package com.prolog.rdc.tms.service.impl.intransit;

import com.prolog.rdc.tms.constant.enums.InTransitPositionTypeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author hongbo.pan
 * @date 2022/9/20
 */
@Component
public class InTransitFactory {

    @Autowired
    @Qualifier("inTransitDeviceServiceImpl")
    private AbstractInTransit inTransitDeviceService;

    @Autowired
    @Qualifier("inTransitServiceImpl")
    protected AbstractInTransit inTransitService;

    @Autowired
    @Qualifier("inTransitDeviceLinkServiceImpl")
    protected AbstractInTransit inTransitDeviceLinkService;

    /**
     * getInTransitService
     * @param type
     * @return
     */
    public AbstractInTransit getInTransitService(String type) {
        if (InTransitPositionTypeEnum.DEVICE.getCode().equals(type)) {
            return inTransitDeviceService;
        } else if (InTransitPositionTypeEnum.DEVICE_LINK.getCode().equals(type)) {
            return inTransitDeviceLinkService;
        }
        return inTransitService;
    }

}
