对于省区划编码是X00000的这种情况,修复了火点筛选时会出现的bug。

This commit is contained in:
liuchengqian 2022-08-23 09:44:38 +08:00
parent e1777590c1
commit ddac4c7b22
2 changed files with 6 additions and 38 deletions

View File

@ -35,12 +35,11 @@ import java.util.Map;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* @author XinYi Song
*/
@RestController @RestController
public class FirePointController { public class FirePointController {
private final Locale locale = LocaleContextHolder.getLocale();
@Resource @Resource
private FirePointService firePointService; private FirePointService firePointService;
@ -61,8 +60,6 @@ public class FirePointController {
@GetMapping("/queryzzhd") @GetMapping("/queryzzhd")
public String queryzzhd() { public String queryzzhd() {
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities1 = firePointQueryHelper.queryZZHD("371482", "2022-01-01 00:00:10", "2022-06-26 00:00:10"); List<FirePointEntity> firePointEntities1 = firePointQueryHelper.queryZZHD("371482", "2022-01-01 00:00:10", "2022-06-26 00:00:10");
List<FirePointEntity> firePointEntities2 = firePointQueryHelper.queryZZHD("371403", "2022-01-01 00:00:10", "2022-06-26 00:00:10"); List<FirePointEntity> firePointEntities2 = firePointQueryHelper.queryZZHD("371403", "2022-01-01 00:00:10", "2022-06-26 00:00:10");
List<FirePointEntity> firePointEntities3 = firePointQueryHelper.queryZZHD("371426", "2022-01-01 00:00:10", "2022-06-26 00:00:10"); List<FirePointEntity> firePointEntities3 = firePointQueryHelper.queryZZHD("371426", "2022-01-01 00:00:10", "2022-06-26 00:00:10");
@ -90,8 +87,6 @@ public class FirePointController {
*/ */
@PostMapping("/insertFirePoint") @PostMapping("/insertFirePoint")
public String insertFirePoint(@RequestBody FirePointQo firePointQo) { public String insertFirePoint(@RequestBody FirePointQo firePointQo) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo); FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo);
if (firePointEntity == null) { if (firePointEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale); return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
@ -108,8 +103,6 @@ public class FirePointController {
*/ */
@PostMapping("/insertfirepointchanneltwo") @PostMapping("/insertfirepointchanneltwo")
public String insertFirePointChannelTwo(@RequestBody FirePointQo firePointQo) { public String insertFirePointChannelTwo(@RequestBody FirePointQo firePointQo) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
ShanDongFirePointEntity firePointEntity = firePointService.insertFirePointChannelTwo(firePointQo); ShanDongFirePointEntity firePointEntity = firePointService.insertFirePointChannelTwo(firePointQo);
if (firePointEntity == null) { if (firePointEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale); return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
@ -125,7 +118,6 @@ public class FirePointController {
*/ */
@GetMapping("/queryshandongfirepointlist") @GetMapping("/queryshandongfirepointlist")
public String queryShanDongFirePointList() { public String queryShanDongFirePointList() {
Locale locale = LocaleContextHolder.getLocale();
List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime")); List<ShanDongFirePointEntity> shanDongFirePointList = shanDongFirePointDao.findAll(Sort.by(Sort.Direction.DESC, "satelliteTime"));
if (shanDongFirePointList.isEmpty()) { if (shanDongFirePointList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
@ -151,8 +143,6 @@ public class FirePointController {
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
@PostMapping("/updateauditfiretype") @PostMapping("/updateauditfiretype")
public String updateAuditFireType(@RequestBody AuditFireTypeQo auditFireTypeQo) { public String updateAuditFireType(@RequestBody AuditFireTypeQo auditFireTypeQo) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
String fireCode = auditFireTypeQo.getFireCode(); String fireCode = auditFireTypeQo.getFireCode();
String auditFireType = auditFireTypeQo.getAuditFireType(); String auditFireType = auditFireTypeQo.getAuditFireType();
FirePointEntity firePointByFireCode = firePointDao.findByFireCode(fireCode); FirePointEntity firePointByFireCode = firePointDao.findByFireCode(fireCode);
@ -165,7 +155,6 @@ public class FirePointController {
@GetMapping("/queryshandongfirepointbytime") @GetMapping("/queryshandongfirepointbytime")
public String queryShanDongFirePointByTime(@RequestParam(required = false, value = "startTime") String startTime, @RequestParam(required = false, value = "endTime") String endTime) { public String queryShanDongFirePointByTime(@RequestParam(required = false, value = "startTime") String startTime, @RequestParam(required = false, value = "endTime") String endTime) {
Locale locale = LocaleContextHolder.getLocale();
Specification<ShanDongFirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> { Specification<ShanDongFirePointEntity> specification = (root, criteriaQuery, criteriaBuilder) -> {
List<Predicate> list = new ArrayList<>(); List<Predicate> list = new ArrayList<>();
if (startTime != null && !"".equals(startTime)) { if (startTime != null && !"".equals(startTime)) {
@ -207,8 +196,6 @@ public class FirePointController {
*/ */
@GetMapping("/selectUserName") @GetMapping("/selectUserName")
public String selectUserName(@RequestHeader(value = "Authorization") String token) { public String selectUserName(@RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 验证token // 验证token
String tokenUserName = TokenUtil.getTokenUserName(token); String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
@ -226,13 +213,8 @@ public class FirePointController {
*/ */
@GetMapping("/selectTodayFirePoint") @GetMapping("/selectTodayFirePoint")
public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode, @RequestHeader(value = "Authorization") String token) { public String selectTodayFirePoint(@RequestParam("countyCode") String countyCode, @RequestHeader(value = "Authorization") String token) {
// 获取区域信息 List<FirePointEntity> firePointList = firePointService.selectTodayFirePoint(countyCode);
Locale locale = LocaleContextHolder.getLocale(); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale);
List<FirePointEntity> firePointEntities = firePointService.selectTodayFirePoint(countyCode);
if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有火点数据", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointEntities, locale);
} }
/** /**
@ -240,8 +222,6 @@ public class FirePointController {
*/ */
@PostMapping("/selectFirePoint") @PostMapping("/selectFirePoint")
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();
// 区县编码 // 区县编码
String cityCode = (String) map.get("cityCode"); String cityCode = (String) map.get("cityCode");
// 开始时间 // 开始时间
@ -283,8 +263,6 @@ public class FirePointController {
*/ */
@PostMapping("/insertAppTask") @PostMapping("/insertAppTask")
public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException { public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if ("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null) { if ("".equals(appTaskBodyVo.getFireCode()) || appTaskBodyVo.getFireCode() == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码不能为空", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码不能为空", locale);
} }
@ -310,8 +288,6 @@ public class FirePointController {
*/ */
@GetMapping("/selectFirePointBetweenSeven") @GetMapping("/selectFirePointBetweenSeven")
public String selectFirePointBetweenSeven() { public String selectFirePointBetweenSeven() {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<FirePointEntity> firePointEntities = firePointService.selectFirePointBetweenSeven(); List<FirePointEntity> firePointEntities = firePointService.selectFirePointBetweenSeven();
if (firePointEntities == null || firePointEntities.size() == 0) { if (firePointEntities == null || firePointEntities.size() == 0) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有火点数据", locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有火点数据", locale);
@ -324,8 +300,6 @@ public class FirePointController {
*/ */
@GetMapping("/selectFirePointByMonth") @GetMapping("/selectFirePointByMonth")
public String selectFirePointByMonth(@RequestHeader(value = "Authorization") String token) { public String selectFirePointByMonth(@RequestHeader(value = "Authorization") String token) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
// 验证token // 验证token
String tokenUserName = TokenUtil.getTokenUserName(token); String tokenUserName = TokenUtil.getTokenUserName(token);
SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName);
@ -359,8 +333,6 @@ public class FirePointController {
*/ */
@GetMapping("/selectCityName") @GetMapping("/selectCityName")
public String selectCityName(@RequestParam("code") String countyCode) { public String selectCityName(@RequestParam("code") String countyCode) {
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
if (9 == countyCode.length()) { if (9 == countyCode.length()) {
List<Map<String, String>> maps = new ArrayList<>(); List<Map<String, String>> maps = new ArrayList<>();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale);
@ -384,8 +356,6 @@ public class FirePointController {
*/ */
@GetMapping("/selectFirePointByCode") @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); FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale);
} }
@ -399,8 +369,6 @@ public class FirePointController {
@Transactional(rollbackOn = Exception.class) @Transactional(rollbackOn = Exception.class)
@PostMapping("/updateBeforeFireAndAfterFireImage") @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 fireCode = (String) map.get("fireCode");
String beforeFireImage = (String) map.get("beforeFireImage"); String beforeFireImage = (String) map.get("beforeFireImage");
String afterFireImage = (String) map.get("afterFireImage"); String afterFireImage = (String) map.get("afterFireImage");

View File

@ -16,8 +16,8 @@ public class FirePointCodeUtils {
} }
public static String getCodeNotZeroEnd(String code) throws Exception { public static String getCodeNotZeroEnd(String code) throws Exception {
String codeNotZeroEnd = code; String codeNotZeroEnd = code.trim();
while (codeNotZeroEnd.endsWith("0")) { while (codeNotZeroEnd.length() > 2 && codeNotZeroEnd.endsWith("0")) {
codeNotZeroEnd = codeNotZeroEnd.substring(0, codeNotZeroEnd.length() - 1); codeNotZeroEnd = codeNotZeroEnd.substring(0, codeNotZeroEnd.length() - 1);
} }
return codeNotZeroEnd; return codeNotZeroEnd;