jinpengyong
2023-09-27 68e22957db996437fa20a9a4aa5ff37c54d4056f
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.moral.api.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.moral.api.entity.HistorySecondUav;
import com.moral.api.mapper.HistorySecondUavMapper;
import com.moral.api.pojo.dto.uav.UAVGetBD;
import com.moral.api.pojo.dto.uav.UAVGteForDTO;
import com.moral.api.pojo.dto.uav.UAVQueryTimeSlotDTO;
import com.moral.api.pojo.dto.uav.UAVResultDTO;
import com.moral.api.pojo.form.uav.UAVQueryTimeSlotForm;
import com.moral.api.pojo.vo.uav.HistorySecondUavVOs;
import com.moral.api.pojo.vo.uav.UAVQueryDateVO;
import com.moral.api.pojo.vo.uav.UAVQueryTimeSlotVO;
import com.moral.api.pojo.vo.uav.UAVQueryTimeSlotVOs;
import com.moral.api.service.HistorySecondUavService;
import com.moral.api.service.UAVService;
import com.moral.constant.ResponseCodeEnum;
import com.moral.constant.ResultMessage;
import com.moral.util.DateUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
 
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * @ClassName UAVController
 * @Description 无人机控制器
 * @Author 陈凯裕
 * @Date 2021/8/31 15:08
 * @Version TODO
 **/
@Slf4j
@Api(tags = {"无人机控制器"})
@RestController
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/uav")
public class UAVController {
 
    @Autowired
    HistorySecondUavService historySecondUavService;
    @Autowired
    HistorySecondUavMapper historySecondUavMapper;
    @Autowired
    UAVService uavService;
 
    /**
    * @Description: 根据批次号查询无人机飞行数据
            * @Param: [batch]
            * @return: com.moral.constant.ResultMessage
            * @Author: 陈凯裕
            * @Date: 2021/9/13
            */
    @RequestMapping("queryDataByBatch")
    public ResultMessage queryDataByBatch(String batch){
        List<HistorySecondUav> historySecondUavs = historySecondUavService.queryDataByBatch(batch);
        if (historySecondUavs==null){
            return new ResultMessage(ResponseCodeEnum.SENSOR_IS_NOT_EXIST,"null");
        }
        
        //转换前端所需参数
        HistorySecondUavVOs vo = HistorySecondUavVOs.convert(historySecondUavs);
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
 
    @PostMapping("getUav")
    public ResultMessage test(@RequestBody Map<String, Object> params){
        //判断是否缺少参数
        if (!params.containsKey("mac") || !params.containsKey("batch") || !params.containsKey("height1")|| !params.containsKey("uvasize")|| !params.containsKey("height2")) {
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        }
        List<UAVResultDTO> uavResultDTOS = uavService.getUav(params);
        if (ObjectUtils.isEmpty(uavResultDTOS)){
            return new ResultMessage(ResponseCodeEnum.SENSOR_IS_NOT_EXIST,"null");
        }
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),uavResultDTOS);
    }
 
 
    /**
    * @Description: 查询组织在哪天有无人机飞行,返回具体日期
            * @Param: [organizationId]
            * @return: com.moral.constant.ResultMessage
            * @Author: 陈凯裕
            * @Date: 2021/9/8
            */
    @RequestMapping("queryDate")
    public ResultMessage queryDate(Integer organizationId){
        //处理查询业务
        List<Date> dates = historySecondUavService.queryDate(organizationId);
        //封装vo层
        UAVQueryDateVO vo = UAVQueryDateVO.convert(dates);
        //返回数据
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
 
 
    /**
    * @Description: 查询某天组织无人机的飞行时间段
            * @Param: [form]
            * @return: com.moral.constant.ResultMessage
            * @Author: 陈凯裕
            * @Date: 2021/9/13
            */
    @RequestMapping("queryTimeSlot")
    public ResultMessage queryTimeSlot(UAVQueryTimeSlotForm form){
        //判断是否缺少参数
        if (!form.valid())
            return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),
                    ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
        //处理查询业务
        List<UAVQueryTimeSlotDTO> dtos = historySecondUavService.queryTimeSlot(form);
        if (ObjectUtils.isEmpty(dtos)){
            return new ResultMessage(ResponseCodeEnum.TARGET_IS_NULL,null);
        }
        //封装vo层
        UAVQueryTimeSlotVOs vo = UAVQueryTimeSlotVOs.convert(dtos);
 
        //返回数据
        return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),vo);
    }
 
    @GetMapping("UAVTest")
    public ResultMessage UAVTest(BigDecimal lat, BigDecimal lon, String batch){
        historySecondUavService.UAVTest(lat, lon, batch);
        return new ResultMessage();
    }
 
}