wuxw 3 anni fa
parent
commit
0edc442f5e

+ 20 - 1
java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java

@@ -351,11 +351,30 @@ public class QueryServiceSMOImpl extends LoggerEngine implements IQueryServiceSM
     public JSONObject execJava(JSONObject params, String javaCode) throws BusinessException {
         try {
             //JSONObject params = dataQuery.getRequestParams();
+            List<String> columns = new ArrayList<>();
             Interpreter interpreter = new Interpreter();
             interpreter.eval(javaCode);
             interpreter.set("params", params.toJSONString());
             interpreter.set("queryServiceDAOImpl",queryServiceDAOImpl);
-            return JSONObject.parseObject(interpreter.eval("execute(params,queryServiceDAOImpl)").toString());
+            JSONObject results = JSONObject.parseObject(interpreter.eval("execute(params,queryServiceDAOImpl)").toString());
+
+            JSONArray data = null;
+            if (results == null || results.size() < 1) {
+                data = new JSONArray();
+            } else {
+                data = results.getJSONArray("data");
+            }
+
+            JSONArray th = new JSONArray();
+            for (String key : data.getJSONObject(0).keySet()) {
+                th.add(key);
+            }
+            JSONObject paramOut = new JSONObject();
+            paramOut.put("th", th);
+            paramOut.put("td", data);
+            paramOut.put("total",results.getString("total"));
+
+            return paramOut;
         } catch (Exception e) {
             logger.error("数据交互异常:", e);
             throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR, "数据交互异常," + e.getMessage());

+ 10 - 21
service-report/src/main/java/com/java110/report/bmo/customReport/InspectionStaffData.java

@@ -27,13 +27,9 @@ public class InspectionStaffData implements ReportExecute {
 
     }
 
-    public JSONObject execute(String paramStr, IQueryServiceDAO queryServiceDAOImpl) {
-
-        JSONObject params = JSONObject.parseObject(paramStr);
-
+    public String execute(String paramStr, IQueryServiceDAO queryServiceDAOImpl) {
         JSONObject paramOut = new JSONObject();
-        JSONArray th = new JSONArray();
-        th.add("员工");
+        JSONObject params = JSONObject.parseObject(paramStr);
 
         List sqlParams = new ArrayList();
         String sql = "select \n" +
@@ -98,15 +94,15 @@ public class InspectionStaffData implements ReportExecute {
         List datas = queryServiceDAOImpl.executeSql(sql, sqlParams.toArray());
 
         if (datas == null || datas.size() < 1) {
-            paramOut.put("td", new JSONArray());
-
-            return paramOut;
+            paramOut.put("toatl",1);
+            paramOut.put("data",new JSONArray());
+            return paramOut.toJSONString();
         }
 
         JSONArray tds = new JSONArray();
         JSONObject td = null;
-        for (int dataIndex = 0 ; dataIndex < datas.size() ; dataIndex ++ ){
-            Map dataObj = (Map)datas.get(dataIndex);
+        for (int dataIndex = 0; dataIndex < datas.size(); dataIndex++) {
+            Map dataObj = (Map) datas.get(dataIndex);
             td = hasInTd(tds, dataObj);
 
             if (td == null) {
@@ -119,17 +115,10 @@ public class InspectionStaffData implements ReportExecute {
             td.put("状态", dataObj.get("状态"));
         }
 
-        for (String key : tds.getJSONObject(0).keySet()) {
-            if ("员工".equals(key)) {
-                continue;
-            }
-            th.add(key);
-        }
-
+        paramOut.put("total",params.get("row"));
+        paramOut.put("data",tds);
 
-        paramOut.put("th", th);
-        paramOut.put("td", tds);
-        return paramOut;
+        return paramOut.toJSONString();
     }
 
 

+ 1 - 1
service-report/src/main/java/com/java110/report/bmo/customReport/ReportExecute.java

@@ -6,5 +6,5 @@ import com.java110.service.context.DataQuery;
 
 public interface ReportExecute {
 
-    JSONObject execute(String params,IQueryServiceDAO queryServiceDAOImpl);
+    String execute(String params,IQueryServiceDAO queryServiceDAOImpl);
 }