Sfoglia il codice sorgente

综合警情-周边资源相关接口开发

jichaobo 2 anni fa
parent
commit
67d4156cd7

+ 8 - 9
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/DemPoliceInfoController.java

@@ -122,8 +122,9 @@ public class DemPoliceInfoController {
      * @return
      */
     @GetMapping("/warningInstanceScatterer")
-    public ApiResult<List<Map<String, Object>>> warningInstanceScatterer(@RequestParam(value = "streetTown", required = false) String streetTown) {
-        return ApiResult.success(demPoliceInfoService.warningInstanceScatterer(streetTown));
+    public ApiResult<List<Map<String, Object>>> warningInstanceScatterer(@RequestParam(value = "streetTown", required = false) String streetTown,
+                                                                         @RequestParam(value = "id", required = false, defaultValue = "0") Integer id) {
+        return ApiResult.success(demPoliceInfoService.warningInstanceScatterer(streetTown, id));
     }
 
     /**
@@ -131,16 +132,14 @@ public class DemPoliceInfoController {
      *
      * @param longitude 实时警情经度
      * @param latitude  实时警情纬度
-     * @param pageNum   当前页
-     * @param pageSize  每页条数
+     * @param distance  距离
      * @return
      */
     @GetMapping("/waterSourceList")
-    public ApiResult<CommonPage<Map<String, Object>>> waterSourceList(@RequestParam(value = "longitude") double longitude,
-                                                                      @RequestParam(value = "latitude") double latitude,
-                                                                      @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
-                                                                      @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
-        return ApiResult.success(demWaterSourceService.waterSourceList(longitude, latitude, pageNum, pageSize));
+    public ApiResult<List<Map<String, Object>>> waterSourceList(@RequestParam(value = "longitude") double longitude,
+                                                                @RequestParam(value = "latitude") double latitude,
+                                                                @RequestParam(value = "distance", required = false, defaultValue = "150") Integer distance) {
+        return ApiResult.success(demWaterSourceService.surroundingResources(longitude, latitude, distance));
     }
 
     /**

+ 15 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/DemWaterSourceController.java

@@ -10,6 +10,7 @@ import com.usky.fire.service.DemWaterSourceService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -67,5 +68,19 @@ public class DemWaterSourceController {
         demWaterSourceService.delWaterSource(id);
         return ApiResult.success();
     }
+
+
+    /**
+     * 消防水源情况-警情撒点
+     *
+     * @param scattererType 撒点类型
+     * @param streetTown    街镇
+     * @return
+     */
+    @GetMapping("waterSourceScatterer")
+    public ApiResult<List<Object>> waterSourceScatterer(@RequestParam(value = "scattererType") String scattererType,
+                                                        @RequestParam(value = "streetTown", required = false) String streetTown) {
+        return ApiResult.success(demWaterSourceService.waterSourceScatterer(scattererType, streetTown));
+    }
 }
 

+ 13 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/DemWaterSourceMaintain.java

@@ -3,11 +3,12 @@ package com.usky.fire.domain;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.time.LocalDateTime;
-import java.io.Serializable;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
 /**
  * <p>
  * 天然水源信息表
@@ -69,5 +70,15 @@ public class DemWaterSourceMaintain implements Serializable {
      */
     private String deleteFlag;
 
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
 
 }

+ 2 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/DemMicroStationMapper.java

@@ -2,6 +2,7 @@ package com.usky.fire.mapper;
 
 import com.usky.fire.domain.DemMicroStation;
 import com.usky.common.mybatis.core.CrudMapper;
+import org.springframework.stereotype.Repository;
 
 /**
  * <p>
@@ -11,6 +12,7 @@ import com.usky.common.mybatis.core.CrudMapper;
  * @author JCB
  * @since 2022-10-24
  */
+@Repository
 public interface DemMicroStationMapper extends CrudMapper<DemMicroStation> {
 
 }

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/DemPoliceInfoService.java

@@ -26,7 +26,7 @@ public interface DemPoliceInfoService extends CrudService<DemPoliceInfo> {
 
     Map<String, List<AlertStatisticsVO>> getAlertStatisticsByHouse(String startTime, String endTime, String streetTown);
 
-    List<Map<String, Object>> warningInstanceScatterer(String streetTown);
+    List<Map<String, Object>> warningInstanceScatterer(String streetTown, Integer id);
 
     List<String> getFireType();
 }

+ 4 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/DemWaterSourceMaintainService.java

@@ -4,6 +4,8 @@ import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mybatis.core.CrudService;
 import com.usky.fire.domain.DemWaterSourceMaintain;
 
+import java.util.List;
+
 /**
  * <p>
  * 天然水源信息表 服务类
@@ -45,4 +47,6 @@ public interface DemWaterSourceMaintainService extends CrudService<DemWaterSourc
      * @param id 主键ID
      */
     void delWaterSourceMaintain(Integer id);
+
+    List<Object> waterSourceMaintainScatterer(String streetTown);
 }

+ 8 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/DemWaterSourceService.java

@@ -2,6 +2,7 @@ package com.usky.fire.service;
 
 import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mybatis.core.CrudService;
+import com.usky.fire.domain.DemMicroStation;
 import com.usky.fire.domain.DemWaterSource;
 
 import java.util.List;
@@ -44,5 +45,11 @@ public interface DemWaterSourceService extends CrudService<DemWaterSource> {
 
     List<Object> waterSourceList(String streetTown);
 
-    CommonPage<Map<String, Object>> waterSourceList(double longitude, double latitude, Integer pageNum, Integer pageSize);
+    List<DemWaterSource> waterSourceList();
+
+    List<Map<String, Object>> surroundingResources(double longitude, double latitude, Integer distance);
+
+    List<Object> waterSourceScatterer(String scattererType, String streetTown);
+
+    List<DemMicroStation> microStationScatterer();
 }

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/DemMicroStationServiceImpl.java

@@ -113,7 +113,7 @@ public class DemMicroStationServiceImpl extends AbstractCrudService<DemMicroStat
 
     @Override
     public List<Object> microStationScatterer(String streetTown) {
-        IPage<DemMicroStation> page = new Page<>();
+        IPage<DemMicroStation> page = new Page<>(1, 500);
         LambdaQueryWrapper<DemMicroStation> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(DemMicroStation::getId, DemMicroStation::getStationName, DemMicroStation::getLongitude,
                 DemMicroStation::getDimension)

+ 4 - 3
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/DemPoliceInfoServiceImpl.java

@@ -146,13 +146,14 @@ public class DemPoliceInfoServiceImpl extends AbstractCrudService<DemPoliceInfoM
     }
 
     @Override
-    public List<Map<String, Object>> warningInstanceScatterer(String streetTown) {
+    public List<Map<String, Object>> warningInstanceScatterer(String streetTown, Integer id) {
         IPage<DemPoliceInfo> page = new Page<>(1, 500);
         LambdaQueryWrapper<DemPoliceInfo> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(DemPoliceInfo::getAddress, DemPoliceInfo::getGisX, DemPoliceInfo::getGisY,
-                DemPoliceInfo::getId,DemPoliceInfo::getCaseType,DemPoliceInfo::getSquadron,
-                DemPoliceInfo::getFilingTime,DemPoliceInfo::getSupplement,DemPoliceInfo::getPoliceId)
+                DemPoliceInfo::getId, DemPoliceInfo::getCaseType, DemPoliceInfo::getSquadron,
+                DemPoliceInfo::getFilingTime, DemPoliceInfo::getSupplement, DemPoliceInfo::getPoliceId)
                 .eq(StringUtils.isNotBlank(streetTown), DemPoliceInfo::getStreetTown, streetTown)
+                .eq(null != id && id != 0, DemPoliceInfo::getId, id)
                 .isNotNull(DemPoliceInfo::getQuenchTime)
                 .orderByDesc(DemPoliceInfo::getId);
         page = this.page(page, queryWrapper);

+ 48 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/DemWaterSourceMaintainServiceImpl.java

@@ -2,6 +2,7 @@ package com.usky.fire.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,10 +12,15 @@ import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.DemWaterSourceMaintain;
 import com.usky.fire.mapper.DemWaterSourceMaintainMapper;
 import com.usky.fire.service.DemWaterSourceMaintainService;
+import com.usky.fire.service.util.OnlineMethod;
+import com.usky.fire.service.vo.LocateInfo;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -62,4 +68,46 @@ public class DemWaterSourceMaintainServiceImpl extends AbstractCrudService<DemWa
         demWaterSourceMaintain.setDeleteFlag("1");
         this.updateById(demWaterSourceMaintain);
     }
+
+    @Override
+    public List<Object> waterSourceMaintainScatterer(String streetTown) {
+        List<Object> list2 = new ArrayList<>();
+        IPage<DemWaterSourceMaintain> page = new Page<>(1, 500);
+        LambdaQueryWrapper<DemWaterSourceMaintain> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(DemWaterSourceMaintain::getDeleteFlag, "0")
+                .isNotNull(DemWaterSourceMaintain::getDescribe)
+                .orderByDesc(DemWaterSourceMaintain::getId);
+        List<DemWaterSourceMaintain> list = this.list(queryWrapper);
+        if (CollectionUtils.isNotEmpty(list)) {
+            String longitude = null;
+            String latitude = null;
+            for (int i = 0; i < list.size(); i++) {
+                if (StringUtils.isBlank(list.get(i).getLongitude()) && StringUtils.isBlank(list.get(i).getLatitude())) {
+                    List<LocateInfo> lonLat = OnlineMethod.getLonLat(list.get(i).getDescribe());
+                    if (CollectionUtils.isNotEmpty(lonLat)) {
+                        longitude = "" + lonLat.get(0).getLongitude();
+                        latitude = "" + lonLat.get(0).getLatitude();
+                    }
+                    DemWaterSourceMaintain demWaterSourceMaintain = new DemWaterSourceMaintain();
+                    demWaterSourceMaintain.setId(list.get(i).getId());
+                    demWaterSourceMaintain.setLatitude(latitude);
+                    demWaterSourceMaintain.setLongitude(longitude);
+                    demWaterSourceMaintain.setUpdatePerson("程序修改");
+                    demWaterSourceMaintain.setCreateTime(LocalDateTime.now());
+                    this.updateById(demWaterSourceMaintain);
+                    list.get(i).setLatitude(latitude);
+                    list.get(i).setLongitude(longitude);
+                }
+                Map<String, Object> map = new HashMap<>();
+                map.put("id", list.get(i).getId());
+                map.put("detachment", list.get(i).getDetachment());
+                map.put("squadron", list.get(i).getSquadron());
+                map.put("describe", list.get(i).getDescribe());
+                map.put("longitude", list.get(i).getLongitude());
+                map.put("latitude", list.get(i).getLatitude());
+                list2.add(map);
+            }
+        }
+        return list2;
+    }
 }

+ 100 - 18
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/DemWaterSourceServiceImpl.java

@@ -7,11 +7,16 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.common.core.exception.BusinessException;
 import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.fire.domain.DemMicroStation;
 import com.usky.fire.domain.DemWaterSource;
+import com.usky.fire.mapper.DemMicroStationMapper;
 import com.usky.fire.mapper.DemWaterSourceMapper;
+import com.usky.fire.service.DemWaterSourceMaintainService;
 import com.usky.fire.service.DemWaterSourceService;
 import com.usky.fire.service.util.OnlineMethod;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -30,6 +35,12 @@ import java.util.Map;
 @Service
 public class DemWaterSourceServiceImpl extends AbstractCrudService<DemWaterSourceMapper, DemWaterSource> implements DemWaterSourceService {
 
+    @Autowired
+    private DemWaterSourceMaintainService demWaterSourceMaintainService;
+
+    @Autowired
+    private DemMicroStationMapper demMicroStationMapper;
+
     @Override
     public CommonPage<Map<String, Object>> waterSourceList(String waterName, Integer id, Integer pageNum, Integer pageSize) {
         List<Map<String, Object>> list = new ArrayList<>();
@@ -107,36 +118,107 @@ public class DemWaterSourceServiceImpl extends AbstractCrudService<DemWaterSourc
     }
 
     @Override
-    public CommonPage<Map<String, Object>> waterSourceList(double longitude, double latitude, Integer pageNum, Integer pageSize) {
-        List<Map<String, Object>> list = new ArrayList<>();
-        IPage<DemWaterSource> page = new Page<>(pageNum, pageSize);
+    public List<DemWaterSource> waterSourceList() {
         LambdaQueryWrapper<DemWaterSource> queryWrapper = Wrappers.lambdaQuery();
         queryWrapper.select(DemWaterSource::getId, DemWaterSource::getWaterType, DemWaterSource::getWaterName,
                 DemWaterSource::getWaterAddress, DemWaterSource::getWaterCompany, DemWaterSource::getContactMode,
                 DemWaterSource::getGisX, DemWaterSource::getGisY)
                 .eq(DemWaterSource::getDeleteFlag, 0)
                 .orderByDesc(DemWaterSource::getId);
-        page = this.page(page, queryWrapper);
-        if (CollectionUtils.isNotEmpty(page.getRecords())) {
-            for (int i = 0; i < page.getRecords().size(); i++) {
+        List<DemWaterSource> list = this.list(queryWrapper);
+        return list;
+    }
+
+    @Override
+    public List<Map<String, Object>> surroundingResources(double longitude, double latitude, Integer distance) {
+        List<Map<String, Object>> list = new ArrayList<>();
+        List<DemWaterSource> list1 = this.waterSourceList();
+        List<DemMicroStation> list2 = this.microStationScatterer();
+        if (CollectionUtils.isNotEmpty(list1)) {
+            for (int i = 0; i < list1.size(); i++) {
                 Map<String, Object> map = new HashMap<>();
-                map.put("id", page.getRecords().get(i).getId());
-                map.put("waterType", page.getRecords().get(i).getWaterType());
-                map.put("waterName", page.getRecords().get(i).getWaterName());
-                map.put("waterAddress", page.getRecords().get(i).getWaterAddress());
-                map.put("waterCompany", page.getRecords().get(i).getWaterCompany());
-                map.put("contactMode", page.getRecords().get(i).getContactMode());
-                if (StringUtils.isNotBlank(page.getRecords().get(i).getGisX()) && StringUtils.isNotBlank(page.getRecords().get(i).getGisY())) {
-                    double gisX = Double.valueOf(page.getRecords().get(i).getGisX());
-                    double gisY = Double.valueOf(page.getRecords().get(i).getGisY());
-                    map.put("distance", OnlineMethod.GetDistance(longitude, latitude, gisX, gisY));
+                int distance1 = 0;
+                if (StringUtils.isNotBlank(list1.get(i).getGisX()) && StringUtils.isNotBlank(list1.get(i).getGisY())) {
+                    double gisX = Double.valueOf(list1.get(i).getGisX());
+                    double gisY = Double.valueOf(list1.get(i).getGisY());
+                    double v = OnlineMethod.GetDistance(longitude, latitude, gisX, gisY);
+                    distance1 = new Double(v).intValue();
+                    map.put("distance", v);
                 } else {
                     map.put("distance", null);
                 }
-                list.add(map);
+                map.put("id", list1.get(i).getId());
+                map.put("waterType", list1.get(i).getWaterType());
+                map.put("waterName", list1.get(i).getWaterName());
+                map.put("waterAddress", list1.get(i).getWaterAddress());
+                map.put("waterCompany", list1.get(i).getWaterCompany());
+                map.put("contactMode", list1.get(i).getContactMode());
+                map.put("longitude", list1.get(i).getGisX());
+                map.put("latitude", list1.get(i).getGisY());
+                map.put("chargeName", null);
+                if (distance1 <= distance && distance1 != 0) {
+                    list.add(map);
+                }
             }
         }
-        return new CommonPage<>(list, page.getTotal(), pageSize, pageNum);
+
+        if (CollectionUtils.isNotEmpty(list2)) {
+            for (int i = 0; i < list2.size(); i++) {
+                Map<String, Object> map = new HashMap<>();
+                int distance1 = 0;
+                if (StringUtils.isNotBlank(list2.get(i).getLongitude().toString()) && StringUtils.isNotBlank(list2.get(i).getDimension().toString())) {
+                    double gisX = Double.valueOf(list2.get(i).getLongitude().toString());
+                    double gisY = Double.valueOf(list2.get(i).getDimension().toString());
+                    double v = OnlineMethod.GetDistance(longitude, latitude, gisX, gisY);
+                    distance1 = new Double(v).intValue();
+                    map.put("distance", v);
+                } else {
+                    map.put("distance", null);
+                }
+                map.put("id", list2.get(i).getId());
+                map.put("waterType", "消防站");
+                map.put("waterName", list2.get(i).getStationName());
+                map.put("waterAddress", list2.get(i).getAddress());
+                map.put("waterCompany", null);
+                map.put("chargeName", list2.get(i).getChargeName());
+                map.put("contactMode", list2.get(i).getChargePhone());
+                map.put("longitude", list2.get(i).getLongitude());
+                map.put("latitude", list2.get(i).getDimension());
+                if (distance1 <= distance && distance1 != 0) {
+                    list.add(map);
+                }
+            }
+        }
+        return list;
+    }
+
+
+    @Override
+    public List<Object> waterSourceScatterer(String scattererType, String streetTown) {
+        List<Object> list = new ArrayList<>();
+        switch (scattererType) {
+            case "消火栓":
+                list = this.waterSourceList(streetTown);
+                break;
+            case "天然水源":
+                list = demWaterSourceMaintainService.waterSourceMaintainScatterer(streetTown);
+                break;
+            default:
+                throw new BusinessException("该类型点位未定义");
+        }
+        return list;
+    }
+
+    @Override
+    public List<DemMicroStation> microStationScatterer() {
+        LambdaQueryWrapper<DemMicroStation> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.select(DemMicroStation::getId, DemMicroStation::getStationName, DemMicroStation::getLongitude,
+                DemMicroStation::getDimension, DemMicroStation::getAddress, DemMicroStation::getChargeName,
+                DemMicroStation::getChargePhone)
+                .eq(DemMicroStation::getDeleteFlag, "0")
+                .orderByDesc(DemMicroStation::getId);
+        List<DemMicroStation> list = demMicroStationMapper.selectList(queryWrapper);
+        return list;
     }
 
 }

+ 2 - 0
service-fire/service-fire-biz/src/main/resources/mapper/fire/DemWaterSourceMaintainMapper.xml

@@ -13,6 +13,8 @@
         <result column="update_time" property="updateTime" />
         <result column="update_person" property="updatePerson" />
         <result column="delete_flag" property="deleteFlag" />
+        <result column="longitude" property="longitude" />
+        <result column="latitude" property="latitude" />
     </resultMap>
 
 </mapper>