package com.qmth.sop.server.api;

import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.sop.business.service.DeviceMonitorService;
import com.qmth.sop.common.contant.SystemConstant;
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;
import java.util.List;
import java.util.Map;

/**
 * 设备保障监控 控制器
 *
 * @author: shudonghui
 * @date: 2023-08-14 15:55:18
 * @version: 1.0
 * @email: shudonghui@qmth.com.cn
 * @Company: www.qmth.com.cn
 */
@Api(tags = "设备保障监控 Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DEVICE + "/monitor")
public class DeviceMonitorController {


    @Resource
    DeviceMonitorService deviceMonitorService;

    
    @ApiOperation(value = "库存监控统计接口")
    @RequestMapping(value = "/count", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "库存监控统计", response = Map.class)})
    public Result count(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId,
                        @ApiParam(value = "型号", required = false) @RequestParam(required = false) String model
    ) {
        Map<String, Object> map = deviceMonitorService.count(supplierId, model);

        return ResultUtil.ok(map);
    }

    //按型号统计状态明细
    
    @ApiOperation(value = "按型号统计状态明细")
    @RequestMapping(value = "/countByModel", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "按型号统计状态明细", response = List.class)})
    public Result countByModel(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId) {
        List<Map<String, Object>> list = deviceMonitorService.countByModel(supplierId);

        return ResultUtil.ok(list);
    }

    //按服务单元统计设备状态
    
    @ApiOperation(value = "按服务单元统计设备状态")
    @RequestMapping(value = "/countByServiceUnit", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态", response = Map.class)})
    public Result countByServiceUnit() {
        Map<String, Object> map = deviceMonitorService.countByServiceUnit();
        return ResultUtil.ok(map);
    }
    //按服务单元统计设备状态明细
    
    @ApiOperation(value = "按服务单元统计设备状态明细")
    @RequestMapping(value = "/countByServiceUnitDetail", method = RequestMethod.POST)
    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态明细", response = List.class)})
    public Result countByServiceUnitDetail() {
        List<Map<String, Object>> list = deviceMonitorService.countByServiceUnitDetail();
        return ResultUtil.ok(list);
    }

}