package org.well.well.manager;


import org.well.well.core.hibernate.HibernateEntityDao;
import org.well.well.domain.BusWell;
import org.well.well.domain.Device;
import org.well.well.domain.DeviceWell;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BusWellManager extends HibernateEntityDao<BusWell> {

    @Resource
    DeviceManager deviceManager;
    @Resource
    DeviceWellManager deviceWellManager;

    public BusWell getWellByDevCode(String devCode) {
        try {
            Device device = deviceManager.getDeviceByDevCode(devCode);
            if (null != device) {
                DeviceWell deviceWell = deviceWellManager.getDeviceWellByDevice(device);
                if (null != deviceWell) {
                    return get(deviceWell.getWellId());
                }
            }
        }catch (Exception e ){
            e.printStackTrace();
        }
        return null;
    }

}