package com.moral.api.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.ObjectUtils;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import com.moral.api.service.SpecialDeviceService;
|
import com.moral.constant.ResponseCodeEnum;
|
import com.moral.constant.ResultMessage;
|
import com.moral.util.WebUtils;
|
|
@Slf4j
|
@Api(tags = {"走航车"})
|
@RestController
|
@CrossOrigin(origins = "*", maxAge = 3600)
|
@RequestMapping("/cruiser")
|
public class CruiserController {
|
|
@Autowired
|
private SpecialDeviceService specialDeviceService;
|
|
/**
|
* @return 返回请求成功后的对象信息
|
*/
|
@GetMapping("selectCruisers")
|
@ApiOperation(value = "获取当前组织下所有走航车列表", notes = "走航车轨迹")
|
public ResultMessage getCarsInfo() {
|
List<Map<String, Object>> response = specialDeviceService.selectCruisers();
|
return ResultMessage.ok(response);
|
}
|
|
/**
|
* @param mac 设备mac
|
* @return 返回请求成功后的对象信息
|
*/
|
@GetMapping("getDates")
|
@ApiOperation(value = "获取有走航数据的日期", notes = "获取有走航数据的日期")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
|
@ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String")
|
})
|
public ResultMessage getDates(String mac) {
|
if (ObjectUtils.isEmpty(mac)) {
|
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
|
}
|
List<String> response = specialDeviceService.getDatesByMac(mac);
|
return ResultMessage.ok(response);
|
}
|
|
/**
|
* @param request 请求信息
|
* @return 返回请求成功后的对象信息
|
*/
|
@GetMapping("cruiserTrajectory")
|
@ApiOperation(value = "走航车轨迹", notes = "走航车轨迹")
|
@ApiImplicitParams(value = {
|
@ApiImplicitParam(name = "token", value = "token", required = true, paramType = "header", dataType = "String"),
|
@ApiImplicitParam(name = "mac", value = "设备mac", required = true, paramType = "query", dataType = "String"),
|
@ApiImplicitParam(name = "time", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
|
})
|
public ResultMessage carTrajectory(HttpServletRequest request) {
|
Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
|
if (!params.containsKey("mac") || !params.containsKey("time")) {
|
return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
|
}
|
List<Map<String, Object>> response = specialDeviceService.carTrajectory(params);
|
return ObjectUtils.isEmpty(response) ? ResultMessage.ok() : ResultMessage.ok(response);
|
}
|
|
}
|