From b9f3e4a899013ce21de3fc1ac127d137c7494595 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 02 九月 2024 15:21:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java |  563 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 555 insertions(+), 8 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java
index 0ce7bef..fd3d7b9 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java
@@ -1,27 +1,30 @@
 package com.vci.web.service.impl;
 import cn.hutool.core.io.FileUtil;
+import com.vci.constant.FrameWorkLangCodeConstant;
 import com.vci.corba.common.PLException;
-import com.vci.corba.omd.ltm.LinkType;
-import com.vci.corba.omd.qtm.QTInfo;
 import com.vci.corba.portal.data.Constraint;
 import com.vci.corba.portal.data.PLAction;
 import com.vci.corba.portal.data.PLActionCls;
 import com.vci.corba.portal.data.PLActionParam;
-import com.vci.dto.PLActionClsDTO;
-import com.vci.dto.PLActionDTO;
-import com.vci.dto.PLActionQueryDTO;
+import com.vci.dto.*;
+import com.vci.starter.poi.bo.WriteExcelData;
+import com.vci.starter.poi.bo.WriteExcelOption;
+import com.vci.starter.poi.util.ExcelUtil;
+import com.vci.starter.web.exception.VciBaseException;
 import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.util.ControllerUtil;
+import com.vci.starter.web.util.LangBaseUtil;
 import com.vci.starter.web.util.LocalFileUtil;
+import com.vci.web.enumpck.ActionEnum;
+import com.vci.web.enumpck.PlTypetypeEnum;
 import com.vci.web.other.ExportActionLogBean;
 import com.vci.web.other.ExportBeans;
-import com.vci.web.other.LinkQTExportData;
 import com.vci.web.service.*;
 import com.vci.web.util.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
@@ -302,7 +305,7 @@
     @Override
     public void exportBeans(List<String> actionOid, HttpServletResponse response) throws PLException, IOException {
         String defaultTempFolder = LocalFileUtil.getDefaultTempFolder();
-        String vciqtmfFileName = defaultTempFolder + File.separator + "actionTemplateExp" + new Date().getTime() + ".vciamf";
+        String vciqtmfFileName = defaultTempFolder + File.separator + "VCIACTIONMODELFILE" + new Date().getTime() + ".vciamf";
         HashMap exportBeans = new HashMap<String, Object>();
         getExportBeans(actionOid, exportBeans);// 鑾峰緱瀵煎嚭Bean鍚屾椂锛岃褰昹og
 
@@ -325,6 +328,550 @@
         FileUtil.del(defaultTempFolder + File.separator);
     }
 
+    @Override
+    public BaseResult impData(MultipartFile file) throws IOException, PLException {
+        // 瀵煎叆鐨勫璞�
+        ExportBeans exportBeans = null;
+        if (file == null) {
+            return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+        }
+        if (!file.getOriginalFilename().endsWith(".vciamf")) {
+            throw new VciBaseException("浠呰兘涓婁紶.vciqtf鏍煎紡鏂囦欢锛岃閲嶆柊涓婁紶锛�");
+        }
+        HashMap map;
+        try {
+            ObjectInputStream obj = new ObjectInputStream(file.getInputStream());
+            map = (HashMap) obj.readObject();
+        } catch (ClassNotFoundException e) {
+            return BaseResult.fail("瀵煎叆瀵硅薄鏈幏鍙栨垚鍔燂紒锛佸鍏ュ璞$増鏈彿涓嶅悓锛�");
+        }
+        //鏈�缁堢殑鎸佷箙鍖�
+        ArrayList<PLActionCls> pLActionClsList = new ArrayList<>();
+        // 鏇存崲actionId鍚庯紝鍙互浠庢瀵艰埅涓幏寰楀師鏉ョ殑id
+        HashMap<String /* newId */, String /* oldId */> actionIdNav = new HashMap<String /* newId */, String /* oldId */>();
+        // 鏇存崲actionClsId鍚庯紝鍙互浠庢瀵艰埅涓幏寰楀師鏉ョ殑id
+        HashMap<String /* newId */, String /* oldId */> actionClsIdNav = new HashMap<String /* newId */, String /* oldId */>();
+        //淇濆瓨鎵�鏈夌埗鍒嗙被锛岀敤id涓籯ey
+        HashMap<String/*id*/,PLActionCls> actionClses = new HashMap<String/*id*/,PLActionCls>();
+        // 瀛樺偍绗﹀悎鏉′欢鐨凱LAction
+        ArrayList<PLAction> optionPLActionList = new ArrayList<>();
+        // 瀛樺偍绗﹀悎鏉′欢鐨凱LActionCls
+        ArrayList<PLActionCls> optionPLActionClsList =  new ArrayList<>();
+        // 搴撲腑鐨勬墍鏈堿ction鍒嗙被瀵硅薄
+        PLActionCls[] pLActionClses = null;
+        exportBeans = (ExportBeans) map.get("exportBeans");
+        // 娣诲姞瀵煎叆鐨勬暟鎹�
+        addImportData(exportBeans, pLActionClsList, actionIdNav, actionClsIdNav, optionPLActionClsList, pLActionClses, optionPLActionList);
+        // 灏哖LActionCls 銆丳LAction 瀵瑰簲鐨剆et闆嗗悎杞崲鎴愭暟缁勶紙鍖归厤鍘焌ddExportTreeNode鏂规硶锛�
+        PLActionCls[] newPLActionClsArray = new PLActionCls[optionPLActionClsList.size()];
+        PLAction[] newPLActionArray = new PLAction[optionPLActionList.size()];
+        optionPLActionClsList.toArray(newPLActionClsArray);
+        optionPLActionList.toArray(newPLActionArray);
+        //娓呮鍒嗙被id
+        actionClses.clear();
+        //淇濆瓨鎵�鏈夊垎绫籭d
+        for (int i = 0; i < newPLActionClsArray.length; i++) {
+            actionClses.put(newPLActionClsArray[i].id,newPLActionClsArray[i]);
+        }
+        //淇濆瓨鎵�鏈夊瓨鍦╝ction鐨勫垎绫伙紙瀛愬垎绫诲瓨鍦╝ction涔熶繚瀛橈級
+        HashSet<PLActionCls> pLActionClss =new HashSet<PLActionCls> ();
+        for (int i = 0; i < newPLActionArray.length; i++) {
+            //缂撳瓨璇ュ垎绫荤殑鎵�鏈夌埗鍒嗙被
+            saveParentCls(newPLActionArray[i].plActionCls,pLActionClss,actionClses);
+        }
+        PLActionCls[] actionClslist = new PLActionCls[pLActionClss.size()];
+        pLActionClss.toArray(actionClslist);
+        PLActionClsDTO treDto = new PLActionClsDTO();
+        treDto.setName("Action鍒嗙被");
+
+        Map<String, List<PLAction>> plActionMap = Arrays.stream(newPLActionArray).collect(Collectors.groupingBy(e -> e.plActionCls));
+        Map<String, List<PLActionCls>> plActionClsMap = pLActionClss.stream().collect(Collectors.groupingBy(e -> e.pid));
+        Map<String, List<PLActionCls>> allCls = Arrays.stream(platformClientUtil.getUIService().getPLActionClsArray()).collect(Collectors.groupingBy(e -> e.name));
+        // 娣诲姞瀛愯妭鐐�(婧愭爲鑺傜偣)
+        for (Map.Entry<String, PLActionCls> entry : exportBeans.getPLActionClsBeans().entrySet()) {
+            if (StringUtils.isBlank(entry.getValue().pid)) {
+                PLActionClsDTO parentDto = new PLActionClsDTO();
+                parentDto.setId(entry.getValue().id);
+                parentDto.setName(entry.getValue().name);
+                parentDto.setPid(entry.getValue().pid);
+                parentDto.setDescription(entry.getValue().description);
+                parentDto.setCreator(entry.getValue().creator);
+                parentDto.setCreateTime(entry.getValue().createTime);
+                parentDto.setSerialno(entry.getValue().serialno);
+                addExportTreeNode(plActionClsMap, plActionMap, parentDto, allCls, exportBeans);
+                treDto.getChilds().add(parentDto);
+            }
+        }
+        PLActionClsDTO noDto = new PLActionClsDTO();
+        noDto.setName("鏈垎绫�");
+        if(plActionMap.containsKey("")){
+            for (PLAction plAction : plActionMap.get("")) {
+                PLActionClsDTO childPrentDto = new PLActionClsDTO();
+                if (plAction.plName.endsWith("@#淇敼$%")) {
+                    childPrentDto.setName(plAction.plCode + "/" + plAction.plName.replace("@#淇敼$%", "銆愪慨鏀瑰畬鎴愩��"));
+                    plAction.plName = plAction.plName.replace("@#淇敼$%", "");
+                    platformClientUtil.getUIService().updatePLAction(plAction);
+                }else
+                if (plAction.plName.endsWith("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%")) {
+                    childPrentDto.setName(plAction.plCode + "/" + plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "銆恆ction瀛樺湪鍦ㄦ湭鍒嗙被涓紝淇敼瀹屾垚銆�"));
+                    plAction.plName = plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "");
+                    platformClientUtil.getUIService().updatePLAction(plAction);
+//                    plAction.plName = plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "銆恆ction瀛樺湪鍦ㄦ湭鍒嗙被涓紝淇敼Action骞舵寜瀵煎叆鏂囦欢鍒涘缓action鍒嗙被銆�");
+                }
+                else {
+                    childPrentDto.setName(plAction.plCode + "/" + "銆愭柊澧炲畬鎴愩��");
+//                    plAction.plName += "銆愭柊澧炪��";
+                    platformClientUtil.getUIService().savePLAction(plAction);
+                }
+                dealParam(exportBeans, plAction);
+                childPrentDto.setId(plAction.plOId);
+                childPrentDto.setPid(plAction.plActionCls);
+                noDto.getChilds().add(childPrentDto);
+            }
+        }
+        treDto.getChilds().add(noDto);
+
+        return BaseResult.success(treDto);
+    }
+    /**
+     * 瀵煎嚭Action
+     * @param plActionExpDTO 瀵煎嚭灞炴�ц缃璞�
+     */
+    @Override
+    public void exportAction(PLActionExpDTO plActionExpDTO, HttpServletResponse response) throws PLException, IOException {
+        String defaultTempFolder = LocalFileUtil.getDefaultTempFolder();
+        String excelPath = defaultTempFolder + File.separator + plActionExpDTO.getFileName() + ".xls";
+        try {
+            new File(excelPath).createNewFile();
+        } catch (Throwable e) {
+            throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e);
+        }
+        isValidPageForamt(plActionExpDTO);
+        //璁剧疆鍒�
+        List<WriteExcelData> excelDataList = new ArrayList<>();
+        //璁剧疆鍒楀ご
+        for (int index = 0; index < plActionExpDTO.getColumnName().size(); index++) {
+            excelDataList.add(new WriteExcelData(0,index, plActionExpDTO.getColumnName().get(index)));
+        }
+        PLAction[] allPLAction ;
+        if(plActionExpDTO.getDataType().equals(ActionEnum.EXP_ALL.getValue()) ||
+                plActionExpDTO.getDataType().equals(ActionEnum.EXP_PAGE.getValue())){
+            allPLAction = platformClientUtil.getUIService().getAllPLAction();
+        }else{
+            allPLAction = new PLAction[plActionExpDTO.getChooseDataOid().size()];
+            for (int i = 0; i < plActionExpDTO.getChooseDataOid().size(); i++) {
+                allPLAction[i] = platformClientUtil.getUIService().getPLActionById(plActionExpDTO.getChooseDataOid().get(i));
+            }
+        }
+        if(Func.isEmpty(allPLAction)){
+            excelDataList.add(new WriteExcelData(1,1, "鏍规嵁灞炴�у悕绉版湭鏌ヨ鍒板睘鎬т俊鎭紝璇峰埛鏂板悗灏濊瘯閲嶆柊瀵煎嚭锛�"));
+        }else{
+            for (int i = 0; i < allPLAction.length; i++) {
+                PLAction action = allPLAction[i];
+                List<String> columnName = plActionExpDTO.getColumnName();
+                for (int index = 0; index < columnName.size(); index++) {
+                    switch (columnName.get(index)){
+                        case "缂栧彿":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plCode));
+                            break;
+                        case "绫昏矾寰�":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plBSUrl));
+                            break;
+                        case "閾炬帴鍦板潃":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plCSClass));
+                            break;
+                        case "鎻忚堪":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plDesc));
+                            break;
+                        case "绫诲瀷":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plTypeType.equals(PlTypetypeEnum.BUSINESS.getValue()) ?
+                                    PlTypetypeEnum.BUSINESS.getText() : PlTypetypeEnum.LINK.getText()));
+                            break;
+                        case "鍚嶇О":
+                            excelDataList.add(new WriteExcelData(i+1,index, action.plName));
+                            break;
+                    }
+                }
+            }
+        }
+        WriteExcelOption excelOption = new WriteExcelOption(excelDataList);
+        ExcelUtil.writeDataToFile(excelPath, excelOption);
+        ControllerUtil.writeFileToResponse(response,excelPath);
+        FileUtil.del(defaultTempFolder + File.separator);
+    }
+    /**
+     * 淇濆瓨Action鍙傛暟鏁版嵁
+     * dto action浼犺緭瀵硅薄
+     * @return 淇濆瓨缁撴灉
+     */
+    @Override
+    public BaseResult savePLActionParam(PLActionParamDTO dto) throws PLException {
+        if(dto.getName() == null || dto.getName().equals("")) {
+            throw new PLException("500",new String[]{"鍙傛暟鍚嶇О涓嶈兘涓虹┖"});
+        }
+        PLActionParam param = new PLActionParam();
+        param.oid = "";
+        param.name = dto.getName();
+        param.defaultValue = dto.getDefaultValue();
+        param.description = dto.getDescription();
+        param.action = dto.getAction();
+        String message = platformClientUtil.getUIService().createPLActionParam(param);
+
+        if(message.startsWith("0")) {
+            if(message.equals("01")) {
+                throw new PLException("500",new String[]{"鍙傛暟鍚嶅凡缁忓瓨鍦紒"});
+            } else {
+                throw new PLException("500",new String[]{"娣诲姞鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)});
+            }
+        }
+        return BaseResult.success();
+    }
+
+    @Override
+    public BaseResult updatePLActionParam(PLActionParamDTO dto) throws PLException {
+        if(dto.getName() == null || dto.getName().equals("")) {
+            throw new PLException("500",new String[]{"鍙傛暟鍚嶇О涓嶈兘涓虹┖"});
+        }
+        PLActionParam param = new PLActionParam();
+        param.oid = dto.getOid();
+        param.name = dto.getName();
+        param.defaultValue = dto.getDefaultValue();
+        param.description = dto.getDescription();
+        param.action = dto.getAction();
+        String message = platformClientUtil.getUIService().editPLActionParam(param);
+
+        if(message.startsWith("0")) {
+            if(message.equals("01")) {
+                throw new PLException("500",new String[]{"鍙傛暟鍚嶅凡缁忓瓨鍦紒"});
+            } else {
+                throw new PLException("500",new String[]{"娣诲姞鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)});
+            }
+        }
+        return BaseResult.success();
+    }
+    /**
+     * 鍒犻櫎Action鍙傛暟鏁版嵁
+     * oid 鍙傛暟涓婚敭
+     * @return 淇濆瓨缁撴灉
+     */
+    @Override
+    public BaseResult deletePLActionParam(String oid) throws PLException {
+        if(StringUtils.isBlank(oid)){
+            throw new PLException("500", new String[]{"鍙傛暟涓婚敭涓嶈兘涓虹┖"});
+        }
+        String message = platformClientUtil.getUIService().deletePLActionParam(oid);
+        if (message.startsWith("0")) {
+            throw new PLException("500", new String[]{"鍒犻櫎鎸夐挳鍙傛暟鏃跺彂鐢熷紓甯革細" + message.substring(1)});
+        }
+        return BaseResult.success();
+    }
+
+    public boolean isValidPageForamt(PLActionExpDTO plActionExpDTO) throws PLException {
+
+        boolean res = false;
+        if(plActionExpDTO.getDataType().equals(ActionEnum.EXP_ALL.getValue()) ||
+                plActionExpDTO.getDataType().equals(ActionEnum.EXP_CHOOSE.getValue())) {
+            res = true;
+            return res;
+        }
+        if(StringUtils.isBlank(plActionExpDTO.getPageNum())){
+            throw new PLException("500", new String[]{"椤电爜涓嶈兘涓虹┖"});
+        } else{
+            int pageCount = 1;//杩欓噷鍥哄畾鐢变簬鐣岄潰娌℃湁缈婚〉鍔熻兘
+            String[] pages = plActionExpDTO.getPageNum().split("-");
+
+            // 鐢╠obule鎺ユ敹杈撳叆鐨勬暟鎹紝闃叉杈撳叆瓒呭ぇ鍊硷紙澶т簬Integer.MAX_VALUE锛�
+            // 杞崲鎴怚nteger锛岃繘琛屾瘮杈冿紝鍙婂湪鎻愮ず鍐呭涓幓鎺塪ouble绫诲瀷鏁版嵁鍙兘浼氬嚭鐜扮殑灏忔暟鐐�
+            if(pages.length == 1){
+                double pageD = Double.parseDouble(pages[0]);
+                if(pageD > Integer.MAX_VALUE){
+                    throw new PLException("500", new String[]{"璧峰椤电爜 " + String.valueOf(pageD) + " 涓嶅緱澶т簬 " + Integer.MAX_VALUE});
+                }else{
+                    int page = (int)pageD;
+                    if(page > pageCount){
+                        throw new PLException("500", new String[]{"杈撳叆鐨勯〉鐮� " + page + " 涓嶅緱澶т簬鎬婚〉鏁� " + pageCount});
+                    } else if(page > Integer.MAX_VALUE){
+                        throw new PLException("500", new String[]{"杈撳叆鐨勯〉鐮� " + page + " 涓嶅緱澶т簬 " + Integer.MAX_VALUE});
+                    } else {
+                        res = true;
+                    }
+                }
+            } else{
+                double pageStartD = Double.parseDouble(pages[0]);
+                double pageEndD = Double.parseDouble(pages[1]);
+                if(pageStartD > Integer.MAX_VALUE){
+                    throw new PLException("500", new String[]{"璧峰椤电爜 " + pageStartD + " 涓嶅緱澶т簬 " + Integer.MAX_VALUE});
+                } else if(pageEndD > Integer.MAX_VALUE){
+                    throw new PLException("500", new String[]{"缁撴潫椤电爜 " + pageEndD + " 涓嶅緱澶т簬 " + Integer.MAX_VALUE});
+                } else{
+                    int pageStart = (int)pageStartD;
+                    int pageEnd = (int)pageEndD;
+                    if(pageStart > pageCount){
+                        throw new PLException("500", new String[]{"璧峰椤电爜 " + pageStart + " 涓嶅緱澶т簬鎬婚〉鏁� " + pageCount});
+                    } else if(pageEnd > pageCount){
+                        throw new PLException("500", new String[]{"缁撴潫椤电爜 " + pageEnd + " 涓嶅緱澶т簬鎬婚〉鏁� " + pageCount});
+                    } else if(pageStart > pageEnd){
+                        throw new PLException("500", new String[]{"璧峰椤电爜 " + pageStart + " 涓嶅緱澶т簬缁撴潫椤电爜 " + pageEnd});
+                    } else{
+                        res = true;
+                    }
+                }
+            }
+        }
+        return res;
+    }
+
+
+    /**
+     * 澶勭悊鍙傛暟鍒楄〃
+     * @param exportBeans 瀵煎叆鏁版嵁闆嗗悎
+     * @param plAction action瀵硅薄
+     * @throws PLException
+     */
+    private void dealParam(ExportBeans exportBeans, PLAction plAction) throws PLException {
+        PLActionParam[] plActionParamArrayByActionId = exportBeans.getPLActionParamArrayByActionId(plAction.plOId);
+        PLActionParam[] paramArray = platformClientUtil.getUIService().getPLActionParamArrayByActionId(plAction.plOId);
+        Map<String, List<PLActionParam>> params = Arrays.stream(paramArray).collect(Collectors.groupingBy(e -> e.oid));
+        if(plActionParamArrayByActionId == null){
+            return;
+        }
+        for (PLActionParam param : plActionParamArrayByActionId) {
+            if(params.containsKey(param)){
+                platformClientUtil.getUIService().editPLActionParam(param);
+            }else {
+                platformClientUtil.getUIService().createPLActionParam(param);
+            }
+        }
+    }
+
+    private void addExportTreeNode(Map<String, List<PLActionCls>> pLActionClses, Map<String, List<PLAction>> plActions,
+                                   PLActionClsDTO parentDto,Map<String, List<PLActionCls>> allCls, ExportBeans exportBeans) throws PLException {
+
+        //澶勭悊褰撳墠鑺傜偣涓嬬殑action
+        if(plActions.containsKey(parentDto.getId())){
+            for (PLAction plAction : plActions.get(parentDto.getId())) {
+                PLActionClsDTO childPrentDto = new PLActionClsDTO();
+                childPrentDto.setId(plAction.plOId);
+                if (plAction.plName.endsWith("@#淇敼$%")) {
+                    childPrentDto.setName(plAction.plCode + "/" + plAction.plName.replace("@#淇敼$%", "銆愪慨鏀规垚鍔熴��"));
+//                    plAction.plName = plAction.plName.replace("@#淇敼$%", "銆愪慨鏀广��");
+                    plAction.plName = plAction.plName.replace("@#淇敼$%", "");
+                    platformClientUtil.getUIService().updatePLAction(plAction);
+                }else
+                if (plAction.plName.endsWith("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%")) {
+                    childPrentDto.setName(plAction.plCode + "/" + plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "銆恆ction瀛樺湪鍦ㄦ湭鍒嗙被涓紝淇敼Action鎴愬姛銆�"));
+//                    plAction.plName = plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "銆恆ction瀛樺湪鍦ㄦ湭鍒嗙被涓紝淇敼Action骞舵寜瀵煎叆鏂囦欢鍒涘缓action鍒嗙被銆�");
+                    plAction.plName = plAction.plName.replace("@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%", "");
+                    platformClientUtil.getUIService().updatePLAction(plAction);
+                }
+                else {
+                    childPrentDto.setName(plAction.plCode + "/" + plAction.plName.replace("@#鏂板%", "銆愭柊澧炴垚鍔熴��"));
+//                    plAction.plName += "銆愭柊澧炪��";
+                    platformClientUtil.getUIService().savePLAction(plAction);
+                }
+                dealParam(exportBeans, plAction);
+                childPrentDto.setPid(plAction.plActionCls);
+                parentDto.getChilds().add(childPrentDto);
+            }
+        }
+        if(pLActionClses.containsKey(parentDto.getId())){
+            List<PLActionCls> plActionCls = pLActionClses.get(parentDto.getId());
+            for (PLActionCls plActionCl : plActionCls) {
+                PLActionClsDTO childParentDto = new PLActionClsDTO();
+                childParentDto.setId(plActionCl.id);
+                if(allCls.containsKey(childParentDto.getName())){
+                    childParentDto.setName(plActionCl.name);
+                }else {
+                    childParentDto.setName(plActionCl.name + "銆愭柊澧炲畬鎴愩��");
+                    platformClientUtil.getUIService().creaetePLActionCls(plActionCl);
+                }
+                childParentDto.setPid(plActionCl.pid);
+                childParentDto.setDescription(plActionCl.description);
+                childParentDto.setCreator(plActionCl.creator);
+                childParentDto.setCreateTime(plActionCl.createTime);
+                childParentDto.setSerialno(plActionCl.serialno);
+                addExportTreeNode(pLActionClses, plActions, childParentDto, allCls, exportBeans);
+                parentDto.getChilds().add(childParentDto);
+            }
+
+        }
+
+    }
+
+
+    /**
+     * 淇濆瓨鎵�鏈夌埗鍒嗙被
+     * @param plActionCls
+     * @param pLActionClsList
+     */
+    private void saveParentCls(String plActionCls, HashSet<PLActionCls> pLActionClsList,
+                               HashMap<String/*id*/,PLActionCls> actionClses) {
+        if(actionClses.containsKey(plActionCls)){
+            PLActionCls pCls = actionClses.get(plActionCls);
+            pLActionClsList.add(pCls);
+            saveParentCls(pCls.pid, pLActionClsList, actionClses);
+        }
+
+    }
+
+    private void addImportData(ExportBeans exportBeans, ArrayList<PLActionCls> pLActionClsList, HashMap<String /* newId */,
+            String /* oldId */> actionIdNav,HashMap<String /* newId */, String /* oldId */> actionClsIdNav,
+            ArrayList<PLActionCls> optionPLActionClsList, PLActionCls[] pLActionClses, ArrayList<PLAction> plActionList)
+            throws PLException {
+        HashMap<String, PLAction> pLActionBeans = exportBeans.getPLActions();
+        if (pLActionBeans == null) {
+            throw new VciBaseException("瀵煎叆瀵硅薄鏈幏鍙栨垚鍔燂紒锛�");
+        }
+        //鏁版嵁搴撲腑娌℃湁瀛樺湪鐨勬暟鎹璞★紝闇�瑕佽繘琛屼繚瀛�
+//        ArrayList<PLAction> plActionList = new ArrayList<>();
+        PLAction[] allPLAction = platformClientUtil.getUIService().getAllPLAction();
+        Map<String, PLAction> allPLActionMap = Arrays.stream(allPLAction).collect(Collectors.toMap(e -> e.plOId, e -> e));
+        Set<Map.Entry<String, PLAction>> plActions = pLActionBeans.entrySet();
+        for (Map.Entry<String, PLAction> entry : plActions) {
+            PLAction plAction = entry.getValue();
+            PLAction plActionInDB =allPLActionMap.get(plAction.plOId);
+
+            if (plActionInDB != null) {
+                if( plActionInDB.plActionCls != ""){
+                    plAction.plActionCls = plActionInDB.plActionCls;
+                    // plAction.plOId = newId;
+                    plAction.plName += "@#淇敼$%";
+                    plActionList.add(plAction);
+                    continue;
+                }else{
+                    plAction.plName += "@#瀛樺湪鍦ㄦ湭鍒嗙被涓�$%";
+                }
+
+            }
+            // 灏嗚瀹炰緥acion瀛樺叆鍒皃lActionList涓�
+            plActionList.add(plAction);
+
+            // 瀹氫箟list瀛樺偍褰撳墠action鍒版暟鎹簱action鐨勮矾寰勪笂鐨勬墍鏈塒LActionCls瀵硅薄
+            List<PLActionCls> plActionClsList = new ArrayList<PLActionCls>();
+            // 鑾峰緱搴撲腑鐨勬渶杩戠殑PLActionCls瀵硅薄
+            String pId = WebUtil.getSnowflakePk();
+            String oId = WebUtil.getSnowflakePk();
+
+            PLActionCls pLActionCls = getParentPLActionClsInDBById(plAction,
+                    pId, plActionClsList, actionClsIdNav, exportBeans, optionPLActionClsList, pLActionClses);
+
+            changePLActionOID(plAction, oId, pId, actionIdNav);
+
+            if (plActionClsList.size() == 1) {
+                // 鍒犻櫎"鏈垎绫�"鍒嗙被瀵硅薄
+                PLActionCls plActionCls = plActionClsList.get(plActionClsList
+                        .size() - 1);
+
+                if(pLActionCls != null){
+                    plAction.plActionCls = pLActionCls.id;
+                    if(plActionCls.name.equals("鏈垎绫�")){
+                        plAction.plActionCls = "";
+                    }
+                    plActionClsList.remove(plActionClsList.size() - 1);
+                }else{
+                    if(plActionCls.name.equals("鏈垎绫�")){
+                        plActionClsList.remove(plActionClsList.size() - 1);
+                    }else{
+                        plActionCls.pid = "";
+                    }
+
+                }
+
+            }
+            if (plActionClsList.size() >= 2) {
+
+                PLActionCls plActionCls2 = plActionClsList.get(plActionClsList
+                        .size() - 2);
+                PLActionCls plActionCls1 = plActionClsList.get(plActionClsList
+                        .size() - 1);
+                if (pLActionCls != null) {
+                    // 灏嗗鍏ュ璞′笌鈥滃簱涓殑鏈�杩戠殑PLActionCls瀵� 璞♀�漬ame鐩稿悓鐨勫璞�
+                    // 鐨勪笅涓�涓狿LActionCls瀵硅薄鐖秈d鏀逛负搴撲腑鈥滄渶杩戔�漃LActionCls瀵硅薄id
+                    plActionClsList.remove(plActionClsList.size() - 1);
+                    plActionCls2.pid = pLActionCls.id;
+                }else{
+                    if(plActionCls1.name.equals("鏈垎绫�")){
+                        plActionClsList.remove(plActionClsList.size() - 1);
+                        plActionCls2.pid = "";
+                    }else{
+                        plActionCls1.pid = "";
+                    }
+
+                }
+
+            }
+            // 澧炲姞鍒版暣浣搇ist涓敤鏉ユ渶缁堟寔涔呭寲
+            pLActionClsList.addAll(plActionClsList);
+        }
+    }
+
+
+    private void changePLActionOID(PLAction plAction, String oId, String pId, HashMap<String /* newId */, String /* oldId */> actionIdNav) {
+        actionIdNav.put(oId, plAction.plOId);
+        plAction.plOId = oId;
+        plAction.plActionCls = pId;
+    }
+    /***
+     * 鑾峰緱搴撲腑鐨凱LActionCls瀵硅薄锛岀敤鏉ュ珌鎺ュ鍏ユ潵鐨勬爲
+     *
+     * @param
+     * @param plActionClsList
+     * @return
+     */
+    private PLActionCls getParentPLActionClsInDBById(Object plActionClsIdObj,
+                                                     String newPLActionClsId, List<PLActionCls> plActionClsList,
+                                                     HashMap<String /* newId */, String /* oldId */> actionClsIdNav,ExportBeans exportBeans,
+                                                     ArrayList<PLActionCls> optionPLActionClsList, PLActionCls[] pLActionClses) {
+        String pId = null;
+        if (plActionClsIdObj instanceof PLAction) {
+            pId = ((PLAction) plActionClsIdObj).plActionCls;
+            if(pId.equals("")){
+                PLActionCls noneCls = new PLActionCls("", "鏈垎绫�", "", "", "", 0, (short)0);
+                plActionClsList.add(noneCls);
+                return noneCls;
+            }
+        }
+        if (plActionClsIdObj instanceof PLActionCls) {
+            pId = ((PLActionCls) plActionClsIdObj).pid;
+            pId = actionClsIdNav.get(pId);
+            if(pId.equals("")){
+                pId = "null";
+            }
+
+        }
+
+        PLActionCls plActionCls = exportBeans.getPLActionClsBeanById(pId);// 浠庡鍏ュ璞′腑鑾峰緱鐖跺垎绫�
+
+
+        PLActionCls tempPLActionCls = null;
+        if (plActionCls != null) {// plActionCls涓虹┖ 璇佹槑鐖惰妭鐐逛负鏍硅妭鐐�
+
+            plActionClsList.add(plActionCls);
+            if(optionPLActionClsList.contains(plActionCls)){
+                return plActionCls ;
+            }
+            for (PLActionCls Cls : pLActionClses) {
+                if ((plActionCls.id.equals("") && plActionCls.name.trim()
+                        .equals("鏈垎绫�"))
+                        || plActionCls.name.trim().equals(Cls.name.trim())) {
+                    tempPLActionCls = Cls;
+                }
+            }
+            plActionCls.id = newPLActionClsId; // 淇敼鐖跺垎绫籭d
+        } else {
+            return null;
+        }
+
+        if (tempPLActionCls == null) {
+            String newClsId = WebUtil.getSnowflakePk();
+            actionClsIdNav.put(newClsId, plActionCls.pid);
+            plActionCls.pid = newClsId;
+            return getParentPLActionClsInDBById(plActionCls, newClsId,
+                    plActionClsList, actionClsIdNav, exportBeans, optionPLActionClsList, pLActionClses);
+        }
+        return tempPLActionCls;
+    }
+
     /**
      * 澶勭悊瀵煎嚭鐨勫璞�
      * @param actionOid 鐣岄潰閫夋嫨鐨刟ction鍒楄〃鏁版嵁

--
Gitblit v1.9.3