66 lines
2.3 KiB
Java
66 lines
2.3 KiB
Java
![]() |
package com.ruoyi.web.app;
|
||
|
|
||
|
import java.math.BigDecimal;
|
||
|
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.util.StringUtils;
|
||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
import com.ruoyi.bst.device.domain.DeviceQuery;
|
||
|
import com.ruoyi.bst.device.domain.DeviceVO;
|
||
|
import com.ruoyi.bst.device.domain.enums.DeviceStatus;
|
||
|
import com.ruoyi.bst.device.service.DeviceService;
|
||
|
import com.ruoyi.common.annotation.Anonymous;
|
||
|
import com.ruoyi.common.core.controller.BaseController;
|
||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||
|
|
||
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
||
|
@RestController
|
||
|
@RequestMapping("/app/device")
|
||
|
public class AppDeviceController extends BaseController {
|
||
|
|
||
|
@Autowired
|
||
|
private DeviceService deviceService;
|
||
|
|
||
|
@ApiOperation("获取附近可用车辆列表")
|
||
|
@GetMapping("/listNearBy")
|
||
|
@Anonymous
|
||
|
public AjaxResult listNearBy(DeviceQuery 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("中心坐标格式错误,必须包含经度和纬度");
|
||
|
}
|
||
|
query.setStatus(DeviceStatus.AVAILABLE.getCode());
|
||
|
return success(deviceService.selectDeviceList(query));
|
||
|
}
|
||
|
|
||
|
@ApiOperation("获取可用车辆详情")
|
||
|
@GetMapping("/availableDetail")
|
||
|
public AjaxResult getAvailableDetail(@RequestParam(required = false) Long id, @RequestParam(required = false) String sn) {
|
||
|
DeviceQuery query = new DeviceQuery();
|
||
|
query.setStatus(DeviceStatus.AVAILABLE.getCode());
|
||
|
if (id != null) {
|
||
|
query.setId(id);
|
||
|
} else if (StringUtils.hasText(sn)) {
|
||
|
query.setEqSn(sn);
|
||
|
} else {
|
||
|
return error("ID和SN不允许同时为空");
|
||
|
}
|
||
|
|
||
|
DeviceVO device = deviceService.selectOne(query);
|
||
|
return success(device);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|