From 0871a25215fb468f121785600f796a14b54d8ebc Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 06 六月 2025 15:47:00 +0800
Subject: [PATCH] 1.刀具添加字段 2.新增dnc传输日志表 3.导入NC文件默认产生nc文件对应数控程序加工确认表 4.拆分两网 修改yml配置

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java |   91 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 83 insertions(+), 8 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java
index e108ded..1061927 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java
@@ -5,12 +5,14 @@
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
-import org.jeecg.modules.dnc.entity.GuideCardBatch;
+import org.jeecg.modules.dnc.constant.DocAttributionTypeEnum;
+import org.jeecg.modules.dnc.entity.*;
 import org.jeecg.modules.dnc.mapper.GuideCardBatchMapper;
-import org.jeecg.modules.dnc.service.IGuideCardBatchService;
+import org.jeecg.modules.dnc.service.*;
 import org.jeecg.modules.system.service.ISysDictService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
 import java.util.List;
@@ -27,6 +29,24 @@
     @Autowired
     private ISysDictService sysDictService;
 
+    @Autowired
+    private IDocInfoService docInfoService;
+
+    @Autowired
+    private IDocRelativeService docRelativeService;
+
+    @Autowired
+    private IPartsInfoService partsInfoService;
+
+    @Autowired
+    private IProcessStreamService processStreamService;
+
+    @Autowired
+    private IWorkStepService workStepService;
+
+    @Autowired
+    private IDeviceTypeService deviceTypeService;
+
     /**
      * 鐢熸垚娴佹按鍙�
      * @param code
@@ -42,9 +62,9 @@
 
         // 鏌ヨ褰撳勾鎵�鏈夎褰�
         QueryWrapper<GuideCardBatch> wrapper = new QueryWrapper<>();
-        wrapper.likeRight("create_time", DateUtils.formatDate(new Date(), "yyyy"));
+        wrapper.apply("YEAR(create_time) = YEAR(GETDATE())");
         wrapper.isNotNull("serial_number");
-        wrapper.orderByDesc("SUBSTR(serial_number, -4)");
+        wrapper.orderByDesc("SUBSTRING(serial_number, LEN(serial_number)-3, 4)");
 
         List<GuideCardBatch> list = this.list(wrapper);
 
@@ -62,10 +82,65 @@
             serialSuffix = "0001"; // 褰撳勾鏃犺褰曞垯鍒濆鍖�
         }
 
-        // 鑾峰彇鍗曚綅缂栫爜
-        String unitCode = sysDictService.queryDictTextByKey("unit_code", code);
-
         // 鎷兼帴瀹屾暣缂栧彿
-        return yearSuffix + unitCode + user.getUsername() + serialSuffix;
+        return yearSuffix + code + user.getUsername() + serialSuffix;
+    }
+
+    /**
+     * 瀵煎叆NC鏂囦欢榛樿浜х敓nc鏂囦欢瀵瑰簲鏁版帶绋嬪簭鍔犲伐纭琛�
+     * @param docId
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean importGuideCardBatch(String docId,String attributionId,Integer attributionType){
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        DocInfo docInfo=docInfoService.getById(docId);
+        if (docInfo==null){
+            return false;
+        }
+        PartsInfo partsInfo=new PartsInfo();
+        ProcessStream processStream;
+        WorkStep workStep;
+        DeviceType deviceType;
+        GuideCardBatch guideCardBatch=new GuideCardBatch();
+        if (DocAttributionTypeEnum.PROCESS.getCode().equals(attributionType)){
+            //宸ュ簭璁惧绫�
+            deviceType=deviceTypeService.getById(attributionId);
+            if (deviceType==null){
+                return false;
+            }
+            processStream=processStreamService.getById(deviceType.getAttributionId());
+            if (processStream==null){
+                return false;
+            }
+            guideCardBatch.setProcessWorkCode(processStream.getProcessCode());
+            partsInfo=partsInfoService.getById(processStream.getPartsId());
+        }else if (DocAttributionTypeEnum.WORKSITE.getCode().equals(attributionType)){
+            //宸ユ璁惧绫�
+            deviceType=deviceTypeService.getById(attributionId);
+            if (deviceType==null){
+                return false;
+            }
+            workStep=workStepService.getById(deviceType.getAttributionId());
+            if (workStep==null){
+                return false;
+            }
+            guideCardBatch.setProcessWorkCode(workStep.getStepCode());
+            partsInfo=partsInfoService.getById(workStep.getPartsId());
+        }
+        if (partsInfo==null){
+            return false;
+        }
+        guideCardBatch.setDocId(docId);
+        guideCardBatch.setSerialNumber(getSerialNumber("C140"));
+        guideCardBatch.setUnit(sysDictService.queryDictTextByKey("unit_code", "C140"));
+        guideCardBatch.setDocName(docInfo.getDocName());
+        guideCardBatch.setPartsCode(partsInfo.getPartsCode());
+        guideCardBatch.setPartsName(partsInfo.getPartsName());
+        guideCardBatch.setMaterielDesp(partsInfo.getMaterielDesp());
+        guideCardBatch.setCompiler(user.getUsername());
+        guideCardBatch.setCreateTime(new Date());
+        return this.save(guideCardBatch);
     }
 }

--
Gitblit v1.9.3