package com.glxp.mipsdl.service.auth;

import cn.hutool.core.util.ReflectUtil;
import com.glxp.mipsdl.config.ThirdSysConfig;
import com.glxp.mipsdl.entity.auth.AuthWarehouseEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Field;

/**
 * 仓库相关Service
 */
@Service
public class AuthWarehouseService {

    @Resource
    private ThirdSysConfig thirdSysConfig;

    /**
     * 获取当前医院对应的第三方系统的仓库ID
     *
     * @param authWarehouseEntity
     * @return
     */
    public String getThirdInvCode(AuthWarehouseEntity authWarehouseEntity) {
        //通过反射，获取到当前第三方系统ID对应的第三方系统仓库编码
        Field field = ReflectUtil.getField(AuthWarehouseEntity.class, thirdSysConfig.getThirdId());
        String thirdInvCode = String.valueOf(ReflectUtil.getFieldValue(authWarehouseEntity, field));
        return thirdInvCode;
    }


}
