package com.tofly.gpsboot.controller.car;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.es.dto.EsQueryDto;
import com.tofly.gpsboot.service.calculate.ICalculateGpsService;
import com.tofly.gpsboot.service.car.CarService;
import com.tofly.gpsboot.service.car.CarUserService;
import com.tofly.gpsboot.service.comm.IDisposeDateService;
import com.tofly.gpsboot.service.es.IGpsUploadService;
import com.tofly.gpsboot.service.maintain.EventMangeService;
import com.tofly.pojo.car.vo.CarTrackVo;
import com.tofly.pojo.maintain.EventMange;
import com.tofly.pojo.maintain.dto.CarTrackDto;
import com.tofly.pojo.plan.Car;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//@RestController
//@AllArgsConstructor
//@RequestMapping("/cartrack")
//@Api(tags="车辆巡查档案")
public class CarTrackController {

//    private final IGpsUploadService iGpsUploadService;
//    private final CarService carService;
//    private final CarUserService carUserService;
//    private final IDisposeDateService disposeDateService;
//    private final ICalculateGpsService iCalculateGpsService;
//    private final EventMangeService eventMangeService;
//    @GetMapping("/page" )
//    @ApiOperation(value = "分页查询")
//    public ResultRespone<Page<CarTrackVo>> getCarGpsPage(Page page,
//                                                         @ModelAttribute CarTrackDto carTrackDto) {
//
//        Page<CarTrackVo> carTrackPage = carService.getCarTrackPage(page, carTrackDto);
//
//
//        List<CarTrackVo> records = carTrackPage.getRecords();
//        List<CarTrackVo> trackList = new ArrayList<>();
//        records.forEach(re->{
//            List<EventMange> list = eventMangeService.list(Wrappers.<EventMange>lambdaQuery()
//                    .eq(EventMange::getCreateUserid, re.getUserId())
//                    .between(re.getBeginDate() != null && re.getEndDate() != null,
//                            EventMange::getCreateTime, re.getBeginDate(), re.getEndDate()
//                    ));
//            re.setEventMangeList(list);
//            EsQueryDto dto = new EsQueryDto();
//            dto.setUserId(re.getUserId());
//            dto.setStartDate(re.getBeginDate());
//            if(re.getEndDate()==null){
//                dto.setEndDate(new Date());
//            }else{
//                dto.setEndDate(re.getEndDate());
//
//            }
//            List<String> sectionGps = iGpsUploadService.getSectionGps(dto);
//            re.setTrackSections(sectionGps);
//            trackList.add(re);
//        });
//        carTrackPage.setRecords(trackList);
//
//        return ResultRespone.success(carTrackPage);
//    }
}
