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.WeekSpotCheckConditionDto;
import com.tofly.watermeter.custom.service.meterBusiness.WeekSpotCheckService;
import com.tofly.watermeter.custom.vo.BwzjbcjdatailVO;
import com.tofly.watermeter.entity.Bwzjbcjdatail;
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 javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/weekSpotCheck")
@AllArgsConstructor
@Api(tags = "表务管理-周检表抽检接口优化")
public class WeekSpotCheckController {

    private final WeekSpotCheckService weekSpotCheckService;

    @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, WeekSpotCheckConditionDto dto) {
        return ResultRespone.success(weekSpotCheckService.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, WeekSpotCheckConditionDto dto) {
        return ResultRespone.success(weekSpotCheckService.queryInfo(page, response, dto));
    }

    @PostMapping("/insertWeek")
    @ApiOperation("添加周检")
    public ResultRespone insertWeek(@RequestBody BwzjbcjdatailVO tail) {
        return ResultRespone.success(weekSpotCheckService.insertWeek(tail));
    }

    @GetMapping("/getTurnOverTable")
    @ApiOperation("获取已移交水表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "移交类型", required = true, dataType = "string"),
            @ApiImplicitParam(name = "vendor", value = "厂家", dataType = "long"),
            @ApiImplicitParam(name = "cal", value = "口径", dataType = "long"),
            @ApiImplicitParam(name = "tableType", value = "水表类型", dataType = "long"),
            @ApiImplicitParam(name = "dto", value = "水表编号", dataType = "string")
    })
    public ResultRespone getTurnOverTable(Page page, Long type, Long vendor, Long cal, Long tableType, String dto, String lsbh) {
        return ResultRespone.success(weekSpotCheckService.getTurnOverTable(page, type, vendor, cal, tableType, dto, lsbh));
    }

    @GetMapping("/getCheckNum")
    @ApiOperation("获取待抽检数据")
    public ResultRespone getCheckNum(String lsbh, Long cal, Long yjlx,String tableName) {
        return ResultRespone.success(weekSpotCheckService.getCheckNum(lsbh, cal, yjlx,tableName));
    }

}
