| | |
| | | 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.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; |
| | |
| | | private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; |
| | | @Autowired |
| | | protected Validator validator; |
| | | |
| | | /** |
| | | * 查询井管理 |
| | | * |
| | |
| | | public ArdAlarmpointsWell selectArdAlarmpointsWellById(String id) { |
| | | return ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(id); |
| | | } |
| | | |
| | | /** |
| | | * 查询井管理 |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param ardAlarmpointsWell 按井编号查询 |
| | | * @return |
| | | */ |
| | |
| | | @Transactional |
| | | public int insertArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { |
| | | boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell); |
| | | if(wellIdExists) |
| | | { |
| | | if (wellIdExists) { |
| | | throw new RuntimeException("井号已存在"); |
| | | } |
| | | ardAlarmpointsWell.setId(IdUtils.simpleUUID()); |
| | |
| | | @Transactional |
| | | public int updateArdAlarmpointsWell(ArdAlarmpointsWell ardAlarmpointsWell) { |
| | | boolean wellIdExists = checkWellIdExists(ardAlarmpointsWell); |
| | | if(wellIdExists) |
| | | { |
| | | if (wellIdExists) { |
| | | throw new RuntimeException("井号已存在"); |
| | | } |
| | | ardAlarmpointsWell.setUpdateBy(SecurityUtils.getUsername()); |
| | |
| | | * @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("不允许操作井"); |
| | | } |
| | | } |
| | |
| | | * @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 |
| | |
| | | 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; |
| | | } |
| | | } |