| | |
| | | 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; |
| | | |
| | |
| | | private final OssTemplate ossTemplate; |
| | | private final ProgramAnnotationService programAnnotationService; |
| | | private final MachineService machineService; |
| | | |
| | | |
| | | /** |
| | | * 默认有效期间(月数),2年 |
| | |
| | | |
| | | //处理程序包下层的程序节点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){ |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置固化注释,实现方式,获取文件字节下,修改后替换文件 |
| | | * @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); |