2023-03-08 14:06:14 +08:00
|
|
|
|
package com.xkrs.helper;
|
2023-02-23 17:23:55 +08:00
|
|
|
|
|
2023-03-08 14:06:14 +08:00
|
|
|
|
import com.xkrs.dao.FirePointOrdinaryDao;
|
|
|
|
|
import com.xkrs.model.bean.FirePointQueryResultBean;
|
|
|
|
|
import com.xkrs.model.entity.FirePointOrdinaryEntity;
|
|
|
|
|
import com.xkrs.model.entity.SysUserEntity;
|
2023-03-14 16:32:31 +08:00
|
|
|
|
import com.xkrs.utilsnew.DateTimeUtils;
|
|
|
|
|
import com.xkrs.utilsnew.FirePointCodeUtils;
|
2023-04-13 09:04:35 +08:00
|
|
|
|
import com.xkrs.utilsnew.VipTimeRangeUtils;
|
2023-02-23 17:23:55 +08:00
|
|
|
|
import org.apache.hc.core5.util.TextUtils;
|
2023-03-01 16:14:48 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2023-03-07 09:57:39 +08:00
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
2023-03-01 16:18:46 +08:00
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
2023-02-23 17:23:55 +08:00
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
2023-03-01 16:18:46 +08:00
|
|
|
|
import javax.persistence.criteria.Predicate;
|
2023-02-24 10:45:27 +08:00
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
2023-02-23 17:23:55 +08:00
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
|
public class FirePointQueryManager {
|
|
|
|
|
|
2023-03-01 16:14:48 +08:00
|
|
|
|
public static Logger log = LoggerFactory.getLogger(FirePointQueryManager.class);
|
|
|
|
|
|
2023-02-23 17:23:55 +08:00
|
|
|
|
@Resource
|
|
|
|
|
private FirePointOrdinaryDao firePointOrdinaryDao;
|
|
|
|
|
|
2023-03-07 10:14:14 +08:00
|
|
|
|
/**
|
|
|
|
|
* 查询火点播报(无token)
|
|
|
|
|
*
|
|
|
|
|
* @param limit 最大数量
|
|
|
|
|
*/
|
2023-03-07 09:57:39 +08:00
|
|
|
|
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"));
|
2023-03-29 16:22:57 +08:00
|
|
|
|
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(pageRequest).getContent();
|
|
|
|
|
return new FirePointQueryResultBean(true, "", firePointList, firePointList.size());
|
2023-03-07 09:57:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 17:28:09 +08:00
|
|
|
|
public FirePointQueryResultBean queryFirePointBelongToUser(SysUserEntity sysUserEntity, String userSubAreaCountyCode, String startTime, String endTime, String satelliteType, String landType) {
|
2023-02-23 17:23:55 +08:00
|
|
|
|
|
2023-03-29 16:22:57 +08:00
|
|
|
|
String noRedundantUserCode = ("管理员".equals(sysUserEntity.getAccountType())) ? null : FirePointCodeUtils.getFormatCutCode(sysUserEntity.getCountyCode());
|
|
|
|
|
String userSubAreaCutCountyCode = (TextUtils.isEmpty(userSubAreaCountyCode)) ? null : FirePointCodeUtils.getFormatCutCode(userSubAreaCountyCode);
|
2023-02-23 17:23:55 +08:00
|
|
|
|
|
2023-03-01 16:18:46 +08:00
|
|
|
|
//查询未审核的普通火点
|
|
|
|
|
Specification<FirePointOrdinaryEntity> specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<>();
|
2023-03-16 21:28:29 +08:00
|
|
|
|
//非空判断
|
|
|
|
|
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)));
|
2023-03-01 16:18:46 +08:00
|
|
|
|
//添加区划编码的过滤
|
2023-03-07 09:20:28 +08:00
|
|
|
|
if (!TextUtils.isEmpty(noRedundantUserCode)) {
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%"));
|
|
|
|
|
}
|
|
|
|
|
//添加子区域区划编码的过滤(比如查询火点的系统用户所属的区划是山东省,但是该用户目前只想查询青岛市的火点,那么noRedundantUserCode=山东省区划,userSubAreaCutCountyCode=青岛市区划)
|
2023-03-02 17:28:09 +08:00
|
|
|
|
if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) {
|
|
|
|
|
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), userSubAreaCutCountyCode + "%"));
|
|
|
|
|
}
|
2023-03-01 17:03:32 +08:00
|
|
|
|
//开始时间查询条件
|
|
|
|
|
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));
|
|
|
|
|
}
|
2023-03-01 16:18:46 +08:00
|
|
|
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|
};
|
|
|
|
|
//未审核的普通火点列表
|
2023-03-29 16:22:57 +08:00
|
|
|
|
List<FirePointOrdinaryEntity> firePointList = firePointOrdinaryDao.findAll(specificationOrdinary, Sort.by(Sort.Direction.DESC, "satelliteTime"));
|
2023-04-13 09:04:35 +08:00
|
|
|
|
boolean inVipTimeRange = VipTimeRangeUtils.checkIfInVipTimeRange(sysUserEntity.getVipTimeRangeJson());//查询火点后的步骤
|
|
|
|
|
if ((!"管理员".equals(sysUserEntity.getAccountType())) && (!inVipTimeRange)) {
|
|
|
|
|
//该账号不是管理员,并且不在VIP时间范围内。(过期的普通用户)那就清空火点的研判标志
|
|
|
|
|
for (FirePointOrdinaryEntity firePoint : firePointList) {
|
|
|
|
|
firePoint.setFireStatus(null);//过期的普通用户看不到火点的研判标志
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-29 16:22:57 +08:00
|
|
|
|
return new FirePointQueryResultBean(true, "", firePointList, firePointList.size());
|
2023-02-23 17:23:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|