From cd00884c3db8fa6808b3b5949ab1a2b1459d6bdc Mon Sep 17 00:00:00 2001
From: cuilei <ray_tsu1@163.com>
Date: 星期三, 11 六月 2025 10:36:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java |  147 ++++++++++++++++++++++--------------------------
 1 files changed, 67 insertions(+), 80 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 3bfd2bb..70ab35e 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
@@ -25,7 +25,6 @@
 import org.jeecg.modules.dnc.utils.date.DateUtil;
 import org.jeecg.modules.dnc.utils.file.FileUtilS;
 import org.jeecg.modules.dncFlow.entity.AssignFileStream;
-import org.jeecg.modules.dncFlow.entity.ToEquipmentTask;
 import org.jeecg.modules.dncFlow.ext.AssignFileStreamExt;
 import org.jeecg.modules.dncFlow.mapper.AssignFileStreamMapper;
 import org.jeecg.modules.dncFlow.request.ApproveBatchRequest;
@@ -33,7 +32,6 @@
 import org.jeecg.modules.dncFlow.request.AssignFileStreamQueryRequest;
 import org.jeecg.modules.dncFlow.request.TaskRequest;
 import org.jeecg.modules.dncFlow.service.IAssignFileStreamService;
-import org.jeecg.modules.dncFlow.service.IToEquipmentTaskService;
 import org.jeecg.modules.dncFlow.vo.AssignFlowTaskVo;
 import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness;
 import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
@@ -44,6 +42,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.message.enums.DeployEnum;
 import org.jeecg.modules.system.service.IMdcProductionService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -72,13 +71,7 @@
     @Autowired
     private IDocInfoService docInfoService;
     @Autowired
-    private IProcessStreamService processStreamService;
-    @Autowired
     private IDocClassificationService classificationService;
-    @Autowired
-    private IToEquipmentTaskService equipmentTaskService;
-    @Autowired
-    private IDeviceInfoService deviceInfoService;
     @Autowired
     private IDocFileService docFileService;
     @Autowired
@@ -103,11 +96,12 @@
     private IFlowMyBusinessService flowMyBusinessService;
     @Autowired
     private PermissionService permissionService;
-
-    @Value("${securedoc.whether}")
-    private String whether;
-    @Value("${securedoc.localFilePath}")
-    private String localFilePath;
+    @Autowired
+    private IDncPassLogService dncPassLogService;
+    @Value("${deploy.deployType}")
+    private String deployType;    //宸ユ帶缃�/娑夊瘑缃戦儴缃� 0涓哄伐鎺х綉 1涓烘秹瀵嗙綉
+    @Value("${deploy.secretFolder}")
+    private String secretFolder;    //娑夊瘑缃戜紶杈搉c鏂囦欢澶�
 
     @Override
     @Transactional(rollbackFor = {Exception.class})
@@ -134,7 +128,6 @@
      */
     public String getDeviceSpecialChar(String deviceId, String fileId){
         //鏇挎崲涓簃dc璁惧琛�
-//        DeviceInfo deviceInfo = deviceInfoService.getById(deviceId);
         MdcEquipment mdcEquipment = iMdcEquipmentService.getById(deviceId);
         if(mdcEquipment == null)
             ExceptionCast.cast(ActivitiCode.ACT_ASSIGN_DEVICE_NONE);
@@ -228,6 +221,9 @@
         //鏉冮檺鏍¢獙
         validateParams(stream);
         DocInfo docInfo = getDocInfo(stream);
+        //淇敼鍘熸湁鐘舵��
+        docInfo.setDocDispatchStatus(4);
+        docInfoService.updateById(docInfo);
         MdcEquipment mdcEquipment = getMdcEquipment(stream);
         DocFile docFile = getDocFile(stream);
         DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 7, stream.getDeviceId());
@@ -258,7 +254,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("鎿嶄綔鎴愬姛");
     }
@@ -337,6 +336,9 @@
             DocFile docFile = docFileService.getById(en.getFileId());
             if(docFile == null)
                 ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
+            //淇敼鍘熸湁鐘舵��
+            docInfo.setDocDispatchStatus(4);
+            docInfoService.updateById(docInfo);
             DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(en.getDocId(),7, en.getDeviceId());
             if(deviceDoc != null) {
                 // 鍒犻櫎 澶囦唤  瑕嗙洊 鍘熸湁鐨�
@@ -380,6 +382,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) {
@@ -476,64 +482,6 @@
         return false;
     }
 
-    @Override
-    @Transactional(rollbackFor = {Exception.class})
-    public boolean transferDocFile(String pnCode, String deviceNo) {
-        List<ProcessStream> streams = processStreamService.validateDeviceProcessInfo(pnCode, deviceNo);
-        DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
-        if(deviceInfo == null)
-            ExceptionCast.cast(DeviceCode.DEVICE_NOT_EXIST);
-        //鍒犻櫎鍘熸潵璁惧涓嬬殑鎵�鏈夋枃妗�
-        docRelativeService.deleteByDocAttr(7, deviceInfo.getDeviceId());
-        List<DocInfo> docInfoList = docInfoService.getByProcessIds(streams);
-        if(docInfoList == null || docInfoList.isEmpty())
-            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
-        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        String userId = user.getId();
-        if(!ValidateUtil.validateString(userId))
-            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
-        for(DocInfo docInfo : docInfoList) {
-            DocFile docFile = docFileService.getById(docInfo.getPublishFileId());
-            if(docFile == null)
-                ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
-            //鎻掑叆鏂囨。鍒拌澶囧彂閫佹枃妗�
-            DocClassification classification = classificationService.getByCode(SEND_CODE);
-            if(classification == null)
-                ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
-            DocRelative docRelative = new DocRelative();
-            docRelative.setDocId(docInfo.getDocId());
-            docRelative.setClassificationId(classification.getClassificationId());
-            docRelative.setAttributionType(7);
-            docRelative.setAttributionId(deviceInfo.getDeviceId());
-            boolean b = docRelativeService.save(docRelative);
-            if(!b)
-                ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
-            //鎻掑叆鏂囦欢浼犺緭浠诲姟琛�
-            ToEquipmentTask equipmentTask = new ToEquipmentTask();
-            //涓嶈兘鐩存帴浠巇oc涓嬁fileId 鍜寁ersion  鍙兘浼氬瓨鍦ㄦ枌鏇�
-            //equipmentTask.setFileId(docInfo.getPublishFileId());
-            //equipmentTask.setDocVersion(docInfo.getPublishVersion());
-            equipmentTask.setDocId(docInfo.getDocId());
-            equipmentTask.setSyncFlag(1);
-            equipmentTask.setDeviceNo(deviceInfo.getDeviceNo());
-            equipmentTask.setDeviceId(deviceInfo.getDeviceId());
-            equipmentTask.setDepartId(deviceInfo.getDepartId());
-            //鏂囦欢鐩稿叧淇℃伅
-            equipmentTask.setFileId(docFile.getFileId());
-            equipmentTask.setDocVersion(docFile.getDocVersion());
-            equipmentTask.setFileName(docInfo.getDocName());
-            equipmentTask.setFileEncodeName(docFile.getFileEncodeName());
-            equipmentTask.setFilePath(docFile.getFilePath());
-            equipmentTask.setFileSuffix(docFile.getFileSuffix());
-            equipmentTask.setFileSize(docFile.getFileSize());
-            b = equipmentTaskService.save(equipmentTask);
-            if(!b) {
-                ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR);
-            }
-        }
-        return synchronizedFlagService.updateFlag(1);
-    }
-
     //浼犲弬楠岃瘉
     private void validateParams(AssignFileStream stream) {
         if (stream == null) {
@@ -564,7 +512,7 @@
 
     //鑾峰彇鏂囦欢
     private void handleExistingDeviceDoc(DocFile docFile, MdcEquipment mdcEquipment, String deviceId) {
-        List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getEquipmentId());
+        List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
         if (strings != null && !strings.isEmpty()) {
             String path = StringUtils.join(strings.toArray(), "/");
             boolean copyFileNc = FileUtilS.copyFileNcToBak(path + "/" + mdcEquipment.getEquipmentId(),
@@ -650,22 +598,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"
@@ -678,7 +665,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