From 2795789b148bd40ecd03fb4d44f5fcd203c268b6 Mon Sep 17 00:00:00 2001
From: lixiangyu <lixiangyu@xalxzn.com>
Date: 星期五, 05 九月 2025 18:02:00 +0800
Subject: [PATCH] refactor(cms): 重构刀具入库提交逻辑

---
 src/main/java/org/jeecg/modules/cms/service/impl/CuttingInboundServiceImpl.java |  134 ++++++--
 src/main/java/org/jeecg/modules/cms/service/ICuttingReceiveDetailService.java   |    3 
 src/main/java/org/jeecg/modules/cms/controller/CuttingReceiveController.java    |  282 +++++++++---------
 src/main/java/org/jeecg/modules/cms/entity/CuttingInventory.java                |   16 
 src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java    |  164 ++--------
 src/main/java/org/jeecg/modules/cms/service/ICuttingInboundService.java         |    2 
 src/main/java/org/jeecg/modules/cms/controller/CuttingToolController.java       |  294 +++++++++---------
 src/main/java/org/jeecg/modules/cms/mapper/CuttingReceiveDetailMapper.java      |    2 
 src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java  |    1 
 9 files changed, 445 insertions(+), 453 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java b/src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java
index 932e249..59b2736 100644
--- a/src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java
+++ b/src/main/java/org/jeecg/modules/cms/controller/CuttingInboundController.java
@@ -279,163 +279,75 @@
 
 
     /*
-     * 鐢熸垚鍞竴鏉$爜鐨勬柟娉�
+     * 鐢熸垚鍞竴鏉$爜鐨勬柟娉曪紙鐩墠杩樻病鏈夌紪鐮佽鍒欙紝纭畾鍚庡湪杩欓噷鏀癸級
      */
     private String generateUniqueBarcode(String cuttingId, int index) {
         // 鏉$爜鐢熸垚瑙勫垯绀轰緥锛氬垁鍏稩D + 搴忓彿(4浣�) + 闅忔満鏁�
         return cuttingId + String.format("%04d", index + 1) + (int) (Math.random() * 10000);
     }
-//    @GetMapping("/submit")
-//    public Result<?> submit(@RequestParam("orderId") String orderId) {
-//        //         cuttingInboundService.submit(orderId);
-//        //         return Result.ok("鎻愪氦鎴愬姛");
+
+    @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("鏈壘鍒板搴旂殑鍏ュ簱鍗�");
 //            }
-//
-//            // 妫�鏌ュ叆搴撳崟鐘舵�侊紝鍙厑璁哥姸鎬佷负"1"鐨勫叆搴撳崟鎻愪氦
-//            if (!"1".equals(cuttingInbound.getOrderStatus())) {
-//                return Result.error("鍙湁鐘舵�佷负鏈彁浜ょ殑鍏ュ簱鍗曟墠鑳芥墽琛屾彁浜ゆ搷浣�");
-//            }
-//
-//            // 2. 鏇存柊鐘舵�佷负宸叉彁浜�
 //            cuttingInbound.setOrderStatus("2");
-//            boolean updateResult = cuttingInboundService.updateById(cuttingInbound);
-//            if (!updateResult) {
-//                return Result.error("鏇存柊鍏ュ簱鍗曠姸鎬佸け璐�");
-//            }
+//            cuttingInboundService.updateById(cuttingInbound);
 //
-//            // 3. 鑾峰彇鍏ュ簱鏄庣粏
+//            // 2. 鑾峰彇鍏ュ簱鏄庣粏
 //            List<CuttingInboundDetail> detailList = cuttingInboundDetailService.lambdaQuery()
 //                    .eq(CuttingInboundDetail::getOrderId, orderId)
 //                    .list();
 //
-//            // 鐢ㄤ簬缁熻鎬绘暟閲�
-//            int totalSubmitted = 0;
-//
-//            // 鎵归噺淇濆瓨鐨勫垪琛�
+//            // 3. 鏀堕泦鎵�鏈夐渶瑕佷繚瀛樼殑鏁版嵁
 //            List<CuttingInventory> inventoryList = new ArrayList<>();
 //            List<CuttingInboundInventory> inboundInventoryList = new ArrayList<>();
 //
-//            // 4. 鏍规嵁鏄庣粏鏁伴噺鐢熸垚搴撳瓨璁板綍鍜屾潯鐮�
 //            for (CuttingInboundDetail detail : detailList) {
-//                // 鏍规嵁鏄庣粏涓殑鏁伴噺鐢熸垚瀵瑰簲鏁伴噺鐨勫簱瀛樿褰時eceive_number
-//                int quantity = detail.getReceiveNumber() != null ? detail.getReceiveNumber() : 0;
-//                for (int i = 0; i < quantity; i++) {
-//                    totalSubmitted++;
-//                    // 涓烘瘡涓垁鍏风敓鎴愮嫭绔嬬殑搴撳瓨璁板綍
-//                    CuttingInventory cuttingInventory = new CuttingInventory();
-//                    String inventoryId = UUID.randomUUID().toString().replace("-", "");
-//                    cuttingInventory.setId(inventoryId);
-//                    cuttingInventory.setCuttingId(detail.getCuttingId());
-//                    // 涓烘瘡涓垁鍏风敓鎴愬敮涓�鏉$爜
-//                    cuttingInventory.setCuttingBarcode(generateUniqueBarcode(detail.getCuttingId(), i));
-//                    // 璁剧疆搴撳瓨鐘舵�佷负鍦ㄥ簱
-//                    cuttingInventory.setInventoryStatus("姝e父");
-//                    // 璁剧疆褰撳墠瀵垮懡涓�100
-//                    cuttingInventory.setCurrentLife(BigDecimal.valueOf(100));
-//                    // 娣诲姞鍒版壒閲忎繚瀛樺垪琛�
-//                    inventoryList.add(cuttingInventory);
+//                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("姝e父");
+//                    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(inventoryId);
-//                    // 娣诲姞鍒版壒閲忎繚瀛樺垪琛�
+//                    cuttingInboundInventory.setInventoryId(inventory.getId());
 //                    inboundInventoryList.add(cuttingInboundInventory);
 //                }
+//
+//                // 6. 鎵归噺淇濆瓨鍏宠仈鍏崇郴锛堜竴娆℃�ф搷浣滐級
+//                cuttingInboundInventoryService.saveBatch(inboundInventoryList);
 //            }
 //
-//            // 鎵归噺淇濆瓨搴撳瓨璁板綍
-//            if (!inventoryList.isEmpty()) {
-//                boolean saveResult = cuttingInventoryService.saveBatch(inventoryList);
-//                if (!saveResult) {
-//                    throw new RuntimeException("淇濆瓨搴撳瓨璁板綍澶辫触");
-//                }
-//            }
+//            long endTime = System.currentTimeMillis();
+//            log.info("鍒�鍏峰叆搴撴彁浜ゅ畬鎴愶紝鑰楁椂: {} s", (endTime - startTime)/1000);
+//            return Result.ok("鎻愪氦鎴愬姛");
 //
-//            // 鎵归噺淇濆瓨鍏宠仈鍏崇郴
-//            if (!inboundInventoryList.isEmpty()) {
-//                boolean relationSaveResult = cuttingInboundInventoryService.saveBatch(inboundInventoryList);
-//                if (!relationSaveResult) {
-//                    throw new RuntimeException("淇濆瓨鍏宠仈鍏崇郴澶辫触");
-//                }
-//            }
-//
-//            Map<String, Object> result = new HashMap<>();
-//            result.put("message", "鎻愪氦鎴愬姛");
-//            result.put("totalSubmitted", totalSubmitted);
-//            return Result.ok(result);
 //        } catch (Exception e) {
-//            log.error("鎻愪氦鍏ュ簱鍗曞け璐ワ紝orderId: " + orderId, e);
-//            throw new RuntimeException("鎻愪氦澶辫触: " + e.getMessage(), e);
+//            long endTime = System.currentTimeMillis();
+//            log.error("鎻愪氦鍏ュ簱鍗曞け璐ワ紝orderId: " + orderId + "锛岃�楁椂: " + (endTime - startTime) + " ms", e);
+//            return Result.error("鎻愪氦澶辫触: " + e.getMessage());
 //        }
-//    }
-
-    @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("姝e父");
-                    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);
     }
 }
 
diff --git a/src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java b/src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java
index 630d7e6..a0e4d74 100644
--- a/src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java
+++ b/src/main/java/org/jeecg/modules/cms/controller/CuttingInventoryController.java
@@ -6,6 +6,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.cms.entity.CuttingInventory;
diff --git a/src/main/java/org/jeecg/modules/cms/controller/CuttingReceiveController.java b/src/main/java/org/jeecg/modules/cms/controller/CuttingReceiveController.java
index 1d78b9f..17ad902 100644
--- a/src/main/java/org/jeecg/modules/cms/controller/CuttingReceiveController.java
+++ b/src/main/java/org/jeecg/modules/cms/controller/CuttingReceiveController.java
@@ -43,141 +43,141 @@
 import io.swagger.annotations.ApiOperation;
 import org.jeecg.common.aspect.annotation.AutoLog;
 
- /**
+/**
  * @Description: 鍒�鍏烽鐢ㄥ崟
  * @Author: jeecg-boot
- * @Date:   2025-07-28
+ * @Date: 2025-07-28
  * @Version: V1.0
  */
-@Api(tags="鍒�鍏烽鐢ㄥ崟")
+@Api(tags = "鍒�鍏烽鐢ㄥ崟")
 @RestController
 @RequestMapping("/cms/cuttingReceive")
 @Slf4j
 public class CuttingReceiveController extends JeecgController<CuttingReceive, ICuttingReceiveService> {
-	@Autowired
-	private ICuttingReceiveService cuttingReceiveService;
+    @Autowired
+    private ICuttingReceiveService cuttingReceiveService;
 
-	 @Autowired
-	 private ICuttingReceiveDetailService cuttingReceiveDetailService;
-	
-	/**
-	 * 鍒嗛〉鍒楄〃鏌ヨ
-	 *
-	 * @param cuttingReceive
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ", notes="鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ")
-	@GetMapping(value = "/list")
-	public Result<IPage<CuttingReceive>> queryPageList(CuttingReceive cuttingReceive,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<CuttingReceive> queryWrapper = QueryGenerator.initQueryWrapper(cuttingReceive, req.getParameterMap());
-		Page<CuttingReceive> page = new Page<CuttingReceive>(pageNo, pageSize);
-		IPage<CuttingReceive> pageList = cuttingReceiveService.page(page, queryWrapper);
-		return Result.OK(pageList);
-	}
-	
-	/**
-	 *   娣诲姞
-	 *
-	 * @param jSONObject
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-娣诲姞")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-娣诲姞", notes="鍒�鍏烽鐢ㄥ崟-娣诲姞")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody JSONObject jSONObject) {
-		CuttingReceive cuttingReceive = jSONObject.toJavaObject(CuttingReceive.class);
-		cuttingReceive.setOrderStatus("1");
-		cuttingReceiveService.saveOrUpdate(cuttingReceive);
-		//鍒犻櫎鍘熷叧鑱旀暟鎹�
-		List<CuttingReceiveDetail> cuttingReceiveDetailList = cuttingReceiveDetailService.lambdaQuery().eq(CuttingReceiveDetail::getOrderId,cuttingReceive.getId()).list();
-		cuttingReceiveDetailService.removeBatchByIds(cuttingReceiveDetailList);
-		//娣诲姞鏂板叧鑱旀暟鎹�
-		JSONArray jsonArray = jSONObject.getJSONArray("detailData");
-		List<CuttingReceiveDetail> list = jsonArray.toJavaList(CuttingReceiveDetail.class);
-		for (int i = 0; i < list.size(); i++) {
-			CuttingReceiveDetail temp = list.get(i);
-			temp.setOrderId(cuttingReceive.getId());
-			cuttingReceiveDetailService.save(temp);
-		}
-		return Result.OK("娣诲姞鎴愬姛锛�");
-	}
-	
-	/**
-	 *  缂栬緫
-	 *
-	 * @param cuttingReceive
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-缂栬緫")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-缂栬緫", notes="鍒�鍏烽鐢ㄥ崟-缂栬緫")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:edit")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody CuttingReceive cuttingReceive) {
-		cuttingReceiveService.updateById(cuttingReceive);
-		return Result.OK("缂栬緫鎴愬姛!");
-	}
-	
-	/**
-	 *   閫氳繃id鍒犻櫎
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎", notes="鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:delete")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		cuttingReceiveService.removeById(id);
-		return Result.OK("鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 *  鎵归噺鍒犻櫎
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎", notes="鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:deleteBatch")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.cuttingReceiveService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 * 閫氳繃id鏌ヨ
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ")
-	@ApiOperation(value="鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ", notes="鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ")
-	@GetMapping(value = "/queryById")
-	public Result<CuttingReceive> queryById(@RequestParam(name="id",required=true) String id) {
-		CuttingReceive cuttingReceive = cuttingReceiveService.getById(id);
-		if(cuttingReceive==null) {
-			return Result.error("鏈壘鍒板搴旀暟鎹�");
-		}
-		return Result.OK(cuttingReceive);
-	}
+    @Autowired
+    private ICuttingReceiveDetailService cuttingReceiveDetailService;
 
     /**
-    * 瀵煎嚭excel
-    *
-    * @param request
-    * @param cuttingReceive
-    */
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     *
+     * @param cuttingReceive
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ", notes = "鍒�鍏烽鐢ㄥ崟-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/list")
+    public Result<IPage<CuttingReceive>> queryPageList(CuttingReceive cuttingReceive,
+                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                       HttpServletRequest req) {
+        QueryWrapper<CuttingReceive> queryWrapper = QueryGenerator.initQueryWrapper(cuttingReceive, req.getParameterMap());
+        Page<CuttingReceive> page = new Page<CuttingReceive>(pageNo, pageSize);
+        IPage<CuttingReceive> pageList = cuttingReceiveService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 娣诲姞
+     *
+     * @param jSONObject
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏烽鐢ㄥ崟-娣诲姞")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-娣诲姞", notes = "鍒�鍏烽鐢ㄥ崟-娣诲姞")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:add")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody JSONObject jSONObject) {
+        CuttingReceive cuttingReceive = jSONObject.toJavaObject(CuttingReceive.class);
+        cuttingReceive.setOrderStatus("1");
+        cuttingReceiveService.saveOrUpdate(cuttingReceive);
+        //鍒犻櫎鍘熷叧鑱旀暟鎹�
+        List<CuttingReceiveDetail> cuttingReceiveDetailList = cuttingReceiveDetailService.lambdaQuery().eq(CuttingReceiveDetail::getOrderId, cuttingReceive.getId()).list();
+        cuttingReceiveDetailService.removeBatchByIds(cuttingReceiveDetailList);
+        //娣诲姞鏂板叧鑱旀暟鎹�
+        JSONArray jsonArray = jSONObject.getJSONArray("detailData");
+        List<CuttingReceiveDetail> list = jsonArray.toJavaList(CuttingReceiveDetail.class);
+        for (int i = 0; i < list.size(); i++) {
+            CuttingReceiveDetail temp = list.get(i);
+            temp.setOrderId(cuttingReceive.getId());
+            cuttingReceiveDetailService.save(temp);
+        }
+        return Result.OK("娣诲姞鎴愬姛锛�");
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param cuttingReceive
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏烽鐢ㄥ崟-缂栬緫")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-缂栬緫", notes = "鍒�鍏烽鐢ㄥ崟-缂栬緫")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody CuttingReceive cuttingReceive) {
+        cuttingReceiveService.updateById(cuttingReceive);
+        return Result.OK("缂栬緫鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎", notes = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        cuttingReceiveService.removeById(id);
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎", notes = "鍒�鍏烽鐢ㄥ崟-鎵归噺鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.cuttingReceiveService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鏌ヨ
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ")
+    @ApiOperation(value = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ", notes = "鍒�鍏烽鐢ㄥ崟-閫氳繃id鏌ヨ")
+    @GetMapping(value = "/queryById")
+    public Result<CuttingReceive> queryById(@RequestParam(name = "id", required = true) String id) {
+        CuttingReceive cuttingReceive = cuttingReceiveService.getById(id);
+        if (cuttingReceive == null) {
+            return Result.error("鏈壘鍒板搴旀暟鎹�");
+        }
+        return Result.OK(cuttingReceive);
+    }
+
+    /**
+     * 瀵煎嚭excel
+     *
+     * @param request
+     * @param cuttingReceive
+     */
     //@RequiresPermissions("org.jeecg.modules:cms_cutting_receive:exportXls")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, CuttingReceive cuttingReceive) {
@@ -185,28 +185,28 @@
     }
 
     /**
-      * 閫氳繃excel瀵煎叆鏁版嵁
-    *
-    * @param request
-    * @param response
-    * @return
-    */
+     * 閫氳繃excel瀵煎叆鏁版嵁
+     *
+     * @param request
+     * @param response
+     * @return
+     */
     //@RequiresPermissions("cms_cutting_receive:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, CuttingReceive.class);
     }
 
-	 /**
-	  * 鏍规嵁棰嗙敤id鏌ヨ棰嗙敤鏄庣粏
-	  *
-	  * @param orderId
-	  * @return
-	  */
-	 @GetMapping("/detailList")
-	 public Result<?> detailList(@RequestParam("orderId") String orderId) {
-		 List<Map<String, Object>> list = cuttingReceiveDetailService.detailList(orderId);
-		 return Result.ok(list);
-	 }
+    /**
+     * 鏍规嵁棰嗙敤id鏌ヨ棰嗙敤鏄庣粏
+     *
+     * @param orderId
+     * @return
+     */
+    @GetMapping("/detailList")
+    public Result<?> detailList(@RequestParam("orderId") String orderId) {
+        List<Map<String, Object>> list = cuttingReceiveDetailService.detailList(orderId);
+        return Result.ok(list);
+    }
 
 }
diff --git a/src/main/java/org/jeecg/modules/cms/controller/CuttingToolController.java b/src/main/java/org/jeecg/modules/cms/controller/CuttingToolController.java
index c7d07ce..d650056 100644
--- a/src/main/java/org/jeecg/modules/cms/controller/CuttingToolController.java
+++ b/src/main/java/org/jeecg/modules/cms/controller/CuttingToolController.java
@@ -40,145 +40,145 @@
 import io.swagger.annotations.ApiOperation;
 import org.jeecg.common.aspect.annotation.AutoLog;
 
- /**
+/**
  * @Description: 鍒�鍏蜂俊鎭�
  * @Author: jeecg-boot
- * @Date:   2025-07-28
+ * @Date: 2025-07-28
  * @Version: V1.0
  */
-@Api(tags="鍒�鍏蜂俊鎭�")
+@Api(tags = "鍒�鍏蜂俊鎭�")
 @RestController
 @RequestMapping("/cms/cuttingTool")
 @Slf4j
 public class CuttingToolController extends JeecgController<CuttingTool, ICuttingToolService> {
-	@Autowired
-	private ICuttingToolService cuttingToolService;
+    @Autowired
+    private ICuttingToolService cuttingToolService;
 
-	 @Autowired
-	 private ICuttingPropertiesService cuttingPropertiesService;
-	
-	/**
-	 * 鍒嗛〉鍒楄〃鏌ヨ
-	 *
-	 * @param cuttingTool
-	 * @param pageNo
-	 * @param pageSize
-	 * @param req
-	 * @return
-	 */
-	//@AutoLog(value = "鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes="鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
-	@GetMapping(value = "/list")
-	public Result<IPage<CuttingTool>> queryPageList(CuttingTool cuttingTool,
-								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
-								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-								   HttpServletRequest req) {
-		QueryWrapper<CuttingTool> queryWrapper = QueryGenerator.initQueryWrapper(cuttingTool, req.getParameterMap());
-		Page<CuttingTool> page = new Page<CuttingTool>(pageNo, pageSize);
-		IPage<CuttingTool> pageList = cuttingToolService.page(page, queryWrapper);
-		return Result.OK(pageList);
-	}
-	
-	/**
-	 *   娣诲姞
-	 *
-	 * @param cuttingTool
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏蜂俊鎭�-娣诲姞")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-娣诲姞", notes="鍒�鍏蜂俊鎭�-娣诲姞")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:add")
-	@PostMapping(value = "/add")
-	public Result<String> add(@RequestBody CuttingTool cuttingTool) {
-		cuttingToolService.save(cuttingTool);
-		List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList();
-		for (CuttingProperties cuttingProperties : cuttingPropertiesList) {
-			cuttingProperties.setCuttingId(cuttingTool.getId());
-			cuttingPropertiesService.save(cuttingProperties);
-		}
-		return Result.OK("娣诲姞鎴愬姛锛�");
-	}
-	
-	/**
-	 *  缂栬緫
-	 *
-	 * @param cuttingTool
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏蜂俊鎭�-缂栬緫")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-缂栬緫", notes="鍒�鍏蜂俊鎭�-缂栬緫")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:edit")
-	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
-	public Result<String> edit(@RequestBody CuttingTool cuttingTool) {
-		cuttingToolService.saveOrUpdate(cuttingTool);
-		List<String> deletePropertiesIds = cuttingTool.getDeletePropertiesIds();
-		if (deletePropertiesIds != null) {
-			for (String deletePropertiesId : deletePropertiesIds) {
-				cuttingPropertiesService.removeById(deletePropertiesId);
-			}
-		}
-		List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList();
-		for (CuttingProperties cuttingProperties : cuttingPropertiesList) {
-			cuttingProperties.setCuttingId(cuttingTool.getId());
-			cuttingPropertiesService.saveOrUpdate(cuttingProperties);
-		}
-		return Result.OK("缂栬緫鎴愬姛!");
-	}
-	
-	/**
-	 *   閫氳繃id鍒犻櫎
-	 *
-	 * @param id
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎", notes="鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:delete")
-	@DeleteMapping(value = "/delete")
-	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
-		cuttingToolService.removeById(id);
-		cuttingPropertiesService.remove(new LambdaQueryWrapper<CuttingProperties>().eq(CuttingProperties::getCuttingId, id));
-		return Result.OK("鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 *  鎵归噺鍒犻櫎
-	 *
-	 * @param ids
-	 * @return
-	 */
-	@AutoLog(value = "鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎", notes="鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎")
-	//@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:deleteBatch")
-	@DeleteMapping(value = "/deleteBatch")
-	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.cuttingToolService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
-	}
-	
-	/**
-	 * 閫氳繃id鏌ヨ
-	 *
-	 * @param id
-	 * @return
-	 */
-	//@AutoLog(value = "鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ")
-	@ApiOperation(value="鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ", notes="鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ")
-	@GetMapping(value = "/queryById")
-	public Result<CuttingTool> queryById(@RequestParam(name="id",required=true) String id) {
-		CuttingTool cuttingTool = cuttingToolService.getById(id);
-		if(cuttingTool==null) {
-			return Result.error("鏈壘鍒板搴旀暟鎹�");
-		}
-		return Result.OK(cuttingTool);
-	}
+    @Autowired
+    private ICuttingPropertiesService cuttingPropertiesService;
 
     /**
-    * 瀵煎嚭excel
-    *
-    * @param request
-    * @param cuttingTool
-    */
+     * 鍒嗛〉鍒楄〃鏌ヨ
+     *
+     * @param cuttingTool
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    //@AutoLog(value = "鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ", notes = "鍒�鍏蜂俊鎭�-鍒嗛〉鍒楄〃鏌ヨ")
+    @GetMapping(value = "/list")
+    public Result<IPage<CuttingTool>> queryPageList(CuttingTool cuttingTool,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        QueryWrapper<CuttingTool> queryWrapper = QueryGenerator.initQueryWrapper(cuttingTool, req.getParameterMap());
+        Page<CuttingTool> page = new Page<CuttingTool>(pageNo, pageSize);
+        IPage<CuttingTool> pageList = cuttingToolService.page(page, queryWrapper);
+        return Result.OK(pageList);
+    }
+
+    /**
+     * 娣诲姞
+     *
+     * @param cuttingTool
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏蜂俊鎭�-娣诲姞")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-娣诲姞", notes = "鍒�鍏蜂俊鎭�-娣诲姞")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:add")
+    @PostMapping(value = "/add")
+    public Result<String> add(@RequestBody CuttingTool cuttingTool) {
+        cuttingToolService.save(cuttingTool);
+        List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList();
+        for (CuttingProperties cuttingProperties : cuttingPropertiesList) {
+            cuttingProperties.setCuttingId(cuttingTool.getId());
+            cuttingPropertiesService.save(cuttingProperties);
+        }
+        return Result.OK("娣诲姞鎴愬姛锛�");
+    }
+
+    /**
+     * 缂栬緫
+     *
+     * @param cuttingTool
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏蜂俊鎭�-缂栬緫")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-缂栬緫", notes = "鍒�鍏蜂俊鎭�-缂栬緫")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:edit")
+    @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
+    public Result<String> edit(@RequestBody CuttingTool cuttingTool) {
+        cuttingToolService.saveOrUpdate(cuttingTool);
+        List<String> deletePropertiesIds = cuttingTool.getDeletePropertiesIds();
+        if (deletePropertiesIds != null) {
+            for (String deletePropertiesId : deletePropertiesIds) {
+                cuttingPropertiesService.removeById(deletePropertiesId);
+            }
+        }
+        List<CuttingProperties> cuttingPropertiesList = cuttingTool.getCuttingPropertiesList();
+        for (CuttingProperties cuttingProperties : cuttingPropertiesList) {
+            cuttingProperties.setCuttingId(cuttingTool.getId());
+            cuttingPropertiesService.saveOrUpdate(cuttingProperties);
+        }
+        return Result.OK("缂栬緫鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鍒犻櫎
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎", notes = "鍒�鍏蜂俊鎭�-閫氳繃id鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:delete")
+    @DeleteMapping(value = "/delete")
+    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
+        cuttingToolService.removeById(id);
+        cuttingPropertiesService.remove(new LambdaQueryWrapper<CuttingProperties>().eq(CuttingProperties::getCuttingId, id));
+        return Result.OK("鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎", notes = "鍒�鍏蜂俊鎭�-鎵归噺鍒犻櫎")
+    //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:deleteBatch")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        this.cuttingToolService.removeByIds(Arrays.asList(ids.split(",")));
+        return Result.OK("鎵归噺鍒犻櫎鎴愬姛!");
+    }
+
+    /**
+     * 閫氳繃id鏌ヨ
+     *
+     * @param id
+     * @return
+     */
+    //@AutoLog(value = "鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ")
+    @ApiOperation(value = "鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ", notes = "鍒�鍏蜂俊鎭�-閫氳繃id鏌ヨ")
+    @GetMapping(value = "/queryById")
+    public Result<CuttingTool> queryById(@RequestParam(name = "id", required = true) String id) {
+        CuttingTool cuttingTool = cuttingToolService.getById(id);
+        if (cuttingTool == null) {
+            return Result.error("鏈壘鍒板搴旀暟鎹�");
+        }
+        return Result.OK(cuttingTool);
+    }
+
+    /**
+     * 瀵煎嚭excel
+     *
+     * @param request
+     * @param cuttingTool
+     */
     //@RequiresPermissions("org.jeecg.modules:cms_cutting_tool:exportXls")
     @RequestMapping(value = "/exportXls")
     public ModelAndView exportXls(HttpServletRequest request, CuttingTool cuttingTool) {
@@ -186,30 +186,30 @@
     }
 
     /**
-      * 閫氳繃excel瀵煎叆鏁版嵁
-    *
-    * @param request
-    * @param response
-    * @return
-    */
+     * 閫氳繃excel瀵煎叆鏁版嵁
+     *
+     * @param request
+     * @param response
+     * @return
+     */
     //@RequiresPermissions("cms_cutting_tool:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
         return super.importExcel(request, response, CuttingTool.class);
     }
 
-
-	 @GetMapping(value = "/getCuttingToolList")
-	 public Result<?> getCuttingToolList(@RequestParam("pageNo") Integer pageNo,
-									   @RequestParam("pageSize") Integer pageSize,
-									   @RequestParam Map<String, Object> params) {
-		 IPage<Map<String, Object>> cuttingToolList = cuttingToolService.getCuttingToolList(pageNo, pageSize, params);
-		 for (Map<String, Object> record : cuttingToolList.getRecords()) {
-			 String cuttingId = (String) record.get("id");
-			 List<CuttingProperties> cuttingPropertiesList = cuttingPropertiesService.selectListByCuttingId(cuttingId);
-			 record.put("cuttingPropertiesList", cuttingPropertiesList);
-		 }
-		 return Result.ok(cuttingToolList);
-	 }
+    //閫夋嫨鍒�鍏风殑鎺ュ彛
+    @GetMapping(value = "/getCuttingToolList")
+    public Result<?> getCuttingToolList(@RequestParam("pageNo") Integer pageNo,
+                                        @RequestParam("pageSize") Integer pageSize,
+                                        @RequestParam Map<String, Object> params) {
+        IPage<Map<String, Object>> cuttingToolList = cuttingToolService.getCuttingToolList(pageNo, pageSize, params);
+        for (Map<String, Object> record : cuttingToolList.getRecords()) {
+            String cuttingId = (String) record.get("id");
+            List<CuttingProperties> cuttingPropertiesList = cuttingPropertiesService.selectListByCuttingId(cuttingId);
+            record.put("cuttingPropertiesList", cuttingPropertiesList);
+        }
+        return Result.ok(cuttingToolList);
+    }
 
 }
diff --git a/src/main/java/org/jeecg/modules/cms/entity/CuttingInventory.java b/src/main/java/org/jeecg/modules/cms/entity/CuttingInventory.java
index f9c7d7b..61c03b7 100644
--- a/src/main/java/org/jeecg/modules/cms/entity/CuttingInventory.java
+++ b/src/main/java/org/jeecg/modules/cms/entity/CuttingInventory.java
@@ -4,10 +4,8 @@
 import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.math.BigDecimal;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableLogic;
+
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
@@ -57,6 +55,9 @@
     @ApiModelProperty(value = "鍒�鍏稩D")
     @Dict(dictTable = "cms_cutting_tool",dicCode="id",dicText = "cutting_code")
     private String cuttingId;
+
+    @TableField(exist = false) // 琛ㄧず杩欎笉鏄暟鎹簱瀛楁
+    private String cuttingCode;
 	/**鍒�鍏锋潯鐮�*/
 	@Excel(name = "鍒�鍏锋潯鐮�", width = 15)
     @ApiModelProperty(value = "鍒�鍏锋潯鐮�")
@@ -69,4 +70,11 @@
 	@Excel(name = "褰撳墠瀵垮懡(鐧惧垎姣�)", width = 15)
     @ApiModelProperty(value = "褰撳墠瀵垮懡(鐧惧垎姣�)")
     private BigDecimal currentLife;
+
+    // 鍦–uttingInventory瀹炰綋绫讳腑娣诲姞
+    @TableField(exist = false) // 琛ㄧず杩欎笉鏄暟鎹簱瀛楁
+    private String cuttingIdSearch;
+
+    @TableField(exist = false) // 琛ㄧず杩欎笉鏄暟鎹簱瀛楁
+    private String cuttingBarcodeSearch;
 }
diff --git a/src/main/java/org/jeecg/modules/cms/mapper/CuttingReceiveDetailMapper.java b/src/main/java/org/jeecg/modules/cms/mapper/CuttingReceiveDetailMapper.java
index 9113c5c..b134181 100644
--- a/src/main/java/org/jeecg/modules/cms/mapper/CuttingReceiveDetailMapper.java
+++ b/src/main/java/org/jeecg/modules/cms/mapper/CuttingReceiveDetailMapper.java
@@ -15,5 +15,5 @@
  */
 public interface CuttingReceiveDetailMapper extends BaseMapper<CuttingReceiveDetail> {
 
-    public List<Map<String, Object>> detailList(@Param("orderId") String orderId);
+    List<Map<String, Object>> detailList(@Param("orderId") String orderId);
 }
diff --git a/src/main/java/org/jeecg/modules/cms/service/ICuttingInboundService.java b/src/main/java/org/jeecg/modules/cms/service/ICuttingInboundService.java
index c01d8f1..fd30f93 100644
--- a/src/main/java/org/jeecg/modules/cms/service/ICuttingInboundService.java
+++ b/src/main/java/org/jeecg/modules/cms/service/ICuttingInboundService.java
@@ -15,4 +15,6 @@
  */
 public interface ICuttingInboundService extends IService<CuttingInbound> {
     Result<?> importExcelData(List<CuttingInboundExportVo> list);
+
+    Result<?> submit(String orderId);
 }
diff --git a/src/main/java/org/jeecg/modules/cms/service/ICuttingReceiveDetailService.java b/src/main/java/org/jeecg/modules/cms/service/ICuttingReceiveDetailService.java
index 1f02463..cb6f87f 100644
--- a/src/main/java/org/jeecg/modules/cms/service/ICuttingReceiveDetailService.java
+++ b/src/main/java/org/jeecg/modules/cms/service/ICuttingReceiveDetailService.java
@@ -7,6 +7,7 @@
 import java.util.Map;
 
 /**
+ *
  * @Description: 棰嗙敤鍗曟槑缁�
  * @Author: jeecg-boot
  * @Date:   2025-07-28
@@ -14,5 +15,5 @@
  */
 public interface ICuttingReceiveDetailService extends IService<CuttingReceiveDetail> {
 
-    public List<Map<String, Object>> detailList(String orderId);
+    List<Map<String, Object>> detailList(String orderId);
 }
diff --git a/src/main/java/org/jeecg/modules/cms/service/impl/CuttingInboundServiceImpl.java b/src/main/java/org/jeecg/modules/cms/service/impl/CuttingInboundServiceImpl.java
index 991f67f..17ded30 100644
--- a/src/main/java/org/jeecg/modules/cms/service/impl/CuttingInboundServiceImpl.java
+++ b/src/main/java/org/jeecg/modules/cms/service/impl/CuttingInboundServiceImpl.java
@@ -1,17 +1,25 @@
 package org.jeecg.modules.cms.service.impl;
 
+import io.micrometer.core.annotation.Timed;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 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.mapper.CuttingInboundMapper;
+import org.jeecg.modules.cms.service.ICuttingInboundInventoryService;
 import org.jeecg.modules.cms.service.ICuttingInboundService;
 import org.jeecg.modules.cms.service.ICuttingInboundDetailService;
+import org.jeecg.modules.cms.service.ICuttingInventoryService;
 import org.jeecg.modules.cms.vo.CuttingInboundExportVo;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,10 +30,18 @@
  * @Date:   2025-07-28
  * @Version: V1.0
  */
+
+@Slf4j
 @Service
 public class CuttingInboundServiceImpl extends ServiceImpl<CuttingInboundMapper, CuttingInbound> implements ICuttingInboundService {
     @Autowired
     private ICuttingInboundDetailService cuttingInboundDetailService; // 娉ㄥ叆浠庤〃鏈嶅姟
+
+    @Autowired
+    private ICuttingInventoryService cuttingInventoryService;
+
+    @Autowired
+    private ICuttingInboundInventoryService cuttingInboundInventoryService;
     /**
      * 閫氳繃Excel瀵煎叆鍒�鍏峰叆搴撳崟鏁版嵁
      *
@@ -35,39 +51,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Result<?> importExcelData(List<CuttingInboundExportVo> list) {
-//        try {
-//            for (CuttingInboundExportVo exportVo : list) {
-//                // 淇濆瓨涓昏〃鏁版嵁
-//                CuttingInbound cuttingInbound = new CuttingInbound();
-//                cuttingInbound.setReceiver(exportVo.getReceiver());
-//                cuttingInbound.setReceiveTime(exportVo.getReceiveTime());
-//                cuttingInbound.setReceiveComment(exportVo.getReceiveComment());
-//                cuttingInbound.setConfirmer(exportVo.getConfirmer());
-//                cuttingInbound.setConfirmTime(exportVo.getConfirmTime());
-//                cuttingInbound.setConfirmComment(exportVo.getConfirmComment());
-//                cuttingInbound.setOrderStatus(exportVo.getOrderStatus());
-//
-//                // 淇濆瓨涓昏〃鏁版嵁浠ヨ幏鍙朓D
-//                this.save(cuttingInbound);
-//
-//                // 鑾峰彇涓昏〃ID
-//                String orderId = cuttingInbound.getId();
-//
-//                // 澶勭悊浠庤〃鏁版嵁
-//                List<CuttingInboundDetail> detailList = exportVo.getDetailList();
-//                if (detailList != null && !detailList.isEmpty()) {
-//                    for (CuttingInboundDetail detail : detailList) {
-//                        detail.setOrderId(orderId); // 璁剧疆澶栭敭鍏宠仈
-//                        cuttingInboundDetailService.save(detail);
-//                    }
-//                }
-//            }
-//            return Result.ok("瀵煎叆鎴愬姛");
-//        } catch (Exception e) {
-//            log.error("瀵煎叆澶辫触", e);
-//            return Result.error("瀵煎叆澶辫触: " + e.getMessage());
-//        }
-//    }
+
         for (CuttingInboundExportVo exportVo : list) {
             // 淇濆瓨涓昏〃鏁版嵁
             CuttingInbound cuttingInbound = new CuttingInbound();
@@ -96,4 +80,88 @@
         }
         return Result.ok("瀵煎叆鎴愬姛");
     }
+
+
+    /*
+     * 鐢熸垚鍞竴鏉$爜鐨勬柟娉曪紙纭畾缂栫爜鐢熸垚瑙勫垯鍚庡湪姝ゅ閲嶅啓锛�
+     */
+    private String generateUniqueBarcode(String cuttingId, int index) {
+        // 鏉$爜鐢熸垚瑙勫垯绀轰緥锛氬垁鍏稩D + 搴忓彿(4浣�) + 闅忔満鏁�
+        return cuttingId + String.format("%04d", index + 1) + (int) (Math.random() * 10000);
+    }
+    @Override
+    @Timed(value = "cutting.inbound.submit", description = "鍒�鍏峰叆搴撴彁浜よ�楁椂")
+    public synchronized Result<?> submit(String orderId) {
+        long startTime = System.currentTimeMillis();
+        try {
+            // 1. 鏇存柊鍏ュ簱鍗曠姸鎬�
+            CuttingInbound cuttingInbound = this.getById(orderId);
+            if (cuttingInbound == null) {
+                return Result.error("鏈壘鍒板搴旂殑鍏ュ簱鍗�");
+            }
+
+            // 妫�鏌ュ叆搴撳崟鐘舵�侊紝鍙厑璁哥姸鎬佷负"1"鐨勫叆搴撳崟鎻愪氦
+            if (!"1".equals(cuttingInbound.getOrderStatus())) {
+                return Result.error("鍙湁鐘舵�佷负鏈彁浜ょ殑鍏ュ簱鍗曟墠鑳芥墽琛屾彁浜ゆ搷浣�");
+            }
+
+            cuttingInbound.setOrderStatus("2");
+            boolean updateResult = this.updateById(cuttingInbound);
+            if (!updateResult) {
+                return Result.error("鏇存柊鍏ュ簱鍗曠姸鎬佸け璐ワ紝鍙兘宸茶鍏朵粬鐢ㄦ埛澶勭悊");
+            }
+
+            // 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("姝e父");
+                    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("鍒�鍏峰叆搴撴彁浜ゅ畬鎴愶紝鑰楁椂: {} ms", (endTime - startTime));
+            return Result.ok("鎻愪氦鎴愬姛");
+
+        } catch (Exception e) {
+            long endTime = System.currentTimeMillis();
+            log.error("鎻愪氦鍏ュ簱鍗曞け璐ワ紝orderId: " + orderId + "锛岃�楁椂: " + (endTime - startTime) + " ms", e);
+            return Result.error("鎻愪氦澶辫触: " + e.getMessage());
+        }
+    }
+
+
+
+
 }

--
Gitblit v1.9.3