From cbe2a61dd87095a666fcd8d1f945b2b6d7e7f885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E7=88=B1=E5=AD=A6=E4=B9=A0=E7=9A=84=E7=9F=B3?= =?UTF-8?q?=E5=90=8C=E5=AD=A6?= <2936013465@qq.com> Date: Sat, 16 Nov 2024 16:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E7=9D=A3=E5=AF=9F=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/datav/DataGobalController.java | 2 +- .../supervision/mapper/NegativeMapper.java | 145 ++++++++++-------- .../mapper/NegativeProblemRelationMapper.java | 4 +- .../biutag/supervision/pojo/vo/RankVo.java | 2 +- .../DataSupervisionNotifyServiceImpl.java | 33 ++-- 5 files changed, 107 insertions(+), 79 deletions(-) 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 882d613..00c71df 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/DataGobalController.java @@ -63,7 +63,7 @@ public class DataGobalController { // 问题类型占比 List wtlxlist = dataGobalService.getProblemRate(beginTime, endTime); - // 查所有的市局 + // 地图数据 List gobalTempMapVoList = dataGobalService.getMapIconInfo(beginTime, endTime); if ( gobalTempMapVoList==null || gobalTempMapVoList.size() == 0) { gobalTempMapVoList = new ArrayList<>(); diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java index 5a072ee..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,20 +149,6 @@ 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 " + - "AND n.discoveryTime BETWEEN #{beginTime} AND #{endTime}") - Long getCountByGroupType(Integer groupType, Date beginTime, Date endTime); @@ -120,68 +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 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 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); - @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); - @Select("select id from negative where discovury_time between #{beginTime} and #{endTime}") - List selectNegativeIdsByTime(Date beginTime, Date endTime); // endregion } diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java index 31f09bd..44cd53b 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeProblemRelationMapper.java @@ -19,7 +19,7 @@ public interface NegativeProblemRelationMapper extends BaseMapper3 " + @@ -37,7 +37,7 @@ public interface NegativeProblemRelationMapper extends BaseMapper3 " + 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/DataSupervisionNotifyServiceImpl.java b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java index b9f4b39..0f106bc 100644 --- a/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java @@ -23,6 +23,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * @author 舒云 @@ -101,10 +102,9 @@ 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); for (SupDepart depart : departs) { RankVo rankVo = new RankVo(); rankVo.setLabel(depart.getShortName()); rankVo.setDepartId(depart.getId()); + rankVoRes.add(rankVo); } - - - - - return null; + 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; + 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; } }