package cn.com.victorysoft.business.condition.service;

import cn.com.victorysoft.business.condition.dao.AbnormalUnitDao;
import cn.com.victorysoft.business.condition.dao.FlushDailyDao;
import cn.com.victorysoft.business.condition.entity.AbnormalUnit;
import cn.com.victorysoft.business.condition.entity.FlushDaily;
import cn.com.victorysoft.business.condition.param.FlushDailyParam;
import cn.com.victorysoft.business.sys.param.UnitDatePageParam;
import cn.com.victorysoft.business.sys.param.UnitDateParam;
import cn.com.victorysoft.business.util.PageUtils;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

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

@Service
public class AbnormalUnitService {

    @Resource
    private AbnormalUnitDao abnormalUnitDao;

    /**
     * 查询本单位及子单位
     */
    public List<AbnormalUnit> selectUnitChildren(UnitDatePageParam param) {
        List<AbnormalUnit> result = new ArrayList<>();
        AbnormalUnit unit = abnormalUnitDao.selectUnit(param);
        if (unit == null) {
            unit = new AbnormalUnit();
        }
        List<AbnormalUnit> children = abnormalUnitDao.selectChildren(param);
        result.add(unit);
        result.addAll(children);
        return result;
    }

    public int deleteByDate(Date date) {
        return abnormalUnitDao.deleteByDate(date);
    }

}
