From c6adc85b61922f74e5fc513fda66ca9ed225537b Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Mon, 11 Oct 2021 16:28:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B0=B4=E4=BD=93=E7=B1=BB=E5=9E=8B=E7=81=AB=E7=82=B9=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/common/config/WebSecurityConfig.java | 1 + .../xkrs/controller/FirePointController.java | 15 ++++++++ src/main/java/com/xkrs/dao/FirePointDao.java | 14 +++++++ .../service/impl/FirePointServiceImpl.java | 37 ++++++++++--------- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 8f6ee06..ef534a9 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -59,6 +59,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.POST,"/uploadFile").permitAll() .antMatchers(HttpMethod.POST,"/insertFireTest").permitAll() .antMatchers(HttpMethod.POST,"/importCityExcel").permitAll() + .antMatchers(HttpMethod.POST,"/deleteShuiTi").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 41d88bb..5e52482 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.transaction.Transactional; import java.io.IOException; import java.util.List; import java.util.Locale; @@ -324,4 +325,18 @@ public class FirePointController { } return outputEncapsulationObject(PromptMessageEnum.SUCCESS,firePointEntities,locale); } + + /** + * 删除水体类型的火点信息 + * @return + */ + @Transactional(rollbackOn = Exception.class) + @PostMapping("/deleteShuiTi") + public String deleteShuiTi(){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + List integers = firePointDao.selectId(); + firePointDao.deleteByIdIn(integers); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"删除成功",locale); + } } diff --git a/src/main/java/com/xkrs/dao/FirePointDao.java b/src/main/java/com/xkrs/dao/FirePointDao.java index e9a537a..e733b8f 100644 --- a/src/main/java/com/xkrs/dao/FirePointDao.java +++ b/src/main/java/com/xkrs/dao/FirePointDao.java @@ -71,4 +71,18 @@ public interface FirePointDao extends JpaRepository, JpaSp "on fp.county_code like concat('%',ci.city_code,'%') AND fp.add_time BETWEEN ?1 AND ?2 " + "group by ci.city_name",nativeQuery = true) List> selectNumByArea(String startTime,String endTime); + + /** + * 查询水体类型的id + * @return + */ + @Query(value = "select id from fire_point where land_type = '水体'",nativeQuery = true) + List selectId(); + + /** + * 批量删除水体 + * @param id + */ + @Modifying(clearAutomatically=true) + void deleteByIdIn(List id); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 585bd86..5bccfe4 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -78,21 +78,24 @@ public class FirePointServiceImpl implements FirePointService { @Override public FirePointEntity insertFirePoint(FirePointQo firePointQo) { FirePointEntity firePointEntity = new FirePointEntity(); - 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.setSatelliteType(firePointQo.getSatelliteType()); - firePointEntity.setLandType(firePointQo.getLandtype()); - firePointEntity.setConfidence(firePointQo.getConfidence()); - firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now())); - firePointEntity.setFireType("0"); - firePointEntity.setFireImage(firePointQo.getFireImage()); - firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); - log.info("-------发现新火点"); + if(firePointQo.getLandtype().equals("水体")){ + return null; + }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.setSatelliteType(firePointQo.getSatelliteType()); + firePointEntity.setLandType(firePointQo.getLandtype()); + firePointEntity.setConfidence(firePointQo.getConfidence()); + firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now())); + firePointEntity.setFireType("0"); + firePointEntity.setFireImage(firePointQo.getFireImage()); + firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); + log.info("-------发现新火点"); /*log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); Map map = new HashMap(3); map.put("countyCode",firePointQo.getCountyCode()); @@ -109,8 +112,8 @@ public class FirePointServiceImpl implements FirePointService { String websocket = JSON.toJSONString(map1); // 将监测到的火点信息返给前端 WebSocketServer.broadInfo(websocket);*/ - return firePointDao.save(firePointEntity); - + return firePointDao.save(firePointEntity); + } } /**