山东临时火点表到全国火点表的新逻辑

This commit is contained in:
liuchengqian 2022-06-02 22:10:17 +08:00
parent 813dfbeace
commit 6488f40bb7
4 changed files with 60 additions and 46 deletions

View File

@ -6,7 +6,10 @@ import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.dao.FirePointDao;
import com.xkrs.dao.ShanDongFirePointDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.*;
import com.xkrs.model.entity.FirePoint;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.entity.ShanDongFirePointEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.qo.AuditFireTypeQo;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo;
@ -15,11 +18,13 @@ import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService;
import com.xkrs.websocket.service.WebSocketServer;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import javax.transaction.Transactional;
import java.io.IOException;
import java.util.ArrayList;
@ -134,26 +139,25 @@ public class FirePointController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
/**
* 发短息
*
* @return
*/
@GetMapping("/sem")
public String sem() {
@GetMapping("/queryshandongfirepointbytime")
public String queryShanDongFirePointByTime(@RequestParam(required = false, value = "startTime") String startTime, @RequestParam(required = false, value = "endTime") String endTime) {
Locale locale = LocaleContextHolder.getLocale();
CountyCodeWeiXinEntity countyCodeWeiXinEntity = new CountyCodeWeiXinEntity();
countyCodeWeiXinEntity.setCountyCode("370000");
countyCodeWeiXinEntity.setWeixinId("18447024917@chatroom");
countyCodeWeiXinDao.save(countyCodeWeiXinEntity);
// try {
// WDWxSendMsgUtil.sendMsg("18447024917@chatroom", "微信发消息测试66666", 0);
// } catch (Exception e) {
// e.printStackTrace();
// }
// SendSms.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{"荒岛66666"});
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "shanDongFirePointList", locale);
Specification<ShanDongFirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
};
List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(specification);
if (shanDongFirePointList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, shanDongFirePointList, locale);
}
/**

View File

@ -10,7 +10,6 @@ import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService;
import com.xkrs.utils.*;
import org.apache.http.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig;
@ -142,7 +141,7 @@ public class FirePointServiceImpl implements FirePointService {
FirePointEntity savedFirePointEntity = firePointDao.save(firePointEntity);
//如果开关关闭了山东的火点发送短信微信
if ((!switchOpened) && firePointEntity.getCountyCode().startsWith("37")) {
sendBroadcast(firePointEntity.getStreetCode(), firePointEntity.getFirePointAddress());
sendBroadcast(firePointEntity);
}
return savedFirePointEntity;
}
@ -301,7 +300,7 @@ public class FirePointServiceImpl implements FirePointService {
//如果开关关闭了山东的火点发送短信微信
if (firePointEntity.getCountyCode().startsWith("37")) {
sendBroadcast(firePointEntity.getStreetCode(), firePointEntity.getFirePointAddress());
sendBroadcast(firePointEntity);
}
}
shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState);
@ -309,20 +308,19 @@ public class FirePointServiceImpl implements FirePointService {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
private void sendBroadcast(String firePointStreetCode, String firePointAddress) {
private void sendBroadcast(FirePointEntity firePointEntity) {
//发送微信消息
sendWeiXinMessage(firePointStreetCode, firePointAddress);
sendWeiXinMessage(firePointEntity);
//发送短信消息
sendSMSMessage(firePointStreetCode, firePointAddress);
sendSMSMessage(firePointEntity);
}
/**
* 发送微信消息
*
* @param firePointStreetCode
* @param firePointAddress
* @param firePointEntity
*/
private void sendWeiXinMessage(String firePointStreetCode, String firePointAddress) {
private void sendWeiXinMessage(FirePointEntity firePointEntity) {
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
if (countyCodeWeiXinList.isEmpty()) {
return;
@ -331,12 +329,12 @@ public class FirePointServiceImpl implements FirePointService {
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
String countyCode = countyCodeWeiXin.getCountyCode();
String startCountyCode = getStartCountyCode(countyCode);
if ((!TextUtils.isEmpty(startCountyCode)) && firePointStreetCode.startsWith(startCountyCode)) {
if (firePointEntity.getStreetCode().startsWith(startCountyCode)) {
weixinIdList.add(countyCodeWeiXin.getWeixinId());
}
}
if (weixinIdList.size() > 0) {
String content = "【星科瑞升】您注册的区域卫星监测到疑似火点," + firePointAddress + "\n请登录系统查看";
String content = "【星科瑞升】您注册的区域卫星监测到疑似火点," + firePointEntity.getFirePointAddress() + "\n请登录系统查看";
for (String weixinId : weixinIdList) {
try {
WDWxSendMsgUtil.sendMsg(weixinId, content, 0);
@ -350,26 +348,36 @@ public class FirePointServiceImpl implements FirePointService {
/**
* 发送短信消息
*
* @param firePointStreetCode
* @param firePointAddress
* @param firePointEntity
*/
private void sendSMSMessage(String firePointStreetCode, String firePointAddress) {
private void sendSMSMessage(FirePointEntity firePointEntity) {
List<SysUserEntity> sysUserList = sysUserDao.findAll();
if (sysUserList.isEmpty()) {
return;
}
List<String> telephoneList = new ArrayList<>();
for (SysUserEntity sysUser : sysUserList) {
try {
String countyCode = sysUser.getCountyCode();
String startCountyCode = getStartCountyCode(countyCode);
if ((!TextUtils.isEmpty(startCountyCode)) && firePointStreetCode.startsWith(startCountyCode)) {
if (firePointEntity.getStreetCode().startsWith(startCountyCode)) {
if (sysUser.getReceiveSms() != 1) {
continue;
}
LocalDateTime sysUserOverDateTime = DateTimeUtil.stringToDateTimeFormatter(sysUser.getOverTime(), DateTimeUtil.COMMON_FORMATTER_DATETIME);
if (sysUserOverDateTime.isBefore(DateTimeUtil.getNowTime())) {
continue;
}
telephoneList.add("86" + sysUser.getUserName());
}
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
if (telephoneList.size() > 0) {
// String[] telephoneArray = telephoneList.toArray(new String[]{});
String[] telephoneArray = new String[]{"8615764226530"};
SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointAddress});
String[] telephoneArray = telephoneList.toArray(new String[]{});
SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointEntity.getFirePointAddress()});
}
}

View File

@ -167,6 +167,8 @@ public class SysUserServiceImpl implements SysUserService {
sysUserEntity.setLoginNum(0);
sysUserEntity.setCountyCode(countyCode);
sysUserEntity.setCountyName(countyName);
sysUserEntity.setVipLevel(0);
sysUserEntity.setReceiveSms(0);
sysUserDao.save(sysUserEntity);
RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();

View File

@ -15,11 +15,11 @@ import java.util.regex.Pattern;
*/
public class DateTimeUtil {
private final static String COMMON_PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";
private final static String COMMON_PATTERN_DATE = "yyyy-MM-dd";
private final static DateTimeFormatter COMMON_FORMATTER_DATETIME = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATETIME);
private final static DateTimeFormatter COMMON_FORMATTER_DATE = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATE);
private final static ZoneOffset DEFAULT_ZONE_OFFSET = ZoneOffset.of("+8");
public final static String COMMON_PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";
public final static String COMMON_PATTERN_DATE = "yyyy-MM-dd";
public final static DateTimeFormatter COMMON_FORMATTER_DATETIME = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATETIME);
public final static DateTimeFormatter COMMON_FORMATTER_DATE = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATE);
public final static ZoneOffset DEFAULT_ZONE_OFFSET = ZoneOffset.of("+8");
/**
* 字符串转LocalDate