From 572a15d110b9882c332f434ab7f9a2699cf70e80 Mon Sep 17 00:00:00 2001
From: 16639036659 <577530412@qq.com>
Date: Wed, 27 Mar 2024 09:35:53 +0800
Subject: [PATCH] redis添加前缀
---
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java | 40 ++++++++++++++++++++++++++++++++++++----
1 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java
index 0f93767..8fda170 100644
--- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java
+++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/GasWarnLogServiceImpl.java
@@ -8,18 +8,20 @@
import com.gkhy.fourierSpecialGasMonitor.domain.account.entity.User;
import com.gkhy.fourierSpecialGasMonitor.domain.account.enums.UserStatusEnum;
import com.gkhy.fourierSpecialGasMonitor.domain.account.repository.jpa.UserRepository;
+import com.gkhy.fourierSpecialGasMonitor.entity.GasConcentration;
import com.gkhy.fourierSpecialGasMonitor.entity.GasWarnLog;
import com.gkhy.fourierSpecialGasMonitor.entity.query.FindGasWarnLogPageQuery;
import com.gkhy.fourierSpecialGasMonitor.entity.query.GasWarnTimesCountTimeSlotQuery;
+import com.gkhy.fourierSpecialGasMonitor.entity.query.WindRoseTimeSlotQuery;
import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogCountByTimeReqDTO;
import com.gkhy.fourierSpecialGasMonitor.entity.req.GasWarnLogInfoReqDTO;
import com.gkhy.fourierSpecialGasMonitor.entity.req.HandleGasWarnLogReqDTO;
-import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindGasWarnLogPageRespDTO;
-import com.gkhy.fourierSpecialGasMonitor.entity.resp.FindGasWarnLogSmsUserPageRespDTO;
-import com.gkhy.fourierSpecialGasMonitor.entity.resp.GasWarnLogCountByTimeRespDTO;
-import com.gkhy.fourierSpecialGasMonitor.entity.resp.GasWarnLogInfoByTimeRespDTO;
+import com.gkhy.fourierSpecialGasMonitor.entity.req.WindRoseByTimeReqDTO;
+import com.gkhy.fourierSpecialGasMonitor.entity.resp.*;
import com.gkhy.fourierSpecialGasMonitor.enums.GasWarnTimesCountEnum;
import com.gkhy.fourierSpecialGasMonitor.enums.WarnHandleStatusEnum;
+import com.gkhy.fourierSpecialGasMonitor.enums.WindRoseEnum;
+import com.gkhy.fourierSpecialGasMonitor.repository.GasConcentrationRepository;
import com.gkhy.fourierSpecialGasMonitor.repository.GasWarnLogRepository;
import com.gkhy.fourierSpecialGasMonitor.service.GasWarnLogService;
import com.gkhy.fourierSpecialGasMonitor.utils.ThreadLocalUtil;
@@ -34,6 +36,7 @@
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
+import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@@ -53,6 +56,9 @@
@Autowired
private GasWarnLogRepository gasWarnLogRepository;
+
+ @Resource
+ private GasConcentrationRepository gasConcentrationRepository;
@Autowired
private UserRepository userRepository;
@@ -191,6 +197,32 @@
}
@Override
+ public Result gasWindRoseByTime(WindRoseByTimeReqDTO reqDTO) {
+ if (reqDTO == null && reqDTO .getCountTime() == null)
+ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空");
+ Integer countTime = reqDTO.getCountTime();
+ List<GasConcentration> gasConcentrations;
+ if (reqDTO.getCountTime().equals(WindRoseEnum.CUSTOM_TIME.getState())){
+ if (reqDTO.getStartTime() == null && reqDTO.getEndTime() == null)
+ throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL,"参数不能为空");
+ gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(reqDTO.getStartTime(), reqDTO.getEndTime());
+ }else {
+ WindRoseTimeSlotQuery query = WindRoseEnum.getQueryObject(countTime).getTimeSlotByStrategy();
+ gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(query.getStartTime(), query.getEndTime());
+ }
+ Result result = Result.success();
+ if (CollectionUtils.isEmpty(gasConcentrations))
+ return result;
+ List<WindRoseByTimeRespDTO> collect = gasConcentrations.stream().map(gasConcentration -> {
+ WindRoseByTimeRespDTO dto = new WindRoseByTimeRespDTO();
+ BeanUtils.copyProperties(gasConcentration, dto);
+ return dto;
+ }).collect(Collectors.toList());
+ result.setData(collect);
+ return result;
+ }
+
+ @Override
public Result gasWarnLogInfoByTime(GasWarnLogInfoReqDTO gasWarnLogInfoReqDTO) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime startTime = now.with(LocalTime.MIN);
--
Gitblit v1.9.2