From de42c7075ba5a474ba74d8833e9830dfa1312464 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 28 八月 2024 15:20:17 +0800
Subject: [PATCH] 业务类型查询模板接口上传

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java |  428 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 409 insertions(+), 19 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
index 8f49da8..83fd63d 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsQueryTemplateImpl.java
@@ -3,11 +3,15 @@
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ZipUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.vci.client.ClientSession;
 import com.vci.client.common.oq.OQTool;
+import com.vci.client.common.providers.ClientServiceProvider;
 import com.vci.common.qt.object.*;
 import com.vci.constant.FrameWorkLangCodeConstant;
 import com.vci.corba.common.PLException;
 import com.vci.corba.omd.atm.AttributeDef;
+import com.vci.corba.omd.btm.BizType;
+import com.vci.corba.omd.data.BusinessObject;
 import com.vci.corba.omd.data.LinkObject;
 import com.vci.corba.omd.ltm.LinkType;
 import com.vci.corba.omd.qtm.QTD;
@@ -22,8 +26,10 @@
 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.pagemodel.DataGrid;
 import com.vci.starter.web.pagemodel.Tree;
 import com.vci.starter.web.util.*;
+import com.vci.web.other.BtmQTExportData;
 import com.vci.web.other.LinkQTExportData;
 import com.vci.web.service.*;
 import com.vci.web.util.DateUtil;
@@ -32,17 +38,22 @@
 import com.vci.web.util.WebUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateFormatUtils;
+import org.dom4j.Document;
 import org.dom4j.DocumentException;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
+import org.jdesktop.swingx.JXDatePicker;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
+import javax.swing.*;
+import java.awt.*;
 import java.io.*;
 import java.util.*;
+import java.util.List;
 import java.util.stream.Collectors;
 
 /**
@@ -90,7 +101,7 @@
     }
 
     /**
-     * 鏌ヨ妯℃澘
+     * 淇濆瓨鏌ヨ妯℃澘
      * @param qtd 鏌ヨ妯℃澘瀹炰綋绫�
      * @return 淇濆瓨缁撴灉
      */
@@ -150,8 +161,7 @@
         }
     }
     /**
-     *
-     * @param dataMap 浼犺緭鐨勬暟鎹璞★細
+     * @param qtInfoDTO 浼犺緭鐨勬暟鎹璞★細
      *                linkTypeName 閾炬帴绫诲瀷銆�
      *                rdPositive 鏂瑰悜锛宼rue姝e悜锛宖alse鍙嶅悜
      *                btmName 涓氬姟绫诲瀷鍚嶇О
@@ -163,7 +173,7 @@
      */
     @Override
     public BaseResult getCriteria(QTInfoDTO qtInfoDTO) throws PLException {
-        QueryTemplate qt = getQT(qtInfoDTO);
+        QueryTemplate qt = getQT(qtInfoDTO,true);
         String checkInfo = OQTool.checkQT(qt);
         if(!checkInfo.equals("OK")){
             throw new PLException("500", new String[]{checkInfo});
@@ -189,7 +199,7 @@
             qtInfoDTO.setBtmName(obj.btmName);
             qtInfoDTO.setQtName(obj.qtName);
             qtInfoDTO.setLevelFlag(obj.levelFlag);
-//            qtInfoDTO.setQtText(obj.qtText);
+            //qtInfoDTO.setQtText(obj.qtText);
             qtInfoDTO.setQtUIText(obj.qtUIText);
             if(StringUtils.isNotBlank(obj.qtUIText)){
                 //灏嗙粰瀹氱殑String鏂囨湰瑙f瀽涓篨ML鏂囨。骞惰繑鍥炴柊鍒涘缓鐨刣ocument
@@ -271,7 +281,7 @@
      */
     @Override
     public BaseResult linkSave(QTInfoDTO qtInfoDTO) throws PLException {
-        QueryTemplate qt = getQT(qtInfoDTO);
+        QueryTemplate qt = getQT(qtInfoDTO,true);
         String checkInfo = OQTool.checkQT(qt);
         if(!checkInfo.equals("OK")){
             throw new PLException("500", new String[]{checkInfo});
@@ -415,17 +425,22 @@
      * 缁勮鏌ヨ妯℃澘
      * @return
      */
-    public QueryTemplate getQT(QTInfoDTO qtInfoDTO) throws PLException {
+    public QueryTemplate getQT(QTInfoDTO qtInfoDTO,boolean isLinkType) throws PLException {
         QueryTemplate qt = new QueryTemplate();
-        qt.setType(QTConstants.TYPE_LINK);
-        //TODO String qtId =
-        qt.setLinkType(qtInfoDTO.getBtmName());
-        qt.setDirection(qtInfoDTO.getQueryTemplate().getDirection());
-        qt.setBtmType(qtInfoDTO.getQueryTemplate().getBtmType());
 
-        qt.setVersion(qtInfoDTO.getQueryTemplate().getVersion());
-        qt.setQueryISLeaf(qtInfoDTO.getQueryTemplate().isQueryISLeaf());
-        qt.setLevel(qtInfoDTO.getQueryTemplate().getLevel());
+        if(isLinkType){
+            qt.setType(QTConstants.TYPE_LINK);
+            qt.setLinkType(qtInfoDTO.getBtmName());
+            qt.setDirection(qtInfoDTO.getQueryTemplate().getDirection());
+            qt.setBtmType(qtInfoDTO.getQueryTemplate().getBtmType());
+            qt.setVersion(qtInfoDTO.getQueryTemplate().getVersion());
+            qt.setQueryISLeaf(qtInfoDTO.getQueryTemplate().isQueryISLeaf());
+            qt.setLevel(qtInfoDTO.getQueryTemplate().getLevel());
+        }else{
+            qt.setType(QTConstants.TYPE_BTM);
+            qt.setBtmType(qtInfoDTO.getBtmName());
+        }
+
         List<String> clauseList = new ArrayList<String>();
         //TODO 鏌ヨ鍒� 鏄剧ず鍒�
         clauseList.add("*");
@@ -915,7 +930,6 @@
 //        return qt;
 //    }
 
-
     /**
      * 杩斿洖鏌ヨ鐨勭増鏈�
      * @return
@@ -940,7 +954,6 @@
         return version;
     }
 
-
     /**
      * 鏍¢獙鍙傛暟
      * @param qtd
@@ -957,7 +970,6 @@
             throw new PLException("500", new String[]{"璇ユā鏉垮畾涔夊悕宸茬粡琚娇鐢�, 璇锋洿鎹�"});
         }
     }
-
 
     /**
      * 瀵煎嚭閾炬帴绫诲瀷鏌ヨ妯℃澘
@@ -1143,6 +1155,35 @@
         }
     }
 
+    private void getPLQtBtmItem2(String string, BizType bizType, List<BizType> ltsNew) {
+        // TODO Auto-generated method stub
+        try {
+            BizType queryBizType = platformClientUtil.getBtmService().getBizTypes(string)[0];
+            BizType[] btmArray = platformClientUtil.getBtmService().getBizTypes("");
+            String[] strings = queryBizType.apNameArray;
+            boolean b = true;
+            for (int i = 0; i < btmArray.length; i++) {
+                if (btmArray[i].name.equals(string)) {
+                    b = false;
+                    if (Arrays.equals(bizType.apNameArray, strings)) {
+                        btmArray[i].name += "銆愪笟鍔$被鍨嬪凡瀛樺湪銆�";
+                        ltsNew.add(btmArray[i]);
+                    } else {
+                        btmArray[i].name += "銆愪笟鍔$被鍨嬪瓨鍦ㄤ絾灞炴�т笉涓�鑷淬��";
+                        ltsNew.add(btmArray[i]);
+                    }
+                }
+            }
+            if (b) {
+                bizType.name += "銆愪笟鍔$被鍨嬩笉瀛樺湪銆�";
+                ltsNew.add(bizType);
+            }
+        } catch (PLException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
     private void getPLQtWrapper(String string, QTInfo qtWrapper, List<LinkType> ltsNew, List<QTInfo> qTWrapperNew, Map<String/*绫诲瀷鍚嶇О*/, QTD[]/*鏌ヨ妯℃澘瀹氫箟*/> newNorepQTDs) {
         try {
             QTInfo[] qtws = platformClientUtil.getQTDService().getAllQTs();
@@ -1208,6 +1249,71 @@
         }
     }
 
+    private void getPLBtmQtWrapper(String string, QTInfo qtWrapper, List<BizType> ltsNew, List<QTInfo> qTWrapperNew, Map<String/*绫诲瀷鍚嶇О*/, QTD[]/*鏌ヨ妯℃澘瀹氫箟*/> newNorepQTDs) {
+        try {
+            QTInfo[] qtws = platformClientUtil.getQTDService().getAllQTs();
+            boolean islaet = true;
+            for (int i = 0; i < qtws.length; i++) {
+                if (string.equals(qtws[i].qtName)) {
+                    islaet = false;
+                    for (BizType lt : ltsNew) {
+                        if (qtWrapper.btmName.equals(lt.name.substring(0,
+                                lt.name.indexOf("銆�")))) {
+                            if (lt.name.endsWith("銆愪笟鍔$被鍨嬪凡瀛樺湪銆�")) {
+                                qtWrapper.qtName += "銆愭煡璇㈡ā鏉垮凡瀛樺湪锛屼笉瀵煎叆銆�";
+                                qTWrapperNew.add(qtWrapper);
+                            }else if(lt.name.endsWith("銆愪笟鍔$被鍨嬪瓨鍦ㄤ絾灞炴�т笉涓�鑷淬��")){
+                                qtWrapper.qtName += "銆愭煡璇㈡ā鏉挎墍灞炰笟鍔$被鍨嬪睘鎬т笉涓�鑷达紝涓嶅鍏ャ��";
+                                qTWrapperNew.add(qtWrapper);
+                            }else{
+                                qtWrapper.qtName += "銆愭煡璇㈡ā鏉挎墍灞炰笟鍔$被鍨嬩笉瀛樺湪锛屼笉瀵煎叆銆�";
+                                qTWrapperNew.add(qtWrapper);
+                            }
+                        }
+                    }
+                }
+            }
+            if (islaet) {
+                for (BizType btmItem : ltsNew) {
+                    if (qtWrapper.btmName.equals(btmItem.name.substring(0,
+                            btmItem.name.indexOf("銆�")))) {
+                        if (btmItem.name.endsWith("銆愪笟鍔$被鍨嬪凡瀛樺湪銆�")) {
+                            //鍒ゆ柇鏌ヨ妯℃澘瀹氫箟鏄惁瀛樺湪锛岃繘琛屼繚瀛�
+                            QTD[] qtds = newNorepQTDs.get(qtWrapper.btmName);
+                            if(qtds != null){
+                                for (QTD qtd : qtds) {
+                                    QTD qtdByName = platformClientUtil.getQTDService().getQTDByName(qtd.name);
+                                    if(!(qtdByName != null && StringUtils.isNotBlank(qtdByName.name))){
+                                        boolean b = platformClientUtil.getQTDService().addQTD(qtd);
+                                        if(!b){
+                                            qtWrapper.qtName += qtWrapper.qtName+"瀵煎叆鏌ヨ妯℃澘瀹氫箟銆�" + qtdByName.name + "銆戝け璐ワ紒";
+                                        }
+                                    }
+                                }
+                                newNorepQTDs.remove(qtWrapper.btmName);
+                            }
+                            boolean success = platformClientUtil.getQTDService().saveQT(qtWrapper);
+                            if(!success){
+                                qtWrapper.qtName += qtWrapper.qtName+"瀵煎叆澶辫触锛�";
+                            }else {
+                                qtWrapper.qtName += "銆愭煡璇㈡ā鏉垮鍏ユ垚鍔燂紒銆�";
+                            }
+                            qTWrapperNew.add(qtWrapper);
+                        }else if(btmItem.name.endsWith("銆愪笟鍔$被鍨嬪瓨鍦ㄤ絾灞炴�т笉涓�鑷淬��")){
+                            qtWrapper.qtName += "銆愭煡璇㈡ā鏉挎墍灞炰笟鍔$被鍨嬪睘鎬т笉涓�鑷达紝涓嶅鍏ャ��";
+                            qTWrapperNew.add(qtWrapper);
+                        }else{
+                            qtWrapper.qtName += "銆愭煡璇㈡ā鏉挎墍灞炰笟鍔$被鍨嬩笉瀛樺湪锛屼笉瀵煎叆銆�";
+                            qTWrapperNew.add(qtWrapper);
+                        }
+                    }
+                }
+            }
+        } catch (PLException e) {
+            e.printStackTrace();
+        }
+    }
+
     //鏍规嵁閫夋嫨鐨勬煡璇㈡ā鏉胯繃婊ゆā鏉垮畾涔�
     private Map<String, QTD[]> getnewNorepQTDs(Map<String, QTD[]> norepQTDs,
                                                Map<String, QTInfo> allQTs) {
@@ -1235,6 +1341,290 @@
         if(!b){
             return BaseResult.fail("鍒犻櫎澶辫触锛侊紒锛�");
         }
-        return BaseResult.success();
+        return BaseResult.success("鏌ヨ妯℃澘鍒犻櫎鎴愬姛锛�");
     }
+
+    /**
+     * @param qtInfoDTO 浼犺緭鐨勬暟鎹璞★細
+     *                linkTypeName 閾炬帴绫诲瀷銆�
+     *                rdPositive 鏂瑰悜锛宼rue姝e悜锛宖alse鍙嶅悜
+     *                btmName 涓氬姟绫诲瀷鍚嶇О
+     *                combRelaType 涓氬姟绫诲瀷閫夋嫨鍊�
+     *                versionValue 鐗堟湰鐝鍊�
+     *                isQueryIsLeaf 鏄惁閫夋嫨涓嬬骇
+     *                level 瀛愯妭鐐瑰眰鏁�
+     * @return 鏌ヨ缁撴灉
+     */
+    @Override
+    public BaseResult getCriteriaBtm(QTInfoDTO qtInfoDTO) throws PLException {
+        QueryTemplate qt = getQT(qtInfoDTO,false);
+        String checkInfo = OQTool.checkQT(qt);
+        if(!checkInfo.equals("OK")){
+            throw new PLException("500", new String[]{checkInfo});
+        }
+        qt.setId("qt1");
+        BusinessObject[] result = platformClientUtil.getQueryService().findBTMObjects(qt.getId(), OQTool.qtTOXMl(qt).asXML());
+        return BaseResult.dataList(Arrays.asList(result));
+    }
+
+    /**
+     * 涓氬姟绫诲瀷鏌ヨ妯℃澘淇濆瓨
+     * @param qtInfoDTO 淇濆瓨浼犺緭瀵硅薄
+     * @return 淇濆瓨缁撴灉
+     */
+    @Override
+    public BaseResult btmSave(QTInfoDTO qtInfoDTO) throws PLException {
+        VciBaseUtil.alertNotNull(
+                qtInfoDTO,"淇濆瓨鐨勪笟鍔$被鍨嬫ā鏉垮璞�",
+                qtInfoDTO.getBtmName(),"璇烽�夋嫨涓氬姟绫诲瀷鍜屾煡璇㈡ā鏉垮畾涔夋潵鍒涘缓鏌ヨ妯℃澘"
+        );
+
+        //add by caill start 閬嶅巻鏅�氭煡璇㈡ā鏉胯緭鍏ユ涓殑鍊煎仛鏍¢獙
+        //		ArrayList<String> list = cpm_centerPanel.getList();
+        //		for(int i=0;i<list.size();i++){
+        //			String text = (String) list.get(i);
+        //			if(text.contains("'")){
+        //				JOptionPane.showMessageDialog(cp_mainPanel, "鏉′欢鍊间腑鍖呭惈浜嗛潪娉曞瓧绗�", "闈炴硶瀛楃", JOptionPane.ERROR_MESSAGE);
+        //				return;
+        //			}
+        //		}
+        //淇濆瓨涔嬪墠甯﹀嚭宸查�夋嫨鐨剄tName
+        QueryTemplate qt = getQT(qtInfoDTO,false);
+        //鍓嶇璋冪敤杩欎釜鏂规硶isExistsQT()
+        /*if(isExists(qtName)){
+            return BaseResult.success("","璇ユ煡璇㈡ā鏉垮悕宸茬粡瀛樺湪,鏄惁瑕嗙洊锛�");
+        }*/
+        String checkInfo = OQTool.checkQT(qt);
+        if(!checkInfo.equals("OK")){
+            throw new PLException("500", new String[]{checkInfo});
+        }
+        //璁剧疆鎺掑簭淇℃伅
+        qt.setOrderInfoList(qtInfoDTO.getQueryTemplate().getOrderInfoList());
+        QTInfo qtWrapper = new QTInfo();
+        qtWrapper.qtName = qtInfoDTO.getQtName();
+        qtWrapper.btmName = qt.getBtmType();
+        qtWrapper.creator = WebUtil.getCurrentUserId();
+        qtWrapper.createTime = System.currentTimeMillis();
+        if(qtInfoDTO.getTree() == null){
+            qtWrapper.qtUIText = "";
+        }else{
+            //褰撳嬀閫変簡楂樼骇鏌ヨ鏃堕渶瑕佸鐞嗛珮绾ф煡璇㈢殑鐩稿叧鏉′欢
+            qtWrapper.qtUIText = getSeniorXML(qtInfoDTO);
+        }
+        qtWrapper.levelFlag = qtInfoDTO.getLevelFlag();
+        qtWrapper.qtText = OQTool.qtTOXMl(qt).asXML();
+        boolean saveFlag = platformClientUtil.getQTDService().saveQT(qtWrapper);
+        if(saveFlag){
+            return BaseResult.success("淇濆瓨鏌ヨ妯℃澘鎴愬姛");
+        }else{
+            return BaseResult.fail("淇濆瓨鏌ヨ妯℃澘澶辫触");
+        }
+    }
+
+    /**
+     * 鏇存柊鏁版嵁搴撶粨鏋�
+     * @return 淇濆瓨缁撴灉
+     */
+    @Override
+    public BaseResult updateDBStructure() throws PLException {
+        boolean f = platformClientUtil.getQTDService().updateQT();
+        if(f){
+            return BaseResult.success("鏇存柊鎴愬姛");
+        }else{
+            return BaseResult.fail("鏇存柊澶辫触");
+        }
+    }
+
+    /**
+     * 涓氬姟绫诲瀷鏌ヨ妯℃澘鏍戞煡璇紝鐢ㄤ簬鐣岄潰鐨勫鍑哄姛鑳�
+     * @return 鏌ヨ缁撴灉
+     */
+    @Override
+    public BaseResult getBtmQtTree() throws PLException {
+        BizType[] bizTypes= null;
+        QTInfo[] qts = null;
+        HashMap<String,Object> tree = new HashMap();
+        tree.put("text","涓氬姟绫诲瀷");
+        if (bizTypes == null) {
+            List<BizType> es = new ArrayList<>();
+            bizTypes = platformClientUtil.getBtmService().getBizTypes("");
+            for (BizType lt : bizTypes) {
+                QTInfo[] qtWrappers = platformClientUtil.getQTDService().getObjTypeQTs(lt.name);
+                if (qtWrappers.length!=0) {
+                    es.add(lt);
+                }
+            }
+            bizTypes = es.toArray(new BizType[es.size()]);
+            //TODO:闇�淇娌℃湁鍏宠仈鏌ヨ妯℃澘涓氬姟绫诲瀷鍘绘帀
+            qts = platformClientUtil.getQTDService().getAllQTs();//鑾峰彇鎵�鏈夋煡璇㈡ā鏉�
+        }
+        List<HashMap<String,Object>> childList = new ArrayList<>();
+        //娣诲姞涓氬姟绫诲瀷鏍硅妭鐐�
+        for (BizType plAction : bizTypes) {
+            HashMap<String,Object> childTree = new HashMap();
+            childTree.put("text", plAction.label + "/" +plAction.name);
+            childTree.put("oid", plAction.oid);
+            //tree.put("children", childTree);
+            addExportTreeNode(plAction, qts, childTree);
+            childList.add(childTree);
+        }
+        tree.put("children", childList);
+        return BaseResult.success(tree);
+    }
+
+    /**
+     * 瀵煎嚭涓氬姟绫诲瀷鏌ヨ妯℃澘
+     * names 鏌ヨ妯℃澘鍚�
+     * @return
+     */
+    @Override
+    public void expBtmQTTemplate(List<String> names, HttpServletResponse response) throws PLException, IOException {
+        String defaultTempFolder = LocalFileUtil.getDefaultTempFolder();
+        String vciqtmfFileName = defaultTempFolder + File.separator + "BtmTemplateExp" + new Date().getTime() + ".vciqtf";
+        BtmQTExportData exportData = new BtmQTExportData();
+        for (String name : names) {
+            QTInfo qt = platformClientUtil.getQTDService().getQT(name);
+            exportData.getAllQTs().put(qt.qtName,qt);
+            BizType[] bizTypes = platformClientUtil.getBtmService().getBizTypes(qt.btmName);
+            for (int i = 0; i < bizTypes.length; i++) {
+                BizType bizType = bizTypes[i];
+                if(bizTypes != null && !bizType.oid.equals("")){
+                    exportData.getSelectedBtmItems().put(bizType.name, bizType);
+                    exportData.getSelectedBtmAttrs().put(bizType.name, bizType.apNameArray);
+                    exportData.getAllQTDs().put(bizType.name, platformClientUtil.getQTDService().getBizTypeQTDs(bizType.name));
+                }
+            }
+        }
+        ObjectOutputStream vciamfFileStream = null;
+        try {
+            File vciqtmfFile = new File(vciqtmfFileName);
+            vciamfFileStream = new ObjectOutputStream(new FileOutputStream(vciqtmfFile));
+            vciamfFileStream.writeObject(exportData);
+        }finally {
+            try {
+                if (vciamfFileStream != null) {
+                    vciamfFileStream.flush();
+                    vciamfFileStream.close();
+                }
+            } catch (Exception e) {
+                throw new PLException("500",new String[]{"瀵煎嚭娴佸叧闂紓甯革紒"});
+            }
+        }
+        ControllerUtil.writeFileToResponse(response,vciqtmfFileName);
+        FileUtil.del(defaultTempFolder + File.separator);
+    }
+
+    /**
+     * 鏌ヨ鏉′欢涓嬬殑閫夋嫨鏌ヨ妯℃澘瀵硅瘽妗嗭紙鏌ヨ鍏ㄩ儴妯℃澘鍜屾墍瀵瑰簲鐨勪笟鍔$被鍨嬫垨閾炬帴绫诲瀷鍚嶏級
+     * @return
+     */
+    @Override
+    public BaseResult getAllQTs() throws PLException {
+        QTInfo[] allQTs = platformClientUtil.getQTDService().getAllQTs();
+        DataGrid<QTInfo> dataGrid = new DataGrid<>();
+        dataGrid.setData(Arrays.asList(allQTs));
+        dataGrid.setTotal(allQTs.length);
+        return BaseResult.dataGrid(dataGrid);
+    }
+
+    /**
+     * 瀵煎叆涓氬姟绫诲瀷鏌ヨ妯℃澘
+     * @param file 涓婁紶鐨勬枃浠�
+     * @return 瀵煎叆缁撴灉
+     */
+    @Override
+    public BaseResult impBtmTemplate(MultipartFile file) throws IOException, ClassNotFoundException {
+        if (file == null) {
+            return BaseResult.fail(FrameWorkLangCodeConstant.IMPORT_FAIL, new String[]{"鏃犲鍏ョ殑鏂囦欢"});
+        }
+        if (!file.getOriginalFilename().endsWith(".vciqtf")) {
+            throw new VciBaseException("浠呰兘涓婁紶.vciqtf鏍煎紡鏂囦欢锛岃閲嶆柊涓婁紶锛�");
+        }
+        ObjectInputStream obj = new ObjectInputStream(
+                file.getInputStream());
+        BtmQTExportData qtExportData = (BtmQTExportData) obj.readObject();
+        List<BizType> ltsNew = new ArrayList<>();
+        List<QTInfo> qTWrapperNew = new ArrayList<>();
+        Map<String/* 绫诲瀷鍚嶇О */, QTD[]/* 鏌ヨ妯℃澘瀹氫箟 */> norepQTDs = new HashMap<String, QTD[]>();
+        addImportBtmData(qtExportData, ltsNew, qTWrapperNew, norepQTDs);
+        QTInfo[] qts = qTWrapperNew
+                .toArray(new QTInfo[qTWrapperNew.size()]);
+        //澶勭悊鏍戠殑杩斿洖
+        HashMap<String,Object> tree = new HashMap();
+        tree.put("text","涓氬姟绫诲瀷");
+        List<HashMap<String,Object>> childList = new ArrayList<>();
+        //娣诲姞涓氬姟绫诲瀷鏍硅妭鐐�
+        for (BizType plAction : ltsNew) {
+            HashMap<String,Object> childTree = new HashMap();
+            childTree.put("text", plAction.label + "/" +plAction.name);
+            childTree.put("oid", plAction.oid);
+            addExportTreeNode(plAction, qts, childTree);
+            childList.add(childTree);
+        }
+        tree.put("children", childList);
+        return BaseResult.success(tree);
+    }
+
+    // 鏁版嵁杩囨护
+    private void addImportBtmData(BtmQTExportData qtExportData, List<BizType> ltsNew, List<QTInfo> qTWrapperNew,
+                               Map<String/* 绫诲瀷鍚嶇О */, QTD[]/* 鏌ヨ妯℃澘瀹氫箟 */> norepQTDs) {
+        Map<String/* 绫诲瀷鍚嶇О */, QTD[]/* 鏌ヨ妯℃澘瀹氫箟 */> allQTDs = qtExportData
+                .getAllQTDs();
+        Map<String/* 绫诲瀷鍚嶇О */, BizType/* 绫诲瀷瀵硅薄 */> selectedBtmItems = qtExportData
+                .getSelectedBtmItems();
+        Map<String/* 绫诲瀷鍚嶇О */, String[]/* 绫诲瀷鎵�灞炲睘鎬� */> selectedBtmAttrs = qtExportData
+                .getSelectedBtmAttrs();
+        Map<String/* 鏌ヨ妯℃澘鍚嶇О */, QTInfo/* 鏌ヨ妯℃澘瀵硅薄 */> allSelectedQTs = qtExportData
+                .getAllQTs();
+        if (allQTDs.size() == 0 || allQTDs == null
+                || selectedBtmItems.size() == 0 || selectedBtmItems == null
+                || selectedBtmAttrs.size() == 0 || selectedBtmAttrs == null
+                || allSelectedQTs.size() == 0 || allSelectedQTs == null) {
+            throw new VciBaseException("瀵煎叆鐨勬ā鏉挎暟鎹湁璇�!!!");
+        }
+        Set<Map.Entry<String, QTD[]>> pLActions = allQTDs.entrySet();
+        Set<Map.Entry<String, QTInfo>> pLQts = allSelectedQTs.entrySet();
+        Set<Map.Entry<String, BizType>> btmpLQts = selectedBtmItems.entrySet();
+        for (Map.Entry<String, QTD[]> entry : pLActions) {
+            String string = entry.getKey();
+            QTD[] qtds = entry.getValue();
+            getPLQtIsInDB(string, qtds, norepQTDs);
+        }
+        for (Map.Entry<String, BizType> entry : btmpLQts) {
+            String string = entry.getKey();
+            BizType bizType = entry.getValue();
+            getPLQtBtmItem2(string, bizType, ltsNew);
+        }
+        Map<String/*绫诲瀷鍚嶇О*/, QTD[]/*鏌ヨ妯℃澘瀹氫箟*/> newNorepQTDs = getnewNorepQTDs(norepQTDs,allSelectedQTs);
+        for (Map.Entry<String, QTInfo> entry : pLQts) {
+            String string = entry.getKey();
+            QTInfo qtWrapper = entry.getValue();
+            getPLBtmQtWrapper(string, qtWrapper, ltsNew, qTWrapperNew, newNorepQTDs);
+        }
+
+    }
+
+    /**
+     * 鐢熸垚瀵煎嚭鏍戦�夋嫨浠ュ強瀵煎叆鏍戞樉绀�
+     * @param bizType
+     * @param qts
+     * @param tree
+     */
+    private void addExportTreeNode(BizType bizType/*涓氬姟绫诲瀷*/,QTInfo[] qts/*鏌ヨ妯℃澘瀵硅薄*/,HashMap<String,Object> tree) {
+        List<String> childList = new ArrayList<>();
+        // 娣诲姞鏌ヨ妯℃澘瀵硅薄瀛愯妭鐐�
+        for (QTInfo qtItem : qts) {
+            //澶勭悊瀵煎叆鏃舵棤娉曡繘琛岀被鍨嬪垽鏂�
+            int splitLength = bizType.name.indexOf("銆�");
+            if(splitLength == -1){
+                splitLength = bizType.name.length();
+            }
+            if (qtItem.btmName.equals(bizType.name.substring(0,
+                    splitLength))) {
+                childList.add(qtItem.qtName);
+            }
+        }
+        tree.put("children",childList);
+    }
+
 }

--
Gitblit v1.9.3