王 垚
2021-09-08 0fcc730fb3fa804c6e38f6f980eb15ee0a84eb33
送货计划保存删除 反写提料计划 服务插件
2个文件已添加
137 ■■■■■ 已修改文件
src/BLL/Demo.BillView/PRD/Pur_Receive.cs 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/BLL/Demo.BillView/PRD/Pur_ReceiveDelete.cs 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/BLL/Demo.BillView/PRD/Pur_Receive.cs
New file
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Core.Metadata.FieldElement;
using System.ComponentModel;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.SCM.App;
using ZD.Cloud.Logger;
namespace Demo.BillView.PRD
{
    [Description("[收料通知单-保存]按钮功能]")]
    [HotUpdate]
    public class Pur_Receive : AbstractOperationServicePlugIn
    {
        public override void OnPreparePropertys(PreparePropertysEventArgs e)
        {
            base.OnPreparePropertys(e);
            e.FieldKeys.Add("FSrcBillType");
            e.FieldKeys.Add("FSrcBillNo");
            e.FieldKeys.Add("FID");
            e.FieldKeys.Add("FTreeEntity_FEntryID");
            e.FieldKeys.Add("FBillNo");
            e.FieldKeys.Add("FBFLowId");
            e.FieldKeys.Add("FMaterialId");
            e.FieldKeys.Add("FActReceiveQty");
            e.FieldKeys.Add("FTLENTRYID");
            e.FieldKeys.Add("FTLISFX");
        }
        /// <summary>
        ///保存更新提料计划单 收料数量
        /// </summary>
        /// <param name="e"></param>
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            List<string> sqlList = new List<string>();
            string sql = "";
            //审核时更新生产用料清单表明细领料数量
            Entity entity = this.BusinessInfo.GetEntity("FDetailEntity");//获取明细信息
            foreach (var billObj in e.SelectedRows)
            {
                DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity)
                            as DynamicObjectCollection;
                foreach (var entryRow in entryRows)
                {
                    string fentryId = entryRow["FTLENTRYID"].ToString();
                    bool fisfx = Convert.ToBoolean(entryRow["FTLISFX"]);
                    if (fentryId == "0" || fisfx)
                        continue;
                    sql = string.Format($"/*dialect*/update Cg_PODemandPlanBillSub set  FReciveCount = FReciveCount + {Convert.ToDecimal(entryRow["ActReceiveQty"])} where FEntryID = {fentryId} ");
                    //LogHelper.Info("领料单的日计划用料清单ID:" + fentryId);
                    sqlList.Add(sql);
                    sql = string.Format($"/*dialect*/update T_PUR_ReceiveEntry set  FTlisfx =  1 where FentryId = {entryRow["Id"]}");
                    sqlList.Add(sql);
                }
            }
            DBServiceHelper.ExecuteBatch(Context, sqlList);
        }
    }
}
src/BLL/Demo.BillView/PRD/Pur_ReceiveDelete.cs
New file
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Core.Metadata.FieldElement;
using System.ComponentModel;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.SCM.App;
using ZD.Cloud.Logger;
namespace Demo.BillView.PRD
{
    //删除单据 或 删除明细行时 扣除提料单的收料数量
    [Description("[收料通知单-删除]按钮功能]")]
    [HotUpdate]
    public class Pur_ReceiveDelete : AbstractOperationServicePlugIn
    {
        public override void OnPreparePropertys(PreparePropertysEventArgs e)
        {
            base.OnPreparePropertys(e);
            e.FieldKeys.Add("FSrcBillType");
            e.FieldKeys.Add("FSrcBillNo");
            e.FieldKeys.Add("FID");
            e.FieldKeys.Add("FTreeEntity_FEntryID");
            e.FieldKeys.Add("FBillNo");
            e.FieldKeys.Add("FBFLowId");
            e.FieldKeys.Add("FMaterialId");
            e.FieldKeys.Add("FActReceiveQty");
            e.FieldKeys.Add("FTLENTRYID");
            e.FieldKeys.Add("FTLISFX");
        }
        /// <summary>
        ///保存更新提料计划单 收料数量
        /// </summary>
        /// <param name="e"></param>
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            List<string> sqlList = new List<string>();
            string sql = "";
            //审核时更新生产用料清单表明细领料数量
            Entity entity = this.BusinessInfo.GetEntity("FDetailEntity");//获取明细信息
            foreach (var billObj in e.SelectedRows)
            {
                DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity)
                            as DynamicObjectCollection;
                foreach (var entryRow in entryRows)
                {
                    string fentryId = entryRow["FTLENTRYID"].ToString();
                    bool fisfx = Convert.ToBoolean(entryRow["FTLISFX"]);
                    if (fentryId == "0")
                        continue;
                    sql = string.Format($"/*dialect*/update Cg_PODemandPlanBillSub set  FReciveCount = FReciveCount - {Convert.ToDecimal(entryRow["ActReceiveQty"])} where FEntryID = {fentryId} ");
                    //LogHelper.Info("领料单的日计划用料清单ID:" + fentryId);
                    sqlList.Add(sql);
                    sql = string.Format($"/*dialect*/update T_PUR_ReceiveEntry set  FTlisfx =  0 where FentryId = {entryRow["Id"]}");
                    sqlList.Add(sql);
                }
            }
            DBServiceHelper.ExecuteBatch(Context, sqlList);
        }
    }
}