优化双火点渠道入库逻辑

This commit is contained in:
liuchengqian 2023-02-03 14:37:11 +08:00
parent ff294b8213
commit 6eebae91e9
3 changed files with 38 additions and 14 deletions

View File

@ -45,18 +45,23 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
public String debug() { public String debug() {
// FirePointChannelConfigBean firePointChannelConfigBean = new FirePointChannelConfigBean(); // FirePointChannelConfigBean firePointChannelConfigBean = new FirePointChannelConfigBean();
// firePointChannelConfigBean.setChannelName(FirePointChannelConfigBean.Precise); // firePointChannelConfigBean.setChannelName(FirePointChannelConfigBean.Ordinary);
// List<FirePointChannelConfigBean.ChannelConfig> configList = new ArrayList<>(); // List<FirePointChannelConfigBean.ChannelConfig> configList = new ArrayList<>();
// //
// FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig(); // FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig();
// channelConfig1.setStartTime("2022-01-01 00:00:00"); // channelConfig1.setStartTime("");
// channelConfig1.setEndTime("2022-09-01 00:00:00"); // channelConfig1.setEndTime("");
// configList.add(channelConfig1); // configList.add(channelConfig1);
// //
// FirePointChannelConfigBean.ChannelConfig channelConfig2 = new FirePointChannelConfigBean.ChannelConfig(); //// FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig();
// channelConfig2.setStartTime("2022-10-01 00:00:00"); //// channelConfig1.setStartTime("2022-01-01 00:00:00");
// channelConfig2.setEndTime("2022-11-01 00:00:00"); //// channelConfig1.setEndTime("2022-09-01 00:00:00");
// configList.add(channelConfig2); //// 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); // firePointChannelConfigBean.setConfigList(configList);
// String serialize = JsonUtils.<FirePointChannelConfigBean>serialize(firePointChannelConfigBean); // String serialize = JsonUtils.<FirePointChannelConfigBean>serialize(firePointChannelConfigBean);
@ -105,7 +110,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
firePointOrdinaryDao.save(firePointOrdinaryEntity); firePointOrdinaryDao.save(firePointOrdinaryEntity);
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll(); List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList); boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList);
//如果现在不属于精准渠道的时间范围那么普通渠道来的火点就入库精准火点库 //如果现在不属于精准渠道的时间范围那么普通渠道来的火点就入库精准火点库
if (!inPreciseTimeRange) { if (!inPreciseTimeRange) {
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
@ -150,7 +155,7 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间 String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll(); List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList); boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(fireCode, satelliteLocalDateTime, firePointChannelConfigEntityList);
//如果现在属于精准渠道的时间范围那么精准渠道来的火点就入库精准火点库 //如果现在属于精准渠道的时间范围那么精准渠道来的火点就入库精准火点库
if (inPreciseTimeRange) { if (inPreciseTimeRange) {
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity(); FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();

View File

@ -4,6 +4,7 @@ import com.xkrs.straw.model.bean.FirePointChannelConfigBean;
import com.xkrs.straw.model.entity.FirePointChannelConfigEntity; import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
import com.xkrs.straw.service.impl.DispatchFirePointServiceImpl; import com.xkrs.straw.service.impl.DispatchFirePointServiceImpl;
import com.xkrs.utils.DateTimeUtils; import com.xkrs.utils.DateTimeUtils;
import com.xkrs.utils.SMSUtils;
import org.apache.hc.core5.util.TextUtils; import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -18,10 +19,16 @@ public class DispatchFirePointUtils {
private DispatchFirePointUtils() { private DispatchFirePointUtils() {
} }
public static boolean checkIfInPreciseTimeRange(LocalDateTime satelliteLocalDateTime, List<FirePointChannelConfigEntity> firePointChannelConfigEntityList) { public static boolean checkIfInPreciseTimeRange(String fireCode, LocalDateTime satelliteLocalDateTime, List<FirePointChannelConfigEntity> firePointChannelConfigEntityList) {
if (firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 0) { if (firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 0) {
//TODO 报错发短信通知我 int resValue1 = 0;
log.info("系统报错checkIfInPreciseTimeRange firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 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; return true;
} }
for (FirePointChannelConfigEntity firePointChannelConfigEntity : firePointChannelConfigEntityList) { for (FirePointChannelConfigEntity firePointChannelConfigEntity : firePointChannelConfigEntityList) {
@ -30,8 +37,14 @@ public class DispatchFirePointUtils {
if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) { if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) {
List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList(); List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList();
if (channelConfigList == null || channelConfigList.size() == 0) { if (channelConfigList == null || channelConfigList.size() == 0) {
//TODO 报错发短信通知我 int resValue1 = 0;
log.info("系统报错checkIfInPreciseTimeRange channelConfigList == null || channelConfigList.size() == 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; return true;
} }
for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) { for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) {

View File

@ -13,6 +13,12 @@ import com.tencentcloudapi.sms.v20190711.models.SendSmsResponse;
*/ */
public class SMSUtils { 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) { public static int sendSmsToUser(String[] phoneNumbers, String templateId, String[] templateParams) {
int resValue = 0; int resValue = 0;
try { try {