package com.chinaitop.depot.intelligent.comprehensive.service.impl;

import com.chinaitop.depot.intelligent.comprehensive.service.ComprehensiveService;
import com.chinaitop.depot.intelligent.utils.ParameterUtil;
import com.chinaitop.depot.intelligent.ventilation.mapper.TVentilationMapper;
import com.chinaitop.depot.intelligent.ventilation.model.TVentilation;
import com.chinaitop.depot.intelligent.ventilation.model.TVentilationExample;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

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

@Service
public class ComprehensiveServiceImpl implements ComprehensiveService {
    @Resource
    private TVentilationMapper tVentilationMapper;

    @Override
    public List<TVentilation> getList(String vCfCode, String vDistinguishState,String orgId) {
        TVentilationExample example = new TVentilationExample();
        TVentilationExample.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotBlank(vCfCode)) {
            criteria.andVCfCodeEqualTo(vCfCode);
        }
        if (StringUtils.isNotBlank(vDistinguishState)) {
            criteria.andVDistinguishStateEqualTo(Integer.valueOf(vDistinguishState));
        }
        if (ParameterUtil.isnotnull(orgId)) {
            criteria.andOrgIdEqualTo(orgId);
        }
        example.setOrderByClause("v_start_time desc");
        return tVentilationMapper.selectByExample(example);
    }

    @Override
    public TVentilation getById(String id) {
        TVentilation tVentilation = tVentilationMapper.selectByPrimaryKey(id);
        return tVentilation;
    }
}
