1.优化微信通知文案

2.按照卫星时间倒序返回火点信息
This commit is contained in:
liuchengqian 2022-06-03 15:21:57 +08:00
parent 91d9451f7b
commit 68b514d815
2 changed files with 27 additions and 18 deletions

View File

@ -18,6 +18,7 @@ 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.domain.Sort;
import org.springframework.data.jpa.domain.Specification; 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.*;
@ -104,7 +105,7 @@ public class FirePointController {
@GetMapping("/queryshandongfirepointlist") @GetMapping("/queryshandongfirepointlist")
public String queryShanDongFirePointList() { public String queryShanDongFirePointList() {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(); List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime"));
if (shanDongFirePointList.isEmpty()) { if (shanDongFirePointList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
} }
@ -155,7 +156,7 @@ public class FirePointController {
Predicate[] predicates = new Predicate[list.size()]; Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates)); return criteriaBuilder.and(list.toArray(predicates));
}; };
List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(specification); List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime"));
if (shanDongFirePointList.isEmpty()) { if (shanDongFirePointList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
} }

View File

@ -203,16 +203,8 @@ public class FirePointServiceImpl implements FirePointService {
log.info("-------发现新山东火点"); log.info("-------发现新山东火点");
ShanDongFirePointEntity savedFirePointEntity = shanDongFirePointDao.save(firePointEntity); ShanDongFirePointEntity savedFirePointEntity = shanDongFirePointDao.save(firePointEntity);
try {//微信消息通知工作组 try {//微信消息通知工作组
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); String messageContent = getMessageContent(firePointEntity);
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude()); WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
String countyName = firePointEntity.getCountyName();
String content = firePointEntity.getSatelliteType() + "发现1个火点。\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName;
try {
WDWxSendMsgUtil.sendMsg("18447024917@chatroom", content, 0);
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -350,14 +342,10 @@ public class FirePointServiceImpl implements FirePointService {
} }
} }
if (weixinIdList.size() > 0) { if (weixinIdList.size() > 0) {
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000"); String messageContent = getMessageContent(firePointEntity);
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
String countyName = firePointEntity.getCountyName();
String content = firePointEntity.getSatelliteType() + "发现1个火点。\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName;
for (String weixinId : weixinIdList) { for (String weixinId : weixinIdList) {
try { try {
WDWxSendMsgUtil.sendMsg(weixinId, content, 0); WDWxSendMsgUtil.sendMsg(weixinId, messageContent, 0);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -365,6 +353,26 @@ public class FirePointServiceImpl implements FirePointService {
} }
} }
private String getMessageContent(FirePointEntity firePointEntity) {
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
String satelliteTime = firePointEntity.getSatelliteTime();
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
String countyName = firePointEntity.getCountyName();
String content = firePointEntity.getSatelliteType() + "发现1个火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName;
return content;
}
private String getMessageContent(ShanDongFirePointEntity firePointEntity) {
java.text.DecimalFormat decimalFormat = new DecimalFormat("#.000000");
String satelliteTime = firePointEntity.getSatelliteTime();
String formatLongitude = decimalFormat.format(firePointEntity.getLongitude());
String formatLatitude = decimalFormat.format(firePointEntity.getLatitude());
String countyName = firePointEntity.getCountyName();
String content = firePointEntity.getSatelliteType() + "发现1个待审核火点。\n卫星时间" + satelliteTime + "\nlongitude" + formatLongitude + "\nlatitude" + formatLatitude + "\ncountyName" + countyName;
return content;
}
/** /**
* 发送短信消息 * 发送短信消息
* *