package com.qmth.sop.server.api;

import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.sop.business.bean.result.CrmProgressResult;
import com.qmth.sop.business.service.CrmProgressMonitorService;
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 项目进度监控
 * @Author haoguanghui
 * @date 2024/09/11
 */
@Api(tags = "项目进度监控Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_CRM_PROCESS_MONITOR)
public class CrmProgressMonitorController {

    @Resource
    CrmProgressMonitorService crmProgressMonitorService;

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

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

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


}
