| | |
| | | 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.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | 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 |
| | |
| | | public class UAVController { |
| | | |
| | | @Autowired |
| | | HistorySecondUavService historySecondUavService; |
| | | @Autowired |
| | | HistorySecondUavMapper historySecondUavMapper; |
| | | @Autowired |
| | | 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); |
| | | } |
| | | |
| | | @PostMapping("getUavMore") |
| | | public ResultMessage getUavMore(@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(); |
| | | } |
| | | |
| | | @GetMapping("UAVUpdateTest") |
| | | public ResultMessage UAVUpdateTest( String batch){ |
| | | historySecondUavService.UAVUpdateTest(batch); |
| | | return new ResultMessage(); |
| | | } |
| | | |
| | | } |