火点重构-完善防火季订阅
This commit is contained in:
parent
be55e7b47a
commit
2c0420d20b
@ -6,6 +6,7 @@ import com.xkrs.model.entity.CountyCodeWeiXinEntity;
|
||||
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
||||
import com.xkrs.model.entity.SysUserEntity;
|
||||
import com.xkrs.model.helper.PushHelper;
|
||||
import com.xkrs.utilsnew.DateTimeUtils;
|
||||
import com.xkrs.utilsnew.FirePointCodeUtils;
|
||||
import com.xkrs.utilsnew.SMSUtils;
|
||||
import com.xkrs.utilsnew.WeiXinMessageUtils;
|
||||
@ -15,6 +16,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -32,11 +34,7 @@ public class FirePointPushManager {
|
||||
@Resource
|
||||
private PushHelper pushHelper;
|
||||
|
||||
// public void pushNotification(FirePointOrdinaryEntity firePointOrdinaryEntity) {
|
||||
//// pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false);
|
||||
// }
|
||||
|
||||
private void pushNotification(FirePointOrdinaryEntity firePoint) {
|
||||
public void pushNotification(FirePointOrdinaryEntity firePoint) {
|
||||
//发送微信群聊消息
|
||||
sendWeChatGroupMessage(firePoint);
|
||||
|
||||
@ -73,14 +71,17 @@ public class FirePointPushManager {
|
||||
sendResult = "短信通知发送失败!";
|
||||
}
|
||||
//记录短信通知日志
|
||||
StringBuilder stringBuilder = new StringBuilder("发送人:青岛星科瑞升信息科技有限公司\n");
|
||||
for (String telephone : telephoneArray) {
|
||||
stringBuilder.append("接收人:").append(telephone).append("\n");
|
||||
String nowTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("开始统计发送短信").append(nowTime).append("\n");
|
||||
builder.append("发送人:青岛星科瑞升信息科技有限公司").append("\n");
|
||||
builder.append("火点详情:").append(firePoint.toString()).append("\n");
|
||||
for (SysUserEntity smsReceiver : smsReceiverList) {
|
||||
builder.append("接收人姓名:").append(smsReceiver.getReallyName()).append(",手机号:").append(smsReceiver.getUserName()).append(",区划编码:").append(smsReceiver.getCountyCode()).append(",区划名称:").append(smsReceiver.getCountyName()).append("\n");
|
||||
}
|
||||
stringBuilder.append("模板参数:").append(firePoint.getFirePointAddress()).append("\n");
|
||||
stringBuilder.append("超级详细的参数:").append(firePoint.toString()).append("\n");
|
||||
stringBuilder.append(sendResult);
|
||||
log.info(stringBuilder.toString());
|
||||
builder.append(sendResult).append("\n");
|
||||
builder.append("结束统计发送短信").append(nowTime).append("\n");
|
||||
log.info(builder.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,12 @@ import com.xkrs.model.qo.AllFirePointQo;
|
||||
import com.xkrs.model.qo.UpdateFirePointQo;
|
||||
import com.xkrs.service.DispatchFirePointService;
|
||||
import com.xkrs.utilsnew.DateTimeUtils;
|
||||
import com.xkrs.utilsnew.ErrorInfoLogUtils;
|
||||
import com.xkrs.utilsnew.FirePointFilterUtils;
|
||||
import org.apache.hc.core5.util.TextUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -165,16 +165,18 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
@Override
|
||||
public String updateFirePoint(UpdateFirePointQo updateFirePointQo) {
|
||||
List<UpdateFirePointQo.DataDTO> list = updateFirePointQo.getData();
|
||||
//先遍历一遍接收到的参数集合,参数不合法就返回错误,参数全部OK就进入下面的循环更新火点状态
|
||||
for (UpdateFirePointQo.DataDTO item : list) {
|
||||
String fireCode = item.getFireCode();
|
||||
String status = item.getStatus();
|
||||
if ((!TextUtils.isEmpty(fireCode)) && (!TextUtils.isEmpty(status)) && (("0".equals(status)) || ("1".equals(status)))) {
|
||||
System.out.println("参数正常:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
} else {
|
||||
System.out.println("参数异常:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
ErrorInfoLogUtils.log("updateFirePoint 参数异常:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "更新失败", locale);
|
||||
}
|
||||
}
|
||||
//参数全部OK,更新火点状态
|
||||
for (UpdateFirePointQo.DataDTO item : list) {
|
||||
try {
|
||||
String fireCode = item.getFireCode();
|
||||
@ -186,14 +188,15 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||
Predicate[] predicateArray = new Predicate[predicateList.size()];
|
||||
return criteriaBuilder.and(predicateList.toArray(predicateArray));
|
||||
};
|
||||
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime"));
|
||||
if (firePointList.isEmpty()) {
|
||||
System.out.println("操作异常,审核系统发送的fireCode在秸秆系统已有的火点中找不到:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
//根据fireCode找到火点
|
||||
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(specification);
|
||||
if (firePointList.size() == 1) {
|
||||
FirePointOrdinaryEntity firePoint = firePointList.get(0);
|
||||
firePoint.setFireStatus(status);//设置属性
|
||||
firePointOrdinaryDao.save(firePoint);//数据库保存
|
||||
firePointPushManager.pushNotification(firePoint);//将火点消息通知用户
|
||||
} else {
|
||||
for (FirePointOrdinaryEntity firePoint : firePointList) {
|
||||
firePoint.setFireStatus(status);
|
||||
firePointOrdinaryDao.save(firePoint);
|
||||
}
|
||||
ErrorInfoLogUtils.log("操作异常,审核系统发送的fireCode在秸秆系统中size() != 1:fireCode = " + fireCode + ",status = " + fireCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
24
src/main/java/com/xkrs/utilsnew/ErrorInfoLogUtils.java
Normal file
24
src/main/java/com/xkrs/utilsnew/ErrorInfoLogUtils.java
Normal file
@ -0,0 +1,24 @@
|
||||
package com.xkrs.utilsnew;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ErrorInfoLogUtils {
|
||||
|
||||
private ErrorInfoLogUtils() {
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ErrorInfoLogUtils.class);
|
||||
|
||||
public static void log(String message) {
|
||||
log(message, true);
|
||||
}
|
||||
|
||||
public static void log(String message, boolean sendSms) {
|
||||
logger.info(message);
|
||||
if (sendSms) {
|
||||
SMSUtils.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{message});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -42,9 +42,6 @@ public class FirePointCodeUtils {
|
||||
try {
|
||||
String formatCutCode = FirePointCodeUtils.getFormatCutCode(sysUser.getCountyCode());
|
||||
if (firePointStreetCode.startsWith(formatCutCode)) {
|
||||
if (TextUtils.isEmpty(sysUser.getPlaceHolder())) {//不是超级用户不发短信
|
||||
continue;
|
||||
}
|
||||
if (sysUser.getActiveFlag() != 0) {//被禁用的用户不发短信
|
||||
continue;
|
||||
}
|
||||
@ -55,10 +52,8 @@ public class FirePointCodeUtils {
|
||||
continue;
|
||||
}
|
||||
boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(sysUser.getVipTimeRangeJson());
|
||||
if (inVipTimeRange) {
|
||||
//VIP用户可以接收短信
|
||||
} else {
|
||||
//普通用户可以接收3条短信
|
||||
if (!inVipTimeRange) {
|
||||
//普通用户最多可以接收3条短信
|
||||
Long receiveSmsCount = sysUser.getReceiveSmsCount();
|
||||
if (receiveSmsCount != null && receiveSmsCount >= 3) {
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user