yangys
2025-09-22 0bdfd76339bb58be09927b8c2fe268175c3a7cc8
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 机床代码
    * @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 机床代码
    * @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);
   }
}