yangys
2025-09-10 dc01577b31204fd3c80645b45d81ff693f79a985
blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramExportDNCService.java
@@ -17,6 +17,10 @@
import org.springblade.mdm.program.entity.NcProgramApproved;
import org.springblade.mdm.program.entity.NcProgramExchange;
import org.springblade.mdm.program.mapper.NcProgramExchangeMapper;
import org.springblade.mdm.program.service.programannotation.AnnotationData;
import org.springblade.mdm.program.service.programannotation.AnnotationProcessor;
import org.springblade.mdm.program.service.programannotation.MachineAnnotationConfig;
import org.springblade.mdm.program.service.programannotation.ProcessorHelper;
import org.springblade.system.feign.IDictClient;
import org.springblade.system.pojo.entity.DictBiz;
import org.springframework.stereotype.Service;
@@ -44,7 +48,7 @@
   private final FlowProgramFileService flowProgramFileService;
   private final ProgramAnnotationService programAnnotationService;
   private final MachineAnnotationConfig annotationConfig;
   /**
    * 导出dnc压缩包
    * @param approvedIdArray 待导出审批表id数组
@@ -75,7 +79,7 @@
   private void addProgramPackageToZip(ZipOutputStream zipOut, NcProgramApproved approved) throws IOException{
      NcNode packageNode = ncNodeService.getById(approved.getNcNodeId());
      String packageFolder = packageNode.getName()+"-"+packageNode.getProcessEdition()+"/";
      String packageFolder = packageNode.getName()+"/";
      ZipEntry zipEntry = new ZipEntry(packageFolder);// "/"结尾表示文件夹
      zipOut.putNextEntry(zipEntry);
      zipOut.closeEntry();
@@ -97,13 +101,23 @@
         deviationSerial = ncNodeService.getDeviationSerialForNode(packageNode);
      }
      List<DictBiz> annotationDictList= programAnnotationService.getAnnotionDictList();
      //List<DictBiz> annotationDictList= programAnnotationService.getAnnotionDictList();
      for (NcNode node : programNodes) {
         String filePathInZip = genFilePathInZip(packageFolder,node,deviationSerial);
         programFile = this.flowProgramFileService.getById(node.getFlowProgramFileId());
         if(programFile.isProgram()) {//程序文件,才会加入压缩包
            InputStream inputStream = ossTemplate.statFileStream(programFile.getOssName());
            String sendDir = machine.getProgSendDir()==null? StringUtil.EMPTY:machine.getProgSendDir();
            AnnotationProcessor annoProcessor = ProcessorHelper.getProcessor(machine.getControlSystem(),annotationConfig);
            AnnotationData annoData = new AnnotationData();
            annoData.setSendPath(sendDir);
            annoData.setProgramStatus(status);
            annoData.setDeviation(programPackageNode.getDeviation());
            annoData.setFilename(programFile.getName());
            InputStream addedInsFinal = annoProcessor.setAnnotation(annoData,inputStream);
            addedInsFinal.reset();
            /*
            InputStream addedInsFinal;
            InputStream addedIns2 = programAnnotationService.setSendDirAndStatusAnnotation(sendDir,status,inputStream,machine.getControlSystem());
            if(StringUtils.isNotBlank(programPackageNode.getDeviation())) {
@@ -111,7 +125,7 @@
               addedInsFinal = programAnnotationService.setPldAnnotation(programPackageNode.getDeviation(),addedIns2, machine.getControlSystem(), annotationDictList);;
            }else{
               addedInsFinal = addedIns2;
            }
            }*/
            this.addInputStreamToZip(zipOut, addedInsFinal, filePathInZip);
         }
      }