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.dto.ScrapStatisticsDto;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.ImportTurnOverDto;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.TurnOverDto;
import com.tofly.watermeter.custom.service.meterBusiness.TurnOverService;
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("/turnOver")
@Api(tags = "表务管理-水表移交接口改动")
@AllArgsConstructor
public class TurnOverController {

    private final TurnOverService turnOverService;

    @GetMapping("/queryInfo")
    @ApiOperation("水表移交详情查询")
    public ResultRespone queryInfo(HttpServletResponse response, Page page, TurnOverDto dto) {
        return ResultRespone.success(turnOverService.queryInfo(response, page, dto));
    }

    @GetMapping("count")
    @ApiOperation("水表移交统计")
    @ApiImplicitParam(name = "isTimeCount",value = "0 厂家统计 1 时间统计",required = true,dataType = "long")
    public ResultRespone count(HttpServletResponse response, TurnOverDto dto) {
        return ResultRespone.success(turnOverService.count(response, dto));
    }

    @GetMapping("/canTurnOver")
    @ApiOperation("获取可移交水表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor", value = "厂家", dataType = "long"),
            @ApiImplicitParam(name = "cal", value = "口径", dataType = "long"),
            @ApiImplicitParam(name = "type", value = "类型", dataType = "long"),
            @ApiImplicitParam(name = "str", value = "水表编号模糊查询", dataType = "string")
    })
    public ResultRespone canTurnOver(Page page, TurnOverDto dto) {
        return ResultRespone.success(turnOverService.canTurnOver(page, dto));
    }

    @PostMapping("/importTurnOver")
    @ApiOperation("批量移交")
    public ResultRespone importTurnOver(@RequestBody ImportTurnOverDto dto) {
        return ResultRespone.success(turnOverService.importTurnOver(dto));
    }

    @PostMapping("/getNonEntityCode")
    @ApiOperation("获取不匹配水表编号")
    public ResultRespone getNonEntityCode(String code, String sbzt) {
        return ResultRespone.success(turnOverService.getNonEntityCode(code,sbzt));
    }

    @GetMapping("/scrapStatistics")
    @ApiOperation("报废水表统计")
    public ResultRespone scrapStatistics(ScrapStatisticsDto dto){
        return ResultRespone.success(turnOverService.scrapStatistics(dto));
    }

    @GetMapping("/scrapDetail")
    @ApiOperation("报废水表详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor", value = "厂家,多个’,‘分割", dataType = "string"),
            @ApiImplicitParam(name = "status", value = "0 全部水表 1 报废水表", dataType = "string"),
            @ApiImplicitParam(name = "startDate", value = "开始日期 yyyy-MM-dd HH:mm:ss", dataType = "date"),
            @ApiImplicitParam(name = "endDate", value = "结束日期 yyyy-MM-dd HH:mm:ss", dataType = "date"),
    })
    public ResultRespone scrapDetail(Page page, ScrapStatisticsDto dto){
        return ResultRespone.success(turnOverService.scrapDetail(page,dto));
    }

}
