package com.jpsoft.shinestar.modules.base.service.impl;

import com.jpsoft.shinestar.modules.base.dao.TotalCheckCompanyDAO;
import com.jpsoft.shinestar.modules.base.entity.CompanyInfo;
import com.jpsoft.shinestar.modules.base.entity.TotalCheckCompany;
import com.jpsoft.shinestar.modules.base.service.TotalCheckCompanyService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 墨鱼_mo
 * @date 2020-3-27 14:38
 */
@Transactional
@Component(value="totalCheckCompanyService")
public class TotalCheckCompanyServiceImpl implements TotalCheckCompanyService {

    @Resource(name = "totalCheckCompanyDAO")
    private TotalCheckCompanyDAO totalCheckCompanyDAO;

    @Override
    public int insert(TotalCheckCompany totalCheckCompany) {
        return totalCheckCompanyDAO.insert(totalCheckCompany);
    }

    @Override
    public Integer findMinNormalDay() {
        return totalCheckCompanyDAO.findMinNormalDay();
    }

    @Override
    public Integer getTotalAbnormalNum() {
        return totalCheckCompanyDAO.getTotalAbnormalNum();
    }

    @Override
    public Integer findMinNormalDayByCompanyList(List<CompanyInfo> list) {
        return totalCheckCompanyDAO.findMinNormalDayByCompanyList(list);
    }

    @Override
    public Integer getTotalAbnormalNumByCompanyList(List<CompanyInfo> list) {
        Integer total = totalCheckCompanyDAO.getTotalAbnormalNumByCompanyList(list);
        if (total == null){
            return 0;
        }else {
            return total;
        }

    }

    @Override
    public TotalCheckCompany findByCompanyId(String id) {
        return totalCheckCompanyDAO.findByCompanyId(id);
    }

    @Override
    public int update(TotalCheckCompany totalCheckCompany) {
        return totalCheckCompanyDAO.update(totalCheckCompany);
    }

    @Override
    public Integer getTotalCheckNum(List<CompanyInfo> list) {
        return totalCheckCompanyDAO.getTotalCheckNum(list);
    }

    @Override
    public List<TotalCheckCompany> findAll() {
        return totalCheckCompanyDAO.findAll();
    }

    @Override
    public Date findMaxAbnormalTimeByCompanyList(List<CompanyInfo> list) {
        return totalCheckCompanyDAO.findMaxAbnormalTimeByCompanyList(list);
    }

    @Override
    public Integer findMaxNormalDayByCompanyList(List<CompanyInfo> list) {
        Integer total = totalCheckCompanyDAO.findMaxNormalDayByCompanyList(list);
        if (total == null){
            return 0;
        }else {
            return total;
        }
    }
}
