/// <summary> /// 生成母单号 /// </summary> /// <param name="billData"></param> /// <returns></returns> /// <exception cref="Exception"></exception> public void CreateMuOrderNo(DynamicObject billData) { string F_JNXM_MuOrderNum = billData["F_JNXM_MuOrderNum"].GetStringJNXM(); if (F_JNXM_MuOrderNum == "")//母单号为空 { string CITY_Num = ""; var BD_CUSTOMEREXT = billData["BD_CUSTOMEREXT"] as DynamicObjectCollection; if (BD_CUSTOMEREXT != null && BD_CUSTOMEREXT.Count > 0) { string CITY_Id = BD_CUSTOMEREXT.First()["CITY_Id"].GetStringJNXM(); CITY_Num = Synthesize.GetAuxiliaryFiledValue(this.Context, CITY_Id, "F_JNXM_Selfdefine1").Trim(); } string F_JNXM_County_Id = billData["F_JNXM_County_Id"].GetStringJNXM(); string F_JNXM_County_Num = Synthesize.GetAuxiliaryFiledValue(this.Context, F_JNXM_County_Id, "F_JNXM_Selfdefine1").Trim(); if (CITY_Num != "" && F_JNXM_County_Num != "") { billData["F_JNXM_CityCountyNum"] = CITY_Num + F_JNXM_County_Num;//更新城市区县编码组合 //获取自动编码 var BillCodeRule = Synthesize.GetDataValue(this.Context, "BOS_BillCodeRuleRuntime", "FName = '客户母单号编码规则'"); if (BillCodeRule != null) { string Number = billData["Number"].GetStringJNXM();//保存原来的编码 billData["Number"] = ""; BusinessDataService dataService = new BusinessDataService(); FormMetadata metadata = (FormMetadata)AppServiceContext.MetadataService.Load(this.Context, "BD_Customer"); var businInfo = metadata.BusinessInfo; bool isUpdateMax = true; var dataObjs = new DynamicObject[] { billData }; string specifiedRuleId = Convert.ToString(BillCodeRule["Id"]);//编码规则 var billNoList = dataService.GetBillNo(Context, businInfo, dataObjs, isUpdateMax, specifiedRuleId); billData["F_JNXM_MuOrderNum"] = billNoList[0].BillNo; billData["Number"] = Number;//恢复原来的编码 } else { throw new KDBusinessException("", "未配置客户母单号编码规则"); } } else { throw new KDBusinessException("", "请在辅助资料类别【市\\区】的【自定义字段1】中配置对应的编码"); } } }
标签:编码,CITY,string,自定义,billData,JNXM,单据,Num From: https://www.cnblogs.com/zouhuaxin/p/17891125.html