物料审核-自动分配到其他组织的代码分享
[HotUpdate]
[Description("物料-审核自动分配插件")]
public class MaterialAutoAllocateService: AbstractOperationServicePlugIn
{
object creatOrgId;
object useOrgId;
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
{
base.AfterExecuteOperationTransaction(e);
var pkIds = new List<object>();
foreach (var dataEntity in e.SelectedRows)
{
creatOrgId = dataEntity.DataEntity["CreateOrgId_Id"];
useOrgId = dataEntity.DataEntity["UseOrgId_Id"];
if (useOrgId.Equals(creatOrgId))
{
pkIds.Add(dataEntity.DataEntity["Id"]);
}
}
if (pkIds.Count>0)
if (queryData != null)
{
var collection = (DynamicObjectCollection)queryData["FEntity"];
var destOrgIds = collection.Select(x => Convert.ToInt64(x["FUseOrgId2_Id"])).ToList();
//读取目标单据元数据
IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();
FormMetadata meta = metaService.Load(this.Context, "BD_MATERIAL") as FormMetadata;
foreach (var DestOrgId in destOrgIds)
{
var parameter = new AllocateParameter(meta.BusinessInfo, meta.InheritPath, Convert.ToInt64(creatOrgId),
BOSEnums.Enu_AllocateType.Allocate, "Allocate");
parameter.PkId = pkIds; //分配内码
parameter.DestOrgId = DestOrgId;
parameter.AutoSubmitAndAudit = true;
parameter.AllocateUserId = this.Context.UserId;
var allocateService = ServiceHelper.GetService<IAllocateService>();
IOperationResult result = allocateService.Allocate(this.Context,parameter);
if (!result.IsSuccess)
{
var opt = new OperateResult();
opt.Number = result.ValidationErrors[0].Id;
opt.Name = result.ValidationErrors[0].Title;
opt.Message = result.ValidationErrors[0].Message;
this.OperationResult.OperateResult.Add(opt);
}
}
}
}
}
}
[Description("物料-审核自动分配插件")]
public class MaterialAutoAllocateService: AbstractOperationServicePlugIn
{
object creatOrgId;
object useOrgId;
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
{
base.AfterExecuteOperationTransaction(e);
var pkIds = new List<object>();
foreach (var dataEntity in e.SelectedRows)
{
creatOrgId = dataEntity.DataEntity["CreateOrgId_Id"];
useOrgId = dataEntity.DataEntity["UseOrgId_Id"];
if (useOrgId.Equals(creatOrgId))
{
pkIds.Add(dataEntity.DataEntity["Id"]);
}
}
if (pkIds.Count>0)
{
//这里通过分配规则的编码'001'获取需要分配使用组织的组织内码
if (queryData != null)
{
var collection = (DynamicObjectCollection)queryData["FEntity"];
var destOrgIds = collection.Select(x => Convert.ToInt64(x["FUseOrgId2_Id"])).ToList();
//读取目标单据元数据
IMetaDataService metaService = ServiceHelper.GetService<IMetaDataService>();
FormMetadata meta = metaService.Load(this.Context, "BD_MATERIAL") as FormMetadata;
foreach (var DestOrgId in destOrgIds)
{
var parameter = new AllocateParameter(meta.BusinessInfo, meta.InheritPath, Convert.ToInt64(creatOrgId),
BOSEnums.Enu_AllocateType.Allocate, "Allocate");
parameter.PkId = pkIds; //分配内码
parameter.DestOrgId = DestOrgId;
parameter.AutoSubmitAndAudit = true;
parameter.AllocateUserId = this.Context.UserId;
var allocateService = ServiceHelper.GetService<IAllocateService>();
IOperationResult result = allocateService.Allocate(this.Context,parameter);
if (!result.IsSuccess)
{
var opt = new OperateResult();
opt.Number = result.ValidationErrors[0].Id;
opt.Name = result.ValidationErrors[0].Title;
opt.Message = result.ValidationErrors[0].Message;
this.OperationResult.OperateResult.Add(opt);
}
}
}
}
}
}
物料审核-自动分配到其他组织的代码分享
[HotUpdate][Description("物料-审核自动分配插件")]public class MaterialAutoAllocateService: AbstractOperationServicePlugIn{ ...
点击下载文档
本文2024-09-16 18:31:24发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-22687.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章