| | |
| | | package com.ycl.smoke.task; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ycl.service.redis.RedisService; |
| | | import com.ycl.smoke.entity.OdsAlarmMsg; |
| | | import com.ycl.smoke.entity.*; |
| | | import com.ycl.smoke.dto.*; |
| | | import com.ycl.smoke.remote.service.ISmokeDetectionService; |
| | | import com.ycl.smoke.service.IOdsAlarmMsgService; |
| | | import com.ycl.smoke.service.*; |
| | | import com.ycl.utils.redis.RedisKey; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | |
| | | IOdsAlarmMsgService alarmMsgService; |
| | | |
| | | IOdsTenMinDataService tenMinDataService; |
| | | |
| | | IOdsInTimeService inTimeService; |
| | | |
| | | IOdsLocaleService localeService; |
| | | |
| | | IOdsCustomerService customerService; |
| | | |
| | | IOdsAlarmRecordService alarmRecordService; |
| | | |
| | | IOdsCurAlarmService curAlarmService; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | |
| | | this.alarmMsgService = alarmMsgService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setTenMinDataService(IOdsTenMinDataService tenMinDataService) { |
| | | this.tenMinDataService = tenMinDataService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setInTimeService(IOdsInTimeService inTimeService) { |
| | | this.inTimeService = inTimeService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setLocaleService(IOdsLocaleService localeService) { |
| | | this.localeService = localeService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setCustomerService(IOdsCustomerService customerService) { |
| | | this.customerService = customerService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setAlarmRecordService(IOdsAlarmRecordService alarmRecordService) { |
| | | this.alarmRecordService = alarmRecordService; |
| | | } |
| | | |
| | | @Autowired |
| | | public void setCurAlarmService(IOdsCurAlarmService curAlarmService) { |
| | | this.curAlarmService = curAlarmService; |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0 */2 * * * ?") // 每一个分钟执行 0 0/1 * ? |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void alarmMsgTask() { |
| | | try { |
| | |
| | | AlarmMsgResponseDto dto = responseDto.getData(); |
| | | List<OdsAlarmMsg> list = dto.getContent(); |
| | | System.out.println(list.size()); |
| | | list.forEach(o->{ |
| | | list.forEach(o -> { |
| | | try { |
| | | alarmMsgService.save(o); |
| | | } |
| | | catch (Exception ex){ |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0 */2 * * * ?") // 每一个分钟执行 0 0/1 * ? |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void queryDataDetectorDaily2Task() { |
| | | try { |
| | |
| | | AlarmMsgResponseDto dto = responseDto.getData(); |
| | | List<OdsAlarmMsg> list = dto.getContent(); |
| | | System.out.println(list.size()); |
| | | list.forEach(o->{ |
| | | list.forEach(o -> { |
| | | try { |
| | | alarmMsgService.save(o); |
| | | } |
| | | catch (Exception ex){ |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | }); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void queryTenMinData() { |
| | | try { |
| | | TenMinParamDto paramDto = TenMinParamDto.builder().build(); |
| | | |
| | | SmokeResultResponseDto<List<OdsTenMinData>> responseDto = smokeDetectionService.queryTenMinData(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | List<OdsTenMinData> list = responseDto.getData(); |
| | | list.forEach(o -> { |
| | | try { |
| | | tenMinDataService.save(o); |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void listDataIntime() { |
| | | try { |
| | | DataIntimeParamDto paramDto = DataIntimeParamDto.builder().build(); |
| | | |
| | | SmokeResultResponseDto<DataIntimeResponseDto> responseDto = smokeDetectionService.listDataIntime(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | DataIntimeResponseDto dataIntimeResponseDto = responseDto.getData(); |
| | | List<OdsInTime> list = dataIntimeResponseDto.getContent(); |
| | | list.forEach(o -> { |
| | | try { |
| | | inTimeService.save(o); |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void listLocale() { |
| | | try { |
| | | LocaleParamDto paramDto = LocaleParamDto.builder().build(); |
| | | |
| | | SmokeResultResponseDto<LocaleResponseDto> responseDto = smokeDetectionService.listLocale(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | LocaleResponseDto responseDataDto = responseDto.getData(); |
| | | List<OdsLocale> list = responseDataDto.getContent(); |
| | | list.forEach(o -> { |
| | | try { |
| | | o.setCustomerString(JSON.toJSONString(o.getCustomer())); |
| | | localeService.save(o); |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void queryCustomer() { |
| | | try { |
| | | CustomerParamDto paramDto = CustomerParamDto.builder().build(); |
| | | |
| | | SmokeResultResponseDto<CustomerResponseDto> responseDto = smokeDetectionService.queryCustomer(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | CustomerResponseDto responseDataDto = responseDto.getData(); |
| | | List<OdsCustomer> list = responseDataDto.getContent(); |
| | | list.forEach(o -> { |
| | | try { |
| | | o.setAreasString(o.getAreas() == null ? "" : JSON.toJSONString(o.getAreas())); |
| | | o.setAreaIdsString(o.getAreaIds() == null ? "" : JSON.toJSONString(o.getAreaIds())); |
| | | o.setAreaIdCascadsString(o.getAreaIdCascads() == null ? "" : JSON.toJSONString(o.getAreaIdCascads())); |
| | | customerService.save(o); |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void listAlarmRecord() { |
| | | try { |
| | | AlarmMsgParamDto paramDto = AlarmMsgParamDto.builder().build(); |
| | | |
| | | SmokeResultResponseDto<AlarmRecordResponseDto> responseDto = smokeDetectionService.getListAlarmRecord(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | AlarmRecordResponseDto responseDataDto = responseDto.getData(); |
| | | List<OdsAlarmRecord> list = responseDataDto.getContent(); |
| | | list.forEach(o -> { |
| | | try { |
| | | o.setAlarmRecordPicsString(JSON.toJSONString(o.getAlarmRecordPics())); |
| | | alarmRecordService.save(o); |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 1 * * ?") // 每天零点执行 |
| | | // @Scheduled(cron = "0/1 * * * * ?") // 每秒执行 |
| | | public void listCurAlarm() { |
| | | try { |
| | | CurAlarmParamDto paramDto = CurAlarmParamDto.builder().Typ(2).build(); |
| | | |
| | | SmokeResultResponseDto<CurAlarmResponseDto> responseDto = smokeDetectionService.getListCurAlarm(paramDto, redisService.get(RedisKey.SMOKE_TOKEN).toString()); |
| | | if (responseDto.getStatus() == 200) { |
| | | CurAlarmResponseDto responseDataDto = responseDto.getData(); |
| | | List<OdsCurAlarm> list = responseDataDto.getContent(); |
| | | list.forEach(o -> { |
| | | try { |
| | | curAlarmService.save(o); |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | }); |
| | | // alarmMsgService.saveBatch(list); |
| | | } else if (responseDto.getStatus() == 114) { |
| | | login(); |
| | | queryDataDetectorDaily2Task(); |
| | | } |
| | | } catch (Exception ex) { |
| | | System.out.printf(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | void login() { |
| | | LoginParamDto loginParamDto = LoginParamDto.builder().username("connect_test2").password("test@234").noCode(true).build(); |
| | | SmokeResultResponseDto<LoginResponseDto> responseDto = smokeDetectionService.loginAction(loginParamDto); |