package com.casic.missiles.controller.cockpit;

import com.casic.missiles.dto.ReturnDTO;
import com.casic.missiles.dto.ReturnUtil;
import com.casic.missiles.dto.cockpit.*;
import com.casic.missiles.model.equipment.EquipmentFixedAssets;
import com.casic.missiles.model.equipment.EquipmentStandardEquipment;
import com.casic.missiles.service.cockpit.IAssetMonitorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: 计量管理驾驶舱-资产监控
 * @Author: wangpeng
 * @Date: 2023/6/5 15:52
 */
@Api(tags = "计量管理驾驶舱-资产监控")
@Slf4j
@RestController
@RequestMapping("/cockpit/asset/monitor")
public class AssetMonitorController {
    @Autowired
    private IAssetMonitorService assetMonitorService;

    @ApiOperation("资产管理-设备总数、装置总数、能力总数")
    @GetMapping("/assetManagement")
    public ReturnDTO<AssetManagementResponse> assetManagement() {
        return ReturnUtil.success(assetMonitorService.assetManagement());
    }

    /**
     * 改成只展示在用设备、闲置设备、封存设备
     */
    @ApiOperation("计量设备-在用设备、闲置设备、封存设备")
    @GetMapping("/equipment")
    public ReturnDTO<EquipmentResponse> equipment() {
        return ReturnUtil.success(assetMonitorService.equipment());
    }

    @ApiOperation("本年各月设备到期数量")
    @GetMapping("/expireDeviceStatistics")
    public ReturnDTO<List<ExpireDeviceStatisticsResponse>> expireDeviceStatistics() {
        return ReturnUtil.success(assetMonitorService.expireDeviceStatistics());
    }

    @ApiOperation("本月设备到期详情")
    @GetMapping("/expireDeviceList")
    public ReturnDTO<EquipmentFixedAssets> expireDeviceList() {
        return ReturnUtil.success(assetMonitorService.expireDeviceList());
    }

    /**
     * 使用部门综合分析中各比率平均数
     */
    @ApiOperation("设备检定")
    @GetMapping("/deviceMeasure")
    public ReturnDTO<DeviceMeasureResponse> deviceMeasure() {
        return ReturnUtil.success(assetMonitorService.deviceMeasure());
    }

    /**
     * 改成只展示在用装置、暂停装置、撤销装置
     */
    @ApiOperation("标准装置-在用装置、暂停装置、撤销装置")
    @GetMapping("/standardEquipment")
    public ReturnDTO<StandardEquipmentResponse> standardEquipment() {
        return ReturnUtil.success(assetMonitorService.standardEquipment());
    }

    // TODO: 2023/6/26 该接口数据需质量模块中的证书支持，目前使用remind_time统计不正确，待后续修改
    @ApiOperation("本年各月装置到期数量")
    @GetMapping("/expireEquipmentStatistics")
    public ReturnDTO<List<ExpireEquipmentStatisticsResponse>> expireEquipmentStatistics() {
        return ReturnUtil.success(assetMonitorService.expireEquipmentStatistics());
    }

    @ApiOperation("本月装置到期详情")
    @GetMapping("/expireEquipmentList")
    public ReturnDTO<EquipmentStandardEquipment> expireEquipmentList() {
        return ReturnUtil.success(assetMonitorService.expireEquipmentList());
    }
}
