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

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.FirePointDao;
import com.xkrs.dao.ShanDongFirePointDao; import com.xkrs.dao.ShanDongFirePointDao;
import com.xkrs.dao.SysUserDao; 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.AuditFireTypeQo;
import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo; import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo;
@ -15,11 +18,13 @@ import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService; import com.xkrs.service.StreetService;
import com.xkrs.websocket.service.WebSocketServer; import com.xkrs.websocket.service.WebSocketServer;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -134,26 +139,25 @@ public class FirePointController {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
} }
/** @GetMapping("/queryshandongfirepointbytime")
* 发短息 public String queryShanDongFirePointByTime(@RequestParam(required = false, value = "startTime") String startTime, @RequestParam(required = false, value = "endTime") String endTime) {
*
* @return
*/
@GetMapping("/sem")
public String sem() {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
Specification<ShanDongFirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
CountyCodeWeiXinEntity countyCodeWeiXinEntity = new CountyCodeWeiXinEntity(); List<Predicate> list = new ArrayList<>();
countyCodeWeiXinEntity.setCountyCode("370000"); if (startTime != null && !"".equals(startTime)) {
countyCodeWeiXinEntity.setWeixinId("18447024917@chatroom"); list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
countyCodeWeiXinDao.save(countyCodeWeiXinEntity); }
// try { if (endTime != null && !"".equals(endTime)) {
// WDWxSendMsgUtil.sendMsg("18447024917@chatroom", "微信发消息测试66666", 0); list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
// } catch (Exception e) { }
// e.printStackTrace(); Predicate[] predicates = new Predicate[list.size()];
// } return criteriaBuilder.and(list.toArray(predicates));
// SendSms.sendSmsToUser(new String[]{"8615764226530"}, "1425995", new String[]{"荒岛66666"}); };
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "shanDongFirePointList", locale); 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.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService; import com.xkrs.service.FirePointService;
import com.xkrs.utils.*; import com.xkrs.utils.*;
import org.apache.http.util.TextUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
@ -142,7 +141,7 @@ public class FirePointServiceImpl implements FirePointService {
FirePointEntity savedFirePointEntity = firePointDao.save(firePointEntity); FirePointEntity savedFirePointEntity = firePointDao.save(firePointEntity);
//如果开关关闭了山东的火点发送短信微信 //如果开关关闭了山东的火点发送短信微信
if ((!switchOpened) && firePointEntity.getCountyCode().startsWith("37")) { if ((!switchOpened) && firePointEntity.getCountyCode().startsWith("37")) {
sendBroadcast(firePointEntity.getStreetCode(), firePointEntity.getFirePointAddress()); sendBroadcast(firePointEntity);
} }
return savedFirePointEntity; return savedFirePointEntity;
} }
@ -301,7 +300,7 @@ public class FirePointServiceImpl implements FirePointService {
//如果开关关闭了山东的火点发送短信微信 //如果开关关闭了山东的火点发送短信微信
if (firePointEntity.getCountyCode().startsWith("37")) { if (firePointEntity.getCountyCode().startsWith("37")) {
sendBroadcast(firePointEntity.getStreetCode(), firePointEntity.getFirePointAddress()); sendBroadcast(firePointEntity);
} }
} }
shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState); shanDongFirePointDao.updateVerifyStateByFireCode(fireCode, verifyState);
@ -309,20 +308,19 @@ public class FirePointServiceImpl implements FirePointService {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale); 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 firePointEntity
* @param firePointAddress
*/ */
private void sendWeiXinMessage(String firePointStreetCode, String firePointAddress) { private void sendWeiXinMessage(FirePointEntity firePointEntity) {
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll(); List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
if (countyCodeWeiXinList.isEmpty()) { if (countyCodeWeiXinList.isEmpty()) {
return; return;
@ -331,12 +329,12 @@ public class FirePointServiceImpl implements FirePointService {
for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) { for (CountyCodeWeiXinEntity countyCodeWeiXin : countyCodeWeiXinList) {
String countyCode = countyCodeWeiXin.getCountyCode(); String countyCode = countyCodeWeiXin.getCountyCode();
String startCountyCode = getStartCountyCode(countyCode); String startCountyCode = getStartCountyCode(countyCode);
if ((!TextUtils.isEmpty(startCountyCode)) && firePointStreetCode.startsWith(startCountyCode)) { if (firePointEntity.getStreetCode().startsWith(startCountyCode)) {
weixinIdList.add(countyCodeWeiXin.getWeixinId()); weixinIdList.add(countyCodeWeiXin.getWeixinId());
} }
} }
if (weixinIdList.size() > 0) { if (weixinIdList.size() > 0) {
String content = "【星科瑞升】您注册的区域卫星监测到疑似火点," + firePointAddress + "\n请登录系统查看"; String content = "【星科瑞升】您注册的区域卫星监测到疑似火点," + firePointEntity.getFirePointAddress() + "\n请登录系统查看";
for (String weixinId : weixinIdList) { for (String weixinId : weixinIdList) {
try { try {
WDWxSendMsgUtil.sendMsg(weixinId, content, 0); WDWxSendMsgUtil.sendMsg(weixinId, content, 0);
@ -350,26 +348,36 @@ public class FirePointServiceImpl implements FirePointService {
/** /**
* 发送短信消息 * 发送短信消息
* *
* @param firePointStreetCode * @param firePointEntity
* @param firePointAddress
*/ */
private void sendSMSMessage(String firePointStreetCode, String firePointAddress) { private void sendSMSMessage(FirePointEntity firePointEntity) {
List<SysUserEntity> sysUserList = sysUserDao.findAll(); List<SysUserEntity> sysUserList = sysUserDao.findAll();
if (sysUserList.isEmpty()) { if (sysUserList.isEmpty()) {
return; return;
} }
List<String> telephoneList = new ArrayList<>(); List<String> telephoneList = new ArrayList<>();
for (SysUserEntity sysUser : sysUserList) { for (SysUserEntity sysUser : sysUserList) {
String countyCode = sysUser.getCountyCode(); try {
String startCountyCode = getStartCountyCode(countyCode); String countyCode = sysUser.getCountyCode();
if ((!TextUtils.isEmpty(startCountyCode)) && firePointStreetCode.startsWith(startCountyCode)) { String startCountyCode = getStartCountyCode(countyCode);
telephoneList.add("86" + sysUser.getUserName()); 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) { if (telephoneList.size() > 0) {
// String[] telephoneArray = telephoneList.toArray(new String[]{}); String[] telephoneArray = telephoneList.toArray(new String[]{});
String[] telephoneArray = new String[]{"8615764226530"}; SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointEntity.getFirePointAddress()});
SendSms.sendSmsToUser(telephoneArray, "1425995", new String[]{firePointAddress});
} }
} }

View File

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

View File

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