| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | |
| | | @Autowired |
| | | private GasWarnLogRepository gasWarnLogRepository; |
| | | |
| | | @Resource |
| | | private GasConcentrationRepository gasConcentrationRepository; |
| | | |
| | | @Autowired |
| | | private UserRepository userRepository; |
| | |
| | | } |
| | | |
| | | @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(); |
| | | WindRoseTimeSlotQuery query = WindRoseEnum.getQueryObject(countTime).getTimeSlotByStrategy(); |
| | | Result result = Result.success(); |
| | | List<GasConcentration> gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(query.getStartTime(), query.getEndTime()); |
| | | 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); |