forked from ard/ruoyi-api

‘liusuyi’
2023-09-27 509d655f6c1c70c38cb54ca3e5b0bac3dcfe0020
增加获取附近井接口
1 files deleted
5 files modified
123 ■■■■ changed files
ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java 8 ●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/IArdAlarmpointsWellService.java 9 ●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java 54 ●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java 9 ●●●●● patch | view | raw | blame | history
ard-work/src/main/resources/templates/mediaMTX.html 40 ●●●●● patch | view | raw | blame | history
ruoyi-admin/Dockerfile 3 ●●●● patch | view | raw | blame | history
ard-work/src/main/java/com/ruoyi/alarmpoints/well/controller/ArdAlarmpointsWellController.java
@@ -211,6 +211,12 @@
        //根据deptId获取对应兴趣点数据
        return Results.succeed(ardAlarmpointsWellService.conditionList(ardAlarmpointsWellParam));
    }
    @PostMapping("/getNearbyWells")
    @ApiOperation("查询附近的所有井")
    public TableDataInfo getNearbyWells(Long deptId,Double[]position){
        startPage();
        List<ArdAlarmpointsWell> nearbyWellList = ardAlarmpointsWellService.getNearbyWellList(deptId,position,1000);
        return getDataTable(nearbyWellList);
    }
}
ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/IArdAlarmpointsWellService.java
@@ -102,7 +102,7 @@
    /**
     * 核对井号是否唯一
     *
     * @param id 需要核对的井的主键
     * @param well 需要核对的井
     * @return 结果
     */
@@ -117,5 +117,10 @@
    PageInfo<ArdAlarmpointsWell> conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam);
    List<ArdAlarmpointsWellDeptVo> wellListDept(List<Long> deptList);
    /**
     * 获取附近的井
     * 刘苏义
     * 2023/9/27 10:26:35
     */
    List<ArdAlarmpointsWell> getNearbyWellList(Long deptId,Double[] position,Integer range);
}
ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.alarmpoints.well.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -19,6 +20,7 @@
import com.ruoyi.common.utils.bean.BeanValidators;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.utils.gis.GisUtil;
import lombok.ToString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,6 +44,7 @@
    private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper;
    @Autowired
    protected Validator validator;
    /**
     * 查询井管理
     *
@@ -52,6 +55,7 @@
    public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id) {
        return ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(id);
    }
    /**
     * 查询井管理
     *
@@ -76,7 +80,6 @@
    }
    /**
     *
     * @param ardAlarmpointsWell 按井编号查询
     * @return
     */
@@ -96,8 +99,7 @@
    @Transactional
    public int insertArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) {
        boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell);
        if(wellIdExists)
        {
        if (wellIdExists) {
            throw new RuntimeException("井号已存在");
        }
        ardAlarmpointsWell.setId(IdUtils.simpleUUID());
@@ -117,8 +119,7 @@
    @Transactional
    public int updateArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) {
        boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell);
        if(wellIdExists)
        {
        if (wellIdExists) {
            throw new RuntimeException("井号已存在");
        }
        ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername());
@@ -204,10 +205,8 @@
     * @param well 井信息
     */
    @Override
    public void checkWellAllowed(ArdAlarmpointsWell well)
    {
        if (StringUtils.isNotNull(well.getId()))
        {
    public void checkWellAllowed(ArdAlarmpointsWell well) {
        if (StringUtils.isNotNull(well.getId())) {
            throw new ServiceException("不允许操作井");
        }
    }
@@ -218,23 +217,21 @@
     * @param userId 用户id
     */
    @Override
    public void checkWellDataScope(String userId)
    {
        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
        {
    public void checkWellDataScope(String userId) {
        if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
            ArdAlarmpointsWell well = new ArdAlarmpointsWell();
            well.setUserId(userId);
            List<ArdAlarmpointsWell> wells = SpringUtils.getAopProxy(this).selectArdAlarmpointsWellList(well);
            if (StringUtils.isEmpty(wells))
            {
            if (StringUtils.isEmpty(wells)) {
                throw new ServiceException("没有权限访问井数据!");
            }
        }
    }
    /**
     * 核对井号是否唯一
     *
     * @param wellId 需要核对的井号
     * @param well 需要核对的井
     * @return 结果
     */
    @Override
@@ -297,4 +294,29 @@
    public List<ArdAlarmpointsWellDeptVo> wellListDept(List<Long> deptList) {
        return ardAlarmpointsWellMapper.wellListDept(deptList);
    }
    @Override
    public List<ArdAlarmpointsWell> getNearbyWellList(Long deptId, Double[] position, Integer range) {
        List<ArdAlarmpointsWell> nearbyWellList = new ArrayList<>();
        try {
            ArdAlarmpointsWell ardAlarmpointsWell = new ArdAlarmpointsWell();
            ardAlarmpointsWell.setDeptId(deptId);
            List<ArdAlarmpointsWell> ardAlarmpointsWells = ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(ardAlarmpointsWell);
            if (ardAlarmpointsWells.size() > 0) {
                for (ArdAlarmpointsWell well : ardAlarmpointsWells) {
                    Double longitude = well.getLongitude();
                    Double latitude = well.getLatitude();
                    if (longitude != null && latitude != null) {
                        double distance = GisUtil.getDistance(position, new Double[]{longitude, latitude});
                        if (distance <= range) {
                            nearbyWellList.add(well);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            log.error("获取附近井异常:" + ex.getMessage());
        }
        return nearbyWellList;
    }
}
ard-work/src/main/java/com/ruoyi/utils/gis/GisUtil.java
@@ -26,6 +26,15 @@
        GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo);
        return geodeticCalculator.calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance();
    }
    public static double getDistance(Double[] From, Double[] To) {
        double longitudeFrom = From[0];
        double latitudeFrom = From[1];
        double longitudeTo = To[0];
        double latitudeTo = To[1];
        GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom);
        GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo);
        return geodeticCalculator.calculateGeodeticCurve(Ellipsoid.WGS84, source, target).getEllipsoidalDistance();
    }
    /**
     * 根据经纬度,计算两点间的距离
     *
ard-work/src/main/resources/templates/mediaMTX.html
File was deleted
ruoyi-admin/Dockerfile
@@ -4,4 +4,5 @@
ENV TimeZone=Asia/Shanghai
# 使用软连接,并且将时区配置覆盖/etc/timezone
RUN ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone
ENTRYPOINT ["java","-jar","/ruoyi-admin.jar"]
RUN mkdir -p /work
ENTRYPOINT ["java","-Dloader.path=/work/libs","-jar","/ruoyi-admin.jar"]