From c92be9df89d2c72d8d9fc4d0c7c54f53e1897521 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期五, 02 八月 2024 15:44:31 +0800 Subject: [PATCH] 生命周期新增修改查询等接口上传 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java | 239 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 219 insertions(+), 20 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java index 96c7c05..7f4a3fd 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java +++ b/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()); + } + }); + + //骞冲彴鐨刣eleteStatus鏂规硶蹇呬紶涓変釜鍙傛暟锛宱id銆乶ame鍜宼s + List<LifeCycle> lcList = new ArrayList<>(); + for(OsLifeCycleDTO lcDTO : lifeCycleDTOS){ + //oid鍜宼s鍒ょ┖ + 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[]{"寰呭垹闄ょ殑鐢熷懡鍛ㄦ湡鍒楄〃涓富閿�恛id銆戙�佽皟鏁存椂闂淬�恡s銆戙�佺姸鎬佸悕绉般�恘ame銆戜笉鑳戒负绌猴紒"}); + } + 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){ -- Gitblit v1.9.3