计划订单投放采购申请单获取辅助属性默认值

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

计划订单投放采购申请单获取辅助属性默认值

## 问题背景 目前标准产品只能从打开的表单里通过实体服务规则配置【设置弹性域缺省值】实现物料辅助属性默认值的携带。但计划订单投放采购申请单完成前过程中没有建立视图进行保存,不会触发这类依赖视图值更新或表单操作执行的规则。因此需要在计划订单投放采购申请单时补充一段获取辅助属性的缺省值处理,以完善解决投放的采购申请单取价依赖辅助属性的逻辑问题。 ## 样例插件 插件为单据转换插件,需要注册在【计划订单】转换【采购申请单】的转换规则。对这块未有了解请先阅读以下文章: ·[单据转换规则说明](https://vip.kingdee.com/questions/7439/answers/10933) ·[单据转换插件知识帖合集](https://vip.kingdee.com/article/279657956822376704) ```csharp using Kingdee.BOS.App.Core; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn; using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args; using Kingdee.BOS.Core.Metadata.FieldElement; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Kingdee.K3.BD.ServiceHelper; using Kingdee.K3.Core.MFG; using Kingdee.K3.Core.MFG.EntityHelper; using Kingdee.K3.MFG.App; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SampleAppPlugIn { public class SetDefaultFexValue : AbstractConvertPlugIn { public override void OnAfterCreateLink(CreateLinkEventArgs e) { var entrys = e.TargetExtendedDataEntities.FindByEntityKey("FEntity"); FormMetadata auxMeta = MetaDataServiceHelper.Load(this.Context, MFGFormIdConst.SubSys_BD.BD_FLEXSITEMDETAILV) as FormMetadata; List<DynamicObject> auxPropObjects = new List<DynamicObject>(); foreach (var entry in entrys) { long auxPropId = entry.DataEntity.GetDynamicValue<long>("AuxpropId_Id"); if (auxPropId > 0) continue; DynamicObject mtrl = entry.DataEntity.GetDynamicValue<DynamicObject>("MaterialId"); if (mtrl == null) continue; DynamicObjectCollection mtrlAuxProps = mtrl["MaterialAuxPty"] as DynamicObjectCollection; if (mtrlAuxProps.IsEmpty() || mtrlAuxProps.Any(x => x.GetDynamicValue<bool>("IsEnable1") == true) == false) { continue; } string mtrlId = entry.DataEntity.GetDynamicValue<string>("MaterialId_Id"); var defPropertyValues = BDFlexServiceHelper.GetAuxPtyValueDefInfo(this.Context, mtrlId, ""); if (defPropertyValues.IsEmpty()) continue; DynamicObject auxPropObject = entry.DataEntity.GetDynamicValue<DynamicObject>("AuxpropId"); if (auxPropObject == null) { auxPropObject = new DynamicObject(auxMeta.BusinessInfo.GetDynamicObjectType()); auxPropObjects.Add(auxPropObject); foreach (var defPV in defPropertyValues) { string fflexNumber = defPV.GetDynamicValue<string>("FFlexNumber"); Field f = auxMeta.BusinessInfo.GetField(fflexNumber); auxPropObject.SetDynamicObjectItemValue(f.PropertyName + "_Id", defPV["FDefValueId"]); } entry.DataEntity.SetDynamicObjectItemValue("AuxpropId", auxPropObject); } } if (!auxPropObjects.IsEmpty()) { DBServiceHelper.LoadReferenceObject(this.Context, auxPropObjects.ToArray(), auxMeta.BusinessInfo.GetDynamicObjectType(), false); FlexSaveService sv = new FlexSaveService(this.Context, "Save"); MFGFlexHelperUtil.SaveFlexFixedColumn(this.Context, e.TargetBusinessInfo, e.TargetExtendedDataEntities.FindByEntityKey("FBillHead").Select(x => x.DataEntity).ToArray()); } } } } ``` ```python import clr clr.AddReference('Kingdee.K3.MFG.ServiceHelper') clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.K3.BD.ServiceHelper') clr.AddReference('Kingdee.K3.MFG.App') clr.AddReference('System') from Kingdee.K3.BD.ServiceHelper import BDFlexServiceHelper from Kingdee.BOS.ServiceHelper import DBServiceHelper from Kingdee.BOS.ServiceHelper import MetaDataServiceHelper from Kingdee.K3.MFG.App import MFGFlexHelperUtil from Kingdee.BOS.Orm.DataEntity import DynamicObject from System.Collections.Generic import List from System import Int64 def OnAfterCreateLink(e): auxMeta = MetaDataServiceHelper.Load(this.Context, 'BD_FLEXSITEMDETAILV') auxPropObjects = List[DynamicObject]() entrys = e.TargetExtendedDataEntities.FindByEntityKey("FEntity") for entry in entrys: auxPropId = entry.DataEntity["AuxpropId_Id"] if auxPropId > 0: continue mtrl = entry.DataEntity["MaterialId"] if mtrl is None: continue mtrlAuxProps = mtrl["MaterialAuxPty"] if mtrlAuxProps is None or mtrlAuxProps.Count==0: continue if len(filter(lambda x:x['IsEnable1']==True,mtrlAuxProps))<=0: continue mtrlId = entry.DataEntity["MaterialId_Id"] defPropertyValues = BDFlexServiceHelper.GetAuxPtyValueDefInfo(this.Context, str(mtrlId), "") if defPropertyValues is None or defPropertyValues.Count==0: continue auxPropObject = entry.DataEntity["AuxpropId"] if auxPropObject is None: auxPropObject = DynamicObject(auxMeta.BusinessInfo.GetDynamicObjectType()) auxPropObjects.Add(auxPropObject) for defPV in defPropertyValues: fflexNumber = defPV["FFlexNumber"] f=auxMeta.BusinessInfo.GetField(fflexNumber) auxPropObject[f.PropertyName+"_Id"]=defPV["FDefValueId"] entry.DataEntity["AuxpropId"]=auxPropObject if auxPropObjects.Count>0: DBServiceHelper.LoadReferenceObject(this.Context, auxPropObjects.ToArray(), auxMeta.BusinessInfo.GetDynamicObjectType(), False) datas=List[DynamicObject]() for data in e.TargetExtendedDataEntities.FindByEntityKey("FBillHead"): datas.Add(data.DataEntity) MFGFlexHelperUtil.SaveFlexFixedColumn(this.Context, e.TargetBusinessInfo, datas.ToArray()) ```

计划订单投放采购申请单获取辅助属性默认值

## 问题背景目前标准产品只能从打开的表单里通过实体服务规则配置【设置弹性域缺省值】实现物料辅助属性默认值的携带。但计划订单投放采购...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息