From 0bdfd76339bb58be09927b8c2fe268175c3a7cc8 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期一, 22 九月 2025 10:11:33 +0800
Subject: [PATCH] 优化现场编制导出
---
blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/NcProgramExportInnerService.java | 42 ++++++++++++++++++++++++++++++++----------
1 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/NcProgramExportInnerService.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/NcProgramExportInnerService.java
index 2b28b62..2d6b432 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/NcProgramExportInnerService.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/machinefile/service/NcProgramExportInnerService.java
@@ -43,7 +43,7 @@
private final OssTemplate ossTemplate;
private final MachineFileService machineFileService;
private final MachineService machineService;
- private final MachineAnnotationConfig annoConfig;
+ private final AnnotationProcessorHelper annotationProcessorHelper;
private final ProgramAnnotationService programAnnotationService;
/**
* 瀵煎嚭鍒版秹瀵嗙綉
@@ -69,6 +69,7 @@
addInputStreamToZip(zipOut,ins , programName + "/" + acceptedFile.getName(),acceptedFile.getName(),machineFile.getMachineCode());
}
acceptedFile.setExportTime(DateUtil.now());
+ acceptedFile.setStatus(MachineAcceptedFile.STATUS_EXPORTED);
}
}
@@ -79,7 +80,15 @@
os.close();
}
-
+ /**
+ * j灏嗚緭鍏ユ祦鍔犲叆zip
+ * @param zipOut zip鏂囦欢杈撳嚭閲岃矾
+ * @param inputStream 鏂囦欢鐨勮緭鍏ユ祦
+ * @param entryName entryName
+ * @param filename 鍘熷鏂囦欢鍚�
+ * @param machineCode 鏈哄簥浠g爜
+ * @throws IOException 寮傚父
+ */
public void addInputStreamToZip(ZipOutputStream zipOut, InputStream inputStream, String entryName,String filename,String machineCode)
throws IOException {
// 鍒涘缓鏂扮殑 ZIP 鏉$洰
@@ -97,9 +106,17 @@
zipOut.closeEntry();
}
+ /**
+ * 缁欏鍑烘枃浠跺鍔犳敞閲婏紝娑夊瘑缃戣鐢�
+ * @param inputStream 杈撳叆娴�
+ * @param filename 鏂囦欢鍚�
+ * @param machineCode 鏈哄簥浠g爜
+ * @return 瀹屾垚鍚庣殑stream
+ * @throws IOException 鎿嶄綔寮傚父
+ */
InputStream setAnnotations(InputStream inputStream,String filename,String machineCode) throws IOException {
Machine machine = this.machineService.getByCode(machineCode);
- AnnotationProcessor annoProcessor = ProcessorHelper.getProcessor(machine.getControlSystem(),annoConfig);
+ AnnotationProcessor annoProcessor = annotationProcessorHelper.getProcessor(machine.getControlSystem());
AnnotationData annoData = new AnnotationData();
annoData.setFilename(filename);
@@ -107,15 +124,20 @@
AnnotationProperties annoProps = annoProcessor.getAnnotationProperties();
- ByteArrayInputStream bais = new ByteArrayInputStream(IOUtils.toByteArray(inputStream));
- String statusLine = FileContentUtil.readLineAt(bais,annoProps.getStatusLineIndex());
- String status = programAnnotationService.removeAnnotation(machine.getControlSystem(),statusLine);
- if(StringUtils.equalsAny(status,"SQ","GH","PL")){
+ ByteArrayInputStream byteInsStream = new ByteArrayInputStream(IOUtils.toByteArray(inputStream));
+ String statusLine = FileContentUtil.readLineAt(byteInsStream,annoProps.getStatusLineIndex());
+ String text = programAnnotationService.removeAnnotation(machine.getControlSystem(),statusLine);
+ if(AnnotationUtil.isStatusContent(text)){
+ //鏄�3绉嶇姸鎬佷箣涓�
+ annoData.setProgramStatus(text);
+ }else{
+ //娌℃湁鎸夎瘯鍒囧鐞�
+ annoData.setProgramStatus(AnnotationUtil.SQ);
}
- bais.reset();
- annoData.setProgramStatus("3");
- return annoProcessor.putAnnotation(annoData,bais);
+ byteInsStream.reset();
+ //
+ return annoProcessor.putAnnotation(annoData,byteInsStream);
}
}
--
Gitblit v1.9.3