package com.ruoyi.web.controller.api.csConfig;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.cs.domain.CsCompanyClass;
import com.ruoyi.cs.domain.CsOrderClass;
import com.ruoyi.cs.domain.CsProjectClass;
import com.ruoyi.cs.domain.CsResourceClass;
import com.ruoyi.cs.service.*;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;


/**
 * @Author: LCL
 * @Date: 2024/4/24
 * @Description:
 */
@Api("下拉框等配置")
@RestController
@RequestMapping("/api/cs/csConfig")
public class ApiCsConfigController extends BaseController {

    @Resource
    private ICsCompanyClassService csCompanyClassService;

    @Resource
    private ICsOrderClassService csOrderClassService;

    @Resource
    private ICsProjectClassService csProjectClassService;

    @Resource
    private ICsResourceClassService csResourceClassService;

    @Resource
    private ICsResourceOrderApplyService csResourceOrderApplyService;
    @Resource
    private ICsOrderMemberUserService csOrderMemberUserService;
    @Resource
    private ICsAchievementInfoDetailsService csAchievementInfoDetailsService;


    /**
     * 单位类别列表
     *
     * @return success
     */
    @GetMapping("/getCsCompanyClassList")
    public AjaxResult getCsCompanyClassList() {
        try {
            CsCompanyClass csCompanyClass = new CsCompanyClass();
            csCompanyClass.setDelFlag("0");
            return AjaxResult.success().put("data", csCompanyClassService.selectCsCompanyClassList(csCompanyClass));
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("单位类别列表异常");
        }
    }

    /**
     * 获取管理端工作台统计
     */
    @GetMapping( "/getStatistics")
    public AjaxResult getStatistics(String beginAt, String endAt)
    {
        Map<String,Object> map = new HashMap<>();

        map.put("HPCCPU", "10");//HPC CPU核数
        map.put("HPCMemory", "3");//HPC 内存使用量
        map.put("cloudVirtualMachine", "20");//云计算 虚拟机数量
        map.put("cloudMemory", "50");//云计算 内存
        map.put("cloudStorage", "300");//云计算 存储空间
        map.put("storageCapacity", "500");//存储 存储容量
        map.put("storageIO", "50");//存储 I/O带宽
        map.put("nodeVirtualMachine", "60");//裸节点 虚拟机数量
        map.put("nodeMemory", "20");//裸节点 内存
        map.put("nodeStorage", "512");//裸节点 存储空间
        map.put("VPNCPU", "20");//网络(VPN) CPU使用
        // 创建Random类实例
        Random random = new Random();
        // 生成一个[?, ?)之间的随机整数
        int randomNumber = random.nextInt(100);
        map.put("VPN", randomNumber+"M/S");//网络(VPN) 流量

        map.put("companyNum", "5");//新增合作单位

        //新增成果数量
        map.putAll(csAchievementInfoDetailsService.selectAchievementInfoDetailsStatistics(beginAt, endAt));
        // 查询管理端人员相关统计
        map.putAll(csOrderMemberUserService.selectUserStatistics(beginAt, endAt));
        // 查询管理端资源、工单相关统计
        map.putAll(csResourceOrderApplyService.selectResourceOrderStatistics(beginAt, endAt));

        return AjaxResult.success(map);
    }


}
