package cn.com.ty.lift.business.maintenance.service;

import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceCompany;
import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceCompanyMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author bieao
 * @date 2019/12/12
 * @description 维保业务层
 */
@Service
public class MaintenanceService {

    @Resource
    private MaintenanceCompanyMapper maintenanceCompanyMapper;

    @Resource
    private PlatformCompanyLiftRelevanceService platformService;

    /**
     * @param mtCompanyId 维保公司id
     * @return 比较结果
     * @description 判断当前公司台量是否大于企业设置的台量
     * @date 2019/12/12 5:27 PM
     */
    public boolean judge(Long mtCompanyId) {
        //查询维保公司设置的最大电梯台量
        MaintenanceCompany company = maintenanceCompanyMapper.selectById(mtCompanyId);
        int limitedNum = company.getLimitedNum();
        //获取该公司企业电梯关联表的实际电梯台量
        int currentNum = platformService.countLiftNum(mtCompanyId);
        return limitedNum >= currentNum;
    }
}
