wuxw
2022-05-11 bb735e0400ffe2be078614a409f977434f4558ee
优化 报表配置 Java 配置bug
1个文件已修改
2个文件已添加
147 ■■■■■ 已修改文件
java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/bmo/customReport/InspectionStaffData.java 134 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-report/src/main/java/com/java110/report/bmo/customReport/ReportExecute.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
java110-service/src/main/java/com/java110/service/smo/impl/QueryServiceSMOImpl.java
@@ -354,7 +354,8 @@
            Interpreter interpreter = new Interpreter();
            interpreter.eval(javaCode);
            interpreter.set("params", params);
            return JSONObject.parseObject(interpreter.eval("execute(dataQuery)").toString());
            interpreter.set("queryServiceDAOImpl",queryServiceDAOImpl);
            return JSONObject.parseObject(interpreter.eval("execute(params,queryServiceDAOImpl)").toString());
        } catch (Exception e) {
            logger.error("数据交互异常:", e);
            throw new BusinessException(ResponseConstant.RESULT_CODE_INNER_ERROR, "数据交互异常," + e.getMessage());
service-report/src/main/java/com/java110/report/bmo/customReport/InspectionStaffData.java
New file
@@ -0,0 +1,134 @@
package com.java110.report.bmo.customReport;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.db.dao.IQueryServiceDAO;
import com.java110.utils.util.DateUtil;
import org.apache.commons.lang.StringUtils;
import java.util.*;
public class InspectionStaffData implements ReportExecute {
    public JSONObject hasInTd(JSONArray tds, Map<String, Object> dataObj) {
        if (tds == null || tds.size() < 1) {
            return null;
        }
        for (int tdIndex = 0; tdIndex < tds.size(); tdIndex++) {
            if (tds.getJSONObject(tdIndex).getString("员工").equals(dataObj.get("员工"))) {
                return tds.getJSONObject(tdIndex);
            }
        }
        return null;
    }
    @Override
    public JSONObject execute(JSONObject params, IQueryServiceDAO queryServiceDAOImpl) {
        JSONObject paramOut = new JSONObject();
        JSONArray th = new JSONArray();
        th.add("员工");
        List sqlParams = new ArrayList();
        String sql = "select \n" +
                "t.staff_name '员工',\n" +
                "ipo.inspection_name '巡检点',\n" +
                "(select count(1) from inspection_task it \n" +
                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
                "and itd.act_user_id is not null\n" +
                "and it.create_time > ?\n" +
                "and it.create_time < ?\n" +
                ") '已巡检',\n" +
                "(select count(1) from inspection_task it \n" +
                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
                "and itd.act_user_id is null\n" +
                "and it.create_time > ?\n" +
                "and it.create_time < ?\n" +
                ") '未巡检',\n" +
                "(select itd.description from inspection_task it \n" +
                "INNER JOIN inspection_task_detail itd on it.task_id = itd.task_id and itd.status_cd = '0'\n" +
                "where it.inspection_plan_id = ip.inspection_plan_id\n" +
                "and itd.inspection_id = ipo.inspection_id and it.plan_user_id = t.staff_id\n" +
                "and itd.act_user_id is not null\n" +
                "and it.create_time > ?\n" +
                "and it.create_time < ?\n" +
                "limit 1\n" +
                ") '状态'\n" +
                "from inspection_plan_staff t\n" +
                "left join inspection_plan ip on t.inspection_plan_id = ip.inspection_plan_id and ip.status_cd = '0'\n" +
                "left join inspection_route_point_rel irpr on ip.inspection_route_id = irpr.inspection_route_id and irpr.status_cd= '0'\n" +
                "left join inspection_point ipo on irpr.inspection_id = ipo.inspection_id and ipo.status_cd = '0'\n" +
                "where 1=1 and t.status_cd = '0'\n";
        if (params.containsKey("startTime") && !StringUtils.isEmpty(params.getString("startTime"))) {
            sqlParams.add(params.get("startTime"));
            sqlParams.add(params.get("endTime"));
            sqlParams.add(params.get("startTime"));
            sqlParams.add(params.get("endTime"));
            sqlParams.add(params.get("startTime"));
            sqlParams.add(params.get("endTime"));
        } else {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DAY_OF_YEAR, 1);
            String tomorrow = DateUtil.getFormatTimeString(calendar.getTime(), DateUtil.DATE_FORMATE_STRING_B);
            sqlParams.add(DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
            sqlParams.add(tomorrow);
            sqlParams.add(DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
            sqlParams.add(tomorrow);
            sqlParams.add(DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_B));
            sqlParams.add(tomorrow);
        }
        if (params.containsKey("communityId") && !StringUtils.isEmpty(params.getString("communityId"))) {
            sql += "and t.`community_id` = ? ";
            sqlParams.add(params.get("communityId"));
        }
        sql += "GROUP BY t.staff_name ,ipo.inspection_name";
        List<Map<String, Object>> datas = queryServiceDAOImpl.executeSql(sql, sqlParams.toArray());
        if (datas == null || datas.size() < 1) {
            paramOut.put("td", new JSONArray());
            return paramOut;
        }
        JSONArray tds = new JSONArray();
        JSONObject td = null;
        for (Map<String, Object> dataObj : datas) {
            td = hasInTd(tds, dataObj);
            if (td == null) {
                td = new JSONObject();
                td.put("员工", dataObj.get("员工"));
                tds.add(td);
            }
            td.put(dataObj.get("巡检点").toString(), dataObj.get("已巡检") + "/" + dataObj.get("未巡检"));
            td.put("状态", dataObj.get("状态"));
        }
        for (String key : tds.getJSONObject(0).keySet()) {
            if ("员工".equals(key)) {
                continue;
            }
            th.add(key);
        }
        paramOut.put("th", th);
        paramOut.put("td", tds);
        return paramOut;
    }
}
service-report/src/main/java/com/java110/report/bmo/customReport/ReportExecute.java
New file
@@ -0,0 +1,10 @@
package com.java110.report.bmo.customReport;
import com.alibaba.fastjson.JSONObject;
import com.java110.db.dao.IQueryServiceDAO;
import com.java110.service.context.DataQuery;
public interface ReportExecute {
    JSONObject execute(JSONObject params,IQueryServiceDAO queryServiceDAOImpl);
}