From 5e6c3ac5d7c7a2702a0bad5195e954c9e95d2306 Mon Sep 17 00:00:00 2001
From: Houjie <714924425@qq.com>
Date: 星期日, 15 六月 2025 17:55:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java
index 2d1c271..9dbdaec 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/CutterServiceImpl.java
@@ -10,15 +10,19 @@
 import org.jeecg.modules.dnc.entity.Cutter;
 import org.jeecg.modules.dnc.entity.DocFile;
 import org.jeecg.modules.dnc.entity.DocInfo;
+import org.jeecg.modules.dnc.entity.GuideCardBatch;
 import org.jeecg.modules.dnc.exception.ExceptionCast;
 import org.jeecg.modules.dnc.mapper.CutterMapper;
 import org.jeecg.modules.dnc.response.CommonCode;
 import org.jeecg.modules.dnc.service.ICutterService;
 import org.jeecg.modules.dnc.service.IDocFileService;
 import org.jeecg.modules.dnc.service.IDocInfoService;
+import org.jeecg.modules.dnc.service.IGuideCardBatchService;
 import org.jeecg.modules.dnc.utils.ValidateUtil;
 import org.jeecg.modules.dnc.utils.file.FileUtilS;
-import org.jeecg.modules.system.service.ISysDictService;
+import org.jeecg.modules.tms.entity.PreparationOrderDetail;
+import org.jeecg.modules.tms.entity.dto.PreparationOrderAndDetailDto;
+import org.jeecg.modules.tms.service.IPreparationOrderService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -40,8 +44,10 @@
     private IDocFileService docFileService;
 
     @Autowired
-    private ISysDictService sysDictService;
+    private IGuideCardBatchService guideCardBatchService;
 
+    @Autowired
+    private IPreparationOrderService preparationOrderService;
     /**
      * 鏂板鍒�鍏蜂俊鎭�
      * @param cutter
@@ -194,13 +200,54 @@
                 return Result.error("鏈彂鐜板垁鍏风殑鍙傛暟淇℃伅娉ㄩ噴锛屾棤娉曟彁鍙栧垁鍏蜂俊鎭�");
             }
             this.saveBatch(newCutterList);
-            //TODO鍙戦�佸垁鍏风鐞嗘暟鎹�
             return Result.OK("鎻愬彇鍒�鍏蜂俊鎭垚鍔�");
         }else {
             return Result.error("鏈彂鐜板垁鍏风殑鍙傛暟淇℃伅娉ㄩ噴锛屾棤娉曟彁鍙栧垁鍏蜂俊鎭�");
         }
     }
 
+    @Override
+    public Result<?> sendToCutterSystem(String docId,String attributionId,Integer attributionType){
+        List<Cutter> cutterList = this.list(new QueryWrapper<Cutter>()
+                .eq("doc_id", docId)
+                .eq(StrUtil.isNotEmpty(attributionId),"attribution_id",attributionId)
+                .eq("attribution_type",attributionType));
+        if (cutterList == null || cutterList.isEmpty()) {
+            return Result.error("鏈彂鐜板垁鍏蜂俊鎭紝鏃犳硶鍙戦�佸埌鍒�鍏风郴缁�");
+        }
+        if (cutterList.stream().anyMatch(item -> item.getCutterCode() == null)) {
+            return Result.error("鏈彂鐜板垁鍏风紪鍙蜂俊鎭紝鏃犳硶鍙戦�佸埌鍒�鍏风郴缁�");
+        }
+        //鑾峰彇鏈�鏂版暟鎺х▼搴忓姞宸ョ‘璁よ〃
+        List<GuideCardBatch> guideCardBatchList = guideCardBatchService.list(new QueryWrapper<GuideCardBatch>()
+                .eq("doc_id", docId)
+                .isNotNull("serial_number")
+                .orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)"));
+        if (guideCardBatchList == null || guideCardBatchList.isEmpty()) {
+            return Result.error("鏈彂鐜扮▼搴忓姞宸ョ‘璁よ〃淇℃伅锛屾棤娉曞彂閫佸埌鍒�鍏风郴缁�");
+        }
+        GuideCardBatch guideCardBatch = guideCardBatchList.get(0);
+        PreparationOrderAndDetailDto dto = new PreparationOrderAndDetailDto();
+        dto.setPartDrawingNo(guideCardBatch.getPartsCode());
+        dto.setPartName(guideCardBatch.getPartsName());
+        dto.setPartMaterial(guideCardBatch.getMaterielDesp());
+        dto.setProductionProcessesNo(guideCardBatch.getProcessWorkCode());
+        dto.setBatchCode(guideCardBatch.getProcessingBatch());
+        dto.setMachiningCount(guideCardBatch.getProcessingQuantity());
+        dto.setEquipmentCode(guideCardBatch.getProcessingEquipment());
+        dto.setNcName(guideCardBatch.getDocName());
+        List<PreparationOrderDetail> detailList = new ArrayList<>();
+        cutterList.forEach(item -> {
+            PreparationOrderDetail detail = new PreparationOrderDetail();
+            detail.setToolCode(item.getCutterCode());
+            detail.setToolId(item.getToolsId());
+            detailList.add(detail);
+        });
+        dto.setPreparationOrderDetailList(detailList);
+        preparationOrderService.addPreparationOrderFromDnc(dto);
+        return Result.OK("鍙戦�佸埌鍒�鍏风郴缁熸垚鍔�");
+    }
+
     public List<Cutter> extractToolAfterM6(DocInfo docInfo, List<String> ncLines) {
         List<Cutter> cutterList = new ArrayList<>();
         String currentToolCode = null; // 鐢ㄤ簬杩借釜褰撳墠鎹㈠垁鎸囦护鐨勫垁鍏峰彿

--
Gitblit v1.9.3