diff --git a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java index 1504f57..07bbff6 100644 --- a/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java +++ b/src/main/java/com/xkrs/straw/service/impl/DispatchFirePointServiceImpl.java @@ -45,18 +45,23 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { public String debug() { // FirePointChannelConfigBean firePointChannelConfigBean = new FirePointChannelConfigBean(); -// firePointChannelConfigBean.setChannelName(FirePointChannelConfigBean.Precise); +// firePointChannelConfigBean.setChannelName(FirePointChannelConfigBean.Ordinary); // List configList = new ArrayList<>(); // // FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig(); -// channelConfig1.setStartTime("2022-01-01 00:00:00"); -// channelConfig1.setEndTime("2022-09-01 00:00:00"); +// channelConfig1.setStartTime(""); +// channelConfig1.setEndTime(""); // configList.add(channelConfig1); // -// FirePointChannelConfigBean.ChannelConfig channelConfig2 = new FirePointChannelConfigBean.ChannelConfig(); -// channelConfig2.setStartTime("2022-10-01 00:00:00"); -// channelConfig2.setEndTime("2022-11-01 00:00:00"); -// configList.add(channelConfig2); +//// FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig(); +//// channelConfig1.setStartTime("2022-01-01 00:00:00"); +//// channelConfig1.setEndTime("2022-09-01 00:00:00"); +//// configList.add(channelConfig1); +// +//// FirePointChannelConfigBean.ChannelConfig channelConfig2 = new FirePointChannelConfigBean.ChannelConfig(); +//// channelConfig2.setStartTime("2022-10-01 00:00:00"); +//// channelConfig2.setEndTime("2022-11-01 00:00:00"); +//// configList.add(channelConfig2); // // firePointChannelConfigBean.setConfigList(configList); // String serialize = JsonUtils.serialize(firePointChannelConfigBean); @@ -105,7 +110,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { firePointOrdinaryDao.save(firePointOrdinaryEntity); List firePointChannelConfigEntityList = channelConfigDao.findAll(); - boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList); + boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); //如果现在不属于精准渠道的时间范围,那么普通渠道来的火点就入库精准火点库 if (!inPreciseTimeRange) { FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); @@ -150,7 +155,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService { String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间 List firePointChannelConfigEntityList = channelConfigDao.findAll(); - boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList); + boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList); //如果现在属于精准渠道的时间范围,那么精准渠道来的火点就入库精准火点库 if (inPreciseTimeRange) { FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); diff --git a/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java b/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java index e97046b..22afefa 100644 --- a/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java +++ b/src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java @@ -4,6 +4,7 @@ import com.xkrs.straw.model.bean.FirePointChannelConfigBean; import com.xkrs.straw.model.entity.FirePointChannelConfigEntity; import com.xkrs.straw.service.impl.DispatchFirePointServiceImpl; import com.xkrs.utils.DateTimeUtils; +import com.xkrs.utils.SMSUtils; import org.apache.hc.core5.util.TextUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -18,10 +19,16 @@ public class DispatchFirePointUtils { private DispatchFirePointUtils() { } - public static boolean checkIfInPreciseTimeRange(LocalDateTime satelliteLocalDateTime, List firePointChannelConfigEntityList) { + public static boolean checkIfInPreciseTimeRange(String fireCode, LocalDateTime satelliteLocalDateTime, List firePointChannelConfigEntityList) { if (firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 0) { - //TODO 报错,发短信通知我 - log.info("系统报错:checkIfInPreciseTimeRange firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.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; } for (FirePointChannelConfigEntity firePointChannelConfigEntity : firePointChannelConfigEntityList) { @@ -30,8 +37,14 @@ public class DispatchFirePointUtils { if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) { List channelConfigList = firePointChannelConfigBean.getConfigList(); if (channelConfigList == null || channelConfigList.size() == 0) { - //TODO 报错,发短信通知我 - log.info("系统报错:checkIfInPreciseTimeRange 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; } for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) { diff --git a/src/main/java/com/xkrs/utils/SMSUtils.java b/src/main/java/com/xkrs/utils/SMSUtils.java index a010c53..446cda9 100644 --- a/src/main/java/com/xkrs/utils/SMSUtils.java +++ b/src/main/java/com/xkrs/utils/SMSUtils.java @@ -13,6 +13,12 @@ import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse; */ public class SMSUtils { + public static void main(String[] args) { + String errorMessage = "星科瑞升-秸秆火后台系统报错-检查火点卫星时间是否在精准渠道配置时间范围内-数据库配置项-时间列表-为null或size=0-火点编码=20230201021511011713127"; + int sendSmsToUser = sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{errorMessage}); + System.out.println("sendSmsToUser = " + sendSmsToUser); + } + public static int sendSmsToUser(String[] phoneNumbers, String templateId, String[] templateParams) { int resValue = 0; try {