插件构造数据包调用保存操作不触发批号保存服务问题排查
一、【问题现象】
自定义的BOS单据在保存操作上配置了保存并更新批号主档服务,前台手工新增单据点保存时,该服务会执行,
但是插件生成的单据不会执行保存并更新批号主档服务,批号ID没有。插件中批号的赋值方式是用entry['Lot_Text'] = 'ABC'这种方式赋的,保存调用的标准服务BusinessDataServiceHelper.Save(Context, realOrderMetaData.BusinessInfo, bill, OperateOption.Create(), 'Save')
二、【解决方案】
单据的保存操作上配置有"保存并更新批号主档"服务,触发保存操作,会生成批号主档(如果对应批号不存在)
构造完数据包调用LoadReferenceObject方法(基础档案在实体中赋值ID自动加载其相关引用资料),再调用保存操作
DBServiceHelper.LoadReferenceObject(this.Context, new DynamicObject[] { oMisDelivery }, oMisDelivery.DynamicObjectType, false);
//获取其他出库单的元数据 IMetaDataService metaService = Kingdee.BOS.Contracts.ServiceFactory.GetService<IMetaDataService>(this.Context); FormMetadata MisDeliveryMeta = (FormMetadata)metaService.Load(this.Context, SCMFormIdConst.STK_MisDelivery); DynamicObject oMisDelivery = new DynamicObject(MisDeliveryMeta.BusinessInfo.GetDynamicObjectType()); //实体ORM标识:明细信息 DynamicObjectCollection detailCollItem = oMisDelivery["BillEntry"] as DynamicObjectCollection; #region 单据头 oMisDelivery["BillTypeID_Id"] = "61a4d51a5a6fb8"; //单据类型 oMisDelivery["DocumentStatus"] = "Z"; //单据状态 oMisDelivery["FFormId"] = "STK_MisDelivery"; //业务对象类型 oMisDelivery["BizType"] = "0"; //业务类型 oMisDelivery["StockOrgId_Id"] = 100003; //库存组织 oMisDelivery["PickOrgId_Id"] = 100003; //领料组织=货主 oMisDelivery["StockDirect"] = "GENERAL"; //库存方向 oMisDelivery["Date"] = DateTime.Now; oMisDelivery["CreateDate"] = DateTime.Now; oMisDelivery["ModifyDate"] = DateTime.Now; oMisDelivery["DeptId_Id"] = 100202; oMisDelivery["CreatorId_Id"] = Convert.ToInt64(this.Context.UserId); //创建人 oMisDelivery["ModifierId_Id"] = Convert.ToInt64(this.Context.UserId); //修改人 oMisDelivery["CancelStatus"] = "A"; //作废状态 oMisDelivery["OwnerTypeIdHead"] = "BD_OwnerOrg"; //货主类型 oMisDelivery["OwnerIdHead_Id"] = 100003; //货主 oMisDelivery["TransferBizType_Id"] = Convert.ToInt64(6); //跨组织业务类型 #endregion DynamicObject detailItem = new DynamicObject(detailCollItem.DynamicCollectionItemPropertyType); detailItem["Seq"] = 1; detailItem["LOT_TEXT"] = "20220708-Test"; detailItem["StockId_Id"] = 100022; detailItem["StockStatusId_Id"] = 10000; detailItem["KeeperTypeId"] = "BD_KeeperOrg"; detailItem["KeeperId_Id"] = 100003; detailItem["OwnerTypeId"] = "BD_OwnerOrg"; detailItem["OwnerId_Id"] = 100003; detailItem["MaterialId_Id"] = 140324; detailItem["BaseUnitId_Id"] = 10101; detailItem["BaseQty"] = 1; detailItem["UnitID_Id"] = 10101; detailItem["Qty"] = 1; detailCollItem.Add(detailItem); DBServiceHelper.LoadReferenceObject(this.Context, new DynamicObject[] { oMisDelivery }, oMisDelivery.DynamicObjectType, false); //准备操作参数 OperateOption op = OperateOption.Create(); //忽略可发量检查 op.AddInteractionFlag("KD_SAL_CHECKQTY"); op.AddInteractionFlag("SAL_DOWNPRICECHECK"); op.AddInteractionFlag(K3.Core.SCM.SCMConst.MinusCheckSensor); op.SetIgnoreWarning(true); op.SetVariableValue("IgnoreCheckSalAvailableQty", true); //暂存 IDraftService draftService = Kingdee.BOS.Contracts.ServiceFactory.GetService<IDraftService>(this.Context); IOperationResult operResult = draftService.Draft(this.Context, MisDeliveryMeta.BusinessInfo, new DynamicObject[] { oMisDelivery }, op); ISaveService saveService = Kingdee.BOS.Contracts.ServiceFactory.GetService<ISaveService>(this.Context); operResult = saveService.Save(this.Context, MisDeliveryMeta.BusinessInfo, new DynamicObject[] { oMisDelivery }, op); //operResult = BusinessDataServiceHelper.Save(Context, MisDeliveryMeta.BusinessInfo, oMisDelivery, OperateOption.Create(), "Save");
插件构造数据包调用保存操作不触发批号保存服务问题排查
一、【问题现象】自定义的BOS单据在保存操作上配置了保存并更新批号主档服务,前台手工新增单据点保存时,该服务会执行,但是插件生成的单...
点击下载文档
本文2024-09-16 19:04:23发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-26217.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章