销售订单下推生产订单释放预留
#### 需求描述
1.某些类型的销售订单不走销售出库,因此下推生产订单入库后的预留关系不会被自动释放。
2.生产订单可以供应给其他需求单。
因此,在该类型的销售订单下推生产订单时,释放其与生产订单的预留关系,并保留生产订单下级的预留关系。
#### 实现思路
生产订单保存时,判定当前的生产订单作为供应的预留关系是否存在销售订单作为需求的预留关系,如果存在则获取生产订单的单据ID与分录ID批量释放预留,仅释放生产订单作为供应的预留关系。
1.二开锚点:生产订单保存操作插件
2.二开重写事件:AbstractOperationServicePlugIn
#### 参考插件
```csharp
using Kingdee.BOS;
using Kingdee.BOS.Core.BusinessFlow.ReserveLogic;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.K3.Core.MFG;
using Kingdee.K3.Core.MFG.EnumConst;
using Kingdee.K3.Core.MFG.PLN.Reserved;
using Kingdee.K3.Core.MFG.PLN.Reserved.ReserveArgs;
using Kingdee.K3.MFG.App;
using Kingdee.K3.MFG.Common.BusinessEntity.PLN;
using Kingdee.K3.MFG.Contracts.PLN.Reserve;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace SampleAppPlugIn
{
[Description("生产订单释放预留")]
public class MOSaveReleaseReserveLink : AbstractOperationServicePlugIn
{
public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
{
List<OriBillInfo> lstFinishCloseRows = new List<OriBillInfo>();
var releaseDatas = GetReleseDatas(this.Context, e.DataEntitys.Select(x => Convert.ToInt64(x["Id"])).ToList());
if (!releaseDatas.IsEmpty())
{
//删除预留关系中该分录作为供应的分录,不删除相关需求的预留关系(并删除预留关系的转换日志,否则在重复保存时无法重新生成预留关系)
ReserveArgs<ReleaseRowInfo> releaseArgs = new ReserveArgs<ReleaseRowInfo>();
releaseArgs.SelectRows = (from p in releaseDatas
select new ReleaseRowInfo
(
"PRD_MO",
Convert.ToString(p["FSUPPLYINTERID"]),
Convert.ToString(p["FSUPPLYENTRYID"]),
"FTreeEntity")
).ToList();
AppServiceContext.PLNService.ReserveLinkService.ReleaseBackward(this.Context, releaseArgs, null);
}
}
/// <summary>
/// 1.根据当前的生产订单单据ID联查预留表销售订单表获取生产订单作为供应的预留关系
/// 2.针对特定的销售订单单据类型过滤:T4.FBILLTYPE
/// </summary>
/// <param name="ctx"></param>
/// <param name="moIds"></param>
/// <returns></returns>
DynamicObjectCollection GetReleseDatas(Context ctx, List<long> moIds)
{
long[] ids = moIds.Distinct().ToArray();
if (ids.IsEmpty()) return null;
string soBillTypeId = "销售订单单据类型内码";//请按实际项目中的单据类型替换
string strSql = string.Format(@"
SELECT T2.FSUPPLYINTERID,T2.FSUPPLYENTRYID FROM T_PLN_RESERVELINK T1
INNER JOIN T_PLN_RESERVELINKENTRY T2 ON T1.FID = T2.FID
INNER JOIN T_PRD_MO T3 ON T2.FSUPPLYBILLNO=T3.FBILLNO AND T2.FSUPPLYFORMID = 'PRD_MO'
INNER JOIN T_SAL_ORDER T4 ON T1.FINTDEMANDID = T4.FID
{0}
WHERE T2.FSUPPLYBILLNO='' AND T4.FBILLTYPEID = '{1}'", StringUtils.GetSqlWithCardinality(ids.Count(), "@ids", 0), soBillTypeId);
return DBServiceHelper.ExecuteDynamicObject(ctx, strSql, null, null, System.Data.CommandType.Text, new SqlParam[] {
new SqlParam("@ids",KDDbType.udt_inttable,ids)
});
}
}
}
```
销售订单下推生产订单释放预留
#### 需求描述1.某些类型的销售订单不走销售出库,因此下推生产订单入库后的预留关系不会被自动释放。2.生产订单可以供应给其他需求单。因...
点击下载文档
上一篇:星辰集成配置说明下一篇:寄售结算匹配库存功能简介
本文2024-09-23 02:47:21发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-154711.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章