SysInitQuery 类是NC 参数的前后台公共服务类, 前后台使用参数的必须通过该接口调用
package nc.pubitf.para;import java.util.Map;import nc.bs.framework.common.NCLocator;
import nc.itf.uap.busibean.ISysInitGetValue;
import nc.itf.uap.busibean.ISysInitQry;
import nc.itf.uap.busibean.SysinitAccessor;
import nc.pubitf.annotation.Description;
import nc.pubitf.annotation.MethodInfo;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.para.SysInitVO;
/*** <p>* <b>参数对外服务接口(绝大多数API通过缓存访问,少数未走缓存已标明),前后台皆可调用.</b>* </p>* * @author <b>Origin(sxj) Maintainer(dengliang1)</b>* @since <b>NC5.0</b>*/
@Description("参数的前后台公共服务类, 前后台使用参数的必须通过该接口调用")
public class SysInitQuery
{/*** <b>取某一组织下UFBoolean型参数值</b>* * <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCode* 参数编码* * @return <tt>UFBoolean</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码查询逻辑型参数值", parameterName = {"pk_org", "initCode" }, parameterDescrition = { "组织主键", "参数编码" })public static nc.vo.pub.lang.UFBoolean getParaBoolean(String pk_org, String initCode) throws BusinessException{return SysinitAccessor.getInstance().getParaBoolean(pk_org, initCode);}/*** <b>取某一组织下UFDouble型参数值 如果组织主键和参数的类型不匹配,系统自动转换</b>* * <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCode* 参数编码* * @return <tt>UFDouble</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码查询UFDouble型参数值", parameterName = {"pk_org", "initCode" }, parameterDescrition = { "组织主键", "参数编码" })public static nc.vo.pub.lang.UFDouble getParaDbl(String pk_org, String initCode) throws BusinessException{return SysinitAccessor.getInstance().getParaDbl(pk_org, initCode);}/*** <b>取某一组织下Integer型参数值</b>* <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCode* 参数编码* * @return <tt>Integer</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码查询整数型参数值", parameterName = {"pk_org", "initCode" }, parameterDescrition = { "组织主键", "参数编码" })public static java.lang.Integer getParaInt(String pk_org, String initCode) throws BusinessException{return SysinitAccessor.getInstance().getParaInt(pk_org, initCode);}/***<b>取某一组织下String型参数值</b>* <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCode* 参数编码* * @return <tt>String</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码查询字符型参数值", parameterName = {"pk_org", "initCode" }, parameterDescrition = { "组织主键", "参数编码" })public static java.lang.String getParaString(String pk_org, String initCode) throws BusinessException{return SysinitAccessor.getInstance().getParaString(pk_org, initCode);}/*** <b>取某一组织下的指定批量参数值</b>* * <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCodeAry* 参数编码数组* * @return <tt>Map</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码数组批查询参数值", parameterName = {"pk_org", "initCodeAry" }, parameterDescrition = { "组织主键", "参数编码数组" })public static Map<String, String> queryBatchParaValues(String pk_org, String[] initCodeAry) throws BusinessException{return (Map<String, String>) SysinitAccessor.getInstance().queryBatchParaValues(pk_org, initCodeAry);}/*** <b>取某一组织下参数对象</b>* * <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 最明细的组织主键:如果参数组织类型不能转换那么:如果参数为组织级的,为组织主键; 如果参数为集团级的,为集团主键;* 如果参数为全局级的,为全局主键常量; 如果参数存在参数组织类型转换,那么请把pk_org设为较明细的级别主键,* 例如果存在参数存在“集团-公司”的转换关系,请传公司主键* @param initCode* 参数编码* * @return <tt>{@link SysInitVO}</tt>对象* * @throws BusinessException* * @since NC5.0*/@MethodInfo(description = "根据组织主键、参数编码查询参数VO", parameterName = { "pk_org", "initCode" }, parameterDescrition = { "组织主键", "参数编码" })public static SysInitVO querySysinitVO(String pk_org, String initCode) throws BusinessException{return SysinitAccessor.getInstance().getSysInitVO(pk_org, initCode);}/*** <b>取某一组织某一组编码的参数对象(不走缓存)</b>* * <p>* <strong>最后修改人:sxj</strong>* <p>* <strong>最后修改日期:2006-3-14</strong>* <p>* * @param pk_org* 组织主键(暂不支持组织转换情形)* @param groupCode* 组编码* * @return <tt>{@link SysInitVO[]}</tt>对象* * @throws BusinessException* * @since NC5.0*/public static SysInitVO[] querySysInit(String pk_org, String groupCode) throws BusinessException{return NCLocator.getInstance().lookup(ISysInitQry.class).querySysInit(pk_org, groupCode);}/*** <b>取某一参数代码下批量组织的参数值(不走缓存)</b>* <p>* <b>根据组织主键数据和initcode返回一个map数据结构(key-组织主键,value-参数值)</b>* </p>* * <p>* <strong>最后修改人:dengliang1</strong>* <p>* <strong>最后修改日期:2012-07-02</strong>* <p>* * @param pk_orgs* 组织主键数组,若该参数是支持组织转换模式请传入较小的组织主键(如‘集团-公司’请传入公司主键)* @param initcode* 参数代码* * @return <tt>{@link Map<String, String>}</tt>对象* * @throws BusinessException* * @since NC6.1*/public static Map<String, String> getBatchParaString(String[] pk_orgs, String initcode) throws BusinessException{return NCLocator.getInstance().lookup(ISysInitGetValue.class).getBatchParaString(pk_orgs, initcode);}/*** <b>取某一参数代码下批量组织的参数值(不走缓存)</b>* <p>* <b>根据组织主键数据和initcode返回一个map数据结构(key-组织主键,value-参数值)</b>* </p>* * <p>* <strong>最后修改人:dengliang1</strong>* <p>* <strong>最后修改日期:2012-07-02</strong>* <p>* * @param pk_orgs* 组织主键数组,若该参数是支持组织转换模式请传入较小的组织主键(如‘集团-公司’请传入公司主键)* @param initcode* 参数代码* * @return <tt>{@link Map<String, UFBoolean>}</tt>对象* * @throws BusinessException* * @since NC6.1*/public static Map<String, UFBoolean> getBatchParaBoolean(String[] pk_orgs, String initcode) throws BusinessException{return NCLocator.getInstance().lookup(ISysInitGetValue.class).getBatchParaBoolean(pk_orgs, initcode);}/*** <b>取某一参数代码下批量组织的参数值(不走缓存)</b>* <p>* <b>根据组织主键数据和initcode返回一个map数据结构(key-组织主键,value-参数值)</b>* </p>* * <p>* <strong>最后修改人:dengliang1</strong>* <p>* <strong>最后修改日期:2012-07-02</strong>* <p>* * @param pk_orgs* 组织主键数组,若该参数是支持组织转换模式请传入较小的组织主键(如‘集团-公司’请传入公司主键)* @param initcode* 参数代码* * @return <tt>{@link Map<String, Integer>}</tt>对象* * @throws BusinessException* * @since NC6.1*/public static Map<String, Integer> getBatchParaInt(String[] pk_orgs, String initcode) throws BusinessException{return NCLocator.getInstance().lookup(ISysInitGetValue.class).getBatchParaInt(pk_orgs, initcode);}/*** <b>传入sysinitvo对象,获取与其同模块同组织下的参数数组(sysinitvo本身除外)</b>* <P>* <b>(若没有结果则返回空的数组)</b>* * @param sysinitvo * 给定的参数对象* * @return SysInitVO[] * 参数对象数组* * @throws BusinessException* * @Since NC6.3*/public static SysInitVO[] querySysinitArrayUnderSpecifiedModulePkOrg(SysInitVO sysinitvo) throws BusinessException{return NCLocator.getInstance().lookup(ISysInitQry.class).querySysinitArrayUnderSpecifiedModulePkOrg(sysinitvo);}
}
比如总账调用这个接口进行封装的类:
package nc.itf.glcom.para;import nc.bs.logging.Logger;
import nc.itf.org.IOrgConst;
import nc.pubitf.para.SysInitQuery;
import nc.pubitf.uapbd.PriceAccuracyUtil;
import nc.vo.bd.currtype.CurrtypeVO;
import nc.vo.fipub.utils.StrTools;
import nc.vo.gateway60.itfs.Currency;
import nc.vo.gateway60.itfs.ICurrtypeConst;
import nc.vo.gateway60.pub.GlBusinessException;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDouble;import org.apache.commons.lang.StringUtils;/*** * <p>* 总账参数获取工具类* * 参数编码定义:GLParaCodeConst* * 参数值定义:GLParaValueConst* </p>** 修改记录:<br>* <li>修改人:修改日期:修改内容:</li>* <br><br>** @see * @author hurh* @version V6.0* @since V6.0 创建时间:2011-7-5*/
public class GLParaAccessor {/*** * 根据组织主键、参数编码查询逻辑型参数值* <p>修改记录:</p>* @param pk_org* @param code* @return* @throws BusinessException* @see * @since V6.0* @hurh*/public static UFBoolean getParaBoolean(String pk_org, String code) throws BusinessException{try {return SysInitQuery.getParaBoolean(pk_org, code);} catch (BusinessException e) {Logger.error("获取参数错误:【" + code + "】" + e.getMessage(), e);throw new BusinessException(e.getMessage(), e);}}/*** * 根据组织主键、参数编码查询字符型参数值* <p>修改记录:</p>* @param pk_org* @param code* @return* @throws BusinessException* @see * @since V6.0* @hurh*/public static String getParaString(String pk_org, String code) throws BusinessException{try {return SysInitQuery.getParaString(pk_org, code);} catch (BusinessException e) {Logger.error("获取参数错误:【" + code + "】" + e.getMessage(), e);throw new BusinessException(e.getMessage(), e);}}/*** * 根据组织主键、参数编码查询整数型参数值* <p>修改记录:</p>* @param pk_org* @param code* @return* @throws BusinessException* @see * @since V6.0* @hurh*/public static Integer getParaInt(String pk_org, String code) throws BusinessException{try {return SysInitQuery.getParaInt(pk_org, code);} catch (BusinessException e) {Logger.error("获取参数错误:【" + code + "】" + e.getMessage(), e);throw new BusinessException(e.getMessage(), e);}}/*** * 根据组织主键、参数编码查询UFDouble型参数值* <p>修改记录:</p>* @param pk_org* @param code* @return* @throws BusinessException* @see * @since V6.0*/public static UFDouble getParaDouble(String pk_org, String code) throws BusinessException{try {return SysInitQuery.getParaDbl(pk_org, code);} catch (BusinessException e) {Logger.error("获取参错误:【" + code + "】" + e.getMessage(), e);throw new BusinessException(e.getMessage(), e);}}/*** * 获取参数GL120:是否支持二级核算单位* <p>修改记录:</p>* @param accountingbook* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isSecondBUStart(String pk_org) throws BusinessException {if(pk_org == null){Logger.error("组织为空。");return UFBoolean.FALSE;}//pk_org = AccountBookUtil.getPk_orgByAccountBookPk(pk_org);return getParaBoolean(pk_org, GLParaCodeConst.IS_SECONDBUSTART);}/*** * 获取参数GL121:是否按业务单元进行平衡检查* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isBUBalanceCheck(String pk_org) throws BusinessException {return getParaBoolean(pk_org, GLParaCodeConst.IS_BUBALANCECHK);}/*** * 获取参数GL080:核销日期(凭证日期、业务日期)* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static String getVerifyDate(String pk_org) throws BusinessException {return getParaString(pk_org, GLParaCodeConst.S_VERIFYDATE);}/*** * 获取参数GL116:是否校验集团本币借贷平衡(不控制、提示、控制)* <p>修改记录:</p>* @param accountingbook* @return* @throws BusinessException* @see * @since V6.0*/public static String getGroupAmountCtrl(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_GROUPAMOUNT_BALANCECTL);}/*** * 获取参数GL118:是否校验全局本币借贷平衡(不控制、提示、控制)* <p>修改记录:</p>* @param accountingbook* @return* @throws BusinessException* @see * @since V6.0*/public static String getGlobalAmountCtrl(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_GLOBALAMOUNT_BALANCECTL);}/*** * 获取参数GL066:上月未结账本月是否能记账* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isThisMonCanTally(String pk_org) throws BusinessException{return getParaBoolean(pk_org, GLParaCodeConst.IS_TALLYENABLE_NOSETTLE);}/*** * 获取参数GL020:是否允许反关账* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isUnCloseEnable(String pk_org) throws BusinessException{return getParaBoolean(pk_org, GLParaCodeConst.IS_UNCLOSEENABLE);}/*** * 获取参数GL112:是否支持提前关账* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isPreCloseEnable(String pk_org) throws BusinessException{return getParaBoolean(pk_org, GLParaCodeConst.IS_PRECLOSEENABLE);}/*** * 获取参数NC001:集团本位币计算方式* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static String getGroupConvertModel(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_GROUPCONVERTMODEL);}/*** * 获取参数NC002:全局本位币计算方式* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static String getGlobalConvertModel(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_GLOBALCONVERTMODEL);}/*** * 组织是否启用集团本位币* <p>修改记录:</p>* @param pk_group* @return* @see * @since V6.0*/public static UFBoolean isStartGroupCurr(String pk_org){String para;try {para = getGroupConvertModel(pk_org);} catch (BusinessException e) {Logger.error(e.getMessage(), e);throw new GlBusinessException(e.getMessage(), e);}UFBoolean model = UFBoolean.valueOf(StringUtils.isNotBlank(para) && !para.equals(GLParaValueConst.GROUP_DISABLE));return model;}/*** * 是否启用全局本位币* <p>修改记录:</p>* @return* @see * @since V6.0*/public static UFBoolean isStartGlobalCurr(){String para;try {para = getGlobalConvertModel(IOrgConst.GLOBEORG);} catch (BusinessException e) {Logger.error(e.getMessage(), e);throw new GlBusinessException(e.getMessage(), e);}UFBoolean model = UFBoolean.valueOf(StringUtils.isNotBlank(para) && !para.equals(GLParaValueConst.GLOBAL_DISABLE));return model;}/*** * 获取参数GL112:(提前)关账检查内部交易对账是否完成* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isCloseCheckContrast(String pk_org) throws BusinessException{return getParaBoolean(pk_org, GLParaCodeConst.IS_CLOSECHKCONTRAST);}/*** * 获取参数GL093:辅助项为空是否显示* <p>修改记录:</p>* @param pk_org * @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isDisplayNullFree(String pk_org) throws BusinessException{return getParaBoolean(pk_org, GLParaCodeConst.IS_DISPLAYNULLFREE);}/*** * 是否允许反记账* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isUnTallyable(String pk_org) throws BusinessException{return UFBoolean.TRUE;}/*** * 获取参数GL033:检查凭证断号的环节* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static String getChkBreakNOStep(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_CHKBREAKNOSTEP);}/*** * 获取参数GL106:公有协调核算账簿* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static String getReconPk_accountingbook(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_RECONCILE);}/*** * 获取参数GL034:关账检查业务系统是否结账的财务核算账簿* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.1*/public static String getCloseChkAccBook(String pk_org) throws BusinessException{return getParaString(pk_org, GLParaCodeConst.S_CLOSECHK_ACCBOOK);}/*** * 凭证打印是否检查凭证断号* <p>修改记录:</p>* @param pk_org* @return* @throws BusinessException* @see * @since V6.0*/public static UFBoolean isPrintChkBreakNO(String pk_org) throws BusinessException{String value = getChkBreakNOStep(pk_org);if (value == null || "".equals(value)){value = GLParaValueConst.GL033_VOUCHER_PRINT;}if(GLParaValueConst.GL033_VOUCHER_PRINT.equals(value)){return UFBoolean.TRUE;}return UFBoolean.FALSE;}/*** 根据币种得到单价精度* @param pk_currtype* @return*/public static int[] getPricePrecision(String pk_currtype){Integer priceDigit = ICurrtypeConst.CURRTYPE_DEFAULT_DIGIT;Integer priceRoundMod = UFDouble.ROUND_HALF_UP;if(!StrTools.isEmptyStr(pk_currtype)&&!pk_currtype.equals("ZZZZZZZZZZZZZZZZZZZZ")){try {priceDigit = PriceAccuracyUtil.getInstance().getPriceAccuracyValuePair(pk_currtype).getPriceAccuracy();if(priceDigit==null){priceDigit = 4;}priceRoundMod = PriceAccuracyUtil.getInstance().getPriceAccuracyValuePair(pk_currtype).getRoundMode();if(priceRoundMod==null){priceRoundMod = UFDouble.ROUND_HALF_UP;}} catch (Exception e) {Logger.error(e.getMessage(), e);}}return new int[]{priceDigit, priceRoundMod};}
}
使用案例:GLParaAccessor.isSecondBUStart(pk_org);