diff --git a/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java b/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java index f72b8af..3549d93 100644 --- a/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java +++ b/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java @@ -35,74 +35,79 @@ public class DispatchFirePointUtils { return true; } for (FirePointChannelConfigEntity firePointChannelConfigEntity : firePointChannelConfigEntityList) { - String jsonContent = firePointChannelConfigEntity.getJsonContent(); - FirePointChannelConfigBean firePointChannelConfigBean = JsonUtils.deserialize(jsonContent, FirePointChannelConfigBean.class); - if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) { - List channelConfigList = firePointChannelConfigBean.getConfigList(); - if (channelConfigList == null || channelConfigList.size() == 0) { - int resValue1 = 0; - String errorMessage = "星科瑞升-秸秆火后台系统报错-检查火点卫星时间是否在精准渠道配置时间范围内-数据库配置项-时间列表-为null或size=0-火点编码=" + fireCode; - try { - resValue1 = SMSUtils.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{errorMessage}); - } catch (Exception e) { - e.printStackTrace(); + try { + String jsonContent = firePointChannelConfigEntity.getJsonContent(); + FirePointChannelConfigBean firePointChannelConfigBean = JsonUtils.deserialize(jsonContent, FirePointChannelConfigBean.class); + if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) { + List channelConfigList = firePointChannelConfigBean.getConfigList(); + if (channelConfigList == null || channelConfigList.size() == 0) { + int resValue1 = 0; + String errorMessage = "星科瑞升-秸秆火后台系统报错-检查火点卫星时间是否在精准渠道配置时间范围内-数据库配置项-时间列表-为null或size=0-火点编码=" + fireCode; + try { + resValue1 = SMSUtils.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{errorMessage}); + } catch (Exception e) { + e.printStackTrace(); + } + log.info(errorMessage + (resValue1 == 0 ? "--短信通知发送成功" : "--短信通知发送失败")); + return true; } - log.info(errorMessage + (resValue1 == 0 ? "--短信通知发送成功" : "--短信通知发送失败")); - return true; - } - for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) { - //预处理开始时间 - String startTime = channelConfig.getStartTime();//获取精准火点渠道的开始时间 - boolean needCheckStartTime = !TextUtils.isEmpty(startTime); - LocalDateTime sameYearStartTime = null;//计算得出精准渠道和传入火点同年的开始时间 - if (needCheckStartTime) { - sameYearStartTime = obtainLocalDateTimeSameYear(satelliteLocalDateTime.getYear(), startTime); - needCheckStartTime = sameYearStartTime != null; - } - //预处理结束时间 - String endTime = channelConfig.getEndTime();//获取精准火点渠道的结束时间 - boolean needCheckEndTime = !TextUtils.isEmpty(endTime); - LocalDateTime sameYearEndTime = null;//计算得出精准渠道和传入火点同年的结束时间 - if (needCheckEndTime) { - sameYearEndTime = obtainLocalDateTimeSameYear(satelliteLocalDateTime.getYear(), endTime); - needCheckEndTime = sameYearEndTime != null; - } - //排列组合4种情况 - if (needCheckStartTime) { + for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) { + //预处理开始时间 + String startTime = channelConfig.getStartTime();//获取精准火点渠道的开始时间 + boolean needCheckStartTime = !TextUtils.isEmpty(startTime); + LocalDateTime sameYearStartTime = null;//计算得出精准渠道和传入火点同年的开始时间 + if (needCheckStartTime) { + sameYearStartTime = obtainLocalDateTimeSameYear(satelliteLocalDateTime.getYear(), startTime); + needCheckStartTime = sameYearStartTime != null; + } + //预处理结束时间 + String endTime = channelConfig.getEndTime();//获取精准火点渠道的结束时间 + boolean needCheckEndTime = !TextUtils.isEmpty(endTime); + LocalDateTime sameYearEndTime = null;//计算得出精准渠道和传入火点同年的结束时间 if (needCheckEndTime) { - //开始时间、结束时间都需要比较 - if (sameYearStartTime.isBefore(satelliteLocalDateTime) && sameYearEndTime.isAfter(satelliteLocalDateTime)) { - String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); - String time1 = DateTimeUtils.localDateTimeToString(sameYearStartTime); - String time2 = DateTimeUtils.localDateTimeToString(sameYearEndTime); - log.info("开始时间、结束时间都需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1 + ",结束时间=" + time2); - return true; + sameYearEndTime = obtainLocalDateTimeSameYear(satelliteLocalDateTime.getYear(), endTime); + needCheckEndTime = sameYearEndTime != null; + } + //排列组合4种情况 + if (needCheckStartTime) { + if (needCheckEndTime) { + //开始时间、结束时间都需要比较 + if (sameYearStartTime.isBefore(satelliteLocalDateTime) && sameYearEndTime.isAfter(satelliteLocalDateTime)) { + String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); + String time1 = DateTimeUtils.localDateTimeToString(sameYearStartTime); + String time2 = DateTimeUtils.localDateTimeToString(sameYearEndTime); + log.info("开始时间、结束时间都需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1 + ",结束时间=" + time2); + return true; + } + } else { + //开始时间需要比较,结束时间不需要比较 + if (sameYearStartTime.isBefore(satelliteLocalDateTime)) { + String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); + String time1 = DateTimeUtils.localDateTimeToString(sameYearStartTime); + log.info("开始时间需要比较,结束时间不需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1); + return true; + } } } else { - //开始时间需要比较,结束时间不需要比较 - if (sameYearStartTime.isBefore(satelliteLocalDateTime)) { - String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); - String time1 = DateTimeUtils.localDateTimeToString(sameYearStartTime); - log.info("开始时间需要比较,结束时间不需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1); + if (needCheckEndTime) { + //开始时间不需要比较,结束时间需要比较 + if (sameYearEndTime.isAfter(satelliteLocalDateTime)) { + String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); + String time2 = DateTimeUtils.localDateTimeToString(sameYearEndTime); + log.info("开始时间不需要比较,结束时间需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",结束时间=" + time2); + return true; + } + } else { + //开始时间、结束时间都不需要比较 + log.info("开始时间、结束时间都不需要比较,比较结果:属于精准时间范围内"); return true; } } - } else { - if (needCheckEndTime) { - //开始时间不需要比较,结束时间需要比较 - if (sameYearEndTime.isAfter(satelliteLocalDateTime)) { - String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime); - String time2 = DateTimeUtils.localDateTimeToString(sameYearEndTime); - log.info("开始时间不需要比较,结束时间需要比较,比较结果:属于精准时间范围内,详情:火点时间=" + time0 + ",结束时间=" + time2); - return true; - } - } else { - //开始时间、结束时间都不需要比较 - log.info("开始时间、结束时间都不需要比较,比较结果:属于精准时间范围内"); - return true; - } } } + } catch (Exception e) { + e.printStackTrace(); + log.info("检查渠道配置时间失败,错误=" + e.getMessage() + ",原始内容=" + firePointChannelConfigEntity.getJsonContent()); } } //没有因为遇到符合条件的情况提前退出,就认为不属于精准渠道配置的时间范围之内