From f312e74eeea869744b5b7b8c0e01f3a6598385a9 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Fri, 16 Sep 2022 17:34:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 - .../controller/FireAndRangerController.java | 57 ------ .../xkrs/controller/FirePointController.java | 77 +------- .../controller/ForestRangerController.java | 55 ------ .../java/com/xkrs/dao/FireAndRangerDao.java | 55 ------ src/main/java/com/xkrs/dao/FirePointDao.java | 31 --- src/main/java/com/xkrs/dao/FireTaskDao.java | 18 -- .../java/com/xkrs/dao/FireTaskPhotoDao.java | 29 --- .../java/com/xkrs/dao/ForestRangerDao.java | 63 ------ .../xkrs/service/FireAndRangerService.java | 34 ---- .../com/xkrs/service/FirePointService.java | 40 ---- .../com/xkrs/service/ForestRangerService.java | 31 --- .../impl/FireAndRangerServiceImpl.java | 174 ----------------- .../service/impl/FirePointServiceImpl.java | 181 ------------------ .../service/impl/ForestRangerServiceImpl.java | 83 -------- 15 files changed, 1 insertion(+), 928 deletions(-) delete mode 100644 src/main/java/com/xkrs/controller/FireAndRangerController.java delete mode 100644 src/main/java/com/xkrs/controller/ForestRangerController.java delete mode 100644 src/main/java/com/xkrs/dao/FireAndRangerDao.java delete mode 100644 src/main/java/com/xkrs/dao/FireTaskDao.java delete mode 100644 src/main/java/com/xkrs/dao/FireTaskPhotoDao.java delete mode 100644 src/main/java/com/xkrs/dao/ForestRangerDao.java delete mode 100644 src/main/java/com/xkrs/service/FireAndRangerService.java delete mode 100644 src/main/java/com/xkrs/service/ForestRangerService.java delete mode 100644 src/main/java/com/xkrs/service/impl/FireAndRangerServiceImpl.java delete mode 100644 src/main/java/com/xkrs/service/impl/ForestRangerServiceImpl.java diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 4dd45e1..723b761 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -62,7 +62,6 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET, "/weather/cityName").permitAll() .antMatchers(HttpMethod.GET, "/weather/cityId").permitAll() .antMatchers(HttpMethod.GET, "/selectFirePointByCode").permitAll() - .antMatchers(HttpMethod.POST, "/updateTypeByFireCode").permitAll() .antMatchers(HttpMethod.GET, "/api/user/verificationCode").permitAll() .antMatchers(HttpMethod.GET, "/api/user/selectAgentOrgList").permitAll()//获取代理组织列表 .antMatchers(HttpMethod.POST, "/uploadFileMore").permitAll() diff --git a/src/main/java/com/xkrs/controller/FireAndRangerController.java b/src/main/java/com/xkrs/controller/FireAndRangerController.java deleted file mode 100644 index 26cbe4c..0000000 --- a/src/main/java/com/xkrs/controller/FireAndRangerController.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.xkrs.controller; - -import com.xkrs.service.FireAndRangerService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.io.UnsupportedEncodingException; -import java.util.Map; - -/** - * @author xkrs - */ -@RestController -public class FireAndRangerController { - - @Resource - private FireAndRangerService fireAndRangerService; - - /** - * 将火点分配给某个人 - * - * @param map - * @param token - * @return - */ - @PostMapping("/addFireAndRanger") - public String addFireAndRanger(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) throws UnsupportedEncodingException { - String rangerName = (String) map.get("rangerName"); - String fireCode = (String) map.get("fireCode"); - String handler = (String) map.get("handler"); - String verifier = (String) map.get("verifier"); - return fireAndRangerService.addFireAndRanger(rangerName, fireCode, handler, verifier, token); - } - - /** - * 护林员查看自己的火点任务 - * - * @param token - * @return - */ - @GetMapping("/selectFireInformation") - public String selectFireInformation(@RequestHeader(value = "Authorization") String token) { - return fireAndRangerService.selectFireInformation(token); - } - - /** - * 根据火点编码查询核查信息 - * - * @param map - * @return - */ - @PostMapping("/findFireAndRanger") - public String findFireAndRangerByFireCode(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) throws Exception { - String fireCode = (String) map.get("fireCode"); - return fireAndRangerService.findFireAndRangerByFireCode(fireCode, token); - } -} diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 6080a2c..b9afe72 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -11,7 +11,6 @@ import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.AuditFireTypeQo; import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.qo.ShanDongFirePointVerifyStateQo; -import com.xkrs.model.vo.AppTaskBodyVo; import com.xkrs.service.FirePointService; import com.xkrs.service.StreetService; import com.xkrs.utils.FirePointQueryHelper; @@ -20,14 +19,12 @@ import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.persistence.criteria.Predicate; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.transaction.Transactional; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -189,20 +186,10 @@ public class FirePointController { */ @GetMapping("/queryFirePoint") public String queryFirePoint(@RequestParam(value = "code", required = false) String code, @RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime, @RequestParam(value = "satelliteType", required = false) String satelliteType, @RequestParam(value = "landType", required = false) String landType) { - List firePointList= firePointService.queryFirePoint(code, startTime, endTime, satelliteType, landType); + List firePointList = firePointService.queryFirePoint(code, startTime, endTime, satelliteType, landType); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale); } - /** - * 更新火点的街道编号数据 - * - * @return - */ - @GetMapping("/updateFirePointStreetCode") - public String updateFirePointStreetCode() { - return firePointService.updateFirePointStreetCode(); - } - /** * 测试 * @@ -258,45 +245,6 @@ public class FirePointController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, firePointList, locale); } - /** - * 根据火点编码修改火点状态 - * - * @param map - * @param token - * @return - */ - @PostMapping("/updateTypeByFireCode") - 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); - } - - /** - * 提交核查任务 - */ - @PostMapping("/insertAppTask") - public String insertAppTask(@RequestParam("files") MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException { - 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 (files == null || files.length == 0) { - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "图片不能为空", locale); - } - return firePointService.insertAppTask(files, appTaskBodyVo); - } - - /** - * 查询核查的任务信息 - */ - @GetMapping("/selectAppTask") - public String selectAppTask(@RequestParam("fireCode") String fireCode) throws Exception { - return firePointService.selectAppTask(fireCode); - } - /** * 查询近一周的火点信息 */ @@ -374,27 +322,4 @@ public class FirePointController { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode, locale); } - /** - * 根据火点编码添加火点前后的图片 - * - * @param map - * @return - */ - @Transactional(rollbackOn = Exception.class) - @PostMapping("/updateBeforeFireAndAfterFireImage") - public String updateBeforeFireAndAfterFireImage(@RequestBody Map map) { - 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); - } - FirePointEntity byFireCode = firePointDao.findByFireCode(fireCode); - if (byFireCode == null) { - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "火点编码错误!", locale); - } - firePointDao.updateBeforeFireAndAfterFireImage(fireCode, beforeFireImage, afterFireImage); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加图片成功!", locale); - } - } diff --git a/src/main/java/com/xkrs/controller/ForestRangerController.java b/src/main/java/com/xkrs/controller/ForestRangerController.java deleted file mode 100644 index 7d83440..0000000 --- a/src/main/java/com/xkrs/controller/ForestRangerController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.xkrs.controller; - -import com.xkrs.service.ForestRangerService; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import java.util.Map; - -/** - * @author xkrs - */ -@RestController -public class ForestRangerController { - - @Resource - private ForestRangerService forestRangerService; - - /** - * 根据区县编码查询相关护林员的信息 - * - * @param rangerCountyCode - * @return - */ - @GetMapping("/findByRangerCountyCode") - public String findByRangerCountyCode(@RequestParam("rangerCountyCode") String rangerCountyCode, @RequestHeader(value = "Authorization") String token) { - return forestRangerService.findByRangerCountyCode(rangerCountyCode); - } - - /** - * 根据区县编码查询该区县所有护林员的信息 - * - * @param countyCode - * @param token - * @return - */ - @GetMapping("/findAllByRangerCountyCode") - public String findAllByRangerCountyCode(@RequestParam("countyCode") String countyCode, @RequestHeader(value = "Authorization") String token) { - return forestRangerService.findAllByRangerCountyCode(countyCode, token); - } - - /** - * 根据手机号修改护林员的位置 - * - * @param map - * @return - */ - @PostMapping("/updateLatAndLonByPhone") - public String updateLatAndLonByPhone(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) { - String rangerLatitude = (String) map.get("rangerLatitude"); - String rangerLongitude = (String) map.get("rangerLongitude"); - String rangerPhone = (String) map.get("rangerPhone"); - return forestRangerService.updateLatAndLonByPhone(rangerLatitude, rangerLongitude, rangerPhone); - } - -} diff --git a/src/main/java/com/xkrs/dao/FireAndRangerDao.java b/src/main/java/com/xkrs/dao/FireAndRangerDao.java deleted file mode 100644 index e8f1ed1..0000000 --- a/src/main/java/com/xkrs/dao/FireAndRangerDao.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.FireAndRanger; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Component; - -/** - * @author xkrs - */ -@Component -public interface FireAndRangerDao extends JpaRepository, JpaSpecificationExecutor { - - /** - * 根据火点编码查询信息 - * @param fireCode - * @return - */ - FireAndRanger findByFireCode(String fireCode); - - /** - * 根据护林员手机号查询 - * @param rangerName - * @param progressType - * @return - */ - FireAndRanger findByRangerNameAndProgressType(String rangerName, String progressType); - - /** - * 根据火点编码删除火点信息 - * @param fireCode - * @return - */ - FireAndRanger deleteByFireCode(String fireCode); - - /** - * 根据火点编码修改结束时间 - * @param fireCode - * @param endTime - */ - @Modifying(clearAutomatically=true) - @Query(value = "update fire_and_ranger set end_time = ?2 where fire_code = ?1",nativeQuery = true) - void updateEndTimeByFireCode(String fireCode, String endTime); - - /** - * 根据火点编码修改进程状态 - * @param fireCode - * @param endTime - */ - @Modifying(clearAutomatically=true) - @Query(value = "update fire_and_ranger set progress_type = ?2 where fire_code = ?1",nativeQuery = true) - void updateProgressTypeByFireCode(String fireCode, String endTime); -} diff --git a/src/main/java/com/xkrs/dao/FirePointDao.java b/src/main/java/com/xkrs/dao/FirePointDao.java index c6ea710..84d13b0 100644 --- a/src/main/java/com/xkrs/dao/FirePointDao.java +++ b/src/main/java/com/xkrs/dao/FirePointDao.java @@ -7,13 +7,9 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; -import javax.transaction.Transactional; import java.util.List; import java.util.Map; -/** - * @author XinYi Song - */ @Component public interface FirePointDao extends JpaRepository, JpaSpecificationExecutor { @@ -25,13 +21,6 @@ public interface FirePointDao extends JpaRepository, JpaS @Query(value = "SELECT * FROM fire_point WHERE longitude = ?1 AND latitude = ?2 AND street_code = ?3 AND satellite_time = ?4 AND satellite_type = ?5 AND land_type = ?6", nativeQuery = true) List findDuplicatedData(double longitude, double latitude, String streetCode, String satelliteTime, String satelliteType, String landType); - /** - * 根据火点编码修改火点状态 - */ - @Modifying(clearAutomatically = true) - @Query(value = "UPDATE fire_point SET fire_type = ?2 WHERE fire_code = ?1", nativeQuery = true) - void updateFireTypeByFireCode(String fireCode, String fireType); - /** * 根据火点编码修改审核火点状态 */ @@ -51,26 +40,6 @@ public interface FirePointDao extends JpaRepository, JpaS @Query(value = "select ci.city_name cityname,count(fp.id) from street ci left join fire_point fp on fp.county_code like concat('%',ci.city_code,'%') AND fp.satellite_time BETWEEN ?1 AND ?2 group by ci.city_name", nativeQuery = true) List> selectNumByArea(String startTime, String endTime); - /** - * 根据火点编码,修改火点前后图片路径 - */ - @Modifying(clearAutomatically = true) - @Query(value = "update fire_point set before_fire_image = ?2,after_fire_image = ?3 where fire_code = ?1", nativeQuery = true) - void updateBeforeFireAndAfterFireImage(String fireCode, String beforeFireImage, String afterFireImage); - - /** - * 查询街道编码异常的火点 - */ -// @Query(value = "SELECT * FROM fire_point WHERE length(street_code) != 9", nativeQuery = true) -// update fire_point set street_name = (SELECT street_name from street WHERE fire_point.street_code = street.street_code) WHERE fire_point.street_name ISNULL - @Query(value = "SELECT * FROM fire_point WHERE street_code ISNULL", nativeQuery = true) - List selectAbnormalStreetCode(); - - @Transactional(rollbackOn = Exception.class) - @Modifying(clearAutomatically = true) - @Query(value = "UPDATE fire_point SET street_code = ?2 WHERE id = ?1", nativeQuery = true) - void updateStreetCodeById(Integer id, String streetCode); - @Query(value = "select a.really_name 姓名, a.county_name 所在市, a.telephone 手机号, a.vip_level vip, b.satellite_time 扫描时间, " + "round(cast(b.longitude as numeric) ,6) 经度, round(cast(b.latitude as numeric) ,6) 纬度, b.fire_point_address 详细地址 from sys_user a left join fire_point b on " + "case when left(a.county_code, 4) = '0000' then left(b.county_code, 4) = left(a.county_code, 4) " + "when left(a.county_code, 2) = '00' then left(b.county_code, 2) = left(a.county_code, 2) " + "else left(b.county_code, 2) = left(a.county_code, 2) end where a.vip_level > 0 and satellite_time > ?1", nativeQuery = true) List> downloadFirePointByVip(String yesterday); diff --git a/src/main/java/com/xkrs/dao/FireTaskDao.java b/src/main/java/com/xkrs/dao/FireTaskDao.java deleted file mode 100644 index 964f4ca..0000000 --- a/src/main/java/com/xkrs/dao/FireTaskDao.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.FireTask; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** - * @author xkrs - */ -public interface FireTaskDao extends JpaRepository, JpaSpecificationExecutor { - - /** - * 根据火点编码查询该条任务 - * @param fireCode - * @return - */ - FireTask findByTaskFireCode(String fireCode); -} diff --git a/src/main/java/com/xkrs/dao/FireTaskPhotoDao.java b/src/main/java/com/xkrs/dao/FireTaskPhotoDao.java deleted file mode 100644 index 141e4ed..0000000 --- a/src/main/java/com/xkrs/dao/FireTaskPhotoDao.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.FireTaskPhoto; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Query; - -import java.util.List; - -/** - * @author xkrs - */ -public interface FireTaskPhotoDao extends JpaRepository, JpaSpecificationExecutor { - - /** - * 根据火点编码查询图片 - * @param fireCode - * @return - */ - @Query(value = "select task_photo from fire_task_photo where photo_fire_code = :fireCode",nativeQuery = true) - List findPhotoPath(String fireCode); - - /** - * 通过火点编码查询图片的信息 - * @param fireCode - * @return - */ - List findAllByPhotoFireCode(String fireCode); -} diff --git a/src/main/java/com/xkrs/dao/ForestRangerDao.java b/src/main/java/com/xkrs/dao/ForestRangerDao.java deleted file mode 100644 index 174a473..0000000 --- a/src/main/java/com/xkrs/dao/ForestRangerDao.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.xkrs.dao; - -import com.xkrs.model.entity.ForestRanger; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.jpa.repository.Modifying; -import org.springframework.data.jpa.repository.Query; - -import java.util.List; - -/** - * @author xkrs - */ -public interface ForestRangerDao extends JpaRepository, JpaSpecificationExecutor { - - /** - * 根据市区县编码查询护林员的信息 - * @param rangerCountyCode - * @return - */ - ForestRanger findByRangerCountyCode(String rangerCountyCode); - - /** - * 根据手机号对护林员的位置进行修改 - * @param rangerLatitude - * @param rangerLongitude - * @param rangerPhone - */ - @Modifying(clearAutomatically=true) - @Query(value = "update forest_ranger set ranger_latitude = ?1,ranger_longitude = ?2 where ranger_phone = ?3",nativeQuery = true) - void updateLatAndLonByPhone(String rangerLatitude,String rangerLongitude,String rangerPhone); - - /** - * 根据手机号修改护林员的状态值 - * @param rangerPhone - * @param rangerType - */ - @Modifying(clearAutomatically=true) - @Query(value = "update forest_ranger set ranger_type = ?2 where ranger_phone = ?1",nativeQuery = true) - void updateRangerTypeByPhone(String rangerPhone,String rangerType); - - /** - * 根据手机号查询护林员的信息 - * @param rangerPhone - * @return - */ - ForestRanger findByRangerPhone(String rangerPhone); - - /** - * 根据区县编码查询该区县护林员的信息 - * @param rangerCountyCode - * @return - */ - List findAllByRangerCountyCode(String rangerCountyCode); - - /** - * 根据区县编码模糊查询护林员的信息 - * @param rangerCountyCode - * @return - */ - @Query(value = "select * from forest_ranger where ranger_county_code like CONCAT('%',:rangerCountyCode,'%')",nativeQuery = true) - List findAllsByRangerCountyCode(String rangerCountyCode); -} diff --git a/src/main/java/com/xkrs/service/FireAndRangerService.java b/src/main/java/com/xkrs/service/FireAndRangerService.java deleted file mode 100644 index 9edd104..0000000 --- a/src/main/java/com/xkrs/service/FireAndRangerService.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.xkrs.service; - -import java.io.UnsupportedEncodingException; - -/** - * @author xkrs - */ -public interface FireAndRangerService { - - /** - * 将火点分配给护林员 - * @param token - * @param rangerName - * @param fireCode - * @param handler - * @param verifier - * @return - */ - String addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException; - - /** - * 护林员查看自己的火点任务 - * @param token - * @return - */ - String selectFireInformation(String token); - - /** - * 根据火点编码查询处理的信息 - * @param fireCode - * @return - */ - String findFireAndRangerByFireCode(String fireCode, String token) throws Exception; -} diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 7b2eb75..c4afcac 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -2,12 +2,9 @@ package com.xkrs.service; import com.xkrs.model.entity.FirePointEntity; import com.xkrs.model.qo.FirePointQo; -import com.xkrs.model.vo.AppTaskBodyVo; -import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.util.List; /** @@ -39,36 +36,6 @@ public interface FirePointService { */ List selectTodayFirePoint(String countyCode); - /** - * 根据火点编码修改火点的状态(预警) - * - * @param fireCode - * @param fireType - * @param token - * @return - */ - String updateTypeByFireCode(String fireCode, String fireType, String token); - - /** - * 提交核查任务信息 - * - * @param files - * @param appTaskBodyVo - * @return - * @throws IOException - */ - String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException; - - /** - * 根据火点编码查询任务信息 - * - * @param fireCode - * @param - * @return - * @throws Exception - */ - String selectAppTask(String fireCode) throws Exception; - /** * 查询近一周天的火点信息 * @@ -104,13 +71,6 @@ public interface FirePointService { */ String selectFirePointNumWeek(); - /** - * 更新火点的街道编号数据 - * - * @return - */ - String updateFirePointStreetCode(); - /** * 根据火点编号更新审核状态 * 操作1:将火点编号对应的火点从山东火点表转存到火点表 diff --git a/src/main/java/com/xkrs/service/ForestRangerService.java b/src/main/java/com/xkrs/service/ForestRangerService.java deleted file mode 100644 index fef04be..0000000 --- a/src/main/java/com/xkrs/service/ForestRangerService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.xkrs.service; - -/** - * @author xkrs - */ -public interface ForestRangerService { - - /** - * 根据区县编码查询护林员的信息 - * @param rangerCountyCode - * @return - */ - String findByRangerCountyCode(String rangerCountyCode); - - /** - * 根据区县编码查询该区县所有护林员的信息 - * @param countyCode - * @param token - * @return - */ - String findAllByRangerCountyCode(String countyCode, String token); - - /** - * 根据手机号修改用户位置 - * @param rangerLatitude - * @param rangerLongitude - * @param rangerPhone - * @return - */ - String updateLatAndLonByPhone(String rangerLatitude,String rangerLongitude,String rangerPhone); -} diff --git a/src/main/java/com/xkrs/service/impl/FireAndRangerServiceImpl.java b/src/main/java/com/xkrs/service/impl/FireAndRangerServiceImpl.java deleted file mode 100644 index 787b85f..0000000 --- a/src/main/java/com/xkrs/service/impl/FireAndRangerServiceImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.xkrs.service.impl; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.common.tool.TokenUtil; -import com.xkrs.dao.*; -import com.xkrs.model.entity.*; -import com.xkrs.model.vo.AppPhotoVo; -import com.xkrs.model.vo.AppTaskBodyVo; -import com.xkrs.service.FireAndRangerService; -import com.xkrs.utils.DateTimeUtil; -import com.xkrs.utils.ObjectToBeanUtils; -import com.xkrs.utils.RestTemplateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cglib.beans.BeanCopier; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.http.HttpHeaders; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import javax.transaction.Transactional; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * @author xkrs - */ -@Service -public class FireAndRangerServiceImpl implements FireAndRangerService { - - public static Logger log = LoggerFactory.getLogger(FireAndRangerServiceImpl.class); - - @Resource - private FireAndRangerDao fireAndRangerDao; - - @Resource - private SysUserDao sysUserDao; - - @Resource - private FirePointDao firePointDao; - - @Resource - private ForestRangerDao forestRangerDao; - - @Resource - private RestTemplateUtil restTemplateUtil; - - @Resource - private FireTaskDao fireTaskDao; - - @Resource - private FireTaskPhotoDao fireTaskPhotoDao; - - /** - * 将火点分配给护林员 - * @param rangerName - * @param fireCode - * @return - */ - @Transactional(rollbackOn = Exception.class) - @Override - public String addFireAndRanger(String rangerName, String fireCode, String handler, String verifier, String token) throws UnsupportedEncodingException { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - String tokenUserName = TokenUtil.getTokenUserName(token); - FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode); - if(byFireCode != null){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"该火点已经分配,请勿重复操作",locale); - } - FirePointEntity byFireCode1 = firePointDao.findByFireCode(fireCode); - // 给app端推送的消息内容 - - Map map = new HashMap(3); - map.put("latitude",byFireCode1.getLatitude()); - map.put("longitude",byFireCode1.getLongitude()); - map.put("detailedAddress",byFireCode1.getFirePointAddress()); - String content = JSON.toJSONString(map); - String ss = URLEncoder.encode(content,"utf-8"); - - String url = "https://api.xmpush.xiaomi.com/v3/message/alias?title=收到消息&description=请"+verifier+"去核查该火点信息&payload="+ss+"&restricted_package_name=com.xkrs.fieldverification¬ify_id=2&extra.notify_effect=2&extra.intent_uri=fieldverify://xkrs.com&alias="+rangerName+"&extra.notify_foreground=0&extra.channel_id=mipush"; - - String time = DateTimeUtil.dateTimeToString(LocalDateTime.now()); - FireAndRanger fireAndRanger = new FireAndRanger(); - fireAndRanger.setRangerName(rangerName); - fireAndRanger.setFireCode(fireCode); - fireAndRanger.setHandlerTime(time); - fireAndRanger.setHandler(handler); - fireAndRanger.setVerifier(verifier); - fireAndRanger.setProgressType("1"); - - // 将火点分配给该护林员后,将护林员状态修改为1 表示正在执行火点任务 - forestRangerDao.updateRangerTypeByPhone(rangerName,"1"); - - JSONObject jsonObject = new JSONObject(); - HttpHeaders httpHeaders = new HttpHeaders(); - httpHeaders.add("Authorization","key=QW+6vVbWptJHscqD7zuM5w=="); - log.info("-----------已向app发送消息"); - restTemplateUtil.doPostMessageToApp(url, httpHeaders, jsonObject); - - FireAndRanger save = fireAndRangerDao.save(fireAndRanger); - if(save == null){ - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"操作失败",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功",locale); - } - - /** - * 护林员查看自己的火点任务 - * @param token - * @return - */ - @Override - public String selectFireInformation(String token) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - String tokenUserName = TokenUtil.getTokenUserName(token); - SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); - ForestRanger byRangerPhone = forestRangerDao.findByRangerPhone(sysUserEntity.getUserName()); - if(byRangerPhone.getRangerType().equals("1")){ - FireAndRanger byRangerName = fireAndRangerDao.findByRangerNameAndProgressType(sysUserEntity.getUserName(),"1"); - if(byRangerName == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有任何任务",locale); - } - FirePointEntity byFireCode = firePointDao.findByFireCode(byRangerName.getFireCode()); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byFireCode,locale); - }else { - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有任何任务",locale); - } - - } - - /** - * 根据火点编码查询核查的信息 - * @param fireCode - * @return - */ - @Override - public String findFireAndRangerByFireCode(String fireCode, String token) throws Exception { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - String tokenUserName = TokenUtil.getTokenUserName(token); - FireAndRanger byFireCode = fireAndRangerDao.findByFireCode(fireCode); - if(byFireCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没有该火点的核查信息",locale); - } - Map map = new HashMap(3); - map.put("fire",byFireCode); - FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode); - if(byTaskFireCode == null){ - map.put("task",null); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); - }else { - AppTaskBodyVo appTaskBodyVo = new AppTaskBodyVo(); - // 做映射,返回vo类对象 - BeanCopier beanCopier = BeanCopier.create(FireTask.class, AppTaskBodyVo.class, false); - beanCopier.copy(byTaskFireCode,appTaskBodyVo,null); - - List photoPath = fireTaskPhotoDao.findPhotoPath(fireCode); - List appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class); - appTaskBodyVo.setTaskFirePhoto(appPhotoVos); - map.put("task",appTaskBodyVo); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); - } - } -} diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 1a73e2a..443f37f 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -1,12 +1,9 @@ package com.xkrs.service.impl; import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.common.tool.TokenUtil; import com.xkrs.dao.*; import com.xkrs.model.entity.*; import com.xkrs.model.qo.FirePointQo; -import com.xkrs.model.vo.AppPhotoVo; -import com.xkrs.model.vo.AppTaskBodyVo; import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.service.FirePointService; import com.xkrs.service.GlobalConfigService; @@ -17,10 +14,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheEvict; -import org.springframework.cglib.beans.BeanCopier; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -62,18 +57,6 @@ public class FirePointServiceImpl implements FirePointService { @Resource private SysUserDao sysUserDao; - @Resource - private FireAndRangerDao fireAndRangerDao; - - @Resource - private ForestRangerDao forestRangerDao; - - @Resource - private FireTaskDao fireTaskDao; - - @Resource - private FireTaskPhotoDao fireTaskPhotoDao; - @Resource private StreetDao streetDao; @@ -547,119 +530,6 @@ public class FirePointServiceImpl implements FirePointService { return firePointEntities; } - /** - * 根据火点编码修改火点的状态(预警) - * - * @param fireCode - * @param fireType - * @param token - * @return - */ - @Transactional(rollbackOn = Exception.class) - @Override - public String updateTypeByFireCode(String fireCode, String fireType, String token) { - String tokenUserName = TokenUtil.getTokenUserName(token); - 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); - } - if (fireType.equals(byFireCode.getFireType())) { - 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)) { - FirePointEntity byFireCode3 = firePointDao.findByFireCode(fireCode); - // 核查 - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode3, locale); - } else { - String rangerType = "0"; - FireAndRanger byFireCode1 = fireAndRangerDao.findByFireCode(fireCode); - if (byFireCode1 == null) { - FirePointEntity byFireCode4 = firePointDao.findByFireCode(fireCode); - String time = dateTimeToString(LocalDateTime.now()); - FireAndRanger fireAndRanger = new FireAndRanger(); - fireAndRanger.setFireCode(fireCode); - // 由于测试阶段先用用户账号代替,后期换成getReallyName(用户真实姓名) - fireAndRanger.setHandler(sysUserEntity.getReallyName()); - fireAndRanger.setEndTime(time); - fireAndRangerDao.save(fireAndRanger); - // 结案 - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFireCode4, locale); - } - // 火点结案,将护林员的状态修改为0 表示该护林员没有在执行任务,处于空闲状态 - forestRangerDao.updateRangerTypeByPhone(byFireCode1.getRangerName(), rangerType); - String time = dateTimeToString(LocalDateTime.now()); - fireAndRangerDao.updateEndTimeByFireCode(fireCode, time); - fireAndRangerDao.updateProgressTypeByFireCode(fireCode, "0"); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "结案", locale); - } - } - - /** - * 提交核查任务 - * - * @param files - * @param appTaskBodyVo - * @return - */ - @Transactional(rollbackOn = Exception.class) - @Override - public String insertAppTask(MultipartFile[] files, AppTaskBodyVo appTaskBodyVo) throws IOException { - FirePointEntity byFireCode = firePointDao.findByFireCode(appTaskBodyVo.getFireCode()); - if (byFireCode == null) { - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, "火点编码错误,请重新输入", locale); - } - FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(appTaskBodyVo.getFireCode()); - if (byTaskFireCode != null) { - return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "该火点的任务已经提交,请勿重复提交", locale); - } - String s = dateTimeToString(LocalDateTime.now()); - FireTask fireTask = new FireTask(); - fireTask.setTaskFireCode(appTaskBodyVo.getFireCode()); - fireTask.setTaskInformation(appTaskBodyVo.getTaskInformation()); - fireTask.setTaskTime(s); - FireTask save = fireTaskDao.save(fireTask); - 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); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "任务提交成功", locale); - } - - /** - * 根据火点编码查询任务信息 - * - * @param fireCode - * @return - * @throws Exception - */ - @Override - public String selectAppTask(String fireCode) throws Exception { - FireTask byTaskFireCode = fireTaskDao.findByTaskFireCode(fireCode); - 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); - - List photoPath = fireTaskPhotoDao.findPhotoPath(fireCode); - List appPhotoVos = ObjectToBeanUtils.objectToBean(photoPath, AppPhotoVo.class); - appTaskBodyVo.setTaskFirePhoto(appPhotoVos); - - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, appTaskBodyVo, locale); - } - /** * 查询近一个月的火点数量 * @@ -735,55 +605,4 @@ public class FirePointServiceImpl implements FirePointService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale); } - /** - * 更新火点的街道编号数据 - * - * @return - */ - @Override - public String updateFirePointStreetCode() { - System.out.println("开始格式化街道编号"); - List firePointEntityList = firePointDao.selectAbnormalStreetCode(); - long startTimeMillis = System.currentTimeMillis(); - int listSize = firePointEntityList.size(); - for (int i = 0; i < listSize; i++) { - try { - FirePointEntity firePointEntity = firePointEntityList.get(i); - List locationList = new ArrayList<>(); - locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude()); - GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList); - String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode(); - if (townCode.length() > 9) { - townCode = townCode.substring(0, 9); - } - firePointDao.updateStreetCodeById(firePointEntity.getId(), townCode); - if (i % 10 == 0) { - long spendTimeMillis = System.currentTimeMillis() - startTimeMillis; - double remainTimeMillis = (listSize - i) * spendTimeMillis * 1D / i; - System.out.println("已完成(" + i + "/" + listSize + "),用时" + formatDuring(spendTimeMillis) + ",剩余" + formatDuring((long) remainTimeMillis)); - } - } catch (Exception e) { - e.printStackTrace(); - System.out.println("街道编号格式化出现错误:" + e.getMessage()); - } - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "街道编号格式化完毕", locale); - } - - public static String formatDuring(long mss) { - long days = mss / (1000 * 60 * 60 * 24); - long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); - long minutes = (mss % (1000 * 60 * 60)) / (1000 * 60); - long seconds = (mss % (1000 * 60)) / 1000; - if (days <= 0 && hours <= 0 && minutes <= 0) { - return seconds + " 秒 "; - } - if (days <= 0 && hours <= 0) { - return minutes + " 分钟 " + seconds + " 秒 "; - } - if (days <= 0) { - return hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "; - } - return days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "; - } } diff --git a/src/main/java/com/xkrs/service/impl/ForestRangerServiceImpl.java b/src/main/java/com/xkrs/service/impl/ForestRangerServiceImpl.java deleted file mode 100644 index b71b70d..0000000 --- a/src/main/java/com/xkrs/service/impl/ForestRangerServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.xkrs.service.impl; - -import com.xkrs.common.encapsulation.PromptMessageEnum; -import com.xkrs.common.tool.TokenUtil; -import com.xkrs.dao.ForestRangerDao; -import com.xkrs.model.entity.ForestRanger; -import com.xkrs.service.ForestRangerService; -import org.springframework.context.i18n.LocaleContextHolder; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import javax.transaction.Transactional; -import java.util.List; -import java.util.Locale; - -import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; - -/** - * @author xkrs - */ -@Service -public class ForestRangerServiceImpl implements ForestRangerService { - - @Resource - private ForestRangerDao forestRangerDao; - - /** - * 根据曲线编码查询护林员的信息 - * @param rangerCountyCode - * @return - */ - @Override - public String findByRangerCountyCode(String rangerCountyCode) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - ForestRanger byRangerCountyCode = forestRangerDao.findByRangerCountyCode(rangerCountyCode); - if(byRangerCountyCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该区县暂时还没有相关护林员的信息",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byRangerCountyCode,locale); - } - - /** - * 根据区县编码查询该区县所有护林员的信息 - * @param countyCode - * @return - */ - @Override - public String findAllByRangerCountyCode(String countyCode, String token) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - String tokenUserName = TokenUtil.getTokenUserName(token); - if("0000".equals(countyCode.substring(2))){ - List allsByRangerCountyCode = forestRangerDao.findAllsByRangerCountyCode(countyCode.substring(0,2)); - if(allsByRangerCountyCode == null || allsByRangerCountyCode.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该省护林员的信息",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,allsByRangerCountyCode,locale); - }else { - List allByRangerCountyCode = forestRangerDao.findAllsByRangerCountyCode(countyCode.substring(0,4)); - if(allByRangerCountyCode == null || allByRangerCountyCode.size() == 0){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该市护林员的信息",locale); - } - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,allByRangerCountyCode,locale); - } - } - - /** - * 根据手机号修改护林员的位置信息 - * @param rangerLatitude - * @param rangerLongitude - * @param rangerPhone - * @return - */ - @Transactional(rollbackOn = Exception.class) - @Override - public String updateLatAndLonByPhone(String rangerLatitude, String rangerLongitude, String rangerPhone) { - // 获取区域信息 - Locale locale = LocaleContextHolder.getLocale(); - forestRangerDao.updateLatAndLonByPhone(rangerLatitude,rangerLongitude,rangerPhone); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功",locale); - } -}