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 1eeb90f..30a5b18 100644 --- a/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java +++ b/src/main/java/com/biutag/supervision/controller/datav/SupervisionNotifyController.java @@ -2,10 +2,7 @@ package com.biutag.supervision.controller.datav; import com.alibaba.fastjson.JSONObject; import com.biutag.supervision.pojo.Result; -import com.biutag.supervision.pojo.vo.EchartsVo; -import com.biutag.supervision.pojo.vo.GobalMapIconVo; -import com.biutag.supervision.pojo.vo.RankVo; -import com.biutag.supervision.pojo.vo.SuperviseMapIconVo; +import com.biutag.supervision.pojo.vo.*; import com.biutag.supervision.service.DataSupervisionNotifyServiceImpl; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -21,6 +18,7 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Map; /** * @Auther: sh @@ -53,8 +51,17 @@ public class SupervisionNotifyController { //地图数据 List superviseTempMapVoList = dataSupervisionNotifyService.getsupervisionMapIconInfo(beginTime, endTime); + + // 黄赌毒总览 + List hddzlList = dataSupervisionNotifyService.getYellowBet(beginTime, endTime); + + // 黄毒赌列表 + List hddList = dataSupervisionNotifyService.getYellowBet(beginTime, endTime); + JSONObject data = new JSONObject().fluentPut("wtlxList", wtlxList) - .fluentPut("overview", overview); + .fluentPut("overview", overview) + .fluentPut("superviseTempMapVoList", superviseTempMapVoList) + .fluentPut("hddList", hddList); return Result.success(data); } @@ -70,8 +77,23 @@ public class SupervisionNotifyController { public Result getChangedRank(@RequestParam Integer groupType, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date beginTime, @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) { - JSONObject rankOverview = dataSupervisionNotifyService.getDailySupervisionCount(groupType, beginTime, endTime); - List changedRankList = dataSupervisionNotifyService.getChangedRateRank(groupType, beginTime, endTime); + RankVoSup temp = dataSupervisionNotifyService.getSuperversionRank( beginTime, endTime); + JSONObject rankOverview=new JSONObject(); + if ( temp != null) { + rankOverview + .fluentPut("proTotal", temp.getProblem_number()) + .fluentPut("changing", temp.getRectifing_number()) + .fluentPut("changed", temp.getRectifed_number()) + .fluentPut("correctionRate", temp.getRectify_rate()); + }else { + rankOverview + .fluentPut("proTotal",0) + .fluentPut("changing", 0) + .fluentPut("changed", 0) + .fluentPut("correctionRate", 0); + } + List changedRankList = dataSupervisionNotifyService.getChangedRateRank(groupType, beginTime, endTime); + JSONObject data = new JSONObject() .fluentPut("rankOverview", rankOverview) .fluentPut("changedRankList", changedRankList); diff --git a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java index 74d2adb..d1a1dc0 100644 --- a/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java +++ b/src/main/java/com/biutag/supervision/mapper/NegativeMapper.java @@ -3,10 +3,7 @@ package com.biutag.supervision.mapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.supervision.pojo.entity.Negative; -import com.biutag.supervision.pojo.vo.EchartsVo; -import com.biutag.supervision.pojo.vo.OrganizeProblemRankVo; -import com.biutag.supervision.pojo.vo.RankVo; -import com.biutag.supervision.pojo.vo.RecentTrendByMonthVo; +import com.biutag.supervision.pojo.vo.*; import org.apache.ibatis.annotations.Select; import java.util.Date; @@ -240,6 +237,37 @@ public interface NegativeMapper extends BaseMapper { @Select("") Long getRelationOrgCountByDepartId(String departId); + @Select("SELECT a.departId, a.name, COUNT(DISTINCT c.id) AS totalPro, COUNT(DISTINCT IF(c.isRectifyCode = 0, c.id, 0)) - 1 AS changing, COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1 AS changed, COUNT(DISTINCT c.involveDepartId) AS relationOrg, COUNT(DISTINCT d.blameIdCode) AS personNum, ROUND((COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1) / COUNT(DISTINCT c.id) * 100, 1) AS changedRate\n" + + "FROM statistics_depart a INNER JOIN sup_depart b ON a.departId = b.pid " + + " INNER JOIN negative c ON b.id = c.involveDepartId " + + " LEFT JOIN negative_blame d ON c.id = d.negativeId " + + "WHERE a.groupId = 3 AND discoveryTime BETWEEN #{beginTime} AND #{endTime} AND checkStatus IN ('1', '2') AND problemSourcesCode IN (13, 15) " + + "GROUP BY a.name, a.departId") + List getMap(Date beginTime, Date endTime); + + @Select("SELECT a.name, COUNT(DISTINCT c.id) AS problem_number, COUNT(DISTINCT IF(c.isRectifyCode = 0, c.id, 0)) - 1 AS rectifing_number, COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1 AS rectifed_number, COUNT(DISTINCT c.involveDepartId) AS depart_number, COUNT(DISTINCT d.blameIdCode) AS person_number, ROUND((COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1) / COUNT(DISTINCT c.id) * 100, 1) AS rectify_rate\n" + + "FROM statistics_depart a INNER JOIN sup_depart b ON a.departId = b.pid " + + " INNER JOIN negative c ON b.id = c.involveDepartId " + + " LEFT JOIN negative_blame d ON c.id = d.negativeId " + + "WHERE a.groupId = 3 AND discoveryTime BETWEEN #{beginTime} AND #{endTime} AND checkStatus IN ('1', '2') AND special_supervision = 1\n" + + "GROUP BY a.name") + List getYellowBet(Date beginTime, Date endTime); + + @Select("SELECT COUNT(DISTINCT c.id) AS problem_number, COUNT(DISTINCT IF(c.isRectifyCode = 0, c.id, 0)) - 1 AS rectifing_number, COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1 AS rectifed_number, COUNT(DISTINCT c.involveDepartId) AS depart_number, COUNT(DISTINCT d.blameIdCode) AS person_number, ROUND((COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1) / COUNT(DISTINCT c.id) * 100, 1) AS rectify_rate\n" + + "FROM sup_depart b INNER JOIN negative c ON b.id = c.involveDepartId " + + " LEFT JOIN negative_blame d ON c.id = d.negativeId " + + "WHERE discoveryTime BETWEEN #{beginTime} AND #{endTime} AND checkStatus IN ('1', '2') AND problemSourcesCode = 13 ") + RankVoSup getSuperversionRank(Date beginTime, Date endTime); + + + @Select("SELECT a.name, COUNT(DISTINCT c.id) AS problem_number, COUNT(DISTINCT IF(c.isRectifyCode = 0, c.id, 0)) - 1 AS rectifing_number, COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1 AS rectifed_number, COUNT(DISTINCT c.involveDepartId) AS depart_number, COUNT(DISTINCT d.blameIdCode) AS person_number, ROUND((COUNT(DISTINCT IF(c.isRectifyCode = 1, c.id, 0)) - 1) / COUNT(DISTINCT c.id) * 100, 1) AS rectify_rate\n" + + "FROM statistics_depart a INNER JOIN sup_depart b ON a.departId = b.pid \n" + + " INNER JOIN negative c ON b.id = c.involveDepartId \n" + + " LEFT JOIN negative_blame d ON c.id = d.negativeId\n" + + "WHERE a.groupId = 3 AND discoveryTime BETWEEN #{beginTime} AND #{endTime} AND checkStatus IN ('1', '2') AND problemSourcesCode = 13\n" + + "GROUP BY a.name") + List getChangedRateRank(Date beginTime, Date endTime); + // endregion diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RankVoSup.java b/src/main/java/com/biutag/supervision/pojo/vo/RankVoSup.java new file mode 100644 index 0000000..47c43ff --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/RankVoSup.java @@ -0,0 +1,19 @@ +package com.biutag.supervision.pojo.vo; + +import lombok.Data; + +/** + * @Auther: sh + * @Date: 2024/11/17 01:35 + * @Description: + */ +@Data +public class RankVoSup { + private String problem_number; // 问题数 + private String rectifing_number; // 整改中 + private String rectifed_number; // 已整改 + private String depart_number; // 部门数 + private String person_number; // 人员数 + private String rectify_rate; // 整改率 +} + diff --git a/src/main/java/com/biutag/supervision/pojo/vo/RankVoSupTwo.java b/src/main/java/com/biutag/supervision/pojo/vo/RankVoSupTwo.java new file mode 100644 index 0000000..92cb8d6 --- /dev/null +++ b/src/main/java/com/biutag/supervision/pojo/vo/RankVoSupTwo.java @@ -0,0 +1,21 @@ +package com.biutag.supervision.pojo.vo; + +import lombok.Data; + +/** + * @Auther: sh + * @Date: 2024/11/17 01:35 + * @Description: + */ +@Data +public class RankVoSupTwo { + private String name; // 名字 + private String problem_number; // 问题数 + private String rectifing_number; // 整改中 + private String rectifed_number; // 已整改 + private String depart_number; // + private String person_number; // 人数 + private String rectify_rate; // 整改率 + +} + diff --git a/src/main/java/com/biutag/supervision/pojo/vo/SuperviseMapIconVo.java b/src/main/java/com/biutag/supervision/pojo/vo/SuperviseMapIconVo.java index 979cc00..0333343 100644 --- a/src/main/java/com/biutag/supervision/pojo/vo/SuperviseMapIconVo.java +++ b/src/main/java/com/biutag/supervision/pojo/vo/SuperviseMapIconVo.java @@ -15,6 +15,7 @@ public class SuperviseMapIconVo { private String changed; private String relationOrg; private String changedRate; + private String personNum; private String departId; } diff --git a/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java index 0fa804c..a84af52 100644 --- a/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java +++ b/src/main/java/com/biutag/supervision/service/DataSupervisionNotifyServiceImpl.java @@ -16,11 +16,9 @@ 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.GobalMapIconVo; -import com.biutag.supervision.pojo.vo.RankVo; -import com.biutag.supervision.pojo.vo.SuperviseMapIconVo; +import com.biutag.supervision.pojo.vo.*; import lombok.RequiredArgsConstructor; +import org.apache.poi.ss.formula.functions.Intercept; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -62,6 +60,7 @@ public class DataSupervisionNotifyServiceImpl extends ServiceImpl getChangedRateRank(Integer groupType, Date beginTime, Date endTime) { - List rankVoRes = new ArrayList<>(); - // 所有分局部门 - List departs = supDepartMapper.selectDepartsByGroupType(groupType); - for (SupDepart depart : departs) { + List rankVoRes = negativeMapper.getChangedRateRank(beginTime, endTime); + List res = new ArrayList<>(); + for (RankVoSupTwo one : rankVoRes) { 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); + rankVo.setLabel(one.getName()); + rankVo.setValue(Double.parseDouble(one.getRectify_rate())); + rankVo.setRate(Double.parseDouble(one.getRectify_rate())); + rankVo.setNumerator(one.getRectifed_number()); + rankVo.setDenominator(one.getRectifed_number()); + res.add(rankVo); } - // 使用 Stream API 进行排序 - rankVoRes = rankVoRes.stream().sorted((o1, o2) -> o2.getRate().compareTo(o1.getRate())).collect(Collectors.toList()); - // 排序 - return rankVoRes; + return res; } public List getProblemTypeRatio(Date beginTime, Date endTime) { - List echartsVos = new ArrayList<>(); - echartsVos = negativeMapper.getProblemTypes(beginTime, endTime); + List echartsVos = negativeMapper.getProblemTypes(beginTime, endTime); return echartsVos; } @@ -166,7 +147,6 @@ public class DataSupervisionNotifyServiceImpl extends ServiceImpl getsupervisionMapIconInfo(Date beginTime, Date endTime) { - List res = new ArrayList<>(); - List supDeparts = supDepartMapper.selectDepartsByGroupType(3); - for (SupDepart supDepart : supDeparts) { - SuperviseMapIconVo SuperviseMapIconVo = new SuperviseMapIconVo(); - SuperviseMapIconVo.setName(supDepart.getShortName()); - SuperviseMapIconVo.setDepartId(supDepart.getId()); - res.add(SuperviseMapIconVo); - } - for (SuperviseMapIconVo re : res) { - String departId = re.getDepartId(); - Long changed = negativeMapper.getNotifyChanged(beginTime, endTime, departId); - Long changing = negativeMapper.getNotifyChanging(beginTime, endTime, departId); - Long totalPro = changed + changing; - Long relationOrg = negativeMapper.getRelationOrgCountByDepartId(departId); - QueryWrapper preQueryWrapper = new QueryWrapper<>(); - preQueryWrapper.in("problemSourcesCode", ProblemSourcesEnum.XCDC.getValue(), ProblemSourcesEnum.ZXDC.getValue()); - List negatives = negativeMapper.selectList(preQueryWrapper); - Long supervisionNotifyPreTotal = 0L; - for (Negative negative : negatives) { - String id = negative.getId(); - QueryWrapper totalWrapper = new QueryWrapper<>(); - totalWrapper.eq("negativeId", id); - supervisionNotifyPreTotal += negativeBlameMapper.selectCount(totalWrapper); - } + List res = negativeMapper.getMap(beginTime, endTime); + return res; + } + + public List getYellowBet(Date beginTime, Date endTime) { + List res = negativeMapper.getYellowBet(beginTime, endTime); + List resv = new ArrayList<>(); + for (RankVoSupTwo re : res) { + RankVo rankVo = new RankVo(); + rankVo.setLabel(re.getName()); + rankVo.setValue(Double.parseDouble(re.getProblem_number())); + resv.add(rankVo); } - return null; + return resv; } - /** - * 涉及人数 - * 1、查出在 negative中的id集合 - * 2、查出集合在blame中的涉及人数 - */ - /*QueryWrapper preQueryWrapper = new QueryWrapper<>(); - preQueryWrapper.in("problemSourcesCode", ProblemSourcesEnum.XCDC.getValue(), ProblemSourcesEnum.ZXDC.getValue()); + public RankVoSup getSuperversionRank(Date beginTime, Date endTime) { + RankVoSup res = negativeMapper.getSuperversionRank(beginTime, endTime); + if (res == null) { + res=new RankVoSup(); + res.setRectify_rate("0"); + res.setProblem_number("0"); + res.setRectifing_number("0"); + res.setDepart_number("0"); + res.setPerson_number("0"); + res.setRectifed_number("0"); + + }else { + if (res.getProblem_number() == null) { + res.setRectifed_number("0"); + } + if (res.getRectifing_number() == null) { + res.setRectifing_number("0"); + } + if (res.getDepart_number() == null) { + res.setDepart_number("0"); + } + if (res.getRectify_rate() == null) { + res.setRectify_rate("0"); + } + if (res.getRectifed_number() == null) { + res.setRectifed_number("0"); - List negatives = negativeMapper.selectList(preQueryWrapper); - Long supervisionNotifyPreTotal = 0L; - for (Negative negative : negatives) { - String id = negative.getId(); - QueryWrapper totalWrapper = new QueryWrapper<>(); - totalWrapper.eq("negativeId", id); - supervisionNotifyPreTotal += negativeBlameMapper.selectCount(totalWrapper); - }*/ + } + if (res.getProblem_number() == null) { + res.setProblem_number("0"); + } + } + + return res; + } }