火点重构

This commit is contained in:
liuchengqian 2023-03-29 16:22:57 +08:00
parent 98bdecd7ba
commit 266f2d4ab0
12 changed files with 22 additions and 1048 deletions

View File

@ -2,7 +2,6 @@ package com.xkrs.controller;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.FirePointPreciseDao;
import com.xkrs.dao.StreetDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointSubscribeManager;
@ -36,8 +35,6 @@ public class DispatchFirePointController {
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
@Resource
private FirePointPreciseDao firePointPreciseDao;
@Resource
private StreetDao streetDao;
private final Locale locale = LocaleContextHolder.getLocale();

View File

@ -1,10 +0,0 @@
package com.xkrs.dao;
import com.xkrs.model.entity.FirePointPreciseEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface FirePointPreciseDao extends JpaRepository<FirePointPreciseEntity, Long>, JpaSpecificationExecutor<FirePointPreciseEntity> {
}

View File

@ -3,12 +3,10 @@ package com.xkrs.helper;
import com.xkrs.dao.CountyCodeWeiXinDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.model.entity.CountyCodeWeiXinEntity;
import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.helper.PushHelper;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.utilsnew.FirePointCodeUtils;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.SMSUtils;
import com.xkrs.utilsnew.WeiXinMessageUtils;
import org.slf4j.Logger;
@ -38,11 +36,7 @@ public class FirePointPushManager {
//// pushNotification(FirePointConvertUtils.convert(firePointOrdinaryEntity), false);
// }
public void pushNotification(FirePointPreciseEntity firePointPreciseEntity) {
pushNotification(FirePointConvertUtils.convert(firePointPreciseEntity));
}
private void pushNotification(AllFirePointVo firePoint) {
private void pushNotification(FirePointOrdinaryEntity firePoint) {
//发送微信群聊消息
sendWeChatGroupMessage(firePoint);
@ -93,7 +87,7 @@ public class FirePointPushManager {
/**
* 发送微信消息
*/
private void sendWeChatGroupMessage(AllFirePointVo firePoint) {
private void sendWeChatGroupMessage(FirePointOrdinaryEntity firePoint) {
List<CountyCodeWeiXinEntity> countyCodeWeiXinList = countyCodeWeiXinDao.findAll();
if (countyCodeWeiXinList.isEmpty()) {
return;

View File

@ -1,18 +1,11 @@
package com.xkrs.helper;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.FirePointPreciseDao;
import com.xkrs.model.bean.FirePointQueryResultBean;
import com.xkrs.model.bean.VipTimeRangeBean;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.utilsnew.DateTimeUtils;
import com.xkrs.utilsnew.FirePointCodeUtils;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.JsonUtils;
import com.xkrs.utilsold.DateTimeUtil;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,9 +18,7 @@ import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@Component
public class FirePointQueryManager {
@ -37,9 +28,6 @@ public class FirePointQueryManager {
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
@Resource
private FirePointPreciseDao firePointPreciseDao;
/**
* 查询火点播报无token
*
@ -48,89 +36,15 @@ public class FirePointQueryManager {
public FirePointQueryResultBean queryFirePointBroadcast(Integer limit) {
int size = (limit != null && limit > 0) ? limit : 10;
PageRequest pageRequest = PageRequest.of(1, size, Sort.by(Sort.Direction.DESC, "satelliteTime"));
List<FirePointPreciseEntity> firePointList = firePointPreciseDao.findAll(pageRequest).getContent();
List<AllFirePointVo> resultList = new ArrayList<>();
for (FirePointPreciseEntity firePoint : firePointList) {
resultList.add(FirePointConvertUtils.convert(firePoint));
}
return new FirePointQueryResultBean(true, "", resultList, resultList.size());
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(pageRequest).getContent();
return new FirePointQueryResultBean(true, "", firePointList, firePointList.size());
}
public FirePointQueryResultBean queryFirePointBelongToUser(SysUserEntity sysUserEntity, String userSubAreaCountyCode, String startTime, String endTime, String satelliteType, String landType) {
String countyCode = ("管理员".equals(sysUserEntity.getAccountType())) ? null : sysUserEntity.getCountyCode();
String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
return queryFirePointBelongToUser(countyCode, vipTimeRangeJson, userSubAreaCountyCode, startTime, endTime, satelliteType, landType);
}
public FirePointQueryResultBean queryFirePointBelongToUser(String userCode, String vipTimeRangeJson, String userSubAreaCountyCode, String startTime, String endTime, String satelliteType, String landType) {
String noRedundantUserCode = ("管理员".equals(sysUserEntity.getAccountType())) ? null : FirePointCodeUtils.getFormatCutCode(sysUserEntity.getCountyCode());
String userSubAreaCutCountyCode = (TextUtils.isEmpty(userSubAreaCountyCode)) ? null : FirePointCodeUtils.getFormatCutCode(userSubAreaCountyCode);
String noRedundantUserCode = null;
String userSubAreaCutCountyCode = null;
final List<VipTimeRangeBean.VipTimeRangeItemBean> mVipTimeRangeItemList = new ArrayList<>();
try {
noRedundantUserCode = (TextUtils.isEmpty(userCode)) ? null : FirePointCodeUtils.getFormatCutCode(userCode);
userSubAreaCutCountyCode = (TextUtils.isEmpty(userSubAreaCountyCode)) ? null : FirePointCodeUtils.getFormatCutCode(userSubAreaCountyCode);
//如果用户的VIP时间范围数据是空就返回失败
if (TextUtils.isEmpty(vipTimeRangeJson)) {
return new FirePointQueryResultBean("User VipTimeRangeJson Error 1, vipTimeRangeJson = " + vipTimeRangeJson);
}
//反序列化用户的VIP时间范围得到对象
VipTimeRangeBean vipTimeRangeBean = JsonUtils.deserialize(vipTimeRangeJson, VipTimeRangeBean.class);
//用户注册时有初始VIP时间范围反序列化失败或无数据说明该用户的数据发生了异常返回失败
if (vipTimeRangeBean == null || vipTimeRangeBean.getList() == null || vipTimeRangeBean.getList().size() == 0) {
return new FirePointQueryResultBean("User VipTimeRangeJson Error 2, 已保存的VIP时间范围反序列化失败, vipTimeRangeJson = " + vipTimeRangeJson);
}
//得到由<开始时间 + 结束时间>组成的集合
List<VipTimeRangeBean.VipTimeRangeItemBean> vipTimeRangeItemList = vipTimeRangeBean.getList();
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemA : vipTimeRangeItemList) {
//校验用户VIP开始时间合法性
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getStartTime())) {
return new FirePointQueryResultBean("User VIP 开始时间格式不合法1, StartTime = " + vipTimeRangeItemA.getStartTime());
}
//校验用户VIP结束时间合法性
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemA.getEndTime())) {
return new FirePointQueryResultBean("User VIP 结束时间格式不合法2, EndTime = " + vipTimeRangeItemA.getEndTime());
}
LocalDateTime userStartLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
LocalDateTime userEndLocalDateTimeA = LocalDateTime.parse(vipTimeRangeItemA.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItemB : vipTimeRangeItemList) {
if (vipTimeRangeItemA != vipTimeRangeItemB) {
//校验用户VIP开始时间合法性
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getStartTime())) {
return new FirePointQueryResultBean("User VIP 开始时间格式不合法3, StartTime = " + vipTimeRangeItemB.getStartTime());
}
//校验用户VIP结束时间合法性
if (!DateTimeUtil.isValidDateTime(vipTimeRangeItemB.getEndTime())) {
return new FirePointQueryResultBean("User VIP 结束时间格式不合法4, EndTime = " + vipTimeRangeItemB.getEndTime());
}
LocalDateTime userStartLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
LocalDateTime userEndLocalDateTimeB = LocalDateTime.parse(vipTimeRangeItemB.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
//校验用户VIP开始结束时间是否存在交叉现象
if (userStartLocalDateTimeB.isBefore(userStartLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userStartLocalDateTimeA)) {
return new FirePointQueryResultBean("User VIP 开始结束时间格式不合法5, 存在交叉现象");
}
if (userStartLocalDateTimeB.isBefore(userEndLocalDateTimeA) && userEndLocalDateTimeB.isAfter(userEndLocalDateTimeA)) {
return new FirePointQueryResultBean("User VIP 开始结束时间格式不合法6, 存在交叉现象");
}
}
}
}
mVipTimeRangeItemList.addAll(vipTimeRangeItemList);
} catch (Exception e) {
e.printStackTrace();
return new FirePointQueryResultBean(e.getMessage());
}
return queryFirePointBelongToUser(noRedundantUserCode, mVipTimeRangeItemList, userSubAreaCutCountyCode, startTime, endTime, satelliteType, landType);
}
public FirePointQueryResultBean queryFirePointBelongToUser(String noRedundantUserCode, List<VipTimeRangeBean.VipTimeRangeItemBean> vipTimeRangeItemList, String userSubAreaCutCountyCode, String startTime, String endTime, String satelliteType, String landType) {
//VIP时间范围发生了异常返回失败
if (vipTimeRangeItemList == null || vipTimeRangeItemList.size() == 0) {
return new FirePointQueryResultBean("User VipTimeRangeJson Error 2, 已保存的VIP时间范围出现错误");
}
//查询未审核的普通火点
Specification<FirePointOrdinaryEntity> specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
@ -171,155 +85,11 @@ public class FirePointQueryManager {
if (!TextUtils.isEmpty(landType)) {
predicateList.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem : vipTimeRangeItemList) {
String userStartTime = vipTimeRangeItem.getStartTime();
String userEndTime = vipTimeRangeItem.getEndTime();
//早于不包含VIP开始时间
Predicate beforeStartTimePredicate = criteriaBuilder.lessThan(root.get("satelliteTime").as(String.class), userStartTime);
//晚于不包含VIP结束时间
Predicate afterEndTimePredicate = criteriaBuilder.greaterThan(root.get("satelliteTime").as(String.class), userEndTime);
predicateList.add(criteriaBuilder.or(beforeStartTimePredicate, afterEndTimePredicate));
}
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
};
//未审核的普通火点列表
List<FirePointOrdinaryEntity> firePointOrdinaryList = firePointOrdinaryDao.findAll(specificationOrdinary, Sort.by(Sort.Direction.DESC, "satelliteTime"));
//查询审核通过的精准火点
Specification<FirePointPreciseEntity> specificationPrecise = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
//非空判断
predicateList.add(criteriaBuilder.isNotNull(root.get("proCode").as(String.class)));
predicateList.add(criteriaBuilder.isNotNull(root.get("proName").as(String.class)));
predicateList.add(criteriaBuilder.isNotNull(root.get("cityCode").as(String.class)));
predicateList.add(criteriaBuilder.isNotNull(root.get("cityName").as(String.class)));
predicateList.add(criteriaBuilder.isNotNull(root.get("countyCode").as(String.class)));
predicateList.add(criteriaBuilder.isNotNull(root.get("countyName").as(String.class)));
//添加区划编码的过滤
if (!TextUtils.isEmpty(noRedundantUserCode)) {
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%"));
}
//添加子区域区划编码的过滤比如查询火点的系统用户所属的区划是山东省但是该用户目前只想查询青岛市的火点那么noRedundantUserCode=山东省区划userSubAreaCutCountyCode=青岛市区划
if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) {
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), userSubAreaCutCountyCode + "%"));
}
//开始时间查询条件
if (!TextUtils.isEmpty(startTime)) {
LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
String startTimeString = DateTimeUtils.localDateTimeToString(startTime2);
predicateList.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimeString));
}
//结束时间查询条件
if (!TextUtils.isEmpty(endTime)) {
LocalDateTime endTime1 = DateTimeUtils.stringToLocalDateTime(endTime).plusDays(1);
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
predicateList.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimeString));
}
//卫星类型查询条件
if (!TextUtils.isEmpty(satelliteType)) {
predicateList.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
//地物类型查询条件
if (!TextUtils.isEmpty(landType)) {
predicateList.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}
List<Predicate> subPredicateList = new ArrayList<>();
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem : vipTimeRangeItemList) {
String userStartTime = vipTimeRangeItem.getStartTime();
String userEndTime = vipTimeRangeItem.getEndTime();
//晚于包含VIP开始时间
Predicate beforeStartTimePredicate = criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), userStartTime);
//早于包含VIP结束时间
Predicate afterEndTimePredicate = criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), userEndTime);
subPredicateList.add(criteriaBuilder.and(beforeStartTimePredicate, afterEndTimePredicate));
}
if (subPredicateList.size() == 0) {
} else if (subPredicateList.size() == 1) {
predicateList.add(subPredicateList.get(0));
} else {
Predicate orPredicate = null;
for (int i = 1; i < subPredicateList.size(); i++) {
if (i == 1) {
orPredicate = criteriaBuilder.or(subPredicateList.get(0), subPredicateList.get(1));
} else {
orPredicate = criteriaBuilder.or(orPredicate, subPredicateList.get(i));
}
}
predicateList.add(orPredicate);
}
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
};
//审核通过的精准火点列表
List<FirePointPreciseEntity> firePointPreciseList = firePointPreciseDao.findAll(specificationPrecise, Sort.by(Sort.Direction.DESC, "satelliteTime"));
//将两种数据来源的火点合并到一起
List<AllFirePointVo> resultList = new ArrayList<>();
for (FirePointOrdinaryEntity firePointOrdinaryEntity : firePointOrdinaryList) {
resultList.add(FirePointConvertUtils.convert(firePointOrdinaryEntity));
}
for (FirePointPreciseEntity firePointPreciseEntity : firePointPreciseList) {
resultList.add(FirePointConvertUtils.convert(firePointPreciseEntity));
}
//对合并后的结果进行排序
List<AllFirePointVo> sortedResultList = resultList.stream().sorted(Comparator.comparing(AllFirePointVo::getSatelliteTime)).collect(Collectors.toList());
return new FirePointQueryResultBean(true, "", sortedResultList, sortedResultList.size());
// {
// final String commonSql = "SELECT t.id AS id, t.fire_code AS fireCode, t.county_code AS countyCode, t.county_name AS countyName, t.satellite_time AS satelliteTime, t.longitude AS longitude, t.latitude AS latitude, t.satellite_type AS satelliteType, t.land_type AS landType, t.confidence AS confidence, t.fire_image AS fireImage, t.satellite_image AS satelliteImage, t.town_code AS townCode, t.town_name AS townName, t.add_time AS addTime, t.fire_point_address AS firePointAddress, t.remark AS remark";
//
// StringBuilder ordinaryBuilder = new StringBuilder(commonSql);
// ordinaryBuilder.append(" FROM fire_point_ordinary AS t");
// ordinaryBuilder.append(" WHERE (t.town_code LIKE '" + mNoRedundantUserCode + "%')");
// ordinaryBuilder.append(" AND (");
// for (int i = 0; i < mVipTimeRangeItemList.size(); i++) {
// VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem = mVipTimeRangeItemList.get(i);
// String userStartTime = vipTimeRangeItem.getStartTime();
// String userEndTime = vipTimeRangeItem.getEndTime();
// //早于不包含VIP开始时间或者晚于不包含VIP结束时间
// if (i > 0) {
// ordinaryBuilder.append(" AND ");
// }
// ordinaryBuilder.append("(t.satellite_time<'" + userStartTime + "' OR t.satellite_time>'" + userEndTime + "')");
// }
// ordinaryBuilder.append(")");
// ordinaryBuilder.append(" ORDER BY t.satellite_time DESC");
// String ordinarySql = ordinaryBuilder.toString();
// log.info(sysUserEntity.getCountyName() + ":ordinarySql:" + ordinarySql);
// List<AllFirePointVo> voList1 = firePointOrdinaryDao.customQuery(ordinarySql);
//
// StringBuilder preciseBuilder = new StringBuilder(commonSql);
// preciseBuilder.append(" FROM fire_point_precise AS t");
// preciseBuilder.append(" WHERE (t.town_code LIKE '" + mNoRedundantUserCode + "%')");
// preciseBuilder.append(" AND (");
// for (int i = 0; i < mVipTimeRangeItemList.size(); i++) {
// VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem = mVipTimeRangeItemList.get(i);
// String userStartTime = vipTimeRangeItem.getStartTime();
// String userEndTime = vipTimeRangeItem.getEndTime();
// //晚于包含VIP开始时间并且早于包含VIP结束时间
// if (i > 0) {
// preciseBuilder.append(" OR ");
// }
// preciseBuilder.append("(t.satellite_time>='" + userStartTime + "' AND t.satellite_time<='" + userEndTime + "')");
// }
// preciseBuilder.append(")");
// preciseBuilder.append(" ORDER BY t.satellite_time DESC");
// String preciseSql = preciseBuilder.toString();
// log.info(sysUserEntity.getCountyName() + ":preciseSql:" + preciseSql);
// List<AllFirePointVo> voList2 = firePointPreciseDao.customQuery(preciseSql);
//
// //将两种数据来源的火点合并到一起
// List<AllFirePointVo> resultList = new ArrayList<>();
// resultList.addAll(voList1);
// resultList.addAll(voList2);
// //对合并后的结果进行排序
// resultList.sort(Comparator.comparing(AllFirePointVo::getSatelliteTime));
//
// return new FirePointQueryResultBean(true, "", resultList);
//
// }
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(specificationOrdinary, Sort.by(Sort.Direction.DESC, "satelliteTime"));
return new FirePointQueryResultBean(true, "", firePointList, firePointList.size());
}
}

View File

@ -1,6 +1,6 @@
package com.xkrs.model.bean;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import java.util.List;
@ -10,7 +10,7 @@ public class FirePointQueryResultBean {
private String errorMessage = null;
private List<AllFirePointVo> list = null;
private List<FirePointOrdinaryEntity> list = null;
private long count = 0L;
@ -24,7 +24,7 @@ public class FirePointQueryResultBean {
this.count = 0L;
}
public FirePointQueryResultBean(boolean success, String errorMessage, List<AllFirePointVo> list, long count) {
public FirePointQueryResultBean(boolean success, String errorMessage, List<FirePointOrdinaryEntity> list, long count) {
this.success = success;
this.errorMessage = errorMessage;
this.list = list;
@ -47,11 +47,11 @@ public class FirePointQueryResultBean {
this.errorMessage = errorMessage;
}
public List<AllFirePointVo> getList() {
public List<FirePointOrdinaryEntity> getList() {
return list;
}
public void setList(List<AllFirePointVo> list) {
public void setList(List<FirePointOrdinaryEntity> list) {
this.list = list;
}

View File

@ -1,368 +0,0 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* 审核通过的精准火点
*/
@Entity
@Table(name = "fire_point_precise")
public class FirePointPreciseEntity implements Serializable {
/**
* 指定主键建立自增序列主键值取自序列
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_precise_seq_gen")
@SequenceGenerator(name = "fire_point_precise_seq_gen", sequenceName = "fire_point_precise_id_seq", allocationSize = 1)
private Long id;
/**
* 火点编码
*/
@Column(length = 64, unique = true, columnDefinition = "varchar(64)")
private String fireCode;
/**
* 火点状态
* 0真火点
* 1或null伪火点
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String fireStatus;
/**
* 卫星监测的时间
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String satelliteTime;
/**
* 经度
*/
private Double longitude;
/**
* 纬度
*/
private Double latitude;
/**
* 卫星类型
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String satelliteType;
/**
* 植被类型
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String landType;
/**
* 置信度
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String confidence;
/**
* 当前火点的图片
*/
@Column(length = 512, columnDefinition = "varchar(512)")
private String fireImage;
/**
* 卫星影像图片
*/
@Column(length = 512, columnDefinition = "varchar(512)")
private String satelliteImage;
/**
* 添加的时间
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String addTime;
/**
* 详细地址
*/
@Column(length = 255, columnDefinition = "varchar(255)")
private String firePointAddress;
/**
* 备注
*/
@Column(length = 1024, columnDefinition = "varchar(1024)")
private String remark;
/**
* 占位符
*/
@Column(length = 1024, columnDefinition = "varchar(1024)")
private String placeHolder;
/**
* 省的编码
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String proCode;
/**
* 省的名称
*/
@Column(length = 128, columnDefinition = "varchar(128)")
private String proName;
/**
* 市的编码
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String cityCode;
/**
* 市的名称
*/
@Column(length = 128, columnDefinition = "varchar(128)")
private String cityName;
/**
* 区县的编码
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String countyCode;
/**
* 区县的名称
*/
@Column(length = 128, columnDefinition = "varchar(128)")
private String countyName;
/**
* 乡镇街道的编码
*/
@Column(length = 64, columnDefinition = "varchar(64)")
private String townCode;
/**
* 乡镇街道的名称
*/
@Column(length = 128, columnDefinition = "varchar(128)")
private String townName;
public FirePointPreciseEntity() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFireCode() {
return fireCode;
}
public void setFireCode(String fireCode) {
this.fireCode = fireCode;
}
public String getFireStatus() {
return fireStatus;
}
public void setFireStatus(String fireStatus) {
this.fireStatus = fireStatus;
}
public String getSatelliteTime() {
return satelliteTime;
}
public void setSatelliteTime(String satelliteTime) {
this.satelliteTime = satelliteTime;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public String getSatelliteType() {
return satelliteType;
}
public void setSatelliteType(String satelliteType) {
this.satelliteType = satelliteType;
}
public String getLandType() {
return landType;
}
public void setLandType(String landType) {
this.landType = landType;
}
public String getConfidence() {
return confidence;
}
public void setConfidence(String confidence) {
this.confidence = confidence;
}
public String getFireImage() {
return fireImage;
}
public void setFireImage(String fireImage) {
this.fireImage = fireImage;
}
public String getSatelliteImage() {
return satelliteImage;
}
public void setSatelliteImage(String satelliteImage) {
this.satelliteImage = satelliteImage;
}
public String getAddTime() {
return addTime;
}
public void setAddTime(String addTime) {
this.addTime = addTime;
}
public String getFirePointAddress() {
return firePointAddress;
}
public void setFirePointAddress(String firePointAddress) {
this.firePointAddress = firePointAddress;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getPlaceHolder() {
return placeHolder;
}
public void setPlaceHolder(String placeHolder) {
this.placeHolder = placeHolder;
}
public String getProCode() {
return proCode;
}
public void setProCode(String proCode) {
this.proCode = proCode;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCountyCode() {
return countyCode;
}
public void setCountyCode(String countyCode) {
this.countyCode = countyCode;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public String getTownCode() {
return townCode;
}
public void setTownCode(String townCode) {
this.townCode = townCode;
}
public String getTownName() {
return townName;
}
public void setTownName(String townName) {
this.townName = townName;
}
@Override
public String toString() {
return "FirePointPreciseEntity{" +
"id=" + id +
", fireCode='" + fireCode + '\'' +
", fireStatus='" + fireStatus + '\'' +
", satelliteTime='" + satelliteTime + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", satelliteType='" + satelliteType + '\'' +
", landType='" + landType + '\'' +
", confidence='" + confidence + '\'' +
", fireImage='" + fireImage + '\'' +
", satelliteImage='" + satelliteImage + '\'' +
", addTime='" + addTime + '\'' +
", firePointAddress='" + firePointAddress + '\'' +
", remark='" + remark + '\'' +
", placeHolder='" + placeHolder + '\'' +
", proCode='" + proCode + '\'' +
", proName='" + proName + '\'' +
", cityCode='" + cityCode + '\'' +
", cityName='" + cityName + '\'' +
", countyCode='" + countyCode + '\'' +
", countyName='" + countyName + '\'' +
", townCode='" + townCode + '\'' +
", townName='" + townName + '\'' +
'}';
}
}

View File

@ -5,8 +5,8 @@ import com.xiaomi.xmpush.server.Constants;
import com.xiaomi.xmpush.server.Message;
import com.xiaomi.xmpush.server.Result;
import com.xiaomi.xmpush.server.Sender;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.vo.AllFirePointVo;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@ -35,7 +35,7 @@ public class PushHelper {
* @param firePoint
* @throws Exception
*/
public void dispatchPushMessage(List<String> userAccountList, AllFirePointVo firePoint) throws Exception {
public void dispatchPushMessage(List<String> userAccountList, FirePointOrdinaryEntity firePoint) throws Exception {
Constants.useOfficial();
Sender sender = new Sender("f6N7nchoqOWj3YyZiQPH2w==");
String messagePayload = "This is a message";

View File

@ -1,337 +0,0 @@
package com.xkrs.model.vo;
public class AllFirePointVo {
/**
* 指定主键建立自增序列主键值取自序列
*/
private Long id;
/**
* 火点编码
*/
private String fireCode;
/**
* 火点状态
* 0真火点
* 1或null伪火点
*/
private String fireStatus;
/**
* 卫星监测的时间
*/
private String satelliteTime;
/**
* 经度
*/
private Double longitude;
/**
* 纬度
*/
private Double latitude;
/**
* 卫星类型
*/
private String satelliteType;
/**
* 植被类型
*/
private String landType;
/**
* 置信度
*/
private String confidence;
/**
* 当前火点的图片
*/
private String fireImage;
/**
* 卫星影像图片
*/
private String satelliteImage;
/**
* 添加的时间
*/
private String addTime;
/**
* 详细地址
*/
private String firePointAddress;
/**
* 备注
*/
private String remark;
/**
* 占位符
*/
private String placeHolder;
/**
* 省的编码
*/
private String proCode;
/**
* 省的名称
*/
private String proName;
/**
* 市的编码
*/
private String cityCode;
/**
* 市的名称
*/
private String cityName;
/**
* 区县的编码
*/
private String countyCode;
/**
* 区县的名称
*/
private String countyName;
/**
* 乡镇街道的编码
*/
private String townCode;
/**
* 乡镇街道的名称
*/
private String townName;
public AllFirePointVo() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFireCode() {
return fireCode;
}
public void setFireCode(String fireCode) {
this.fireCode = fireCode;
}
public String getFireStatus() {
return fireStatus;
}
public void setFireStatus(String fireStatus) {
this.fireStatus = fireStatus;
}
public String getSatelliteTime() {
return satelliteTime;
}
public void setSatelliteTime(String satelliteTime) {
this.satelliteTime = satelliteTime;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public String getSatelliteType() {
return satelliteType;
}
public void setSatelliteType(String satelliteType) {
this.satelliteType = satelliteType;
}
public String getLandType() {
return landType;
}
public void setLandType(String landType) {
this.landType = landType;
}
public String getConfidence() {
return confidence;
}
public void setConfidence(String confidence) {
this.confidence = confidence;
}
public String getFireImage() {
return fireImage;
}
public void setFireImage(String fireImage) {
this.fireImage = fireImage;
}
public String getSatelliteImage() {
return satelliteImage;
}
public void setSatelliteImage(String satelliteImage) {
this.satelliteImage = satelliteImage;
}
public String getAddTime() {
return addTime;
}
public void setAddTime(String addTime) {
this.addTime = addTime;
}
public String getFirePointAddress() {
return firePointAddress;
}
public void setFirePointAddress(String firePointAddress) {
this.firePointAddress = firePointAddress;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getPlaceHolder() {
return placeHolder;
}
public void setPlaceHolder(String placeHolder) {
this.placeHolder = placeHolder;
}
public String getProCode() {
return proCode;
}
public void setProCode(String proCode) {
this.proCode = proCode;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public String getCityCode() {
return cityCode;
}
public void setCityCode(String cityCode) {
this.cityCode = cityCode;
}
public String getCityName() {
return cityName;
}
public void setCityName(String cityName) {
this.cityName = cityName;
}
public String getCountyCode() {
return countyCode;
}
public void setCountyCode(String countyCode) {
this.countyCode = countyCode;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public String getTownCode() {
return townCode;
}
public void setTownCode(String townCode) {
this.townCode = townCode;
}
public String getTownName() {
return townName;
}
public void setTownName(String townName) {
this.townName = townName;
}
@Override
public String toString() {
return "AllFirePointVo{" +
"id=" + id +
", fireCode='" + fireCode + '\'' +
", fireStatus='" + fireStatus + '\'' +
", satelliteTime='" + satelliteTime + '\'' +
", longitude=" + longitude +
", latitude=" + latitude +
", satelliteType='" + satelliteType + '\'' +
", landType='" + landType + '\'' +
", confidence='" + confidence + '\'' +
", fireImage='" + fireImage + '\'' +
", satelliteImage='" + satelliteImage + '\'' +
", addTime='" + addTime + '\'' +
", firePointAddress='" + firePointAddress + '\'' +
", remark='" + remark + '\'' +
", placeHolder='" + placeHolder + '\'' +
", proCode='" + proCode + '\'' +
", proName='" + proName + '\'' +
", cityCode='" + cityCode + '\'' +
", cityName='" + cityName + '\'' +
", countyCode='" + countyCode + '\'' +
", countyName='" + countyName + '\'' +
", townCode='" + townCode + '\'' +
", townName='" + townName + '\'' +
'}';
}
}

View File

@ -1,7 +1,10 @@
package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.dao.*;
import com.xkrs.dao.FirePointChannelConfigDao;
import com.xkrs.dao.FirePointOrdinaryDao;
import com.xkrs.dao.StreetDao;
import com.xkrs.dao.SysUserDao;
import com.xkrs.helper.FirePointPushManager;
import com.xkrs.helper.FirePointQueryManager;
import com.xkrs.helper.GeoCodeHelper;
@ -39,9 +42,6 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
@Resource
private FirePointOrdinaryDao firePointOrdinaryDao;
@Resource
private FirePointPreciseDao firePointPreciseDao;
@Resource
private FirePointQueryManager firePointQueryManager;

View File

@ -7,10 +7,8 @@ import com.xkrs.helper.FirePointQueryManager;
import com.xkrs.model.bean.FirePointQueryResultBean;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.SysUserEntity;
import com.xkrs.model.vo.AllFirePointVo;
import com.xkrs.service.FirePointService;
import com.xkrs.utilsnew.DateTimeUtils;
import com.xkrs.utilsnew.FirePointConvertUtils;
import com.xkrs.utilsnew.TokenUtil;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger;
@ -134,8 +132,7 @@ public class FirePointServiceImpl implements FirePointService {
};
List<FirePointOrdinaryEntity> firePointOrdinaryList = firePointOrdinaryDao.findAll(specification, Sort.by(Sort.Direction.DESC, "satelliteTime"));
if (firePointOrdinaryList.size() == 1) {
AllFirePointVo firePointVo = FirePointConvertUtils.convert(firePointOrdinaryList.get(0));
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointVo, locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointOrdinaryList.get(0), locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, null, locale);
}

View File

@ -11,7 +11,7 @@ public class FirePointCodeUtils {
private FirePointCodeUtils() {
}
public static String getFormatCutCode(String code) throws Exception {
public static String getFormatCutCode(String code) {
String formatCutCode = code.trim();
while ((!TextUtils.isEmpty(formatCutCode)) && (formatCutCode.endsWith("0"))) {
formatCutCode = formatCutCode.substring(0, formatCutCode.length() - 1).trim();

View File

@ -1,69 +0,0 @@
package com.xkrs.utilsnew;
import com.xkrs.model.entity.FirePointOrdinaryEntity;
import com.xkrs.model.entity.FirePointPreciseEntity;
import com.xkrs.model.vo.AllFirePointVo;
/**
* AllFirePointVo输出格式转化工具
*/
public class FirePointConvertUtils {
private FirePointConvertUtils() {
}
public static AllFirePointVo convert(FirePointOrdinaryEntity entity) {
AllFirePointVo allFirePointVo = new AllFirePointVo();
allFirePointVo.setId(entity.getId());
allFirePointVo.setFireCode(entity.getFireCode());
allFirePointVo.setSatelliteTime(entity.getSatelliteTime());
allFirePointVo.setLongitude(entity.getLongitude());
allFirePointVo.setLatitude(entity.getLatitude());
allFirePointVo.setSatelliteType(entity.getSatelliteType());
allFirePointVo.setLandType(entity.getLandType());
allFirePointVo.setConfidence(entity.getConfidence());
allFirePointVo.setFireImage(entity.getFireImage());
allFirePointVo.setSatelliteImage(entity.getSatelliteImage());
allFirePointVo.setAddTime(entity.getAddTime());
allFirePointVo.setFirePointAddress(entity.getFirePointAddress());
allFirePointVo.setRemark(entity.getRemark());
allFirePointVo.setPlaceHolder(entity.getPlaceHolder());
allFirePointVo.setProCode(entity.getProCode());
allFirePointVo.setProName(entity.getProName());
allFirePointVo.setCityCode(entity.getCityCode());
allFirePointVo.setCityName(entity.getCityName());
allFirePointVo.setCountyCode(entity.getCountyCode());
allFirePointVo.setCountyName(entity.getCountyName());
allFirePointVo.setTownCode(entity.getTownCode());
allFirePointVo.setTownName(entity.getTownName());
return allFirePointVo;
}
public static AllFirePointVo convert(FirePointPreciseEntity entity) {
AllFirePointVo allFirePointVo = new AllFirePointVo();
allFirePointVo.setId(entity.getId());
allFirePointVo.setFireCode(entity.getFireCode());
allFirePointVo.setSatelliteTime(entity.getSatelliteTime());
allFirePointVo.setLongitude(entity.getLongitude());
allFirePointVo.setLatitude(entity.getLatitude());
allFirePointVo.setSatelliteType(entity.getSatelliteType());
allFirePointVo.setLandType(entity.getLandType());
allFirePointVo.setConfidence(entity.getConfidence());
allFirePointVo.setFireImage(entity.getFireImage());
allFirePointVo.setSatelliteImage(entity.getSatelliteImage());
allFirePointVo.setAddTime(entity.getAddTime());
allFirePointVo.setFirePointAddress(entity.getFirePointAddress());
allFirePointVo.setRemark(entity.getRemark());
allFirePointVo.setPlaceHolder(entity.getPlaceHolder());
allFirePointVo.setProCode(entity.getProCode());
allFirePointVo.setProName(entity.getProName());
allFirePointVo.setCityCode(entity.getCityCode());
allFirePointVo.setCityName(entity.getCityName());
allFirePointVo.setCountyCode(entity.getCountyCode());
allFirePointVo.setCountyName(entity.getCountyName());
allFirePointVo.setTownCode(entity.getTownCode());
allFirePointVo.setTownName(entity.getTownName());
return allFirePointVo;
}
}