From e04e10a0765e1d32535d91292763289adf43d651 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 09 九月 2024 17:49:33 +0800
Subject: [PATCH] 按钮设计对话框:查询、添加、修改接口上传。
---
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsLifeCycleServiceImpl.java | 582 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 538 insertions(+), 44 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 3552e01..26e995a 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
@@ -1,23 +1,34 @@
package com.vci.web.service.impl;
-import com.vci.client.common.providers.ServiceProvider;
import com.vci.corba.common.PLException;
+import com.vci.corba.omd.data.BusinessObject;
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.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.VciDateUtil;
-import com.vci.web.model.OsLifeCycleDO;
-import com.vci.web.pageModel.*;
+import com.vci.starter.web.util.*;
+import com.vci.model.OsLifeCycleDO;
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;
+import org.apache.poi.hssf.util.HSSFColor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,12 +36,14 @@
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;
-import static com.vci.frameworkcore.constant.FrameWorkBusLangCodeConstant.DATA_ID_NOT_EXIST;
-import static com.vci.web.constant.WebLangCodeConstant.LIFE_CYCLE_ROUTER_NULL;
-import static com.vci.web.constant.WebLangCodeConstant.LIFE_CYCLE_TRANS_ERROR;
+import static com.vci.constant.FrameWorkBusLangCodeConstant.DATA_ID_NOT_EXIST;
+import static com.vci.constant.WebLangCodeConstant.LIFE_CYCLE_ROUTER_NULL;
+import static com.vci.constant.WebLangCodeConstant.LIFE_CYCLE_TRANS_ERROR;
/**
* 鐢熷懡鍛ㄦ湡鏈嶅姟
@@ -66,6 +79,11 @@
private WebBoServiceI boService;
/**
+ * 蹇呭~鍒�
+ */
+ private List<Integer> ColumnNameisRed = new ArrayList<Integer>();
+
+ /**
* 鏃ュ織
*/
private Logger logger = LoggerFactory.getLogger(getClass());
@@ -88,7 +106,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 +127,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 +140,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 +159,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]));
}
}
@@ -152,12 +170,12 @@
* @throws VciBaseException 杞崲鐢熷懡鍛ㄦ湡鍑洪敊鐨勬椂鍊欐姏鍑哄紓甯�
*/
@Override
- public void transCboStatus(List<com.vci.client.bof.ClientBusinessObject> cboList,
+ public void transCboStatus(List<BusinessObject> cboList,
String targetStatus) throws VciBaseException {
WebUtil.alertNotNull(cboList,"涓氬姟鏁版嵁瀵硅薄",targetStatus,"鐩爣瀵硅薄");
- com.vci.corba.omd.data.BusinessObject[] bos = new com.vci.corba.omd.data.BusinessObject[cboList.size()];
+ BusinessObject[] bos = new BusinessObject[cboList.size()];
for(int i = 0 ; i < cboList.size() ; i ++){
- bos[i] = cboList.get(i).getBusinessObject();
+ bos[i] = cboList.get(i);
}
transStatus(bos, targetStatus);
}
@@ -214,8 +232,26 @@
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.setName(bound.name);
+ 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);
@@ -259,16 +295,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();
- 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.createTime = lifeCycleVO.getCreateTime() != null ? lifeCycleVO.getCreateTime().getTime():null;
+ lifeCyle.modifier = Func.isBlank(lifeCycleVO.getLastModifier()) ? userId:lifeCycleVO.getLastModifier();
+ lifeCyle.modifyTime = System.currentTimeMillis();
+ 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) {
@@ -289,7 +326,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);
@@ -309,12 +346,11 @@
@VciUnLog
public List<OsLifeCycleVO> selectAllLifeCycle() throws VciBaseException {
try {
-// LifeCyle[] lifeCyles = platformClientUtil.getLifeCycleService().getLifeCyles();
- LifeCycle[] lifeCyles = ServiceProvider.getOMDService().getLifeCycleService().getLifeCycles();
+ LifeCycle[] lifeCyles = platformClientUtil.getLifeCycleService().getLifeCycles();
return lifeCycleDO2VOs(Arrays.stream(lifeCyles).collect(Collectors.toList()));
} catch (PLException vciError) {
if(logger.isErrorEnabled()){
-// logger.error(vciError.error_code,vciError);
+ logger.error(vciError.code,vciError);
}
throw WebUtil.getVciBaseException(vciError);
}
@@ -361,7 +397,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 涓氬姟绫诲瀷鏁版嵁瀵硅薄
@@ -369,12 +404,11 @@
* @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);
-// platformClientUtil.getBOFactoryService().transferBusinessObject(new BusinessObjectHolder(obj), transitionVO);
- ServiceProvider.getBOFService().transferBusinessObject(obj, transitionVO.destination);
+ TransitionVO transitionVO = lifeCycleLineVO2DO(lineVO);
+ platformClientUtil.getBOFService().transferBusinessObject(obj, transitionVO.destination);
} catch (PLException e) {
throw WebUtil.getVciBaseException(e);
}
@@ -388,23 +422,24 @@
* @param lineVO 杩炴帴绾垮璞�
* @return 骞冲彴鐨勮繛鎺ョ嚎瀵硅薄
*/
- private com.vci.corba.omd.lcm.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();
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();
+ event.name = Func.isBlank(eventVO.getEventFullName()) ?
+ platformClientUtil.getLifeCycleService().getLCEventValueByKey(eventVO.getOid()):eventVO.getEventFullName();
events[j] = event;
}
}
@@ -419,12 +454,12 @@
* @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);
}
/**
- * 浣跨敤鐢熷懡鍛ㄦ湡鐨勭紪鍙峰洖鍘诲寘鍚殑鐘舵�佹樉绀哄璞�
+ * 浣跨敤鐢熷懡鍛ㄦ湡鐨勭紪鍙疯幏鍙栧寘鍚殑鐘舵�佹樉绀哄璞�
*
* @param lifeCycleId 鐢熷懡鍛ㄦ湡鐨勭紪鍙�
* @return 鐘舵�佺殑鏄剧ず瀵硅薄
@@ -449,6 +484,27 @@
}
/**
+ * 浣跨敤澶氫釜缂栧彿鑾峰彇鐢熷懡鍛ㄦ湡鐨勫璞�
+ * @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;
+ }
+
+ /**
* 鎵归噺娣诲姞鐢熷懡鍛ㄦ湡
*
* @param lifeCyleList 鐢熷懡鍛ㄦ湡鐨勫唴瀹�
@@ -458,6 +514,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);
@@ -476,6 +534,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);
@@ -485,7 +545,7 @@
}
/**
- * 鐘舵�佸湪鐢熷懡鍛ㄦ湡涓娇鐢ㄧ殑鍕ゅ揩
+ * 鐘舵�佸湪鐢熷懡鍛ㄦ湡涓娇鐢ㄧ殑鑼冨洿
*
* @param statusOid 鐘舵�佺殑涓婚敭
* @return 鐢熷懡鍛ㄦ湡鐨勪俊鎭�
@@ -539,6 +599,434 @@
}
/**
+ * 鏂板鍗曟潯鐢熷懡鍛ㄦ湡
+ * @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 {
+ 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++;
+ }
+
+ }
+ }
+ WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+ ExcelUtil.writeDataToFile(excelPath, excelOption);
+ return excelPath;
+ }
+
+ /**
+ * 涓嬭浇鐢熷懡鍛ㄦ湡瀵煎叆妯℃澘
+ * @param exportFileName
+ * @return
+ * @throws PLException
+ */
+ @Override
+ public String downloadLifeCycleTemplate(String exportFileName) throws Exception {
+ //鐣岄潰娌′紶鍚嶇О锛屼娇鐢ㄩ粯璁ゅ鍑哄悕绉�
+ 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;
+ }
+
+ /**
+ * 瀵煎叆鐢熷懡鍛ㄦ湡
+ * @param file
+ * @return
+ */
+ @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);
+ //绗竴琛岃捣濮嬬姸鎬侀渶瑕佸崟鐙鐞�
+ if(po.getRowIndex().equals("1")){
+ OsLifeCycleLineBoundVO boundVO = new OsLifeCycleLineBoundVO();
+ boundVO.setName(po.getStartStatus());
+ 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);
+ }
+ //澶勭悊鐢熷懡鍛ㄦ湡鍥炬爣鐨勯粯璁ょ殑鍧愭爣淇℃伅
+ OsLifeCycleLineBoundVO boundVO = new OsLifeCycleLineBoundVO();
+ boundVO.setName(po.getTargetLifeStatus());
+ boundVO.setCellh("30.0");
+ boundVO.setCellw("80.0");
+ boundVO.setCellx(String.valueOf(250+(Integer.parseInt(po.getRowIndex())*60)));
+ boundVO.setCelly(String.valueOf(350+(Integer.parseInt(po.getRowIndex())*60)));
+ boundVO.setCellicon("");
+ defaultBoundList.add(boundVO);
+ }
+
+ 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(
+ "鍚嶇О", "鏍囩", "璧峰鐘舵��", "鎻忚堪",
+ "杩炴帴绾垮悕绉�", "杩炴帴绾胯捣濮嬬姸鎬佽嫳鏂囧悕绉�","杩炴帴绾胯捣濮嬬姸鎬佷腑鏂囧悕绉�",
+ "杩炴帴绾跨洰鏍囩姸鎬佽嫳鏂囧悕绉�","杩炴帴绾跨洰鏍囩姸鎬佷腑鏂囧悕绉�", "浜嬩欢", "鍒涘缓鏃堕棿"
+ )
+ );
+ }
+
+ /**
+ * 妫�鏌ョ敓鍛藉懆鏈熷悕绉版槸鍚﹀凡瀛樺湪
+ * @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 缂栧彿
@@ -582,6 +1070,14 @@
return ervo;
}
+ /**
+ * 鏌ヨ鎵�鏈夎穬杩佷簨浠秌ey
+ * @return
+ */
+ @Override
+ public List<String> getLCEventKeys() throws PLException {
+ return Arrays.asList(platformClientUtil.getLifeCycleService().getLCEventKeys());
+ }
/**
* 鎵归噺鎵ц璺冭縼鎿嶄綔锛岃姹傚繀椤绘槸鍚屼竴涓笟鍔$被鍨嬩笅鐨�
@@ -591,7 +1087,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){
@@ -604,9 +1100,7 @@
for(int i = 0 ; i < lineVOs.length; i ++){
vos[i] = lifeCycleLineVO2DO(lineVOs[i]);
}
-// platformClientUtil.getBOFactoryService().batchTransferBusinessObjectAndRelease(
-// bos, vos, releaseStatus);
- ServiceProvider.getBOFService().batchTransferBusinessObjectAndRelease(
+ platformClientUtil.getBOFService().batchTransferBusinessObjectAndRelease(
bos, vos, releaseStatus);
} catch (PLException e) {
throw WebUtil.getVciBaseException(e);
--
Gitblit v1.9.3