EAS BOS 代码获取编码规则自动生成单据编码

//相关引用类
import com.kingdee.eas.basedata.org.OrgUnitInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.bos.BOSException;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.framework.CoreBillBaseInfo;
import com.kingdee.bos.Context;
import com.kingdee.eas.base.codingrule.CodingRuleManagerFactory;
import com.kingdee.eas.base.codingrule.ICodingRuleManager;

 

//传入上下文和info
public static String getNewNumber(Context ctx,CoreBillBaseInfo info){
    String number = "";
    ICodingRuleManager iCodingRuleManager = null;
    OrgUnitInfo orgUnit = ContextUtil.getCurrentOrgUnit(ctx);
    if(orgUnit == null) return null;
    try {
        iCodingRuleManager = CodingRuleManagerFactory.getLocalInstance(ctx);
        if(iCodingRuleManager.isExist(info, orgUnit.getId().toString()))
            number = iCodingRuleManager.getNumber(info, orgUnit.getId().toString());
        else
            return null;
    } catch (EASBizException e) {
        e.printStackTrace();
    } catch (BOSException e) {
        e.printStackTrace();
    }

    return number;
}

 

你可能感兴趣的:(EAS,BOS)