package com.qmth.sop.server.api;

import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.sop.business.bean.result.SopWarnMonitorResult;
import com.qmth.sop.business.service.SopWarnMonitorService;
import com.qmth.sop.common.contant.SystemConstant;
import com.qmth.sop.common.enums.CrmProgressMonitorEnum;
import com.qmth.sop.common.util.Result;
import com.qmth.sop.common.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description sop预警监控
 * @Author haoguanghui
 * @date 2024/09/12
 */
@Api(tags = "sop预警 Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_SOP_WARN_MONITOR)
public class SopWarnMonitorController {

    @Resource
    SopWarnMonitorService sopWarnMonitorService;

    @ApiOperation(value = "按大区预警统计")
    @RequestMapping(value = "/region", method = RequestMethod.POST)
    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SopWarnMonitorResult.class) })
    public Result region(@ApiParam(value = "服务单元ID", required = true) @RequestParam(required = true) Long serviceUnitId) {
        return ResultUtil.ok(sopWarnMonitorService.listWarnByRegion(serviceUnitId, CrmProgressMonitorEnum.BY_LEAD));
    }

    @ApiOperation(value = "按人力商预警统计")
    @RequestMapping(value = "/supplier", method = RequestMethod.POST)
    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SopWarnMonitorResult.class) })
    public Result supplier(@ApiParam(value = "服务单元ID", required = true) @RequestParam(required = true) Long serviceUnitId) {
        return ResultUtil.ok(sopWarnMonitorService.listWarnByRegion(serviceUnitId, CrmProgressMonitorEnum.BY_SUPPLIER));
    }

    @ApiOperation(value = "按区域协调人预警统计")
    @RequestMapping(value = "/coordinator", method = RequestMethod.POST)
    @ApiResponses({ @ApiResponse(code = 200, message = "返回信息", response = SopWarnMonitorResult.class) })
    public Result coordinator(@ApiParam(value = "服务单元ID", required = true) @RequestParam(required = true) Long serviceUnitId) {
        return ResultUtil.ok(sopWarnMonitorService.listWarnByRegion(serviceUnitId, CrmProgressMonitorEnum.BY_COORDINATOR));
    }



}
