浏览代码

可视化报表

lyq 8 月之前
父节点
当前提交
2922282cae

+ 68 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/controller/LawenforcementViewController.java

@@ -0,0 +1,68 @@
+package com.sooka.sponest.lawenforcement.record.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.common.core.domain.R;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.sooka.sponest.lawenforcement.record.domain.bo.LawenforcementViewBO;
+import com.sooka.sponest.lawenforcement.record.domain.vo.LawenforcementViewDeptVO;
+import com.sooka.sponest.lawenforcement.record.domain.vo.LawenforcementViewItemVO;
+import com.sooka.sponest.lawenforcement.record.domain.vo.LawenforcementViewObjVO;
+import com.sooka.sponest.lawenforcement.record.domain.vo.LawenforcementViewPersonVO;
+import com.sooka.sponest.lawenforcement.record.service.ILawenforcementViewService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 可视化Controller
+ *
+ * @author lyq
+ * @date 2024-10-15
+ */
+@RestController
+@RequestMapping("/view")
+public class LawenforcementViewController extends BaseController {
+
+    @Autowired
+    private ILawenforcementViewService lawenforcementViewService;
+
+    @GetMapping("/getRecordReport")
+    public R getRecordRpoort(LawenforcementViewBO lawenforcementViewBO) {
+        return R.ok(lawenforcementViewService.getRecordReport(lawenforcementViewBO));
+    }
+
+    /**
+     * 导出数据列表
+     */
+    @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()) {
+            ExcelUtil<LawenforcementViewDeptVO> util = new ExcelUtil<>(LawenforcementViewDeptVO.class);
+            util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewDeptVO.class), "执法单位统计");
+        }
+        if ("person" == lawenforcementViewBO.getMark()) {
+            ExcelUtil<LawenforcementViewPersonVO> util = new ExcelUtil<>(LawenforcementViewPersonVO.class);
+            util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewPersonVO.class), "执法人员统计");
+        }
+        if ("obj" == lawenforcementViewBO.getMark()) {
+            ExcelUtil<LawenforcementViewObjVO> util = new ExcelUtil<>(LawenforcementViewObjVO.class);
+            util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewObjVO.class), "检查对象统计");
+        }
+        if ("item" == lawenforcementViewBO.getMark()) {
+            ExcelUtil<LawenforcementViewItemVO> util = new ExcelUtil<>(LawenforcementViewItemVO.class);
+            util.exportExcel(response, JSONObject.parseArray(JSON.toJSONString(list), LawenforcementViewItemVO.class), "任务类型统计");
+        }
+    }
+}

+ 27 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/domain/bo/LawenforcementViewBO.java

@@ -0,0 +1,27 @@
+package com.sooka.sponest.lawenforcement.record.domain.bo;
+
+import lombok.Data;
+
+@Data
+public class LawenforcementViewBO {
+
+    private String mark;// dept、person、obj、item
+
+    private String deptName;// 执法单位
+
+    private String personName;// 执法人员
+
+    private String objName;// 检查对象名称
+
+    private String objCode;// 检查对象代码
+
+    private String objPhone;// 检查对象电话
+
+    private String objType;// 检查对象类型lawenforcement_objType
+
+    private String jobType;// 任务类型lawenforcement_jobType
+
+    private String startDate;// 开始日期
+
+    private String endDate;// 结束日期
+}

+ 29 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/domain/vo/LawenforcementViewDeptVO.java

@@ -0,0 +1,29 @@
+package com.sooka.sponest.lawenforcement.record.domain.vo;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class LawenforcementViewDeptVO {
+
+    @Excel(name = "执法单位名称")
+    private String deptName;
+
+    @Excel(name = "执法总数")
+    private String total;
+
+    @Excel(name = "执法进行数")
+    private String ing;
+
+    @Excel(name = "预警频次")
+    private String yujing;
+
+    @Excel(name = "二次执法数")
+    private String two;
+
+    @Excel(name = "立案数")
+    private String lian;
+
+    @Excel(name = "案-件比")
+    private String caseload;
+}

+ 26 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/domain/vo/LawenforcementViewItemVO.java

@@ -0,0 +1,26 @@
+package com.sooka.sponest.lawenforcement.record.domain.vo;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class LawenforcementViewItemVO {
+
+    @Excel(name = "任务类型")
+    private String jobType;
+
+    @Excel(name = "执法部门数")
+    private String dept;
+
+    @Excel(name = "检查对象数")
+    private String obj;
+
+    @Excel(name = "检查子项数量")
+    private String sub;
+
+    @Excel(name = "立案数")
+    private String lian;
+
+    @Excel(name = "案-件比")
+    private String caseload;
+}

+ 35 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/domain/vo/LawenforcementViewObjVO.java

@@ -0,0 +1,35 @@
+package com.sooka.sponest.lawenforcement.record.domain.vo;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class LawenforcementViewObjVO {
+
+    @Excel(name = "检查对象名称")
+    private String objName;
+
+    @Excel(name = "检查对象代码")
+    private String objCode;
+
+    @Excel(name = "检查对象联系电话")
+    private String objPhone;
+
+    @Excel(name = "检查对象类型")
+    private String objType;
+
+    @Excel(name = "检查频次")
+    private String total;
+
+    @Excel(name = "立案数")
+    private String lian;
+
+    @Excel(name = "案-件比")
+    private String caseload;
+
+    @Excel(name = "检查子项数量")
+    private String sub;
+
+    @Excel(name = "检查好评占比")
+    private String haoping;
+}

+ 26 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/domain/vo/LawenforcementViewPersonVO.java

@@ -0,0 +1,26 @@
+package com.sooka.sponest.lawenforcement.record.domain.vo;
+
+import com.ruoyi.common.core.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class LawenforcementViewPersonVO {
+
+    @Excel(name = "执法人员所在部门")
+    private String deptName;
+
+    @Excel(name = "执法人员名称")
+    private String personName;
+
+    @Excel(name = "执法总数")
+    private String total;
+
+    @Excel(name = "二次执法数")
+    private String two;
+
+    @Excel(name = "立案数")
+    private String lian;
+
+    @Excel(name = "案-件比")
+    private String caseload;
+}

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

@@ -0,0 +1,17 @@
+package com.sooka.sponest.lawenforcement.record.mapper;
+
+import com.sooka.sponest.lawenforcement.record.domain.bo.LawenforcementViewBO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 可视化Mapper接口
+ *
+ * @author lyq
+ * @date 2024-10-15
+ */
+public interface LawenforcementViewMapper {
+
+    List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO);
+}

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

@@ -0,0 +1,17 @@
+package com.sooka.sponest.lawenforcement.record.service;
+
+import com.sooka.sponest.lawenforcement.record.domain.bo.LawenforcementViewBO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 可视化Service接口
+ *
+ * @author lyq
+ * @date 2024-10-15
+ */
+public interface ILawenforcementViewService {
+
+    List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO);
+}

+ 28 - 0
src/main/java/com/sooka/sponest/lawenforcement/record/service/impl/LawenforcementViewServiceImpl.java

@@ -0,0 +1,28 @@
+package com.sooka.sponest.lawenforcement.record.service.impl;
+
+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;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 可视化Service业务层处理
+ *
+ * @author lyq
+ * @date 2024-10-15
+ */
+@Service
+public class LawenforcementViewServiceImpl implements ILawenforcementViewService {
+
+    @Autowired
+    private LawenforcementViewMapper lawenforcementViewMapper;
+
+    @Override
+    public List<Map<String, Object>> getRecordReport(LawenforcementViewBO lawenforcementViewBO) {
+        return lawenforcementViewMapper.getRecordReport(lawenforcementViewBO);
+    }
+}

+ 113 - 0
src/main/resources/mapper/lawenforcement/LawenforcementViewMapper.xml

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.sooka.sponest.lawenforcement.record.mapper.LawenforcementViewMapper">
+
+    <select id="getRecordReport" parameterType="LawenforcementViewBO" resultType="map">
+        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,
+            IFNULL(yujing, 0) yujing,
+            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,
+        </if>
+        <if test="mark != null and mark == 'obj'">
+            check_object_name objName,
+            check_object_code objCode,
+            check_object_phone objPhone,
+            dict_label objType,
+            IFNULL(SUM(subitem_count), 0) sub,
+            concat(ROUND(IFNULL(count(evaluation = 1 OR NULL) / count(*), 0) * 100, 2), '%') haoping,
+        </if>
+        <if test="mark != null and mark == 'item'">
+            dict_label dictLabel,
+            count(DISTINCT a.dept_name) dept,
+            count(DISTINCT check_object_name) obj,
+            IFNULL(SUM(subitem_count), 0) sub,
+        </if>
+        count(*) total,
+        count(c.record_id) lian,
+        concat(ROUND(IFNULL(c.record_id / count(*), 0) * 100, 2), '%') caseload
+        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
+            <if test="startDate != null and startDate != ''">
+                AND create_time >= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                AND create_time &lt;= #{endDate}
+            </if>
+            GROUP BY dept_name) e ON e.dept_name = a.dept_name
+        </if>
+        <if test="mark != null and mark == 'person'">
+            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 =
+            '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
+        </if>
+        <where>
+            <if test="mark != null and mark == 'item'">
+                AND dict_type = 'lawenforcement_jobType'
+            </if>
+            <if test="deptName != null and deptName != ''">
+                AND a.dept_name LIKE CONCAT('%', #{deptName}, '%')
+            </if>
+            <if test="personName != null and personName != ''">
+                AND p.person_name LIKE CONCAT('%', #{personName}, '%')
+            </if>
+            <if test="objName != null and objName != ''">
+                AND check_object_name LIKE CONCAT('%', #{objName}, '%')
+            </if>
+            <if test="objCode != null and objCode != ''">
+                AND check_object_code LIKE CONCAT('%', #{objCode}, '%')
+            </if>
+            <if test="objPhone != null and objPhone != ''">
+                AND check_object_phone LIKE CONCAT('%', #{objPhone}, '%')
+            </if>
+            <if test="objType != null and objType != ''">
+                AND check_object_type = #{objType}
+            </if>
+            <if test="jobType != null and jobType != ''">
+                AND job_type = #{jobType}
+            </if>
+            <if test="startDate != null and startDate != ''">
+                AND check_start_time >= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != ''">
+                AND check_end_time &lt;= #{endDate}
+            </if>
+        </where>
+        GROUP BY
+        <if test="mark != null and mark == 'dept'">
+            deptName
+        </if>
+        <if test="mark != null and mark == 'person'">
+            deptName,personName
+        </if>
+        <if test="mark != null and mark == 'obj'">
+            objName,objCode,objPhone,objType
+        </if>
+        <if test="mark != null and mark == 'item'">
+            dictLabel
+        </if>
+        WITH ROLLUP
+        <if test="mark != null and mark == 'person'">
+            HAVING deptName IS NULL OR personName IS NOT NULL
+        </if>
+        <if test="mark != null and mark == 'obj'">
+            HAVING objName IS NULL OR objType IS NOT NULL
+        </if>
+    </select>
+</mapper>