From 509d655f6c1c70c38cb54ca3e5b0bac3dcfe0020 Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期三, 27 九月 2023 10:47:48 +0800 Subject: [PATCH] 增加获取附近井接口 --- ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java | 135 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 122 insertions(+), 13 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java index e0a498f..7b20289 100644 --- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java @@ -1,8 +1,14 @@ package com.ruoyi.alarmpoints.well.service.impl; +import java.util.ArrayList; import java.util.List; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; +import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo; +import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellParam; import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper; import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService; import com.ruoyi.common.annotation.DataScope; @@ -13,10 +19,14 @@ import com.ruoyi.common.utils.StringUtils; 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.validation.Validator; @@ -34,6 +44,7 @@ private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; @Autowired protected Validator validator; + /** * 鏌ヨ浜曠鐞� * @@ -44,6 +55,7 @@ public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id) { return ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(id); } + /** * 鏌ヨ浜曠鐞� * @@ -62,18 +74,17 @@ * @return 浜曠鐞� */ @Override - @DataScope(deptAlias = "d",userAlias = "u") + @DataScope(deptAlias = "d", userAlias = "u") public List<ArdAlarmpointsWell> selectArdAlarmpointsWellList(ArdAlarmpointsWell ardAlarmpointsWell) { return ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(ardAlarmpointsWell); } /** - * * @param ardAlarmpointsWell 鎸変簳缂栧彿鏌ヨ * @return */ @Override - @DataScope(deptAlias = "d",userAlias = "u") + @DataScope(deptAlias = "d", userAlias = "u") public List<ArdAlarmpointsWell> selectArdAlarmpointsWellByWellIdLike(ArdAlarmpointsWell ardAlarmpointsWell) { return ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellIdLike(ardAlarmpointsWell); } @@ -85,7 +96,13 @@ * @return 缁撴灉 */ @Override + @Transactional public int insertArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { + boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell); + if (wellIdExists) { + throw new RuntimeException("浜曞彿宸插瓨鍦�"); + } + ardAlarmpointsWell.setId(IdUtils.simpleUUID()); ardAlarmpointsWell.setUserId(SecurityUtils.getUserId()); ardAlarmpointsWell.setCreateBy(SecurityUtils.getUsername()); ardAlarmpointsWell.setCreateTime(DateUtils.getNowDate()); @@ -99,7 +116,12 @@ * @return 缁撴灉 */ @Override + @Transactional public int updateArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { + boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell); + if (wellIdExists) { + throw new RuntimeException("浜曞彿宸插瓨鍦�"); + } ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername()); ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate()); return ardAlarmpointsWellMapper.updateArdAlarmpointsWell(ardAlarmpointsWell); @@ -183,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("涓嶅厑璁告搷浣滀簳"); } } @@ -197,17 +217,106 @@ * @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 well 闇�瑕佹牳瀵圭殑浜� + * @return 缁撴灉 + */ + @Override + public Boolean checkWellIdExists(ArdAlarmpointsWell well) { + // 鏍¢獙锛歸ellId + String id = (well.getId() == null) ? "" : well.getId(); + String wellId = well.getWellId(); + ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.checkWellIdExists(wellId); + String infoId = (ardAlarmpointsWell == null) ? "" : (ardAlarmpointsWell.getId()); + if ((ardAlarmpointsWell != null) && !((infoId).equals(id))) { + //宸插瓨鍦� + return true; + } + return false; + } + + @Override + public List<ArdAlarmpointsWell> wellByDeptList(List<Long> deptList) { + QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("dept_id", deptList); + return ardAlarmpointsWellMapper.selectList(queryWrapper); + } + + @Override + public ArdAlarmpointsWell wellById(String id) { + return ardAlarmpointsWellMapper.selectById(id); + } + + @Override + public List<ArdAlarmpointsWell> wellList(List<Long> deptList) { + QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>(); + queryWrapper.select("id", "well_id", "oil_production", "longitude", "latitude", "altitude").in("dept_id", deptList); + return ardAlarmpointsWellMapper.selectList(queryWrapper); + } + + @Override + public PageInfo<ArdAlarmpointsWell> conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam) { + Integer pageNum = ardAlarmpointsWellParam.getPageNum(); + Integer pageSize = ardAlarmpointsWellParam.getPageSize(); + PageHelper.startPage(pageNum, pageSize); + QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>(); + queryWrapper.in("dept_id", ardAlarmpointsWellParam.getDeptList()) + .like(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellId()), "well_id", ardAlarmpointsWellParam.getWellId()); +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellNumber()),"well_number",ardAlarmpointsWellParam.getWellNumber()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getOilProduction()),"oil_production",ardAlarmpointsWellParam.getOilProduction()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellBlock()),"well_block",ardAlarmpointsWellParam.getWellBlock()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getDisplacementMode()),"displacement_mode",ardAlarmpointsWellParam.getDisplacementMode()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getSurroundingEnvironment()),"surrounding_environment",ardAlarmpointsWellParam.getSurroundingEnvironment()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellType()),"well_type",ardAlarmpointsWellParam.getWellType()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getInstalledLoad()),"installed_load",ardAlarmpointsWellParam.getInstalledLoad()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getMeteringStation()),"metering_station",ardAlarmpointsWellParam.getMeteringStation()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getTransferStation()),"transfer_station",ardAlarmpointsWellParam.getTransferStation()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getDehydrationStation()),"dehydration_station",ardAlarmpointsWellParam.getDehydrationStation()) +// .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getRunStatus()),"run_status",ardAlarmpointsWellParam.getRunStatus()); + List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.selectList(queryWrapper); + return new PageInfo<>(list); + } + + @Override + 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; + } } -- Gitblit v1.9.3