From af3601ec9b19f037ddfe1ca2966be5d71203d965 Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期六, 04 三月 2023 11:43:23 +0800 Subject: [PATCH] 油烟设备接口 --- ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 218 insertions(+), 10 deletions(-) diff --git a/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java b/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java index be83a71..b0f0276 100644 --- a/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java +++ b/ycl-smoke/src/main/java/com/ycl/smoke/task/ScheduledTask.java @@ -1,10 +1,11 @@ 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; @@ -20,6 +21,18 @@ IOdsAlarmMsgService alarmMsgService; + IOdsTenMinDataService tenMinDataService; + + IOdsInTimeService inTimeService; + + IOdsLocaleService localeService; + + IOdsCustomerService customerService; + + IOdsAlarmRecordService alarmRecordService; + + IOdsCurAlarmService curAlarmService; + @Resource private RedisService redisService; @@ -33,8 +46,37 @@ 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 { @@ -45,11 +87,10 @@ 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) { } }); @@ -64,7 +105,6 @@ } @Scheduled(cron = "0 0 1 * * ?") // 姣忓ぉ闆剁偣鎵ц - // @Scheduled(cron = "0 */2 * * * ?") // 姣忎竴涓垎閽熸墽琛� 0 0/1 * ? // @Scheduled(cron = "0/1 * * * * ?") // 姣忕鎵ц public void queryDataDetectorDaily2Task() { try { @@ -75,11 +115,10 @@ 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) { } }); @@ -93,6 +132,175 @@ } } + + @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); -- Gitblit v1.8.0