package com.hssx.centerdata.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.QueryChainWrapper;
import com.hssx.centerdata.entity.*;
import com.hssx.centerdata.mapper.*;
import com.hssx.centerdata.service.TDataSizeInfoWarehouseUnitsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hssx.centerdata.util.HttpRespMsg;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 数据量信息_入库单位数 服务实现类
 * </p>
 *
 * @author 吴涛涛
 * @since 2019-11-15
 */
@Service
public class TDataSizeInfoWarehouseUnitsServiceImpl extends ServiceImpl<TDataSizeInfoWarehouseUnitsMapper, TDataSizeInfoWarehouseUnits> implements TDataSizeInfoWarehouseUnitsService {

    @Resource
    private TDataSizeInfoWarehouseUnitsMapper tDataSizeInfoWarehouseUnitsMapper;
    @Resource
    private TDataSizeInfoCenterStorageMapper tDataSizeInfoCenterStorageMapper;
    @Resource
    private TDataTypeStatisticsMapper tDataTypeStatisticsMapper;
    @Resource
    private TDataSizeStatisticsMapper tDataSizeStatisticsMapper;
    @Resource
    private TCatalogDataChangeNumMapper tCatalogDataChangeNumMapper;
    @Resource
    private TCatalogApiApplyMapper tCatalogApiApplyMapper;
    @Resource
    private TCatalogSupplyApplyTop5Mapper tCatalogSupplyApplyTop5Mapper;
    @Resource
    private TResourceCatalogNumMapper tResourceCatalogNumMapper;
    @Resource
    private TDatabaseConstructionMapper tDatabaseConstructionMapper;
    @Resource
    private TGeographicDatabaseMapper tGeographicDatabaseMapper;
    @Resource
    private TDataSourceMapper tDataSourceMapper;
    @Resource
    private TPhotoDatabaseDataMapper tPhotoDatabaseDataMapper;
    @Resource
    private TApplyVirtualSizeMapper tApplyVirtualSizeMapper;
    @Resource
    private TMemoryMapper tMemoryMapper;
    @Resource
    private TSystemWarningInfoMapper tSystemWarningInfoMapper;
    @Resource
    private TCpuUseRatioMapper tCpuUseRatioMapper;

    @Override
    public HttpRespMsg getCenterData() {
        HttpRespMsg msg = new HttpRespMsg();
        Map<String,Object> map = new HashMap<>();
        map.put("dataSizeInfoWarehouseUnits",tDataSizeInfoWarehouseUnitsMapper.selectOne(new QueryWrapper<TDataSizeInfoWarehouseUnits>().last("limit 1")).getWarehouseUnitsSize());//入库单位
        map.put("dataSizeInfoCenterStorageTotal",tDataSizeInfoCenterStorageMapper.selectOne(new QueryWrapper<TDataSizeInfoCenterStorage>().last("limit 1")).getConsolidatedStorageDataSize());//中心库数据总量
        map.put("dataTypeStatistics",tDataTypeStatisticsMapper.selectList(new QueryWrapper<TDataTypeStatistics>()));
        map.put("dataSizeStatistics",tDataSizeStatisticsMapper.selectList(new QueryWrapper<TDataSizeStatistics>()));
        msg.data = map;
        return msg;
    }

    @Override
    public HttpRespMsg dataExchange() {
        HttpRespMsg msg = new HttpRespMsg();
        Map<String,Object> map = new HashMap<>();
        map.put("catalogDataChangeNum",tCatalogDataChangeNumMapper.selectOne(new QueryWrapper<TCatalogDataChangeNum>().last("limit 1")));
        map.put("catalogApiApply",tCatalogApiApplyMapper.selectList(new QueryWrapper<TCatalogApiApply>().orderByAsc("show_day")));
        map.put("catalogSupplyApplyTop5",tCatalogSupplyApplyTop5Mapper.selectList(new QueryWrapper<TCatalogSupplyApplyTop5>()));
        map.put("resourceCatalogNum",tResourceCatalogNumMapper.selectList(new QueryWrapper<TResourceCatalogNum>().orderByAsc("create_time")));
        msg.data = map;
        return msg;
    }

    @Override
    public HttpRespMsg fiveMainStorehouses() {
        HttpRespMsg msg = new HttpRespMsg();
        Map<String,Object> map = new HashMap<>();
        map.put("databaseConstruction",tDatabaseConstructionMapper.selectList(new QueryWrapper<TDatabaseConstruction>()));
        map.put("geographicDatabase",tGeographicDatabaseMapper.selectList(new QueryWrapper<TGeographicDatabase>()));
        map.put("dataSource",tDataSourceMapper.selectList(new QueryWrapper<TDataSource>()));
        map.put("photoDatabaseData",tPhotoDatabaseDataMapper.selectList(new QueryWrapper<TPhotoDatabaseData>()));
        msg.data = map;
        return msg;
    }

    @Override
    public HttpRespMsg cloudPlatform() {
        HttpRespMsg msg = new HttpRespMsg();
        Map<String,Object> map = new HashMap<>();
        map.put("applyVirtualSize",tApplyVirtualSizeMapper.selectList(new QueryWrapper<TApplyVirtualSize>()));
        map.put("memory",tMemoryMapper.selectList(new QueryWrapper<TMemory>()));
        map.put("systemWarningInfo",tSystemWarningInfoMapper.selectList(new QueryWrapper<TSystemWarningInfo>()));
        map.put("cpuUseRatio",tCpuUseRatioMapper.selectList(new QueryWrapper<TCpuUseRatio>()));
        msg.data = map;
        return msg;
    }


}
