This commit is contained in:
liuchengqian 2023-03-02 17:28:09 +08:00
parent d1ec3daef7
commit 2f869a7de9
4 changed files with 77 additions and 60 deletions

View File

@ -1,11 +1,9 @@
package com.xkrs.service;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.qo.FirePointQo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* @author XinYi Song
@ -20,14 +18,6 @@ public interface FirePointService {
*/
boolean insertFirePoint(FirePointQo firePointQo);
/**
* 查询今天的火点信息
*
* @param
* @return
*/
List<FirePointEntity> selectTodayFirePoint(String countyCode);
/**
* download vip user's fire point
*
@ -39,16 +29,13 @@ public interface FirePointService {
String downloadFirePoint(HttpServletRequest request, HttpServletResponse response, String ids);
/**
* 动态多条件查询火点列表
*
* @param code 区划编码可以是省市区县街道任意编码如果传需要至少两位不传代表查询全国火点
* @param startTime 过滤火点开始卫星时间不传代表不指定开始时间后台会有限制
* @param endTime 过滤火点结束卫星时间不传代表不指定结束时间
* @param satelliteType 过滤传感器类型不传代表查询全部类型的传感器
* @param landType 过滤地物类型不传代表查询全部地物类型
* @return 符合条件的火点列表
* (Complete)
*/
List<FirePointEntity> queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType);
void queryFirePoint(String token,String code, String startTime, String endTime, String satelliteType, String landType);
String queryFirePoint(String token, String code, String startTime, String endTime, String satelliteType, String landType);
/**
* 查询今天的火点信息 (Complete)
*/
String selectTodayFirePoint(String token, String countyCode);
}

View File

@ -11,11 +11,13 @@ import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService;
import com.xkrs.service.StreetService;
import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.straw.model.bean.FirePointQueryResultBean;
import com.xkrs.straw.model.entity.SysUserEntity;
import com.xkrs.straw.model.helper.PushHelper;
import com.xkrs.straw.model.helper.SMSHelper;
import com.xkrs.straw.utils.FirePointQueryManager;
import com.xkrs.utils.*;
import org.apache.hc.core5.util.TextUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheConfig;
@ -278,26 +280,44 @@ public class FirePointServiceImpl implements FirePointService {
}
/**
* 动态多条件查询火点列表
*
* @param code 区划编码可以是省市区县街道任意编码如果传需要至少两位不传代表查询全国火点
* @param startTime 过滤火点开始卫星时间不传代表不指定开始时间后台会有限制
* @param endTime 过滤火点结束卫星时间不传代表不指定结束时间
* @param satelliteType 过滤传感器类型不传代表查询全部类型的传感器
* @param landType 过滤地物类型不传代表查询全部地物类型
* @return 符合条件的火点列表
* Complete
*/
@Override
public List<FirePointEntity> queryFirePoint(String code, String startTime, String endTime, String satelliteType, String landType) {
return firePointQueryHelper.queryFirePoint(code, startTime, endTime, satelliteType, landType);
public String queryFirePoint(String token, String code, String startTime, String endTime, String satelliteType, String landType) {
//验证token
String userName = TokenUtil.obtainUserNameByToken(token);
if (TextUtils.isEmpty(userName)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "账号不存在或错误", locale);
}
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(userName);
if (sysUserEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "账号不存在或错误", locale);
}
FirePointQueryResultBean firePointQueryResult = firePointQueryManager.queryFirePointBelongToUser(sysUserEntity, code, startTime, endTime, satelliteType, landType);
if (firePointQueryResult.isSuccess()) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointQueryResult.getList(), locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, firePointQueryResult.getErrorMessage(), locale);
}
}
/**
* 查询今天的火点信息
* Complete
*/
// @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override
public List<FirePointEntity> selectTodayFirePoint(String countyCode) {
public String selectTodayFirePoint(String token, String countyCode) {
//验证token
String userName = TokenUtil.obtainUserNameByToken(token);
if (TextUtils.isEmpty(userName)) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "账号不存在或错误", locale);
}
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(userName);
if (sysUserEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "账号不存在或错误", locale);
}
LocalDateTime startTime1 = LocalDateTime.now();
LocalDateTime startTime2 = LocalDateTime.of(startTime1.getYear(), startTime1.getMonth(), startTime1.getDayOfMonth(), 0, 0, 0, 0);
@ -307,7 +327,12 @@ public class FirePointServiceImpl implements FirePointService {
LocalDateTime endTime2 = LocalDateTime.of(endTime1.getYear(), endTime1.getMonth(), endTime1.getDayOfMonth(), 0, 0, 0, 0);
String endTimeString = DateTimeUtils.localDateTimeToString(endTime2);
return firePointQueryHelper.queryFirePoint(countyCode, startTimeString, endTimeString, null, null);
FirePointQueryResultBean firePointQueryResult = firePointQueryManager.queryFirePointBelongToUser(sysUserEntity, countyCode, startTimeString, endTimeString, null, null);
if (firePointQueryResult.isSuccess()) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointQueryResult.getList(), locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, firePointQueryResult.getErrorMessage(), locale);
}
}
}

View File

@ -105,26 +105,19 @@ public class FirePointController {
}
/**
* 动态多条件查询火点列表
* 动态多条件查询火点列表(Complete)
*/
@GetMapping("/queryFirePoint")
public String queryFirePoint(@RequestHeader(value = "Authorization") String token,
@RequestParam(value = "code", required = false) String code,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "satelliteType", required = false) String satelliteType,
@RequestParam(value = "landType", required = false) String landType) {
List<FirePointEntity> firePointList = firePointService.queryFirePoint(token, code, startTime, endTime, satelliteType, landType);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
public String queryFirePoint(@RequestHeader(value = "Authorization") String token, @RequestParam(value = "code", required = false) String code, @RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime, @RequestParam(value = "satelliteType", required = false) String satelliteType, @RequestParam(value = "landType", required = false) String landType) {
return firePointService.queryFirePoint(token, code, startTime, endTime, satelliteType, landType);
}
/**
* 查询今天的火点信息
*/
@GetMapping("/selectTodayFirePoint")
public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode) {
List<FirePointEntity> firePointList = firePointService.selectTodayFirePoint(countyCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
public String selectTodayFirePoint(@RequestHeader(value = "Authorization") String token, @RequestParam("countyCode") String countyCode) {
return firePointService.selectTodayFirePoint(token, countyCode);
}
/**

View File

@ -37,28 +37,36 @@ public class FirePointQueryManager {
@Resource
private FirePointPreciseDao firePointPreciseDao;
public FirePointQueryResultBean queryFirePointBelongToUser(SysUserEntity sysUserEntity, String startTime, String endTime, String satelliteType, String landType) {
public FirePointQueryResultBean queryFirePointBelongToUser(SysUserEntity sysUserEntity, String userSubAreaCountyCode, String startTime, String endTime, String satelliteType, String landType) {
String countyCode = sysUserEntity.getCountyCode();
String vipTimeRangeJson = sysUserEntity.getVipTimeRangeJson();
return queryFirePointBelongToUser(countyCode, vipTimeRangeJson, startTime, endTime, satelliteType, landType);
return queryFirePointBelongToUser(countyCode, vipTimeRangeJson, userSubAreaCountyCode, startTime, endTime, satelliteType, landType);
}
public FirePointQueryResultBean queryFirePointBelongToUser(String userCode, String vipTimeRangeJson, String startTime, String endTime, String satelliteType, String landType) {
public FirePointQueryResultBean queryFirePointBelongToUser(String userCode, String vipTimeRangeJson, String userSubAreaCountyCode, String startTime, String endTime, String satelliteType, String landType) {
String mNoRedundantUserCode = null;
final List<VipTimeRangeBean.VipTimeRangeItemBean> mVipTimeRangeItemList = new ArrayList<>();
String mUserSubAreaCutCountyCode = null;
try {
//如果用户注册的区划编码是空就返回失败
if (TextUtils.isEmpty(userCode)) {
return new FirePointQueryResultBean("User CountyCode Error 1, userCode = " + userCode);
}
//对用户区划编码进行格式化获得没有冗余数据的区划编码
String noRedundantUserCode = FirePointCodeUtils.getFormatCutCode(userCode);
mNoRedundantUserCode = FirePointCodeUtils.getFormatCutCode(userCode);
//如果格式化后的用户区划编码是空就返回失败
if (TextUtils.isEmpty(noRedundantUserCode)) {
return new FirePointQueryResultBean("User CountyCode Error 2, userCode = " + userCode + ", noRedundantUserCode = " + noRedundantUserCode);
if (TextUtils.isEmpty(mNoRedundantUserCode)) {
return new FirePointQueryResultBean("User CountyCode Error 2, userCode = " + userCode + ", noRedundantUserCode = " + mNoRedundantUserCode);
}
if (!TextUtils.isEmpty(userSubAreaCountyCode)) {
mUserSubAreaCutCountyCode = FirePointCodeUtils.getFormatCutCode(userSubAreaCountyCode);
if (!TextUtils.isEmpty(mUserSubAreaCutCountyCode)) {
if (!mUserSubAreaCutCountyCode.startsWith(mNoRedundantUserCode)) {
return new FirePointQueryResultBean("User SubArea CountyCode 出现错误");
}
}
}
//如果用户的VIP时间范围数据是空就返回失败
if (TextUtils.isEmpty(vipTimeRangeJson)) {
return new FirePointQueryResultBean("User VipTimeRangeJson Error 1, vipTimeRangeJson = " + vipTimeRangeJson);
@ -105,7 +113,6 @@ public class FirePointQueryManager {
}
}
}
mNoRedundantUserCode = noRedundantUserCode;
mVipTimeRangeItemList.addAll(vipTimeRangeItemList);
} catch (Exception e) {
@ -113,11 +120,10 @@ public class FirePointQueryManager {
return new FirePointQueryResultBean(e.getMessage());
}
return queryFirePointBelongToUser(mNoRedundantUserCode, mVipTimeRangeItemList, startTime, endTime, satelliteType, landType);
return queryFirePointBelongToUser(mNoRedundantUserCode, mVipTimeRangeItemList, mUserSubAreaCutCountyCode, startTime, endTime, satelliteType, landType);
}
public FirePointQueryResultBean queryFirePointBelongToUser(String noRedundantUserCode, List<VipTimeRangeBean.VipTimeRangeItemBean> vipTimeRangeItemList, String startTime, String endTime, String satelliteType, String landType) {
public FirePointQueryResultBean queryFirePointBelongToUser(String noRedundantUserCode, List<VipTimeRangeBean.VipTimeRangeItemBean> vipTimeRangeItemList, String userSubAreaCutCountyCode, String startTime, String endTime, String satelliteType, String landType) {
//如果格式化后的用户区划编码是空就返回失败
if (TextUtils.isEmpty(noRedundantUserCode)) {
return new FirePointQueryResultBean("User CountyCode Error 2, noRedundantUserCode = " + noRedundantUserCode);
@ -126,13 +132,19 @@ public class FirePointQueryManager {
if (vipTimeRangeItemList == null || vipTimeRangeItemList.size() == 0) {
return new FirePointQueryResultBean("User VipTimeRangeJson Error 2, 已保存的VIP时间范围出现错误");
}
final String finalMNoRedundantUserCode = noRedundantUserCode;
if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) {
if (!userSubAreaCutCountyCode.startsWith(noRedundantUserCode)) {
return new FirePointQueryResultBean("User SubArea CountyCode 出现错误");
}
}
//查询未审核的普通火点
Specification<FirePointOrdinaryEntity> specificationOrdinary = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
//添加区划编码的过滤
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%"));
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%"));
if (!TextUtils.isEmpty(userSubAreaCutCountyCode)) {
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), userSubAreaCutCountyCode + "%"));
}
//开始时间查询条件
if (!TextUtils.isEmpty(startTime)) {
LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);
@ -174,7 +186,7 @@ public class FirePointQueryManager {
Specification<FirePointPreciseEntity> specificationPrecise = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> predicateList = new ArrayList<>();
//添加区划编码的过滤
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), finalMNoRedundantUserCode + "%"));
predicateList.add(criteriaBuilder.like(root.get("townCode").as(String.class), noRedundantUserCode + "%"));
//开始时间查询条件
if (!TextUtils.isEmpty(startTime)) {
LocalDateTime startTime1 = DateTimeUtils.stringToLocalDateTime(startTime);