From d91ee46e736cd877ee9c55e6917f135e5ffd1338 Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: 星期二, 23 四月 2024 09:41:47 +0800
Subject: [PATCH] SPI数据接口提供
---
src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java | 38 +++++++
src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml | 20 ++++
src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleData.java | 26 +++++
src/main/java/com/ruoyi/framework/config/ShiroConfig.java | 4
src/main/java/com/ruoyi/doublePrevention/repository/TrHiddenDangerCheckPointRepository.java | 7 +
src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java | 26 +++++
src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java | 4
src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java | 29 +++++
src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java | 46 +++++++++
src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleLevel.java | 37 +++++++
src/main/java/com/ruoyi/doublePrevention/service/baseService/TrHiddenDangerCheckPointService.java | 7 +
src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/TrHiddenDangerCheckPointServiceImpl.java | 13 ++
12 files changed, 255 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java b/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java
new file mode 100644
index 0000000..79fc09e
--- /dev/null
+++ b/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);
+ }
+
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java
new file mode 100644
index 0000000..8a25cd8
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataRespDTO.java
new file mode 100644
index 0000000..f640b17
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleData.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleData.java
new file mode 100644
index 0000000..7ccbe4c
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleLevel.java b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/TroubleLevel.java
new file mode 100644
index 0000000..1b69fe7
--- /dev/null
+++ b/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;
+ }
+}
diff --git a/src/main/java/com/ruoyi/doublePrevention/repository/TrHiddenDangerCheckPointRepository.java b/src/main/java/com/ruoyi/doublePrevention/repository/TrHiddenDangerCheckPointRepository.java
index 2a53c96..7d36a6a 100644
--- a/src/main/java/com/ruoyi/doublePrevention/repository/TrHiddenDangerCheckPointRepository.java
+++ b/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);
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java b/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
index 2262ada..0aa1580 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
+++ b/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);
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/baseService/TrHiddenDangerCheckPointService.java b/src/main/java/com/ruoyi/doublePrevention/service/baseService/TrHiddenDangerCheckPointService.java
index 29c1e05..6c751e6 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/baseService/TrHiddenDangerCheckPointService.java
+++ b/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);
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/TrHiddenDangerCheckPointServiceImpl.java b/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/TrHiddenDangerCheckPointServiceImpl.java
index 052c7d6..81a8ae1 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/baseService/impl/TrHiddenDangerCheckPointServiceImpl.java
+++ b/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);
+ }
}
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 827faec..ec2ae73 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java
+++ b/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 参数校验
diff --git a/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/src/main/java/com/ruoyi/framework/config/ShiroConfig.java
index eb31311..8be903b 100644
--- a/src/main/java/com/ruoyi/framework/config/ShiroConfig.java
+++ b/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");
diff --git a/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml b/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml
index 435914b..2050f7a 100644
--- a/src/main/resources/mybatis/doublePrevention/TrHiddenDangerCheckPointMapper.xml
+++ b/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>
\ No newline at end of file
--
Gitblit v1.9.2