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/dncFlow/service/impl/AssignFileStreamServiceImpl.java |  158 +++++++++++++++++++++++-----------------------------
 1 files changed, 70 insertions(+), 88 deletions(-)

diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
index 49e51e3..a287e73 100644
--- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -44,7 +44,7 @@
 import org.jeecg.modules.flowable.service.IFlowTaskService;
 import org.jeecg.modules.mdc.entity.MdcEquipment;
 import org.jeecg.modules.mdc.service.IMdcEquipmentService;
-import org.jeecg.modules.system.entity.MdcProduction;
+import org.jeecg.modules.message.enums.DeployEnum;
 import org.jeecg.modules.system.service.IMdcProductionService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -75,10 +75,6 @@
     @Autowired
     private IProcessStreamService processStreamService;
     @Autowired
-    private IWorkStepService workStepService;
-    @Autowired
-    private IPermissionStreamNewService permissionStreamNewService;
-    @Autowired
     private IDocClassificationService classificationService;
     @Autowired
     private IToEquipmentTaskService equipmentTaskService;
@@ -105,14 +101,17 @@
     @Autowired
     private IFlowTaskService flowTaskService;
     @Autowired
-    private IDeviceTypeService deviceTypeService;
-    @Autowired
     private IFlowMyBusinessService flowMyBusinessService;
-
-    @Value("${securedoc.whether}")
-    private String whether;
-    @Value("${securedoc.localFilePath}")
-    private String localFilePath;
+    @Autowired
+    private PermissionService permissionService;
+    @Autowired
+    private IDncPassLogService dncPassLogService;
+    @Value("${deploy.deployType}")
+    //宸ユ帶缃�/娑夊瘑缃戦儴缃� 0涓哄伐鎺х綉 1涓烘秹瀵嗙綉
+    private String deployType;
+    @Value("${deploy.secretFolder}")
+    //娑夊瘑缃戜紶杈搉c鏂囦欢澶�
+    private String secretFolder;
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
@@ -263,7 +262,10 @@
 
         }
         handleFileTransfer(mdcEquipment, docFile);
-        handleFileProcessing(docFile, mdcEquipment, whether, localFilePath);
+        //娉ㄦ剰----鍖哄垎宸ユ帶缃戜笌娑夊瘑缃戯紒锛侊紒  娑夊瘑缃戣繘琛孨C鏂囦欢鐨勬嫹璐濓紝宸ユ帶缃戣礋璐h繘琛岃В鏋怤C鏂囦欢
+        if (deployType.equals(DeployEnum.SMW.getCode())) {
+            handleFileProcessing(docFile, mdcEquipment, secretFolder);
+        }
         synchronizedFlagService.updateFlag(2);
         return Result.OK("鎿嶄綔鎴愬姛");
     }
@@ -332,16 +334,10 @@
         if(!b)
             ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
         if(up.getStatus() == 2) {
-            DocInfo docInfo;
             //鍚屾剰鎿嶄綔
-            if (StrUtil.isNotEmpty(en.getStepId())){
-                //宸ユ涓嬭澶囩被鎸囨淳
-                docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 6, en.getDeviceTypeId());
-            }else {
-                docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), 5, en.getDeviceTypeId());
-            }
-            if(docInfo == null || docInfo.getDocStatus() == 3)
-                               ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR);
+            DocInfo docInfo = docInfoService.getByDocAttrAndDocId(en.getDocId(), Integer.valueOf(en.getAttributionType()), en.getAttributionId());
+            if(docInfo == null )
+               ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR);
             MdcEquipment mdcEquipment = iMdcEquipmentService.getById(en.getDeviceId());
             if(mdcEquipment == null)
                 ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE);
@@ -391,6 +387,10 @@
                                 docFile.getFileName(),docFile.getFileSuffix());
                     }
                 }
+            }
+            //娉ㄦ剰----鍖哄垎宸ユ帶缃戜笌娑夊瘑缃戯紒锛侊紒  娑夊瘑缃戣繘琛孨C鏂囦欢鐨勬嫹璐濓紝宸ユ帶缃戣礋璐h繘琛岃В鏋怤C鏂囦欢
+            if (deployType.equals(DeployEnum.SMW.getCode())) {
+                handleFileProcessing(docFile, mdcEquipment, secretFolder);
             }
             return synchronizedFlagService.updateFlag(1);
         }else if(up.getStatus() == 3) {
@@ -593,69 +593,12 @@
     }
 
     private PermissionStreamNew getPermissionStreams(AssignFileStream stream) {
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        DeviceType deviceType = deviceTypeService.getById(stream.getAttributionId());
-        String attributionId = deviceType != null ? deviceType.getAttributionId() : stream.getAttributionId();
-
-        PermissionStreamNew permissionStreams;
-        if (stream.getAttributionType().equals("5")) {
-            // 宸ュ簭
-            permissionStreams = handleProcess(stream, attributionId, user);
-        } else {
-            // 宸ユ
-            permissionStreams = handleWorkStep(stream, attributionId, user);
-        }
-        if (permissionStreams == null) {
+        PermissionStreamNew permissionStreamNew = permissionService.getPermissionStreams(stream);
+        if (permissionStreamNew  == null) {
             ExceptionCast.cast(ActivitiCode.ACT_NODE_DEPART_NONE);
         }
-        return permissionStreams;
+        return permissionStreamNew ;
     }
-
-    private PermissionStreamNew handleProcess(AssignFileStream stream, String attributionId, LoginUser user) {
-        ProcessStream processStream = processStreamService.getById(attributionId);
-        if (processStream == null) {
-            ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        }
-        stream.setProductId(processStream.getProductId());
-        stream.setComponentId(processStream.getComponentId());
-        stream.setPartsId(processStream.getPartsId());
-        stream.setProcessId(processStream.getProcessId());
-        if (deviceTypeService.getById(stream.getAttributionId()) != null) {
-            stream.setDeviceTypeId(deviceTypeService.getById(stream.getAttributionId()).getId());
-        }
-        return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(processStream.getProcessId(), user.getId(), "5");
-    }
-
-    private PermissionStreamNew handleWorkStep(AssignFileStream stream, String attributionId, LoginUser user) {
-        WorkStep workStep = workStepService.getById(attributionId);
-        if (workStep == null) {
-            ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        }
-        stream.setProductId(workStep.getProductId());
-        stream.setComponentId(workStep.getComponentId());
-        stream.setPartsId(workStep.getPartsId());
-        stream.setProcessId(workStep.getProcessId());
-        stream.setStepId(workStep.getId());
-        if (deviceTypeService.getById(stream.getAttributionId()) != null) {
-            stream.setDeviceTypeId(deviceTypeService.getById(stream.getAttributionId()).getId());
-        }
-        return permissionStreamNewService.loadPermissionStreamNewByBusinessIdAndUserId(workStep.getId(), user.getId(), "6");
-    }
-
-    //鑾峰彇閮ㄩ棬淇℃伅
-    //todo 淇敼
-    private List<String> getDepartIds(List<PermissionStream> permissionStreams, String userId) {
-        Map<String, MdcProduction> map = iMdcProductionService.getUserAssignedDepart(userId);
-        List<String> departIds = permissionStreams.stream()
-                .filter(item -> map.containsKey(item.getDepartId()))
-                .map(PermissionStream::getDepartId)
-                .collect(Collectors.toList());
-        if (departIds.isEmpty()) {
-            ExceptionCast.cast(ActivitiCode.ACT_USER_NOT_PERM);
-        }
-        return departIds;
-    }
-
 
     //灏佽鏁版嵁
     private void saveBusinessObject(AssignFileStream stream, String userId) {
@@ -718,22 +661,61 @@
     }
 
     //灏佽澶勭悊鏂囦欢
-    private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String whether, String localFilePath) {
-        if (whether.equals("true") && !docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) {
+    private void handleFileProcessing(DocFile docFile, MdcEquipment mdcEquipment, String secretFolder) {
+        if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) {
             String size = FileUtilS.fileSizeNC(docFile.getFilePath(), docFile.getFileEncodeName());
             List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
             if (strings != null && !strings.isEmpty()) {
+                DncPassLog passInfoTxt = new DncPassLog();
+
                 String path = StringUtils.join(strings.toArray(), "/");
                 Date dateFirst = DateUtil.getNow();
+                passInfoTxt.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                /*鏌ヨ鏈�鍚庝竴鏉¤褰�*/
+                //浼戠湢 500姣
+                DncPassLog dncPassLog  = dncPassLogService.findDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                int fileTxt = 0, fileNc =0;
+                if (dncPassLog !=null) {
+                    fileTxt = dncPassLog.getSequenceNumber() + 1;
+                } else {
+                    fileTxt =  1;
+                }
+                fileNc = fileTxt + 1;
+                //澶勭悊鏂囦欢鍚嶇О  鏂囦欢璺緞
+                String sequence = String.format("%06d",fileTxt);
+                String sequenceNc = String.format("%06d",fileNc);
+                passInfoTxt.setSequenceNumber(fileTxt);
+                passInfoTxt.setSequenceOrder(sequence);
+                passInfoTxt.setCreateTime(dateFirst);
+                System.out.println(DateUtil.format(dateFirst,DateUtil.STR_DATE_TIME));
+                passInfoTxt.setPassType("02");
+                dncPassLogService.save(passInfoTxt);
+
+                DncPassLog passInfoNc = new DncPassLog();
+                passInfoNc.setSequenceNumber(fileNc);
+                passInfoNc.setSequenceOrder(sequenceNc);
+                passInfoNc.setDayTime(DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY));
+                passInfoNc.setPassType("02");
+                passInfoNc.setPassName(docFile.getFileName());
+                try {
+                    Thread.sleep(1000);
+                    Date date = new Date();
+                    passInfoNc.setCreateTime(date);
+                    System.out.println(DateUtil.format(date,DateUtil.STR_DATE_TIME));
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+
+                dncPassLogService.save(passInfoNc);
                 NcTxtFilePathInfo ncTxt = new NcTxtFilePathInfo();
                 ncTxt.setEquipmentId(mdcEquipment.getEquipmentId());
-                ncTxt.setFileNcName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY));
-                ncTxt.setFileTxtName("02A" + DateUtil.format(dateFirst, DateUtil.STR_YEARMONTHDAY));
+                ncTxt.setFileNcName("10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc);
+                ncTxt.setFileTxtName("10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequence);
                 ncTxt.setFilePath(path + "/" + mdcEquipment.getEquipmentId() + "/");
                 ncTxt.setOrigFileName(docFile.getFileName());
                 ncTxt.setOrigFileSuffix(docFile.getFileSuffix());
                 ncTxt.setFileAddOrDelete(1);
-                String loFilePath = localFilePath + ncTxt.getFileTxtName() + ".nc";
+                String loFilePath = secretFolder +"/"+ ncTxt.getFileTxtName() + ".nc";
                 try {
                     String allList = ncTxt.getFileTxtName() + "\n"
                             + ncTxt.getFileNcName() + "\n"
@@ -746,7 +728,7 @@
                     FileUtilS.fileWriterSql(loFilePath, allList);
                     boolean copyFileNc = FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" +
                                     docFile.getFileName(),
-                            localFilePath + ncTxt.getFileNcName(),
+                            secretFolder +"/"+ncTxt.getFileNcName(),
                             docFile.getFileSuffix(), "NC");
                     if (!copyFileNc) {
                         FileUtilS.deleteNcFile(loFilePath);

--
Gitblit v1.9.3