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.common.log.annotation.ToFlyAppLog;
import com.tofly.watermeter.custom.entity.CustomSearch;
import com.tofly.watermeter.custom.service.ZySbInfoService;
import com.tofly.watermeter.entity.*;
import com.tofly.watermeter.service.BwcjblService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author by Wangjieliu
 * @date 2021/3/17.
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sbcheck")
@Api(tags = "表务--水表检定接口")
public class SbCheckController {
    
    private final ZySbInfoService checkService;
    private final BwcjblService bwcjblService;
    /**
     * 新增水表首检比例配置表
     * @param bwcjbl 水表抽检比例配置表
     * @return ResultRespone
     */
    //="新增水表首检比例配置表" )
    @ApiOperation(value = "新增水表首检比例配置表")
    @PostMapping("/sjconfig")
    public ResultRespone insertConfig(@RequestBody TfYwpnBwsjblgl bwcjbl) {
        //这里配置插入之前，需要查询一下配置表中有没有该口径的比例配置
        return ResultRespone.success(checkService.insert(bwcjbl));
    }
    /**
     * 获取首检比例列表
     * @param page
     * @param sjbl
     * @return
     */
    @ApiOperation(value = "获取首检比例列表")
    @GetMapping("/sjconfig")
    public ResultRespone getConfig(Page page,TfYwpnBwsjblgl sjbl) {
        return ResultRespone.success(checkService.getConfig(page,sjbl));
    }
    //="首检比例修改" )
    @ApiOperation(value = "首检比例修改")
    @PostMapping("/sjupdate")
    public ResultRespone updateConfig(@RequestBody TfYwpnBwsjblgl sjbl) {
        return ResultRespone.success(checkService.updateConfig(sjbl));
    }

    @ApiOperation(value = "首检比例删除")
    @DeleteMapping("/sjdelete/{sbkj}")
    public ResultRespone deleteConfig(@PathVariable("sbkj") Long sbkj) {
        return ResultRespone.success(checkService.deleteConfig(sbkj));
    }

    @ApiOperation(value = "抽检比例修改(水表移交后抽检)")
    @PostMapping("/updateCjblConfig")
    public ResultRespone updateCjblConfig(@RequestBody Bwcjbl bwcjbl) {
        return ResultRespone.success(bwcjblService.updateCjblConfig(bwcjbl));
    }


    @ApiOperation(value = "抽检比例查看(水表移交后抽检)")
    @GetMapping("/getCjblConfig")
    public ResultRespone getCjblConfig(Page<Bwcjbl> page,Bwcjbl bwcjbl) {
        return ResultRespone.success(bwcjblService.getCjblConfig(page , bwcjbl));
    }




    /**
     * 争议检定
     * @param bwzysbjddatail
     * @param request
     * @return
     */
    //="争议检定结果录入" )
    @ApiOperation(value = "争议检定结果录入")
    @PutMapping(value = "/dispute",headers = "content-type=multipart/form-data")
    public ResultRespone insertZyjg(Bwzysbjddatail bwzysbjddatail, HttpServletRequest request) {
        return ResultRespone.success(checkService.insertZyjg(bwzysbjddatail,request));
    }


//    /**
//     * 新增争议检定
//     * @param bwzysbjddatail 水表争议记录表
//     * @return ResultRespone
//     */
//    //="新增争议检定" )
//    @ApiOperation(value = "新增争议检定")
//    @PostMapping("/dispute")
//    public ResultRespone insertZy(@RequestBody Bwzysbjddatail bwzysbjddatail) {
//        return ResultRespone.success(checkService.insertZy(bwzysbjddatail));
//    }

    /**
     * 获取争议检定列表
     * @param page
     * @param bwzysbjddatail
     * @return
     */
    //="争议检定列表")
    @ApiOperation(value = "争议检定列表")
    @GetMapping("/dispute")
    public ResultRespone getZy(Page page,Bwzysbjddatail bwzysbjddatail) {
        return ResultRespone.success(checkService.getZy(page,bwzysbjddatail));
    }
    /**
     *
     * @param id
     * @return
     */
    //="删除争议检定" )
    @ApiOperation(value = "删除争议检定")
    @DeleteMapping("/dispute/{id}")
    public ResultRespone deleteZy(@PathVariable("id") Long id) {
        return ResultRespone.success(checkService.deleteZy(id));
    }
    /**
     * 新增水表抽检
     * @return
     */
    //="新增水表抽检(周检)" )
    @ApiOperation(value = "新增水表抽检(周检)")
    @PostMapping("/spotcheck")
    public ResultRespone insertSpot(@RequestBody Bwzjbcjdatail bwzjbcjdatail) {
        return ResultRespone.success(checkService.insertSpot(bwzjbcjdatail));
    }
    /**
     * 抽检水表查看
     * @return
     */
    //="查看抽检(周检)水表列表" )
    @ApiOperation(value = "查看抽检(周检)水表列表")
    @GetMapping("/spotcheck")
    public ResultRespone getSpot(Page page, CustomSearch search) {
        return ResultRespone.success(checkService.getSpot(page,search));
    }

    //="根据ID删除抽检" )
    @ApiOperation(value = "根据ID删除抽检")
    @DeleteMapping("/spotcheck")
    public ResultRespone delSpot(Long id) {
        return ResultRespone.success(checkService.delSpot(id));
    }

    /**
     * 拆检记录填写
     * @param bwgzbcjdatail
     * @param request
     * @return
     */
    //="填写拆检记录" )
    @ApiOperation(value = "填写拆检记录")
    @PostMapping(value = "/excreterecord",headers = "content-type=multipart/form-data")
    public ResultRespone excreteRecord(Bwgzbcjdatail bwgzbcjdatail, HttpServletRequest request) {
        return ResultRespone.success(checkService.insertExcrete(bwgzbcjdatail,request));
    }
    /**
     * 分页查询拆检记录
     * @param search
     * @return
     */
    //="拆检记录分页查询" )
    @ApiOperation(value = "拆检记录分页查询")
    @GetMapping(value = "/excreterecord")
    public ResultRespone getExcrete(Page page, CustomSearch search) {
        return ResultRespone.success(checkService.getExcrete(page,search));
    }

    /**
     * 删除拆检记录
     * @param id 拆检记录ID
     * @return
     */
    //="删除拆检记录" )
    @ApiOperation(value = "删除拆检记录")
    @DeleteMapping(value = "/excreterecord")
    public ResultRespone delExcrete(Long id) {
        return ResultRespone.success(checkService.delExcrete(id));
    }





//    /**
//     * 修改水表抽检比例配置表
//     * @param bwcjbl 水表抽检比例配置表
//     * @return ResultRespone
//     */
//    //="修改水表抽检比例配置表" )
//    @ApiOperation(value = "修改水表抽检比例配置表")
//    @PutMapping
//    public ResultRespone updateById(@RequestBody Bwcjbl bwcjbl) {
//        return ResultRespone.success(checkService.updateById(bwcjbl));
//    }







}
