|
@@ -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;
|
|
|
}
|
|
|
|
|
|
}
|