From daf9ff33f0a36c9037af70f574697d80174915f8 Mon Sep 17 00:00:00 2001 From: ludc Date: 星期二, 06 八月 2024 11:54:23 +0800 Subject: [PATCH] 生命周期所有接口上传(待联调) --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java | 2 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleVO.java | 4 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java | 325 ++++++++++++++++++++++++++++++++++++++-- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java | 18 ++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java | 2 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleLineBoundVO.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java | 2 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsLifeCyclePO.java | 90 +++++++++++ Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java | 2 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java | 2 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java | 16 + 12 files changed, 435 insertions(+), 32 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleLineBoundVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleLineBoundVO.java index 715f62a..c6f238d 100644 --- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleLineBoundVO.java +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleLineBoundVO.java @@ -1,7 +1,7 @@ package com.vci.pagemodel; /** - * 鐢熷懡鍛ㄦ湡鐨勮繛鎺ョ嚎 + * 鐢熷懡鍛ㄦ湡鐨勫浘鏍囧ぇ灏忓拰鍧愭爣 * @author weidy * @date 2022-1-12 */ diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleVO.java index e657789..0c0b501 100644 --- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleVO.java +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/OsLifeCycleVO.java @@ -89,10 +89,10 @@ /** * 鍖呭惈杩炴帴绾� */ - private List<OsLifeCycleLineVO> lines ; + private List<OsLifeCycleLineVO> lines; /** - * 閾炬帴绾� + * 鐢熷懡鍛ㄦ湡鐨勫浘鏍囧ぇ灏忓拰鍧愭爣 */ private OsLifeCycleLineBoundVO[] bounds; diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java index 4bab322..6da74b4 100644 --- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsEnumPO.java @@ -32,7 +32,7 @@ private String rowIndex; /** - * 灞炴�ц嫳鏂囧悕绉� + * 鑻辨枃鍚嶇О */ @ExcelColumn(value="鏋氫妇鍚嶇О",nullable = false) private String id; diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsLifeCyclePO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsLifeCyclePO.java new file mode 100644 index 0000000..befabeb --- /dev/null +++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/po/OsLifeCyclePO.java @@ -0,0 +1,90 @@ +package com.vci.po; + +import com.vci.dto.OsEnumItemDTO; +import com.vci.dto.OsLifeCycleLineDTO; +import com.vci.pagemodel.OsLifeCycleLineBoundVO; +import com.vci.pagemodel.OsLifeCycleLineVO; +import com.vci.starter.poi.annotation.ExcelColumn; +import com.vci.starter.web.pagemodel.BaseModelVO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.ArrayList; +import java.util.List; + +/** + * 鐢熷懡鍛ㄦ湡瀵煎叆瀵硅薄 + * @author ludc + * @date 2024/7/19 11:11 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class OsLifeCyclePO extends BaseModelVO { + + /** + * 绂佹淇敼杩欎釜鍊� + */ + private static final long serialVersionUID = -2239512786206928201L; + + /** + * 鎵�鍦ㄦ暟鎹 + */ + @ExcelColumn(rowIndexColumn = true,value = "") + private String rowIndex; + + /** + * 鐢熷懡鍛ㄦ湡鑻辨枃鍚嶇О + */ + @ExcelColumn(value="鍚嶇О",nullable = false) + private String id; + + /** + * 鏍囩 + */ + @ExcelColumn(value="鏍囩") + private String name; + + /** + * 璧峰鐘舵�� + */ + @ExcelColumn(value="璧峰鐘舵��",nullable = false) + private String startStatus; + + /** + * 鎻忚堪 + */ + @ExcelColumn(value="鎻忚堪") + private String description; + + /** + * 杩炴帴绾垮悕绉� + */ + /*@ExcelColumn(value="杩炴帴绾垮悕绉�") + private String lineName;*/ + + /** + * 杩炴帴绾胯捣濮嬬姸鎬� + */ + @ExcelColumn(value="杩炴帴绾胯捣濮嬬姸鎬�") + private String sourceLifeStatus; + + /** + * 杩炴帴绾跨洰鏍囩姸鎬� + */ + @ExcelColumn(value="杩炴帴绾跨洰鏍囩姸鎬�") + private String targetLifeStatus; + + /** + * 浜嬩欢 + */ + @ExcelColumn(value="浜嬩欢(;闂撮殧)") + private String events; + + /** + * 鐢ㄤ簬鏁寸悊鎴�1瀵瑰鍏崇郴鏃朵娇鐢紝涓嶉拡瀵瑰鍏ヤ娇鐢� + */ + private List<OsLifeCycleLineVO> lineItems = new ArrayList<>(); + +} diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java index bbffffa..e0aedfc 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/OrgDeptQueryServiceImpl.java @@ -924,7 +924,7 @@ }); }catch (Exception e){ if(logger.isErrorEnabled()){ - logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage()); + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨閮ㄩ棬鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",e.getMessage()); } e.printStackTrace(); return BaseResult.fail(LangBaseUtil.getErrorMsg(e),new String[]{},e); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java index 7f30454..c4460b8 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java @@ -1,9 +1,7 @@ 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; @@ -213,4 +211,20 @@ } } + /** + * 鏌ヨ鎵�鏈夎穬杩佷簨浠秌ey + * @return + */ + @GetMapping("/getLCEventKeys") + public BaseResult getLCEventKeys(){ + try { + return BaseResult.dataList(lifeCycleService.getLCEventKeys()); + }catch (Exception e) { + e.printStackTrace(); + String exceptionMessage = "璺冭縼浜嬩欢鏌ヨ鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e); + logger.error(exceptionMessage); + return BaseResult.fail(exceptionMessage); + } + } + } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java index ea30ac7..066152f 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java @@ -3,7 +3,6 @@ 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; @@ -89,7 +88,7 @@ * @param lifeCycleVO 鏄剧ず瀵硅薄 * @return 鏁版嵁瀵硅薄 */ - LifeCycle lifeCycleVO2DO(OsLifeCycleVO lifeCycleVO); + LifeCycle lifeCycleVO2DO(OsLifeCycleVO lifeCycleVO) throws PLException; /** * 鏌ヨ鎵�鏈夌敓鍛藉懆鏈熺姸鎬� @@ -148,6 +147,13 @@ * @return 鐘舵�佺殑鏄剧ず瀵硅薄 */ List<OsStatusVO> listStatusById(String lifeCycleId); + + /** + * 浣跨敤澶氫釜缂栧彿鑾峰彇鐢熷懡鍛ㄦ湡鐨勫璞� + * @param lcIdList 缂栧彿 + * @return 鏄剧ず瀵硅薄 + */ + List<OsLifeCycleVO> getLifeCycleByIds(Collection<String> lcIdList); /** * 鎵归噺娣诲姞鐢熷懡鍛ㄦ湡 @@ -240,4 +246,10 @@ */ OsERVO listLinesPic(String id); + /** + * 鏌ヨ鎵�鏈夎穬杩佷簨浠秌ey + * @return + */ + List<String> getLCEventKeys() throws PLException; + } diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java index 3af2c48..c95d0bf 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsAttributeServiceImpl.java @@ -1091,7 +1091,7 @@ }); }catch (Exception e){ if(logger.isErrorEnabled()){ - logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨灞炴�ф椂鍑虹幇浜嗛敊璇紝鍏蜂綋鍘熷洜锛�",VciBaseUtil.getExceptionMessage(e)); } e.printStackTrace(); return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java index c76ea0b..7628f7e 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsEnumServiceImpl.java @@ -642,7 +642,7 @@ } }catch (Exception e){ if(logger.isErrorEnabled()){ - logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鏋氫妇鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); } e.printStackTrace(); return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); 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 7f4a3fd..a8e5b77 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 @@ -6,21 +6,21 @@ 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.dto.*; import com.vci.pagemodel.*; +import com.vci.po.OsLifeCyclePO; +import com.vci.starter.poi.bo.ReadExcelOption; +import com.vci.starter.poi.bo.WriteExcelData; +import com.vci.starter.poi.bo.WriteExcelOption; +import com.vci.starter.poi.constant.ExcelLangCodeConstant; +import com.vci.starter.poi.util.ExcelUtil; 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.starter.web.util.*; 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; @@ -28,6 +28,7 @@ import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.util.HSSFColor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -76,6 +77,11 @@ */ @Autowired private WebBoServiceI boService; + + /** + * 蹇呭~鍒� + */ + private List<Integer> ColumnNameisRed = new ArrayList<Integer>(); /** * 鏃ュ織 @@ -226,8 +232,25 @@ e.printStackTrace(); } life.setOid(lifeCycle.oid); + Bound[] bounds = lifeCycle.bounds; + if(bounds != null && bounds.length>0){ + List<OsLifeCycleLineBoundVO> boundVOList = new ArrayList<>(); + Arrays.stream(bounds).forEach(bound->{ + OsLifeCycleLineBoundVO boundVO = new OsLifeCycleLineBoundVO(); + boundVO.setId(bound.id); + boundVO.setCellx(bound.cellx); + boundVO.setCelly(bound.celly); + boundVO.setCellh(bound.cellh); + boundVO.setCellw(bound.cellw); + boundVO.setCellicon(bound.cellicon); + boundVOList.add(boundVO); + }); + life.setBounds(boundVOList.toArray(new OsLifeCycleLineBoundVO[boundVOList.size()])); + }else{ + life.setBounds(new OsLifeCycleLineBoundVO[0]); + } List<OsLifeCycleLineVO> lineVOS = new ArrayList<>(); - if(lifeCycle.routes!=null&& lifeCycle.routes.length>0){ + if(lifeCycle.routes!=null && lifeCycle.routes.length>0){ Arrays.stream(lifeCycle.routes).forEach(route->{ OsLifeCycleLineVO lineVO = new OsLifeCycleLineVO(); lineVO.setSourceLifeStatus(route.source); @@ -271,17 +294,17 @@ * @return 鏁版嵁瀵硅薄 */ @Override - public LifeCycle lifeCycleVO2DO(OsLifeCycleVO lifeCycleVO){ + public LifeCycle lifeCycleVO2DO(OsLifeCycleVO lifeCycleVO) throws PLException { LifeCycle lifeCyle = new LifeCycle(); lifeCyle.name = lifeCycleVO.getId(); lifeCyle.tag = lifeCycleVO.getName(); lifeCyle.oid = lifeCycleVO.getOid(); - String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); + String userId = "developer";//WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); lifeCyle.creator = Func.isBlank(lifeCycleVO.getCreator()) ? userId:lifeCycleVO.getCreator(); lifeCyle.description = lifeCycleVO.getDescription(); lifeCyle.modifier = Func.isBlank(lifeCycleVO.getLastModifier()) ? userId:lifeCycleVO.getLastModifier(); lifeCyle.modifyTime = System.currentTimeMillis(); - lifeCyle.createTime = lifeCycleVO.getCreateTime() != null ? lifeCycleVO.getCreateTime().getTime():null; + lifeCyle.createTime = lifeCycleVO.getCreateTime() != null ? lifeCycleVO.getCreateTime().getTime():System.currentTimeMillis(); lifeCyle.startState =lifeCycleVO.getStartStatus(); lifeCyle.ts = VciDateUtil.date2Str(lifeCycleVO.getTs(),VciDateUtil.DateTimeMillFormat); if(lifeCycleVO.getBounds() !=null && lifeCycleVO.getBounds().length>0) { @@ -302,7 +325,7 @@ }else{ lifeCyle.bounds = new Bound[0]; } - //鍔犻摼鎺ョ嚎 + //鍔犺繛鎺ョ嚎 List<TransitionVO> lines = new ArrayList<>(); for (int i = 0; i < lifeCycleVO.getLines().size(); i++) { OsLifeCycleLineVO lineVO = lifeCycleVO.getLines().get(i); @@ -398,7 +421,7 @@ * @param lineVO 杩炴帴绾垮璞� * @return 骞冲彴鐨勮繛鎺ョ嚎瀵硅薄 */ - private TransitionVO lifeCycleLineVO2DO(OsLifeCycleLineVO lineVO){ + private TransitionVO lifeCycleLineVO2DO(OsLifeCycleLineVO lineVO) throws PLException { com.vci.corba.omd.lcm.TransitionVO transitionVO = new com.vci.corba.omd.lcm.TransitionVO(); transitionVO.id = lineVO.getOid(); transitionVO.source = lineVO.getSourceLifeStatus(); @@ -414,7 +437,8 @@ OsLifeCycleLineEventVO eventVO = lineVO.getEvents()[j]; TransitionVOEvent event = new TransitionVOEvent(); event.id = eventVO.getOid(); - event.name = eventVO.getEventFullName(); + event.name = Func.isBlank(eventVO.getEventFullName()) ? + platformClientUtil.getLifeCycleService().getLCEventValueByKey(eventVO.getOid()):eventVO.getEventFullName(); events[j] = event; } } @@ -434,7 +458,7 @@ } /** - * 浣跨敤鐢熷懡鍛ㄦ湡鐨勭紪鍙峰洖鍘诲寘鍚殑鐘舵�佹樉绀哄璞� + * 浣跨敤鐢熷懡鍛ㄦ湡鐨勭紪鍙疯幏鍙栧寘鍚殑鐘舵�佹樉绀哄璞� * * @param lifeCycleId 鐢熷懡鍛ㄦ湡鐨勭紪鍙� * @return 鐘舵�佺殑鏄剧ず瀵硅薄 @@ -456,6 +480,27 @@ statusVOList.add(statusVOMap.getOrDefault(statusId,new OsStatusVO())); }); return statusVOList; + } + + /** + * 浣跨敤澶氫釜缂栧彿鑾峰彇鐢熷懡鍛ㄦ湡鐨勫璞� + * @param lcIdList 缂栧彿 + * @return 鏄剧ず瀵硅薄 + */ + @Override + public List<OsLifeCycleVO> getLifeCycleByIds(Collection<String> lcIdList) { + if(Func.isEmpty(lcIdList)){ + return null; + } + Map<String, OsLifeCycleVO> lifeCycleVOMap = self.selectAllLifeCycleMap(); + List<OsLifeCycleVO> lifeCycleVOList = new ArrayList<>(); + lcIdList.stream().forEach(vrId->{ + OsLifeCycleVO lifeCycleVO = lifeCycleVOMap.getOrDefault(vrId,null); + if(lifeCycleVO != null){ + lifeCycleVOList.add(lifeCycleVO); + } + }); + return lifeCycleVOList; } /** @@ -663,9 +708,81 @@ */ @Override public String exportLifeCycles(String exportFileName, String lcNames, boolean flag) throws PLException { + if(Func.isBlank(lcNames)){ + throw new PLException("500",new String[]{"璇峰嬀閫夎瀵煎嚭鐨勭敓鍛藉懆鏈熸ā鏉�!"}); + } + //鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉� + exportFileName = Func.isBlank(exportFileName) ? "鐗堟湰瑙勫垯瀵煎嚭_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName; + //璁剧疆鍒楀悕 + List<String> columns = this.getCloumns(flag); + //鍐檈xcel + String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls"; + try { + new File(excelPath).createNewFile(); + } catch (Throwable e) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e); + } + //璁剧疆鍒� + List<WriteExcelData> excelDataList = new ArrayList<>(); + //璁剧疆鍒楀ご + for (int index = 0; index < columns.size(); index++) { + excelDataList.add(new WriteExcelData(0,index, columns.get(index))); + } + //鎸夌収鐗堟湰瑙勫垯鍚嶆煡璇紝鐒跺悗澶勭悊鐗堟湰瑙勫垯瀵煎嚭 + List<String> lcIdList = Func.toStrList(lcNames); + List<OsLifeCycleVO> lifeCycleVOList = this.getLifeCycleByIds(lcIdList); + if(Func.isEmpty(lifeCycleVOList)){ + excelDataList.add(new WriteExcelData(1,1, "鏍规嵁鍚嶇О鏈煡璇㈠埌鐢熷懡鍛ㄦ湡淇℃伅锛岃鍒锋柊鍚庡皾璇曢噸鏂板鍑猴紒")); + }else{ + int row = 1; + for (int i = 0; i < lifeCycleVOList.size(); i++) { + OsLifeCycleVO lifeCycleVO = lifeCycleVOList.get(i); + List<OsLifeCycleLineVO> lines = lifeCycleVO.getLines(); + if(Func.isNotEmpty(lines)){ + for (int j = 0; j < lines.size(); j++) { + int start = row + j; + excelDataList.add(new WriteExcelData(start,0, lifeCycleVO.getId())); + excelDataList.add(new WriteExcelData(start,1, lifeCycleVO.getName())); + excelDataList.add(new WriteExcelData(start,2, lifeCycleVO.getStartStatus())); + excelDataList.add(new WriteExcelData(start,3, lifeCycleVO.getDescription())); + OsLifeCycleLineVO osLifeCycleLineVO = lines.get(j); + //鎸夌収瀵煎嚭妯℃澘鍒楀~鏁版嵁 + if(!flag){ + excelDataList.add(new WriteExcelData(start,4, osLifeCycleLineVO.getName())); + excelDataList.add(new WriteExcelData(start,5, osLifeCycleLineVO.getSourceLifeStatus())); + excelDataList.add(new WriteExcelData(start,6, osLifeCycleLineVO.getSourceLifeStatusName())); + excelDataList.add(new WriteExcelData(start,7, osLifeCycleLineVO.getTargetLifeStatus())); + excelDataList.add(new WriteExcelData(start,8, osLifeCycleLineVO.getTargetLifeStatusName())); + //澶勭悊杩炴帴绾垮寘鍚殑浜嬩欢 + OsLifeCycleLineEventVO[] events = osLifeCycleLineVO.getEvents(); + if(events != null && events.length > 0){ + String collect = Arrays.stream(events).map(OsLifeCycleLineEventVO::getOid).collect(Collectors.joining(";")); + excelDataList.add(new WriteExcelData(start,9, collect)); + } + excelDataList.add(new WriteExcelData(start,10, Func.format(lifeCycleVO.getCreateTime(),"yyyy骞碝M鏈坉d鏃� hh:mm:ss"))); + }else{ + excelDataList.add(new WriteExcelData(start,4, osLifeCycleLineVO.getSourceLifeStatus())); + excelDataList.add(new WriteExcelData(start,5, osLifeCycleLineVO.getTargetLifeStatus())); + } + } + row = row+lines.size(); + }else{ + excelDataList.add(new WriteExcelData(row,0, lifeCycleVO.getId())); + excelDataList.add(new WriteExcelData(row,1, lifeCycleVO.getName())); + excelDataList.add(new WriteExcelData(row,2, lifeCycleVO.getStartStatus())); + excelDataList.add(new WriteExcelData(row,3, lifeCycleVO.getDescription())); + if(!flag){ + excelDataList.add(new WriteExcelData(row,10, Func.format(lifeCycleVO.getCreateTime(),"yyyy骞碝M鏈坉d鏃� hh:mm:ss"))); + } + row++; + } - return null; + } + } + WriteExcelOption excelOption = new WriteExcelOption(excelDataList); + ExcelUtil.writeDataToFile(excelPath, excelOption); + return excelPath; } /** @@ -676,7 +793,38 @@ */ @Override public String downloadLifeCycleTemplate(String exportFileName) throws Exception { - return null; + //鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉� + exportFileName = Func.isBlank(exportFileName) ? "鐢熷懡鍛ㄦ湡瀵煎叆妯℃澘_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName; + //璁剧疆鍒楀悕 + List<String> columns = this.getCloumns(true); + //璁剧疆蹇呭~鍒� + ColumnNameisRed.clear(); + ColumnNameisRed.add(0); + ColumnNameisRed.add(2); + + //鍐檈xcel + String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls"; + try { + new File(excelPath).createNewFile(); + } catch (Throwable e) { + throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e); + } + //璁剧疆鍒� + List<WriteExcelData> excelDataList = new ArrayList<>(); + //璁剧疆鍒楀ご + for (int index = 0; index < columns.size(); index++) { + //鍒ゆ柇鏄惁涓哄繀濉垪锛岀粰蹇呭~鍒楄缃鑹� + if(ColumnNameisRed.contains(index)){ + WriteExcelData excelData = new WriteExcelData(0, index, columns.get(index)); + excelData.setFontColor(String.valueOf(HSSFColor.HSSFColorPredefined.RED.getIndex())); + excelDataList.add(excelData); + }else{ + excelDataList.add(new WriteExcelData(0,index, columns.get(index))); + } + } + WriteExcelOption excelOption = new WriteExcelOption(excelDataList); + ExcelUtil.writeDataToFile(excelPath, excelOption); + return excelPath; } /** @@ -686,9 +834,139 @@ */ @Override public BaseResult importLifeCycles(File file) throws Exception { + VciBaseUtil.alertNotNull(file,"excel鏂囦欢"); + if(!file.exists()){ + throw new VciBaseException("瀵煎叆鐨別xcel鏂囦欢涓嶅瓨鍦�,{0}",new String[]{file.getPath()}); + } + try{ + //1銆佽鍙杄xcel涓殑鏁版嵁锛岀粍鎴愬璞� + ReadExcelOption excelOption = new ReadExcelOption(); + List<OsLifeCyclePO> poList = ExcelUtil.readDataObjectFromExcel(file, OsLifeCyclePO.class,excelOption,(value, po, fieldName)->{}); + //鍘婚櫎閮芥槸绌虹殑鎯呭喌 + if(CollectionUtils.isEmpty(poList)){ + return BaseResult.fail(ExcelLangCodeConstant.IMPORT_CONTENT_NULL,new String[]{}); + } + //灏嗘灇涓惧拰鏋氫妇椤瑰鐞嗘垚涓�瀵瑰鍏崇郴鐨勫璞� + Map<String, OsLifeCyclePO> groupPOMap = new HashMap<>(); + //榛樿鐨勭敓鍛藉懆鏈熷浘鏍囩殑鍧愭爣鍜屽搴︾瓑淇℃伅 + List<OsLifeCycleLineBoundVO> defaultBoundList = new ArrayList<>(); + for (OsLifeCyclePO po : poList) { + //鎷兼帴鐢ㄦ潵浣滀负鍒嗙粍鐨刱ey + String key = po.getId() + "_" + po.getName() + "_" + po.getStartStatus(); + OsLifeCyclePO group = groupPOMap.get(key); + if (group == null) { + group = new OsLifeCyclePO(); + //鎷垮嚭鐜扮殑棣栬鍋氬悗缁殑鎻愮ず琛� + group.setRowIndex(po.getRowIndex()); + group.setId(po.getId()); + group.setName(po.getName()); + group.setStartStatus(po.getStartStatus()); + group.setDescription(po.getDescription()); + groupPOMap.put(key, group); + //澶勭悊鐢熷懡鍛ㄦ湡鍥炬爣鐨勯粯璁ょ殑鍧愭爣淇℃伅 + OsLifeCycleLineBoundVO boundVO = new OsLifeCycleLineBoundVO(); + boundVO.setCellh("30.0"); + boundVO.setCellw("80.0"); + boundVO.setCellx(String.valueOf(200+(Integer.parseInt(po.getRowIndex())*60))); + boundVO.setCelly(String.valueOf(300+(Integer.parseInt(po.getRowIndex())*60))); + boundVO.setCellicon(""); + defaultBoundList.add(boundVO); + } - return null; + OsLifeCycleLineVO lineItemVO = new OsLifeCycleLineVO(); + lineItemVO.setName("line"+po.getRowIndex()); + lineItemVO.setSourceLifeStatus(po.getSourceLifeStatus()); + lineItemVO.setTargetLifeStatus(po.getTargetLifeStatus()); + + //澶勭悊杩炴帴绾垮寘鍚殑浜嬩欢 + String[] eventArr = po.getEvents().split(";"); + if(eventArr != null & eventArr.length > 0){ + List<OsLifeCycleLineEventVO> eventVOList = new ArrayList<>(); + for (int i = 0; i < eventArr.length; i++) { + OsLifeCycleLineEventVO osLCLineEventVO = new OsLifeCycleLineEventVO(); + osLCLineEventVO.setOid(eventArr[i]); + String lcEventValueByKey = platformClientUtil.getLifeCycleService().getLCEventValueByKey(eventArr[i]); + osLCLineEventVO.setEventFullName(lcEventValueByKey); + eventVOList.add(osLCLineEventVO); + } + lineItemVO.setEvents(eventVOList.toArray(new OsLifeCycleLineEventVO[eventVOList.size()])); + } + group.getLineItems().add(lineItemVO); + } + Collection<OsLifeCyclePO> newPOList = groupPOMap.values(); + //鏁版嵁搴撴煡璇㈡槸鍚︽湁宸插瓨鍦ㄧ殑鐢熷懡鍛ㄦ湡鍚嶏紝鏂逛究鍚庣画鍋氬垽閲嶅鐞� + List<OsLifeCycleVO> lifeCycleVOList = this.getLifeCycleByIds(poList.stream().map(OsLifeCyclePO::getId).collect(Collectors.toSet())); + List<String> repeatLCId = new ArrayList<>(); + if(Func.isNotEmpty(lifeCycleVOList)){ + repeatLCId = lifeCycleVOList.stream().map(OsLifeCycleVO::getId).collect(Collectors.toList()); + } + //褰撳墠excel涓槸鍚﹂噸澶嶇敤鐨勫垽閲峂ap:锛坘ey锛氬垽閲嶅睘鎬э紝value锛氳鍙凤級 + Map<String, String> excelReapeat = new HashMap<>(); + //鍒ゆ柇蹇呭~灞炴�ф槸鍚︿负绌虹瓑绛� + List<String> finalRepeatLCId = repeatLCId; + newPOList.stream().forEach(lcPO -> { + if(Func.isBlank(lcPO.getId())){ + throw new VciBaseException("绗��"+lcPO.getRowIndex()+"銆戣锛宭cnameerror"); + }else if(Func.isEmpty(lcPO.getStartStatus())){ + throw new VciBaseException("绗��"+lcPO.getRowIndex()+"銆戣锛宻tartstatuserror"); + }else if(!lcPO.getId().matches("^[A-Za-z]+$")){ + throw new VciBaseException("绗��"+lcPO.getRowIndex()+"銆戣鏁版嵁锛屽悕绉板彧鑳戒负鑻辨枃瀛楁瘝"); + }else if(excelReapeat.containsKey(lcPO.getId())){//鍚嶇О琛ㄦ牸涓垽閲� + throw new VciBaseException("绗��"+excelReapeat.get(lcPO.getId())+"銆戣鍜岀銆�"+lcPO.getRowIndex()+"銆戣鏁版嵁锛屽悕绉伴噸澶�"); + }else if (Func.isNotEmpty(finalRepeatLCId) && finalRepeatLCId.contains(lcPO.getId())){//2銆佸垽鏂悕绉版槸鍚︿笌绯荤粺涓噸澶� + throw new VciBaseException("绗��"+lcPO.getRowIndex()+"銆戣锛屽悕绉板湪绯荤粺涓凡缁忓瓨鍦�,璇蜂慨鏀�!"); + } + //鍏堝鏋氫妇鍚峞xcel涓渶瑕佸垽閲嶅鐞� + excelReapeat.put(lcPO.getId(),lcPO.getRowIndex()); + }); + //淇濆瓨閫昏緫 + for (OsLifeCyclePO osLifeCyclePO : newPOList) { + OsLifeCycleVO osLifeCycleVO = new OsLifeCycleVO(); + //鐢熸垚瀛樺偍鐨凞TO瀵硅薄 + osLifeCycleVO.setId(osLifeCyclePO.getId()); + osLifeCycleVO.setName(osLifeCyclePO.getName()); + osLifeCycleVO.setDescription(osLifeCyclePO.getDescription()); + osLifeCycleVO.setStartStatus(osLifeCyclePO.getStartStatus()); + osLifeCycleVO.setLines(osLifeCyclePO.getLineItems()); + osLifeCycleVO.setBounds(defaultBoundList.toArray(new OsLifeCycleLineBoundVO[defaultBoundList.size()])); + //璋冪敤鏂板鏋氫妇鏂规硶 + boolean addBoolean = platformClientUtil.getLifeCycleService().addLifeCycle(lifeCycleVO2DO(osLifeCycleVO)); + if(!addBoolean){ + throw new PLException("500",new String[]{"淇濆瓨鐢熷懡鍛ㄦ湡鍚嶏紝涓恒��" + osLifeCycleVO.getId() + "銆戠殑鏁版嵁鏃跺嚭鐜伴敊璇�!"}); + } + } + }catch (Exception e){ + if(logger.isErrorEnabled()){ + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢熷懡鍛ㄦ湡淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); + } + e.printStackTrace(); + return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); + } + return BaseResult.success("鐢熷懡鍛ㄦ湡瀵煎叆鎴愬姛锛�"); + } + + /** + * 鑾峰彇瀵煎嚭鎴栧鍏ユā鏉跨殑鍒楀悕 + * @param flag 鏄惁鑾峰彇瀵煎叆妯℃澘鍒楀悕 + * @return + */ + private List<String> getCloumns(boolean flag){ + if(flag){ + return new ArrayList<>( + Arrays.asList( + "鍚嶇О", "鏍囩", "璧峰鐘舵��", "鎻忚堪", + "杩炴帴绾胯捣濮嬬姸鎬�", "杩炴帴绾跨洰鏍囩姸鎬�", "浜嬩欢(;闂撮殧)" + ) + ); + } + return new ArrayList<>( + Arrays.asList( + "鍚嶇О", "鏍囩", "璧峰鐘舵��", "鎻忚堪", + "杩炴帴绾垮悕绉�", "杩炴帴绾胯捣濮嬬姸鎬佽嫳鏂囧悕绉�","杩炴帴绾胯捣濮嬬姸鎬佷腑鏂囧悕绉�", + "杩炴帴绾跨洰鏍囩姸鎬佽嫳鏂囧悕绉�","杩炴帴绾跨洰鏍囩姸鎬佷腑鏂囧悕绉�", "浜嬩欢", "鍒涘缓鏃堕棿" + ) + ); } /** @@ -781,6 +1059,15 @@ } /** + * 鏌ヨ鎵�鏈夎穬杩佷簨浠秌ey + * @return + */ + @Override + public List<String> getLCEventKeys() throws PLException { + return Arrays.asList(platformClientUtil.getLifeCycleService().getLCEventKeys()); + } + + /** * 鎵归噺鎵ц璺冭縼鎿嶄綔锛岃姹傚繀椤绘槸鍚屼竴涓笟鍔$被鍨嬩笅鐨� * @param bos 涓氬姟绫诲瀷鏁版嵁瀵硅薄 * @param lineVOs 璺冭縼瀵硅薄 diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java index 4d9870d..f5c461b 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java @@ -539,7 +539,7 @@ }); }catch (Exception e){ if(logger.isErrorEnabled()){ - logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐢ㄦ埛淇℃伅鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); + logger.error("璇诲彇excel鍐呭鏃舵垨淇濆瓨鐗堟湰瑙勫垯鏃跺嚭鐜颁簡閿欒锛屽叿浣撳師鍥狅細",VciBaseUtil.getExceptionMessage(e)); } e.printStackTrace(); return BaseResult.fail(VciBaseUtil.getExceptionMessage(e),new String[]{},e); diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java index 51c02df..c6247b9 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/WebBtmIOServiceImpl.java @@ -243,7 +243,7 @@ * @param lifeCycleDTOList 瑕佸鍏ョ殑鐢熷懡鍛ㄦ湡鏁版嵁浼犺緭瀵硅薄鍒楄〃 * @throws VciBaseException 鏌ヨ鎴栬�呬繚瀛樺嚭閿欑殑鏃跺�欙紝浼氭姏鍑哄紓甯� */ - private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException{ + private void importLifeCycles(Collection<OsLifeCycleDTO> lifeCycleDTOList) throws VciBaseException, PLException { Set<String> existLifeCycleIds = lifeCycleService.selectAllLifeCycleMap().keySet(); //鐢熷懡鍛ㄦ湡鐨勫悕绉版病鏈夎浆涓哄皬鍐欙紝浣嗘槸骞冲彴鍙堝尯鍒嗗ぇ灏忓啓 List<String> existLifeCycleLowIds = existLifeCycleIds.stream().map(s->s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()); -- Gitblit v1.9.3