package com.keystar.plane.inspection.controller;

import cn.hutool.core.util.IdUtil;
import com.drew.imaging.jpeg.JpegProcessingException;
import com.keystar.mqtt.bo.MqttMessageBo;
import com.keystar.plane.inspection.bo.NewFileBo;
import com.keystar.plane.inspection.bo.PhotoMqttMessageBo;
import com.keystar.plane.inspection.dao.PlanePhotoVo;
import com.keystar.plane.inspection.entity.PlanePhotoEntity;
import com.keystar.plane.inspection.service.MqttService;
import com.keystar.plane.inspection.service.PhotoService;
import com.keystar.plane.inspection.service.PlanePhotoService;
import com.keystar.plane.inspection.utils.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Slf4j
@RestController
@RequestMapping(value = "/photo")
public class PhotoController {

    @Autowired
    PhotoService photoService;

    @Autowired
    PlanePhotoService planePhotoService;

    @Autowired
    MqttService mqttService;

    /**
     *  获取最新的无人机图片文件
     **/
    @GetMapping("/getNewFile")
    public NewFileBo getNewFile(){
        return FileUtil.getNewFilePath();
    }

    /**
     *  发送最新任务图片Mqtt给图像识别
     **/
    @GetMapping("/sendMqtt")
    public void sendMqtt() throws IOException, JpegProcessingException, ParseException, InterruptedException {
        mqttService.sendPhotoMqtt();
    }
}
