package com.huimv.eartag.controller;

import com.huimv.eartag.service.IDeviceService;
import com.huimv.eartag.vo.FarmAllStatusVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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.sql.Timestamp;
import java.text.ParseException;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.biosafety.uface.controller
 * @Description : TODO
 * @Version : 1.0
 * @Author : ZhuoNing
 * @Create : 2020-12-25
 **/
@RestController
@Slf4j
@RequestMapping(value = "/deviceController")
public class DeviceController {
    @Autowired
    private IDeviceService deviceService;

//    @GetMapping(value = "/updateFarmAllStatus")
//    public String updateFarmAllStatus(String farmId, String todayDateText, java.sql.Date todayDate, Timestamp nowTimestamp) throws ParseException {
//        System.out.println("# farmId>>"+farmId);
//        System.out.println("# todayDateText>>"+todayDateText);
//        System.out.println("# todayDate>>"+todayDate);
//        System.out.println("# nowTimestamp>>"+nowTimestamp);
//        //{更新总状态}
//        deviceService.updateEnvtempOfDeviceAllStatus(farmId, todayDateText, todayDate, nowTimestamp);
//        return "ok";
//    }

    @PostMapping(value = "/updateFarmAllStatus")
    public String updateFarmAllStatus(@RequestBody FarmAllStatusVo farmAllStatusVo) throws ParseException {
        String farmId = farmAllStatusVo.getFarmId();
        String todayDateText = farmAllStatusVo.getTodayDateText();
        java.sql.Date todayDate = farmAllStatusVo.getTodayDate();
        Timestamp nowTimestamp = farmAllStatusVo.getNowTimestamp();
        System.out.println("farmId>>"+farmId);
        System.out.println("todayDateText>>"+todayDateText);
        System.out.println("todayDate>>"+todayDate);
        System.out.println("nowTimestamp>>"+nowTimestamp);
        //{更新牧场状态}
        deviceService.updateEnvtempOfDeviceAllStatus(farmId,todayDateText,todayDate,nowTimestamp);
        return "ok";
    }
}
