多单位版国产化地质资料管理系统
zs
2026-02-04 2b543ca35ad4697e31225829be13e375cd2b0259
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
package com.zbooksoft.gdmis.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruili.wcp.web.model.AjaxResponse;
import com.ruili.wcp.web.model.ErrorInfo;
import com.zbooksoft.gdmis.data.entity.ProcessingDetail;
import com.zbooksoft.gdmis.service.ProcessingDetailService;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @Description: 利用统计
 * @Author: zhai
 * @Date: 2024/9/13
 **/
@Controller
@RequestMapping("/utlStatistics")
public class UtlStatisticsController {
 
    @Autowired
    JdbcTemplate jdbcTemplate;
 
    @Autowired
    ProcessingDetailService processingDetailService;
    private static final Logger logger = LoggerFactory.getLogger(UtlStatisticsController.class);
 
    /**
     * 服务利用统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/serviceStatistics")
    @RequiresUser
    public ModelAndView serviceStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/serviceStatistics");
        return mav;
    }
 
 
    /**
     * 根据借阅类型
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlType")
    @RequiresUser
    public ModelAndView utlType() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlType");
        return mav;
    }
 
    @RequestMapping({"/getUtlType"})
    @ResponseBody
    @RequiresUser
    public Object getUtlType(String code) {
        try {
            ArrayList<Map<String, Object>> mapList = new ArrayList<>();
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按人件份统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/transferStatistics")
    @RequiresUser
    public ModelAndView 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 selectParameter, String startData, String endData) {
        try {
            String sql = "SELECT " +
                    "    A.ID," +
                    "    A.XMKYQMC ," +
                    "    COUNT(DISTINCT B.ID) AS transferTime," +
                    "    COUNT(C.ID) AS transferCount," +
                    "    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," +
                    "    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 + "'";
            }
            if (endData != null && !endData.isEmpty()) {
                sql += " AND B.TRANSFER_TIEM <= '" + endData + "'";
            }
            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) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按人件份统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByUser")
    @RequiresUser
    public ModelAndView utlStatisticsByUser() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByUser");
        return mav;
    }
 
 
    @RequestMapping({"/getUtlStatisticsByUser"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByUser(String year, String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
            if (year == null || year.equals("")) {
                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(" EXTRACT(YEAR FROM DATE_TIME)", years);
                    hashMap.put("year", years);
                    mapList.add(hashMap);
                });
            } else {
                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(" EXTRACT(MONTH FROM DATE_TIME)", month);
                    hashMap.put("year", year);
                    hashMap.put("month", month);
                    mapList.add(hashMap);
                });
            }
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按借阅单位统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByDept")
    @RequiresUser
    public ModelAndView utlStatisticsByDept() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByDept");
        return mav;
    }
 
    //获取部门信息
 
    @RequestMapping({"/getUtlStatisticsByDept"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByDept(String deptName,String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
            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);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按借阅单位所在地统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByDeptAddress")
    @RequiresUser
    public ModelAndView utlStatisticsByDeptAddress() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByDeptAddress");
        return mav;
    }
 
    //获取部门信息
 
    @RequestMapping({"/getUtlStatisticsByDeptAddress"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByDeptAddress(String year, String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
 
            String yearSQL = "SELECT DISTINCT city AS city FROM  UTL_VIEW_FORM";
            jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                String city = map.get("city").toString();
                Map<String, Object> hashMap = getCount("city", city);
                hashMap.put("city", city);
                mapList.add(hashMap);
            });
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
 
    /**
     * 按所属行业统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByIndustry")
    @RequiresUser
    public ModelAndView utlStatisticsByIndustry() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByIndustry");
        return mav;
    }
    //获取部门信息
 
    @RequestMapping({"/getUtlStatisticsByIndustry"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByIndustry(String year, String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
 
            String yearSQL = "SELECT DISTINCT TRADE AS TRADE FROM  UTL_VIEW_FORM";
            jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                String trade = map.get("TRADE").toString();
                Map<String, Object> hashMap = getCount("TRADE", trade);
                hashMap.put("trade", trade);
                mapList.add(hashMap);
            });
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
 
    /**
     * 按单位性质统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByDeptType")
    @RequiresUser
    public ModelAndView utlStatisticsByDeptType() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByDeptType");
        return mav;
    }
 
    //获取部门信息
 
    @RequestMapping({"/getUtlStatisticsByDeptType"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByDeptType(String year, String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
 
            String yearSQL = "SELECT DISTINCT DEPT_NATURE AS DEPT_NATURE FROM  UTL_VIEW_FORM";
            jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                String deptNature = map.get("DEPT_NATURE").toString();
                Map<String, Object> hashMap = getCount("DEPT_NATURE", deptNature);
                hashMap.put("deptNature", deptNature);
                mapList.add(hashMap);
            });
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按借阅区域统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByArea")
    @RequiresUser
    public ModelAndView utlStatisticsByArea() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByArea");
        return mav;
    }
 
    @RequestMapping({"/getUtlStatisticsByArea"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsByArea(String year, String startData, String endData) {
        try {
            List<Map<String, Object>> mapList = new ArrayList<>();
 
            String yearSQL = "SELECT DISTINCT DEPT_NATURE AS DEPT_NATURE FROM  UTL_VIEW_FORM";
            jdbcTemplate.queryForList(yearSQL).forEach(map -> {
                String deptNature = map.get("DEPT_NATURE").toString();
                Map<String, Object> hashMap = getCount("DEPT_NATURE", deptNature);
                hashMap.put("deptNature", deptNature);
                mapList.add(hashMap);
            });
            return mapList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 按资料类别统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByType")
    @RequiresUser
    public ModelAndView utlStatisticsByType() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByType");
        return mav;
    }
 
    /**
     * 对外服务详单
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsByService")
    @RequiresUser
    public ModelAndView utlStatisticsByService() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsByService");
        return mav;
    }
 
    /**
     * 涉密资料加工信息统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatisticsBySecurity")
    @RequiresUser
    public ModelAndView utlStatisticsBySecurity() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatisticsBySecurity");
        return mav;
    }
 
    @RequestMapping({"/getUtlStatisticsBySecurity"})
    @ResponseBody
    @RequiresUser
    public Object getUtlStatisticsBySecurity() {
        try {
            QueryWrapper<ProcessingDetail> wrapper = new QueryWrapper<>();
            wrapper.ne("SECURITY_CLASSIFICATION", "");
            wrapper.ne("SECURITY_CLASSIFICATION", "内部");
            wrapper.isNotNull("SECURITY_CLASSIFICATION");
            List<ProcessingDetail> processingDetailList = processingDetailService.list(wrapper);
            return processingDetailList;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 地质资料利用情况统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/utlStatistics")
    @RequiresUser
    public ModelAndView utlStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/utlStatistics");
        return mav;
    }
 
    /**
     * 地质资料利用情况统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/physicalStatistics")
    @RequiresUser
    public ModelAndView physicalStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/physicalStatistics");
        return mav;
    }
 
    public Map<String, Object> getCount(String tableName, String value) {
        HashMap<String, Object> map = new HashMap<>();
        String sql = "SELECT  APPLY_NAME, COUNT(APPLY_NAME) as count,SUM(FILE_COUNT) as file_count,SUM(ITEM_COUNT) as item_count FROM utl_view_form where " + tableName + " ='" + value + "' GROUP BY  APPLY_NAME ";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> map1 : mapList) {
            if (map1.get("APPLY_NAME") != null && "借阅".equals(map1.get("APPLY_NAME").toString())) {
                map.put("borrow", map1.get("count"));
                map.put("borrowFileCount", map1.get("file_count"));
                map.put("borrowItemCount", map1.get("item_count"));
            }
            if (map1.get("APPLY_NAME") != null && "加工".equals(map1.get("APPLY_NAME").toString())) {
                map.put("process", map1.get("count"));
                map.put("processFileCount", map1.get("file_count"));
                map.put("processItemCount", map1.get("item_count"));
            }
            if (map1.get("APPLY_NAME") != null && "实物利用".equals(map1.get("APPLY_NAME").toString())) {
                map.put("physical", map1.get("count"));
                map.put("physicalFileCount", map1.get("file_count"));
                map.put("physicalItemCount", map1.get("item_count"));
            }
        }
        return map;
    }
 
 
    /**
     * 获取地质资料 成果资料 原始资料 实物资料数量
     *
     * @return
     */
    @RequestMapping({"/getCount"})
    @ResponseBody
    @RequiresUser
    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";
            Integer dzzlCount = jdbcTemplate.queryForObject(dzzlCountSql, Integer.class);
            counMap.put("dzzlCount", dzzlCount);
 
            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 ";
//            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_SWYP ";
            Integer swCount = jdbcTemplate.queryForObject(swCountSql, Integer.class);
            counMap.put("swCount", swCount);
 
            return counMap;
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
        }
 
    }
 
    /**
     * 根据资料类别统计
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/typeStatistics")
    @RequiresUser
    public ModelAndView typeStatistics() {
        ModelAndView mav = new ModelAndView("gh/utlStatistics/typeStatistics");
        return mav;
    }
}