package com.bonus.zlpt.bigscreen.service.impl;

import com.bonus.zlpt.bigscreen.domain.vo.*;
import com.bonus.zlpt.bigscreen.mapper.BmCompanyInfoMapper;
import com.bonus.zlpt.bigscreen.service.BmCompanyInfoService;
import com.bonus.zlpt.company.api.enums.CompanyTypeEnum;
import com.bonus.zlpt.equip.api.enums.MaStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 企业信息表(BmCompanyInfo)表服务实现类
 *
 * @author makejava
 * @since 2023-11-30 15:01:48
 */
@Service("bmCompanyInfoService")
public class BmCompanyInfoServiceImpl implements BmCompanyInfoService {

    @Autowired
    private BmCompanyInfoMapper bmCompanyInfoMapper;

    /**
     * 根据企业类型查询对应数量
     * @param
     * @return
     */
    @Override
    public List<CoTypeVo> selectTypeList() {
        List<CoTypeVo> list = bmCompanyInfoMapper.selectTypeList();
        ArrayList<CoTypeVo> typeVos = new ArrayList<>();
        for (CoTypeVo coTypeVo : list) {
            coTypeVo.setCoType(CompanyTypeEnum.getNameByCode(Integer.parseInt(coTypeVo.getCoType())));
            typeVos.add(coTypeVo);
        }
        return typeVos;
    }

    /**
     * 根据企业类型所属查询设备类型数量及经纬度
     * @return
     */
    @Override
    public List<ColtdTypeVo> selectColtdList() {
        List<ColtdTypeVo> list = bmCompanyInfoMapper.selectColtdList();
        ArrayList<ColtdTypeVo> coltdTypeVos = new ArrayList<>();
        for (ColtdTypeVo coltdTypeVo : list) {
            coltdTypeVo.setMaStatus(MaStatusEnum.getNameByCode(Integer.parseInt(coltdTypeVo.getMaStatus())));
            coltdTypeVo.setCompanyType(CompanyTypeEnum.getNameByCode(Integer.parseInt(coltdTypeVo.getCompanyType())));
            coltdTypeVos.add(coltdTypeVo);
        }
        return coltdTypeVos;
    }

    /**
     * 根据时间查询设备历史经纬度
     * @param
     * @return
     */
    @Override
    public List<LatVo> selectTimeList(String beginTime, String endTime, String maId) {
        return bmCompanyInfoMapper.selectTimeList(beginTime, endTime, maId);
    }
}

