package com.tofly.watermeter.custom.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.custom.service.CustomWaterGisService;
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.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 陈浩
 * @date 2020/4/9
 */
@Api(tags = "gis调用水表接口")
@RestController
@AllArgsConstructor
@RequestMapping("/waterGis")
public class CustomWaterGisController {

    private final CustomWaterGisService customWaterGisService;

    /**
     * 停水区域查询
     */
    @GetMapping("/viewWaterCut")
    @ApiOperation("停水区域查询")
    public Page viewWaterCut(@SpringQueryMap Page page, @RequestParam("valveId") String valveId){
        return customWaterGisService.viewWaterCut(page,valveId);
    }

    @GetMapping("viewUseWater")
    @ApiOperation("客户用水量查询")
    @ApiImplicitParams(
            @ApiImplicitParam(name = "khbh",value = "客户编号",required = true,dataType = "string")
    )
    public Page viewUseWater(Page page,String khbh){
        return customWaterGisService.viewUseWater(page,khbh);
    }

    /**
     * 水表关联查询
     */
    @GetMapping("/viewWater")
    @ApiOperation("水表关联查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "khbh",value = "客户编号",dataType = "string"),
            @ApiImplicitParam(name = "yhxm",value = "用户姓名",dataType = "string"),
            @ApiImplicitParam(name = "yhdz",value = "用户地址",dataType = "string")
    })
    public Page<Map> viewWater( Page page, String khbh,String yhxm,String yhdz){
        return customWaterGisService.viewWater(page,khbh,yhxm,yhdz);
    }

    @GetMapping("/waterMonitoring")
    @ApiOperation("用水监控")
    @ApiImplicitParam(name = "code",value = "客户编号/姓名/地址",required = true,dataType = "string")
    public Page waterMonitoring(Page page, String code){
        return customWaterGisService.waterMonitoring(page,code);
    }

/*  系统暂无使用，先注释   @GetMapping("/waterMonitoring")
    @ApiOperation("用水监控")
    public Page waterMonitoring(Page page){
        return customWaterGisService.waterMonitoring(page);
    }*/

    @GetMapping("/useWaterHistory")
    @ApiOperation("查看用户用水历史")
    public Page useWaterHistory(Page page,@RequestParam("khbh") String khbh,@RequestParam("startTime")String startTime,@RequestParam("endTime")String endTime){
        return customWaterGisService.useWaterHistory(page,khbh,startTime,endTime);
    }

    @GetMapping("/numberGetInfo")
    @ApiOperation("查看水表信息")
    @ApiImplicitParam(name = "number",value = "水表编号",required = true,dataType = "string")
    public ResultRespone numberGetInfo(String number){
        return ResultRespone.success(customWaterGisService.numberGetInfo(number));
    }

    @GetMapping("/likeNumber")
    @ApiOperation("模糊查询水表编号")
    public ResultRespone likeNumber(String str){
        return ResultRespone.success(customWaterGisService.likeNumber(str));
    }
}
