| | |
| | | */ |
| | | @Transactional |
| | | public void dncFileAccept(String ids) throws IOException { |
| | | List<Long> idList = Func.toLongList(ids); |
| | | List<Long> acceptIdList = Func.toLongList(ids); |
| | | // |
| | | NcProgramExchange exchange; |
| | | String filekey = getFileKey(); |
| | | String pkgFileName = bladeRedis.get(filekey); |
| | | log.info("filekey={},文件名={}",filekey,pkgFileName); |
| | | String zipFileName = bladeRedis.get(filekey); |
| | | log.info("filekey={},文件名={}",filekey,zipFileName); |
| | | |
| | | Map<Long,List<NcNode>> programPackageSubMap = new HashMap<>(); |
| | | List<NcNode> newProgramPackageList = updateNodeDataByDNCBackData(pkgFileName,idList,programPackageSubMap); |
| | | |
| | | Map<Long,List<FlowProgramFile>> pkgIdFileMap = dealWithBackFile(zipFileName,acceptIdList); |
| | | |
| | | ///List<NcNode> newProgramPackageList = updateNodeDataByDNCBackData(pkgFileName,idList,programPackageSubMap); |
| | | //updateNodeDataByDNCBackData(pkgFileName,idList,programPackageSubMap); |
| | | /* |
| | | log.info("需要启动固化流程的程序包名数量:{}",newProgramPackageList.size()); |
| | | for(NcNode pkgNode :newProgramPackageList){ |
| | | exchange = new NcProgramExchange(); |
| | |
| | | exchange.setNcNodeId(pkgNode.getId()); |
| | | |
| | | this.save(exchange); |
| | | } |
| | | }*/ |
| | | bladeRedis.del(filekey); |
| | | this.ossTemplate.removeFile(pkgFileName); |
| | | log.info("删除oss文件:{}",pkgFileName); |
| | | this.ossTemplate.removeFile(zipFileName); |
| | | log.info("删除oss文件:{}",zipFileName); |
| | | |
| | | //cureFlowService.startCure(newProgramPackageList,programPackageSubMap); |
| | | cureFlowService.startCureNew(pkgIdFileMap); |
| | | |
| | | cureFlowService.startCure(newProgramPackageList,programPackageSubMap); |
| | | } |
| | | |
| | | private Map<Long, List<FlowProgramFile>> dealWithBackFile(String ossFileName, List<Long> acceptIdList) throws IOException{ |
| | | Map<Long, List<FlowProgramFile>> pkgIdFileMap = new HashMap<>(); |
| | | |
| | | InputStream inputStream = this.ossTemplate.statFileStream(ossFileName); |
| | | Path tempZipFile = createTempFile(inputStream); |
| | | List<String> entryNameList = new ArrayList<>(); |
| | | |
| | | ZipEntry entry; |
| | | try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) { |
| | | Enumeration<? extends ZipEntry> entries = zipFile.entries(); |
| | | while(entries.hasMoreElements()) { |
| | | entry = entries.nextElement(); |
| | | entryNameList.add(entry.getName()); |
| | | } |
| | | log.info("allentrynames:{}",entryNameList); |
| | | |
| | | List<NcNode> allAcceptPackages = this.ncNodeService.lambdaQuery().in(NcNode::getId,acceptIdList).list(); |
| | | //根据内部文件,读取和分析程序包和程序文件数据 |
| | | List<String> dirList = entryNameList.stream().filter(s -> s.endsWith("/")).toList(); |
| | | for(String dir : dirList){ |
| | | String programPackageName = StringUtils.removeEnd(dir,"/"); |
| | | Optional<NcNode> optPackageNode = allAcceptPackages.stream().filter(node -> StringUtils.equals(node.getName(),programPackageName)).findFirst(); |
| | | |
| | | if(optPackageNode.isEmpty()){ |
| | | throw new ServiceException("找不到程序"+programPackageName); |
| | | } |
| | | |
| | | NcNode packageNode = optPackageNode.get(); |
| | | if(packageNode.hasCured()) { |
| | | throw new ServiceException(programPackageName + "已经固化,请勿重复入库。"); |
| | | } |
| | | |
| | | //检查是否在审批过程中 |
| | | //根据节点信息查询流程 |
| | | boolean active = flowCommonService.isProcessInstanceActive(packageNode.getProcessInstanceId()); |
| | | if(active){ |
| | | throw new ServiceException(programPackageName+"正在审批中,请勿重复入库。"); |
| | | } |
| | | |
| | | List<FlowProgramFile> flowFiles = new ArrayList<>(); |
| | | //查找包下的文件数据, |
| | | entryNameList.stream().filter(s -> s.startsWith(dir)).forEach(entryName -> { |
| | | log.info("{}下的文件:{}",dir,entryName); |
| | | |
| | | if(!entryName.endsWith("/")){ |
| | | //实际的文件 |
| | | String fileName = StringUtils.removeStart(entryName,dir);//去除文件名路径部分 |
| | | |
| | | try { |
| | | FlowProgramFile newFlowFile = new FlowProgramFile(); |
| | | newFlowFile.setProgramName(packageNode.getName()); |
| | | newFlowFile.setProcessInstanceId(null);//先置为空,启动流程后设置该值 |
| | | newFlowFile.setFileType("program"); |
| | | |
| | | InputStream ins = zipFile.getInputStream(zipFile.getEntry(entryName)); |
| | | BladeFile newOssFile = ossTemplate.putFile("mdm",fileName,ins); |
| | | newFlowFile.setOssName(newOssFile.getName()); |
| | | |
| | | flowFiles.add(newFlowFile); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | }); |
| | | |
| | | pkgIdFileMap.put(packageNode.getId(),flowFiles); |
| | | } |
| | | |
| | | } |
| | | |
| | | return pkgIdFileMap; |
| | | } |
| | | |
| | | /** |