| | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | | |
| | | /** |
| | | * @decription 新增气体 |
| | | * @author Mr.huang |
| | | */ |
| | | @PostMapping("/add") |
| | | @RepeatedClick |
| | | public Result createGasCategory(@RequestBody CreateGasCategoryReqDTO reqDto){ |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * @decription 更新气体 |
| | | * @author Mr.huang |
| | | */ |
| | | @PostMapping("/update") |
| | | @RepeatedClick |
| | | public Result updateGasCategory(@RequestBody UpdateGasCategoryReqDTO reqDto){ |
| | |
| | | |
| | | private LocalDateTime dataReceivingTime; |
| | | |
| | | private Integer position; |
| | | |
| | | private int type; |
| | | |
| | | private String lng; |
| | |
| | | private LocalDateTime endTime; |
| | | |
| | | private Integer gasName; |
| | | |
| | | private Integer position; |
| | | } |
| | |
| | | private LocalDateTime endTime; |
| | | |
| | | private Integer gasName; |
| | | |
| | | private Integer position; |
| | | } |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime time; |
| | | |
| | | private Integer position; |
| | | |
| | | private int type; |
| | | |
| | | private String lng; |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author Mr.huang |
| | | * @decription |
| | |
| | | public class WindRoseByTimeReqDTO { |
| | | |
| | | private Integer countTime; |
| | | |
| | | private LocalDateTime startTime; |
| | | |
| | | private LocalDateTime endTime; |
| | | } |
| | |
| | | |
| | | private LocalDateTime time; |
| | | |
| | | private Integer position; |
| | | |
| | | private int type; |
| | | |
| | | private String lng; |
| | |
| | | |
| | | private LocalDateTime time; |
| | | |
| | | private Integer position; |
| | | |
| | | private int type; |
| | | |
| | | private String lng; |
| | |
| | | LocalDateTime startTime = now.minusHours(24); |
| | | return new WindRoseTimeSlotQuery(startTime,now); |
| | | } |
| | | }, |
| | | CUSTOM_TIME(5,"自定义") { |
| | | @Override |
| | | public WindRoseTimeSlotQuery getTimeSlotByStrategy() { |
| | | return null; |
| | | } |
| | | }; |
| | | |
| | | private Integer state; |
| | |
| | | @Autowired |
| | | private MonitorDailyReportService monitorDailyReportService; |
| | | |
| | | //@Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次 |
| | | @Scheduled(cron = "0/30 * * * * ?") |
| | | @Scheduled(cron = "0 0 2 * * ?") //每天两点执行一次 |
| | | @Async(value = "SocketTaskExecutor") |
| | | public void generateDailyReport() { |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | logger.info("【##】日报生成成功!!! ,时间:"+endTime+",所耗时间: "+execTime+"s"); |
| | | } |
| | | |
| | | /** |
| | | * @decription 画柱形图 |
| | | * @author Mr.huang |
| | | */ |
| | | public void drawBarChart(List<GasFlux> gasFluxes,String fileurl,String series,String molecularFormula,Integer i,Integer j) { |
| | | List<String> collect = gasFluxes.stream() |
| | | .map(gasFlux -> gasFlux.getTime().format(lineChartXDataDisplay)) |
| | |
| | | * @decription |
| | | * @date 2023/8/8 10:49 |
| | | */ |
| | | //@Component |
| | | @Component |
| | | public class HeartbeatSchedule { |
| | | |
| | | @Autowired |
| | |
| | | private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ?") // 每秒执行一次 |
| | | |
| | | @Scheduled(cron = "0/30 * * * * ?") |
| | | @Async(value = "SocketTaskExecutor") |
| | | public void gasConcentrationStatus() { |
| | | GasConcentration gasConcentration = gasConcentrationService.getLastData(); |
| | | if (gasConcentration != null){ |
| | | LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(1); |
| | | LocalDateTime lastReceiveTime = gasConcentration.getDataReceivingTime().plusMinutes(2); |
| | | if (LocalDateTime.now().compareTo(lastReceiveTime) > 0){ |
| | | try { |
| | | heartbeatExcWebsocketServer.sendInfo(HeartbeatExecEnum.GAS_CONCENTRATION.getStatus()+"",null); |
| | |
| | | |
| | | List<GasConcentration> listDatabyTimeSlot(LocalDateTime startTime, LocalDateTime endTime); |
| | | |
| | | Page<GasConcentration> listDatabyTimeSlotAndPage(PageQuery<GasPageQuery> pageQuery); |
| | | Page<GasConcentration> listDatabyTimeSlotAndPositionAndPage(PageQuery<GasPageQuery> pageQuery); |
| | | |
| | | Page<GasConcentration> gasAtmospherePage(PageQuery<GasAtmospherePageQuery> pageQuery); |
| | | |
| | | List<GasConcentration> listDatabyTimeSlotAndPosition(LocalDateTime startTime, LocalDateTime endTime, Integer position); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Page<GasConcentration> listDatabyTimeSlotAndPage(PageQuery<GasPageQuery> pageQuery) { |
| | | public Page<GasConcentration> listDatabyTimeSlotAndPositionAndPage(PageQuery<GasPageQuery> pageQuery) { |
| | | Pageable pageable = PageRequest.of(pageQuery.getPageIndex()-1, pageQuery.getPageSize(), Sort.Direction.DESC, "time"); |
| | | Specification<GasConcentration> specification = new Specification<GasConcentration>() { |
| | | @Override |
| | | public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { |
| | | Set<Predicate> predicateList = new HashSet<>(); |
| | | GasPageQuery searchParams = pageQuery.getSearchParams(); |
| | | if (searchParams != null && searchParams.getPosition() != null){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("position").as(Integer.class),searchParams.getPosition())); |
| | | } |
| | | if (searchParams != null && searchParams.getStartTime() != null && searchParams.getEndTime() != null){ |
| | | predicateList.add(criteriaBuilder.between(root.get("time").as(LocalDateTime.class),searchParams.getStartTime(),searchParams.getEndTime())); |
| | | } |
| | |
| | | Page<GasConcentration> pageResult = gasConcentrationRepository.findAll(specification,pageable); |
| | | return pageResult; |
| | | } |
| | | |
| | | @Override |
| | | public List<GasConcentration> listDatabyTimeSlotAndPosition(LocalDateTime startTime, LocalDateTime endTime, Integer position) { |
| | | if (startTime == null || endTime == null) |
| | | throw new BusinessException(this.getClass(), ResultCode.PARAM_ERROR_NULL.getCode(),"时间区段值不能为空"); |
| | | Specification<GasConcentration> specification = new Specification<GasConcentration>() { |
| | | @Override |
| | | public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder criteriaBuilder) { |
| | | Set<Predicate> predicateList = new HashSet<>(); |
| | | if (position != null){ |
| | | predicateList.add(criteriaBuilder.equal(root.get("position").as(Integer.class),position)); |
| | | } |
| | | predicateList.add(criteriaBuilder.between(root.get("time").as(LocalDateTime.class),startTime,endTime)); |
| | | return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()])); |
| | | } |
| | | }; |
| | | List<GasConcentration> gasConcentrations = gasConcentrationRepository.findAll(specification); |
| | | return gasConcentrations; |
| | | } |
| | | } |
| | |
| | | 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(); |
| | | 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(); |
| | | List<GasConcentration> gasConcentrations = gasConcentrationRepository.findAllByDataReceivingTimeBetweenOrderByDataReceivingTimeDesc(query.getStartTime(), query.getEndTime()); |
| | | if (CollectionUtils.isEmpty(gasConcentrations)) |
| | | return result; |
| | | List<WindRoseByTimeRespDTO> collect = gasConcentrations.stream().map(gasConcentration -> { |
| | |
| | | startTime = zeroTime; |
| | | endTime = nowTime; |
| | | } |
| | | List<GasConcentration> gasConcentrationList = gasConcentrationService.listDatabyTimeSlot(startTime,endTime); |
| | | List<GasConcentration> gasConcentrationList = gasConcentrationService.listDatabyTimeSlotAndPosition(startTime,endTime,reqDto.getPosition()); |
| | | if (CollectionUtils.isEmpty(gasConcentrationList)) |
| | | return success; |
| | | GasCategory gasCategory = gasCategoryService.findById(reqDto.getGasName()); |
| | |
| | | searchResult.setPageIndex(pageQuery.getPageIndex()); |
| | | searchResult.setPageSize(pageQuery.getPageSize()); |
| | | searchResult.setSuccess(); |
| | | Page<GasConcentration> pageResult = gasConcentrationService.listDatabyTimeSlotAndPage(pageQuery); |
| | | Page<GasConcentration> pageResult = gasConcentrationService.listDatabyTimeSlotAndPositionAndPage(pageQuery); |
| | | if (CollectionUtils.isEmpty(pageResult.getContent())) |
| | | return searchResult; |
| | | searchResult.setTotal(pageResult.getTotalElements()); |