From 83c80c4be845c6ddb5f1385201e74289d0262598 Mon Sep 17 00:00:00 2001
From: wuxw7 <wuxw7@asiainfo.com>
Date: 星期三, 09 五月 2018 22:39:55 +0800
Subject: [PATCH] 完成 配置方式 页面数据显示

---
 ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java |  122 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java b/ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java
index 027706a..f87bb90 100644
--- a/ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java
+++ b/ConsoleService/src/main/java/com/java110/console/smo/impl/ConsoleServiceSMOImpl.java
@@ -14,6 +14,7 @@
 import com.java110.common.factory.DataTransactionFactory;
 import com.java110.common.log.LoggerEngine;
 import com.java110.common.util.Assert;
+import com.java110.common.util.StringUtil;
 import com.java110.console.smo.IConsoleServiceSMO;
 import com.java110.entity.service.PageData;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -118,20 +119,56 @@
         Map paramIn = new HashMap();
         paramIn.put("templateCode", templateCode);
         paramIn.put(CommonConstant.ORDER_USER_ID,pd.getUserId());
-        paramIn.put(ServiceCodeConstant.SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE);
-        paramIn.put(ServiceCodeConstant.SERVICE_CODE_NAME,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE_NAME);
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE_COL);
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE_NAME,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE_COL_NAME);
         //paramIn.put("userPwd", userPwd);
         JSONObject businessObj = doExecute(paramIn);
 
         Assert.isNotNull(businessObj,"template","鏌ヨ妯℃澘 鏈嶅姟閰嶇疆閿欒锛岃繑鍥炴姤鏂囦腑鏈寘鍚玹emplate鑺傜偣");
 
+        removeButtonName(businessObj);
 
         JSONObject templateObj = new JSONObject();
+
+        paramColModelToJson(businessObj.getJSONArray("template"));
+
         templateObj.put("template",businessObj.getJSONArray("template"));
 
         pd.setResJson(DataTransactionFactory.pageResponseJson(pd.getTransactionId(),ResponseConstant.RESULT_CODE_SUCCESS,"鏌ヨ鎴愬姛 ",templateObj));
 
+    }
 
+    /**
+     *  colModel 瀛楁澶勭悊
+     * @param jsonArray
+     * @throws SMOException
+     */
+    private void paramColModelToJson(JSONArray jsonArray) throws SMOException{
+        if(jsonArray == null || jsonArray.size() == 0){
+            return ;
+        }
+        try {
+            for(int arrIndex = 0; arrIndex < jsonArray.size();arrIndex ++){
+                JSONObject tObj = jsonArray.getJSONObject(arrIndex);
+                tObj.put("colModel",JSONObject.parse(tObj.getString("colModel")));
+            }
+        }catch (Exception e){
+            logger.error("c_template_col 琛� colModel 閰嶇疆閿欒",e);
+            throw new SMOException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"colModel 閰嶇疆閿欒");
+        }
+    }
+
+    /**
+     * 鍒犻櫎BUTTON 瀛楁 鍊�
+     * @param jsonObject
+     */
+    private void removeButtonName(JSONObject jsonObject){
+        JSONArray template = jsonObject.getJSONArray("template");
+        for(int colIndex = 0 ; colIndex < template.size() ; colIndex ++){
+            if(CommonConstant.TEMPLATE_COLUMN_NAME_BUTTON.equals(template.getJSONObject(colIndex).getString("colName"))){
+                template.getJSONObject(colIndex).put("colName","");
+            }
+        }
     }
 
     private JSONObject doExecute(Map paramIn) {
@@ -187,6 +224,87 @@
     }
 
 
+    /**
+     * 鑾峰彇妯℃澘
+     * @param pd
+     * @return
+     * @throws SMOException
+     */
+    public void getTemplate(PageData pd) throws SMOException{
+        String templateCode = pd.getParam().getString("templateCode");
+
+        Assert.hasText(templateCode,"妯℃澘缂栫爜涓嶈兘涓虹┖");
+
+        Map paramIn = new HashMap();
+        paramIn.put("templateCode", templateCode);
+        paramIn.put(CommonConstant.ORDER_USER_ID,pd.getUserId());
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE);
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE_NAME,ServiceCodeConstant.SERVICE_CODE_QUERY_CONSOLE_TEMPLATE_NAME);
+        //paramIn.put("userPwd", userPwd);
+        JSONObject businessObj = doExecute(paramIn);
+
+        Assert.isNotNull(businessObj,"template","鏌ヨ妯℃澘 鏈嶅姟閰嶇疆閿欒锛岃繑鍥炴姤鏂囦腑鏈寘鍚玹emplate鑺傜偣");
+
+
+        JSONObject templateObj = new JSONObject();
+        templateObj.put("template",businessObj.getJSONObject("template"));
+        pd.setData(templateObj);
+        pd.setResJson(DataTransactionFactory.pageResponseJson(pd.getTransactionId(),ResponseConstant.RESULT_CODE_SUCCESS,"鏌ヨ鎴愬姛 ",templateObj));
+
+    }
+
+    /**
+     * 鏌ヨ妯℃澘鏁版嵁
+     * @param pd
+     * @throws SMOException
+     */
+    public void getTemplateData(PageData pd) throws SMOException{
+
+        //鏌ヨ妯℃澘淇℃伅
+        getTemplate(pd);
+        JSONObject template = pd.getData().getJSONObject("template");
+        String rows = pd.getParam().getString("rows");
+        String page = pd.getParam().getString("page");
+        String sord = pd.getParam().getString("sord");
+        String templateUrl = template.getString("templateUrl");
+        if(StringUtil.isNullOrNone(templateUrl) || !templateUrl.contains(CommonConstant.TEMPLATE_URL_LIST)){
+            throw new SMOException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"閰嶇疆閿欒锛屾ā鏉夸腑涓洪厤缃煡璇㈡暟鎹殑鍦板潃");
+        }
+
+        Map paramIn = new HashMap();
+
+        paramIn.put("rows", rows);
+        paramIn.put("page", page);
+        paramIn.put("sord", sord);
+        paramIn.put(CommonConstant.ORDER_USER_ID,pd.getUserId());
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE,getServiceCode(templateUrl,CommonConstant.TEMPLATE_URL_LIST));
+        paramIn.put(ServiceCodeConstant.SERVICE_CODE_NAME,"鏁版嵁鏌ヨ");
+        //paramIn.put("userPwd", userPwd);
+        JSONObject businessObj = doExecute(paramIn);
+
+        pd.setResJson(businessObj);
+    }
+
+    /**
+     * 鑾峰彇serviceCode
+     * @param templateUrl
+     * @param model
+     * @return
+     * @throws SMOException
+     */
+    private String getServiceCode(String templateUrl,String model) throws SMOException{
+        String [] tUrls = templateUrl.split(CommonConstant.TEMPLATE_URL_SPILT);
+        for(String url : tUrls){
+            if(url.contains(model)){
+                return url.substring(model.length());
+            }
+        }
+
+        throw new SMOException(ResponseConstant.RESULT_CODE_CONFIG_ERROR,"閰嶇疆閿欒锛屾ā鏉夸腑涓洪厤缃甗"+model+"]鏁版嵁鐨勫湴鍧�");
+    }
+
+
+
     public RestTemplate getRestTemplate() {
         return restTemplate;
     }

--
Gitblit v1.8.0