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.FirstInspectionCountDto;
import com.tofly.watermeter.custom.service.meterBusiness.FirstInspectionService;
import com.tofly.watermeter.entity.Bwsjdatail;
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.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "表务管理-水表首检改动接口")
@AllArgsConstructor
@RequestMapping("/firstInspection")
public class FirstInspectionController {

    private final FirstInspectionService firstInspectionService;

    @GetMapping("/getInfo")
    @ApiOperation("获取未首检批次信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isCheck", value = "0,未处理，已处理 ，不传值查询全部", dataType = "string"),
            @ApiImplicitParam(name = "cal", value = "口径", dataType = "long")
    })
    public ResultRespone getInfo(Page page, String isCheck, Long cal) {
        return ResultRespone.success(firstInspectionService.getInfo(page, isCheck, cal));
    }

    @PutMapping("/firstCheck")
    @ApiOperation("水表首检")
    public ResultRespone firstCheck(Bwsjdatail bwsjdatail){
        return ResultRespone.success(firstInspectionService.firstCheck(bwsjdatail));
    }

    @GetMapping("/count")
    @ApiOperation("水表首检统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor",value = "水表厂家",dataType = "list"),
            @ApiImplicitParam(name = "export",value = "0不导出1导出",required = true,dataType = "long")
    })
    public ResultRespone count(HttpServletResponse response, FirstInspectionCountDto dto){
        return ResultRespone.success(firstInspectionService.count(response, dto));
    }

    @GetMapping("/countByCal")
    @ApiOperation("第二层，查看批次信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor",value = "水表厂家",dataType = "list"),
            @ApiImplicitParam(name = "export",value = "0不导出1导出",required = true,dataType = "long"),
            @ApiImplicitParam(name = "cal",value = "口径",required = true,dataType = "long"),
            @ApiImplicitParam(name = "state",value = "1，入库数量 2抽检总数 3待质检数 4已质检数 5合格数量 6 不合格数量",required = true,dataType = "long")
    })
    public ResultRespone  countByCal(HttpServletResponse response,Page page,FirstInspectionCountDto dto){
        return ResultRespone.success(firstInspectionService.countByCal(response, page, dto));
    }

}
