diff --git a/pom.xml b/pom.xml index aadaab7..8ae430e 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ org.springframework.boot spring-boot-starter-websocket - + org.springframework.boot @@ -104,8 +104,8 @@ postgresql - mysql - mysql-connector-java + mysql + mysql-connector-java io.jsonwebtoken @@ -226,6 +226,10 @@ spring-kafka 2.5.10.RELEASE + + junit + junit + diff --git a/src/main/java/com/xkrs/controller/StreetController.java b/src/main/java/com/xkrs/controller/StreetController.java new file mode 100644 index 0000000..07fa55d --- /dev/null +++ b/src/main/java/com/xkrs/controller/StreetController.java @@ -0,0 +1,80 @@ +package com.xkrs.controller; + +import cn.hutool.core.io.IoUtil; +import com.xkrs.dao.CityDao; +import com.xkrs.dao.CountyDao; +import com.xkrs.dao.StreetDao; +import com.xkrs.model.entity.CityEntity; +import com.xkrs.model.entity.CountyEntity; +import com.xkrs.model.entity.StreetEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; + +@RestController +public class StreetController { + + @Resource + private CityDao cityDao; + + @Resource + private CountyDao countyDao; + + @Resource + private StreetDao streetDao; + + @GetMapping("/formatStreetData") + public String formatStreetData() { + File file = new File("/Users/liuchengqian/Downloads/Administrative-divisions-of-China-master/dist/streets2.csv"); + FileInputStream fileInputStream = IoUtil.toStream(file); + BufferedReader reader = IoUtil.getReader(fileInputStream, "UTF-8"); + Stream lines = reader.lines(); + AtomicInteger count = new AtomicInteger(); + lines.forEach(content -> { + try { + content = content.replace("\"", ""); + String[] split = content.split(","); + StreetEntity streetEntity = new StreetEntity(); + streetEntity.setProCode(split[3] + "0000"); + List byProCode1 = cityDao.findByProCode(streetEntity.getProCode()); + if (byProCode1 == null || byProCode1.isEmpty()) { + streetEntity.setProName(""); + } else { + streetEntity.setProName(byProCode1.get(0).getProName()); + } + streetEntity.setCityCode(split[4] + "00"); + List byCityCode1 = countyDao.findByCityCode(streetEntity.getCityCode()); + if (byCityCode1 == null || byCityCode1.isEmpty()) { + streetEntity.setCityName(""); + } else { + streetEntity.setCityName(byCityCode1.get(0).getCityName()); + } + streetEntity.setCountyCode(split[2]); + List byCountyCode = countyDao.findByCountyCode(streetEntity.getCountyCode()); + if (byCountyCode == null || byCountyCode.isEmpty()) { + streetEntity.setCountyName(""); + } else { + streetEntity.setCountyName(byCountyCode.get(0).getCountyName()); + } + streetEntity.setStreetCode(split[0]); + streetEntity.setStreetName(split[1]); + streetDao.save(streetEntity); + count.getAndIncrement(); + System.out.println(content + " >>> " + count); + System.out.println(streetEntity.toString()); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("格式化街道数据时发生异常:" + e.getMessage()); + } + }); + return "666"; + } + +} diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index e1acbf5..498f579 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -34,6 +34,7 @@ import static com.xkrs.utils.EncryptDecryptUtil.encry256; /** * 系统用户Controller + * * @author tajocehn */ @RestController @@ -51,38 +52,37 @@ public class SysUserController { /** * 登录用户Token验证 + * * @return */ - @RequestMapping(value = "/logged/check",method = RequestMethod.POST) - public String loginUserTokenCheck(){ + @RequestMapping(value = "/logged/check", method = RequestMethod.POST) + public String loginUserTokenCheck() { Locale locale = LocaleContextHolder.getLocale(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } @RequestMapping(value = "/check/duplicate", method = RequestMethod.POST) - public String checkDuplicate(@RequestParam(value="userName", required=false) String userName){ + public String checkDuplicate(@RequestParam(value = "userName", required = false) String userName) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); // 验证用户名是否重复 - if(!sysUserService.checkUserName(userName)){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); + if (!sysUserService.checkUserName(userName)) { + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "", locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale); } - @RequestMapping(value = "/add", method = RequestMethod.POST) - public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo, - BindingResult bindingResult){ + public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo, BindingResult bindingResult) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); + if (bindingResult.hasErrors()) { + return outputEncapsulationErrorList(bindingResult.getFieldErrors(), locale); } // 验证用户名是否重复 - if(!sysUserService.checkUserName(userQo.getUserName())){ - return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"该账号已经注册,请勿重复注册",locale); + if (!sysUserService.checkUserName(userQo.getUserName())) { + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "该账号已经注册,请勿重复注册", locale); } // 添加新用户 return sysUserService.addUser(userQo); @@ -90,89 +90,92 @@ public class SysUserController { /** * 软删除指定id的普通用户 + * * @param id * @return */ @RequestMapping(value = "/general/delete", method = RequestMethod.DELETE) @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") - public String deleteCustomUser(@RequestParam(value="userId", required=false) int id){ + public String deleteCustomUser(@RequestParam(value = "userId", required = false) int id) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 int res = sysUserService.softDeleteGeneralUser(id); - if(res==1){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"",locale); + if (res == 1) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "", locale); } else { - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } } @RequestMapping(value = "/update", method = RequestMethod.POST) @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") - public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, - BindingResult bindingResult){ + public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, BindingResult bindingResult) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); // 验证数据合法性 - if(bindingResult.hasErrors()){ - return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); + if (bindingResult.hasErrors()) { + return outputEncapsulationErrorList(bindingResult.getFieldErrors(), locale); } // 修改用户 sysUserService.updateSysUser(userQo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "OK", locale); } /** * 判断用户名是否存在 + * * @param userName * @return */ @GetMapping("/booleanUserName") - public String booleanUserName(@RequestParam("userName") String userName){ + public String booleanUserName(@RequestParam("userName") String userName) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); Map map = new HashMap(3); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(userName); - if(sysUserEntity == null){ - map.put("status",0); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); - }else { - map.put("status",1); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + if (sysUserEntity == null) { + map.put("status", 0); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); + } else { + map.put("status", 1); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); } } /** * 查看用户信息 + * * @return */ @GetMapping("/selectAllUser") @PreAuthorize("hasAnyAuthority('auth_administor')") - public String selectAllUser(@RequestHeader(value="Authorization") String token){ + public String selectAllUser(@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); } List sysUserVos = sysUserService.selectAllUser(); - if(sysUserVos == null || sysUserVos.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有任何用户数据",locale); + if (sysUserVos == null || sysUserVos.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有任何用户数据", locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserVos,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, sysUserVos, locale); } /** * 管理员进行启用禁用的操作 + * * @param map * @param token * @return */ @PostMapping("/operateActiveFlag") @PreAuthorize("hasAnyAuthority('auth_administor')") - public String operateActiveFlag(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + public String operateActiveFlag(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { Integer userId = (Integer) map.get("userId"); String keepType = (String) map.get("keepType"); // 获取区域信息 @@ -180,28 +183,29 @@ public class SysUserController { // 验证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); } // 如果keepType等于1进行启用操作 - if("1".equals(keepType)){ + if ("1".equals(keepType)) { sysUserService.updateEnable(userId); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"启用成功",locale); - }else { + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "启用成功", locale); + } else { sysUserService.updateDisable(userId); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"禁用成功",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "禁用成功", locale); } } /** * 用户修改密码 + * * @param map * @param token * @return */ @PostMapping("/updatePassword") @PreAuthorize("hasAnyAuthority('auth_administor','auth_general_user')") - public String updatePassword(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + public String updatePassword(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); String oldPassword = (String) map.get("oldPassword"); @@ -210,21 +214,22 @@ public class SysUserController { // 验证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 sysUserService.updatePassword(oldPassword,newPassword,confirmPassword,sysUserEntity); + return sysUserService.updatePassword(oldPassword, newPassword, confirmPassword, sysUserEntity); } /** * 管理员修改用户的密码 + * * @param map * @param token * @return */ @PostMapping("/adminUpdatePassword") @PreAuthorize("hasAnyAuthority('auth_administor')") - public String adminUpdatePassword(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + public String adminUpdatePassword(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); // 要修改的用户的id @@ -234,40 +239,42 @@ public class SysUserController { // 验证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 sysUserService.adminUpdatePassword(userId,newPassword,confirmPassword); + return sysUserService.adminUpdatePassword(userId, newPassword, confirmPassword); } /** * 用户忘记密码 + * * @param map * @param * @return */ - @Transactional(rollbackFor=Exception.class) + @Transactional(rollbackFor = Exception.class) @PostMapping("/userUnRememberPassword") - public String userUnRememberPassword(@RequestBody Map map){ + public String userUnRememberPassword(@RequestBody Map map) { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); String phone = (String) map.get("phone"); String newPassword = (String) map.get("newPassword"); String confirmPassword = (String) map.get("confirmPassword"); SysUserEntity sysUserEntity = sysUserDao.selectByUserName(phone); - if(sysUserEntity == null){ - return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale); + if (sysUserEntity == null) { + return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR, "您还没有注册登录,请先注册登录", locale); } - if(!newPassword.equals(confirmPassword)){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"两次密码输入不一致",locale); + if (!newPassword.equals(confirmPassword)) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "两次密码输入不一致", locale); } String newAfterPassword = encry256(newPassword + sysUserEntity.getSalt()); - sysUserDao.updatePassword(sysUserEntity.getId(),newAfterPassword); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"密码修改成功",locale); + sysUserDao.updatePassword(sysUserEntity.getId(), newAfterPassword); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "密码修改成功", locale); } /** * 发送手机号 + * * @param phone * @return * @throws ClientException @@ -277,13 +284,14 @@ public class SysUserController { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); String optCode = String.valueOf(RandomUtil.returnCode()); - redisService.set(phone,optCode,10, TimeUnit.MINUTES); - SendSmsResponse response =sendSms(phone,optCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + redisService.set(phone, optCode, 10, TimeUnit.MINUTES); + SendSmsResponse response = sendSms(phone, optCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } /** * 填写手机号发送验证码,用于用户忘记密码 + * * @param phone * @return * @throws ClientException @@ -293,67 +301,70 @@ public class SysUserController { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); SysUserVo sysUserVo = sysUserDao.selectUserByUserName(phone); - if(sysUserVo == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"手机号错误,请使用您注册的手机号",locale); + if (sysUserVo == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "手机号错误,请使用您注册的手机号", locale); } String optCode = String.valueOf(RandomUtil.returnCode()); - redisService.set(phone,optCode,10, TimeUnit.MINUTES); - SendSmsResponse response =sendSms(phone,optCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + redisService.set(phone, optCode, 10, TimeUnit.MINUTES); + SendSmsResponse response = sendSms(phone, optCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "", locale); } /** * 输入验证码进行判断 + * * @param phone * @param verificationCode * @return */ @GetMapping("/getVerificationCode") - public String getVerificationCode(@RequestParam("phone") String phone, @RequestParam("verificationCode") String verificationCode){ + public String getVerificationCode(@RequestParam("phone") String phone, @RequestParam("verificationCode") String verificationCode) { Locale locale = LocaleContextHolder.getLocale(); String o = (String) redisService.get(phone); - if("".equals(o) || o == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + if ("".equals(o) || o == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "请先发送验证码!", locale); } - if(!redisService.get(phone).equals(verificationCode)){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + if (!redisService.get(phone).equals(verificationCode)) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "验证码错误,请重新输入!", locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"true",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "true", locale); } /** * 更改账号过期时间 + * * @return */ @PostMapping("/updateExpireDate") @PreAuthorize("hasAnyAuthority('auth_administor')") - public String updateExpireDate(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + public String updateExpireDate(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { Integer userId = (Integer) map.get("userId"); Integer timeNum = (Integer) map.get("timeNum"); String keepType = (String) map.get("keepType"); - if("1".equals(keepType)){ + if ("1".equals(keepType)) { return sysUserService.updateExpireDateDay(userId, timeNum); - }else if("2".equals(keepType)){ - return sysUserService.updateExpireDateMonth(userId,timeNum); - }else if("3".equals(keepType)){ - return sysUserService.updateExpireDateYear(userId,timeNum); - }else { + } else if ("2".equals(keepType)) { + return sysUserService.updateExpireDateMonth(userId, timeNum); + } else if ("3".equals(keepType)) { + return sysUserService.updateExpireDateYear(userId, timeNum); + } else { return sysUserService.updatePermanent(userId); } } /** * 修改账号到期时间 + * * @param map * @param token * @return */ @PostMapping("/updateOverTime") @PreAuthorize("hasAnyAuthority('auth_administor')") - public String updateOverTime(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + public String updateOverTime(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { Integer userId = (Integer) map.get("userId"); String overTime = (String) map.get("overTime"); - return sysUserService.updateOverTime(userId,overTime); + return sysUserService.updateOverTime(userId, overTime); } } diff --git a/src/main/java/com/xkrs/dao/CountyDao.java b/src/main/java/com/xkrs/dao/CountyDao.java index 00bf312..e5400b0 100644 --- a/src/main/java/com/xkrs/dao/CountyDao.java +++ b/src/main/java/com/xkrs/dao/CountyDao.java @@ -12,17 +12,19 @@ import java.util.Map; * @author XinYi Song */ @Component -public interface CountyDao extends JpaRepository { +public interface CountyDao extends JpaRepository { /** * 查询市包含的区县和编码 + * * @param code * @return */ - @Query(value = "select county_name cityname,county_code citycode from county where city_code = :code",nativeQuery = true) - List> selectCountyName(String code); + @Query(value = "select county_name cityname,county_code citycode from county where city_code = :code", nativeQuery = true) + List> selectCountyName(String code); /** * 根据市编码查询信息 + * * @param cityCode * @return */ @@ -32,15 +34,18 @@ public interface CountyDao extends JpaRepository { /** * 根据countyCode查询信息 + * * @param countyCode * @return */ - CountyEntity findByCountyCode(String countyCode); + List findByCountyCode(String countyCode); /** * 根据县名称查询信息 + * * @param countyName * @return */ - CountyEntity findByCountyName(String countyName); + List findByCountyName(String countyName); + } diff --git a/src/main/java/com/xkrs/dao/StreetDao.java b/src/main/java/com/xkrs/dao/StreetDao.java new file mode 100644 index 0000000..2f41595 --- /dev/null +++ b/src/main/java/com/xkrs/dao/StreetDao.java @@ -0,0 +1,30 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.StreetEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Optional; + +@Component +public interface StreetDao extends JpaRepository, JpaSpecificationExecutor { + + List findByProName(String proName); + + List findByProCode(String proCode); + + List findByCityName(String cityName); + + List findByCityCode(String cityCode); + + List findByCountyName(String countyName); + + List findByCountyCode(String countyCode); + + Optional findByStreetName(String streetName); + + Optional findByStreetCode(String streetCode); + +} diff --git a/src/main/java/com/xkrs/model/entity/StreetEntity.java b/src/main/java/com/xkrs/model/entity/StreetEntity.java new file mode 100644 index 0000000..21624e3 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/StreetEntity.java @@ -0,0 +1,155 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "street") +public class StreetEntity implements Serializable { + + /** + * 主键id + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "street_seq_gen") + @SequenceGenerator(name = "street_seq_gen", sequenceName = "street_id_seq", allocationSize = 1) + private Integer id; + + /** + * 省名称 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String proName; + + /** + * 省编码 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String proCode; + + /** + * 市名称 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String cityName; + + /** + * 市编码 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String cityCode; + + /** + * 区县名称 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String countyName; + + /** + * 区县编码 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String countyCode; + + /** + * 街道名称 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String streetName; + + /** + * 街道编码 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String streetCode; + + public StreetEntity() { + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getProName() { + return proName; + } + + public void setProName(String proName) { + this.proName = proName; + } + + public String getProCode() { + return proCode; + } + + public void setProCode(String proCode) { + this.proCode = proCode; + } + + public String getCityName() { + return cityName; + } + + public void setCityName(String cityName) { + this.cityName = cityName; + } + + public String getCityCode() { + return cityCode; + } + + public void setCityCode(String cityCode) { + this.cityCode = cityCode; + } + + public String getCountyName() { + return countyName; + } + + public void setCountyName(String countyName) { + this.countyName = countyName; + } + + public String getCountyCode() { + return countyCode; + } + + public void setCountyCode(String countyCode) { + this.countyCode = countyCode; + } + + public String getStreetName() { + return streetName; + } + + public void setStreetName(String streetName) { + this.streetName = streetName; + } + + public String getStreetCode() { + return streetCode; + } + + public void setStreetCode(String streetCode) { + this.streetCode = streetCode; + } + + @Override + public String toString() { + return "StreetEntity{" + + "id=" + id + + ", proName='" + proName + '\'' + + ", proCode='" + proCode + '\'' + + ", cityName='" + cityName + '\'' + + ", cityCode='" + cityCode + '\'' + + ", countyName='" + countyName + '\'' + + ", countyCode='" + countyCode + '\'' + + ", streetName='" + streetName + '\'' + + ", streetCode='" + streetCode + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java index 4e10fc3..bec5427 100644 --- a/src/main/java/com/xkrs/model/entity/SysUserEntity.java +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -98,7 +98,8 @@ public class SysUserEntity implements Serializable { */ private String loginLastTime; - private Integer street; + public SysUserEntity() { + } public Integer getId() { return id; @@ -260,16 +261,8 @@ public class SysUserEntity implements Serializable { this.loginLastTime = loginLastTime; } - public Integer getStreet() { - return street; - } - - public void setStreet(Integer street) { - this.street = street; - } - @Override public String toString() { - return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", lastEntryTime=" + lastEntryTime + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", dayNum=" + dayNum + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + ", street=" + street + '}'; + return "SysUserEntity{" + "id=" + id + ", userName='" + userName + '\'' + ", reallyName='" + reallyName + '\'' + ", password='" + password + '\'' + ", salt='" + salt + '\'' + ", telephone='" + telephone + '\'' + ", countyCode='" + countyCode + '\'' + ", signature='" + signature + '\'' + ", activeFlag=" + activeFlag + ", statusCode=" + statusCode + ", addTime='" + addTime + '\'' + ", lastEntryTime=" + lastEntryTime + ", deleteFlag=" + deleteFlag + ", lastEntryIp='" + lastEntryIp + '\'' + ", dayNum=" + dayNum + ", overTime='" + overTime + '\'' + ", accountType='" + accountType + '\'' + ", countyName='" + countyName + '\'' + ", loginNum=" + loginNum + ", loginLastTime='" + loginLastTime + '\'' + '}'; } } diff --git a/src/main/java/com/xkrs/model/qo/SysUserQo.java b/src/main/java/com/xkrs/model/qo/SysUserQo.java index 37e8e19..553be29 100644 --- a/src/main/java/com/xkrs/model/qo/SysUserQo.java +++ b/src/main/java/com/xkrs/model/qo/SysUserQo.java @@ -41,6 +41,10 @@ public class SysUserQo { @Range(min = 0, max = 2, message = "{SysUser.statusCode.illegal}", groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) private Integer statusCode; + @NotNull(message = "{SysUser.countyName.blank}", groups = {SysUserQoUpdate.class}) + private String countyName; + + @NotNull(message = "{SysUser.countyCode.blank}", groups = {SysUserQoUpdate.class}) private String countyCode; @NotNull(message = "{SysUser.deleteFlag.null}", groups = {SysUserQoUpdate.class}) @@ -54,10 +58,8 @@ public class SysUserQo { private String accountType; - private String countyName; - - @NotNull(message = "{SysUser.street.blank}", groups = {SysUserQoUpdate.class}) - private Integer street; + public SysUserQo() { + } public Integer getId() { return id; @@ -107,6 +109,14 @@ public class SysUserQo { this.statusCode = statusCode; } + public String getCountyName() { + return countyName; + } + + public void setCountyName(String countyName) { + this.countyName = countyName; + } + public String getCountyCode() { return countyCode; } @@ -154,20 +164,4 @@ public class SysUserQo { public void setAccountType(String accountType) { this.accountType = accountType; } - - public String getCountyName() { - return countyName; - } - - public void setCountyName(String countyName) { - this.countyName = countyName; - } - - public Integer getStreet() { - return street; - } - - public void setStreet(Integer street) { - this.street = street; - } } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 08d6a43..3f62c00 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -76,27 +76,28 @@ public class FirePointServiceImpl implements FirePointService { /** * 添加火点信息 + * * @param firePointQo * @return */ - @CacheEvict(value = "FirePointServiceCache",allEntries = true) + @CacheEvict(value = "FirePointServiceCache", allEntries = true) @Override public FirePointEntity insertFirePoint(FirePointQo firePointQo) { FirePointEntity firePointEntity = new FirePointEntity(); - if(firePointQo.getLandtype().equals("水体")){ + if (firePointQo.getLandtype().equals("水体")) { return null; - }else if("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())){ + } else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) { return null; - }else if("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())){ + } else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) { return null; - }else { + } else { firePointEntity.setFireCode(firePointQo.getFireCode()); firePointEntity.setCountyCode(firePointQo.getCountyCode().toString()); firePointEntity.setCountyName(firePointQo.getCountyName()); firePointEntity.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue())); firePointEntity.setLongitude(firePointQo.getLongitude()); firePointEntity.setLatitude(firePointQo.getLatitude()); - firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString())); + firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString())); firePointEntity.setSatelliteType(firePointQo.getSatelliteType()); firePointEntity.setLandType(firePointQo.getLandtype()); firePointEntity.setConfidence(firePointQo.getConfidence()); @@ -127,44 +128,46 @@ public class FirePointServiceImpl implements FirePointService { /** * 查询今天的火点信息 + * * @param * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public List selectTodayFirePoint(String countyCode) { String addTime = DateTimeUtil.dateToString(LocalDate.now()); - if("0000".equals(countyCode.substring(2))){ + if ("0000".equals(countyCode.substring(2))) { List byProCode = cityDao.findByProCode(countyCode); String proName = byProCode.get(0).getProName(); // if(proName.equals("山东省")){ // return firePointDao.selectTodayFirePointShandong(addTime,proName); // } - return firePointDao.selectTodayFirePoint(addTime,proName); + return firePointDao.selectTodayFirePoint(addTime, proName); - }else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){ + } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { List byCityCode = countyDao.findByCityCode(countyCode); String cityName = byCityCode.get(0).getCityName(); CityEntity byCityName = cityDao.findByCityName(cityName); // if(byCityName.getProName().equals("山东省")){ // return firePointDao.selectTodayFirePointShandong(addTime,cityName); // } - return firePointDao.selectTodayFirePoint(addTime,cityName); - }else { - CountyEntity byCountyCode = countyDao.findByCountyCode(countyCode); - CityEntity byCityName = cityDao.findByCityName(byCountyCode.getCityName()); + return firePointDao.selectTodayFirePoint(addTime, cityName); + } else { + List byCountyCode = countyDao.findByCountyCode(countyCode); + CityEntity byCityName = cityDao.findByCityName(byCountyCode.get(0).getCityName()); // if(b // // // yCityName.getProName().equals("山东省")){ // return firePointDao.selectTodayFirePointOneShandong(addTime,countyCode); // } - return firePointDao.selectTodayFirePointOne(addTime,countyCode); + return firePointDao.selectTodayFirePointOne(addTime, countyCode); } } /** * 动态多条件查询火点信息(省) + * * @param cityCode * @param satelliteType * @param landType @@ -172,32 +175,33 @@ public class FirePointServiceImpl implements FirePointService { * @param endTime * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override - public List selectFirePoint(String proCode,String cityCode, String satelliteType, String landType, String startTime, String endTime) { + public List selectFirePoint(String proCode, String cityCode, String satelliteType, String landType, String startTime, String endTime) { List byProCode = cityDao.findByProCode(proCode); String proName = byProCode.get(0).getProName(); - if(!"".equals(startTime) && !"".equals(endTime)){ + if (!"".equals(startTime) && !"".equals(endTime)) { LocalDate localDate = DateTimeUtil.stringToDate(endTime); // 结束时间 LocalDate localDate1 = localDate.plusDays(1); String dateToString = DateTimeUtil.dateToString(localDate1); - return query.selectFirePointByPro(proName,cityCode, satelliteType, landType, startTime, dateToString); + return query.selectFirePointByPro(proName, cityCode, satelliteType, landType, startTime, dateToString); } - return query.selectFirePointByPro(proName,cityCode, satelliteType, landType, startTime, endTime); + return query.selectFirePointByPro(proName, cityCode, satelliteType, landType, startTime, endTime); } /** * 动态多条件查询火点信息(市) - * @param cityCodeOne 市编码 - * @param cityCode 县编码 + * + * @param cityCodeOne 市编码 + * @param cityCode 县编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public List selectFirePointByCity(String cityCodeOne, String cityCode, String satelliteType, String landType, String startTime, String endTime) { //List byCityCode = cityDao.findByCityCode(cityCodeOne.substring(0,3)); @@ -205,44 +209,46 @@ public class FirePointServiceImpl implements FirePointService { String cityName = byCityCode.get(0).getCityName(); CityEntity byCityCode1 = cityDao.findByCityName(cityName); String proName = byCityCode1.getProName(); - if(!"".equals(startTime) && !"".equals(endTime)){ + 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(proName, cityName, cityCode, satelliteType, landType, startTime, dateToString); } - return query.selectFirePointByCity(proName, cityName,cityCode,satelliteType,landType,startTime,endTime); + return query.selectFirePointByCity(proName, cityName, cityCode, satelliteType, landType, startTime, endTime); } /** * 动态多条件查询火点信息(县) - * @param cityCode 县编码 + * + * @param cityCode 县编码 * @param satelliteType * @param landType * @param startTime * @param endTime * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public List selectFirePointByCounty(String cityCode, String satelliteType, String landType, String startTime, String endTime) { - CountyEntity byCountyCode = countyDao.findByCountyCode(cityCode); - CityEntity byCityCode = cityDao.findByCityName(byCountyCode.getCityName()); + List byCountyCode = countyDao.findByCountyCode(cityCode); + CityEntity byCityCode = cityDao.findByCityName(byCountyCode.get(0).getCityName()); String proName = byCityCode.getProName(); - if(!"".equals(startTime) && !"".equals(endTime)){ + 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(proName, cityCode, satelliteType, landType, startTime, dateToString); } - return query.selectFirePointByCounty(proName, cityCode,satelliteType,landType,startTime,endTime); + return query.selectFirePointByCounty(proName, cityCode, satelliteType, landType, startTime, endTime); } /** * 根据火点编码修改火点的状态(预警) + * * @param fireCode * @param fireType * @param token @@ -257,20 +263,20 @@ public class FirePointServiceImpl implements FirePointService { SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode); if ("3".equals(byFireCode.getFireType()) || "-1".equals(byFireCode.getFireType())) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该火点已经结案,请勿进行有关状态操作",locale); + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "该火点已经结案,请勿进行有关状态操作", locale); } if (fireType.equals(byFireCode.getFireType())) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"您正处于当前的状态,请勿进行该操作",locale); + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "您正处于当前的状态,请勿进行该操作", locale); } firePointDao.updateFireTypeByFireCode(fireCode, fireType); if ("1".equals(fireType)) { FirePointEntity byFireCode1 = firePointDao.findByFireCode(fireCode); // 预警 - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode1,locale); - } else if ("2".equals(fireType)){ + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode1, locale); + } else if ("2".equals(fireType)) { FirePointEntity byFireCode3 = firePointDao.findByFireCode(fireCode); // 核查 - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode3,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode3, locale); } else { String rangerType = "0"; FireAndRanger byFireCode1 = fireAndRangerDao.findByFireCode(fireCode); @@ -284,19 +290,20 @@ public class FirePointServiceImpl implements FirePointService { fireAndRanger.setEndTime(time); fireAndRangerDao.save(fireAndRanger); // 结案 - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode4,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode4, locale); } // 火点结案,将护林员的状态修改为0 表示该护林员没有在执行任务,处于空闲状态 forestRangerDao.updateRangerTypeByPhone(byFireCode1.getRangerName(), rangerType); String time = DateTimeUtil.dateTimeToString(LocalDateTime.now()); fireAndRangerDao.updateEndTimeByFireCode(fireCode, time); fireAndRangerDao.updateProgressTypeByFireCode(fireCode, "0"); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"结案",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "结案", locale); } } /** * 提交核查任务 + * * @param files * @param appTaskBodyVo * @return @@ -307,12 +314,12 @@ public class FirePointServiceImpl implements FirePointService { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode()); - if(byFireCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"火点编码错误,请重新输入",locale); + if (byFireCode == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "火点编码错误,请重新输入", locale); } FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(appTaskBodyVo.getFireCode()); - if(byTaskFireCode != null){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该火点的任务已经提交,请勿重复提交",locale); + if (byTaskFireCode != null) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "该火点的任务已经提交,请勿重复提交", locale); } String s = DateTimeUtil.dateTimeToString(LocalDateTime.now()); FireTask fireTask = new FireTask(); @@ -320,19 +327,20 @@ public class FirePointServiceImpl implements FirePointService { fireTask.setTaskInformation(appTaskBodyVo.getTaskInformation()); fireTask.setTaskTime(s); FireTask save = fireTaskDao.save(fireTask); - if(save == null){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"任务提交失败",locale); + if (save == null) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "任务提交失败", locale); } List fireTaskPhotos = PhotoUtil.uploadImage(files, appTaskBodyVo.getFireCode()); List fireTaskPhotos1 = fireTaskPhotoDao.saveAll(fireTaskPhotos); - if(fireTaskPhotos1 == null || fireTaskPhotos1.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"图片上传失败,任务提交失败",locale); + if (fireTaskPhotos1 == null || fireTaskPhotos1.size() == 0) { + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "图片上传失败,任务提交失败", locale); } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"任务提交成功",locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "任务提交成功", locale); } /** * 根据火点编码查询任务信息 + * * @param fireCode * @return * @throws Exception @@ -342,26 +350,27 @@ public class FirePointServiceImpl implements FirePointService { // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode); - if(byTaskFireCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有该火点的任务信息",locale); + if (byTaskFireCode == null) { + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有该火点的任务信息", locale); } AppTaskBodyVo appTaskBodyVo = new AppTaskBodyVo(); // 做映射,返回vo类对象 BeanCopier beanCopier = BeanCopier.create(FireTask.class, AppTaskBodyVo.class, false); - beanCopier.copy(byTaskFireCode,appTaskBodyVo,null); + beanCopier.copy(byTaskFireCode, appTaskBodyVo, null); List photoPath = fireTaskPhotoDao.findPhotoPath(fireCode); List appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class); appTaskBodyVo.setTaskFirePhoto(appPhotoVos); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,appTaskBodyVo,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, appTaskBodyVo, locale); } /** * 查询近一周的火点信息 + * * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public List selectFirePointBetweenSeven() { LocalDateTime localDateTime = LocalDateTime.now(); @@ -375,9 +384,10 @@ public class FirePointServiceImpl implements FirePointService { /** * 查询近一个月的火点信息 + * * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public List selectFirePointByMonth(String countyCode) { LocalDateTime localDateTime = LocalDateTime.now(); @@ -385,30 +395,31 @@ public class FirePointServiceImpl implements FirePointService { // 当前时间减31 LocalDateTime localDateTime1 = localDateTime.minusDays(31); String startTime = DateTimeUtil.dateTimeToString(localDateTime1); - if("0000".equals(countyCode.substring(2))){ + if ("0000".equals(countyCode.substring(2))) { List byProCode = cityDao.findByProCode(countyCode); String proName = byProCode.get(0).getProName(); - return query.selectFirePointByMonth(proName,startTime,endTime); - }else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){ + return query.selectFirePointByMonth(proName, startTime, endTime); + } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { List 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); - }else { - CountyEntity byCountyCode = countyDao.findByCountyCode(countyCode); - CityEntity byCityName = cityDao.findByCityName(byCountyCode.getCityName()); + return query.selectFirePointByMonthCity(proName, cityName, startTime, endTime); + } else { + List 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(proName, countyCode, startTime, endTime); } } /** * 查询近一个月的火点数量 + * * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public String selectFirePointNumMonth() { // 获取区域信息 @@ -422,19 +433,20 @@ public class FirePointServiceImpl implements FirePointService { String startTime = DateTimeUtil.dateTimeToString(localDateTime1); // 查询近一个月各植被类型的火点数量 List> maps = firePointDao.selectNumByLandType(startTime, endTime); - map.put("land",maps); + map.put("land", maps); // 查询近一个月各地区火点数量 List> maps1 = firePointDao.selectNumByArea(startTime, endTime); - map.put("area",maps1); + map.put("area", maps1); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); } /** * 查询近一天的火点数量 + * * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public String selectFirePointNumDay() { // 获取区域信息 @@ -448,19 +460,20 @@ public class FirePointServiceImpl implements FirePointService { String startTime = DateTimeUtil.dateTimeToString(localDateTime1); // 查询近一个月各植被类型的火点数量 List> maps = firePointDao.selectNumByLandType(startTime, endTime); - map.put("land",maps); + map.put("land", maps); // 查询近一个月各地区火点数量 List> maps1 = firePointDao.selectNumByArea(startTime, endTime); - map.put("area",maps1); + map.put("area", maps1); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); } /** * 查询近一周的火点数量 + * * @return */ - @Cacheable(keyGenerator = "keyGenerator", unless="#result == null") + @Cacheable(keyGenerator = "keyGenerator", unless = "#result == null") @Override public String selectFirePointNumWeek() { // 获取区域信息 @@ -474,16 +487,17 @@ public class FirePointServiceImpl implements FirePointService { String startTime = DateTimeUtil.dateTimeToString(localDateTime1); // 查询近一个月各植被类型的火点数量 List> maps = firePointDao.selectNumByLandType(startTime, endTime); - map.put("land",maps); + map.put("land", maps); // 查询近一个月各地区火点数量 List> maps1 = firePointDao.selectNumByArea(startTime, endTime); - map.put("area",maps1); + map.put("area", maps1); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); } /** * 查询该省所有的市 + * * @param code * @return */ @@ -494,6 +508,7 @@ public class FirePointServiceImpl implements FirePointService { /** * 查询市包含的区县和编码 + * * @param code * @return */ @@ -504,6 +519,7 @@ public class FirePointServiceImpl implements FirePointService { /** * 测试插入火点信息 + * * @param firePointQo * @return */ @@ -516,7 +532,7 @@ public class FirePointServiceImpl implements FirePointService { firePoint.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue())); firePoint.setLongitude(firePointQo.getLongitude()); firePoint.setLatitude(firePointQo.getLatitude()); - firePoint.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(),firePointQo.getLongitude().toString())); + firePoint.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString())); firePoint.setSatelliteType(firePointQo.getSatelliteType()); firePoint.setLandType(firePointQo.getLandtype()); firePoint.setConfidence(firePointQo.getConfidence()); @@ -530,6 +546,7 @@ public class FirePointServiceImpl implements FirePointService { /** * 导入全国省市区 + * * @param file * @throws Exception */ @@ -557,22 +574,23 @@ public class FirePointServiceImpl implements FirePointService { /** * 查询今日的火点信息(测试) + * * @param countyCode * @return */ @Override public List selectTodayFire(String countyCode) { String addTime = DateTimeUtil.dateToString(LocalDate.now()); - if("0000".equals(countyCode.substring(2))){ + if ("0000".equals(countyCode.substring(2))) { List byProCode = cityDao.findByProCode(countyCode); String proName = byProCode.get(0).getProName(); - return fireDao.selectTodayFire(addTime,proName); - }else if("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))){ + return fireDao.selectTodayFire(addTime, proName); + } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { List byCityCode = countyDao.findByCityCode(countyCode); String cityName = byCityCode.get(0).getCityName(); - return fireDao.selectTodayFire(addTime,cityName); - }else { - return fireDao.selectTodayFireOne(addTime,countyCode); + return fireDao.selectTodayFire(addTime, cityName); + } else { + return fireDao.selectTodayFireOne(addTime, countyCode); } } } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 8d25d24..b34d9cf 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -19,6 +19,7 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Optional; import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; import static com.xkrs.utils.DateTimeUtil.dateTimeToString; @@ -50,11 +51,14 @@ public class SysUserServiceImpl implements SysUserService { @Resource private NationwideDao nationwideDao; + @Resource + private CityDao cityDao; + @Resource private CountyDao countyDao; @Resource - private CityDao cityDao; + private StreetDao streetDao; /** * 检查用户名是否存在 @@ -80,7 +84,6 @@ public class SysUserServiceImpl implements SysUserService { Locale locale = LocaleContextHolder.getLocale(); String salt = KeyGenerators.string().generateKey(); SysUserEntity sysUserEntity = new SysUserEntity(); - sysUserEntity.setStreet(0); sysUserEntity.setUserName(sysUserQo.getUserName()); String o = (String) redisService.get(sysUserQo.getUserName()); if ("".equals(o) || o == null) { @@ -97,56 +100,72 @@ public class SysUserServiceImpl implements SysUserService { sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt)); sysUserEntity.setTelephone(sysUserQo.getUserName()); - if (TextUtils.isEmpty(sysUserQo.getCountyName())) { + String countyCode = sysUserQo.getCountyCode(); + String countyName = sysUserQo.getCountyName(); + if (TextUtils.isEmpty(countyCode)) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道编码不能为空!", locale); + } + if (TextUtils.isEmpty(countyName)) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省市区街道名称不能为空!", locale); } - sysUserEntity.setCountyCode(sysUserQo.getCountyCode()); - if (1 == sysUserQo.getStreet()) { + if (9 == countyCode.length()) { + Optional byStreetCodeOptional = streetDao.findByStreetCode(countyCode); + if (byStreetCodeOptional.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "街道编码不存在!", locale); + } + Optional byStreetNameOptional = streetDao.findByStreetName(countyName); + if (byStreetNameOptional.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); + } sysUserEntity.setActiveFlag(0); sysUserEntity.setAccountType("街道级"); - } else if ("0000".equals(sysUserQo.getCountyCode().substring(2))) { - List byProCode = cityDao.findByProCode(sysUserQo.getCountyCode()); + } else if ("0000".equals(countyCode.substring(2))) { + List byProCode = cityDao.findByProCode(countyCode); if (byProCode == null || byProCode.size() == 0) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "省编码不存在!", locale); } - List byProName = cityDao.findByProName(sysUserQo.getCountyName()); + List byProName = cityDao.findByProName(countyName); if (byProName == null || byProName.size() == 0) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(1); sysUserEntity.setAccountType("省级"); - } else if ("00".equals(sysUserQo.getCountyCode().substring(4)) && !"0000".equals(sysUserQo.getCountyCode().substring(2))) { - List byCityCode = countyDao.findByCityCode(sysUserQo.getCountyCode()); + } else if ("00".equals(countyCode.substring(4)) && !"0000".equals(countyCode.substring(2))) { + List byCityCode = countyDao.findByCityCode(countyCode); if (byCityCode == null || byCityCode.size() == 0) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "市编码不存在!", locale); } - List byCityName = countyDao.findByCityName(sysUserQo.getCountyName()); + List byCityName = countyDao.findByCityName(countyName); if (byCityName == null || byCityName.size() == 0) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(1); sysUserEntity.setAccountType("市级"); } else { - CountyEntity byCountyCode = countyDao.findByCountyCode(sysUserQo.getCountyCode()); - if (byCountyCode == null) { - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "编码不存在!", locale); + List byCountyCode = countyDao.findByCountyCode(countyCode); + if (byCountyCode == null || byCountyCode.isEmpty()) { + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "区县编码不存在!", locale); } - CountyEntity byCountyName = countyDao.findByCountyName(sysUserQo.getCountyName()); - if (byCountyName == null) { + List byCountyName = countyDao.findByCountyName(countyName); + if (byCountyName == null || byCountyName.isEmpty()) { return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "您所选择的区域不存在!", locale); } sysUserEntity.setActiveFlag(0); sysUserEntity.setAccountType("县级"); } + if (9 == countyCode.length()) {//街道账号5天后过期 + sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(5L))); + } else {//省市区县账号3天后过期 + sysUserEntity.setOverTime(dateTimeToString(LocalDateTime.now().plusDays(3L))); + } sysUserEntity.setStatusCode(0); sysUserEntity.setAddTime(dateTimeToString(LocalDateTime.now())); sysUserEntity.setDeleteFlag(0); sysUserEntity.setDayNum(7); - String string = dateTimeToString(LocalDateTime.now().plusDays(3L)); - sysUserEntity.setOverTime(string); sysUserEntity.setLoginNum(0); - sysUserEntity.setCountyName(sysUserQo.getCountyName()); + sysUserEntity.setCountyCode(countyCode); + sysUserEntity.setCountyName(countyName); sysUserDao.save(sysUserEntity); RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity();