package com.rongwei.bsserver.sys.controller;

import com.rongwei.bscommon.sys.service.EquDieseloilUseManagementService;
import com.rongwei.bscommon.sys.service.MaintenanceService;
import com.rongwei.bscommon.sys.utils.ExceptionUtils;
import com.rongwei.bsentity.domain.EquDieseloilUseManagementDo;
import com.rongwei.bsentity.dto.EquipmentDisposeDTO;
import com.rongwei.rwcommon.base.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 柴油使用管理
 */
@RestController
@RequestMapping("/equDieseloilUseManagement")
public class EquDieseloilUseManagementController {

    private final static Logger log = LoggerFactory.getLogger(EquDieseloilUseManagementController.class);

    @Autowired
    private EquDieseloilUseManagementService equDieseloilUseManagementService;


    /**
     * excel 上传
     * @param multipartFile
     * @return
     */
    @PostMapping("importDieseloil")
    public R uploadDieseloil(@RequestParam("file") MultipartFile multipartFile){
        try {
            log.info("进入接口：/equDieseloilUseManagement/importDieseloil,入参:{}", multipartFile);
            return equDieseloilUseManagementService.uploadDieseloil(multipartFile);
            // return null;
        }catch (Exception e){
            ExceptionUtils.printExceptionDetail(e,"导入失败，请检查后再导入:");
            return R.error(e.getMessage());
        }
    }

    /**
     * 校验重复值
     * @param equDieseloilUseManagementDos
     * @return
     */
    @PostMapping("/checkOneDateAndTenantid")
    public R checkOneDateAndTenantid(@RequestBody List<EquDieseloilUseManagementDo> equDieseloilUseManagementDos){
        try {
            log.info("进入接口：/equDieseloilUseManagement/checkOneDateAndTenantid，参数为：{}",equDieseloilUseManagementDos);
            return equDieseloilUseManagementService.checkOneDateAndTenantid(equDieseloilUseManagementDos);
        }catch (Exception e){
            ExceptionUtils.printExceptionDetail(e,"校验失败,异常为：");
            log.info(e.getMessage());
            return R.error(e.getMessage());
        }

    }
}

