lyq преди 8 месеца
родител
ревизия
2801c86272

+ 19 - 5
src/main/java/com/sooka/sponest/lawenforcement/record/controller/LawenforcementViewController.java

@@ -23,6 +23,9 @@ import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
+import static com.ruoyi.common.core.utils.DateUtils.getLast30Days;
+import static com.ruoyi.common.core.utils.DateUtils.getLast6Months;
+
 /**
  * 可视化Controller
  *
@@ -44,25 +47,36 @@ public class LawenforcementViewController extends BaseController {
     /**
      * 导出数据列表
      */
-    @Log(title = "任务数据", businessType = BusinessType.EXPORT)
+    @Log(title = "执法数据统计", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, LawenforcementViewBO lawenforcementViewBO) {
         List<Map<String, Object>> list = lawenforcementViewService.getRecordReport(lawenforcementViewBO);
-        if ("dept" == lawenforcementViewBO.getMark()) {
+        if ("dept".equals(lawenforcementViewBO.getMark())) {
             ExcelUtil<LawenforcementViewDeptVO> util = new ExcelUtil<>(LawenforcementViewDeptVO.class);
             util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewDeptVO.class), "执法单位统计");
         }
-        if ("person" == lawenforcementViewBO.getMark()) {
+        if ("person".equals(lawenforcementViewBO.getMark())) {
             ExcelUtil<LawenforcementViewPersonVO> util = new ExcelUtil<>(LawenforcementViewPersonVO.class);
             util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewPersonVO.class), "执法人员统计");
         }
-        if ("obj" == lawenforcementViewBO.getMark()) {
+        if ("obj".equals(lawenforcementViewBO.getMark())) {
             ExcelUtil<LawenforcementViewObjVO> util = new ExcelUtil<>(LawenforcementViewObjVO.class);
             util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewObjVO.class), "检查对象统计");
         }
-        if ("item" == lawenforcementViewBO.getMark()) {
+        if ("item".equals(lawenforcementViewBO.getMark())) {
             ExcelUtil<LawenforcementViewItemVO> util = new ExcelUtil<>(LawenforcementViewItemVO.class);
             util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewItemVO.class), "任务类型统计");
         }
     }
+
+    @GetMapping("/getRecordYearMonth")
+    public R getRecordYearMonth(LawenforcementViewBO lawenforcementViewBO) {
+        if ("dept".equals(lawenforcementViewBO.getMark())) {
+            lawenforcementViewBO.setDates(getLast6Months());
+        }
+        if ("person".equals(lawenforcementViewBO.getMark())) {
+            lawenforcementViewBO.setDates(getLast30Days());
+        }
+        return R.ok(lawenforcementViewService.getRecordYearMonth(lawenforcementViewBO));
+    }
 }

+ 6 - 1
src/main/java/com/sooka/sponest/lawenforcement/record/domain/bo/LawenforcementViewBO.java

@@ -1,9 +1,12 @@
 package com.sooka.sponest.lawenforcement.record.domain.bo;
 
+import com.ruoyi.common.datascope.base.domain.BaseBusinessEntity;
 import lombok.Data;
 
+import java.util.List;
+
 @Data
-public class LawenforcementViewBO {
+public class LawenforcementViewBO extends BaseBusinessEntity {
 
     private String mark;// dept、person、obj、item
 
@@ -24,4 +27,6 @@ public class LawenforcementViewBO {
     private String startDate;// 开始日期
 
     private String endDate;// 结束日期
+
+    private List<String> dates;
 }

+ 2 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/mapper/LawenforcementViewMapper.java

@@ -14,4 +14,6 @@ import java.util.Map;
 public interface LawenforcementViewMapper {
 
     List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO);
+
+    List<Map<String, Object>> getRecordYearMonth(LawenforcementViewBO lawenforcementViewBO);
 }

+ 2 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/service/ILawenforcementViewService.java

@@ -14,4 +14,6 @@ import java.util.Map;
 public interface ILawenforcementViewService {
 
     List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO);
+
+    List<Map<String, Object>> getRecordYearMonth(LawenforcementViewBO lawenforcementViewBO);
 }

+ 9 - 1
src/main/java/com/sooka/sponest/lawenforcement/record/service/impl/LawenforcementViewServiceImpl.java

@@ -1,5 +1,6 @@
 package com.sooka.sponest.lawenforcement.record.service.impl;
 
+import com.ruoyi.common.datascope.base.service.BaseService;
 import com.sooka.sponest.lawenforcement.record.domain.bo.LawenforcementViewBO;
 import com.sooka.sponest.lawenforcement.record.mapper.LawenforcementViewMapper;
 import com.sooka.sponest.lawenforcement.record.service.ILawenforcementViewService;
@@ -16,13 +17,20 @@ import java.util.Map;
  * @date 2024-10-15
  */
 @Service
-public class LawenforcementViewServiceImpl implements ILawenforcementViewService {
+public class LawenforcementViewServiceImpl extends BaseService implements ILawenforcementViewService {
 
     @Autowired
     private LawenforcementViewMapper lawenforcementViewMapper;
 
     @Override
     public List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO) {
+        setSookaDataBase(lawenforcementViewBO);
         return lawenforcementViewMapper.getRecordReport(lawenforcementViewBO);
     }
+
+    @Override
+    public List<Map<String, Object>> getRecordYearMonth(LawenforcementViewBO lawenforcementViewBO) {
+        setSookaDataBase(lawenforcementViewBO);
+        return lawenforcementViewMapper.getRecordYearMonth(lawenforcementViewBO);
+    }
 }

+ 35 - 6
src/main/resources/mapper/lawenforcement/LawenforcementViewMapper.xml

@@ -8,14 +8,17 @@
         SELECT
         <if test="mark != null and mark == 'dept'">
             a.dept_name deptName,
-            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_6') OR NULL) ing,
+            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_6') OR NULL)
+            ing,
             IFNULL(yujing, 0) yujing,
-            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL) two,
+            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL)
+            two,
         </if>
         <if test="mark != null and mark == 'person'">
             p.dept_name deptName,
             p.person_name personName,
-            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL) two,
+            count(record_status IN ('lawenforcement_type_3', 'lawenforcement_type_4', 'lawenforcement_type_5') OR NULL)
+            two,
         </if>
         <if test="mark != null and mark == 'obj'">
             check_object_name objName,
@@ -37,7 +40,8 @@
         FROM lawenforcement_record a
         <if test="mark != null and mark == 'dept'">
             LEFT JOIN (
-            SELECT dept_name, count(*) yujing FROM onest_event.centerevent_t_eventcatalogue WHERE event_type_xl = 1301
+            SELECT dept_name, count(*) yujing FROM ${onest_event}.centerevent_t_eventcatalogue WHERE event_type_xl =
+            1301
             <if test="startDate != null and startDate != ''">
                 AND create_time >= #{startDate}
             </if>
@@ -50,12 +54,12 @@
             LEFT JOIN lawenforcement_person p ON p.record_id = a.id AND main_person = 1
         </if>
         <if test="mark != null and mark == 'obj'">
-            LEFT JOIN onest_system.sys_dict_data dict ON dict.dict_value = a.job_type AND dict_type =
+            LEFT JOIN ${onest_system}.sys_dict_data dict ON dict.dict_value = a.job_type AND dict_type =
             'lawenforcement_objType'
         </if>
         LEFT JOIN lawenforcement_case c ON c.record_id = a.id
         <if test="mark != null and mark == 'item'">
-            RIGHT JOIN onest_system.sys_dict_data dict ON dict.dict_value = a.job_type
+            RIGHT JOIN ${onest_system}.sys_dict_data dict ON dict.dict_value = a.job_type
         </if>
         <where>
             <if test="mark != null and mark == 'item'">
@@ -110,4 +114,29 @@
             HAVING objName IS NULL OR objType IS NOT NULL
         </if>
     </select>
+
+    <select id="getRecordYearMonth" parameterType="LawenforcementViewBO" resultType="map">
+        SELECT a.d, IFNULL(r.total, 0) total, IFNULL(c.lian, 0) lian, IFNULL(e.yujing, 0) yujing FROM (
+        <foreach item="date" collection="dates" open="select" separator="union" close="">
+            #{date} d
+        </foreach>) a
+        LEFT JOIN (
+        SELECT DATE_FORMAT( FROM_UNIXTIME( SUBSTR( check_start_time, 1, 10 ) ),
+        <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
+        <if test="mark != null and mark == 'person'">'%Y-%m-%d'</if>) d, count(*) total,
+        count(DISTINCT check_object_name) obj
+        FROM lawenforcement_record GROUP BY d) r ON r.d = a.d
+        LEFT JOIN (
+        SELECT DATE_FORMAT( create_time,
+        <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
+        <if test="mark != null and mark == 'person">'%Y-%m-%d'</if>) d, count(*) lian
+        FROM lawenforcement_case GROUP BY d) c ON c.d = a.d
+        <if test="mark != null and mark == 'dept'">
+            LEFT JOIN (
+            SELECT DATE_FORMAT( create_time,
+            <if test="mark != null and mark == 'dept'">'%Y-%m'</if>
+            <if test="mark != null and mark == 'person'">'%Y-%m-%d'</if>) d, count(*) yujing
+            FROM ${onest_event}.centerevent_t_eventcatalogue WHERE event_type_xl = 1301 GROUP BY d) e ON e.d = a.d
+        </if>
+    </select>
 </mapper>