|  |  |  | 
|---|
|  |  |  | 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.CrossOrigin; | 
|---|
|  |  |  | 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.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.awt.geom.GeneralPath; | 
|---|
|  |  |  | import java.awt.geom.Point2D; | 
|---|
|  |  |  | import java.text.DecimalFormat; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @ClassName UAVController | 
|---|
|  |  |  | 
|---|
|  |  |  | public class UAVController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | HistorySecondUavService historySecondUavService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | HistorySecondUavMapper historySecondUavMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | HistorySecondUavService historySecondUavService; | 
|---|
|  |  |  | UAVService uavService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Description: 根据组织id,mac以及时间查询无人机数据 | 
|---|
|  |  |  | * @Param: [] | 
|---|
|  |  |  | * @Description: 根据批次号查询无人机飞行数据 | 
|---|
|  |  |  | * @Param: [batch] | 
|---|
|  |  |  | * @return: com.moral.constant.ResultMessage | 
|---|
|  |  |  | * @Author: 陈凯裕 | 
|---|
|  |  |  | * @Date: 2021/8/31 | 
|---|
|  |  |  | * @Date: 2021/9/13 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @RequestMapping("query") | 
|---|
|  |  |  | public ResultMessage query(){ | 
|---|
|  |  |  | List<HistorySecondUav> historySecondUavs = historySecondUavMapper.selectList(new QueryWrapper<>()); | 
|---|
|  |  |  | return new ResultMessage(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getMsg(),historySecondUavs); | 
|---|
|  |  |  | @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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|