diff --git a/pom.xml b/pom.xml index 63c17e0..2631f6a 100644 --- a/pom.xml +++ b/pom.xml @@ -166,6 +166,11 @@ DmJdbcDriver18 8.1.3.140 + + net.logstash.logback + logstash-logback-encoder + 4.9 + @@ -183,7 +188,17 @@ true + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + true + + org.springframework.boot spring-boot-maven-plugin @@ -230,4 +245,4 @@ - \ No newline at end of file + diff --git a/src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java b/src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java index 4c9a0bc..029e10c 100644 --- a/src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java +++ b/src/main/java/com/biutag/supervision/constants/enums/ProblemSourcesEnum.java @@ -23,6 +23,10 @@ public enum ProblemSourcesEnum { XF_QT("其他", "25"), SJJD("审计监督", "26"), + ZFTZSJ("政府投资审计", "27"), + ZFSACFSS("执法涉案财务审计", "28"), + JJZRSJ("经济责任审计", "29"), + ZXSJ("专项审计", "30"), JWDC("警务评议", "2"), JYDC("警意调查", "3"), diff --git a/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java b/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java index 4000a52..00c71df 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.vo.*; import com.biutag.supervision.service.DataGobalService; +import com.biutag.supervision.service.DataSupervisionNotifyServiceImpl; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.activation.DataHandler; @@ -35,6 +36,7 @@ public class DataGobalController { private final DataGobalService dataGobalService; + /** * 获取数据大屏概览 * @param beginTime @@ -55,45 +57,18 @@ public class DataGobalController { // 业务类型占比 List ywzblist = dataGobalService.getBusinessRate(beginTime, endTime); + // 突出问题排名 + List tcwtlist = dataGobalService.getStrongProblemRank(beginTime, endTime); + // 问题类型占比 List wtlxlist = dataGobalService.getProblemRate(beginTime, endTime); - // 突出问题排名 - List tcwtlist = dataGobalService.getStrongProblemRank(beginTime, endTime); + // 地图数据 + List gobalTempMapVoList = dataGobalService.getMapIconInfo(beginTime, endTime); + if ( gobalTempMapVoList==null || gobalTempMapVoList.size() == 0) { + gobalTempMapVoList = new ArrayList<>(); + } - // 地图显示结果 - List gobalMapVoList = new ArrayList<>(); - fxsjlist.forEach(item -> { - // 添加总数 - GobalMapIconVo gobalMapVo = new GobalMapIconVo(); - gobalMapVo.setName(item.getLabel()); - gobalMapVo.setTotalPro(Integer.parseInt(item.getValue())); - gobalMapVoList.add(gobalMapVo); - }); - // 市县分局的督察问题 - List superviseProList = dataGobalService.getSuperviseProTotal(beginTime, endTime); - List caseVerifyProList = dataGobalService.getCaseVerifyProTotal(beginTime, endTime); - List mailProList = dataGobalService.getMailProTotal(beginTime, endTime); - List policeProList = dataGobalService.getPoliceProTotal(beginTime, endTime); - List reviewProList = dataGobalService.getReviewProTotal(beginTime, endTime); - List gobalTempMapVoList = new ArrayList<>(); - if (!gobalMapVoList.isEmpty()) { - updateProList(superviseProList, gobalMapVoList, GobalMapIconVo::setSupervisePro); - updateProList(caseVerifyProList, gobalMapVoList, GobalMapIconVo::setCaseVerifyPro); - updateProList(mailProList, gobalMapVoList, GobalMapIconVo::setMailPro); - updateProList(policeProList, gobalMapVoList, GobalMapIconVo::setPolicePro); - updateProList(reviewProList, gobalMapVoList, GobalMapIconVo::setReviewPro); - }else { -// gobalTempMapVoList.add(new GobalMapIconVo("芙蓉分局", 1,11,11,11,11,11)); -// gobalTempMapVoList.add(new GobalMapIconVo("天心分局", 2,22,22,22,22,22)); -// gobalTempMapVoList.add(new GobalMapIconVo("岳麓分局", 3,33,33,33,33,33)); -// gobalTempMapVoList.add(new GobalMapIconVo("开福分局", 4,44,44,44,44,44)); -// gobalTempMapVoList.add(new GobalMapIconVo("雨花分局", 5,55,55,55,55,55)); -// gobalTempMapVoList.add(new GobalMapIconVo("长沙县局", 6,66,66,66,66,66)); -// gobalTempMapVoList.add(new GobalMapIconVo("望城分局", 7,77,77,77,77,77)); -// gobalTempMapVoList.add(new GobalMapIconVo("宁乡市局", 8,88,88,88,88,88)); -// gobalTempMapVoList.add(new GobalMapIconVo("浏阳市局", 9,99,99,99,99,99)); - } JSONObject data = new JSONObject().fluentPut("overview", overview) .fluentPut("fxsjlist", fxsjlist) @@ -101,8 +76,8 @@ public class DataGobalController { .fluentPut("ywzblist", ywzblist) .fluentPut("wtlxlist", wtlxlist) .fluentPut("tcwtlist", tcwtlist) - .fluentPut("gobalMapVoList", gobalMapVoList) .fluentPut("gobalTempMapVoList", gobalTempMapVoList); + return Result.success(data); } @@ -165,4 +140,7 @@ public class DataGobalController { return Result.success(jsonObject); } + + + } diff --git a/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java b/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java index 7bb8b05..1a9ae16 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java @@ -3,6 +3,7 @@ package com.biutag.supervision.controller.datav; import com.alibaba.fastjson.JSONObject; import com.biutag.supervision.pojo.Result; import com.biutag.supervision.pojo.dto.CaseVerifDepart; +import com.biutag.supervision.pojo.vo.EchartsVo; import com.biutag.supervision.pojo.vo.RankVo; import com.biutag.supervision.service.DataSupervisionNotifyServiceImpl; import io.swagger.v3.oas.annotations.Operation; @@ -33,7 +34,7 @@ public class SupervisionNotifyController { private final DataSupervisionNotifyServiceImpl dataSupervisionNotifyService; /** - * 获取所有现场督察钟中央总数数量 + * 获取现场督察大屏数据 * * @return */ @@ -43,14 +44,18 @@ public class SupervisionNotifyController { @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { JSONObject overview = dataSupervisionNotifyService.getAllSupervisionNotifyCount(beginTime, endTime); JSONObject data = new JSONObject().fluentPut("overview", overview); + + //问题类型占比 + List wtlxList = dataSupervisionNotifyService.getProblemTypeRatio(beginTime, endTime); + + // return Result.success(data); } /** * 获取日常督察排行 - * - * @param groupType 分组类型 1: 分县市局 2: 局属单位 + * @param groupType 分组类型 1: 分县市局 2: 局属单位 * @return */ @Operation(summary = "获取日常督察数量概览和整改率排名") @@ -67,5 +72,8 @@ public class SupervisionNotifyController { } + + + } diff --git a/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java b/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java new file mode 100644 index 0000000..71a2f3b --- /dev/null +++ b/src/main/java/com/biutag/supervision/controller/work/AlarmNotificationController.java @@ -0,0 +1,58 @@ +package com.biutag.supervision.controller.work; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.biutag.supervision.pojo.Result; +import com.biutag.supervision.pojo.entity.AlarmNotification; +import com.biutag.supervision.pojo.param.AlarmParam; +import com.biutag.supervision.service.AlarmNotificationService; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author kami on 2024-11-16 11:30:34 + * @version 0.0.1 + * @since 1.8 + */ +@Slf4j +@RestController +@RequestMapping("/alarm/notification") +@AllArgsConstructor +public class AlarmNotificationController { + + private final AlarmNotificationService notificationService; + + /** + * 预警通知分页查询 + * @param param 请求参数 + * @return 预警通知分页数据 + */ + @PostMapping("/pages") + public Result> pages(@RequestBody AlarmParam param) { + return Result.success(notificationService.pages(param)); + } + + /** + * 回复内容 + * @param data 数据 + * @return 响应 + */ + @PostMapping("/reply") + public Result alarmNotificationReply(@RequestBody AlarmNotification data) { + AlarmNotification notification = new AlarmNotification(); + if(data.getId() == null) { + return Result.failed(5000, "未找到对用数据"); + } + notification.setId(data.getId()); + notification.setReplyResultContent(data.getReplyResultContent()); + notification.setReplyState(1); + boolean res = notificationService.updateById(notification); + if(!res) { + return Result.failed(5000, "修改失败"); + } + return Result.success(); + } +} diff --git a/src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java b/src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java new file mode 100644 index 0000000..dc10a6e --- /dev/null +++ b/src/main/java/com/biutag/supervision/mapper/AlarmNotificationMapper.java @@ -0,0 +1,14 @@ +package com.biutag.supervision.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.biutag.supervision.pojo.entity.AlarmNotification; + +/** + * @author kami on 2024-11-16 11:05:28 + * @version 0.0.1 + * @since 1.8 + */ +@DS("master") +public interface AlarmNotificationMapper extends BaseMapper { +} diff --git a/src/main/java/com/biutag/supervision/mapper/BusinessDepartMapper.java b/src/main/java/com/biutag/supervision/mapper/BusinessDepartMapper.java index d0ac758..400f8b4 100644 --- a/src/main/java/com/biutag/supervision/mapper/BusinessDepartMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/BusinessDepartMapper.java @@ -6,9 +6,32 @@ import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.biutag.supervision.pojo.entity.BusinessDepart; import com.biutag.supervision.pojo.model.BusinessPoliceModel; +import com.biutag.supervision.pojo.vo.ProblemSourceVo; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; public interface BusinessDepartMapper extends BaseMapper { Page queryPage(@Param("page") Page page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper); -} \ No newline at end of file + @Select(" ") + List problemStatistics(@Param("list") List list, @Param("time") String time); + + @Select(" ") + Integer problemSum(@Param("list") List list, @Param("time") String time); +} diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java index 35e39a2..f654551 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeBlameMapper.java @@ -2,6 +2,7 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.entity.NegativeBlame; +import com.biutag.supervision.pojo.vo.BlamePerson; import org.apache.ibatis.annotations.Select; import java.time.LocalDateTime; @@ -26,4 +27,18 @@ public interface NegativeBlameMapper extends BaseMapper { List selectVerifyTrue(); -} \ No newline at end of file + @Select(" SELECT blameIdCode, blameName, count(1) as number FROM `negative_blame` " + + " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode = 1 " + + " GROUP BY blameIdCode order by number desc limit 10") + List statisticsBlame(); + + @Select(" SELECT blameIdCode, blameName, count(1) as number FROM `negative_blame` " + + " where blameIdCode is not null and LENGTH(blameIdCode) > 0 and ivPersonTypeCode != 1 " + + " GROUP BY blameIdCode order by number desc limit 10") + List statisticsBlame2(); + + @Select(" SELECT leadIdCode as blameIdCode, leadName as blameName, count(1) as number FROM `negative_blame` " + + " where leadIdCode is not null and LENGTH(leadIdCode) > 0 " + + " GROUP BY leadIdCode order by number desc limit 10") + List statisticsBlame3(); +} diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java index c1e822a..99cfc73 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java @@ -45,6 +45,63 @@ public interface NegativeMapper extends BaseMapper { "GROUP BY monthTime " + "order BY monthTime asc") List selectRecentTrendByMonth(String year); + + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + " (" + + " SELECT sd.id, sd.pid, sd.name, sd1.short_name FROM sup_depart sd " + + " INNER join sup_depart sd1 on sd.pid=sd1.id " + + " and sd1.LEVEL=2 AND sd1.statistics_group_id=3" + + " ) " + + "as temp on ng.involveDepartId=temp.id " + + "AND ng.checkStatus<>3 AND problemSourcesCode in (13, 15, 16) " + + "AND temp.pid=#{departId} AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Integer seleGobalMapIconInfoDc(Date beginTime, Date endTime, Integer departId); + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + " (" + + " SELECT sd.id, sd.pid, sd.name, sd1.short_name FROM sup_depart sd " + + " INNER join sup_depart sd1 on sd.pid=sd1.id " + + " and sd1.LEVEL=2 AND sd1.statistics_group_id=3" + + " ) " + + "as temp on ng.involveDepartId=temp.id " + + "AND ng.checkStatus<>3 AND problemSourcesCode=11 " + + "AND temp.pid=#{departId} AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Integer seleGobalMapIconInfoAjhc(Date beginTime, Date endTime, Integer departId); + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + " (" + + " SELECT sd.id, sd.pid, sd.name, sd1.short_name FROM sup_depart sd " + + " INNER join sup_depart sd1 on sd.pid=sd1.id " + + " and sd1.LEVEL=2 AND sd1.statistics_group_id =3 " + + " ) " + + "as temp on ng.involveDepartId=temp.id " + + "AND ng.checkStatus<>3 AND problemSourcesCode in (21, 22, 23, 24, 25) " + + "AND temp.pid=#{departId} AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Integer seleGobalMapIconInfoXf(Date beginTime, Date endTime, Integer departId); + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + " (" + + " SELECT sd.id, sd.pid, sd.name, sd1.short_name FROM sup_depart sd " + + " INNER join sup_depart sd1 on sd.pid=sd1.id " + + " and sd1.LEVEL=2 AND sd1.statistics_group_id =3 " + + " ) " + + "as temp on ng.involveDepartId=temp.id " + + "AND ng.checkStatus<>3 AND problemSourcesCode=2 " + + "AND temp.pid=#{departId} AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Integer seleGobalMapIconInfoJwpy(Date beginTime, Date endTime, Integer departId); + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + " (" + + " SELECT sd.id, sd.pid, sd.name, sd1.short_name FROM sup_depart sd " + + " INNER join sup_depart sd1 on sd.pid=sd1.id " + + " and sd1.LEVEL=2 AND sd1.statistics_group_id =3 " + + " ) " + + "as temp on ng.involveDepartId=temp.id " + + "AND ng.checkStatus<>3 AND problemSourcesCode=26 " + + "AND temp.pid=#{departId} AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Integer seleGobalMapIconInfoSjdc(Date beginTime, Date endTime, Integer departId); + // endregion @@ -92,18 +149,12 @@ public interface NegativeMapper extends BaseMapper { Long selectRelationOrgCount(Date beginTime, Date endTime, String checkStatus); - @Select("SELECT COUNT(*) FROM negative n " + - "INNER JOIN ( " + - " SELECT DISTINCT sd.id " + - " FROM sup_depart sd " + - " INNER JOIN sup_depart sd1 ON sd.pid = sd1.id " + - " WHERE sd1.statistics_group_id = #{groupType}" + - ") AS filtered_sd ON n.involveDepartId = filtered_sd.id " + - "WHERE n.checkStatus = 1 " + - "AND n.problemSourcesCode = 15;") - Long getCountByGroupType(Integer groupType, Date beginTime, Date endTime); + + /** + * 获取现场督察按二级机构分组和整改状态划分的的问题数 + */ @Select("SELECT COUNT(*) FROM negative n " + "INNER JOIN ( " + " SELECT DISTINCT sd.id " + @@ -112,12 +163,38 @@ public interface NegativeMapper extends BaseMapper { " WHERE sd1.statistics_group_id = #{groupType}" + ") AS filtered_sd ON n.involveDepartId = filtered_sd.id " + "WHERE n.checkStatus = 1 " + - "AND n.problemSourcesCode = 15 " + + "AND n.problemSourcesCode = 13 " + "AND n.isRectifyCode=#{isRectify} " + "AND n.discoveryTime BETWEEN #{beginTime} AND #{endTime}") Long getChangCountByGroupType(Integer groupType, Date beginTime, Date endTime, Integer isRectify); + + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + "(SELECT sd.id, sd.pid, sd.`name`, sd1.short_name FROM sup_depart sd INNER JOIN sup_depart sd1 " + + "ON sd.pid = sd1.id AND sd1.`level`=2 AND sd1.statistics_group_id=3) as temp " + + "ON ng.involveDepartId=temp.id " + + "AND pid=#{departId} " + + "AND problemSourcesCode= 13 " + + "AND checkStatus <> 3 " + + "AND isRectifyCode =1 " + + "AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Long getChangedCountByGroupType(Date beginTime, Date endTime, String departId); + + + + @Select("SELECT count(*) FROM negative ng INNER JOIN " + + "(SELECT sd.id, sd.pid, sd.`name`, sd1.short_name FROM sup_depart sd INNER JOIN sup_depart sd1 " + + "ON sd.pid = sd1.id AND sd1.`level`=2 AND sd1.statistics_group_id=3) as temp\n" + + "ON ng.involveDepartId=temp.id " + + "AND pid=#{departId} " + + "AND problemSourcesCode= 13 " + + "AND isRectifyCode =1 " + + "AND discoveryTime BETWEEN #{beginTime} AND #{endTime}") + Long getCountByGroupType(Date beginTime, Date endTime, String departId); + + // endregion } diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java index 480ec8b..44cd53b 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java @@ -13,77 +13,41 @@ import java.util.List; public interface NegativeProblemRelationMapper extends BaseMapper { - @Select("SELECT npr.oneLevelContent as name, count(*) value " + - "FROM negative_problem_relation npr " + - "WHERE npr.oneLevelContent is not NULL " + - "GROUP BY `name` ") + /** + * 首页大屏问题类型占比 + * @param beginTime + * @param endTime + * @return + */ + @Select("SELECT npr.oneLevelContent as name, count(*) `value` FROM negative_problem_relation npr INNER JOIN " + + " ( " + + " SELECT id FROM negative ng " + + " WHERE checkStatus <>3 " + + " AND discoveryTime BETWEEN #{beginTime} AND #{endTime} " + + " ) as temp " + + "on npr.negativeId=temp.id " + + "AND npr.oneLevelContent is not NULL " + + "GROUP BY npr.oneLevelContent " + + "ORDER BY `value` desc") List selectProblemRate(Date beginTime, Date endTime); - @Select("SELECT threeLevelContent as label, count(*) as `value` " + - "FROM negative_problem_relation " + - "WHERE negativeId " + - "in ( SELECT id FROM negative WHERE discoveryTime BETWEEN #{beginTime} AND #{endTime}) " + - "GROUP BY threeLevelContent " + - "ORDER BY VALUE DESC ") + /** + * 首页大屏突出问题排名 + * @param beginTime + * @param endTime + * @return + */ + @Select("SELECT npr.threeLevelContent as label, count(*) `value` FROM negative_problem_relation npr INNER JOIN " + + " ( " + + " SELECT id FROM negative ng " + + " WHERE checkStatus <>3 " + + " AND discoveryTime BETWEEN #{beginTime} AND #{endTime} " + + " ) as temp " + + "on npr.negativeId=temp.id " + + "AND npr.threeLevelContent is not NULL " + + "GROUP BY npr.threeLevelContent " + + "ORDER BY `value` desc") List selectStrongProblemRank(Date beginTime, Date endTime); - @Select("SELECT sd1.short_name, count(*) value " + - "FROM negative ng " + - "INNER JOIN sup_depart sd " + - "on ng.involveDepartId=sd.id AND sd.`level`=3 " + - "AND checkStatus=1 AND problemSourcesCode in(13, 14, 15, 16) " + - "AND ng.discoveryTime BETWEEN #{beginTime} and #{endTime}" + - "INNER JOIN sup_depart sd1 " + - "on sd.pid=sd1.id and sd1.statistics_group_id=3\n" + - "GROUP BY sd1.id " + - "ORDER BY `value` DESC;") - List selectSuperviseProTotal(Date beginTime, Date endTime); - @Select("SELECT sd1.short_name, count(*) value " + - "FROM negative ng " + - "INNER JOIN sup_depart sd " + - "on ng.involveDepartId=sd.id AND sd.`level`=3 " + - "AND checkStatus=1 AND problemSourcesCode in(17, 18, 19, 20) " + - "AND ng.discoveryTime BETWEEN #{beginTime} and #{endTime}" + - "INNER JOIN sup_depart sd1 " + - "on sd.pid=sd1.id and sd1.statistics_group_id=3\n" + - "GROUP BY sd1.id " + - "ORDER BY `value` DESC;") - List selectCaseVerifyProTotal(Date beginTime, Date endTime); - - @Select("SELECT sd1.short_name, count(*) value " + - "FROM negative ng " + - "INNER JOIN sup_depart sd " + - "on ng.involveDepartId=sd.id AND sd.`level`=3 " + - "AND checkStatus=1 AND problemSourcesCode in(21, 22, 23, 24, 25) " + - "AND ng.discoveryTime BETWEEN #{beginTime} and #{endTime}" + - "INNER JOIN sup_depart sd1 " + - "on sd.pid=sd1.id and sd1.statistics_group_id=3\n" + - "GROUP BY sd1.id " + - "ORDER BY `value` DESC;") - List selectMailProTotal(Date beginTime, Date endTime); - - @Select("SELECT sd1.short_name, count(*) value " + - "FROM negative ng " + - "INNER JOIN sup_depart sd " + - "on ng.involveDepartId=sd.id AND sd.`level`=3 " + - "AND checkStatus=1 AND problemSourcesCode in(2) " + - "AND ng.discoveryTime BETWEEN #{beginTime} and #{endTime}" + - "INNER JOIN sup_depart sd1 " + - "on sd.pid=sd1.id and sd1.statistics_group_id=3\n" + - "GROUP BY sd1.id " + - "ORDER BY `value` DESC;") - List selectPoliceProTotal(Date beginTime, Date endTime); - - @Select("SELECT sd1.short_name, count(*) value " + - "FROM negative ng " + - "INNER JOIN sup_depart sd " + - "on ng.involveDepartId=sd.id AND sd.`level`=3 " + - "AND checkStatus=1 AND problemSourcesCode in(26) " + - "AND ng.discoveryTime BETWEEN #{beginTime} and #{endTime}" + - "INNER JOIN sup_depart sd1 " + - "on sd.pid=sd1.id and sd1.statistics_group_id=3\n" + - "GROUP BY sd1.id " + - "ORDER BY `value` DESC;") - List selectReviewProTotal(Date beginTime, Date endTime); } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java b/src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java index 3ba57be..258aa1c 100644 --- a/src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/SupDepartMapper.java @@ -32,6 +32,11 @@ public interface SupDepartMapper extends BaseMapper { List> getIdsByCode(List departIds); + /** + * 按分组查询单位 + * @param groupType + * @return + */ @Select("select * from sup_depart where statistics_group_id = #{groupType} ") List selectDepartsByGroupType(Integer groupType); } \ No newline at end of file diff --git a/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java b/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java new file mode 100644 index 0000000..25f7611 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/entity/AlarmNotification.java @@ -0,0 +1,131 @@ +package com.biutag.supervision.pojo.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 预警通知 + * @author kami on 2024-11-16 10:51:18 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@TableName("`alarm_notification`") +public class AlarmNotification implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @TableId(value = "id", type = IdType.AUTO) + private String id; + + /** + * 预警时间 + */ + @TableField("`alarm_time`") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") + LocalDateTime alarmTime; + + @TableField("`alarm_type_id`") + Long alarmTypeId; + /** + * 预警类型 + */ + @TableField("`alarm_type`") + String alarmType; + + /** + * 被通知单位机构代码 + */ + @TableField("`notification_depart_code`") + String notificationDepartCode; + + /** + * 被通知单位机构名称 + */ + @TableField("`notification_depart_name`") + String notificationDepartName; + + /** + * 通知内容 + */ + @TableField("`alarm_content`") + String alarmContent; + + /** + * 回复状态0未回复1已回复 + */ + @TableField("`reply_state`") + Integer replyState; + + /** + * 回复情况内容 + */ + @TableField("`reply_result_content`") + String replyResultContent; + + /** + * 创建时间 + */ + @TableField("`crt_time`") + LocalDateTime crtTime; + /** + * 创建用户 + */ + @TableField("`crt_user`") + String crtUser; + /** + * 创建单位 + */ + @TableField("`crt_depart_id`") + String crtDepartId; + /** + * 创建人名称 + */ + @TableField("`crt_name`") + String crtName; + /** + * 创建ip + */ + @TableField("`crt_host`") + String crtHost; + + /** + * 创建用户 + */ + @TableField("`upd_user`") + String updUser; + /** + * 创建单位 + */ + @TableField("`upd_depart_id`") + String updDepartId; + /** + * 创建人名称 + */ + @TableField("`upd_name`") + String updName; + /** + * 创建ip + */ + @TableField("`upd_host`") + String updHost; + + /** + * 修改时间 + */ + @TableField("`upd_time`") + LocalDateTime updTime; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java b/src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java new file mode 100644 index 0000000..d13a17b --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/param/AlarmParam.java @@ -0,0 +1,62 @@ +package com.biutag.supervision.pojo.param; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serial; +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +/** + * @author kami on 2024-11-16 11:12:34 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class AlarmParam extends BasePage implements Serializable { + + @Serial + private static final long serialVersionUID = 1L; + /** + * 预警类型id + */ + Long alarmTypeId; + /** + * 预警开始时间 + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss") + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + @JsonSerialize(using = LocalDateTimeSerializer.class) + LocalDateTime startTime; + + /** + * 预警开始时间 + */ + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss") + @JsonDeserialize(using = LocalDateTimeDeserializer.class) + @JsonSerialize(using = LocalDateTimeSerializer.class) + LocalDateTime endTime; + + /** + * 回复情况0-未回复 1-已回复 + */ + Integer replyState; + /** + * 被通知单位机构编码 + */ + String notificationDepartCode; + /** + * 回复情况 + */ + String alarmContent; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java b/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java new file mode 100644 index 0000000..369ca6f --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/BlamePerson.java @@ -0,0 +1,30 @@ +package com.biutag.supervision.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; + +/** + * @author kami on 2024-11-16 17:28:03 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@Builder +@Slf4j +@AllArgsConstructor +@NoArgsConstructor(force = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class BlamePerson implements Serializable { + + String blameIdCode; + + String blameName; + + Integer number; +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/GobalMapIconVo.java b/src/main/java/com/biutag/supervision/pojo/vo/GobalMapIconVo.java index bf86ee3..ce79513 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/GobalMapIconVo.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/GobalMapIconVo.java @@ -1,6 +1,7 @@ package com.biutag.supervision.pojo.vo; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; @@ -12,6 +13,7 @@ import lombok.NoArgsConstructor; @Data @AllArgsConstructor @NoArgsConstructor +@Builder public class GobalMapIconVo { private String name; // 分县市局名称 @@ -21,6 +23,7 @@ public class GobalMapIconVo { private Integer mailPro; // 信访投诉问题 private Integer policePro; // 警务评议问题 private Integer reviewPro; // 审计监督问题 + private Integer departId; // 分县市局ID } diff --git a/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceStatisticsVo.java b/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceStatisticsVo.java new file mode 100644 index 0000000..60e7b87 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceStatisticsVo.java @@ -0,0 +1,35 @@ +package com.biutag.supervision.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; + +/** + * @author kami on 2024-11-16 15:06:25 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@Builder +@Slf4j +@AllArgsConstructor +@NoArgsConstructor(force = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProblemSourceStatisticsVo implements Serializable { + + Integer aTotal; + + Integer caseTotal; + + Integer negativeTotal; + + Integer peopleCount; + + Double avgPeople; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceVo.java b/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceVo.java new file mode 100644 index 0000000..95e3034 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/ProblemSourceVo.java @@ -0,0 +1,31 @@ +package com.biutag.supervision.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; + +/** + * @author kami on 2024-11-16 15:06:25 + * @version 0.0.1 + * @since 1.8 + */ +@Data +@Builder +@Slf4j +@AllArgsConstructor +@NoArgsConstructor(force = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProblemSourceVo implements Serializable { + + String name; + + String id; + + Integer number; + +} diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RankVo.java b/src/main/java/com/biutag/supervision/pojo/vo/RankVo.java index 10aed34..fc8c3c1 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/RankVo.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/RankVo.java @@ -12,7 +12,7 @@ public class RankVo { private String label; // 部门名称 private String departId; // 部门id - private Integer value; // 数量 + private Double value; // 整改率 private Double rate; // 整改率 private String numerator; // 分子 已整改 private String denominator; // 分母 问题数 diff --git a/src/main/java/com/biutag/supervision/service/AlarmNotificationService.java b/src/main/java/com/biutag/supervision/service/AlarmNotificationService.java new file mode 100644 index 0000000..60f9493 --- /dev/null +++ b/src/main/java/com/biutag/supervision/service/AlarmNotificationService.java @@ -0,0 +1,42 @@ +package com.biutag.supervision.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.biutag.supervision.mapper.AlarmNotificationMapper; +import com.biutag.supervision.pojo.entity.AlarmNotification; +import com.biutag.supervision.pojo.entity.BaseUser; +import com.biutag.supervision.pojo.model.UserModel; +import com.biutag.supervision.pojo.param.AlarmParam; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; + +/** + * @author kami on 2024-11-16 11:07:43 + * @version 0.0.1 + * @since 1.8 + */ +@Service +public class AlarmNotificationService extends ServiceImpl { + + public Page pages(AlarmParam param) { + LambdaQueryWrapper query = new LambdaQueryWrapper(); + if(param.getAlarmTypeId() != null && param.getAlarmTypeId() != -1) { + query.eq(AlarmNotification::getAlarmTypeId, param.getAlarmTypeId()); + } + if(param.getStartTime() != null) { + query.between(AlarmNotification::getAlarmTime, param.getStartTime(), param.getEndTime()); + } + if(param.getReplyState() != null && param.getReplyState() != -1) { + query.eq(AlarmNotification::getReplyState, param.getReplyState()); + } + if(param.getNotificationDepartCode() != null) { + query.eq(AlarmNotification::getNotificationDepartCode, param.getNotificationDepartCode()); + } + if(param.getAlarmContent() != null) { + query.like(AlarmNotification::getAlarmContent, param.getAlarmContent()); + } + return page(Page.of(param.getCurrent(), param.getSize()), query.orderByDesc(AlarmNotification::getAlarmTime)); + } +} diff --git a/src/main/java/com/biutag/supervision/service/DataGobalService.java b/src/main/java/com/biutag/supervision/service/DataGobalService.java index 6f02de2..be99c18 100644 --- a/src/main/java/com/biutag/supervision/service/DataGobalService.java +++ b/src/main/java/com/biutag/supervision/service/DataGobalService.java @@ -3,18 +3,17 @@ package com.biutag.supervision.service; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.biutag.supervision.constants.enums.InspectCaseEnum; -import com.biutag.supervision.mapper.DataCaseVerifMapper; -import com.biutag.supervision.mapper.DataSupervisionNotifyMapper; -import com.biutag.supervision.mapper.NegativeMapper; -import com.biutag.supervision.mapper.NegativeProblemRelationMapper; +import com.biutag.supervision.mapper.*; import com.biutag.supervision.pojo.dto.CaseVerifDepart; import com.biutag.supervision.pojo.entity.DataCaseVerif; import com.biutag.supervision.pojo.entity.DataSupervisionNotify; import com.biutag.supervision.pojo.entity.Negative; +import com.biutag.supervision.pojo.entity.SupDepart; import com.biutag.supervision.pojo.vo.*; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -31,6 +30,7 @@ public class DataGobalService { private final NegativeMapper negativeMapper; private final NegativeProblemRelationMapper negativeProblemRelationMapper; + private final SupDepartMapper supDepartMapper; /** * 获取所有大屏统计数据 @@ -43,36 +43,36 @@ public class DataGobalService { // 督察问题数量(查实版本) Long supervisionPro = getCountByConditions( - Integer.parseInt(InspectCaseEnum.TRUE.getValue()), + Integer.parseInt(InspectCaseEnum.FALSE.getValue()), beginTime, endTime, 13, 15, 16); // 获取案件核查问题数量(查实版本) Long caseVerificationPro = getCountByConditions( - Integer.parseInt(InspectCaseEnum.TRUE.getValue()), + Integer.parseInt(InspectCaseEnum.FALSE.getValue()), beginTime, endTime, 17, 18, 19, 20); // 信访投诉问题数量(查实版本) Long complaintPro = getCountByConditions( - Integer.parseInt(InspectCaseEnum.TRUE.getValue()), + Integer.parseInt(InspectCaseEnum.FALSE.getValue()), beginTime, endTime, 21, 22, 23, 24, 25); // 警务评议问题数量(查实版本) - Long reviewPro = getCountByConditions( - Integer.parseInt(InspectCaseEnum.TRUE.getValue()), + Long talkPro = getCountByConditions( + Integer.parseInt(InspectCaseEnum.FALSE.getValue()), beginTime, endTime, 2); // 审计监督问题数量(查实版本) Long auditPro = getCountByConditions( - Integer.parseInt(InspectCaseEnum.TRUE.getValue()), + Integer.parseInt(InspectCaseEnum.FALSE.getValue()), beginTime, endTime, 26); - Long totalPro = caseVerificationPro + supervisionPro + complaintPro + reviewPro + auditPro; + Long totalPro = caseVerificationPro + supervisionPro + complaintPro + talkPro + auditPro; JSONObject overview = new JSONObject(); overview.fluentPut("totalPro", totalPro) - .fluentPut("caseVerificationPro", caseVerificationPro) .fluentPut("supervisionPro", supervisionPro) + .fluentPut("caseVerificationPro", caseVerificationPro) .fluentPut("complaintPro", complaintPro) - .fluentPut("reviewPro", reviewPro) + .fluentPut("talkPro", talkPro) .fluentPut("auditPro", auditPro); return overview; } @@ -80,6 +80,7 @@ public class DataGobalService { /** * 查询核查属实的公共方法 + * * @param checkStatus 检查状态 * @param startTime 开始时间 * @param endTime 结束时间 @@ -88,7 +89,7 @@ public class DataGobalService { */ public Long getCountByConditions(Integer checkStatus, Date startTime, Date endTime, Integer... problemSourcesCodes) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("checkStatus", checkStatus) + queryWrapper.ne("checkStatus", checkStatus) .between("discoveryTime", startTime, endTime) .and(wrapper -> { for (int i = 0; i < problemSourcesCodes.length; i++) { @@ -107,24 +108,25 @@ public class DataGobalService { return res; } - public List getBusinessRate(Date beginTime,Date endTime) { - List res= negativeMapper.selectBusinessRate(beginTime, endTime); + public List getBusinessRate(Date beginTime, Date endTime) { + List res = negativeMapper.selectBusinessRate(beginTime, endTime); return res; } public List getGobalRecentlyTrendByMonth(String year) { - List res = negativeMapper.selectRecentTrendByMonth(year); + List res = negativeMapper.selectRecentTrendByMonth(year); return res; } /** * 获取问题类型占比 + * * @param beginTime * @param endTime * @return */ public List getProblemRate(Date beginTime, Date endTime) { - List res = negativeProblemRelationMapper.selectProblemRate(beginTime, endTime); + List res = negativeProblemRelationMapper.selectProblemRate(beginTime, endTime); return res; } @@ -134,36 +136,39 @@ public class DataGobalService { */ public List getStrongProblemRank(Date beginTime, Date endTime) { // 1.获取这段时间的negative id - List res= negativeProblemRelationMapper.selectStrongProblemRank(beginTime, endTime); + List res = negativeProblemRelationMapper.selectStrongProblemRank(beginTime, endTime); for (int i = 1; i <= res.size(); i++) { res.get(i - 1).setSort(i); } return res; } - public List getSuperviseProTotal(Date beginTime, Date endTime) { - List res= negativeProblemRelationMapper.selectSuperviseProTotal(beginTime, endTime); - return res; - } - public List getCaseVerifyProTotal(Date beginTime, Date endTime) { - List res= negativeProblemRelationMapper.selectCaseVerifyProTotal(beginTime, endTime); - return res; - } - public List getMailProTotal(Date beginTime, Date endTime) { - List res= negativeProblemRelationMapper.selectMailProTotal(beginTime, endTime); - return res; - } - - public List getPoliceProTotal(Date beginTime, Date endTime) { - List res= negativeProblemRelationMapper.selectPoliceProTotal(beginTime, endTime); - return res; - } - - - public List getReviewProTotal(Date beginTime, Date endTime) { - List res= negativeProblemRelationMapper.selectReviewProTotal(beginTime, endTime); + public List getMapIconInfo(Date beginTime, Date endTime) { + List res = new ArrayList<>(); + List supDeparts = supDepartMapper.selectDepartsByGroupType(3); + for (SupDepart supDepart : supDeparts) { + GobalMapIconVo mapIconVo = new GobalMapIconVo(); + mapIconVo.setName(supDepart.getShortName()); + mapIconVo.setDepartId(Integer.parseInt(supDepart.getId())); + res.add(mapIconVo); + } + for (GobalMapIconVo re : res) { + Integer departId = re.getDepartId(); + Integer supervisePro = negativeMapper.seleGobalMapIconInfoDc(beginTime, endTime, departId); + Integer caseVerifyPro = negativeMapper.seleGobalMapIconInfoAjhc(beginTime, endTime, departId); + Integer mailPro = negativeMapper.seleGobalMapIconInfoXf(beginTime, endTime, departId); + Integer policePro = negativeMapper.seleGobalMapIconInfoJwpy(beginTime, endTime, departId); + Integer reviewPro = negativeMapper.seleGobalMapIconInfoSjdc(beginTime, endTime, departId); + Integer totalPro = supervisePro + caseVerifyPro + mailPro + policePro + reviewPro; + re.setTotalPro(totalPro != null ? totalPro : 0); + re.setSupervisePro(supervisePro != null ? supervisePro : 0); + re.setCaseVerifyPro(caseVerifyPro != null ? caseVerifyPro : 0); + re.setMailPro(mailPro != null ? mailPro : 0); + re.setPolicePro(policePro != null ? policePro : 0); + re.setReviewPro(reviewPro != null ? reviewPro : 0); + } return res; } } diff --git a/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java index d7440c8..3b2d21b 100644 --- a/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java @@ -16,6 +16,7 @@ import com.biutag.supervision.pojo.entity.DataSupervisionNotify; import com.biutag.supervision.pojo.entity.Negative; import com.biutag.supervision.pojo.entity.NegativeBlame; import com.biutag.supervision.pojo.entity.SupDepart; +import com.biutag.supervision.pojo.vo.EchartsVo; import com.biutag.supervision.pojo.vo.RankVo; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -23,6 +24,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * @author 舒云 @@ -69,7 +71,7 @@ public class DataSupervisionNotifyServiceImpl extends ServiceImpl preQueryWrapper = new QueryWrapper<>(); - preQueryWrapper.eq("problemSourcesCode", ProblemSourcesEnum.XCDC.getValue()); + preQueryWrapper.in("problemSourcesCode", ProblemSourcesEnum.XCDC.getValue(), ProblemSourcesEnum.ZXDC.getValue()); List negatives = negativeMapper.selectList(preQueryWrapper); Long supervisionNotifyPreTotal = 0L; @@ -81,8 +83,6 @@ public class DataSupervisionNotifyServiceImpl extends ServiceImpl getChangedRateRank(Integer groupType, Date beginTime, Date endTime) { - List rankVos = new ArrayList<>(); + List rankVoRes = new ArrayList<>(); + // 所有分局部门 List departs = supDepartMapper.selectDepartsByGroupType(groupType); -// negativeMapper.select + for (SupDepart depart : departs) { + RankVo rankVo = new RankVo(); + rankVo.setLabel(depart.getShortName()); + rankVo.setDepartId(depart.getId()); + rankVoRes.add(rankVo); + } + for (RankVo rankVoRe : rankVoRes) { + String departId = rankVoRe.getDepartId(); + Long changed = negativeMapper.getChangedCountByGroupType(beginTime, endTime, departId); + Long totalPro = negativeMapper.getCountByGroupType(beginTime, endTime, departId); + totalPro = totalPro == null ? 0L : totalPro; + changed = changed == null ? 0L : changed; + rankVoRe.setDenominator(totalPro.toString()); + rankVoRe.setNumerator(changed.toString()); + Double rate = totalPro != 0 ? (changed * 1.0 / totalPro) * 100 : 0; + int intRate = (int) Math.ceil(rate); + rankVoRe.setRate((double) intRate); + rankVoRe.setDenominator(totalPro.toString()); + rankVoRe.setNumerator(changed.toString()); + rankVoRe.setRate(rate); + rankVoRe.setValue(rate); + } + // 使用 Stream API 进行排序 + rankVoRes = rankVoRes.stream().sorted((o1, o2) -> o2.getRate().compareTo(o1.getRate())).collect(Collectors.toList()); + // 排序 + return rankVoRes; + } + public List getProblemTypeRatio(Date beginTime, Date endTime) { + List echartsVos = new ArrayList<>(); return null; } diff --git a/src/main/java/com/biutag/supervision/service/ProblemSourceService.java b/src/main/java/com/biutag/supervision/service/ProblemSourceService.java new file mode 100644 index 0000000..9ed34b3 --- /dev/null +++ b/src/main/java/com/biutag/supervision/service/ProblemSourceService.java @@ -0,0 +1,215 @@ +package com.biutag.supervision.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.biutag.supervision.mapper.*; +import com.biutag.supervision.pojo.entity.*; +import com.biutag.supervision.pojo.vo.BlamePerson; +import com.biutag.supervision.pojo.vo.ProblemSourceStatisticsVo; +import com.biutag.supervision.pojo.vo.ProblemSourceVo; +import com.biutag.supervision.util.CompletableUtils.CompletableFutureUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 灵敏感知大屏 + * + * @author kami on 2024-11-16 15:04:16 + * @version 0.0.1 + * @since 1.8 + */ +@Slf4j +@Service +@AllArgsConstructor +public class ProblemSourceService { + + private final BusinessDepartMapper businessDepartMapper; + + private final NegativeMapper negativeMapper; + + private final NegativeBlameMapper blameMapper; + + /** + * 数量统计 + * + * @return 统计结构 + */ + public ProblemSourceStatisticsVo totalStatistics() { + ProblemSourceStatisticsVo.ProblemSourceStatisticsVoBuilder build = ProblemSourceStatisticsVo.builder(); + CompletableFuture.allOf( + CompletableFutureUtil.runSyncObject(() -> build.aTotal(businessDepartMapper.problemSum(List.of(1, 2), "2024-01-01 00:00:00"))), + CompletableFutureUtil.runSyncObject(() -> build.caseTotal(businessDepartMapper.problemSum(List.of(4, 5, 6), "2024-01-01 00:00:00"))), + CompletableFutureUtil.runSyncObject(() -> build.negativeTotal(negativeMapper.selectCount(new LambdaQueryWrapper().in(Negative::getCheckStatus, List.of(1, 2))).intValue())) + ).join(); + List list = blameMapper.selectList(new LambdaQueryWrapper().select(NegativeBlame::getBlameIdCode)); + Long count = list.stream().map(NegativeBlame::getBlameIdCode).distinct().count(); + build.peopleCount(count.intValue()); + ProblemSourceStatisticsVo vo = build.build(); + vo.setAvgPeople(new BigDecimal(vo.getNegativeTotal().toString()).divide(new BigDecimal(vo.getPeopleCount().toString()), 2, RoundingMode.UP).doubleValue()); + return vo; + } + + private final SupDepartMapper supDepartMapper; + + /** + * @param type 类型 1- 风险值 2- 问题数 3-问题发生率 + * @param businessType + */ + public void rankStatistics(Integer type, Integer businessType) { + List departs = supDepartMapper.selectList(new LambdaQueryWrapper() + .select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel)); + Map departMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + + Map mapLevel3 = new HashMap<>(); + Map mapLevel2 = new HashMap<>(); + + for (Negative negative : negatives) { + SupDepart depart = departMap.get(negative.getInvolveDepartId()); + if (depart == null) { + continue; + } + if (depart.getLevel() == 3) { + Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + depart = departMap.get(depart.getPid()); + } + if (depart.getLevel() == 2) { + Integer count = Optional.ofNullable(mapLevel2.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel2.put(negative.getInvolveDepartId(), count); + } + } + } + + private final StatisticsGroupMapper statisticsGroupMapper; + + private final StatisticsDepartMapper departMapper; + + public void statisticsGroupRank() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "交警大队").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + Map mapLevel3 = new HashMap<>(); + for (Negative negative : negatives) { + if (departMap.get(negative.getInvolveDepartId()) == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + /** + * 派出所 + */ + public void statisticsGroupRank2() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "派出所").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + Map mapLevel3 = new HashMap<>(); + for (Negative negative : negatives) { + if (departMap.get(negative.getInvolveDepartId()) == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(negative.getInvolveDepartId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", departMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + // 分县 + public void statisticsGroupRank3() { + StatisticsGroup group = statisticsGroupMapper.selectOne(new LambdaQueryWrapper() + .eq(StatisticsGroup::getName, "派出所").last("limit 1")); + + List list = departMapper.selectList(new LambdaQueryWrapper() + .eq(StatisticsDepart::getLevel, 3) + .eq(StatisticsDepart::getGroupId, group.getGroupId())); + Map departMap = list.stream().collect(Collectors.toMap(StatisticsDepart::getDepartId, Function.identity(), (oldValue, newValue) -> newValue)); + + List departs = supDepartMapper.selectList(new LambdaQueryWrapper() + .eq(SupDepart::getLevel, 2) + .select(SupDepart::getId, SupDepart::getPid, SupDepart::getName, SupDepart::getLevel)); + Map areaMap = departs.stream().collect(Collectors.toMap(SupDepart::getId, Function.identity(), (oldValue, newValue) -> newValue)); + + List negatives = negativeMapper.selectList(new LambdaQueryWrapper() + .in(Negative::getCheckStatus, List.of(1, 2))); + Map mapLevel3 = new HashMap<>(); + for (Negative negative : negatives) { + StatisticsDepart depart = departMap.get(negative.getInvolveDepartId()); + if (depart == null) { + continue; + } + SupDepart area = areaMap.get(depart.getPid()); + if (area == null) { + continue; + } + Integer count = Optional.ofNullable(mapLevel3.get(area.getId())).orElse(0); + count++; + mapLevel3.put(negative.getInvolveDepartId(), count); + } + for (Map.Entry entry : mapLevel3.entrySet()) { + log.info("机构:{} | {}", areaMap.get(entry.getKey()).getName(), entry.getValue()); + } + } + + + /** + * 民警、辅警 + */ + public void personStatistics() { + List list = blameMapper.statisticsBlame(); + + List list2 = blameMapper.statisticsBlame2(); + + List list3 = blameMapper.statisticsBlame3(); + + + for (BlamePerson blamePerson : list) { + log.info("民警:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } + for (BlamePerson blamePerson : list2) { + log.info("辅警:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } + for (BlamePerson blamePerson : list3) { + log.info("领导:{} | {}", blamePerson.getBlameName(), blamePerson.getNumber()); + } + } + +} diff --git a/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureMine.java b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureMine.java new file mode 100644 index 0000000..3199620 --- /dev/null +++ b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureMine.java @@ -0,0 +1,13 @@ +package com.biutag.supervision.util.CompletableUtils; + +/** + * @author kami + * @version 1.0 + * @since 2021/11/22 17:37 + */ +@FunctionalInterface +public interface CompletableFutureMine { + + void run(); + +} diff --git a/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureResult.java b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureResult.java new file mode 100644 index 0000000..1dc42ab --- /dev/null +++ b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureResult.java @@ -0,0 +1,13 @@ +package com.biutag.supervision.util.CompletableUtils; + +/** + * @author kami + * @version 1.0 + * @since 2021/11/22 17:37 + */ +@FunctionalInterface +public interface CompletableFutureResult { + + Boolean run(); + +} diff --git a/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureType.java b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureType.java new file mode 100644 index 0000000..19ef192 --- /dev/null +++ b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureType.java @@ -0,0 +1,13 @@ +package com.biutag.supervision.util.CompletableUtils; + +/** + * @author kami + * @version 1.0 + * @since 2021/11/22 17:37 + */ +@FunctionalInterface +public interface CompletableFutureType { + + T run(); + +} diff --git a/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureUtil.java b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureUtil.java new file mode 100644 index 0000000..d38c5bf --- /dev/null +++ b/src/main/java/com/biutag/supervision/util/CompletableUtils/CompletableFutureUtil.java @@ -0,0 +1,164 @@ +package com.biutag.supervision.util.CompletableUtils; + + +import lombok.extern.slf4j.Slf4j; +import org.slf4j.MDC; + +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +/** + * @author kami + * @version 1.0 + * @since 2021/11/22 17:39 + */ +@Slf4j +public class CompletableFutureUtil { + + private CompletableFutureUtil(){} + + public static final String TRACE_ID = "trace_id"; + + private static void run(CompletableFutureMine completableFutureMine, Map previous) { + if (previous == null) { + MDC.clear(); + } else { + MDC.setContextMap(previous); + } + if (MDC.get(TRACE_ID) == null || MDC.get(TRACE_ID).isEmpty()) { + MDC.put(TRACE_ID, System.nanoTime() + ""); + } + completableFutureMine.run(); + MDC.clear(); + } + + private static Boolean runResult(CompletableFutureResult result, Map previous) { + if (previous == null) { + MDC.clear(); + } else { + MDC.setContextMap(previous); + } + if (MDC.get(TRACE_ID) == null || MDC.get(TRACE_ID).isEmpty()) { + MDC.put(TRACE_ID, System.nanoTime() + ""); + } + Boolean rs = result.run(); + MDC.clear(); + return rs; + } + + public static void runSync(CompletableFutureMine completableFutureMine) { + Map previous = MDC.getCopyOfContextMap(); + CompletableFuture.runAsync(() -> run(completableFutureMine, previous)).exceptionally(e -> { + log.error("",e); + MDC.clear(); + return null; + }); + } + + public static CompletableFuture runSyncObject(CompletableFutureMine completableFutureMine) { + Map previous = MDC.getCopyOfContextMap(); + return CompletableFuture.runAsync(() -> { + if (previous == null) { + MDC.clear(); + } else { + MDC.setContextMap(previous); + } + if (MDC.get(TRACE_ID) == null || MDC.get(TRACE_ID).isEmpty()) { + MDC.put(TRACE_ID, System.nanoTime() + ""); + } + run(completableFutureMine, previous); + MDC.clear(); + }).exceptionally(e -> { + log.error("",e); + MDC.clear(); + return null; + }); + } + + public static void run(CompletableFutureMine completableFutureMine) { + Map previous = MDC.getCopyOfContextMap(); + CompletableFuture.runAsync(() -> run(completableFutureMine, previous)).exceptionally(e -> { + log.error("",e); + MDC.clear(); + return null; + }).join(); + } + + public static void runSyncEach(CompletableFutureResult result, Long time) { + Map previous = MDC.getCopyOfContextMap(); + CompletableFuture.runAsync(() -> { + Boolean goOn = true; + while (Boolean.TRUE.equals(goOn)) { + try { + TimeUnit.SECONDS.sleep(time); + } catch (InterruptedException e) { + log.error("",e); + Thread.currentThread().interrupt(); + } + goOn = runResult(result, previous); + } + }).exceptionally(e -> { + log.error("",e); + MDC.clear(); + return null; + }); + } + + public static void runSyncEach(CompletableFutureResult result, Executor ex, Long time) { + Map previous = MDC.getCopyOfContextMap(); + CompletableFuture.runAsync(() -> { + Boolean goOn = true; + while (goOn) { + try { + TimeUnit.SECONDS.sleep(time); + } catch (InterruptedException e) { + log.error("",e); + Thread.currentThread().interrupt(); + } + goOn = runResult(result, previous); + } + }, ex).exceptionally(e -> { + log.error("",e); + MDC.clear(); + return null; + }); + } + + public static void runSync(CompletableFutureMine completableFutureMine, Executor ex) { + Map previous = MDC.getCopyOfContextMap(); + CompletableFuture.runAsync(() -> run(completableFutureMine, previous), ex).exceptionally(e -> { + log.error("", e); + MDC.clear(); + return null; + }); + } + + public static void runSyncAssert(Boolean assets, CompletableFutureMine completableFutureMine) { + if(Boolean.TRUE.equals(assets)) { + CompletableFuture.runAsync(completableFutureMine::run).exceptionally(e -> { + log.error("",e); + return null; + }); + } + } + + public static CompletableFuture createRunner(CompletableFutureType completableFutureType) { + Map previous = MDC.getCopyOfContextMap(); + return CompletableFuture.supplyAsync(() -> { + if (previous == null) { + MDC.clear(); + } else { + MDC.setContextMap(previous); + } + if (MDC.get(TRACE_ID) == null || MDC.get(TRACE_ID).isEmpty()) { + MDC.put(TRACE_ID, System.nanoTime() + ""); + } + T t = completableFutureType.run(); + MDC.clear(); + return t; + }); + } +} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..39b0463 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,62 @@ + + + logs + + + + + + + + + + + + ${log.colorPattern} + UTF-8 + + + + + + + ${log.path}/info/info.%d{yyyy-MM-dd}.log + ${log.maxHistory} + + + ${log.pattern} + + + INFO + ACCEPT + DENY + + + + + + ${log.path}/error/error.%d{yyyy-MM-dd}.log + ${log.maxHistory} + + + ${log.pattern} + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/AlarmNotificationMapper.xml b/src/main/resources/mapper/AlarmNotificationMapper.xml new file mode 100644 index 0000000..748b212 --- /dev/null +++ b/src/main/resources/mapper/AlarmNotificationMapper.xml @@ -0,0 +1,7 @@ + + + + +