From 21e7d491658dbd969adbcf0bc2f13a5d563ab863 Mon Sep 17 00:00:00 2001 From: 16639036659 <577530412@qq.com> Date: 星期四, 25 四月 2024 13:25:35 +0800 Subject: [PATCH] SPI数据,隐患等级饼图信息独立出来,调整查询方式 --- src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java | 20 ++++++++++ src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml | 5 ++ src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java | 6 +++ src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java | 4 ++ src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java | 12 ------ src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java | 45 ++++++++++++++++++---- src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataForPieChartRespDTO.java | 20 ++++++++++ 7 files changed, 91 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java b/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java index 79fc09e..92433a0 100644 --- a/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java +++ b/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java @@ -1,8 +1,10 @@ package com.ruoyi.doublePrevention.controller; +import com.ruoyi.doublePrevention.entity.SPI.SPIDataForPieChartRespDTO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataRespDTO; +import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; import com.ruoyi.doublePrevention.service.SPIDataCountService; import com.ruoyi.doublePrevention.vo.ResultVO; import org.springframework.beans.factory.annotation.Autowired; @@ -23,4 +25,8 @@ return spiDataCountService.getSPIData(spiDataReqBO); } + @PostMapping("/select/getSPIDataForPieChart") + public ResultVO<TroubleLevel> getSPIDataForPieChart(@RequestBody SPIDataReqBO spiDataReqBO) { + return spiDataCountService.getSPIDataForPieChart(spiDataReqBO); + } } diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataForPieChartRespDTO.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataForPieChartRespDTO.java new file mode 100644 index 0000000..4378f94 --- /dev/null +++ b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataForPieChartRespDTO.java @@ -0,0 +1,20 @@ +package com.ruoyi.doublePrevention.entity.SPI; + +import lombok.Data; + +import java.util.List; + +@Data +public class SPIDataForPieChartRespDTO { + + + private TroubleLevel troubleLevel; + + public TroubleLevel getTroubleLevel() { + return troubleLevel; + } + + public void setTroubleLevel(TroubleLevel troubleLevel) { + this.troubleLevel = troubleLevel; + } +} diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java index 8a25cd8..d55b2cf 100644 --- a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java +++ b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java @@ -12,6 +12,10 @@ private Date endTime; + private String year; + + private String month; + public String getKey() { return key; } @@ -35,4 +39,20 @@ public void setEndTime(Date endTime) { this.endTime = endTime; } + + public String getYear() { + return year; + } + + public void setYear(String year) { + this.year = year; + } + + public String getMonth() { + return month; + } + + public void setMonth(String month) { + this.month = month; + } } diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java index f640b17..3d73878 100644 --- a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java +++ b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java @@ -9,21 +9,9 @@ private List<TroubleData> troubleDataList; - private TroubleLevel troubleLevel; public List<TroubleData> getTroubleDataList() { return troubleDataList; } - public void setTroubleDataList(List<TroubleData> troubleDataList) { - this.troubleDataList = troubleDataList; - } - - public TroubleLevel getTroubleLevel() { - return troubleLevel; - } - - public void setTroubleLevel(TroubleLevel troubleLevel) { - this.troubleLevel = troubleLevel; - } } diff --git a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java b/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java index 0aa1580..b5996ad 100644 --- a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java +++ b/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java @@ -1,7 +1,9 @@ package com.ruoyi.doublePrevention.service; +import com.ruoyi.doublePrevention.entity.SPI.SPIDataForPieChartRespDTO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataRespDTO; +import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; import com.ruoyi.doublePrevention.entity.dto.req.SPIDataCountReqDTO; import com.ruoyi.doublePrevention.entity.dto.resp.SPIDataCountRespDTO; import com.ruoyi.doublePrevention.vo.ResultVO; @@ -14,4 +16,6 @@ ResultVO<SPIDataCountRespDTO> listDangerResultCountByMonthOrYear(SPIDataCountReqDTO spiDataCountReqDTO); ResultVO<SPIDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO); + + ResultVO<TroubleLevel> getSPIDataForPieChart(SPIDataReqBO spiDataReqBO); } diff --git a/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java b/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java index ec2ae73..0160f18 100644 --- a/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java +++ b/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java @@ -1,10 +1,7 @@ package com.ruoyi.doublePrevention.service.impl; import com.ruoyi.doublePrevention.entity.DoublePreventDept; -import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; -import com.ruoyi.doublePrevention.entity.SPI.SPIDataRespDTO; -import com.ruoyi.doublePrevention.entity.SPI.TroubleData; -import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; +import com.ruoyi.doublePrevention.entity.SPI.*; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRectifiedRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerResultRespDO; @@ -190,18 +187,50 @@ List<TroubleData> spiData = checkPointService.getSPIData(spiDataReqBO); - TroubleLevel troubleLevel = checkPointService.getTroubleLevel(spiDataReqBO); - SPIDataRespDTO spiDataRespDTO = new SPIDataRespDTO(); - spiDataRespDTO.setTroubleDataList(spiData); - spiDataRespDTO.setTroubleLevel(troubleLevel); resultVO.setData(spiDataRespDTO); return resultVO; } + @Override + public ResultVO<TroubleLevel> getSPIDataForPieChart(SPIDataReqBO spiDataReqBO) { + + ResultVO resultVO = new ResultVO<>(); + resultVO.setCode("200"); + resultVO.setMsg("查询成功"); + + String key = "006a4740-8f2d-4fdc-a25b-a7413a37a2ba"; + + if (ObjectUtils.isEmpty(spiDataReqBO.getKey())){ + resultVO.setCode("400"); + resultVO.setMsg("key不能为空"); + return resultVO; + } + if (!spiDataReqBO.getKey().equals(key)){ + resultVO.setCode("400"); + resultVO.setMsg("key不正确"); + return resultVO; + } + + SPIDataForPieChartRespDTO spiDataForPieChartRespDTO = new SPIDataForPieChartRespDTO(); + + if (ObjectUtils.isEmpty(spiDataReqBO.getYear())){ + + spiDataReqBO.setYear("2024"); + TroubleLevel troubleLevel = checkPointService.getTroubleLevel(spiDataReqBO); + resultVO.setData(troubleLevel); + return resultVO; + } + + TroubleLevel troubleLevel = checkPointService.getTroubleLevel(spiDataReqBO); + resultVO.setData(troubleLevel); + + return resultVO; + } + /** * @description 参数校验 diff --git a/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml b/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml index 4a93fb7..3e2930e 100644 --- a/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml +++ b/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml @@ -131,6 +131,9 @@ sum(case when trouble_type_name = 'B级隐患' then 1 else 0 end) B, sum(case when trouble_type_name = 'C级隐患' then 1 else 0 end) C from tr_hidden_danger_check_point - WHERE register_create_time >= #{spiDataReqBO.startTime} and #{spiDataReqBO.endTime} >= register_create_time and whether_danger = 1 + WHERE YEAR(register_create_time) = #{spiDataReqBO.year} + <if test="spiDataReqBO.month != null and spiDataReqBO.month != ''"> + AND MONTH(register_create_time) = #{spiDataReqBO.month} + </if> </select> </mapper> \ No newline at end of file -- Gitblit v1.9.2