yangys
2025-08-20 51054f0da5dd4718212064510fff045815388b90
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/task/cure/CureFinishOperateTask.java
@@ -22,6 +22,7 @@
import org.springblade.mdm.utils.FileContentUtil;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.pojo.entity.Dict;
import org.springblade.system.pojo.entity.DictBiz;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -45,7 +46,6 @@
   private final OssTemplate ossTemplate;
   private final ProgramAnnotationService programAnnotationService;
   private final MachineService machineService;
   /**
    * 默认有效期间(月数),2年
@@ -118,16 +118,24 @@
         //处理程序包下层的程序节点111
         List<NcNode> programNodes = nodeService.lambdaQuery().eq(NcNode::getParentId,hisPackageNode.getId()).list();
         FlowProgramFile pfile;
         for(NcNode programNode : programNodes){
            programNode.setIsLastEdition(0);
            programNode.setParentIds(hisPackageNode.getParentIds()+","+hisPackageNode.getId());
            programNode.setIsLastEdition(0);
            pfile = flowProgramFileService.getById(programNode.getFlowProgramFileId());
            if(programNode.getParentId().equals(pkgNode.getId()) && !pfile.isProgram()){
               //当前固化程序包名下的“其他文件”非程序文件。不设置为老版本,直接挪到固化树下,两个网络之间只交换程序文件,其他文件只能保留
               programNode.setIsLastEdition(1);
            }
         }
         nodeService.updateBatchById(programNodes);
      }
      nodeService.updateBatchById(historyProgramPackageNodes);
      Machine machine = machineService.getByCode(pkgNode.getMachineCode());
      List<Dict> annoDicts = programAnnotationService.getAnnotionList();
      List<DictBiz> annoDicts = programAnnotationService.getAnnotionList();
      //新的流程文件,需要在包节点下新建,不能用老的
      List<FlowProgramFile> files = flowProgramFileService.lambdaQuery().eq(FlowProgramFile::getProcessInstanceId,pkgNode.getProcessInstanceId()).list();
      for(FlowProgramFile flowProgramFile : files){
@@ -156,28 +164,31 @@
      }
   }
   /**
    * 设置固化注释,实现方式,获取文件字节下,修改后替换文件
    * @param flowProgramFile oss 文件
    *
    */
   void setGhAnnotation(FlowProgramFile flowProgramFile,String machineGroup,List<Dict> annoDicts) throws IOException {
   void setGhAnnotation(FlowProgramFile flowProgramFile,String machineGroup,List<DictBiz> annoDicts) throws IOException {
      String ossName = flowProgramFile.getOssName();
      //
      try(InputStream ins = ossTemplate.statFileStream(ossName);){
         byte[] bytes = IOUtils.toByteArray(ins);
         ByteArrayInputStream byteInputStream =  new ByteArrayInputStream(bytes);
         InputStream finishedStream = programAnnotationService.setGHAnnotation(byteInputStream,machineGroup,annoDicts);
         /*
         String annoTxt = programAnnotationService.generateAnnotation("GH",machineGroup,annoDicts);
         int statusLineIndex = 2;
         String line2 = FileContentUtil.readLineAt(byteInputStream,statusLineIndex);//第三行应该是状态注释
         //int statusLineIndex = 2;
         String line2 = FileContentUtil.readLineAt(byteInputStream,ProgramAnnotationService.STATUS_LINE_INDEX);//第三行应该是状态注释
         byteInputStream.reset();
         InputStream finishedStream;
         if(programAnnotationService.isAnnotation(line2,machineGroup,annoDicts)){
            finishedStream = FileContentUtil.replaceAtLine(byteInputStream,statusLineIndex,annoTxt);
            finishedStream = FileContentUtil.replaceAtLine(byteInputStream,ProgramAnnotationService.STATUS_LINE_INDEX,annoTxt);
         }else{
            finishedStream = FileContentUtil.insertLine(byteInputStream,statusLineIndex,annoTxt);
         }
            finishedStream = FileContentUtil.insertLine(byteInputStream,ProgramAnnotationService.STATUS_LINE_INDEX,annoTxt);
         }*/
         try(finishedStream) {
            finishedStream.reset();
            BladeFile bfile = ossTemplate.putFile(flowProgramFile.getName(), finishedStream);