| | |
| | | import org.springblade.mdm.program.entity.NcProgramExchange; |
| | | import org.springblade.mdm.program.mapper.NcProgramExchangeMapper; |
| | | import org.springblade.mdm.program.vo.DncSendBackData; |
| | | import org.springblade.mdm.utils.EntityUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | throw new ServiceException("文件为空"); |
| | | } |
| | | |
| | | if(StringUtils.endsWith(file.getOriginalFilename(),".zip")){ |
| | | throw new ServiceException("文件必须为zip包 "); |
| | | if(!StringUtils.endsWith(file.getOriginalFilename(),".zip")){ |
| | | throw new ServiceException("文件必须为zip包"); |
| | | } |
| | | try { |
| | | BladeFile bfile = ossTemplate.putFile(file);//上传,供后续入库使用 |
| | |
| | | for(String dir : dirList){ |
| | | String programPackageName = StringUtils.removeEnd(dir,"/"); |
| | | |
| | | NcNode oriProgramPkg = this.ncNodeService.getLastEditionTryingProgramPackage(programPackageName); |
| | | NcNode tryProgramPkg = this.ncNodeService.getLastEditionTryingProgramPackage(programPackageName); |
| | | NcNode curedProgramPkg = ncNodeService.getLastEditionCuredProgramPackage(programPackageName); |
| | | if(curedProgramPkg != null){ |
| | | throw new ServiceException(programPackageName+"已经固化,请勿重复入库。"); |
| | | } |
| | | if(oriProgramPkg == null){ |
| | | if(tryProgramPkg == null){ |
| | | log.warn("文件夹未发现匹配的程序包名{}",dir); |
| | | continue; |
| | | } |
| | | //检查是否在审批过程中 |
| | | //根据节点信息查询流程 |
| | | boolean active = flowCommonService.isProcessInstanceActive(oriProgramPkg.getProcessInstanceId()); |
| | | boolean active = flowCommonService.isProcessInstanceActive(tryProgramPkg.getProcessInstanceId()); |
| | | if(active){ |
| | | throw new ServiceException(programPackageName+"正在审批中,请勿重复入库。"); |
| | | } |
| | |
| | | throw new ServiceException(programPackageName+"已经固化,请勿重复入库。"); |
| | | }*/ |
| | | |
| | | if(!programPackageIdList.contains(oriProgramPkg.getId())){ |
| | | if(!programPackageIdList.contains(tryProgramPkg.getId())){ |
| | | //不在勾选的范围内 |
| | | log.info("{}不在勾选范围内",programPackageName); |
| | | continue; |
| | | } |
| | | NcNode newProgramPkg = new NcNode(); |
| | | BeanUtils.copyProperties(oriProgramPkg, newProgramPkg); |
| | | clearBaseProperties(newProgramPkg); |
| | | BeanUtils.copyProperties(tryProgramPkg, newProgramPkg); |
| | | EntityUtil.clearBaseProperties(newProgramPkg); |
| | | newProgramPkg.setIsLastEdition(1); |
| | | ncNodeService.save(newProgramPkg); |
| | | newProgramPackageNodeList.add(newProgramPkg); |
| | | |
| | | //旧数据更新为老版本 |
| | | oriProgramPkg.setIsLocked(1);//旧版自动锁定 |
| | | oriProgramPkg.setIsLastEdition(0);; |
| | | ncNodeService.updateById(oriProgramPkg); |
| | | tryProgramPkg.setIsLocked(1);//旧版自动锁定 |
| | | tryProgramPkg.setIsLastEdition(0);; |
| | | ncNodeService.updateById(tryProgramPkg); |
| | | |
| | | //List<FlowProgramFile> newFlowFiles = new ArrayList<>(); |
| | | List<NcNode> newProgramNodes = new ArrayList<>(); |
| | |
| | | if(!entryName.endsWith("/")){ |
| | | //实际的文件 |
| | | String fileName = StringUtils.removeStart(entryName,dir);//去除文件名路径部分 |
| | | NcNode oldProgramNode = this.ncNodeService.getLastEditionProgramFile(fileName,oriProgramPkg.getId()); |
| | | NcNode oldProgramNode = this.ncNodeService.getLastEditionProgramFile(fileName,tryProgramPkg.getId()); |
| | | if(oldProgramNode == null){ |
| | | log.info("{}找不到程序文件",entryName); |
| | | return; |
| | |
| | | |
| | | NcNode newProgramNode = new NcNode(); |
| | | BeanUtils.copyProperties(oldProgramNode, newProgramNode); |
| | | clearBaseProperties(newProgramNode); |
| | | EntityUtil.clearBaseProperties(newProgramNode); |
| | | newProgramNode.setIsLastEdition(1); |
| | | newProgramNode.setParentId(newProgramPkg.getId()); |
| | | newProgramNode.setParentIds(newProgramPkg.getParentIds()+","+newProgramPkg.getId()); |
| | |
| | | |
| | | FlowProgramFile oldFlowFile = flowProgramFileService.getById(newProgramNode.getFlowProgramFileId()); |
| | | |
| | | FlowProgramFile newFlowFile = new FlowProgramFile();//TODO |
| | | FlowProgramFile newFlowFile = new FlowProgramFile(); |
| | | BeanUtils.copyProperties(oldFlowFile, newFlowFile); |
| | | newFlowFile.setProcessInstanceId(null); |
| | | clearBaseProperties(newFlowFile); |
| | | EntityUtil.clearBaseProperties(newFlowFile); |
| | | |
| | | try { |
| | | InputStream ins = zipFile.getInputStream(zipFile.getEntry(entryName)); |
| | |
| | | newProgramNode.setFlowProgramFile(newFlowFile); |
| | | newProgramNode.setVersionNumber(oldProgramNode.genNewVersionNumber()); |
| | | newProgramNodes.add(newProgramNode); |
| | | oldProgramNode.setIsLastEdition(0); |
| | | oldProgramNode.setIsLocked(1); |
| | | ncNodeService.updateById(oldProgramNode); |
| | | //旧节点处理,咋办?如果导出工控网 重复导出呢?,isLastEdition不用设置了,因为 程序包节点 是新的 |
| | | //TODO 待验证 |
| | | //oldProgramNode.setIsLastEdition(原来是0); |
| | | //oldProgramNode.setIsLocked(1); |
| | | //ncNodeService.updateById(oldProgramNode); |
| | | } |
| | | }); |
| | | |
| | |
| | | entity.setCreateUser(jsonObject.getLong("createUser")); |
| | | entity.setUpdateUser(jsonObject.getLong("updateUser")); |
| | | } |
| | | |
| | | /* |
| | | void clearBaseProperties(BizEntity entity){ |
| | | entity.setId(null); |
| | | entity.setCreateTime(null); |
| | |
| | | entity.setStatus(null); |
| | | entity.setCreateUser(null); |
| | | entity.setUpdateUser(null); |
| | | } |
| | | }*/ |
| | | } |