From 4c7296d45efe849dc70a3b2e2240c905481a91c9 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期一, 29 九月 2025 17:44:46 +0800
Subject: [PATCH] 工控网涉密网联调

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java
index 366d803..72b3933 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java
@@ -16,6 +16,7 @@
 import org.springblade.mdm.flow.constants.FlowConstant;
 import org.springblade.mdm.flow.entity.FlowProgramFile;
 import org.springblade.mdm.flow.service.FlowProgramFileService;
+import org.springblade.mdm.flow.service.TaskDispatchService;
 import org.springblade.mdm.program.entity.NcNode;
 import org.springblade.mdm.program.entity.NcNodeHis;
 import org.springblade.mdm.program.entity.NcProgramApproved;
@@ -48,8 +49,8 @@
 	private final OssTemplate ossTemplate;
 	private final FlowProgramFileService flowProgramFileService;
 	private final HistoryService historyService;
-
-	private final MachineAnnotationConfig annotationConfig;
+	private final TaskDispatchService taskDispatchService;
+	private final AnnotationProcessorHelper annotationProcessorHelper;
 	/**
 	 * 瀵煎嚭dnc鍘嬬缉鍖�
 	 * @param approvedIdArray 寰呭鍑哄鎵硅〃id鏁扮粍
@@ -87,8 +88,8 @@
 
 	/**
 	 * 灏嗙▼搴忓寘鍜屼笅灞炴枃浠跺姞鍏ュ帇缂╁寘
-	 * @param zipOut
-	 * @param approved
+	 * @param zipOut zip鏂囦欢杈撳嚭娴�
+	 * @param approved 瀹℃壒瀹屾垚璁板綍
 	 */
 	private void addProgramPackageToZip(ZipOutputStream zipOut, NcProgramApproved approved) throws IOException{
 		NcNodeHis packageNodeHis = ncNodeHisService.getById(approved.getNcNodeId());
@@ -100,7 +101,7 @@
 
 		Machine machine = machineService.getByCode(packageNodeHis.getMachineCode());//绋嬪簭鍖呰妭鐐癸紝鑾峰彇娉ㄩ噴鐢�
 
-		//List<NcNode> programNodes = ncNodeService.lambdaQuery().eq(NcNode::getIsLastEdition,1).eq(NcNode::getParentId, approved.getNcNodeId()).list();
+		//闇�瑕佸鍔犵増鏈彿鐨勮繃婊�
 		List<NcNodeHis> programNodes = ncNodeHisService.lambdaQuery().eq(NcNodeHis::getParentId, approved.getNcNodeId()).list();
 
 		FlowProgramFile programFile;
@@ -113,10 +114,9 @@
 		}
 		long deviationSerial = -1;//鍋忕鍗曞簭鍙� 锛�-1涓洪潪鍋忕鍗曪紝涓嶉渶瑕佸姞鍏�
 		if(packageNodeHis.isDeviationProgram()) {
-			deviationSerial = ncNodeHisService.getDeviationSerialForNode(packageNodeHis);
+			deviationSerial = taskDispatchService.getDeviationSerial(packageNodeHis.getProgramNo());
 		}
 
-		//List<DictBiz> annotationDictList= programAnnotationService.getAnnotionDictList();
 		for (NcNodeHis node : programNodes) {
 			String filePathInZip = genFilePathInZip(packageFolder,node,deviationSerial);
 			programFile = this.flowProgramFileService.getById(node.getFlowProgramFileId());
@@ -124,23 +124,19 @@
 				InputStream inputStream = ossTemplate.statFileStream(programFile.getOssName());
 				String sendDir = machine.getProgSendDir()==null? StringUtil.EMPTY:machine.getProgSendDir();
 
-				AnnotationProcessor annoProcessor = ProcessorHelper.getProcessor(machine.getControlSystem(),annotationConfig);
+				AnnotationProcessor annoProcessor = this.annotationProcessorHelper.getProcessor(machine.getControlSystem());
 				AnnotationData annoData = new AnnotationData();
 				annoData.setSendPath(sendDir);
 				annoData.setProgramStatus(status);
 				annoData.setDeviation(programPackageNode.getDeviation());
 				annoData.setFilename(programFile.getName());
-				InputStream addedInsFinal = annoProcessor.putAnnotation(annoData,inputStream);
+
+				if(StringUtils.startsWith(programPackageNode.getParentIds(),"0,4")) {
+					//璇曞垏琛ュ厖,鐗规畩鏍囪鐘舵��
+					annoData.setProgramStatus(AnnotationUtil.TMP);
+				}
+				InputStream addedInsFinal = annoProcessor.putAnnotation(annoData, inputStream);
 				addedInsFinal.reset();
-				/*
-				InputStream addedInsFinal;
-				InputStream addedIns2 = programAnnotationService.setSendDirAndStatusAnnotation(sendDir,status,inputStream,machine.getControlSystem());
-				if(StringUtils.isNotBlank(programPackageNode.getDeviation())) {
-					//鍋忕鍗曪紝澧炲姞鍋忕鍗曞彿
-					addedInsFinal = programAnnotationService.setPldAnnotation(programPackageNode.getDeviation(),addedIns2, machine.getControlSystem(), annotationDictList);;
-				}else{
-					addedInsFinal = addedIns2;
-				}*/
 				this.addInputStreamToZip(zipOut, addedInsFinal, filePathInZip);
 			}
 		}
@@ -151,7 +147,7 @@
 	 * 鐢熸垚鍦▃ip涓殑鏂囦欢璺緞
 	 * @param packageFolder zip涓殑鏂囦欢澶�
 	 * @param programNode 绋嬪簭鑺傜偣
-	 * @param deviationSerial 鍋忕鍗曞簭鍙�
+	 * @param deviationSerial 涓存椂鏇存敼鍗曞簭鍙�
 	 * @return zip涓殑鏂囦欢璺緞
 	 */
 	String genFilePathInZip(String packageFolder,NcNodeHis programNode,long deviationSerial){

--
Gitblit v1.9.3