金蝶云星空企业版 审核反写插件 亮点:只需配置好参数,代码无需改动
using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using System; using System.ComponentModel; namespace CQXR.DDL.K3.BOS.BusinessPlugIn.ServicePlugIn { [Kingdee.BOS.Util.HotUpdate] [Description("xxx模块-下推xxx--审核服务插件反写")] public class XxxxYyyy : AbstractOperationServicePlugIn { //上下游单据 参数 public string sourceid = "PNYO_8DBG";// 源单(上游)单据标识 public string sourceEntity = "F_QGXM_8DBGJUCS";// 分录ORM实体(上游) public string currentEntity = "F_QGXM_8DBGJUCS";// 分录ORM实体(下游) public string currentid = "QGXM_YZCS";// 当前(下游)单据标识 public string ydbh = "F_QGXM_YDBH";// 源单编号标识 public string ydid = "F_QGXM_YDID";// 源单id public string flid = "F_QGXM_8DBGJUCS_038";// 变更分录标识 public string check = "F_QGXM_CheckBox_iyi";// 变更分录 是否下推行 标识 public string ydhid = "F_QGXM_YDHID";// 变更分录 源单行id 标识 // 变更分录 字段 标识 public string[] field = { "F_QGXM_Text_795_vb1_jdx", "F_QGXM_Base_qku_c1c_2om", "F_QGXM_YZWCRQ_kyb", "F_QGXM_Text_h1g_391" }; // ORM实体名 字段 如果字段属性=基础资料 后面要加 _Id public string[] orm = { "F_QGXM_Text_795", "F_QGXM_Base_qku_Id", "F_QGXM_YZWCRQ", "F_QGXM_Text_h1g" }; #region 代码部分无特殊情况无需改动,只需将上下游参数配置完成即可 public override void OnPreparePropertys(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePropertysEventArgs e) { base.OnPreparePropertys(e); e.FieldKeys.Add(ydbh);//源单编号 e.FieldKeys.Add(ydid);//源单id e.FieldKeys.Add(flid);//变更分录标识 for (int k = 0; k < field.Length; k++) { e.FieldKeys.Add(field[k]); } e.FieldKeys.Add(check); e.FieldKeys.Add(ydhid); } public override void EndOperationTransaction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.EndOperationTransactionArgs e) { base.EndOperationTransaction(e); if (e.DataEntitys == null || e.DataEntitys.Length <= 0) { return; } foreach (DynamicObject dyObject in e.DataEntitys) { long FID = Convert.ToInt64(dyObject["Id"]); long FSouceID = Convert.ToInt64(dyObject[ydid]); FormMetadata Meta = (FormMetadata)MetaDataServiceHelper.Load(this.Context, currentid, true);//当前单据标识 DynamicObject ObjChange = BusinessDataServiceHelper.LoadSingle(this.Context, FID, Meta.BusinessInfo.GetDynamicObjectType()); FormMetadata EmpinfoMeta = (FormMetadata)MetaDataServiceHelper.Load(this.Context, sourceid, true);//源单据标识 DynamicObject Obj = BusinessDataServiceHelper.LoadSingle(this.Context, FSouceID, EmpinfoMeta.BusinessInfo.GetDynamicObjectType()); #region 变更明细反写 DynamicObjectCollection FEntityChange = ObjChange[currentEntity] as DynamicObjectCollection; //变更分录实体 DynamicObjectCollection FEntity = Obj[sourceEntity] as DynamicObjectCollection; //源单分录实体 for (int i = 0; i < FEntityChange.Count; i++) { if (FEntityChange[i][check].ToString().Equals("False", StringComparison.OrdinalIgnoreCase)) { DynamicObject AddEntry = new DynamicObject(FEntity.DynamicCollectionItemPropertyType); for (int k = 0; k < orm.Length; k++) { AddEntry[orm[k]] = FEntityChange[i][orm[k]]; } FEntity.Add(AddEntry); } if (FEntityChange[i][check].ToString().Equals("True", StringComparison.OrdinalIgnoreCase)) { int j = 0; bool done = false; while (!done && j < FEntity.Count) { if (FEntity[j]["Id"].ToString().Equals(FEntityChange[i][ydhid].ToString(), StringComparison.OrdinalIgnoreCase)) { for (int k = 0; k < orm.Length; k++) { FEntity[j][orm[k]] = FEntityChange[i][orm[k]]; } done = true; } j++; } } } for (int y = 0; y < FEntity.Count; y++) { FEntity[y]["Seq"] = y + 1; } #endregion BusinessDataServiceHelper.Save(this.Context, Obj); } } #endregion } }
标签:插件,QGXM,金蝶,分录,BOS,Kingdee,public,string,星空 From: https://www.cnblogs.com/wishit/p/18419546