重写用户获取火点数据的接口
This commit is contained in:
parent
75bf29abc1
commit
1aa674b883
@ -0,0 +1,59 @@
|
|||||||
|
package com.xkrs.straw.utils;
|
||||||
|
|
||||||
|
import com.xkrs.straw.model.entity.FirePointOrdinaryEntity;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointPreciseEntity;
|
||||||
|
import com.xkrs.straw.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.setCountyCode(entity.getCountyCode());
|
||||||
|
allFirePointVo.setCountyName(entity.getCountyName());
|
||||||
|
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.setTownCode(entity.getTownCode());
|
||||||
|
allFirePointVo.setTownName(entity.getTownName());
|
||||||
|
allFirePointVo.setAddTime(entity.getAddTime());
|
||||||
|
allFirePointVo.setFirePointAddress(entity.getFirePointAddress());
|
||||||
|
allFirePointVo.setRemark(entity.getRemark());
|
||||||
|
return allFirePointVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AllFirePointVo convert(FirePointPreciseEntity entity) {
|
||||||
|
AllFirePointVo allFirePointVo = new AllFirePointVo();
|
||||||
|
allFirePointVo.setId(entity.getId());
|
||||||
|
allFirePointVo.setFireCode(entity.getFireCode());
|
||||||
|
allFirePointVo.setCountyCode(entity.getCountyCode());
|
||||||
|
allFirePointVo.setCountyName(entity.getCountyName());
|
||||||
|
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.setTownCode(entity.getTownCode());
|
||||||
|
allFirePointVo.setTownName(entity.getTownName());
|
||||||
|
allFirePointVo.setAddTime(entity.getAddTime());
|
||||||
|
allFirePointVo.setFirePointAddress(entity.getFirePointAddress());
|
||||||
|
allFirePointVo.setRemark(entity.getRemark());
|
||||||
|
return allFirePointVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,17 +4,25 @@ import com.xkrs.straw.dao.FirePointOrdinaryDao;
|
|||||||
import com.xkrs.straw.dao.FirePointPreciseDao;
|
import com.xkrs.straw.dao.FirePointPreciseDao;
|
||||||
import com.xkrs.straw.model.bean.FirePointQueryResultBean;
|
import com.xkrs.straw.model.bean.FirePointQueryResultBean;
|
||||||
import com.xkrs.straw.model.bean.VipTimeRangeBean;
|
import com.xkrs.straw.model.bean.VipTimeRangeBean;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointOrdinaryEntity;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointPreciseEntity;
|
||||||
import com.xkrs.straw.model.entity.SysUserEntity;
|
import com.xkrs.straw.model.entity.SysUserEntity;
|
||||||
|
import com.xkrs.straw.model.vo.AllFirePointVo;
|
||||||
import com.xkrs.utils.DateTimeUtil;
|
import com.xkrs.utils.DateTimeUtil;
|
||||||
import com.xkrs.utils.DateTimeUtils;
|
import com.xkrs.utils.DateTimeUtils;
|
||||||
import com.xkrs.utils.FirePointCodeUtils;
|
import com.xkrs.utils.FirePointCodeUtils;
|
||||||
import org.apache.hc.core5.util.TextUtils;
|
import org.apache.hc.core5.util.TextUtils;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class FirePointQueryManager {
|
public class FirePointQueryManager {
|
||||||
@ -99,8 +107,57 @@ public class FirePointQueryManager {
|
|||||||
return new FirePointQueryResultBean(false, e.getMessage(), null);
|
return new FirePointQueryResultBean(false, e.getMessage(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String finalMNoRedundantUserCode = mNoRedundantUserCode;
|
||||||
|
//查询未审核的普通火点
|
||||||
|
Specification<FirePointOrdinaryEntity> specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
|
//添加区划编码的过滤
|
||||||
|
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%"));
|
||||||
|
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem : mVipTimeRangeItemList) {
|
||||||
|
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"));
|
||||||
|
|
||||||
return null;
|
|
||||||
|
//查询审核通过的精准火点
|
||||||
|
Specification<FirePointPreciseEntity> specificationPrecise = (root, criteriaQuery, criteriaBuilder) -> {
|
||||||
|
List<Predicate> predicateList = new ArrayList<>();
|
||||||
|
//添加区划编码的过滤
|
||||||
|
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%"));
|
||||||
|
for (VipTimeRangeBean.VipTimeRangeItemBean vipTimeRangeItem : mVipTimeRangeItemList) {
|
||||||
|
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);
|
||||||
|
predicateList.add(criteriaBuilder.and(beforeStartTimePredicate, afterEndTimePredicate));
|
||||||
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user