From 326c87fed063066712ebb9e408a30d669f8681d3 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期一, 17 六月 2024 09:36:08 +0800
Subject: [PATCH] 添加
---
src/main/java/com/ruoyi/doublePrevention/service/impl/SPIDataCountServiceImpl.java | 64 +++++++++++++++++++++++--------
1 files changed, 47 insertions(+), 17 deletions(-)
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..2a772bb 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;
@@ -24,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;
@@ -163,7 +162,7 @@
}
@Override
- public ResultVO<SPIDataRespDTO> getSPIData(SPIDataReqBO spiDataReqBO) {
+ public ResultVO<TroubleData> getSPIData(SPIDataReqBO spiDataReqBO) {
ResultVO resultVO = new ResultVO<>();
resultVO.setCode("200");
@@ -181,23 +180,54 @@
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);
+
+ resultVO.setData(spiData);
+
+ 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);
-
- SPIDataRespDTO spiDataRespDTO = new SPIDataRespDTO();
-
- spiDataRespDTO.setTroubleDataList(spiData);
- spiDataRespDTO.setTroubleLevel(troubleLevel);
-
- resultVO.setData(spiDataRespDTO);
+ resultVO.setData(troubleLevel);
return resultVO;
}
--
Gitblit v1.9.2