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 +++++++++++++++++++++--
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsLifeCycleController.java       |  174 +++++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsRevisionRuleServiceImpl.java |    9 
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsRevisionRuleController.java    |    2 
 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsLifeCycleDTO.java                     |   68 ++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsLifeCycleServiceI.java            |   68 ++++++
 6 files changed, 525 insertions(+), 35 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsLifeCycleDTO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsLifeCycleDTO.java
index ca7ef13..2c12046 100644
--- a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/dto/OsLifeCycleDTO.java
+++ b/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;
+
+    /**
+     * 鏈�鍚庝慨鏀规椂闂达紝鏍煎紡鏄痽yyy-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;
     }
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 175f7ff..7f30454 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,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();
+        }
+    }
+
 }
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsRevisionRuleController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsRevisionRuleController.java
index 7b4c389..2f5aed5 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/OsRevisionRuleController.java
+++ b/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);
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 c0be382..ea30ac7 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
@@ -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);
+
 }
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){
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 904da86..4d9870d 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
@@ -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[]{"寰呭垹闄ょ殑鐘舵�佸垪琛ㄤ腑涓婚敭銆恛id銆戙�佽皟鏁存椂闂淬�恡s銆戙�佺姸鎬佸悕绉般�恘ame銆戜笉鑳戒负绌猴紒"});
+                throw new PLException("500",new String[]{"寰呭垹闄ょ殑鐗堟湰瑙勫垯鍒楄〃涓富閿�恛id銆戙�佽皟鏁存椂闂淬�恡s銆戙�佺姸鎬佸悕绉般�恘ame銆戜笉鑳戒负绌猴紒"});
             }
             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[]{"璺宠穬瀛楃鍙兘涓烘暟瀛楁垨鑰呭瓧姣嶏紒"});
         }
         //鍒濆鍊间笉鑳戒负绌轰笖鍙兘涓烘暟瀛楁垨鑰呭瓧姣嶆垨鑻辨枃鐘舵�佷笅鐨勭鍙�

--
Gitblit v1.9.3