| | |
| | | package com.moral.api.controller; |
| | | |
| | | import com.moral.api.pojo.dto.historySecondCruiser.HistorySecondCruiserResultDTO; |
| | | 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.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | return ObjectUtils.isEmpty(response) ? ResultMessage.ok() : ResultMessage.ok(response); |
| | | } |
| | | @GetMapping("carTrajectoryNewAvg") |
| | | @ApiOperation(value = "走航车轨迹均值", notes = "走航车轨迹均值") |
| | | @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"), |
| | | @ApiImplicitParam(name = "type", value = "type", required = true, paramType = "query", dataType = "String") |
| | | @ApiImplicitParam(name = "type", value = "采集因子", required = true, paramType = "query", dataType = "String") |
| | | }) |
| | | public ResultMessage carTrajectoryNewAvg(HttpServletRequest request) { |
| | | long stime = System.currentTimeMillis(); |
| | | Map<String, Object> params = WebUtils.getParametersStartingWith(request, null); |
| | | if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("time2")|| !params.containsKey("type")) { |
| | | if (!params.containsKey("mac") || !params.containsKey("time1")|| !params.containsKey("type")|| !params.containsKey("time2")) { |
| | | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); |
| | | } |
| | | List<Map<String, Object>> response = specialDeviceService.carTrajectory(params,false); |
| | | List<HistorySecondCruiserResultDTO> response = specialDeviceService.carTrajectoryNewAvg(params); |
| | | if(CollectionUtils.isEmpty(response)){ |
| | | return ObjectUtils.isEmpty(response) ? ResultMessage.ok() : ResultMessage.ok(response); |
| | | } |
| | | long etime = System.currentTimeMillis(); |
| | | Map<Integer,HistorySecondCruiserResultDTO> map = new HashMap<>(); |
| | | |
| | | for(int i = 0 ;i<response.size();i++){ |
| | | map.put(i,response.get(i)); |
| | | } |
| | | //计算执行时间 |
| | | System.out.printf("执行时长:%d 毫秒.", (etime - stime)); |
| | | return ResultMessage.ok(map); |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 走航车日报 |