| | |
| | | import org.springblade.mdm.flow.service.CureFlowService; |
| | | import org.springblade.mdm.flow.service.FlowCommonService; |
| | | import org.springblade.mdm.flow.service.FlowProgramFileService; |
| | | import org.springblade.mdm.program.entity.DncBackFile; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | |
| | | private final OssTemplate ossTemplate; |
| | | private final BladeRedis bladeRedis; |
| | | private final FlowCommonService flowCommonService; |
| | | |
| | | private final DncBackFileService dncBackFileService; |
| | | private final ProgramFlowStatusQueryService programFlowStatusQueryService; |
| | | private String getFileKey(){ |
| | | return "dncimpfile-"+ AuthUtil.getUserId(); |
| | | } |
| | |
| | | progData.setId(programPackageNode.getId()); |
| | | progData.setProgramNo(programPackageNode.getProgramNo()); |
| | | |
| | | List<String> fileEtriyNames = fileEntryNameList.stream().filter(n -> n.startsWith(packageName)).toList(); |
| | | List<String> fileEntryNames = fileEntryNameList.stream().filter(n -> n.startsWith(packageName)).toList(); |
| | | List<DncSendBackFile> programFiles = new ArrayList<>(); |
| | | fileEtriyNames.forEach( filePath ->{ |
| | | fileEntryNames.forEach( filePath ->{ |
| | | DncSendBackFile backFile = new DncSendBackFile(); |
| | | backFile.setEntryName(filePath); |
| | | backFile.setName(StringUtils.removeStart(filePath,entryName)); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 处理回传文件 |
| | | * @param ossFileName |
| | | * @param acceptIdList |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | private Map<Long, List<FlowProgramFile>> dealWithBackFile(String ossFileName, List<Long> acceptIdList) throws IOException{ |
| | | Map<Long, List<FlowProgramFile>> pkgIdFileMap = new HashMap<>(); |
| | | |
| | |
| | | //根据节点信息查询流程 |
| | | boolean active = flowCommonService.isProcessInstanceActive(packageNode.getProcessInstanceId()); |
| | | if(active){ |
| | | throw new ServiceException(programPackageName+"正在审批中,请勿重复入库。"); |
| | | throw new ServiceException(programPackageName+"正在审批中,请勿等待审批完成。"); |
| | | } |
| | | |
| | | //验证都过了,保存dncbackFile |
| | | DncBackFile backFile = new DncBackFile(); |
| | | backFile.setNcNodeId(packageNode.getId()); |
| | | backFile.setOssName(ossFileName); |
| | | dncBackFileService.save(backFile); |
| | | |
| | | List<FlowProgramFile> flowFiles = new ArrayList<>(); |
| | | //查找包下的文件数据, |
| | |
| | | * @param programPackageSubMap 新的 程序包节点id -> =文件列表 map,用于回传数据 |
| | | * @throws IOException 访问文件异常 |
| | | */ |
| | | /* |
| | | List<NcNode> updateNodeDataByDNCBackData(String pkgFileName, List<Long> programPackageIdList,Map<Long,List<NcNode>> programPackageSubMap) throws IOException { |
| | | InputStream inputStream = this.ossTemplate.statFileStream(pkgFileName); |
| | | Path tempZipFile = createTempFile(inputStream); |
| | |
| | | |
| | | return newProgramPackageNodeList; |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 创建一个临时zip文件 |
| | | * @param inputStream 文件的输入流 |
| | |
| | | } |
| | | try (InputStream fileIns = zipFile.getInputStream(zipFile.getEntry(entryName))) { |
| | | ByteArrayInputStream bos = new ByteArrayInputStream(fileIns.readAllBytes()); |
| | | boolean isText = FileContentUtil.isTextFile(bos); |
| | | boolean isText = StringUtils.endsWithIgnoreCase(entryName,".txt") || StringUtils.endsWithIgnoreCase(entryName,".nc")|| StringUtils.endsWithIgnoreCase(entryName,".xml"); |
| | | if(!isText) { |
| | | isText = FileContentUtil.isTextFile(bos); |
| | | } |
| | | if (isText) { |
| | | bos.reset(); |
| | | result = FileContentUtil.getContentFromStream(bos); |