Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsLifeCycleDTO.java
@@ -1,5 +1,8 @@ package com.vci.dto; import com.vci.pagemodel.OsLifeCycleLineBoundVO; import com.vci.pagemodel.OsLifeCycleLineVO; import java.util.Date; import java.util.List; @@ -56,10 +59,75 @@ private Date ts; /** * 创建人 */ private String creator; /** * 创建时间 */ private Date createTime; /** * 最后修改人 */ private String lastModifier; /** * 最后修改时间,格式是yyyy-MM-dd HH:mm:ss */ private Date lastModifyTime; /** * 包含的连接线 */ private List<OsLifeCycleLineDTO> lineDTOList; /** * 链接线 */ private OsLifeCycleLineBoundVO[] bounds; public void setCreator(String creator) { this.creator = creator; } public void setCreateTime(Date createTime) { this.createTime = createTime; } public void setLastModifier(String lastModifier) { this.lastModifier = lastModifier; } public void setLastModifyTime(Date lastModifyTime) { this.lastModifyTime = lastModifyTime; } public void setBounds(OsLifeCycleLineBoundVO[] bounds) { this.bounds = bounds; } public String getCreator() { return creator; } public Date getCreateTime() { return createTime; } public String getLastModifier() { return lastModifier; } public Date getLastModifyTime() { return lastModifyTime; } public OsLifeCycleLineBoundVO[] getBounds() { return bounds; } public String getOid() { return oid; } Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java
@@ -1,15 +1,34 @@ package com.vci.web.controller; import com.vci.constant.FrameWorkLangCodeConstant; import com.vci.dto.OsAttributeDTO; import com.vci.dto.OsLifeCycleDTO; import com.vci.pagemodel.OsAttributeVO; import com.vci.starter.web.annotation.controller.VciUnCheckRight; import com.vci.starter.web.annotation.log.VciBusinessLog; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.pagemodel.OsERVO; import com.vci.pagemodel.OsLifeCycleVO; import com.vci.starter.web.util.ControllerUtil; import com.vci.starter.web.util.LocalFileUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.web.service.OsLifeCycleServiceI; import com.vci.web.util.Func; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.util.Date; import java.util.List; /** * 生命周期的控制器 @@ -18,6 +37,7 @@ */ @RequestMapping("/lifeCycleController") @RestController @VciUnCheckRight public class OsLifeCycleController { /** @@ -25,6 +45,11 @@ */ @Autowired private OsLifeCycleServiceI lifeCycleService; /** * 日志 */ private Logger logger = LoggerFactory.getLogger(getClass()); /** * 生命周期列表 @@ -45,4 +70,147 @@ public BaseResult<OsERVO> listLinesPic(String id){ return BaseResult.success(lifeCycleService.listLinesPic(id)); } /** * 查询应用范围 * @param lifeCycleName 版本规则英文名称 * @return */ @GetMapping("/getUsedLifeCycleList") public BaseResult getUsedLifeCycleList(String lifeCycleName){ try { return BaseResult.dataList(lifeCycleService.getUsedLifeCycleList(lifeCycleName)); }catch (Exception e) { e.printStackTrace(); String exceptionMessage = "版本规则应用范围查询时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); return BaseResult.fail(exceptionMessage); } } /** * 添加单条生命周期 * @param osLifeCycleVO * @return 列表的内容 */ @PostMapping( "/addLifeCycle") @VciBusinessLog(operateName = "添加生命周期") public BaseResult addLifeCycle(@RequestBody OsLifeCycleVO osLifeCycleVO) { try { return lifeCycleService.addLifeCycle(osLifeCycleVO) ? BaseResult.success("生命周期添加成功!"):BaseResult.fail("生命周期添加失败!"); }catch (Exception e) { e.printStackTrace(); String exceptionMessage = "添加生命周期时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); return BaseResult.fail(exceptionMessage); } } /** * 修改单条生命周期 * @param osLifeCycleVO * @return 列表的内容 */ @PutMapping( "/updateLifeCycle") @VciBusinessLog(operateName = "修改生命周期") public BaseResult updateLifeCycle(@RequestBody OsLifeCycleVO osLifeCycleVO) { try { return lifeCycleService.updateLifeCycle(osLifeCycleVO) ? BaseResult.success("生命周期修改成功!"):BaseResult.fail("生命周期修改失败!"); }catch (Exception e) { e.printStackTrace(); String exceptionMessage = "修改生命周期时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); return BaseResult.fail(exceptionMessage); } } /** * 删除生命周期 * @param lifeCycleDTOS * @return 列表的内容 */ @DeleteMapping( "/deleteLifeCycles") @VciBusinessLog(operateName = "删除生命周期") public BaseResult deleteLifeCycles(@RequestBody List<OsLifeCycleDTO> lifeCycleDTOS) { try { return lifeCycleService.deleteLifeCycles(lifeCycleDTOS) ? BaseResult.success("生命周期删除成功!"):BaseResult.fail("生命周期删除失败!"); }catch (Exception e) { e.printStackTrace(); String exceptionMessage = "删除生命周期时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); logger.error(exceptionMessage); return BaseResult.fail(exceptionMessage); } } /** * 导出选中的生命周期 * @param exportFileName 导出的文件名 * @param lcNames 需要导出的生命周期英文名称 * @param response */ @GetMapping( "/exportLifeCycles") @VciBusinessLog(operateName = "导出生命周期") public void exportLifeCycles(String exportFileName,String lcNames, HttpServletResponse response){ try { String excelPath = lifeCycleService.exportLifeCycles(exportFileName,lcNames,false); ControllerUtil.writeFileToResponse(response,excelPath); } catch (Exception e) { String msg = "导出生命周期时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); try { //出错时 e.printStackTrace(); ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null); } catch (IOException ioException) { ioException.printStackTrace(); } } } /** * 下载生命周期导入模板 * @param exportFileName * @param response */ @GetMapping( "/downloadLifeCycleTemplate") @VciBusinessLog(operateName = "下载生命周期导入模板") public void downloadLifeCycleTemplate(String exportFileName, HttpServletResponse response){ try { String excelPath = lifeCycleService.downloadLifeCycleTemplate(exportFileName); ControllerUtil.writeFileToResponse(response,excelPath); } catch (Exception e) { String msg = "下载生命周期导入模板时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e); try { //出错时 e.printStackTrace(); ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null); } catch (IOException ioException) { ioException.printStackTrace(); } } } /** * 导入生命周期 * @param file * @return */ @PostMapping("/importLifeCycles") @VciBusinessLog(operateName = "导入生命周期") public BaseResult importLifeCycles(MultipartFile file){ String excelFileName = LocalFileUtil.getDefaultTempFolder() + File.separator + LocalFileUtil.getFileNameForIE(file.getOriginalFilename()); File file1 = new File(excelFileName); try { file.transferTo(new File(excelFileName)); if (file != null) { return lifeCycleService.importLifeCycles(file1); } else { return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"无导入的文件"}); } }catch (Throwable e) { throw new VciBaseException(VciBaseUtil.getExceptionMessage(e),new String[0],e); }finally { file1.delete(); } } } Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsRevisionRuleController.java
@@ -156,7 +156,7 @@ * @param response */ @GetMapping( "/downloadAttributeTemplate") @VciBusinessLog(operateName = "导出版本规则") @VciBusinessLog(operateName = "下载版本规则导入模板") public void downloadVersionRuleTemplate(String exportFileName, HttpServletResponse response){ try { String excelPath = revisionRuleServiceI.downloadVersionRuleTemplate(exportFileName); Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java
@@ -1,15 +1,17 @@ package com.vci.web.service; import com.vci.corba.common.PLException; import com.vci.corba.omd.data.BusinessObject; import com.vci.corba.omd.lcm.LifeCycle; import com.vci.dto.OsAttributeDTO; import com.vci.dto.OsLifeCycleDTO; import com.vci.pagemodel.*; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.pagemodel.OsERVO; import com.vci.pagemodel.OsLifeCycleLineVO; import com.vci.pagemodel.OsLifeCycleVO; import com.vci.pagemodel.OsStatusVO; import java.io.File; import java.util.Collection; import java.util.List; import java.util.Map; @@ -21,8 +23,7 @@ */ public interface OsLifeCycleServiceI extends OsBaseServiceI{ /*** /** * 获取生命周期的状态对应的中文值 * @param status 状态 * @return 状态的显示名称 @@ -68,6 +69,7 @@ * @return 生命周期的显示对象 */ OsLifeCycleVO getLifeCycleById(String lctId) ; /** * 生命周期的数据对象转换为显示对象 * @param lifeCycles 数据对象 @@ -160,7 +162,7 @@ void batchEditLifeCycle(List<LifeCycle> lifeCycleList); /** * 状态在生命周期中使用的勤快 * 状态在生命周期中使用的情况 * @param statusOid 状态的主键 * @return 生命周期的信息 */ @@ -181,9 +183,61 @@ DataGrid<OsLifeCycleVO> gridLifeCycle(BaseQueryObject baseQueryObject); /** * 新增单条生命周期 * @param osLifeCycleVO * @return */ boolean addLifeCycle(OsLifeCycleVO osLifeCycleVO) throws PLException; /** * 修改生命周期 * @param osLifeCycleVO * @return */ boolean updateLifeCycle(OsLifeCycleVO osLifeCycleVO) throws PLException; /** * 删除生命周期 * @param lifeCycleDTOS * @return */ boolean deleteLifeCycles(List<OsLifeCycleDTO> lifeCycleDTOS) throws PLException; /** * 查看生命周期的使用范围 * @return */ List<Map<String,String>> getUsedLifeCycleList(String lifeCycleName) throws PLException; /** * 导出选中的生命周期 * @param exportFileName 导出的文件名 * @param lcNames 需要导出的生命周期名称 * @param flag 控制导出的列名是否和导入模板一致 * @return */ String exportLifeCycles(String exportFileName,String lcNames,boolean flag/*控制导出的列名是否和导入模板一致*/) throws PLException; /** * 下载生命周期导入模板 * @param exportFileName * @return * @throws PLException */ String downloadLifeCycleTemplate(String exportFileName) throws Exception; /** * 导入生命周期 * @param file * @return */ BaseResult importLifeCycles(File file) throws Exception; /** * 生命周期的链接线 * @param id 编号 * @return ER图内容 */ OsERVO listLinesPic(String id); } Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java
@@ -5,16 +5,26 @@ import com.vci.corba.omd.lcm.Bound; import com.vci.corba.omd.lcm.LifeCycle; import com.vci.corba.omd.lcm.TransitionVO; import com.vci.corba.omd.lcm.TransitionVOEvent; import com.vci.corba.omd.vrm.VersionRule; import com.vci.dto.OsLifeCycleDTO; import com.vci.dto.OsLifeCycleLineDTO; import com.vci.dto.OsLifeCycleLineEventDTO; import com.vci.dto.OsRevisionRuleDTO; import com.vci.pagemodel.*; import com.vci.starter.web.annotation.log.VciUnLog; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseQueryObject; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.VciDateUtil; import com.vci.model.OsLifeCycleDO; import com.vci.starter.web.util.WebThreadLocalUtil; import com.vci.web.service.OsLifeCycleServiceI; import com.vci.web.service.OsStatusServiceI; import com.vci.web.service.WebBoServiceI; import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; @@ -25,6 +35,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.swing.*; import java.io.File; import java.util.*; import java.util.stream.Collectors; @@ -88,7 +100,7 @@ * @throws VciBaseException 如果目标生命周期和当前生命周期状态没有连接线时抛出异常 */ @Override public void transStatus(com.vci.corba.omd.data.BusinessObject bo, String targetStatus) public void transStatus(BusinessObject bo, String targetStatus) throws VciBaseException { WebUtil.alertNotNull(bo,"业务数据对象",bo.lctId,"生命周期编码",bo.lcStatus,"当前生命周期状态",targetStatus,"目标生命周期状态"); OsLifeCycleLineVO transVO = getTransVO(bo.lctId, bo.lcStatus, targetStatus); @@ -109,7 +121,7 @@ * @throws VciBaseException 转换生命周期出错的时候抛出异常 */ @Override public void transStatus(List<com.vci.corba.omd.data.BusinessObject> boList, String targetStatus) public void transStatus(List<BusinessObject> boList, String targetStatus) throws VciBaseException { WebUtil.alertNotNull(boList,"业务数据对象",targetStatus,"目标对象"); transStatus(boList.toArray(new com.vci.corba.omd.data.BusinessObject[0]), targetStatus); @@ -122,13 +134,13 @@ * @throws VciBaseException 转换生命周期出错的时候抛出异常 */ @Override public void transStatus(com.vci.corba.omd.data.BusinessObject[] bos, String targetStatus) public void transStatus(BusinessObject[] bos, String targetStatus) throws VciBaseException { WebUtil.alertNotNull(bos,"业务数据对象",targetStatus,"目标对象"); List<OsLifeCycleLineVO> transVOList = new ArrayList<>(); List<com.vci.corba.omd.data.BusinessObject> transBOs = new ArrayList<>(); List<BusinessObject> transBOs = new ArrayList<>(); for(int i = 0 ; i < bos.length ; i ++){ com.vci.corba.omd.data.BusinessObject bo = bos[i]; BusinessObject bo = bos[i]; WebUtil.alertNotNull(bo,"业务数据对象",bo.lctId,"生命周期编码",bo.lcStatus,"当前生命周期状态"); OsLifeCycleLineVO transVO = getTransVO(bo.lctId, bo.lcStatus, targetStatus); if(transVO!=null){ @@ -141,7 +153,7 @@ } } if(!CollectionUtils.isEmpty(transBOs)) { batchTransVo(transBOs.toArray(new com.vci.corba.omd.data.BusinessObject[0]), transVOList.toArray(new OsLifeCycleLineVO[0])); batchTransVo(transBOs.toArray(new BusinessObject[0]), transVOList.toArray(new OsLifeCycleLineVO[0])); } } @@ -264,10 +276,11 @@ lifeCyle.name = lifeCycleVO.getId(); lifeCyle.tag = lifeCycleVO.getName(); lifeCyle.oid = lifeCycleVO.getOid(); lifeCyle.creator = lifeCycleVO.getCreator(); String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); lifeCyle.creator = Func.isBlank(lifeCycleVO.getCreator()) ? userId:lifeCycleVO.getCreator(); lifeCyle.description = lifeCycleVO.getDescription(); lifeCyle.modifier = lifeCycleVO.getLastModifier(); lifeCyle.modifyTime = lifeCycleVO.getLastModifyTime() != null ? lifeCycleVO.getLastModifyTime().getTime():null; lifeCyle.modifier = Func.isBlank(lifeCycleVO.getLastModifier()) ? userId:lifeCycleVO.getLastModifier(); lifeCyle.modifyTime = System.currentTimeMillis(); lifeCyle.createTime = lifeCycleVO.getCreateTime() != null ? lifeCycleVO.getCreateTime().getTime():null; lifeCyle.startState =lifeCycleVO.getStartStatus(); lifeCyle.ts = VciDateUtil.date2Str(lifeCycleVO.getTs(),VciDateUtil.DateTimeMillFormat); @@ -360,7 +373,6 @@ return Optional.ofNullable(life.getLines()).orElseGet(()->new ArrayList<>()).stream().filter(s->s.getSourceLifeStatus().equalsIgnoreCase(currentStatus) && s.getTargetLifeStatus().equalsIgnoreCase(targetStatus)).findFirst().orElseGet(()->null); } /** * 跃迁业务类型的生命周期状态 * @param obj 业务类型数据对象 @@ -368,10 +380,10 @@ * @throws VciBaseException 跃迁出错的是会抛出异常 */ @Override public void doTransVO(com.vci.corba.omd.data.BusinessObject obj,OsLifeCycleLineVO lineVO) throws VciBaseException { public void doTransVO(BusinessObject obj,OsLifeCycleLineVO lineVO) throws VciBaseException { if(lineVO!=null){ try { com.vci.corba.omd.lcm.TransitionVO transitionVO = lifeCycleLineVO2DO(lineVO); TransitionVO transitionVO = lifeCycleLineVO2DO(lineVO); platformClientUtil.getBOFService().transferBusinessObject(obj, transitionVO.destination); } catch (PLException e) { throw WebUtil.getVciBaseException(e); @@ -386,21 +398,21 @@ * @param lineVO 连接线对象 * @return 平台的连接线对象 */ private com.vci.corba.omd.lcm.TransitionVO lifeCycleLineVO2DO(OsLifeCycleLineVO lineVO){ private TransitionVO lifeCycleLineVO2DO(OsLifeCycleLineVO lineVO){ com.vci.corba.omd.lcm.TransitionVO transitionVO = new com.vci.corba.omd.lcm.TransitionVO(); transitionVO.id = lineVO.getOid(); transitionVO.source = lineVO.getSourceLifeStatus(); transitionVO.destination = lineVO.getTargetLifeStatus(); transitionVO.connect = lineVO.getName() == null?"":lineVO.getName(); //加事件 com.vci.corba.omd.lcm.TransitionVOEvent[] events; TransitionVOEvent[] events; if(lineVO.getEvents() == null || lineVO.getEvents().length == 0){ events = new com.vci.corba.omd.lcm.TransitionVOEvent[0]; events = new TransitionVOEvent[0]; }else{ events = new com.vci.corba.omd.lcm.TransitionVOEvent[lineVO.getEvents().length]; events = new TransitionVOEvent[lineVO.getEvents().length]; for (int j = 0; j < lineVO.getEvents().length; j++) { OsLifeCycleLineEventVO eventVO = lineVO.getEvents()[j]; com.vci.corba.omd.lcm.TransitionVOEvent event = new com.vci.corba.omd.lcm.TransitionVOEvent(); TransitionVOEvent event = new TransitionVOEvent(); event.id = eventVO.getOid(); event.name = eventVO.getEventFullName(); events[j] = event; @@ -417,7 +429,7 @@ * @throws VciBaseException 跃迁出错的是会抛出异常 */ @Override public void batchTransVo(com.vci.corba.omd.data.BusinessObject[] bos,OsLifeCycleLineVO[] vos) throws VciBaseException{ public void batchTransVo(BusinessObject[] bos,OsLifeCycleLineVO[] vos) throws VciBaseException{ batchTransVo(bos,vos,null); } @@ -456,6 +468,8 @@ if(!CollectionUtils.isEmpty(lifeCyleList)){ lifeCyleList.stream().forEach(lifeCyle -> { try { //校验生命周期是否合规 this.checkLifeCycle(lifeCyle,true); platformClientUtil.getLifeCycleService().addLifeCycle(lifeCyle); } catch (PLException e) { throw WebUtil.getVciBaseException(e); @@ -474,6 +488,8 @@ if(!CollectionUtils.isEmpty(lifeCycleList)){ lifeCycleList.stream().forEach(lifeCyle -> { try { //校验生命周期是否合规 this.checkLifeCycle(lifeCyle,false); platformClientUtil.getLifeCycleService().modifyLifeCycle(lifeCyle); } catch (PLException e) { throw WebUtil.getVciBaseException(e); @@ -537,6 +553,190 @@ } /** * 新增单条生命周期 * @param osLifeCycleVO * @return */ @Override public boolean addLifeCycle(OsLifeCycleVO osLifeCycleVO) throws PLException { VciBaseUtil.alertNotNull(osLifeCycleVO,"生命周期模板"); LifeCycle lifeCycle = lifeCycleVO2DO(osLifeCycleVO); //生命周期合规校验 checkLifeCycle(lifeCycle,true); return platformClientUtil.getLifeCycleService().addLifeCycle(lifeCycle); } /** * 修改生命周期 * @param osLifeCycleVO * @return */ @Override public boolean updateLifeCycle(OsLifeCycleVO osLifeCycleVO) throws PLException { VciBaseUtil.alertNotNull(osLifeCycleVO,"生命周期模板"); //查询修改的生命周期是否存在 LifeCycle dbLifeCycle = platformClientUtil.getLifeCycleService().getLifeCycle(osLifeCycleVO.getId()); if(Func.isEmpty(dbLifeCycle) || Func.isBlank(dbLifeCycle.oid)){ throw new PLException("500",new String[]{"修改生命周期模板不存在!"}); } osLifeCycleVO.setCreator(dbLifeCycle.creator); osLifeCycleVO.setCreateTime(new Date(dbLifeCycle.createTime)); LifeCycle lifeCycle = lifeCycleVO2DO(osLifeCycleVO); //检查生命周期修改是否和规 checkLifeCycle(lifeCycle,false); return platformClientUtil.getLifeCycleService().modifyLifeCycle(lifeCycle); } /** * 删除生命周期 * @param lifeCycleDTOS * @return */ @Override public boolean deleteLifeCycles(List<OsLifeCycleDTO> lifeCycleDTOS) throws PLException { VciBaseUtil.alertNotNull(lifeCycleDTOS,"待删除的生命周期列表"); //判断要删除的生命周期是否有被引用 lifeCycleDTOS.stream().forEach(item->{ String lifeCycleName = item.getId(); try { List<Map<String, String>> usedLifeCycleList = this.getUsedLifeCycleList(lifeCycleName); if(Func.isNotEmpty(usedLifeCycleList)){ throw new VciBaseException("该生命周期已被使用不允许删除"); } } catch (PLException e) { logger.error(e.getMessage()); e.printStackTrace(); throw new VciBaseException(e.getMessage()); } }); //平台的deleteStatus方法必传三个参数,oid、name和ts List<LifeCycle> lcList = new ArrayList<>(); for(OsLifeCycleDTO lcDTO : lifeCycleDTOS){ //oid和ts判空 String oid = lcDTO.getOid(); //id主要用来对缓存数据删除 String id = lcDTO.getId(); //后台会用ts进行数据一致性校验 Date ts = lcDTO.getTs(); if(Func.isBlank(oid) || Func.isBlank(id) || Func.isEmpty(ts)){ throw new PLException("500",new String[]{"待删除的生命周期列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"}); } LifeCycle vr = new LifeCycle(); vr.oid = oid; vr.name = id; vr.ts = Func.format(ts,VciDateUtil.DateTimeMillFormat); lcList.add(vr); } return platformClientUtil.getLifeCycleService().deleteLifeCycles(lcList.toArray(new LifeCycle[lcList.size()])); } /** * 查看生命周期的使用范围 * @return */ @Override public List<Map<String, String>> getUsedLifeCycleList(String lifeCycleName) throws PLException { if(Func.isBlank(lifeCycleName)){ throw new PLException("500",new String[]{"请选择要查询使用范围的生命周期模板!"}); } String[] btNames = platformClientUtil.getBtmService().getBTNamesByLCName(lifeCycleName); if(Func.isEmpty(btNames)){ return new ArrayList<>(); } List<Map<String,String>> btmNameMapList = new ArrayList<>(); Arrays.stream(btNames).forEach(btName->{ Map<String, String> itemMap = new HashMap<>(); itemMap.put("lifeCycleName",lifeCycleName); itemMap.put("source",btName); btmNameMapList.add(itemMap); }); return btmNameMapList; } /** * 导出选中的生命周期 * @param exportFileName 导出的文件名 * @param lcNames 需要导出的生命周期名称 * @param flag 控制导出的列名是否和导入模板一致 * @return */ @Override public String exportLifeCycles(String exportFileName, String lcNames, boolean flag) throws PLException { return null; } /** * 下载生命周期导入模板 * @param exportFileName * @return * @throws PLException */ @Override public String downloadLifeCycleTemplate(String exportFileName) throws Exception { return null; } /** * 导入生命周期 * @param file * @return */ @Override public BaseResult importLifeCycles(File file) throws Exception { return null; } /** * 检查生命周期名称是否已存在 * @param name * @return */ public boolean checkLCExist(String name) { try { LifeCycle lc = platformClientUtil.getLifeCycleService().getLifeCycle(name); if (lc != null && !lc.name.equals("")) { return true; } } catch (PLException e) { // TODO Auto-generated catch block e.printStackTrace(); logger.error(VciBaseUtil.getExceptionMessage(e)); } return false; } /** * 检查生命周期是否合规 * @param lifeCycle * @param isAdd 是否为新增 * @throws PLException */ public void checkLifeCycle(LifeCycle lifeCycle,boolean isAdd) throws PLException { String name = lifeCycle.name; if (Func.isBlank(name)) { throw new PLException("500", new String[]{"请输入生命周期名称!"}); } if (!name.matches("[a-z A-Z]*")) { throw new PLException("500", new String[]{"生命周期名称只能为英文字母!"}); } if (isAdd && checkLCExist(name)) { throw new PLException("500", new String[]{"该生命周期名称已经存在!"}); } if (Func.isBlank(lifeCycle.startState)) { throw new PLException("500", new String[]{"请选择开始状态!"}); } } /** * 生命周期的链接线 * * @param id 编号 @@ -580,7 +780,6 @@ return ervo; } /** * 批量执行跃迁操作,要求必须是同一个业务类型下的 * @param bos 业务类型数据对象 @@ -589,7 +788,7 @@ * @throws VciBaseException 跃迁出错的是会抛出异常 */ @Override public void batchTransVo(com.vci.corba.omd.data.BusinessObject[] bos,OsLifeCycleLineVO[] lineVOs,String[] releaseStatus) throws VciBaseException{ public void batchTransVo(BusinessObject[] bos,OsLifeCycleLineVO[] lineVOs,String[] releaseStatus) throws VciBaseException{ if(bos!=null && lineVOs != null && lineVOs.length == bos.length){ try { if(releaseStatus == null){ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java
@@ -151,8 +151,8 @@ osRevisionRuleDTOS.stream().forEach(item->{ String vrName = item.getId(); try { String[] btNamesByVerName = platformClientUtil.getBtmService().getBTNamesByVerName(vrName); if(btNamesByVerName != null && btNamesByVerName.length > 0){ List<Map<String, String>> usedVersionRuleList = this.getUsedVersionRuleList(vrName); if(Func.isNotEmpty(usedVersionRuleList)){ throw new VciBaseException("该版本已被使用不允许删除"); } } catch (PLException e) { @@ -172,7 +172,7 @@ //后台会用ts进行数据一致性校验 Date ts = vrDTO.getTs(); if(Func.isBlank(oid) || Func.isBlank(id) || Func.isEmpty(ts)){ throw new PLException("500",new String[]{"待删除的状态列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"}); throw new PLException("500",new String[]{"待删除的版本规则列表中主键【oid】、调整时间【ts】、状态名称【name】不能为空!"}); } VersionRule vr = new VersionRule(); vr.oid = oid; @@ -194,7 +194,8 @@ throw new PLException("500",new String[]{"名称只能为英文!"}); } //跳跃字符只能为数字或者字母 if(Func.isNotBlank(dto.getJumpCharacter()) && (!(dto.getJumpCharacter().matches(regex)))){ String regex0 = "^[a-zA-Z0-9,]+$"; if(Func.isNotBlank(dto.getJumpCharacter()) && (!(dto.getJumpCharacter().matches(regex0)))){ throw new PLException("500",new String[]{"跳跃字符只能为数字或者字母!"}); } //初始值不能为空且只能为数字或者字母或英文状态下的符号