修改 动态多条件查询火点信息

This commit is contained in:
liuchengqian 2022-05-07 16:00:58 +08:00
parent 9321bdf9bf
commit d3ab960893
3 changed files with 254 additions and 317 deletions

View File

@ -43,66 +43,70 @@ public class FirePointController {
/**
* 添加火点数据
*
* @param firePointQo
* @return
*/
@PostMapping("/insertFirePoint")
public String insertFirePoint(@RequestBody FirePointQo firePointQo){
public String insertFirePoint(@RequestBody FirePointQo firePointQo) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo);
if(firePointEntity == null){
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"添加数据失败",locale);
}else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功",locale);
if (firePointEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
}
}
/**
* 测试
*
* @param token
* @return
*/
@GetMapping("/selectUserName")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectUserName(@RequestHeader(value="Authorization") String token){
public String selectUserName(@RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 验证token
String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
if(sysUserEntity == null){
return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale);
if (sysUserEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR, "您还没有注册登录,请先注册登录", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserEntity.getUserName(),locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, sysUserEntity.getUserName(), locale);
}
/**
* 查询今天的火点信息
*
* @param token
* @return
*/
@GetMapping("/selectTodayFirePoint")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode,@RequestHeader(value="Authorization") String token){
public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode, @RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint(countyCode);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
/**
* 动态多条件查询火点信息
*
* @param map
* @param token
* @return
*/
@PostMapping("/selectFirePoint")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectFirePoint(@RequestBody Map map,@RequestHeader(value="Authorization") String token){
public String selectFirePoint(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 区县编码
@ -119,44 +123,54 @@ public class FirePointController {
String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
// 查询省
if(sysUserEntity.getCountyCode().substring(2).equals("0000")){
List<FirePointEntity> firePointEntities = firePointService.selectFirePoint(sysUserEntity.getCountyCode(),cityCode, satelliteType, landType, startTime, endTime);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
// 查询市
}else if(sysUserEntity.getCountyCode().substring(4).equals("00") && !sysUserEntity.getCountyCode().substring(2).equals("0000")){
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCity(sysUserEntity.getCountyCode(), cityCode, satelliteType, landType, startTime, endTime);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
if (9 == sysUserEntity.getCountyCode().length()) {
// 查询县
}else {
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
} else if (sysUserEntity.getCountyCode().substring(2).equals("0000")) {
// 查询省
List<FirePointEntity> firePointEntities = firePointService.selectFirePoint(sysUserEntity.getCountyCode(), cityCode, satelliteType, landType, startTime, endTime);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
} else if (sysUserEntity.getCountyCode().substring(4).equals("00") && !sysUserEntity.getCountyCode().substring(2).equals("0000")) {
// 查询市
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCity(sysUserEntity.getCountyCode(), cityCode, satelliteType, landType, startTime, endTime);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
} else {
// 查询县
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
}
/**
* 根据火点编码修改火点状态
*
* @param map
* @param token
* @return
*/
@PostMapping("/updateTypeByFireCode")
public String updateTypeByFireCode(@RequestBody Map map, @RequestHeader(value="Authorization") String token){
public String updateTypeByFireCode(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) {
String fireCode = (String) map.get("fireCode");
String fireType = (String) map.get("fireType");
return firePointService.updateTypeByFireCode(fireCode,fireType,token);
return firePointService.updateTypeByFireCode(fireCode, fireType, token);
}
/**
* 提交核查任务
*
* @param files
* @param appTaskBodyVo
* @return
@ -165,20 +179,21 @@ public class FirePointController {
public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火点编码不能为空",locale);
if ("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码不能为空", locale);
}
if("".equals(appTaskBodyVo.getTaskInformation()) || appTaskBodyVo.getTaskInformation() == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"任务描述不能为空",locale);
if ("".equals(appTaskBodyVo.getTaskInformation()) || appTaskBodyVo.getTaskInformation() == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "任务描述不能为空", locale);
}
if(files == null || files.length == 0 ){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"图片不能为空",locale);
if (files == null || files.length == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "图片不能为空", locale);
}
return firePointService.insertAppTask(files,appTaskBodyVo);
return firePointService.insertAppTask(files, appTaskBodyVo);
}
/**
* 查询核查的任务信息
*
* @param fireCode
* @return
*/
@ -189,110 +204,117 @@ public class FirePointController {
/**
* 查询近一周的火点信息
*
* @return
*/
@GetMapping("/selectFirePointBetweenSeven")
public String selectFirePointBetweenSeven(){
public String selectFirePointBetweenSeven() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectFirePointBetweenSeven();
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
/**
* 查询近一个月的火点信息
*
* @return
*/
@GetMapping("/selectFirePointByMonth")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectFirePointByMonth(@RequestHeader(value="Authorization") String token) {
public String selectFirePointByMonth(@RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 验证token
String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
List<FirePointEntity> firePointEntities = firePointService.selectFirePointByMonth(sysUserEntity.getCountyCode());
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有火点数据",locale);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
/**
* 查询火点数量
*
* @return
*/
@GetMapping("/selectFirePointNum")
public String selectFirePointNum(@RequestParam("keepType") String keepType){
public String selectFirePointNum(@RequestParam("keepType") String keepType) {
// keepType为1时查询近一天的火点数量
if("1".equals(keepType)){
if ("1".equals(keepType)) {
return firePointService.selectFirePointNumDay();
// keepType为2时,查询近一周的火点数量
}else if("2".equals(keepType)){
} else if ("2".equals(keepType)) {
return firePointService.selectFirePointNumWeek();
}else {
} else {
return firePointService.selectFirePointNumMonth();
}
}
@GetMapping("/websocketTest")
public void websocketTest(@RequestParam("message") String message){
public void websocketTest(@RequestParam("message") String message) {
WebSocketServer.broadInfo(message);
}
/**
* 查询该省所有的市
*
* @return
*/
@GetMapping("/selectCityName")
public String selectCityName(@RequestParam("code") String code){
public String selectCityName(@RequestParam("code") String code) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if(code.substring(2).equals("0000")){
if (code.substring(2).equals("0000")) {
List<Map<String, Object>> maps = firePointService.selectCityName(code);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
}else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale);
} else {
List<Map<String, Object>> maps = firePointService.selectCountyName(code);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale);
}
}
/**
* 根据火点编码查询火点信息
*
* @param fireCode
* @return
*/
@GetMapping("/selectFirePointByCode")
public String selectFirePoint(@RequestParam("fireCode") String fireCode){
public String selectFirePoint(@RequestParam("fireCode") String fireCode) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale);
}
/**
* 测试添加火点信息
*
* @param firePointQo
* @return
*/
@PostMapping("/insertFireTest")
public String insertFireTest(@RequestBody FirePointQo firePointQo){
public String insertFireTest(@RequestBody FirePointQo firePointQo) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePoint firePoint = firePointService.insertFireTest(firePointQo);
if(firePoint == null){
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"添加数据失败",locale);
}else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加成功",locale);
if (firePoint == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
}
}
/**
* 导入全国省市区
*
* @param file
* @return
* @throws Exception
@ -302,70 +324,73 @@ public class FirePointController {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
firePointService.importCityExcel(file);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"导入成功",locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "导入成功", locale);
}
/**
* 查询今天的火点信息(测试)
*
* @param token
* @return
*/
@GetMapping("/selectTodayFire")
@PreAuthorize("hasAnyAuthority('auth_general_user')")
public String selectTodayFire(@RequestParam("countyCode") String countyCode,@RequestHeader(value="Authorization") String token){
public String selectTodayFire(@RequestParam("countyCode") String countyCode, @RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePoint> firePointEntities = firePointService.selectTodayFire(countyCode);
if(firePointEntities == null || firePointEntities.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有火点数据",locale);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
/**
* 删除水体类型的火点信息
*
* @return
*/
@Transactional(rollbackOn = Exception.class)
@PostMapping("/deleteShuiTi")
public String deleteShuiTi(){
public String deleteShuiTi() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<Integer> integers = firePointDao.selectId();
firePointDao.deleteByIdIn(integers);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"删除成功",locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "删除成功", locale);
}
@GetMapping("/selectBeijing")
public String selectBeijing(){
public String selectBeijing() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointDao.selectBeijing();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
}
/**
* 根据火点编码添加火点前后的图片
*
* @param map
* @return
*/
@Transactional(rollbackOn = Exception.class)
@PostMapping("/updateBeforeFireAndAfterFireImage")
public String updateBeforeFireAndAfterFireImage(@RequestBody Map map){
public String updateBeforeFireAndAfterFireImage(@RequestBody Map map) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
String fireCode = (String) map.get("fireCode");
String beforeFireImage = (String) map.get("beforeFireImage");
String afterFireImage = (String) map.get("afterFireImage");
if(fireCode == null || "".equals(fireCode)){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火点编码不能为空!",locale);
if (fireCode == null || "".equals(fireCode)) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码不能为空!", locale);
}
FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode);
if(byFireCode == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火点编码错误!",locale);
if (byFireCode == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码错误!", locale);
}
firePointDao.updateBeforeFireAndAfterFireImage(fireCode,beforeFireImage,afterFireImage);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"添加图片成功!",locale);
firePointDao.updateBeforeFireAndAfterFireImage(fireCode, beforeFireImage, afterFireImage);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加图片成功!", locale);
}
}

View File

@ -210,19 +210,16 @@ public class FirePointServiceImpl implements FirePointService {
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override
public List<FirePointEntity> selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
//List<CityEntity> byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3));
List<CountyEntity> byCityCode = countyDao.findByCityCode(cityCodeOne);
String cityName = byCityCode.get(0).getCityName();
CityEntity byCityCode1 = cityDao.findByCityName(cityName);
String proName = byCityCode1.getProName();
if (!"".equals(startTime) && !"".equals(endTime)) {
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByCity(proName, cityName, cityCode, satelliteType, landType, startTime, dateToString);
return query.selectFirePointByCity(cityName, cityCode, satelliteType, landType, startTime, dateToString);
}
return query.selectFirePointByCity(proName, cityName, cityCode, satelliteType, landType, startTime, endTime);
return query.selectFirePointByCity(cityName, cityCode, satelliteType, landType, startTime, endTime);
}
/**
@ -238,18 +235,14 @@ public class FirePointServiceImpl implements FirePointService {
@Cacheable(keyGenerator = "keyGenerator", unless = "#result == null")
@Override
public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(cityCode);
CityEntity byCityCode = cityDao.findByCityName(byCountyCode.get(0).getCityName());
String proName = byCityCode.getProName();
if (!"".equals(startTime) && !"".equals(endTime)) {
LocalDate localDate = DateTimeUtil.stringToDate(endTime);
// 结束时间
LocalDate localDate1 = localDate.plusDays(1);
String dateToString = DateTimeUtil.dateToString(localDate1);
return query.selectFirePointByCounty(proName, cityCode, satelliteType, landType, startTime, dateToString);
return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, dateToString);
}
return query.selectFirePointByCounty(proName, cityCode, satelliteType, landType, startTime, endTime);
return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, endTime);
}
/**
@ -381,7 +374,6 @@ public class FirePointServiceImpl implements FirePointService {
public List<FirePointEntity> selectFirePointBetweenSeven() {
LocalDateTime localDateTime = LocalDateTime.now();
String endTime = DateTimeUtil.dateTimeToString(localDateTime);
// 当前时间减7
LocalDateTime localDateTime1 = localDateTime.minusDays(7);
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
@ -401,21 +393,18 @@ public class FirePointServiceImpl implements FirePointService {
// 当前时间减31
LocalDateTime localDateTime1 = localDateTime.minusDays(31);
String startTime = DateTimeUtil.dateTimeToString(localDateTime1);
if ("0000".equals(countyCode.substring(2))) {
if (9 == countyCode.length()) {
return query.selectFirePointByMonthCounty(countyCode, startTime, endTime);
} else if ("0000".equals(countyCode.substring(2))) {
List<CityEntity> byProCode = cityDao.findByProCode(countyCode);
String proName = byProCode.get(0).getProName();
return query.selectFirePointByMonth(proName, startTime, endTime);
return query.selectFirePointByMonthPro(proName, startTime, endTime);
} else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) {
List<CountyEntity> byCityCode = countyDao.findByCityCode(countyCode);
String cityName = byCityCode.get(0).getCityName();
CityEntity byCityName = cityDao.findByCityName(cityName);
String proName = byCityName.getProName();
return query.selectFirePointByMonthCity(proName, cityName, startTime, endTime);
return query.selectFirePointByMonthCity(cityName, startTime, endTime);
} else {
List<CountyEntity> byCountyCode = countyDao.findByCountyCode(countyCode);
CityEntity byCityName = cityDao.findByCityName(byCountyCode.get(0).getCityName());
String proName = byCityName.getProName();
return query.selectFirePointByMonthCounty(proName, countyCode, startTime, endTime);
return query.selectFirePointByMonthCounty(countyCode, startTime, endTime);
}
}

View File

@ -6,10 +6,7 @@ import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -26,15 +23,11 @@ public class Query {
/**
* 动态多条件查询项目信息()
* @param
* @return
*/
public List<FirePointEntity> selectFirePointByPro(String address, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(address != null && !"".equals(address)){
if (address != null && !"".equals(address)) {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
}
if (cityCode != null && !"".equals(cityCode)) {
@ -44,17 +37,9 @@ public class Query {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
// if(address.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}
// else {
// if(address.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
// }
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
LocalDateTime localDateTime = LocalDateTime.now();
@ -64,48 +49,35 @@ public class Query {
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
String startTimes = DateTimeUtil.dateTimeToString(localDateTime1);
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimes));
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimes));
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 动态多条件查询项目信息()
* @param
* @return
*/
public List<FirePointEntity> selectFirePointByCity(String proName, String address, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointByCity(String address, String cityCode, String satelliteType, String landType, String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(address != null && !"".equals(address)){
if (address != null && !"".equals(address)) {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
}
if (cityCode != null && !"".equals(cityCode)) {
list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class),cityCode));
list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), cityCode));
}
if (satelliteType != null && !"".equals(satelliteType)) {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}
// else {
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
// }
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
LocalDateTime localDateTime = LocalDateTime.now();
@ -115,45 +87,32 @@ public class Query {
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
String startTimes = DateTimeUtil.dateTimeToString(localDateTime1);
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimes));
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimes));
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 动态多条件查询项目信息()
* @param
* @return
*/
public List<FirePointEntity> selectFirePointByCounty(String proName, String cityCode,String satelliteType,String landType,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if (cityCode != null && !"".equals(cityCode)) {
list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class),cityCode));
list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), cityCode));
}
if (satelliteType != null && !"".equals(satelliteType)) {
list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));
}
if (landType != null && !"".equals(landType)) {
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
list.add(criteriaBuilder.equal(root.get("landType").as(String.class), landType));
}
// else {
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
// }
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
LocalDateTime localDateTime = LocalDateTime.now();
@ -163,129 +122,93 @@ public class Query {
LocalDateTime localDateTime1 = localDateTime.minusDays(30);
String startTimes = DateTimeUtil.dateTimeToString(localDateTime1);
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTimes));
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTimes));
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 查询近一周的火点
* @param startTime
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointBetweenThree(String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointBetweenThree(String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 查询近一个月的火点
* @param startTime
* @param endTime
* @return
* 查询近一个月的火点信息
*/
public List<FirePointEntity> selectFirePointByMonth(String address,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointByMonthPro(String address, String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(address != null && !"".equals(address)){
if (address != null && !"".equals(address)) {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
}
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
// if(address.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 查询近一个月的火点信息
* @param address
* @param startTime
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointByMonthCity(String proName, String address,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointByMonthCity(String address, String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(address != null && !"".equals(address)){
if (address != null && !"".equals(address)) {
list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%"));
}
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}
/**
* 查询近一个月的火点信息
* @param countyCode
* @param startTime
* @param endTime
* @return
*/
public List<FirePointEntity> selectFirePointByMonthCounty(String proName, String countyCode,String startTime,String endTime) {
Specification<FirePointEntity> specification = new Specification<FirePointEntity>() {
@Override
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
public List<FirePointEntity> selectFirePointByMonthCounty(String countyCode, String startTime, String endTime) {
Specification<FirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>();
if(countyCode != null && !"".equals(countyCode)){
if (countyCode != null && !"".equals(countyCode)) {
list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), countyCode));
}
if(startTime != null && !"".equals(startTime)){
if (startTime != null && !"".equals(startTime)) {
list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime));
}
if(endTime != null && !"".equals(endTime)){
if (endTime != null && !"".equals(endTime)) {
list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime));
}
// if(proName.equals("山东省")){
// list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地"));
// }
Predicate[] predicates = new Predicate[list.size()];
return criteriaBuilder.and(list.toArray(predicates));
}
};
return firePointDao.findAll(specification);
}