From e45b445e2145dbd83864eb28417ae02bffc1a900 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 02 九月 2024 15:21:02 +0800
Subject: [PATCH] ui定义:UI上下文区域查询、增加、修改、删除、克隆接口上传

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java     |   36 +++
 Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLUILayoutCloneVO.java       |   38 +++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java    |  154 ++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java   |    1 
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBtmServiceI.java             |   10 
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java         |   62 +++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java |  369 ++++++++++++++++++++++++++++++
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java          |    3 
 8 files changed, 669 insertions(+), 4 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLUILayoutCloneVO.java b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLUILayoutCloneVO.java
new file mode 100644
index 0000000..e1c96bc
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLUILayoutCloneVO.java
@@ -0,0 +1,38 @@
+package com.vci.pagemodel;
+
+import com.vci.corba.portal.data.PLUILayout;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * ui涓婁笅鏂囧厠闅嗗璞�
+ * @author ludc
+ * @date 2024/9/2 12:58
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PLUILayoutCloneVO {
+
+    /**
+     * 鍏嬮殕鐩爣涓婚敭
+     */
+    private String cloneTargetOid;
+
+    /**
+     * 鍏嬮殕鐨勬簮瀵硅薄鐨勪俊鎭�
+     */
+    private PLUILayout sourcePLUILayout;
+
+    /**
+     * 鍏嬮殕鍚嶇О
+     */
+    private String cloneName;
+
+    /**
+     * 鍏嬮殕涓婁笅鏂囩紪鐮�
+     */
+    private String cloneContextCode;
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java
new file mode 100644
index 0000000..5d143b7
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/UIManagerController.java
@@ -0,0 +1,154 @@
+package com.vci.web.controller;
+
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.data.PLUILayout;
+import com.vci.dto.OsBtmTypeDTO;
+import com.vci.pagemodel.PLUILayoutCloneVO;
+import com.vci.starter.web.annotation.log.VciBusinessLog;
+import com.vci.starter.web.pagemodel.BaseQueryObject;
+import com.vci.starter.web.pagemodel.BaseResult;
+import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.web.service.OsBtmServiceI;
+import com.vci.web.service.UIManagerServiceI;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+
+/**
+ * UI瀹氫箟鎺у埗灞�
+ * @author ludc
+ * @date 2024/8/28 17:09
+ */
+@RestController
+@RequestMapping("/uiManagerController")
+public class UIManagerController {
+
+    /**
+     * 鏃ュ織
+     */
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    /**
+     * 涓氬姟绫诲瀷鐨勬湇鍔�
+     */
+    @Autowired
+    private OsBtmServiceI btmService;
+
+    /**
+     * UI瀹氫箟鏈嶅姟
+     */
+    @Autowired
+    private UIManagerServiceI uiManagerService;
+
+    /**
+     * 涓氬姟绫诲瀷鍒楄〃鏌ヨ锛岄潪鏍戠粨鏋勶細鐢ㄤ簬UI瀹氫箟宸︿晶涓氬姟绫诲瀷鏌ヨ
+     * @param btmName
+     * @return
+     * @throws PLException
+     */
+    @GetMapping( "/getBizTree")
+    @VciBusinessLog(operateName = "涓氬姟绫诲瀷鍒楄〃(涓昏鐢ㄤ簬UI瀹氫箟涓氬姟绫诲瀷鏍戞煡璇娇鐢�)")
+    public BaseResult getBizTree(String btmName){
+        try {
+            return BaseResult.success(btmService.getBizTree(btmName));
+        }catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "鑾峰彇UI瀹氫箟涓氬姟绫诲瀷鍒楄〃鏃跺嚭鐜伴敊璇紝鍘熷洜锛�" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * 閫氳繃涓氬姟绫诲瀷name鏌ヨui涓婁笅鏂囷紝鏀寔鍒嗛〉
+     * @param baseQueryObject
+     * @return
+     * @throws PLException
+     */
+    @GetMapping( "/gridUIContextData")
+    @VciBusinessLog(operateName = "閫氳繃涓氬姟绫诲瀷name鏌ヨ鍑簎i涓婁笅鏂�")
+    public BaseResult gridUIContextData(BaseQueryObject baseQueryObject){
+        try {
+            return BaseResult.dataGrid(uiManagerService.gridUIContextData(baseQueryObject));
+        }catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "閫氳繃涓氬姟绫诲瀷name鏌ヨ鍑簎i涓婁笅鏂囨椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * 鍒涘缓UI涓婁笅鏂�
+     * btmTypeDTO 閾炬帴绫诲瀷鐨勪繚瀛樺璞�
+     * @return 淇濆瓨缁撴灉
+     */
+    @PostMapping("/saveUIContextData")
+    public BaseResult saveUIContextData(@RequestBody PLUILayout pluiLayout){
+        try {
+            return uiManagerService.saveUIContextData(pluiLayout) ? BaseResult.success("UI涓婁笅鏂囧垱寤烘垚鍔燂紒"):BaseResult.fail("UI涓婁笅鏂囧垱寤哄け璐ワ紒");
+        } catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "鍒涘缓UI涓婁笅鏂囨椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * 淇敼UI涓婁笅鏂�
+     * btmTypeDTO
+     * @return 淇敼缁撴灉
+     */
+    @PutMapping("/updateUIContextData")
+    public BaseResult updateUIContextData(@RequestBody PLUILayout pluiLayout){
+        try {
+            return uiManagerService.updateUIContextData(pluiLayout) ? BaseResult.success("UI涓婁笅鏂囦慨鏀规垚鍔燂紒"):BaseResult.fail("UI涓婁笅鏂囦慨鏀瑰け璐ワ紒");
+        } catch (Exception e) {
+            e.printStackTrace();
+            String exceptionMessage = "淇敼UI涓婁笅鏂囨椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * 鍒犻櫎UI涓婁笅鏂囨暟鎹�
+     * oids 鍒犻櫎鐨刼id淇℃伅
+     * @return 鍒犻櫎缁撴灉
+     */
+    @DeleteMapping("/delUIContextData")
+    public BaseResult delUIContextData(String[] oids){
+        try {
+            return uiManagerService.delUIContextData(oids) ? BaseResult.success("UI涓婁笅鏂囧垹闄ゆ垚鍔燂紒"):BaseResult.fail("UI涓婁笅鏂囧垹闄ゅけ璐ワ紒");
+        } catch (PLException e) {
+            e.printStackTrace();
+            String exceptionMessage = "鍒犻櫎UI涓婁笅鏂囨椂鍑虹幇閿欒锛屽師鍥狅細" + VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            return BaseResult.fail(exceptionMessage);
+        }
+    }
+
+    /**
+     * UI涓婁笅鏂囧厠闅�
+     * pluiLayoutCloneVO 鍏嬮殕鍙傛暟瀵硅薄
+     * @return 鍏嬮殕缁撴瀯
+     */
+    @PostMapping("/cloneUiContextData")
+    public BaseResult cloneUiContextData(@RequestBody PLUILayoutCloneVO pluiLayoutCloneVO){
+        try {
+            return uiManagerService.cloneUiContextData(pluiLayoutCloneVO) ? BaseResult.success("UI涓婁笅鏂囧厠闅嗘垚鍔燂紒"):BaseResult.fail("UI涓婁笅鏂囧厠闅嗗け璐ワ紒");
+        } catch (PLException e) {
+            e.printStackTrace();
+            String exceptionMessage = "UI涓婁笅鏂囧厠闅嗘椂鍑虹幇閿欒锛屽師鍥狅細" + 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/controller/WebBtmTypeController.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java
index 10c2d5c..f9490cd 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/controller/WebBtmTypeController.java
@@ -104,7 +104,6 @@
      */
     @GetMapping( "/getBizTypes")
     @VciBusinessLog(operateName = "涓氬姟绫诲瀷鍒楄〃(涓昏鐢ㄤ簬瀵硅瘽妗嗕娇鐢�)")
-    @VciUnCheckRight
     public BaseResult getBizTypes(String btmName){
         try {
             return BaseResult.dataList(Arrays.asList(btmService.getBizTypes(btmName)));
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBtmServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBtmServiceI.java
index 2d07b7a..8c21a3c 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBtmServiceI.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/OsBtmServiceI.java
@@ -60,6 +60,14 @@
     BizType[] getBizTypes(String btmName) throws PLException;
 
     /**
+     * 涓氬姟绫诲瀷鍒楄〃鏌ヨ锛岄潪鏍戠粨鏋勶細鐢ㄤ簬UI瀹氫箟宸︿晶涓氬姟绫诲瀷鏌ヨ锛屽彧杩斿洖name鍜宭able
+     * @param btmName
+     * @return
+     * @throws PLException
+     */
+    Tree getBizTree(String btmName) throws PLException;
+
+    /**
      * 鏌ヨ鎵�鏈夌殑涓氬姟绫诲瀷鏄犲皠
      * @return key 鏄笟鍔$殑鑻辨枃鍚嶇О鐨勫皬鍐�
      */
@@ -276,7 +284,7 @@
     /**
      * 瀵煎嚭涓氬姟绫诲瀷
      * oid 涓氬姟绫诲瀷鍚嶇О
-     * @return 鍒涘缓缁撴灉
+     * @return
      */
     void expData(String oid, HttpServletResponse response) throws PLException, IOException;
 
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java
index 4e768f8..40b4ec7 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java
@@ -134,7 +134,6 @@
 	 */
 	UIActionVO actionDO2VO(PLAction action);
 
-
 	/**
 	 * 鏌ヨ鎵�鏈夌殑UI涓婁笅鏂�
 	 * @return 鏄剧ず瀵硅薄
@@ -209,5 +208,5 @@
 
 //	UIContentVO UIContentDO2VO(PLPageLayoutDefination pageLayoutDefination, boolean queryDetail);
 	UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail);
-;
+
 }
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
new file mode 100644
index 0000000..a554efb
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
@@ -0,0 +1,62 @@
+package com.vci.web.service;
+
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.data.PLUILayout;
+import com.vci.pagemodel.PLUILayoutCloneVO;
+import com.vci.starter.web.pagemodel.BaseQueryObject;
+import com.vci.starter.web.pagemodel.DataGrid;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author ludc
+ * @date 2024/8/28 17:05
+ */
+public interface UIManagerServiceI {
+
+    /**
+     * 閫氳繃涓氬姟绫诲瀷name鏌ヨui涓婁笅鏂囷紝鏀寔鍒嗛〉
+     * @param baseQueryObject
+     * @return
+     * @throws PLException
+     */
+    DataGrid gridUIContextData(BaseQueryObject baseQueryObject) throws PLException;
+
+    /**
+     * 缁欎笟鍔$被鍨嬩笅娣诲姞ui涓婁笅鏂�
+     * @param pluiLayout
+     * @return
+     * @throws PLException
+     */
+    boolean saveUIContextData(PLUILayout pluiLayout) throws PLException;
+
+    /**
+     * 淇敼涓氬姟绫诲瀷涓嬫坊鍔爑i涓婁笅鏂�
+     * @param pluiLayout
+     * @return
+     * @throws PLException
+     */
+    boolean updateUIContextData(PLUILayout pluiLayout) throws PLException;
+
+    /**
+     * 鏍规嵁涓婚敭鍜屼笟鍔$被鍨媜id鍒犻櫎ui涓婁笅鏂囨暟鎹�
+     * @return
+     */
+    boolean delUIContextData(String[] oids) throws PLException;
+
+    /**
+     * 鍏嬮殕ui涓婁笅鏂�
+     * @param pluiLayoutCloneVO
+     * @return
+     */
+    boolean cloneUiContextData(PLUILayoutCloneVO pluiLayoutCloneVO) throws PLException;
+
+    /**
+     * 瀵煎嚭ui涓婁笅鏂�(鍕鹃�夌殑瑕佸鍑虹殑鎺у埗鍖虹殑鏁版嵁)
+     * oids
+     * @return
+     */
+    void expUiContextData(String[] oids, HttpServletResponse response) throws PLException, IOException;
+
+}
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
index e46d9c8..f573031 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsBtmServiceImpl.java
@@ -493,6 +493,42 @@
     }
 
     /**
+     * 涓氬姟绫诲瀷鍒楄〃鏌ヨ锛岄潪鏍戠粨鏋勶細鐢ㄤ簬UI瀹氫箟宸︿晶涓氬姟绫诲瀷鏌ヨ锛屽彧杩斿洖name鍜宭able
+     * @param btmName
+     * @return
+     * @throws PLException
+     */
+    @Override
+    public Tree getBizTree(String btmName) throws PLException {
+        if(null == btmName){
+            btmName = "";
+        }
+        Tree returnTree = new Tree();
+        BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(btmName);
+        if(Func.isEmpty(bizTypes)){
+            return returnTree;
+        }
+        returnTree.setOid("");
+        returnTree.setText("涓氬姟绫诲瀷");
+        returnTree.setLeaf(false);
+        List<Tree> trees = new ArrayList<>();
+        Arrays.stream(bizTypes).forEach(bizType -> {
+            Tree tree = new Tree();
+            tree.setText(bizType.name + " " +bizType.label);
+            tree.setOid(bizType.oid);
+            tree.setLeaf(true);
+            tree.setParentName(bizType.fName);
+            Map<String, String> atrrMap = new HashMap<>();
+            atrrMap.put("name",bizType.name);
+            atrrMap.put("lable",bizType.label);
+            tree.setAttributes(atrrMap);
+            trees.add(tree);
+        });
+        returnTree.setChildren(trees);
+        return returnTree;
+    }
+
+    /**
      * 鍙傜収涓氬姟绫诲瀷
      *
      * @param conditionMap 鏌ヨ鏉′欢
diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
new file mode 100644
index 0000000..9a1b63a
--- /dev/null
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
@@ -0,0 +1,369 @@
+package com.vci.web.service.impl;
+
+import com.sun.jnlp.ApiDialog;
+import com.vci.client.mw.ClientContextVariable;
+import com.vci.common.utility.ObjectUtility;
+import com.vci.corba.common.PLException;
+import com.vci.corba.portal.PortalService;
+import com.vci.corba.portal.data.*;
+import com.vci.pagemodel.PLUILayoutCloneVO;
+import com.vci.starter.web.exception.VciBaseException;
+import com.vci.starter.web.pagemodel.BaseQueryObject;
+import com.vci.starter.web.pagemodel.DataGrid;
+import com.vci.starter.web.pagemodel.SessionInfo;
+import com.vci.starter.web.util.VciBaseUtil;
+import com.vci.starter.web.util.WebThreadLocalUtil;
+import com.vci.web.service.UIManagerServiceI;
+import com.vci.web.util.Func;
+import com.vci.web.util.PlatformClientUtil;
+import com.vci.web.util.UITools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * UI瀹氫箟鏈嶅姟鐣岄潰鐩稿叧鎺ュ彛
+ * @author ludc
+ * @date 2024/8/28 17:05
+ */
+@Service
+public class UIManagerServiceImpl implements UIManagerServiceI {
+
+    /**
+     * 骞冲彴鐨勮皟鐢ㄥ伐鍏风被
+     */
+    @Resource
+    private PlatformClientUtil platformClientUtil;
+    /**
+     * 鏃ュ織
+     */
+    private Logger logger = LoggerFactory.getLogger(getClass());
+
+    /**
+     * 鎺掑簭姣旇緝鍣�
+     */
+    private Comparator<PLUILayout> pageLayoutComparator = new Comparator<PLUILayout>() {
+        @Override
+        public int compare(PLUILayout o1, PLUILayout o2) {
+            return o1.plCode.compareTo(o2.plCode);
+        }
+    };
+
+    /**
+     * 鏍规嵁涓氬姟绫诲瀷鍚嶆煡璇i涓婁笅鏂囨暟鎹�
+     * @param baseQueryObject
+     * @return
+     * @throws PLException
+     */
+    @Override
+    public DataGrid gridUIContextData(BaseQueryObject baseQueryObject) throws PLException {
+        VciBaseUtil.alertNotNull(baseQueryObject,"鏉′欢瀵硅薄");
+        int page = baseQueryObject.getPage();
+        int limit = baseQueryObject.getLimit();
+        Map<String, String> conditionMap = baseQueryObject.getConditionMap();
+        String btmName = conditionMap.getOrDefault("btmName","");
+        if(Func.isEmpty(conditionMap) || Func.isBlank(btmName)){
+            throw new PLException("500",new String[]{"鏈幏鍙栧埌涓氬姟绫诲瀷鍚嶇О锛�"});
+        }
+        String txtName = conditionMap.getOrDefault("txtName","").trim();
+        String txtCode = conditionMap.getOrDefault("txtCode","").trim();
+        PortalService.GetPLUILayoutsByRelatedTypeAndQueryInfoResult result = platformClientUtil.getUIService()
+                .getPLUILayoutsByRelatedTypeAndQueryInfo(btmName, txtName, txtCode, page, limit);
+        DataGrid<PLUILayout> dataGrid = new DataGrid<>();
+        int total = (int)result.total;
+        dataGrid.setTotal(total);
+        dataGrid.setLimit(limit);
+        dataGrid.setPage(page);
+        PLUILayout[] res = result.returnValue;
+        Arrays.sort(res,pageLayoutComparator);
+        List<PLUILayout> pluiLayouts = Arrays.asList(res);
+        dataGrid.setData(pluiLayouts);
+        return dataGrid;
+    }
+
+    /**
+     * 缁欎笟鍔$被鍨嬩笅娣诲姞ui涓婁笅鏂�
+     * @param pluiLayout
+     * @return
+     * @throws PLException
+     */
+    @Override
+    public boolean saveUIContextData(PLUILayout pluiLayout) throws VciBaseException {
+        try {
+            //ui涓婁笅鏂囧璞℃牎楠�
+            canContinue(pluiLayout);
+
+            String code = pluiLayout.plCode;
+            String name = pluiLayout.plName;
+            boolean isExist = nameOrCodeIsExist(pluiLayout, false);
+            //鏄惁瀛樺湪鏍¢獙
+            if (isExist){
+                throw new VciBaseException("涓婁笅鏂囩紪鐮佹垨鍚嶇О宸茬粡瀛樺湪锛岃妫�鏌ワ紒");
+            }
+
+            PLUILayout pld = new PLUILayout();
+            pld.plOId = ObjectUtility.getNewObjectID36();
+            pld.plCode = code;
+            pld.plName = name;
+            pld.plRelatedType = pluiLayout.plRelatedType;
+            pld.plDesc = pluiLayout.plDesc;
+            SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
+            pld.plCreateUser = sessionInfo.getUserId();
+            pld.plModifyUser = sessionInfo.getUserId();
+            //瀵艰埅鍖�
+            pld.plIsShowForm = pluiLayout.plIsShowForm;
+            //鎺у埗鍖�
+            pld.plIsShowNavigator = pluiLayout.plIsShowNavigator;
+            //鎿嶄綔鍖�
+            pld.plIsShowTab = pluiLayout.plIsShowTab;
+            //鎵ц淇濆瓨
+            return platformClientUtil.getUIService().savePLUILayout(pld);
+        } catch (PLException e) {
+            e.printStackTrace();
+            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            throw new VciBaseException(exceptionMessage);
+        }
+    }
+
+    /**
+     * 淇敼ui涓婁笅鏂�
+     * @param pluiLayout
+     * @return
+     * @throws PLException
+     */
+    @Override
+    public boolean updateUIContextData(PLUILayout pluiLayout) throws VciBaseException {
+        this.canContinue(pluiLayout);
+        try {
+            String code = pluiLayout.plCode;
+            String name = pluiLayout.plName;
+            boolean isExist = nameOrCodeIsExist(pluiLayout, true);
+            if (isExist){
+                throw new VciBaseException("涓婁笅鏂囩紪鐮佹垨鍚嶇О宸茬粡瀛樺湪锛岃妫�鏌ワ紒");
+            }
+
+            PLUILayout pld = new PLUILayout();
+            pld.plOId = pluiLayout.plOId;
+            pld.plCode = code;
+            pld.plName = name;
+            pld.plRelatedType = pluiLayout.plRelatedType;
+            pld.plDesc = pluiLayout.plDesc;
+            pld.plCreateUser = pluiLayout.plCreateUser;
+            pld.plModifyUser = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
+
+            //瀵艰埅鍖�
+            pld.plIsShowForm = pluiLayout.plIsShowForm;
+            //鎺у埗鍖�
+            pld.plIsShowNavigator = pluiLayout.plIsShowNavigator;
+            //鎿嶄綔鍖�
+            pld.plIsShowTab = pluiLayout.plIsShowTab;
+            //鎵ц淇敼
+            return platformClientUtil.getUIService().updatePLUILayout(pld);
+        } catch (PLException e) {
+            e.printStackTrace();
+            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            throw new VciBaseException(exceptionMessage);
+        }
+    }
+
+    /**
+     * 鏍规嵁涓婚敭鍜屼笟鍔$被鍨媜id鍒犻櫎ui涓婁笅鏂囨暟鎹�
+     * @return
+     */
+    @Override
+    public boolean delUIContextData(String[] oids) throws PLException {
+        VciBaseUtil.alertNotNull(oids,"寰呭垹闄ょ殑瀵硅薄鍒楄〃");
+        //鍒犻櫎鏂规硶涓湁鍏宠仈鏁版嵁鍒犻櫎鐨勬搷浣滈�昏緫
+        return platformClientUtil.getUIService().deletePLUILayoutByOidsForCascade(oids);
+    }
+
+    /**
+     * 鍏嬮殕ui涓婁笅鏂囷紙鍏峰鍏宠仈鏁版嵁鐨勫厠闅嗭級
+     * @param pluiLayoutCloneVO
+     * @return
+     */
+    @Override
+    public boolean cloneUiContextData(PLUILayoutCloneVO pluiLayoutCloneVO) throws PLException {
+        VciBaseUtil.alertNotNull(
+            pluiLayoutCloneVO,"鍏嬮殕鍙傛暟瀵硅薄",
+            pluiLayoutCloneVO.getSourcePLUILayout(),"鍏嬮殕鐨勬簮瀵硅薄淇℃伅",
+            pluiLayoutCloneVO.getCloneName(),"鍏嬮殕鐨勫璞″悕绉�",
+            pluiLayoutCloneVO.getCloneContextCode(),"鍏嬮殕鐨勫璞′笂涓嬫枃缂栫爜"
+        );
+        PLUILayout pluiLayout = new PLUILayout();
+        PLUILayout sourcePLUILayout = pluiLayoutCloneVO.getSourcePLUILayout();
+        //濡傛灉閫夋嫨鍏嬮殕鐩爣锛屽垯鍏嬮殕鍒伴�夋嫨鐨勭被鍨嬩笅锛屽鏋滄病鏈夐�夋嫨鍏嬮殕鐩爣锛屽垯鍏嬮殕鍒板綋鍓嶇被鍨嬩笅
+        if(Func.isBlank(pluiLayoutCloneVO.getCloneTargetOid())){
+            pluiLayout.plRelatedType = sourcePLUILayout.plRelatedType;
+        }
+        //鍏嬮殕鐨勫悕绉板拰ui涓婁笅鏂囩紪鍙锋煡閲�
+        String cloneName = pluiLayoutCloneVO.getCloneName();
+        String cloneContextCode = pluiLayoutCloneVO.getCloneContextCode();
+        pluiLayout.plOId = ObjectUtility.getNewObjectID36();
+        pluiLayout.plName = cloneName;
+        pluiLayout.plCode = cloneContextCode;
+        pluiLayout.plIsShowTab = sourcePLUILayout.plIsShowTab;
+        pluiLayout.plIsShowNavigator = sourcePLUILayout.plIsShowNavigator;
+        pluiLayout.plIsShowForm = sourcePLUILayout.plIsShowForm;
+        pluiLayout.plDesc = sourcePLUILayout.plDesc;
+        SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread();
+        pluiLayout.plCreateUser = sessionInfo.getUserId();
+        pluiLayout.plModifyUser = sessionInfo.getUserId();
+        //鍏嬮殕鐩爣涓媢i鍚嶇О鍜岀紪鍙锋煡閲�
+        this.checkCodeName(pluiLayout);
+        //1銆佸厛淇濆瓨ui涓婁笅鏂�
+        boolean res = platformClientUtil.getUIService().savePLUILayout(pluiLayout);
+        //2銆佸啀鑰冭檻瀛愯妭鐐圭殑鍏嬮殕
+        PLTabPage[] pages = platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(sourcePLUILayout.plOId); //鎺у埗鍖鸿妭鐐瑰強鍏跺瓙鑺傜偣鐨勫厠闅�
+        if(pages == null){
+            return true;
+        }
+        try {
+            for (PLTabPage page : pages) {
+                savePlpageLayoutDefinationRelation(page,pluiLayout.plOId);
+            }
+            return true;
+        }catch (Exception e){
+            e.printStackTrace();
+            String exceptionMessage = VciBaseUtil.getExceptionMessage(e);
+            logger.error(exceptionMessage);
+            throw new VciBaseException(exceptionMessage);
+        }
+    }
+
+    @Override
+    public void expUiContextData(String[] oids, HttpServletResponse response) throws PLException, IOException {
+
+    }
+
+    /**
+     * 鎺у埗鍖鸿妭鐐瑰強鍏跺瓙鑺傜偣鐨勫厠闅�
+     * @param obj
+     */
+    private void savePlpageLayoutDefinationRelation(Object obj,String plUILayoutId) {
+        PLTabPage tabPage = (PLTabPage)obj;
+        try {
+
+            PLPageDefination[] pLPageDefinations = platformClientUtil.getUIService().getPLPageDefinationsByPageContextOId(tabPage.plOId);
+
+            tabPage.plOId = ObjectUtility.getNewObjectID36();
+            tabPage.plContextOId = plUILayoutId;
+            //add by caill start 2016.8.15 瀵艰埅鍖恒�佹帶鍒跺尯銆佹搷浣滃尯鍦ㄦ病鏈夊瓙鑺傜偣鐨勬儏鍐典笅鐨勫厠闅�
+            if(pLPageDefinations.length==0){
+                platformClientUtil.getUIService().savePLTabPage(tabPage);
+            }
+            //add by caill end
+            for(int j=0;j<pLPageDefinations.length;j++){
+                PLPageDefination plPageDef = pLPageDefinations[j];
+
+                platformClientUtil.getUIService().savePLTabPage(tabPage);
+                PLTabButton[] pLTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(plPageDef.plOId);
+
+                plPageDef.plOId = ObjectUtility.getNewObjectID36();
+                plPageDef.plTabPageOId = tabPage.plOId;
+                platformClientUtil.getUIService().savePLPageDefination(plPageDef);
+
+                for(int b=0;b<pLTabButtons.length;b++){
+                    PLTabButton plTabButton = pLTabButtons[b];
+                    PLCommandParameter[] pLCommandParameters = platformClientUtil.getUIService().getPLCommandParametersByCommandOId(plTabButton.plOId);
+
+                    plTabButton.plOId = ObjectUtility.getNewObjectID36();
+                    plTabButton.plTableOId = plPageDef.plOId;
+                    platformClientUtil.getUIService().savePLTabButton(plTabButton);
+
+                    for(int c=0;c<pLCommandParameters.length;c++){
+                        final PLCommandParameter plCommandParameter = pLCommandParameters[c];
+                        plCommandParameter.plOId = ObjectUtility.getNewObjectID36();
+                        plCommandParameter.plCommandOId = plTabButton.plOId;
+                        platformClientUtil.getUIService().savePLCommandParameter(plCommandParameter);
+                    }
+                }
+            }
+        } catch (PLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 鏈仛鍒ょ┖澶勭悊锛岃皟鐢ㄥ墠璇蜂繚璇乷bj涓嶄负绌�
+     * @param obj
+     * @throws PLException
+     */
+    public void checkCodeName(PLUILayout obj) throws PLException {
+        PLUILayout[] plUILayouts = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(obj.plRelatedType);
+        int length = plUILayouts.length;
+        String code = obj.plCode;
+        String name = obj.plName;
+
+        if (Func.isNotBlank(name) || Func.isNotBlank(code)){
+            for (int i =0;i<length;i++){//寰幆鑺傜偣鐨刄I涓婃枃鍜屽悕绉�
+                if (plUILayouts[i].plCode.equalsIgnoreCase(code) || plUILayouts[i].plName.equals(name)){
+                    throw new VciBaseException("涓氬姟绫诲瀷涓婾I鍚嶇О鎴朥I涓婁笅鏂囩紪鐮佸凡瀛樺湪锛�");
+                }
+            }
+        }
+    }
+
+    /**
+     * ui涓婁笅鏂囨柊澧炰慨鏀瑰墠妫�鏌�
+     * @param pluiLayout
+     */
+    private void canContinue(PLUILayout pluiLayout){
+        String code = pluiLayout.plCode;
+        String name = pluiLayout.plName;
+        if(Func.isBlank(code)){
+            throw new VciBaseException("涓婁笅鏂囩紪鐮佷笉鑳戒负绌猴紒");
+        }
+        if(Func.isBlank(name)){
+            throw new VciBaseException("鍚嶇О涓嶈兘涓虹┖锛�");
+        }
+        if((pluiLayout.plIsShowNavigator == 0) && (pluiLayout.plIsShowForm == 0) && (pluiLayout.plIsShowTab == 0)){
+            throw new VciBaseException("涓婁笅鏂囪嚦灏戣鍖呭惈涓�涓尯鍩燂紒");
+        }
+    }
+
+    /**
+     * 妫�鏌ュ悕绉版垨鑰呯紪鐮佹槸鍚﹀凡瀛樺湪
+     * @param pluiLayout
+     * @param isEdit
+     * @return
+     * @throws VciBaseException
+     */
+    private boolean nameOrCodeIsExist(PLUILayout pluiLayout, boolean isEdit) throws PLException {
+        boolean res = false;
+        //鏌ヨ鍚屼竴涓氬姟绫诲瀷涓嬬殑ui涓婁笅鏂囷紝鐒跺悗鏌ラ噸
+        PLUILayout[] plpagelayoutdefinations = platformClientUtil.getUIService().getPLUILayoutsByRelatedType(pluiLayout.plRelatedType);
+        int length = plpagelayoutdefinations.length;
+        for (int i =0;i<length;i++){
+            String code = plpagelayoutdefinations[i].plCode;
+            String name = plpagelayoutdefinations[i].plName;
+            String ids = plpagelayoutdefinations[i].plOId;
+            if(isEdit){
+                if(!ids.equals(pluiLayout.plOId)){
+                    if (pluiLayout.plCode.equalsIgnoreCase(code) || pluiLayout.plName.equals(name)){
+                        res = true;
+                        break;
+                    }
+                }
+            }
+            else {
+                if (code.equalsIgnoreCase(code) || name.equals(name)){
+                    res = true;
+                    break;
+                }
+            }
+        }
+        return res;
+    }
+
+}

--
Gitblit v1.9.3