package com.tofly.xrtygis.custom.controller.dma;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.entity.dma.CostomEval;
import com.tofly.xrtygis.custom.entity.dma.CostomWarn;
import com.tofly.xrtygis.custom.entity.dma.DmawarnhandleDto;
import com.tofly.xrtygis.service.DmawarnhandleService;
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;

/**
 * @author FlashWJL
 * @date 2021/5/26 17:13
 */
@RestController
@AllArgsConstructor
@RequestMapping("/warn")
@Api(tags = "分区计量--异常分析")
public class CostomWarnController {

    private final DmawarnhandleService dmawarnhandleService;

    @GetMapping("/getWarn")
    @ApiOperation(value = "异常信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间 2021-04-30 03:59:57", required = true, dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "结束时间 2021-05-19 02:15:53", required = true, dataType = "string"),
            @ApiImplicitParam(name = "tempLate", value = "导出标识；1", required = false, dataType = "string"),
            @ApiImplicitParam(name = "warnType", value = "1：夜间最小流量异常处理；2：总分水量差异常处理", required = false, dataType = "string"),
            @ApiImplicitParam(name = "ishandle", value = "派单状态(0=待派单，1=不派单，2=已派单）", required = false, dataType = "string")
    })
    public ResultRespone getWarn(HttpServletResponse response, Page page, CostomWarn costomWarn) {
        return ResultRespone.success(dmawarnhandleService.getWarn(response, page, costomWarn));
    }


    @PostMapping("/warnHandle")
    @ApiOperation(value = "异常数据操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "异常信息ID", required = true, dataType = "string"),
            @ApiImplicitParam(name = "ishandle", value = "派单状态(1=不派单，2=已派单） ", required = true, dataType = "string"),
            @ApiImplicitParam(name = "orderTime", value = "派工时间，如果是派班则必传 ", required = false, dataType = "string")
    })
    public ResultRespone warnHandle(@RequestBody DmawarnhandleDto dmawarnhandle) {
        return ResultRespone.success(dmawarnhandleService.warnHandle(dmawarnhandle));
    }

    @GetMapping("/analyze")
    @ApiOperation(value = "异常占比分析")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "开始时间 2021-04-30 03:59:57", required = true, dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "结束时间 2021-05-19 02:15:53", required = true, dataType = "string")
    })
    public ResultRespone analyze(CostomWarn costomWarn) {
        return ResultRespone.success(dmawarnhandleService.analyze(costomWarn));
    }

    @GetMapping("/resultEval")
    @ApiOperation(value = "效果评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tempLate", value = "导出标识；1", dataType = "string"),
    })
    public ResultRespone resultEval(HttpServletResponse response, Page page, CostomEval costomEval) {
        return ResultRespone.success(dmawarnhandleService.resultEval(response, page, costomEval));
    }

    @GetMapping("/workOrderQuery")
    @ApiOperation("工单跟踪")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startTime", value = "登记开始日期 yyyy-MM-dd", dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "登记结束日期 yyyy-MM-dd", dataType = "string"),
    })
    public ResultRespone workOrderQuery(Page page, String startTime, String endTime) {
        return ResultRespone.success(dmawarnhandleService.workOrderQuery(page, startTime, endTime));
    }


}
