[add] 新增根据GeoJson创建箱变、逆变器接口和对应方法 [update] 修改根据进度类别创建光伏板信息
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
package org.dromara.facility.constant;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/23 11:29
|
||||
*/
|
||||
public interface FacPhotovoltaicPanelPartsConstant {
|
||||
|
||||
String POINT = "钻孔";
|
||||
|
||||
String COLUMN = "桩基";
|
||||
|
||||
String SUPPORT = "支架";
|
||||
|
||||
}
|
@ -15,6 +15,7 @@ import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerQueryReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerUpdateReq;
|
||||
@ -82,6 +83,17 @@ public class FacBoxTransformerController extends BaseController {
|
||||
return R.ok(facBoxTransformerService.insertByBo(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过GeoJson新增设施-箱变
|
||||
*/
|
||||
@SaCheckPermission("facility:boxTransformer:add")
|
||||
@Log(title = "设施-箱变", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/geoJson")
|
||||
public R<Void> insertByGeoJson(@RequestBody FacBoxTransformerCreateByGeoJsonReq req) {
|
||||
return toAjax(facBoxTransformerService.insertByGeoJson(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设施-箱变
|
||||
*/
|
||||
|
@ -15,6 +15,7 @@ import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterQueryReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterUpdateReq;
|
||||
@ -82,6 +83,17 @@ public class FacInverterController extends BaseController {
|
||||
return R.ok(facInverterService.insertByBo(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过GeoJson新增设施-逆变器
|
||||
*/
|
||||
@SaCheckPermission("facility:inverter:add")
|
||||
@Log(title = "设施-逆变器", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/geoJson")
|
||||
public R<Void> insertByGeoJson(@RequestBody FacInverterCreateByGeoJsonReq req) {
|
||||
return toAjax(facInverterService.insertByGeoJson(req));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设施-逆变器
|
||||
*/
|
||||
|
@ -71,6 +71,11 @@ public class FacBoxTransformer extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -71,6 +71,11 @@ public class FacInverter extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -69,6 +69,11 @@ public class FacPhotovoltaicPanel extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -69,6 +69,11 @@ public class FacPhotovoltaicPanelColumn extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -69,6 +69,11 @@ public class FacPhotovoltaicPanelPoint extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -69,6 +69,11 @@ public class FacPhotovoltaicPanelSupport extends BaseEntity {
|
||||
*/
|
||||
private Long progressCategoryId;
|
||||
|
||||
/**
|
||||
* 进度类别名称
|
||||
*/
|
||||
private String progressCategoryName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
|
@ -0,0 +1,40 @@
|
||||
package org.dromara.facility.domain.dto.boxtransformer;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeoJsonByPoint;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/23 18:12
|
||||
*/
|
||||
@Data
|
||||
public class FacBoxTransformerCreateByGeoJsonReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = -5887138349157048252L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 地理位置
|
||||
*/
|
||||
private FacGeoJsonByPoint locationGeoJson;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private FacGeoJsonByPoint nameGeoJson;
|
||||
|
||||
/**
|
||||
* 进度类别id列表
|
||||
*/
|
||||
private List<Long> progressCategoryIdList;
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package org.dromara.facility.domain.dto.inverter;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeoJsonByPoint;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/23 18:15
|
||||
*/
|
||||
@Data
|
||||
public class FacInverterCreateByGeoJsonReq implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 924709230113144983L;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 地理位置
|
||||
*/
|
||||
private FacGeoJsonByPoint locationGeoJson;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private FacGeoJsonByPoint nameGeoJson;
|
||||
|
||||
/**
|
||||
* 进度类别id列表
|
||||
*/
|
||||
private List<Long> progressCategoryIdList;
|
||||
|
||||
}
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.facility.domain.FacBoxTransformer;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerQueryReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerUpdateReq;
|
||||
@ -55,6 +56,14 @@ public interface IFacBoxTransformerService extends IService<FacBoxTransformer> {
|
||||
*/
|
||||
Long insertByBo(FacBoxTransformerCreateReq req);
|
||||
|
||||
/**
|
||||
* 新增设施-箱变
|
||||
*
|
||||
* @param geoJson GeoJson格式
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByGeoJson(FacBoxTransformerCreateByGeoJsonReq geoJson);
|
||||
|
||||
/**
|
||||
* 修改设施-箱变
|
||||
*
|
||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.facility.domain.FacInverter;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterQueryReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterUpdateReq;
|
||||
@ -55,6 +56,14 @@ public interface IFacInverterService extends IService<FacInverter> {
|
||||
*/
|
||||
Long insertByBo(FacInverterCreateReq req);
|
||||
|
||||
/**
|
||||
* 新增设施-逆变器
|
||||
*
|
||||
* @param geoJson GeoJson格式
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
Boolean insertByGeoJson(FacInverterCreateByGeoJsonReq geoJson);
|
||||
|
||||
/**
|
||||
* 修改设施-逆变器
|
||||
*
|
||||
|
@ -7,8 +7,8 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.domain.dto.matrix.*;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixVo;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixDetailGisVo;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -111,4 +111,22 @@ public interface IFacMatrixService extends IService<FacMatrix> {
|
||||
*/
|
||||
Page<FacMatrixVo> getVoPage(Page<FacMatrix> matrixPage);
|
||||
|
||||
/**
|
||||
* 根据坐标获取符合的方阵
|
||||
*
|
||||
* @param matrixList 方阵集合
|
||||
* @param coordinates 坐标
|
||||
* @return 符合的方阵
|
||||
*/
|
||||
FacMatrix getMatrixIdByCoordinates(List<FacMatrix> matrixList, List<Double> coordinates);
|
||||
|
||||
/**
|
||||
* 根据二维坐标获取符合的方阵
|
||||
*
|
||||
* @param matrixList 方阵集合
|
||||
* @param coordinates 坐标
|
||||
* @return 符合的方阵
|
||||
*/
|
||||
FacMatrix getMatrixIdBy2Coordinates(List<FacMatrix> matrixList, List<List<Double>> coordinates);
|
||||
|
||||
}
|
||||
|
@ -14,20 +14,31 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.facility.domain.FacBoxTransformer;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerCreateReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerQueryReq;
|
||||
import org.dromara.facility.domain.dto.boxtransformer.FacBoxTransformerUpdateReq;
|
||||
import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeometryByPoint;
|
||||
import org.dromara.facility.domain.vo.boxtransformer.FacBoxTransformerVo;
|
||||
import org.dromara.facility.mapper.FacBoxTransformerMapper;
|
||||
import org.dromara.facility.service.IFacBoxTransformerService;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.JSTUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设施-箱变Service业务层处理
|
||||
@ -45,6 +56,9 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
|
||||
@Resource
|
||||
private IFacMatrixService matrixService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
/**
|
||||
* 查询设施-箱变
|
||||
*
|
||||
@ -120,6 +134,99 @@ public class FacBoxTransformerServiceImpl extends ServiceImpl<FacBoxTransformerM
|
||||
return boxTransformer.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设施-箱变
|
||||
*
|
||||
* @param geoJson GeoJson格式
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByGeoJson(FacBoxTransformerCreateByGeoJsonReq geoJson) {
|
||||
Long projectId = geoJson.getProjectId();
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取当前项目下方阵信息
|
||||
List<FacMatrix> matrixList = matrixService.lambdaQuery()
|
||||
.eq(FacMatrix::getProjectId, projectId).list();
|
||||
if (CollUtil.isEmpty(matrixList)) {
|
||||
throw new ServiceException("项目下无方阵数据,请先创建方阵消息后再添加光伏板信息", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取箱变信息
|
||||
List<FacBoxTransformer> oldBoxTransformerList = this.lambdaQuery()
|
||||
.eq(FacBoxTransformer::getProjectId, projectId).list();
|
||||
Map<String, FacBoxTransformer> boxTransformerMap = oldBoxTransformerList.stream().collect(Collectors.toMap(
|
||||
boxTransformer -> boxTransformer.getName() + "_" + boxTransformer.getProgressCategoryId(),
|
||||
Function.identity(),
|
||||
(boxTransformer1, boxTransformer2) -> boxTransformer1
|
||||
));
|
||||
List<FacFeatureByPoint> locationGeoJson = geoJson.getLocationGeoJson().getFeatures();
|
||||
List<FacFeatureByPoint> nameGeoJson = geoJson.getNameGeoJson().getFeatures();
|
||||
// 获取进度类别信息
|
||||
List<Long> progressCategoryIdList = geoJson.getProgressCategoryIdList();
|
||||
Map<Long, PgsProgressCategory> progressCategoryMap = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getId, progressCategoryIdList).list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
PgsProgressCategory::getId,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
List<FacBoxTransformer> boxTransformerList = new ArrayList<>();
|
||||
for (FacFeatureByPoint locationFeature : locationGeoJson) {
|
||||
FacGeometryByPoint geometry = locationFeature.getGeometry();
|
||||
List<Double> coordinates = geometry.getCoordinates();
|
||||
// 判断箱变在哪个方阵里
|
||||
FacMatrix matrix = matrixService.getMatrixIdByCoordinates(matrixList, coordinates);
|
||||
if (matrix == null) {
|
||||
continue;
|
||||
}
|
||||
// 获取箱变名称
|
||||
String name = JSTUtils.findNearestText(coordinates, nameGeoJson);
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
// 根据进度类别创建
|
||||
for (Long progressCategoryId : progressCategoryIdList) {
|
||||
FacBoxTransformer boxTransformer = new FacBoxTransformer();
|
||||
boxTransformer.setMatrixId(matrix.getId());
|
||||
boxTransformer.setName(name);
|
||||
boxTransformer.setProjectId(projectId);
|
||||
boxTransformer.setPositions(JSONUtil.toJsonStr(coordinates));
|
||||
String mapKey = name + "_" + progressCategoryId;
|
||||
// 如果有同名同类别箱变,则获取该箱变完成状态
|
||||
if (CollUtil.isNotEmpty(boxTransformerMap) && boxTransformerMap.containsKey(mapKey)) {
|
||||
FacBoxTransformer oldBoxTransformer = boxTransformerMap.get(name);
|
||||
boxTransformer.setFinishType(oldBoxTransformer.getFinishType());
|
||||
boxTransformer.setFinishDate(oldBoxTransformer.getFinishDate());
|
||||
boxTransformer.setProgressCategoryId(oldBoxTransformer.getProgressCategoryId());
|
||||
boxTransformer.setProgressCategoryName(oldBoxTransformer.getProgressCategoryName());
|
||||
boxTransformer.setStatus(oldBoxTransformer.getStatus());
|
||||
} else {
|
||||
boxTransformer.setProgressCategoryId(progressCategoryId);
|
||||
boxTransformer.setProgressCategoryName(progressCategoryMap.get(progressCategoryId).getName());
|
||||
}
|
||||
boxTransformerList.add(boxTransformer);
|
||||
}
|
||||
}
|
||||
// 删除旧数据
|
||||
if (CollUtil.isNotEmpty(oldBoxTransformerList)) {
|
||||
boolean result = this.removeBatchByIds(oldBoxTransformerList);
|
||||
if (!result) {
|
||||
throw new ServiceException("删除箱变失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
// 批量保存
|
||||
if (CollUtil.isNotEmpty(boxTransformerList)) {
|
||||
boolean result = this.saveBatch(boxTransformerList);
|
||||
if (!result) {
|
||||
throw new ServiceException("新增箱变失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设施-箱变
|
||||
*
|
||||
|
@ -14,6 +14,10 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.facility.domain.FacInverter;
|
||||
import org.dromara.facility.domain.FacMatrix;
|
||||
import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeometryByPoint;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterCreateReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterQueryReq;
|
||||
import org.dromara.facility.domain.dto.inverter.FacInverterUpdateReq;
|
||||
@ -21,13 +25,20 @@ import org.dromara.facility.domain.vo.inverter.FacInverterVo;
|
||||
import org.dromara.facility.mapper.FacInverterMapper;
|
||||
import org.dromara.facility.service.IFacInverterService;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.JSTUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设施-逆变器Service业务层处理
|
||||
@ -45,6 +56,9 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
|
||||
@Resource
|
||||
private IFacMatrixService matrixService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
/**
|
||||
* 查询设施-逆变器
|
||||
*
|
||||
@ -120,6 +134,99 @@ public class FacInverterServiceImpl extends ServiceImpl<FacInverterMapper, FacIn
|
||||
return inverter.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设施-逆变器
|
||||
*
|
||||
* @param geoJson GeoJson格式
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByGeoJson(FacInverterCreateByGeoJsonReq geoJson) {
|
||||
Long projectId = geoJson.getProjectId();
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取当前项目下方阵信息
|
||||
List<FacMatrix> matrixList = matrixService.lambdaQuery()
|
||||
.eq(FacMatrix::getProjectId, projectId).list();
|
||||
if (CollUtil.isEmpty(matrixList)) {
|
||||
throw new ServiceException("项目下无方阵数据,请先创建方阵消息后再添加光伏板信息", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取箱变信息
|
||||
List<FacInverter> oldInverterList = this.lambdaQuery()
|
||||
.eq(FacInverter::getProjectId, projectId).list();
|
||||
Map<String, FacInverter> inverterMap = oldInverterList.stream().collect(Collectors.toMap(
|
||||
inverter -> inverter.getName() + "_" + inverter.getProgressCategoryId(),
|
||||
Function.identity(),
|
||||
(inverter1, inverter2) -> inverter1
|
||||
));
|
||||
List<FacFeatureByPoint> locationGeoJson = geoJson.getLocationGeoJson().getFeatures();
|
||||
List<FacFeatureByPoint> nameGeoJson = geoJson.getNameGeoJson().getFeatures();
|
||||
// 获取进度类别信息
|
||||
List<Long> progressCategoryIdList = geoJson.getProgressCategoryIdList();
|
||||
Map<Long, PgsProgressCategory> progressCategoryMap = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getId, progressCategoryIdList).list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
PgsProgressCategory::getId,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
List<FacInverter> inverterList = new ArrayList<>();
|
||||
for (FacFeatureByPoint locationFeature : locationGeoJson) {
|
||||
FacGeometryByPoint geometry = locationFeature.getGeometry();
|
||||
List<Double> coordinates = geometry.getCoordinates();
|
||||
// 判断箱变在哪个方阵里
|
||||
FacMatrix matrix = matrixService.getMatrixIdByCoordinates(matrixList, coordinates);
|
||||
if (matrix == null) {
|
||||
continue;
|
||||
}
|
||||
// 获取逆变器名称
|
||||
String name = JSTUtils.findNearestText(coordinates, nameGeoJson);
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
// 根据进度类别创建
|
||||
for (Long progressCategoryId : progressCategoryIdList) {
|
||||
FacInverter inverter = new FacInverter();
|
||||
inverter.setMatrixId(matrix.getId());
|
||||
inverter.setName(name);
|
||||
inverter.setProjectId(projectId);
|
||||
inverter.setPositions(JSONUtil.toJsonStr(coordinates));
|
||||
String mapKey = name + "_" + progressCategoryId;
|
||||
// 如果有同名同类别箱变,则获取该箱变完成状态
|
||||
if (CollUtil.isNotEmpty(inverterMap) && inverterMap.containsKey(mapKey)) {
|
||||
FacInverter oldInverter = inverterMap.get(name);
|
||||
inverter.setFinishType(oldInverter.getFinishType());
|
||||
inverter.setFinishDate(oldInverter.getFinishDate());
|
||||
inverter.setProgressCategoryId(oldInverter.getProgressCategoryId());
|
||||
inverter.setProgressCategoryName(oldInverter.getProgressCategoryName());
|
||||
inverter.setStatus(oldInverter.getStatus());
|
||||
} else {
|
||||
inverter.setProgressCategoryId(progressCategoryId);
|
||||
inverter.setProgressCategoryName(progressCategoryMap.get(progressCategoryId).getName());
|
||||
}
|
||||
inverterList.add(inverter);
|
||||
}
|
||||
}
|
||||
// 删除旧数据
|
||||
if (CollUtil.isNotEmpty(oldInverterList)) {
|
||||
boolean result = this.removeBatchByIds(oldInverterList);
|
||||
if (!result) {
|
||||
throw new ServiceException("删除逆变器失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
// 批量保存
|
||||
if (CollUtil.isNotEmpty(inverterList)) {
|
||||
boolean result = this.saveBatch(inverterList);
|
||||
if (!result) {
|
||||
throw new ServiceException("新增逆变器失败,数据库异常", HttpStatus.ERROR);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设施-逆变器
|
||||
*
|
||||
|
@ -14,17 +14,17 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.facility.domain.*;
|
||||
import org.dromara.facility.domain.enums.FacFinishStatusEnum;
|
||||
import org.dromara.facility.domain.dto.geojson.FacFeature;
|
||||
import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeometry;
|
||||
import org.dromara.facility.domain.dto.matrix.*;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixVo;
|
||||
import org.dromara.facility.domain.enums.FacFinishStatusEnum;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixDetailGisVo;
|
||||
import org.dromara.facility.domain.vo.matrix.FacMatrixVo;
|
||||
import org.dromara.facility.mapper.FacMatrixMapper;
|
||||
import org.dromara.facility.service.*;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.GeoJsonUtils;
|
||||
import org.dromara.utils.JSTUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -41,7 +41,8 @@ import java.util.List;
|
||||
* @date 2025-04-21
|
||||
*/
|
||||
@Service
|
||||
public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix> implements IFacMatrixService {
|
||||
public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix>
|
||||
implements IFacMatrixService {
|
||||
|
||||
@Resource
|
||||
private IBusProjectService projectService;
|
||||
@ -251,7 +252,7 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
|
||||
if (projectService.getById(projectId) == null) {
|
||||
throw new ServiceException("项目不存在", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
// 获取当下项目下方阵信息
|
||||
// 获取当前项目下方阵信息
|
||||
List<FacMatrix> oldMatrixList = this.lambdaQuery()
|
||||
.eq(FacMatrix::getProjectId, projectId).list();
|
||||
List<FacMatrix> matrixList = new ArrayList<>();
|
||||
@ -263,12 +264,12 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
|
||||
matrix.setProjectId(projectId);
|
||||
FacGeometry geometry = feature.getGeometry();
|
||||
// 获取坐标信息
|
||||
List<List<Double>> coordinatesList = GeoJsonUtils.getTwoDimensionalCoordinates(geometry);
|
||||
List<List<Double>> coordinatesList = JSTUtils.getTwoDimensionalCoordinates(geometry);
|
||||
// 获取方阵名称
|
||||
String name = null;
|
||||
for (FacFeatureByPoint nameFeature : nameFeatures) {
|
||||
List<Double> nameCoordinates = nameFeature.getGeometry().getCoordinates();
|
||||
Boolean result = GeoJsonUtils.pointIsWithInPlane(coordinatesList, nameCoordinates);
|
||||
Boolean result = JSTUtils.pointIsWithInPlane(coordinatesList, nameCoordinates);
|
||||
if (result) {
|
||||
name = nameFeature.getProperties().getText();
|
||||
break;
|
||||
@ -475,4 +476,57 @@ public class FacMatrixServiceImpl extends ServiceImpl<FacMatrixMapper, FacMatrix
|
||||
return matrixVoPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据坐标获取符合的方阵
|
||||
*
|
||||
* @param matrixList 方阵集合
|
||||
* @param coordinates 坐标
|
||||
* @return 符合的方阵
|
||||
*/
|
||||
@Override
|
||||
public FacMatrix getMatrixIdByCoordinates(List<FacMatrix> matrixList, List<Double> coordinates) {
|
||||
// 判断在哪个方阵里
|
||||
FacMatrix matchMatrix = null;
|
||||
for (FacMatrix matrix : matrixList) {
|
||||
String positions = matrix.getPositions();
|
||||
List<List<Double>> positionList = new ArrayList<>();
|
||||
List<String> arr = JSONUtil.toList(positions, String.class);
|
||||
for (String s : arr) {
|
||||
positionList.add(JSONUtil.toList(s, Double.class));
|
||||
}
|
||||
Boolean result = JSTUtils.pointIsWithInPlane(positionList, coordinates);
|
||||
if (result) {
|
||||
matchMatrix = matrix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return matchMatrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据二维坐标获取符合的方阵
|
||||
*
|
||||
* @param matrixList 方阵集合
|
||||
* @param coordinates 坐标
|
||||
* @return 符合的方阵
|
||||
*/
|
||||
@Override
|
||||
public FacMatrix getMatrixIdBy2Coordinates(List<FacMatrix> matrixList, List<List<Double>> coordinates) {
|
||||
FacMatrix matchMatrix = null;
|
||||
for (FacMatrix matrix : matrixList) {
|
||||
String positions = matrix.getPositions();
|
||||
List<List<Double>> positionList = new ArrayList<>();
|
||||
List<String> arr = JSONUtil.toList(positions, String.class);
|
||||
for (String s : arr) {
|
||||
positionList.add(JSONUtil.toList(s, Double.class));
|
||||
}
|
||||
Boolean result = JSTUtils.planeIsWithInPlane(positionList, coordinates);
|
||||
if (result) {
|
||||
matchMatrix = matrix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return matchMatrix;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.facility.constant.FacPhotovoltaicPanelPartsConstant;
|
||||
import org.dromara.facility.domain.FacPhotovoltaicPanel;
|
||||
import org.dromara.facility.domain.FacPhotovoltaicPanelColumn;
|
||||
import org.dromara.facility.domain.FacPhotovoltaicPanelPoint;
|
||||
@ -17,8 +18,11 @@ import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
|
||||
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateByGeoJsonReq;
|
||||
import org.dromara.facility.domain.dto.photovoltaicpanelparts.FacPhotovoltaicPanelPartsCreateReq;
|
||||
import org.dromara.facility.service.*;
|
||||
import org.dromara.progress.constant.PgsProgressCategoryConstant;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.GeoJsonUtils;
|
||||
import org.dromara.utils.JSTUtils;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@ -63,6 +67,9 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
@Resource
|
||||
private IFacPhotovoltaicPanelSupportService photovoltaicPanelSupportService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
/**
|
||||
* 批量新增设施-光伏板(桩点、立柱、支架)
|
||||
*
|
||||
@ -115,6 +122,19 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
List<FacPhotovoltaicPanelSupport> supportList = new ArrayList<>();
|
||||
// 获取当前登录用户
|
||||
Long userId = LoginHelper.getUserId();
|
||||
// 获取进度类别
|
||||
List<String> progressCategoryNameList = List.of(FacPhotovoltaicPanelPartsConstant.POINT,
|
||||
FacPhotovoltaicPanelPartsConstant.COLUMN,
|
||||
FacPhotovoltaicPanelPartsConstant.SUPPORT);
|
||||
Map<String, PgsProgressCategory> progressCategoryMap = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getName, progressCategoryNameList)
|
||||
.in(PgsProgressCategory::getProjectId, projectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID)
|
||||
.list()
|
||||
.stream().collect(Collectors.toMap(
|
||||
PgsProgressCategory::getName,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
// 遍历所有光伏板,找到所有匹配的点
|
||||
for (FacPhotovoltaicPanel photovoltaicPanel : photovoltaicPanelList) {
|
||||
String positions = photovoltaicPanel.getPositions();
|
||||
@ -124,7 +144,7 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
positionList.add(JSONUtil.toList(s, Double.class));
|
||||
}
|
||||
// 获取点在面内的点
|
||||
List<List<Double>> pointInPlaneList = GeoJsonUtils.getPointInPlaneList(positionList, pointPositionList);
|
||||
List<List<Double>> pointInPlaneList = JSTUtils.getPointInPlaneList(positionList, pointPositionList);
|
||||
// 删除点在面内的点
|
||||
pointPositionList.removeAll(pointInPlaneList);
|
||||
// 判断点在面内的点是否为空
|
||||
@ -148,6 +168,11 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
photovoltaicPanelPoint.setFinishType(oldPoint.getFinishType());
|
||||
photovoltaicPanelPoint.setStatus(oldPoint.getStatus());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(progressCategoryMap) && progressCategoryMap.containsKey(FacPhotovoltaicPanelPartsConstant.POINT)) {
|
||||
PgsProgressCategory progressCategory = progressCategoryMap.get(FacPhotovoltaicPanelPartsConstant.POINT);
|
||||
photovoltaicPanelPoint.setProgressCategoryId(progressCategory.getId());
|
||||
photovoltaicPanelPoint.setProgressCategoryName(progressCategory.getName());
|
||||
}
|
||||
pointList.add(photovoltaicPanelPoint);
|
||||
FacPhotovoltaicPanelColumn photovoltaicPanelColumn = new FacPhotovoltaicPanelColumn();
|
||||
photovoltaicPanelColumn.setProjectId(projectId);
|
||||
@ -161,6 +186,11 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
photovoltaicPanelColumn.setFinishType(oldColumn.getFinishType());
|
||||
photovoltaicPanelColumn.setStatus(oldColumn.getStatus());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(progressCategoryMap) && progressCategoryMap.containsKey(FacPhotovoltaicPanelPartsConstant.COLUMN)) {
|
||||
PgsProgressCategory progressCategory = progressCategoryMap.get(FacPhotovoltaicPanelPartsConstant.COLUMN);
|
||||
photovoltaicPanelColumn.setProgressCategoryId(progressCategory.getId());
|
||||
photovoltaicPanelColumn.setProgressCategoryName(progressCategory.getName());
|
||||
}
|
||||
columnList.add(photovoltaicPanelColumn);
|
||||
FacPhotovoltaicPanelSupport photovoltaicPanelSupport = new FacPhotovoltaicPanelSupport();
|
||||
photovoltaicPanelSupport.setProjectId(projectId);
|
||||
@ -174,6 +204,11 @@ public class FacPhotovoltaicPanelPartsServiceImpl implements IFacPhotovoltaicPan
|
||||
photovoltaicPanelSupport.setFinishType(oldSupport.getFinishType());
|
||||
photovoltaicPanelSupport.setStatus(oldSupport.getStatus());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(progressCategoryMap) && progressCategoryMap.containsKey(FacPhotovoltaicPanelPartsConstant.SUPPORT)) {
|
||||
PgsProgressCategory progressCategory = progressCategoryMap.get(FacPhotovoltaicPanelPartsConstant.SUPPORT);
|
||||
photovoltaicPanelSupport.setProgressCategoryId(progressCategory.getId());
|
||||
photovoltaicPanelSupport.setProgressCategoryName(progressCategory.getName());
|
||||
}
|
||||
supportList.add(photovoltaicPanelSupport);
|
||||
i++;
|
||||
}
|
||||
|
@ -27,8 +27,10 @@ import org.dromara.facility.mapper.FacPhotovoltaicPanelMapper;
|
||||
import org.dromara.facility.service.IFacMatrixService;
|
||||
import org.dromara.facility.service.IFacPhotovoltaicPanelPartsService;
|
||||
import org.dromara.facility.service.IFacPhotovoltaicPanelService;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.service.IPgsProgressCategoryService;
|
||||
import org.dromara.project.service.IBusProjectService;
|
||||
import org.dromara.utils.GeoJsonUtils;
|
||||
import org.dromara.utils.JSTUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -61,6 +63,9 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
|
||||
@Resource
|
||||
private IFacPhotovoltaicPanelPartsService photovoltaicPanelPartsService;
|
||||
|
||||
@Resource
|
||||
private IPgsProgressCategoryService progressCategoryService;
|
||||
|
||||
/**
|
||||
* 查询设施-光伏板
|
||||
*
|
||||
@ -168,32 +173,29 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
|
||||
List<FacPhotovoltaicPanel> photovoltaicPanelList = new ArrayList<>();
|
||||
List<FacFeatureByPlane> locationFeatures = geoJson.getLocationGeoJson().getFeatures();
|
||||
List<FacFeatureByPoint> nameFeatures = geoJson.getNameGeoJson().getFeatures();
|
||||
// 获取进度类别信息
|
||||
List<Long> progressCategoryIdList = geoJson.getProgressCategoryIdList();
|
||||
Map<Long, PgsProgressCategory> progressCategoryMap = progressCategoryService.lambdaQuery()
|
||||
.in(PgsProgressCategory::getId, progressCategoryIdList).list()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
PgsProgressCategory::getId,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
for (FacFeatureByPlane locationFeature : locationFeatures) {
|
||||
FacGeometryByPlane geometry = locationFeature.getGeometry();
|
||||
List<List<Double>> coordinates = geometry.getCoordinates().getFirst();
|
||||
// 判断光伏板在哪个方阵里
|
||||
Long matrixId = null;
|
||||
for (FacMatrix matrix : matrixList) {
|
||||
String positions = matrix.getPositions();
|
||||
List<List<Double>> positionList = new ArrayList<>();
|
||||
List<String> arr = JSONUtil.toList(positions, String.class);
|
||||
for (String s : arr) {
|
||||
positionList.add(JSONUtil.toList(s, Double.class));
|
||||
}
|
||||
Boolean result = GeoJsonUtils.planeIsWithInPlane(positionList, coordinates);
|
||||
if (result) {
|
||||
matrixId = matrix.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matrixId == null) {
|
||||
FacMatrix matrix = matrixService.getMatrixIdBy2Coordinates(matrixList, coordinates);
|
||||
if (matrix == null) {
|
||||
continue;
|
||||
}
|
||||
// 获取光伏板名称
|
||||
String name = null;
|
||||
for (FacFeatureByPoint nameFeature : nameFeatures) {
|
||||
List<Double> nameCoordinates = nameFeature.getGeometry().getCoordinates();
|
||||
Boolean result = GeoJsonUtils.pointIsWithInPlane(coordinates, nameCoordinates);
|
||||
Boolean result = JSTUtils.pointIsWithInPlane(coordinates, nameCoordinates);
|
||||
if (result) {
|
||||
name = nameFeature.getProperties().getText();
|
||||
break;
|
||||
@ -203,9 +205,9 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
|
||||
continue;
|
||||
}
|
||||
// 根据进度类别创建
|
||||
for (Long progressCategoryId : geoJson.getProgressCategoryIdList()) {
|
||||
for (Long progressCategoryId : progressCategoryIdList) {
|
||||
FacPhotovoltaicPanel photovoltaicPanel = new FacPhotovoltaicPanel();
|
||||
photovoltaicPanel.setMatrixId(matrixId);
|
||||
photovoltaicPanel.setMatrixId(matrix.getId());
|
||||
photovoltaicPanel.setName(name);
|
||||
photovoltaicPanel.setProjectId(projectId);
|
||||
photovoltaicPanel.setPositions(JSONUtil.toJsonStr(coordinates));
|
||||
@ -216,9 +218,11 @@ public class FacPhotovoltaicPanelServiceImpl extends ServiceImpl<FacPhotovoltaic
|
||||
photovoltaicPanel.setFinishType(oldPhotovoltaicPanel.getFinishType());
|
||||
photovoltaicPanel.setFinishDate(oldPhotovoltaicPanel.getFinishDate());
|
||||
photovoltaicPanel.setProgressCategoryId(oldPhotovoltaicPanel.getProgressCategoryId());
|
||||
photovoltaicPanel.setProgressCategoryName(oldPhotovoltaicPanel.getProgressCategoryName());
|
||||
photovoltaicPanel.setStatus(oldPhotovoltaicPanel.getStatus());
|
||||
} else {
|
||||
photovoltaicPanel.setProgressCategoryId(progressCategoryId);
|
||||
photovoltaicPanel.setProgressCategoryName(progressCategoryMap.get(progressCategoryId).getName());
|
||||
}
|
||||
photovoltaicPanelList.add(photovoltaicPanel);
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package org.dromara.progress.constant;
|
||||
|
||||
/**
|
||||
* @author lcj
|
||||
* @date 2025/5/23 11:44
|
||||
*/
|
||||
public interface PgsProgressCategoryConstant {
|
||||
|
||||
/**
|
||||
* 项目公共进度类别ID
|
||||
*/
|
||||
Long PUBLIC_PROJECT_ID = 0L;
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.progress.constant.PgsProgressCategoryConstant;
|
||||
import org.dromara.progress.domain.PgsProgressCategory;
|
||||
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryCreateReq;
|
||||
import org.dromara.progress.domain.dto.progresscategory.PgsProgressCategoryQueryReq;
|
||||
@ -201,11 +202,11 @@ public class PgsProgressCategoryServiceImpl extends ServiceImpl<PgsProgressCateg
|
||||
Long pid = req.getPid();
|
||||
String name = req.getName();
|
||||
String unitType = req.getUnitType();
|
||||
Long progressCategoryId = req.getProjectId();
|
||||
Long projectId = req.getProjectId();
|
||||
// 模糊查询
|
||||
lqw.like(StringUtils.isNotBlank(name), PgsProgressCategory::getName, name);
|
||||
// 精确查询
|
||||
lqw.eq(ObjectUtils.isNotEmpty(progressCategoryId), PgsProgressCategory::getProjectId, progressCategoryId);
|
||||
lqw.in(ObjectUtils.isNotEmpty(projectId), PgsProgressCategory::getProjectId, projectId, PgsProgressCategoryConstant.PUBLIC_PROJECT_ID);
|
||||
lqw.eq(StringUtils.isNotBlank(unitType), PgsProgressCategory::getUnitType, unitType);
|
||||
lqw.eq(ObjectUtils.isNotEmpty(pid), PgsProgressCategory::getPid, pid);
|
||||
return lqw;
|
||||
|
@ -3,7 +3,9 @@ package org.dromara.utils;
|
||||
import org.dromara.common.core.constant.HttpStatus;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.constant.GeoJsonConstant;
|
||||
import org.dromara.facility.domain.dto.geojson.FacFeatureByPoint;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeometry;
|
||||
import org.dromara.facility.domain.dto.geojson.FacGeometryByPoint;
|
||||
import org.locationtech.jts.geom.*;
|
||||
|
||||
import java.util.List;
|
||||
@ -13,7 +15,37 @@ import java.util.stream.Collectors;
|
||||
* @author lcj
|
||||
* @date 2025/4/24 11:48
|
||||
*/
|
||||
public class GeoJsonUtils {
|
||||
public class JSTUtils {
|
||||
|
||||
/**
|
||||
* 获取最近点的名称
|
||||
*
|
||||
* @param target 目标点
|
||||
* @param nameGeoJson 点对象列表
|
||||
* @return 最近点的名称
|
||||
*/
|
||||
public static String findNearestText(List<Double> target, List<FacFeatureByPoint> nameGeoJson) {
|
||||
GeometryFactory geometryFactory = new GeometryFactory();
|
||||
Point targetPoint = geometryFactory.createPoint(new Coordinate(target.get(0), target.get(1)));
|
||||
FacFeatureByPoint nearestFeature = null;
|
||||
double minDistance = Double.MAX_VALUE;
|
||||
for (FacFeatureByPoint feature : nameGeoJson) {
|
||||
FacGeometryByPoint geometry = feature.getGeometry();
|
||||
List<Double> coords = geometry.getCoordinates();
|
||||
if (coords != null && coords.size() == 2) {
|
||||
Point currentPoint = geometryFactory.createPoint(new Coordinate(coords.get(0), coords.get(1)));
|
||||
double distance = targetPoint.distance(currentPoint);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
nearestFeature = feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nearestFeature != null && nearestFeature.getProperties() != null) {
|
||||
return nearestFeature.getProperties().getText();
|
||||
}
|
||||
return null; // 如果没找到合适的点
|
||||
}
|
||||
|
||||
/**
|
||||
* 点是否在平面内
|
||||
@ -82,7 +114,7 @@ public class GeoJsonUtils {
|
||||
*/
|
||||
public static Coordinate[] getPlaneCoordinate(List<List<Double>> planeLists) {
|
||||
return planeLists.stream().map(planeList ->
|
||||
new Coordinate(planeList.get(0), planeList.get(1)))
|
||||
new Coordinate(planeList.getFirst(), planeList.get(1)))
|
||||
.toList().toArray(new Coordinate[0]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user