王 垚
2021-02-16 211bb749ab809dab4276c66a5d23bb5ea053ba8f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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.DynamicForm.PRD
{
    [Description("[生产领料单-审核]按钮功能]")]
    [HotUpdate]
    public class Pro_SCLLSH : 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("FBaseUnitQty");
            e.FieldKeys.Add("FBaseJoinQty");
            e.FieldKeys.Add("FDayPlanBillNo");
            e.FieldKeys.Add("FDayPlanFentryId");
            e.FieldKeys.Add("FBaseActualQty");
        }
        /// <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("FEntity");//获取明细信息
            foreach (var billObj in e.SelectedRows)
            {
                DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity)
                            as DynamicObjectCollection;
                foreach (var entryRow in entryRows)
                {
                    string fentryId = entryRow["FDayPlanFentryId"].ToString();
                    if (fentryId == "0")
                        continue;
                    sql = string.Format($"/*dialect*/update Sc_DayPlanPPBomBillSub set  FPickedQty = FPickedQty + {Convert.ToDecimal(entryRow["BaseActualQty"])} where FEntryID = {fentryId} ");
                    //LogHelper.Info("领料单的日计划用料清单ID:" + fentryId);
                    sqlList.Add(sql);
                }
            }
            DBServiceHelper.ExecuteBatch(Context, sqlList);
        }
    }
}