| | |
| | | return gasCategory; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | logger.info("【气体异常map】init完成"); |
| | | logger.info("[GasExcMap] init complete"); |
| | | } |
| | | |
| | | @PostConstruct |
| | |
| | | } |
| | | } |
| | | } |
| | | logger.info("【预警阈值】init完成"); |
| | | logger.info("[WarningThreshold] init complete"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | GasFlux save = gasFluxService.save(gasFlux); |
| | | if (save == null) |
| | | throw new DataReceiveException(this.getClass(), ForeignResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"气体通量数据保存失败"); |
| | | gasFluxDataCacheAndPush(); |
| | | return ForeignResult.success(); |
| | | } |
| | | |
| | |
| | | push = true; |
| | | descs.add(GasFluxStateEnum.INVERSION_FAILED_10_MINUTES_NO_DATA.getDesc()); |
| | | } |
| | | if (push == true){ |
| | | String message = JSON.toJSONString(reqDTO); |
| | | try { |
| | | GasDeviceExcWebsocketServer.sendInfo(message,null); |
| | | } catch (IOException e) { |
| | | logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); |
| | | } |
| | | String message = JSON.toJSONString(reqDTO); |
| | | //todo 暂时改为实时推送给前端 |
| | | try { |
| | | GasDeviceExcWebsocketServer.sendInfo(message,null); |
| | | } catch (IOException e) { |
| | | logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); |
| | | } |
| | | if (push){ |
| | | //todo 线上环境还是异常才向前端推送 |
| | | //String message = JSON.toJSONString(reqDTO); |
| | | //try { |
| | | // GasDeviceExcWebsocketServer.sendInfo(message,null); |
| | | //} catch (IOException e) { |
| | | // logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败"); |
| | | //} |
| | | String execInfo = JSON.toJSONString(descs); |
| | | logger.info("【警告】设备异常,异常原因: "+ execInfo); |
| | | DeviceExceptionLog log = new DeviceExceptionLog(); |
| | |
| | | return ForeignResult.success(); |
| | | } |
| | | |
| | | private void gasFluxDataCacheAndPush(GasFlux save){ |
| | | private void gasFluxDataCacheAndPush(){ |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0); |
| | | List<GasFlux> gasFluxes = gasFluxService.listTodayGasFluxData(startTime,time); |
| | |
| | | @Override |
| | | @Transactional |
| | | public ForeignResult uploadGasConcentration(UploadGasConcentrationReqDTO reqDto) { |
| | | //gasConcentrationParameterVerification(reqDto); |
| | | gasConcentrationParameterVerification(reqDto); |
| | | GasConcentration gasConcentration = new GasConcentration(); |
| | | BeanUtils.copyProperties(reqDto,gasConcentration); |
| | | gasConcentration.setDataReceivingTime(LocalDateTime.now()); |
| | |
| | | Integer count= integer + 1; |
| | | gasExcCountMap.put(i,count); |
| | | if (yellowWarningThreshold.equals(count)) { |
| | | System.out.println("超过次数: "+count); |
| | | warnLogGenerateAndExecPush(WarningThresholdEnum.YELLOW.getCode(), gasCategory.get(i),value); |
| | | } |
| | | if (redWarningThreshold.equals(count)) { |
| | |
| | | } |
| | | |
| | | private void dataCacheAndPush(GasConcentration save){ |
| | | LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0); |
| | | LocalDateTime time = LocalDateTime.now(); |
| | | String cacheName = time.format(formatter); |
| | | RBucket<String> bucket = redissonClient.getBucket(gasConcentrationCachePrefix+cacheName); |
| | | String cache = bucket.get(); |
| | | List<GasConcentration> gasConcentrations = JSON.parseArray(cache,GasConcentration.class); |
| | | if (CollectionUtils.isEmpty(gasConcentrations)){ |
| | | gasConcentrations = new ArrayList<>(); |
| | | List<GasConcentration> concentrations = gasConcentrationService.listDatabyTimeSlot(startTime, time); |
| | | if (CollectionUtils.isEmpty(concentrations)){ |
| | | gasConcentrations = new ArrayList<>(); |
| | | }else { |
| | | gasConcentrations = concentrations; |
| | | } |
| | | gasConcentrations.add(save); |
| | | }else { |
| | | gasConcentrations.add(save); |