From c588bf4ecd889823225b4d0ec37edf8924894c4a Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: 星期日, 28 四月 2024 13:07:49 +0800
Subject: [PATCH] SPI数据按照需求调整
---
src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java | 18 +++++++++++-------
src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java | 7 ++-----
src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java | 7 ++-----
src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java | 19 ++++++++++---------
4 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java b/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java
index 92433a0..102c3e8 100644
--- a/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java
+++ b/src/main/java/com/ruoyi/doublePrevention/controller/SPIDataController.java
@@ -1,10 +1,7 @@
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.entity.SPI.*;
import com.ruoyi.doublePrevention.service.SPIDataCountService;
import com.ruoyi.doublePrevention.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
@@ -21,7 +18,7 @@
private SPIDataCountService spiDataCountService;
@PostMapping("/select/getSPIData")
- public ResultVO<SPIDataRespDTO> getSPIData(@RequestBody SPIDataReqBO spiDataReqBO) {
+ public ResultVO<TroubleData> 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
index d55b2cf..10e7b2b 100644
--- a/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java
+++ b/src/main/java/com/ruoyi/doublePrevention/entity/SPI/SPIDataReqBO.java
@@ -1,16 +1,20 @@
package com.ruoyi.doublePrevention.entity.SPI;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
-import java.util.Date;
+
+import java.time.LocalDateTime;
@Data
public class SPIDataReqBO {
private String key;
- private Date startTime;
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime startTime;
- private Date endTime;
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
+ private LocalDateTime endTime;
private String year;
@@ -24,19 +28,19 @@
this.key = key;
}
- public Date getStartTime() {
+ public LocalDateTime getStartTime() {
return startTime;
}
- public void setStartTime(Date startTime) {
+ public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
- public Date getEndTime() {
+ public LocalDateTime getEndTime() {
return endTime;
}
- public void setEndTime(Date endTime) {
+ public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
diff --git a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java b/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
index b5996ad..7a5d424 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/SPIDataCountService.java
@@ -1,9 +1,6 @@
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.SPI.*;
import com.ruoyi.doublePrevention.entity.dto.req.SPIDataCountReqDTO;
import com.ruoyi.doublePrevention.entity.dto.resp.SPIDataCountRespDTO;
import com.ruoyi.doublePrevention.vo.ResultVO;
@@ -15,7 +12,7 @@
*/
ResultVO<SPIDataCountRespDTO> listDangerResultCountByMonthOrYear(SPIDataCountReqDTO spiDataCountReqDTO);
- ResultVO<SPIDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO);
+ ResultVO<TroubleData> 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 0160f18..2a772bb 100644
--- a/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java
+++ b/src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java
@@ -21,7 +21,9 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import java.time.LocalDate;
import java.time.LocalDateTime;
+import java.time.Period;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -160,7 +162,7 @@
}
@Override
- public ResultVO<SPIDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO) {
+ public ResultVO<TroubleData> getSPIData(SPIDataReqBO spiDataReqBO) {
ResultVO resultVO = new ResultVO<>();
resultVO.setCode("200");
@@ -178,19 +180,18 @@
resultVO.setMsg("key不正确");
return resultVO;
}
- if (ObjectUtils.isEmpty(spiDataReqBO.getStartTime())){
- spiDataReqBO.setStartTime(new Date(123, 3,1));
+ LocalDateTime startTime = LocalDate.now().withDayOfMonth(1).atStartOfDay();
+ for (int i = 0; i < 12; i++) {
+ startTime = startTime.minus(Period.ofMonths(1));
}
- if (ObjectUtils.isEmpty(spiDataReqBO.getEndTime())){
- spiDataReqBO.setEndTime(new Date());
- }
+ spiDataReqBO.setStartTime(startTime);
+ spiDataReqBO.setEndTime(LocalDateTime.now());
+
List<TroubleData> spiData = checkPointService.getSPIData(spiDataReqBO);
- SPIDataRespDTO spiDataRespDTO = new SPIDataRespDTO();
- spiDataRespDTO.setTroubleDataList(spiData);
- resultVO.setData(spiDataRespDTO);
+ resultVO.setData(spiData);
return resultVO;
}
--
Gitblit v1.9.2