jinpengyong
2023-08-28 ea75e686ed771fa377f688d9eaf8027740265aa1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.entity.ManageCoordinate;
import com.moral.api.entity.SpecialDevice;
import com.moral.api.pojo.dto.cruiser.CruiserDTO;
import com.moral.api.service.HistorySecondCruiserService;
import com.moral.api.service.ManageCoordinateService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.WebUtils;
 
@Slf4j
@Api(tags = {"走航车路段查询"})
@RestController
@RequestMapping("cruiserInfo")
public class CruiserController {
 
 
    @Autowired
    private HistorySecondCruiserService historySecondCruiserService;
 
 
 
 
    /**
     *
     * @return
     */
    @GetMapping("selectCruisers")
    @ApiOperation(value = "获取所有走航车")
    public ResultMessage selectCruisers() {
        List<SpecialDevice> specialDevices = historySecondCruiserService.selectCruisers();
        if (ObjectUtils.isEmpty(specialDevices)){
            return ResultMessage.fail(ResponseCodeEnum.TARGET_IS_NULL.getCode(),
                    ResponseCodeEnum.TARGET_IS_NULL.getMsg());
        }
        return ResultMessage.ok(specialDevices);
    }
 
    @GetMapping("getCruiserInFo")
    @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 = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getCruiserInFo(HttpServletRequest request){
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> cruiserInFo = historySecondCruiserService.getCruiserInFo(params);
 
        return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok(ResponseCodeEnum.DEVICE_IS_NULL.getMsg()) : ResultMessage.ok(cruiserInFo);
    }
 
 
 
 
 
    @GetMapping("getCruiserCompare")
    @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 = "time1", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String"),
            @ApiImplicitParam(name = "time2", value = "时间,2021-08-18", required = true, paramType = "query", dataType = "String")
    })
    public ResultMessage getCruiserCompare(HttpServletRequest request){
        Map<String, Object> params = WebUtils.getParametersStartingWith(request, null);
        if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        Map<String, Object> cruiserInFo = historySecondCruiserService.getCruiserCompare(params);
 
        return ObjectUtils.isEmpty(cruiserInFo)? ResultMessage.ok(ResponseCodeEnum.DEVICE_IS_NULL.getMsg()) : ResultMessage.ok(cruiserInFo);
    }
 
}