yangys
2025-09-13 a0f3e98fdd9472af3c78b42423a7e3fa6fb92eba
blade-service/blade-mdm/src/main/java/org/springblade/mdm/flow/excution/cure/NormalCureFinishDataHandler.java
@@ -10,18 +10,17 @@
import org.springblade.mdm.basesetting.machine.service.MachineService;
import org.springblade.mdm.basesetting.machine.entity.Machine;
import org.springblade.mdm.commons.contants.ParamConstants;
import org.springblade.mdm.flow.entity.ApproveRecord;
import org.springblade.mdm.flow.entity.FlowProgramFile;
import org.springblade.mdm.flow.excution.dispatch.FinishDataHandler;
import org.springblade.mdm.flow.service.ApproveRecordService;
import org.springblade.mdm.flow.service.FlowProgramFileService;
import org.springblade.mdm.flow.service.FlowProgramProperties;
import org.springblade.mdm.program.entity.NcNode;
import org.springblade.mdm.program.entity.NcProgramApproved;
import org.springblade.mdm.program.service.NcNodeAutoCreateService;
import org.springblade.mdm.program.service.NcNodeService;
import org.springblade.mdm.program.service.NcProgramApprovedService;
import org.springblade.mdm.program.service.ProgramAnnotationService;
import org.springblade.mdm.program.service.programannotation.AnnotationProperties;
import org.springblade.mdm.program.service.programannotation.AnnotationUtil;
import org.springblade.mdm.program.service.programannotation.MachineAnnotationConfig;
import org.springblade.mdm.utils.EntityUtil;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.pojo.entity.DictBiz;
@@ -45,9 +44,8 @@
@Component("normalCureFinishDataHandler")
public class NormalCureFinishDataHandler implements FinishDataHandler {
   @Autowired
   private NcProgramApprovedService approvedService;
   @Autowired
   private ApproveRecordService approveRecordService;
   private MachineAnnotationConfig config;
   @Autowired
   private FlowProgramFileService flowProgramFileService;
   @Autowired
@@ -89,7 +87,7 @@
   /**
    * 将节点和历史节点挪动到固化的同级节点下
    * @param pkgNode 要固化的节点
    * @param pkgNode1 要固化的节点
    * @param historyProgramPackageNodes 程序包名 历史节点
    */
   void moveNodeToCuredTree(NcNode pkgNode1,List<NcNode> historyProgramPackageNodes, FlowProgramProperties programProperties) throws IOException {
@@ -159,7 +157,7 @@
         newProgNode.setFlowProgramFileId(flowProgramFile.getId());
         newProgNode.setIsCured(1);
         setGhAnnotation(flowProgramFile,machine.getMachineGroupCode(),annoDicts);
         setGhAnnotation(flowProgramFile,machine.getControlSystem(),annoDicts);
         nodeService.save(newProgNode);
      }
@@ -202,15 +200,20 @@
    * @param flowProgramFile oss 文件
    *
    */
   void setGhAnnotation(FlowProgramFile flowProgramFile,String machineGroup,List<DictBiz> annoDicts) throws IOException {
   void setGhAnnotation(FlowProgramFile flowProgramFile,String controlSystem,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);
         //InputStream finishedStream = programAnnotationService.setGHAnnotation(byteInputStream,controlSystem,annoDicts);
         List<DictBiz> annoDictList = programAnnotationService.getAnnotionDictList();
         AnnotationProperties annoProps = config.getConfigMap().get(controlSystem);
         if(annoProps == null){
            annoProps = AnnotationProperties.getDefault();
         }
         InputStream finishedStream =AnnotationUtil.setAnnotationAndGetInputStream(byteInputStream, "GH", annoProps.getStatusLineIndex(), controlSystem, annoDictList);
         try(finishedStream) {
            finishedStream.reset();
            BladeFile bfile = ossTemplate.putFile(flowProgramFile.getName(), finishedStream);
@@ -222,6 +225,7 @@
      }
   }
   /**
    * 计算有效期
    * @return