多单位版国产化地质资料管理系统
zs
2026-02-04 2b543ca35ad4697e31225829be13e375cd2b0259
src/main/java/com/zbooksoft/gdmis/controller/UtlStatisticsController.java
@@ -86,14 +86,15 @@
    @RequestMapping(value = "/transferStatistics")
    @RequiresUser
    public ModelAndView transferStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/transferStatistics");
//        ModelAndView mav = new ModelAndView("gh/utlStatistics/transferStatistics");
        ModelAndView mav = new ModelAndView("gh/utlStatistics/cs");
        return mav;
    }
    @RequestMapping({"/getTransferStatistics"})
    @ResponseBody
    @RequiresUser
    public Object getTransferStatistics(String year, String startData, String endData) {
    public Object getTransferStatistics(String selectParameter, String startData, String endData) {
        try {
            String sql = "SELECT " +
                    "    A.ID," +
@@ -103,12 +104,17 @@
                    "    COUNT(CASE WHEN C.yszt = '3' THEN C.ID END) AS tidyCount," +
                    "    COUNT(CASE WHEN C.yszt = '3' THEN C.ID END) AS acceptCount," +
                    "    SUM(C.WJDX) AS acceptData," +
                    "    COUNT(CASE WHEN D.is_pass = 0 THEN D.id END) AS returnTime" +
                    "    COUNT(CASE WHEN D.is_pass = 0 THEN D.id END) AS returnTime," +
                    "    SUM(C.YM) AS YM," +
                    "    SUM(C.SL) AS SL" +
                    " FROM CAT_FILE_AJJXX A" +
                    " LEFT JOIN BUS_TRANSFER_LOG B ON A.ID = B.AJ_ID" +
                    " LEFT JOIN CAT_ITEM_YSWJXX C ON A.ID = C.AJ_ID" +
                    " LEFT JOIN CAT_CHECK_INFO D ON A.ID = D.aj_id" +
                    " WHERE 1=1 ";
            if (selectParameter.equals("rk")){
                sql += " AND C.YSZT=3 ";
            }
            // 添加时间段筛选条件
            if (startData != null && !startData.isEmpty()) {
                sql += " AND B.TRANSFER_TIEM >= '" + startData + "'";
@@ -118,6 +124,53 @@
            }
            sql += " GROUP BY A.ID, A.XMKYQMC" +
                    " ORDER BY A.ID;";
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
    }
    // 获取饼状图数据
    @RequestMapping("/getCollectionEchartsPieData")
    @ResponseBody
    public Object getCollectionEchartsPieData() {
        String sql="select xmkyqlx as name,count(b.id) as value FROM cat_file_ajjxx a left join cat_item_yswjxx b on b.aj_id=a.id GROUP by a.xmkyqlx";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
        // 将键名转换为小写
        List<Map<String, Object>> result = new ArrayList<>();
        for (Map<String, Object> map : mapList) {
            Map<String, Object> newMap = new HashMap<>();
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                newMap.put(entry.getKey().toLowerCase(), entry.getValue());
            }
            result.add(newMap);
        }
        return result;
    }
    /**
     * 入库统计
     * @param year
     * @param startData
     * @param endData
     * @return
     */
    @RequestMapping({"/getInboundTimelinessRate"})
    @ResponseBody
    @RequiresUser
    public Object getInboundTimelinessRate(String year, String startData, String endData) {
        try {
            String sql = "select aj.xmkyqmc,ys.wjtm,ys.sl,ys.ym,ys.wjdx from CAT_ITEM_YSWJXX as ys left join cat_file_ajjxx as aj on ys.aj_id=aj.id where ys.yszt='3' ";
            // 添加时间段筛选条件
            if (startData != null && !startData.isEmpty()) {
                sql += " AND aj.yswsj >= '" + startData + "'";
            }
            if (endData != null && !endData.isEmpty()) {
                sql += " AND aj.yswsj <= '" + endData + "'";
            }
            List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
            return mapList;
        } catch (Exception e) {
@@ -148,18 +201,18 @@
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
            if (year == null || year.equals("")) {
                String yearSQL = "SELECT DISTINCT YEAR(DATE_TIME) AS YEAR FROM  UTL_VIEW_FORM ";
                String yearSQL = "SELECT DISTINCT EXTRACT(YEAR FROM DATE_TIME) AS YEAR FROM UTL_VIEW_FORM";
                jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                    String years = map.get("YEAR").toString().replace(".0", "");
                    Map<String, Object> hashMap = getCount("YEAR(DATE_TIME)", years);
                    Map<String, Object> hashMap = getCount(" EXTRACT(YEAR FROM DATE_TIME)", years);
                    hashMap.put("year", years);
                    mapList.add(hashMap);
                });
            } else {
                String yearSQL = "SELECT DISTINCT MONTH(DATE_TIME) AS MONTH FROM  UTL_VIEW_FORM where YEAR(DATE_TIME) = '" + year + "'";
                String yearSQL = "SELECT DISTINCT EXTRACT(MONTH FROM DATE_TIME) AS MONTH FROM  UTL_VIEW_FORM where EXTRACT(YEAR FROM DATE_TIME) = '" + year + "'";
                jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                    String month = map.get("MONTH").toString().replace(".0", "");
                    Map<String, Object> hashMap = getCount(" MONTH(DATE_TIME)", month);
                    Map<String, Object> hashMap = getCount(" EXTRACT(MONTH FROM DATE_TIME)", month);
                    hashMap.put("year", year);
                    hashMap.put("month", month);
                    mapList.add(hashMap);
@@ -191,19 +244,22 @@
    @RequestMapping({"/getUtlStatisticsByDept"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByDept(String deptName) {
    public Object getUtlStatisticsByDept(String deptName,String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
            if (deptName == null || deptName.equals("")) {
                String yearSQL = "SELECT DISTINCT DEPT_NAME AS DEPT_NAME FROM  UTL_VIEW_FORM";
                jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                    String deptNames = map.get("DEPT_NAME") == null ? "" : map.get("DEPT_NAME").toString();
                    Map<String, Object> hashMap = getCount("DEPT_NAME", deptNames);
                    hashMap.put("deptName", deptNames);
                    mapList.add(hashMap);
                });
            String yearSQL="SELECT DISTINCT DEPT_NAME AS DEPT_NAME FROM  UTL_VIEW_FORM where dept_name like '%"+deptName+"%'";
            if (startData != null && !startData.isEmpty()) {
                yearSQL += " AND date >= '" + startData + "'";
            }
            if (endData != null && !endData.isEmpty()) {
                yearSQL += " AND date <= '" + endData + "'";
            }
            jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                String deptNames = map.get("DEPT_NAME") == null ? "" : map.get("DEPT_NAME").toString();
                Map<String, Object> hashMap = getCount("DEPT_NAME", deptNames);
                hashMap.put("deptName", deptNames);
                mapList.add(hashMap);
            });
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
@@ -478,19 +534,22 @@
    public Object getCount() {
        try {
            HashMap<Object, Object> counMap = new HashMap<>();
            String dzzlCountSql = "select count(1) from CAT_FILE_AJJXX where fbzt = 1";
//            String dzzlCountSql = "select count(1) from CAT_FILE_AJJXX where fbzt = 1";
            String dzzlCountSql = "select count(1) from CAT_FILE_AJJXX";
            Integer dzzlCount = jdbcTemplate.queryForObject(dzzlCountSql, Integer.class);
            counMap.put("dzzlCount", dzzlCount);
            String yzCountSql = "select count(1) from CAT_ITEM_YSWJXX where AJ_ID IN (select ID from CAT_FILE_AJJXX where fbzt = 1)";
            String yzCountSql = "select count(1) from CAT_ITEM_YSWJXX";
//            String yzCountSql = "select count(1) from CAT_ITEM_YSWJXX where AJ_ID IN (select ID from CAT_FILE_AJJXX where fbzt = 1)";
            Integer yzCount = jdbcTemplate.queryForObject(yzCountSql, Integer.class);
            counMap.put("yzCount", yzCount);
            String cgCountSql = "select count(1) from CAT_ITEM_CGWJXX where AJ_ID IN (select ID from CAT_FILE_AJJXX where fbzt = 1)";
            String cgCountSql = "select count(1) from CAT_ITEM_CGWJXX ";
//            String cgCountSql = "select count(1) from CAT_ITEM_CGWJXX where AJ_ID IN (select ID from CAT_FILE_AJJXX where fbzt = 1)";
            Integer cgCount = jdbcTemplate.queryForObject(cgCountSql, Integer.class);
            counMap.put("cgCount", cgCount);
            String swCountSql = "select count(1) from CAT_FILE_SWAJXX ";
            String swCountSql = "select count(1) from CAT_FILE_SWYP ";
            Integer swCount = jdbcTemplate.queryForObject(swCountSql, Integer.class);
            counMap.put("swCount", swCount);
@@ -501,4 +560,17 @@
        }
    }
    /**
     * 根据资料类别统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/typeStatistics")
    @RequiresUser
    public ModelAndView typeStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/typeStatistics");
        return mav;
    }
}