2025-03-25 18:03:57 +08:00
|
|
|
package com.ruoyi.web.app;
|
|
|
|
|
2025-04-21 18:27:12 +08:00
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
2025-03-25 18:03:57 +08:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import com.ruoyi.bst.area.domain.AreaQuery;
|
|
|
|
import com.ruoyi.bst.area.domain.enums.AreaStatus;
|
2025-04-21 18:27:12 +08:00
|
|
|
import com.ruoyi.bst.area.service.AreaDashboard;
|
2025-03-25 18:03:57 +08:00
|
|
|
import com.ruoyi.bst.area.service.AreaService;
|
2025-03-27 18:03:33 +08:00
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
2025-03-25 18:03:57 +08:00
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
2025-04-21 18:27:12 +08:00
|
|
|
import com.ruoyi.common.domain.vo.LongIntegerVO;
|
2025-03-25 18:03:57 +08:00
|
|
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/app/area")
|
|
|
|
public class AppAreaController extends BaseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private AreaService areaService;
|
|
|
|
|
2025-04-21 18:27:12 +08:00
|
|
|
@Autowired
|
|
|
|
private AreaDashboard areaDashboard;
|
|
|
|
|
|
|
|
// 设置前提条件
|
|
|
|
private void setQuery(AreaQuery query) {
|
|
|
|
query.setStatus(AreaStatus.ENABLED.getCode());
|
|
|
|
}
|
|
|
|
|
2025-03-25 18:03:57 +08:00
|
|
|
@ApiOperation("获取运营区详情")
|
|
|
|
@GetMapping("/detail")
|
2025-03-27 18:03:33 +08:00
|
|
|
@Anonymous
|
2025-03-25 18:03:57 +08:00
|
|
|
public AjaxResult getAreaDetail(Long id) {
|
|
|
|
AreaQuery query = new AreaQuery();
|
|
|
|
query.setId(id);
|
2025-04-21 18:27:12 +08:00
|
|
|
setQuery(query);
|
2025-03-25 18:03:57 +08:00
|
|
|
return success(areaService.selectOne(query));
|
|
|
|
}
|
2025-04-21 18:27:12 +08:00
|
|
|
|
|
|
|
@ApiOperation("获取附近的运营区")
|
|
|
|
@GetMapping("/nearby")
|
|
|
|
@Anonymous
|
|
|
|
public AjaxResult getNearbyArea(AreaQuery query) {
|
|
|
|
if (query.getRadius() == null || query.getRadius().compareTo(BigDecimal.ZERO) <= 0 || query.getRadius().compareTo(BigDecimal.valueOf(10000)) > 0) {
|
|
|
|
return error("半径必须在0-10000之间");
|
|
|
|
}
|
|
|
|
if (query.getCenter() == null) {
|
|
|
|
return error("中心坐标不能为空");
|
|
|
|
}
|
|
|
|
if (query.getCenter().size() != 2) {
|
|
|
|
return error("中心坐标格式错误,必须包含经度和纬度");
|
|
|
|
}
|
|
|
|
setQuery(query);
|
|
|
|
|
|
|
|
// 查询设备数量最多的运营区ID
|
|
|
|
LongIntegerVO max = areaDashboard.selectMaxOfDeviceCountAreaId(query);
|
|
|
|
if (max == null) {
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 查询运营区详情
|
|
|
|
return success(areaService.selectAreaById(max.getKey()));
|
|
|
|
}
|
2025-03-25 18:03:57 +08:00
|
|
|
|
|
|
|
}
|