diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index e10da10..ce10e01 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -10,6 +10,7 @@ import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.vo.AppTaskBodyVo; import com.xkrs.service.FirePointService; +import com.xkrs.service.StreetService; import com.xkrs.websocket.service.WebSocketServer; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.security.access.prepost.PreAuthorize; @@ -19,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.transaction.Transactional; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.Map; @@ -40,6 +42,8 @@ public class FirePointController { @Resource private FirePointDao firePointDao; + @Resource + private StreetService streetService; /** * 添加火点数据 @@ -154,7 +158,7 @@ public class FirePointController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale); } else { // 查询县 - List firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), satelliteType, landType, startTime, endTime); + List firePointEntities = firePointService.selectFirePointByCounty(sysUserEntity.getCountyCode(), cityCode, satelliteType, landType, startTime, endTime); if (firePointEntities == null || firePointEntities.size() == 0) { return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); } @@ -276,14 +280,20 @@ public class FirePointController { * @return */ @GetMapping("/selectCityName") - public String selectCityName(@RequestParam("code") String code) { + public String selectCityName(@RequestParam("code") String countyCode) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); - if (code.substring(2).equals("0000")) { - List> maps = firePointService.selectCityName(code); + if (9 == countyCode.length()) { + List> maps = new ArrayList<>(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); + } else if ("0000".equals(countyCode.substring(2))) { + List> maps = streetService.selectCityList(countyCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); + } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { + List> maps = streetService.selectCountyList(countyCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); } else { - List> maps = firePointService.selectCountyName(code); + List> maps = streetService.selectStreetList(countyCode); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); } } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 0cda0c7..1c206e0 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -44,31 +44,31 @@ public interface FirePointService { */ List selectFirePoint(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime); - /** * 动态多条件查询火点信息(市) * - * @param cityCodeOne 市编码 - * @param cityCode 县编码 + * @param cityCode 市编码 + * @param countyCode 县编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime); + List selectFirePointByCity(String cityCode, String countyCode, String satelliteType, String landType, String startTime, String endTime); /** * 动态多条件查询火点信息(县) * - * @param cityCode 县编码 + * @param countyCode 县编码 + * @param streetCode 街道编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime); + List selectFirePointByCounty(String countyCode, String streetCode, String satelliteType, String landType, String startTime, String endTime); /** * 动态多条件查询火点信息(街道) diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 1eff5aa..dcf2760 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -198,8 +198,8 @@ public class FirePointServiceImpl implements FirePointService { /** * 动态多条件查询火点信息(市) * - * @param cityCodeOne 市编码 - * @param cityCode 县编码 + * @param cityCode 市编码 + * @param countyCode 县编码 * @param satelliteType * @param landType * @param startTime @@ -208,23 +208,24 @@ public class FirePointServiceImpl implements FirePointService { */ @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override - public List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) { - List byCityCode = countyDao.findByCityCode(cityCodeOne); + public List selectFirePointByCity(String cityCode, String countyCode, String satelliteType, String landType, String startTime, String endTime) { + List byCityCode = countyDao.findByCityCode(cityCode); String cityName = byCityCode.get(0).getCityName(); if (!"".equals(startTime) && !"".equals(endTime)) { LocalDate localDate = DateTimeUtil.stringToDate(endTime); // 结束时间 LocalDate localDate1 = localDate.plusDays(1); String dateToString = DateTimeUtil.dateToString(localDate1); - return query.selectFirePointByCity(cityName, cityCode, satelliteType, landType, startTime, dateToString); + return query.selectFirePointByCity(cityName, countyCode, satelliteType, landType, startTime, dateToString); } - return query.selectFirePointByCity(cityName, cityCode, satelliteType, landType, startTime, endTime); + return query.selectFirePointByCity(cityName, countyCode, satelliteType, landType, startTime, endTime); } /** * 动态多条件查询火点信息(县) * - * @param cityCode 县编码 + * @param countyCode 县编码 + * @param streetCode 街道编码 * @param satelliteType * @param landType * @param startTime @@ -233,15 +234,15 @@ public class FirePointServiceImpl implements FirePointService { */ @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override - public List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) { + public List selectFirePointByCounty(String countyCode, String streetCode, String satelliteType, String landType, String startTime, String endTime) { if (!"".equals(startTime) && !"".equals(endTime)) { LocalDate localDate = DateTimeUtil.stringToDate(endTime); // 结束时间 LocalDate localDate1 = localDate.plusDays(1); String dateToString = DateTimeUtil.dateToString(localDate1); - return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, dateToString); + return query.selectFirePointByCounty(countyCode, streetCode, satelliteType, landType, startTime, dateToString); } - return query.selectFirePointByCounty(cityCode, satelliteType, landType, startTime, endTime); + return query.selectFirePointByCounty(countyCode, streetCode, satelliteType, landType, startTime, endTime); } @Override diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java index 2ec56a5..1eba0e4 100644 --- a/src/main/java/com/xkrs/utils/Query.java +++ b/src/main/java/com/xkrs/utils/Query.java @@ -24,11 +24,11 @@ public class Query { /** * 动态多条件查询项目信息(省) */ - public List selectFirePointByPro(String address, String cityCode, String satelliteType, String landType, String startTime, String endTime) { + public List selectFirePointByPro(String proName, String cityCode, String satelliteType, String landType, String startTime, String endTime) { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { List list = new ArrayList<>(); - if (address != null && !"".equals(address)) { - list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%")); + if (proName != null && !"".equals(proName)) { + list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + proName + "%")); } if (cityCode != null && !"".equals(cityCode)) { list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + cityCode + "%")); @@ -62,14 +62,14 @@ public class Query { /** * 动态多条件查询项目信息(市) */ - public List selectFirePointByCity(String address, String cityCode, String satelliteType, String landType, String startTime, String endTime) { + public List selectFirePointByCity(String cityName, String countyCode, String satelliteType, String landType, String startTime, String endTime) { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { List list = new ArrayList<>(); - if (address != null && !"".equals(address)) { - list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + address + "%")); + if (cityName != null && !"".equals(cityName)) { + list.add(criteriaBuilder.like(root.get("firePointAddress").as(String.class), "%" + cityName + "%")); } - if (cityCode != null && !"".equals(cityCode)) { - list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), cityCode)); + if (countyCode != null && !"".equals(countyCode)) { + list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + countyCode + "%")); } if (satelliteType != null && !"".equals(satelliteType)) { list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType)); @@ -100,11 +100,14 @@ public class Query { /** * 动态多条件查询项目信息(县) */ - public List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) { + public List selectFirePointByCounty(String countyCode, String streetCode, String satelliteType, String landType, String startTime, String endTime) { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { List list = new ArrayList<>(); - if (cityCode != null && !"".equals(cityCode)) { - list.add(criteriaBuilder.equal(root.get("countyCode").as(String.class), cityCode)); + if (countyCode != null && !"".equals(countyCode)) { + list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + countyCode + "%")); + } + if (streetCode != null && !"".equals(streetCode)) { + list.add(criteriaBuilder.like(root.get("streetCode").as(String.class), "%" + streetCode + "%")); } if (satelliteType != null && !"".equals(satelliteType)) { list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType)); @@ -139,7 +142,7 @@ public class Query { Specification specification = (root, criteriaQuery, criteriaBuilder) -> { List list = new ArrayList<>(); if (streetCode != null && !"".equals(streetCode)) { - list.add(criteriaBuilder.equal(root.get("streetCode").as(String.class), streetCode)); + list.add(criteriaBuilder.like(root.get("streetCode").as(String.class), streetCode)); } if (satelliteType != null && !"".equals(satelliteType)) { list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));