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