|
|
|
@ -2,7 +2,9 @@ package com.ruoyi.database.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
|
|
import com.ruoyi.database.domain.MetaActualUnitInfo;
|
|
|
|
|
import com.ruoyi.database.domain.vo.MetaActualUnitInfoVO;
|
|
|
|
|
import com.ruoyi.database.service.MetaActualUnitInfoService;
|
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
@ -18,6 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 实有单位信息表(MetaActualUnitInfo)Controller
|
|
|
|
@ -92,4 +95,29 @@ public class MetaActualUnitInfoController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/distance")
|
|
|
|
|
@ApiOperation("周边单位列表")
|
|
|
|
|
public TableDataInfo<MetaActualUnitInfoVO> peripheryUnit(MetaActualUnitInfo metaActualUnitInfo) {
|
|
|
|
|
List<MetaActualUnitInfo> list = metaActualUnitInfoService.lambdaQuery()
|
|
|
|
|
.ne(MetaActualUnitInfo::getUnitId, metaActualUnitInfo.getUnitId())
|
|
|
|
|
.between(MetaActualUnitInfo::getLatitude, metaActualUnitInfo.getLatitude() - 0.001, metaActualUnitInfo.getLatitude() + 0.001)
|
|
|
|
|
.between(MetaActualUnitInfo::getLongitude, metaActualUnitInfo.getLongitude() - 0.001, metaActualUnitInfo.getLongitude() + 0.001)
|
|
|
|
|
.list();
|
|
|
|
|
List<MetaActualUnitInfoVO> metaActualUnitInfoVOS = list.stream().map(info -> {
|
|
|
|
|
MetaActualUnitInfoVO metaActualUnitInfoVO = new MetaActualUnitInfoVO();
|
|
|
|
|
BeanUtils.copyProperties(info, metaActualUnitInfoVO);
|
|
|
|
|
double dLat = Math.toRadians(metaActualUnitInfoVO.getLatitude() - metaActualUnitInfo.getLatitude());
|
|
|
|
|
double dLon = Math.toRadians(metaActualUnitInfoVO.getLongitude() - metaActualUnitInfo.getLongitude());
|
|
|
|
|
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
|
|
|
|
|
Math.cos(Math.toRadians(metaActualUnitInfo.getLatitude())) * Math.cos(Math.toRadians(metaActualUnitInfoVO.getLatitude())) *
|
|
|
|
|
Math.sin(dLon / 2) * Math.sin(dLon / 2);
|
|
|
|
|
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
|
|
|
double distance = 6371 * c * 1000;
|
|
|
|
|
metaActualUnitInfoVO.setDistance((int)distance + "米");
|
|
|
|
|
return metaActualUnitInfoVO;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
return getDataTable(metaActualUnitInfoVOS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|