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); + } } /**