package com.ruoyi.bst.fault.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.fault.domain.FaultQuery;
import com.ruoyi.bst.fault.domain.enums.FaultStatus;
import com.ruoyi.bst.fault.domain.vo.FaultStatVO;
import com.ruoyi.bst.fault.mapper.FaultMapper;
import com.ruoyi.bst.fault.service.FaultDashboard;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.dashboard.constants.StatKeys;

@Service
public class FaultDashboardImpl implements FaultDashboard {
    
    @Autowired
    private FaultMapper faultMapper;

    @Override
    public FaultStatVO selectStat(FaultQuery query, List<String> keys) {
        FaultStatVO vo = new FaultStatVO();
        if (keys.contains(StatKeys.FAULT_PENDING_COUNT)) {
            vo.setPendingCount(this.selectPendingCount(query));
        }
        return vo;
    }

    @Override
    public Integer selectPendingCount(FaultQuery query) {
        FaultQuery pendingQuery = new FaultQuery();
        BeanUtils.copyProperties(query, pendingQuery);
        pendingQuery.setAppealStatus(FaultStatus.PENDING.getCode());
        return faultMapper.selectCount(pendingQuery);
    }
}
