package ncc.bs.arap.task;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;

import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.InvocationInfoProxy;
import nc.bs.framework.common.NCLocator;
import nc.bs.logging.Logger;
import nc.bs.pub.formulaparse.FormulaParse;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.pa.PreAlertReturnType;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.bs.uap.tools.formula.ExtFormulaParser;
import nc.impl.pubapp.env.BSContext;
import nc.impl.pubapp.pattern.database.TempTable;
import nc.itf.uap.pf.IPfExchangeService;
import nc.jdbc.framework.processor.ArrayListProcessor;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.jdbc.framework.processor.ResultSetProcessor;
import nc.md.data.access.DASFacade;
import nc.md.data.access.NCObject;
import nc.md.model.type.IType;
import nc.pub.sap.constant.SapConstants;
import nc.pubitf.arap.receivable.IArapReceivableBillPubQueryService;
import nc.pubitf.para.SysInitQuery;
import nc.util.mmf.framework.base.MMValueCheck;
import nc.util.mmf.framework.base.MMValueConvert;
import nc.util.uap.twxt.WYTwxtUtil;
import nc.vo.arap.payable.AggPayableBillVO;
import nc.vo.arap.payable.PayableBillItemVO;
import nc.vo.arap.payable.PayableBillVO;
import nc.vo.arap.receivable.AggReceivableBillVO;
import nc.vo.arap.receivable.ReceivableBillItemVO;
import nc.vo.arap.receivable.ReceivableBillVO;
import nc.vo.baseapp.jsontool.JsonTransfVOUtil;
import nc.vo.esb.ResultEsbVO;
import nc.vo.esb.ResultVO;
import nc.vo.jcom.lang.StringUtil;
import nc.vo.pf.change.ExchangeRuleVO;
import nc.vo.pf.change.PfBillMappingUtil;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.JavaType;
import nc.vo.pub.formulaset.FormulaParseFather;
import nc.vo.pub.formulaset.VarryVO;
import nc.vo.pub.lang.UFBoolean;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.tmpub.util.SqlUtil;
import nc.vo.uap.pf.PFBusinessException;
import nc.vo.uap.rbac.constant.INCSystemUserConst;
import ncc.itf.arap.synbill.IArapRecbillForNC;
	
public class RecbillNCSynToNCCTask implements IBackgroundWorkPlugin {
		
		FormulaParseFather formulaParse=new FormulaParse();
		private Map<String, Object> invocationInfoMap=null;
		// 由平台提供的一些环境变量
		protected String m_strDate = null;

		protected String m_strOperator = null;

		// protected String m_strAccountYear;

		protected String m_strGroup;

		// 系统时间
		protected String m_strNowTime;

		// 业务时间
		protected UFDateTime m_strBuziTime;

		protected UFDate m_strBuziDate;

		/** 来源单据或交易类型 */
		protected String m_sourceBilltype = null;

		/** 目的单据或交易类型 */
		protected String m_destBilltype;

		protected String m_destTranstype;
	public FormulaParseFather getFormulaParse() {
		return formulaParse;
	}
	
	@Override
	public PreAlertObject executeTask(BgWorkingContext context) throws BusinessException {
		String message="";
		try {
			setInvocationInfo();
			String nccds=InvocationInfoProxy.getInstance().getUserDataSource();
			String ncds =SysInitQuery.getParaString("GLOBLE00000000000000", "NC63DS");
			BaseDAO baseDAO=new BaseDAO();
			BaseDAO ncBaseDAO=new BaseDAO(ncds);
			String qryNCCOrgModuleSql="SELECT dapsystem_org_temp.pk_org pk_org,dapsystem_org_temp.code orgcode,nvl(org_moduleperiod.pk_accperiod,'~') ACCPERIOD FROM ( SELECT org_orgs_sub.pk_org,org_orgs_sub.code, dap_dapsystem_sub.orgtypecode, dap_dapsystem_sub.moduleid FROM ( SELECT systypecode, moduleid, systypename, parentcode, devmodule, orgtypecode, appscope, isitem, isaccount, def1, def2, def3, supportcloseaccbook, isncinnermodule, resid, nodeorder, dr, ts FROM dap_dapsystem WHERE moduleid in ('2008') and orgtypecode in ( 'FINANCEORGTYPE000000' ) ) dap_dapsystem_sub, ( SELECT pk_org,code FROM org_orgs WHERE ISBUSINESSUNIT='Y') org_orgs_sub ) dapsystem_org_temp LEFT outer JOIN org_moduleperiod ON dapsystem_org_temp.moduleid = org_moduleperiod.moduleid AND dapsystem_org_temp.pk_org = org_moduleperiod.pk_org";
			
			List orgModuleList=(List) baseDAO.executeQuery(qryNCCOrgModuleSql,new ArrayListProcessor());
			
			List<List<Object>> rows = new ArrayList<List<Object>>();
			List<Object> row=null;
			Object[] o=null;
			for(int a=0;a<orgModuleList.size();a++) {
				row=new ArrayList<Object>();
				o=(Object[]) orgModuleList.get(a);
				row.add(o[0]);
				row.add(o[1]);
				row.add(o[2]);
				rows.add(row);
			}
			InvocationInfoProxy.getInstance().setUserDataSource(ncds);
			 //创建临时表，存放从NC查出来的数据，然后跟NCC进行对比过滤
			 TempTable tempTable=new TempTable();
			 String tmptablename="tmp_nccorgaccperiod";
			 String[] columns = {
				      "pk_org","orgcode", "accperiod"
				    };
			 String[] columnTypes = {"VARCHAR2(50)", "VARCHAR2(50)","VARCHAR2(50)"};
			 
			 JavaType[] types = new JavaType[] {JavaType.String, JavaType.String,JavaType.String};
			 
			 tmptablename=tempTable.getTempTable(tmptablename, columns, columnTypes, types, rows);
			
//			 ncBaseDAO.executeQuery("select * from "+tmptablename +"", new MapProcessor());
			 
			String qryRecBillSql="SELECT DISTINCT ar.BILLNO,ar.PK_RECBILL FROM AR_RECBILL ar LEFT JOIN AR_RECITEM ai ON ar.PK_RECBILL =ai.PK_RECBILL LEFT JOIN BD_CUSTOMER bc ON ai.CUSTOMER =bc.PK_CUSTOMER LEFT JOIN ORG_ORGS org ON bc.CODE=org.CODE LEFT JOIN "+tmptablename+" accperiod ON accperiod.orgcode=org.code  WHERE  ar.APPROVESTATUS =1  and nvl(ar.dr,0)=0 and nvl(ai.dr,0)=0  AND substr(ar.APPROVEDATE,0,7)>accperiod.accperiod "
					+ "AND nvl(org.DEF56,'N') ='Y' AND org.DEF38 <>'Y'\n";
							
			
			ncBaseDAO.setMaxRows(-1);
			Map<String, String> ncBillMap=new HashMap<String, String>();
			 ncBaseDAO.executeQuery(qryRecBillSql, new ResultSetProcessor() {
				
				@Override
				public Object handleResultSet(ResultSet rs) throws SQLException {
					while(rs.next()) {
						ncBillMap.put(rs.getString(1), rs.getString(2));
					}
					return null;
				}
			});
			 qryRecBillSql="SELECT def2 FROM AP_PAYABLEBILL ap WHERE nvl(dr,0)=0 AND  DEF2 in("+SqlUtil.buildSqlConditionForIn(ncBillMap.keySet().toArray(new String[0]))+")";
			 
			 List<String> pList= (List<String>) baseDAO.executeQuery(qryRecBillSql, new ColumnListProcessor());
			 
			if(MMValueCheck.isNotEmpty(pList)) {
				for(int i=0;i<pList.size();i++) {
					if(ncBillMap.containsKey(pList.get(i))) {
						ncBillMap.remove(pList.get(i));
					}
				}
			}
			//改为NC数据源，查询NC数据
			InvocationInfoProxy.getInstance().setUserDataSource(ncds);
			IArapReceivableBillPubQueryService billPubQueryService=NCLocator.getInstance().lookup(IArapReceivableBillPubQueryService.class);
			
			AggReceivableBillVO[] receivableBillVOs=billPubQueryService.findBillByPrimaryKey(ncBillMap.values().toArray(new String[0]));
			
			if(MMValueCheck.isNotEmpty(receivableBillVOs)) {
				InvocationInfoProxy.getInstance().setUserDataSource(nccds);
				HashMap<String,ArrayList<String>>	 hConfig = JsonTransfVOUtil.getFormulas("TWF1_HEAD",SapConstants.DIRECTION_NC2SAP);
				HashMap<String,ArrayList<String>>	 bConfig = JsonTransfVOUtil.getFormulas("TWF1_BODY",SapConstants.DIRECTION_NC2SAP);
				HashMap<String, String> hTransMap=JsonTransfVOUtil.getTranNCcodes("TWF1_HEAD", SapConstants.DIRECTION_SAP2NC);//获取天问传NCC方向的配置
				HashMap<String, String> bTransMap=JsonTransfVOUtil.getTranNCcodes("TWF1_BODY", SapConstants.DIRECTION_SAP2NC);//获取天问传NCC方向的配置
				IPfExchangeService service =NCLocator.getInstance().lookup(IPfExchangeService.class);
				InvocationInfoProxy.getInstance().setUserDataSource(ncds);
				String nccgroupId =InvocationInfoProxy.getInstance().getGroupId();
				IPfExchangeService exchangeService=NCLocator.getInstance().lookup(IPfExchangeService.class);
				
				
				String wsql ="SELECT * FROM PUB_VOCHANGE_B pvb WHERE pvb.PK_VOCHANGE in(SELECT PK_VOCHANGE FROM pub_vochange WHERE (pk_busitype ='~' ) and (pk_group ='~' or pk_group = 'global00000000000000' or pk_group='0001H210000000000IGL') AND SRC_BILLTYPE ='F0' AND SRC_TRANSTYPE ='F0-Cxx-D38' AND DEST_BILLTYPE ='F1' AND nvl(dr,0)=0) AND nvl(dr,0)=0";
				
				List<ExchangeRuleVO> exchangeRuleVOs=(List<ExchangeRuleVO>) ncBaseDAO.executeQuery(wsql,new BeanListProcessor(ExchangeRuleVO.class));
				
				if(MMValueCheck.isEmpty(exchangeRuleVOs)) {
					nccloud.framework.core.exception.ExceptionUtils.wrapBusinessException("NC不存在来源交易类型F0-Cxx-D38目的单据类型F1交换规则");
				}
				List<AggPayableBillVO> aggPayableBillVOs=new ArrayList<AggPayableBillVO>();
				AggPayableBillVO changeValueObject=null;
				PayableBillVO billVO=null;
				PayableBillItemVO payableBillItemVO=null;
				List<PayableBillItemVO> payableBillItemVOs=new ArrayList<PayableBillItemVO>();
				List<String> fRules=new ArrayList<String>();
				for(AggReceivableBillVO receivableBillVO:receivableBillVOs) {
					billVO=new PayableBillVO();
					ReceivableBillVO recHVo=receivableBillVO.getHeadVO();
					ReceivableBillItemVO[] recitemVos=receivableBillVO.getBodyVOs();
					for(ExchangeRuleVO ruleVO:exchangeRuleVOs) {
						if(ruleVO.getDest_attr().startsWith("bodys.")) {
							continue;
						}
						if(ruleVO.getRuleType()==1) {
							Object sysParaObject=invocationInfoMap.get(ruleVO.getRuleData());
							if(MMValueCheck.isNotEmpty(sysParaObject)) {
								billVO.setAttributeValue(ruleVO.getDest_attr().toLowerCase(),sysParaObject);
							}
						}else if(ruleVO.getRuleType()==2) {
								billVO.setAttributeValue(ruleVO.getDest_attr().toLowerCase(),recHVo.getAttributeValue(ruleVO.getRuleData().toLowerCase()));
						}else if(ruleVO.getRuleType()==3) {
							fRules.add(ruleVO.getDest_attr() + "->" + ruleVO.getRuleData());
						}
					}
					
					for(ReceivableBillItemVO reci:recitemVos) {
						payableBillItemVO=new PayableBillItemVO();
						for(ExchangeRuleVO ruleVO:exchangeRuleVOs) {
							if(!ruleVO.getDest_attr().startsWith("bodys.")) {
								continue;
							}
							String destAttr =ruleVO.getDest_attr();
							String ruleData =ruleVO.getRuleData();
							if(ruleVO.getRuleType()==1) {
								Object sysParaObject=invocationInfoMap.get(ruleVO.getRuleData());
								if(MMValueCheck.isNotEmpty(sysParaObject)) {
									payableBillItemVO.setAttributeValue(destAttr.toLowerCase().substring(destAttr.indexOf("."), destAttr.length()),sysParaObject);
								}
							}else if(ruleVO.getRuleType()==2) {
								payableBillItemVO.setAttributeValue(destAttr.toLowerCase().substring(destAttr.indexOf(".")+1, destAttr.length()),reci.getAttributeValue(ruleData.toLowerCase().substring(ruleData.indexOf(".")+1,ruleData.length())));
							}else if(ruleVO.getRuleType()==3) {
								fRules.add(ruleVO.getDest_attr() + "->" + ruleVO.getRuleData());
							}
						}
						payableBillItemVOs.add(payableBillItemVO);
					}
					changeValueObject=new AggPayableBillVO();
					changeValueObject.setParentVO(billVO);
					changeValueObject.setChildrenVO(payableBillItemVOs.toArray(new PayableBillItemVO[0]));
					execFormulasMetaToMetaBatch(new AggregatedValueObject[] {receivableBillVO},new AggregatedValueObject[] {changeValueObject},fRules.toArray(new String[0]));
					aggPayableBillVOs.add(changeValueObject);
					fRules.clear();
				}
				
			//获取表头公式
			List<String> hformulas = hConfig.get(SapConstants.FORMULA_KEY);
			//获取表体公式
			List<String> bformulas = bConfig.get(SapConstants.FORMULA_KEY);
			
			ExtFormulaParser extFormulaParser = new ExtFormulaParser();
			
			IArapRecbillForNC recbillForNC=NCLocator.getInstance().lookup(IArapRecbillForNC.class);
			
			JSONObject reqJsonObject=null;
			JSONObject header=null;
			JSONArray bodyJsonArray=null;
			JSONObject bodyJson=null;
			
			int succCount=0;
			InvocationInfoProxy.getInstance().setProperty("ISFROMNC", UFBoolean.TRUE.toString());
			BSContext.getInstance().setSession("ISFROMNC", UFBoolean.TRUE);
			for(AggPayableBillVO vo:aggPayableBillVOs) {
				reqJsonObject=new JSONObject();
				header=new JSONObject();
				bodyJsonArray=new JSONArray();
				//改为NC数据源，查询NC数据
				InvocationInfoProxy.getInstance().setUserDataSource(ncds);
				//执行公式转换
				extFormulaParser.execFormulas(hformulas.toArray(new String[hformulas.size()]), bformulas.toArray(new String[bformulas.size()]), vo);
				//组装json，然后调用接口
				PayableBillVO headvo=vo.getHeadVO();
				PayableBillItemVO[] items=vo.getBodyVOs();
				Iterator<Entry<String, String>> it = hTransMap.entrySet().iterator();
			    while (it.hasNext()) {
			    	Entry<String, String> entry=it.next();
			    	header.put(entry.getKey(),MMValueConvert.toType(headvo.getAttributeValue(entry.getValue()), JavaType.String));
			    }
				
			    for(int b=0;b<items.length;b++) {
			    	bodyJson=new JSONObject();
			    	it = bTransMap.entrySet().iterator();
			    	while (it.hasNext()) {
			        	Entry<String, String> entry=it.next();
			        	bodyJson.put(entry.getKey(),MMValueConvert.toType(items[b].getAttributeValue(entry.getValue()), JavaType.String));
			        }
			    	bodyJsonArray.add(bodyJson);
			    }
			    reqJsonObject.put("Header", header);
			    reqJsonObject.put("Items", bodyJsonArray);
			    
			    String  reqData=WYTwxtUtil.getSendToEsbData(AppContext.getInstance().getServerTime().getMillis()+"", reqJsonObject);
			    //改为NCC数据源，查询NCC数据
				InvocationInfoProxy.getInstance().setUserDataSource(nccds);
				reqData=recbillForNC.recbillNCSynNCC_RequiresNew(reqData);
				ResultEsbVO<ResultVO> esb =JSON.parseObject(reqData,new TypeReference<ResultEsbVO<ResultVO>>() {});
				if("S".equals(esb.getEsbInfo().getReturnStatus())) {
					succCount++;
				}
			}
			message="执行总数量："+(MMValueCheck.isEmpty(aggPayableBillVOs)?"0":aggPayableBillVOs.size())+",生成成功数量："+succCount;
		}
		} catch (Exception e) {
			ExceptionUtils.wrappBusinessException(e.getCause().getMessage());
		}
		PreAlertObject msg = new PreAlertObject();
		msg.setReturnType(PreAlertReturnType.RETURNMESSAGE);
		msg.setReturnObj(message);
		msg.setMsgTitle("拉取NC63内部交易应收单同步NCC生成应付单后台任务");
		context.setLogStr(message);
		return msg;
	}
	
	public void setInvocationInfo(){
				if(MMValueCheck.isEmpty(invocationInfoMap)) {
					invocationInfoMap=new HashMap<String, Object>();
					invocationInfoMap.put("SYSDATE", (new UFDate()).toString());
					invocationInfoMap.put("SYSOPERATOR",InvocationInfoProxy.getInstance().getUserId());
					invocationInfoMap.put("SYSGROUP",InvocationInfoProxy.getInstance().getGroupId());
					invocationInfoMap.put("SYSTIME",(new UFDateTime(new Date())).toString());
					invocationInfoMap.put("BUZIDATE",new UFDate(InvocationInfoProxy.getInstance().getBizDateTime()));
					invocationInfoMap.put("BUZITIME",new UFDateTime(InvocationInfoProxy.getInstance().getBizDateTime()));
				}
	}
	
	/**
	 * 批量执行
	 * 
	 * @throws BusinessException
	 * */
	private void execFormulasMetaToMetaBatch(AggregatedValueObject[] sourceVOs,
			AggregatedValueObject[] targetVOs,String[] sFormulas) throws BusinessException {
		String[] formulas = sFormulas;
		if (formulas == null || formulas.length == 0)
			return;
		// 执行公式交换
		for (int i = 0; i < formulas.length; i++) {
			Logger.debug("**执行公式交换:" + formulas[i]);
			// 设置表达式
			getFormulaParse().setExpress(formulas[i]);
			// 获得变量
			VarryVO varry = getFormulaParse().getVarry();
			// leijun 2006-3-6 add this break
			if (varry == null)
				continue;

			execFormulaMetaToMeta2Batch(sourceVOs, targetVOs, varry);
		}

	}
	private void execFormulaMetaToMeta2Batch(AggregatedValueObject[] sourceVOs,
			AggregatedValueObject[] targetVOs, VarryVO varry)
			throws BusinessException {

		String destPath = varry.getFormulaName();
		NCObject ncObj = NCObject.newInstance(targetVOs[0]);

			parseMetaFormulaVarBatch(sourceVOs, targetVOs, varry);

			IType iType = ncObj.getRelatedBean().getAttributeByPath(destPath)
					.getDataType();

			Object[] realValues = null;
			// XXX:取得公式值
			Object[] valueObjs = getFormulaParse().getValueO();

			realValues = new Object[targetVOs.length];

			for (int i = 0; i < targetVOs.length; i++) {
				// ***从int转换为String的公式，或者去多于资源的公式，varry.getVarry().length==0,此时返回的结果数组长度只为1
				if (valueObjs.length == 1
						&& (varry.getVarry() == null || varry.getVarry().length == 0)) {
					realValues[i] = getValueByIType(valueObjs[0], iType);
				} else {
					realValues[i] = getValueByIType(valueObjs[i], iType);
				}
			}

			// 如果出错，则抛出异常
			String errStr = getFormulaParse().getError();
			if (!StringUtil.isEmptyWithTrim(errStr))
				throw new PFBusinessException(errStr);

			// XXX给目的元数据中的属性赋值 等dingxm提供批量方法，再修改此处
			for (int i = 0, end = targetVOs.length; i < end; i++) {
				NCObject _ncObj = NCObject.newInstance(targetVOs[i]);
				_ncObj.setAttributeValue(destPath, realValues[i]);
			}
	}

	private void parseMetaFormulaVarBatch(AggregatedValueObject[] sourceVOs,
			AggregatedValueObject[] targetVOs, VarryVO varry) {
		Logger.debug("**开始执行元数据公式");

		NCObject[] sourceObjs = new NCObject[sourceVOs.length];
		NCObject[] targetObjs = new NCObject[targetVOs.length];
		for (int index = 0, end = sourceObjs.length; index < end; index++) {
			sourceObjs[index] = NCObject.newInstance(sourceVOs[index]);
		}

		for (int j = 0; j < (varry.getVarry() == null ? 0
				: varry.getVarry().length); j++) {
			String var = varry.getVarry()[j];
			ArrayList<Object> values = new ArrayList<Object>();
			List<Object[]> sourceValues = null;

			if (PfBillMappingUtil.isSystemEnvField(var)) {
				// 系统变量
				Object systemValue = getEnvParamValue(var);
				for (int index = 0, end = sourceObjs.length; index < end; index++) {
					values.add(systemValue);
				}
			} else {
				sourceValues = DASFacade.getAttributeValue(
						new String[] { var }, sourceObjs);

				// 来源取不到属性，则取目的vo的相关属性
				if (sourceValues == null || sourceValues.size() == 0) {
					for (int index = 0, end = targetObjs.length; index < end; index++) {
						targetObjs[index] = NCObject
								.newInstance(targetVOs[index]);
					}
					sourceValues = DASFacade.getAttributeValue(
							new String[] { var }, targetObjs);
				}

				for (int index = 0, end = sourceObjs.length; index < end; index++) {
					if (sourceValues == null)
						// 跳出循环
						break;

					Object[] temp_sourceValue = sourceValues.get(index);
					Object sourceValue = null;
					if (temp_sourceValue != null
							&& temp_sourceValue.length != 0) {
						sourceValue = temp_sourceValue[0];
					}
					if (sourceValue instanceof Object[]) {
						Object temp = null;
						if (sourceValue != null
								&& ((Object[]) sourceValue).length == 1) {
							temp = ((Object[]) sourceValue)[0];
						}
						values.add(temp);
					} else {
						values.add(sourceValue);
					}
				}
			}

			getFormulaParse().addVariable(var, values);

		}
	}
	
	/**
	 * 将元数据的属性值转化为指定的类型
	 * 
	 * @param valueObj
	 * @param iType
	 * @return
	 */
	private Object getValueByIType(Object valueObj, IType iType) {
		if (valueObj == null)
			return null;
		Object objTarget = valueObj;
		objTarget = iType.valueOf(valueObj);
		return objTarget;
	}
	private Object getEnvParamValue(String srcField) {
		Object valueObj = null;
		if (srcField.equals(PfBillMappingUtil.ENV_NOWDATE)) {
			valueObj = m_strDate;
		} else if (srcField.equals(PfBillMappingUtil.ENV_BUZIDATE)) {
			valueObj = m_strBuziDate;
		} else if (srcField.equals(PfBillMappingUtil.ENV_LOGINUSER)) {
			valueObj = m_strOperator;
		} else if (srcField.equals(PfBillMappingUtil.ENV_LOGINGROUP)) {
			valueObj = m_strGroup;
		} else if (srcField.equals(PfBillMappingUtil.ENV_NOWTIME)) {
			valueObj = m_strNowTime;
		} else if (srcField.equals(PfBillMappingUtil.ENV_BUZITIME)) {
			valueObj = m_strBuziTime;
		} else if (srcField.equals(PfBillMappingUtil.ENV_NCSYSUSER)) {
			valueObj = INCSystemUserConst.NC_USER_PK;
		} else if (srcField.equals(PfBillMappingUtil.ENV_DEST_BILLTYPE)) {
			valueObj = m_destBilltype;
		} else if (srcField.equals(PfBillMappingUtil.ENV_DEST_TRANSTYPE)) {
			valueObj = m_destTranstype;
		}
		return valueObj;
	}
}
