From bc8cd378fd72f43e66120c540f57f630580aa093 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 11 九月 2025 10:57:13 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java | 150 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 111 insertions(+), 39 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 18f1a94..2fb9d31 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 @@ -113,7 +113,7 @@ //鏌ヨ鏂囨。鐨勭姸鎬侊紝鎵瑰噯鐘舵�佹墠鍙互鎸囨淳 DocInfo docInfo=getDocInfo(stream); DocClassification docClassification=iDocClassificationService.getById(docInfo.getClassificationId()); - if (docInfo.getDocDispatchStatus()!=null&&docInfo.getDocDispatchStatus()!=3&&docClassification.getClassificationCode().equals("nc")){ + if (docInfo.getDocDispatchStatus()!=null&&docInfo.getDocDispatchStatus()!=3&&docInfo.getDocDispatchStatus()!=5&&docClassification.getClassificationCode().equals("nc")){ return Result.error("璇ユ枃浠剁姸鎬佷笉鍏佽鎸囨淳,璇峰厛瀹屾垚瀹$娴佺▼"); } if(flowableEnable) { @@ -182,14 +182,13 @@ validateParams(stream); DocInfo docInfo = getDocInfo(stream); MdcEquipment mdcEquipment = getMdcEquipment(stream); - DocFile docFile = docFileService.getById(stream.getFileId()); DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(stream.getDocId(), 7, stream.getDeviceId()); if (deviceDoc != null) { - handleExistingDeviceDoc(docFile, mdcEquipment, stream.getDeviceId()); + return Result.error("瀛樺湪鐩稿悓鏂囨。,涓嶅厑璁搁噸澶嶆寚娲撅紝璇峰垹闄ゅ悗鎸囨淳"); } deviceDoc = docInfoService.findByAttrAndDocName(docInfo.getDocName(), 7, stream.getDeviceId()); if (deviceDoc != null) { - handleExistingDeviceDoc(docFile, mdcEquipment, stream.getDeviceId()); + return Result.error("瀛樺湪鐩稿悓鏂囨。,涓嶅厑璁搁噸澶嶆寚娲撅紝璇峰垹闄ゅ悗鎸囨淳"); } PermissionStreamNew permissionStreams = getPermissionStreams(stream); if (permissionStreams==null){ @@ -199,7 +198,7 @@ String userId = user.getId(); saveBusinessObject(stream, userId); System.out.println("鎸囨淳NC鏂囨。鍒拌澶囨祦绋嬶細" + stream.getDocId()); - flowCommonService.initActBusiness("鎸囨淳NC鏂囨。鍒拌澶囨祦绋嬶細" +docInfo.getDocName()+"."+docInfo.getDocSuffix()+"鍒拌澶�->"+mdcEquipment.getEquipmentName() , + flowCommonService.initActBusiness("鎸囨淳NC鏂囨。鍒拌澶囨祦绋嬶細" +docInfo.getDocName()+"."+docInfo.getDocSuffix()+"鍒拌澶�->"+mdcEquipment.getEquipmentId() , stream.getStreamId(), "IAssignFileStreamService", "assign_nc_to_device", null); Map<String, Object> variables = new HashMap<>(); variables.put("dataId", stream.getStreamId()); @@ -266,9 +265,9 @@ } handleFileTransfer(mdcEquipment, docFile); //NC鏂囦欢鐨勬嫹璐� - handleFileProcessing(docFile, mdcEquipment, secretFolder); +// handleFileProcessing(docFile, mdcEquipment, secretFolder); //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐� - handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); +// handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); synchronizedFlagService.updateFlag(2); return Result.OK("鎿嶄綔鎴愬姛"); } @@ -347,8 +346,11 @@ DocFile docFile = docFileService.getById(en.getFileId()); if(docFile == null) ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); - //淇敼鍘熸湁鐘舵�� - docInfo.setDocDispatchStatus(4); + //淇敼NC鐘舵�� + if (Objects.equals(en.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode().toString()) || + Objects.equals(en.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode().toString())) { + docInfo.setDocDispatchStatus(4); + } docInfoService.updateById(docInfo); DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(en.getDocId(),7, en.getDeviceId()); if(deviceDoc != null) { @@ -379,19 +381,17 @@ } if(!b) ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); - if (mdcEquipment != null) { - List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); - if (strings != null && !strings.isEmpty()) { - String path = StringUtils.join(strings.toArray(), "/"); - boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ mdcEquipment.getEquipmentId(), - docFile.getFileEncodeName(), + List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId()); + if (strings != null && !strings.isEmpty()) { + String path = StringUtils.join(strings.toArray(), "/"); + boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(),path + "/"+ mdcEquipment.getEquipmentId(), + docFile.getFileEncodeName(), + docFile.getFileName(),docFile.getFileSuffix()); + if (!copyFileNc) { + ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); + } else { + FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(), docFile.getFileName(),docFile.getFileSuffix()); - if (!copyFileNc) { - ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); - } else { - FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(), - docFile.getFileName(),docFile.getFileSuffix()); - } } } List<DocRelative> docRelativeList=docRelativeService. @@ -402,13 +402,15 @@ if (docRelativeList.isEmpty()){ ExceptionCast.cast(ActivitiCode.ACT_APPROVE_ERROR); } - //娑夊瘑缃戣繘琛孨C鏂囦欢鐨勬嫹璐� - handleFileTransfer(mdcEquipment, docFile); - //NC鏂囦欢鐨勬嫹璐� - handleFileProcessing(docFile, mdcEquipment, secretFolder); - //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐� - handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); - return synchronizedFlagService.updateFlag(1); + DocRelative docRelative=docRelativeList.get(0); + if (!Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode()) || + !Objects.equals(docRelative.getAttributionType(), DocAttributionTypeEnum.WORKSITE.getCode())) { + //鍏朵粬鏂囦欢鐨勬嫹璐� + handleFileOtherProcessing(docFile, mdcEquipment, secretFolder); + //瀵瑰簲浜у搧缁撴瀯鏍戞嫹璐� + handleProductTree(docInfo,docRelativeList.get(0),mdcEquipment.getEquipmentId()); + } + return true; }else if(up.getStatus() == 3) { //鎷掔粷鎿嶄綔 浠�涔堜篃涓嶅仛 return true; @@ -532,16 +534,16 @@ } //鑾峰彇鏂囦欢 - private void handleExistingDeviceDoc(DocFile docFile, MdcEquipment mdcEquipment, String deviceId) { + private void handleExistingDeviceDoc(DocInfo docInfo,DocFile docFile, MdcEquipment mdcEquipment, String deviceId) { 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(), docFile.getFileName(), docFile.getFileSuffix()); if (!copyFileNc) { - ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); + ExceptionCast.cast(ActivitiCode.ACT_DEVICE_DOC_ERROR); } else { - DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(deviceId, 7, deviceId); + DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(docInfo.getDocId(), 7, deviceId); boolean doc = docRelativeService.deleteDocByAttr(deviceDoc.getDocId(), 7, deviceId); if (!doc) { ExceptionCast.cast(ActivitiCode.ACT_DOC_ERROR_DELEVE); @@ -688,16 +690,86 @@ passInfoTxt.setPassType(DncPassLogPassType.PRODUCTSTRUCTURE.getCode()); dncPassLogService.save(passInfoTxt); String fileName="10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY); - if (Objects.equals(docInfo.getAttributionType(), DocAttributionTypeEnum.PROCESS.getCode())){ - //宸ュ簭瀵瑰簲璁惧绫� - String filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); - System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath); - }else { - //宸ユ瀵瑰簲璁惧绫� - String filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); - System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath); + String filePath=""; + switch (docInfo.getAttributionType()){ + case 1: + //浜у搧瀵瑰簲鍏朵粬鏂囨。 + filePath = ferryService.exportData(TransferPackage.DataType.PRODUCT, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("浜у搧鏁版嵁宸插鍑�: " + filePath); + break; + case 2: + //閮ㄤ欢瀵瑰簲鍏朵粬鏂囨。 + filePath = ferryService.exportData(TransferPackage.DataType.COMPONENT, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("閮ㄤ欢鏁版嵁宸插鍑�: " + filePath); + break; + case 3: + //闆朵欢瀵瑰簲鍏朵粬鏂囨。 + filePath = ferryService.exportData(TransferPackage.DataType.PARTS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("闆朵欢鏁版嵁宸插鍑�: " + filePath); + break; + case 4: + //宸ヨ壓鐗堟湰瀵瑰簲鍏朵粬鏂囨。 + filePath = ferryService.exportData(TransferPackage.DataType.OPERATION, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("宸ヨ壓鐗堟湰鏁版嵁宸插鍑�: " + filePath); + break; + case 5: + //宸ュ簭瀵瑰簲璁惧绫� + filePath = ferryService.exportData(TransferPackage.DataType.PROCESS, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("宸ュ簭鏁版嵁宸插鍑�: " + filePath); + break; + case 6: + //宸ユ瀵瑰簲璁惧绫� + filePath = ferryService.exportData(TransferPackage.DataType.WORKSTEP, docRelative.getId(),fileName+sequence+"_"+equipmentId+".ferry"); + System.out.println("宸ユ鏁版嵁宸插鍑�: " + filePath); + break; + default: + break; } } + + //灏佽澶勭悊鍏朵粬鏂囦欢 + private void handleFileOtherProcessing(DocFile docFile, MdcEquipment mdcEquipment, String secretFolder) { + if (!docFile.getFileSuffix().equals("zip") && !docFile.getFileSuffix().equals("rar")) { + 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 fileNc =0; + if (dncPassLog !=null) { + fileNc = dncPassLog.getSequenceNumber() + 1; + } else { + fileNc = 1; + } + //澶勭悊鏂囦欢鍚嶇О 鏂囦欢璺緞 + String sequenceNc = String.format("%06d",fileNc); + 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); + FileUtilS.copyFileUpName(path + "/" + mdcEquipment.getEquipmentId() + "/send/" + + docFile.getFileName(), + secretFolder +"/"+"10A"+DateUtil.format(dateFirst,DateUtil.STR_YEARMONTHDAY)+sequenceNc+"_"+mdcEquipment.getEquipmentId(), + docFile.getFileSuffix(), docFile.getFileSuffix()); + } + } + } + @Override public void afterFlowHandle(FlowMyBusiness business) { business.getTaskNameId();//鎺ヤ笅鏉ュ鎵圭殑鑺傜偣 -- Gitblit v1.9.3