新火炬后端单体项目初始化代码
src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java
@@ -10,10 +10,7 @@
import io.micrometer.core.annotation.Timed;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.cms.entity.CuttingInbound;
import org.jeecg.modules.cms.entity.CuttingInboundDetail;
import org.jeecg.modules.cms.entity.CuttingInboundInventory;
import org.jeecg.modules.cms.entity.CuttingInventory;
import org.jeecg.modules.cms.entity.*;
import org.jeecg.modules.cms.mapper.CuttingInboundMapper;
import org.jeecg.modules.cms.service.ICuttingInboundDetailService;
import org.jeecg.modules.cms.service.ICuttingInboundInventoryService;
@@ -142,6 +139,9 @@
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
        cuttingInboundService.removeById(id);
        //删除刀具领用明细表的数据
        cuttingInboundDetailService.remove
                (new QueryWrapper<CuttingInboundDetail>().eq("order_id", id));
        return Result.OK("删除成功!");
    }
@@ -289,64 +289,7 @@
    @GetMapping("/submit")
    @Timed(value = "cutting.inbound.submit", description = "刀具入库提交耗时")
    public Result<?> submit(@RequestParam("orderId") String orderId) {
//        long startTime = System.currentTimeMillis();
//        try {
//            // 1. 更新入库单状态
//            CuttingInbound cuttingInbound = cuttingInboundService.getById(orderId);
//            if (cuttingInbound == null) {
//                return Result.error("未找到对应的入库单");
//            }
//            cuttingInbound.setOrderStatus("2");
//            cuttingInboundService.updateById(cuttingInbound);
//
//            // 2. 获取入库明细
//            List<CuttingInboundDetail> detailList = cuttingInboundDetailService.lambdaQuery()
//                    .eq(CuttingInboundDetail::getOrderId, orderId)
//                    .list();
//
//            // 3. 收集所有需要保存的数据
//            List<CuttingInventory> inventoryList = new ArrayList<>();
//            List<CuttingInboundInventory> inboundInventoryList = new ArrayList<>();
//
//            for (CuttingInboundDetail detail : detailList) {
//                int quantity = detail.getReceiveNumber() != null ? detail.getReceiveNumber().intValue() : 0;
//
//                for (int i = 0; i < quantity; i++) {
//                    // 生成库存记录
//                    CuttingInventory cuttingInventory = new CuttingInventory();
//                    cuttingInventory.setCuttingId(detail.getCuttingId());
//                    cuttingInventory.setCuttingBarcode(generateUniqueBarcode(detail.getCuttingId(), i));
//                    cuttingInventory.setInventoryStatus("正常");
//                    cuttingInventory.setCurrentLife(BigDecimal.valueOf(100));
//                    inventoryList.add(cuttingInventory);
//                }
//            }
//
//            // 4. 批量保存库存记录(一次性操作)
//            if (!inventoryList.isEmpty()) {
//                cuttingInventoryService.saveBatch(inventoryList);
//
//                // 5. 为每个保存的库存记录创建关联关系
//                for (CuttingInventory inventory : inventoryList) {
//                    CuttingInboundInventory cuttingInboundInventory = new CuttingInboundInventory();
//                    cuttingInboundInventory.setOrderId(orderId);
//                    cuttingInboundInventory.setInventoryId(inventory.getId());
//                    inboundInventoryList.add(cuttingInboundInventory);
//                }
//
//                // 6. 批量保存关联关系(一次性操作)
//                cuttingInboundInventoryService.saveBatch(inboundInventoryList);
//            }
//
//            long endTime = System.currentTimeMillis();
//            log.info("刀具入库提交完成,耗时: {} s", (endTime - startTime)/1000);
//            return Result.ok("提交成功");
//
//        } catch (Exception e) {
//            long endTime = System.currentTimeMillis();
//            log.error("提交入库单失败,orderId: " + orderId + ",耗时: " + (endTime - startTime) + " ms", e);
//            return Result.error("提交失败: " + e.getMessage());
//        }
        return cuttingInboundService.submit(orderId);
    }
}