This commit is contained in:
liuchengqian 2023-02-14 10:12:02 +08:00
parent 642327f88f
commit 27366b8826

View File

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