src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java
对比新文件 @@ -0,0 +1,26 @@ package com.ruoyi.doublePrevention.controller; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataRespDTO; import com.ruoyi.doublePrevention.service.SPIDataCountService; import com.ruoyi.doublePrevention.vo.ResultVO; import org.springframework.beans.factory.annotation.Autowired; 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; @RestController @RequestMapping("/SPIData") public class SPIDataController { @Autowired private SPIDataCountService spiDataCountService; @PostMapping("/select/getSPIData") public ResultVO<SPIDataRespDTO> getSPIData(@RequestBody SPIDataReqBO spiDataReqBO) { return spiDataCountService.getSPIData(spiDataReqBO); } } src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java
对比新文件 @@ -0,0 +1,38 @@ package com.ruoyi.doublePrevention.entity.SPI; import lombok.Data; import java.util.Date; @Data public class SPIDataReqBO { private String key; private Date startTime; private Date endTime; public String getKey() { return key; } public void setKey(String key) { this.key = key; } public Date getStartTime() { return startTime; } public void setStartTime(Date startTime) { this.startTime = startTime; } public Date getEndTime() { return endTime; } public void setEndTime(Date endTime) { this.endTime = endTime; } } src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java
对比新文件 @@ -0,0 +1,29 @@ package com.ruoyi.doublePrevention.entity.SPI; import lombok.Data; import java.util.List; @Data public class SPIDataRespDTO { 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; } } src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleData.java
对比新文件 @@ -0,0 +1,26 @@ package com.ruoyi.doublePrevention.entity.SPI; public class TroubleData { private String time; private Integer count; public String getTime() { return time; } public void setTime(String time) { this.time = time; } public Integer getCount() { return count; } public void setCount(Integer count) { this.count = count; } } src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleLevel.java
对比新文件 @@ -0,0 +1,37 @@ package com.ruoyi.doublePrevention.entity.SPI; public class TroubleLevel { private String A; private String B; private String C; public String getA() { return A; } public void setA(String a) { A = a; } public String getB() { return B; } public void setB(String b) { B = b; } public String getC() { return C; } public void setC(String c) { C = c; } } src/main/java/com/ruoyi/doublePrevention/repository/TrHiddenDangerCheckPointRepository.java
@@ -1,5 +1,8 @@ package com.ruoyi.doublePrevention.repository; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.TroubleData; import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRectifiedRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO; import org.apache.ibatis.annotations.Param; @@ -21,4 +24,8 @@ */ DataCountDangerLevelRectifiedRespDO listDangerLevelRectifiedCountByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("depIds") List<Long> depIds); List<TroubleData> getSPIData(@Param(value="spiDataReqBO")SPIDataReqBO spiDataReqBO); TroubleLevel getTroubleLevel(@Param(value="spiDataReqBO")SPIDataReqBO spiDataReqBO); } src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
@@ -1,5 +1,7 @@ package com.ruoyi.doublePrevention.service; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.SPIDataRespDTO; import com.ruoyi.doublePrevention.entity.dto.req.SPIDataCountReqDTO; import com.ruoyi.doublePrevention.entity.dto.resp.SPIDataCountRespDTO; import com.ruoyi.doublePrevention.vo.ResultVO; @@ -10,4 +12,6 @@ * 数据统计-隐患数据统计-根据月或者年 */ ResultVO<SPIDataCountRespDTO> listDangerResultCountByMonthOrYear(SPIDataCountReqDTO spiDataCountReqDTO); ResultVO<SPIDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO); } src/main/java/com/ruoyi/doublePrevention/service/baseService/TrHiddenDangerCheckPointService.java
@@ -1,5 +1,8 @@ package com.ruoyi.doublePrevention.service.baseService; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.TroubleData; import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRectifiedRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO; @@ -18,4 +21,8 @@ * @description 统计时间段内一般已整改、重大已整改的隐患数量 */ DataCountDangerLevelRectifiedRespDO listDangerLevelRectifiedCountByTime(Date startTime, Date endTime, List<Long> depIds); List<TroubleData> getSPIData(SPIDataReqBO spiDataReqBO); TroubleLevel getTroubleLevel(SPIDataReqBO spiDataReqBO); } src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/TrHiddenDangerCheckPointServiceImpl.java
@@ -1,5 +1,8 @@ package com.ruoyi.doublePrevention.service.baseService.impl; import com.ruoyi.doublePrevention.entity.SPI.SPIDataReqBO; import com.ruoyi.doublePrevention.entity.SPI.TroubleData; import com.ruoyi.doublePrevention.entity.SPI.TroubleLevel; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRectifiedRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO; import com.ruoyi.doublePrevention.repository.TrHiddenDangerCheckPointRepository; @@ -31,4 +34,14 @@ public DataCountDangerLevelRectifiedRespDO listDangerLevelRectifiedCountByTime(Date startTime, Date endTime, List<Long> depIds) { return checkPointRepository.listDangerLevelRectifiedCountByTime(startTime,endTime,depIds); } @Override public List<TroubleData> getSPIData(SPIDataReqBO spiDataReqBO) { return checkPointRepository.getSPIData(spiDataReqBO); } @Override public TroubleLevel getTroubleLevel(SPIDataReqBO spiDataReqBO) { return checkPointRepository.getTroubleLevel(spiDataReqBO); } } src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java
@@ -1,6 +1,10 @@ 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.dto.DataCountDangerLevelRectifiedRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerLevelRespDO; import com.ruoyi.doublePrevention.entity.dto.DataCountDangerResultRespDO; @@ -13,7 +17,6 @@ import com.ruoyi.doublePrevention.service.baseService.PreventRiskDangerInfoService; import com.ruoyi.doublePrevention.service.baseService.TrHiddenDangerCheckPointService; import com.ruoyi.doublePrevention.vo.ResultVO; import io.swagger.models.auth.In; import org.apache.commons.lang3.ObjectUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.util.Calendar; import java.util.Date; import java.util.List; @@ -158,6 +162,46 @@ return parameterVerificationResult; } @Override public ResultVO<SPIDataRespDTO> getSPIData(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; } if (ObjectUtils.isEmpty(spiDataReqBO.getStartTime())){ spiDataReqBO.setStartTime(new Date(123, 3,1)); } if (ObjectUtils.isEmpty(spiDataReqBO.getEndTime())){ spiDataReqBO.setEndTime(new Date()); } 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; } /** * @description 参数校验 src/main/java/com/ruoyi/framework/config/ShiroConfig.java
@@ -225,7 +225,7 @@ } /** * Shiro过滤器配置 * Shiro过滤器配置 todo 过滤器 */ @Bean public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) @@ -254,6 +254,8 @@ filterChainDefinitionMap.put("/logout", "logout"); // 不需要拦截的访问 filterChainDefinitionMap.put("/login", "anon,captchaValidate"); // 不需要拦截的访问 todo filterChainDefinitionMap.put("/SPIData/**", "anon,captchaValidate"); // 注册相关 filterChainDefinitionMap.put("/register", "anon,captchaValidate"); src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml
@@ -108,4 +108,24 @@ </if> </select> <!-- List<TroubleDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO);--> <select id="getSPIData" resultType="com.ruoyi.doublePrevention.entity.SPI.TroubleData"> SELECT DATE_FORMAT(register_create_time, '%Y-%m') time, sum(1) count FROM tr_hidden_danger_check_point WHERE register_create_time >= #{spiDataReqBO.startTime} and #{spiDataReqBO.endTime} >= register_create_time and whether_danger = 1 GROUP BY time ORDER BY time ASC </select> <!-- TroubleLevel getTroubleLevel(SPIDataReqBO spiDataReqBO);--> <select id="getTroubleLevel" resultType="com.ruoyi.doublePrevention.entity.SPI.TroubleLevel"> select sum(case when trouble_type_name = 'A级隐患' then 1 else 0 end) A, 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 </select> </mapper>