package com.tofly.watermeter.custom.controller.meterBusiness;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.FaultSpotCheckConditionDto;
import com.tofly.watermeter.custom.service.meterBusiness.FaultSpotCheckService;
import com.tofly.watermeter.custom.vo.BwgzbcjdatailVO;
import com.tofly.watermeter.entity.Bwgzbcjdatail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/faultSpotCheck")
@Api(tags = "表务管理-故障表抽检改动接口")
@AllArgsConstructor
public class FaultSpotCheckCoutroller {

    private final FaultSpotCheckService faultSpotCheckService;

    @GetMapping("/count")
    @ApiOperation("故障表抽检统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor",value = "厂家",dataType = "list"),
            @ApiImplicitParam(name = "month",value = "年月 yyyy-mm",dataType = "string"),
            @ApiImplicitParam(name = "export",value = "0不导出1导出",required = true,dataType = "long")

    })
    public ResultRespone count(HttpServletResponse response, FaultSpotCheckConditionDto dto){
        return ResultRespone.success(faultSpotCheckService.count(response, dto));
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor",value = "厂家",dataType = "list"),
            @ApiImplicitParam(name = "month",value = "年月 yyyy-mm",dataType = "string"),
            @ApiImplicitParam(name = "export",value = "0不导出1导出",required = true,dataType = "long"),
            @ApiImplicitParam(name = "cal",value = "口径",dataType = "list"),
            @ApiImplicitParam(name = "info",value = "0查看移交信息 1查看周检记录",required = true,dataType = "long"),
            @ApiImplicitParam(name = "weekType",value = "0 查看抽检总数详情  1 查看抽检合格数  2查看抽检不合格数",required = true,dataType = "long"),

    })
    @GetMapping("/queryInfo")
    @ApiOperation("故障表详情统计")
    public ResultRespone queryInfo(Page page, HttpServletResponse response, FaultSpotCheckConditionDto dto){
        return ResultRespone.success(faultSpotCheckService.queryInfo(page, response, dto));
    }

    @PostMapping("/insertFault")
    @ApiOperation("故障表抽检")
    public ResultRespone insertFault(@RequestParam(value = "fileList", required = false)List<MultipartFile> fileList, BwgzbcjdatailVO tail){
        return ResultRespone.success(faultSpotCheckService.insertFault(fileList, tail));
    }

}
