a
This commit is contained in:
96
14.宝锐/GZ.LJY000.Biori/SAL_OUTSTOCK/OperationEventPlugInEx.py
Normal file
96
14.宝锐/GZ.LJY000.Biori/SAL_OUTSTOCK/OperationEventPlugInEx.py
Normal file
@@ -0,0 +1,96 @@
|
||||
#引入clr运行库
|
||||
import clr
|
||||
#添加对cloud插件开发的常用组件引用
|
||||
clr.AddReference('System')
|
||||
clr.AddReference('System.Data')
|
||||
clr.AddReference('Kingdee.BOS')
|
||||
clr.AddReference('Kingdee.BOS.Core')
|
||||
clr.AddReference('Kingdee.BOS.App')
|
||||
clr.AddReference('Kingdee.BOS.App.Core')
|
||||
clr.AddReference('Kingdee.BOS.Contracts')
|
||||
clr.AddReference('Kingdee.BOS.DataEntity')
|
||||
clr.AddReference('Kingdee.BOS.ServiceHelper')
|
||||
#dairycloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
|
||||
from Kingdee.BOS.Core import *
|
||||
from Kingdee.BOS.Util import *
|
||||
from Kingdee.BOS.Core.Bill import *
|
||||
from Kingdee.BOS.Core.List import *
|
||||
from Kingdee.BOS.Core.Bill.PlugIn import *
|
||||
from Kingdee.BOS.Orm.DataEntity import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
|
||||
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
|
||||
from Kingdee.BOS.Core.Metadata.ConvertElement.ServiceArgs import *
|
||||
from System import *
|
||||
from System.Data import *
|
||||
from Kingdee.BOS.App.Data import *
|
||||
from Kingdee.BOS.App import *
|
||||
from Kingdee.BOS.Orm import *
|
||||
from Kingdee.BOS.Contracts import *
|
||||
from System.Collections.Generic import List
|
||||
from Kingdee.BOS.ServiceHelper import *
|
||||
from Kingdee.BOS.App.Core import *
|
||||
|
||||
def OnPreparePropertys(e):
|
||||
e.FieldKeys.Add("FRowType");
|
||||
e.FieldKeys.Add("FPackBillNo");
|
||||
# e.FieldKeys.Add("FPackBillSeq");
|
||||
# e.FieldKeys.Add("FPackBillEntryId");
|
||||
e.FieldKeys.Add("FRealQty");
|
||||
e.FieldKeys.Add("FPackBarCode");
|
||||
|
||||
def BeforeDoSaveExecute(e):
|
||||
# if this.FormOperation.OperationId == 8:
|
||||
for entity in e.DataEntities:
|
||||
entries = entity["SAL_OUTSTOCKENTRY"]
|
||||
sqlL = List[str]();
|
||||
for idx,entry in enumerate(entries):
|
||||
rowType = 1 if entry["RowType"] == "Parent" else 2;
|
||||
if rowType == 2 or rowType == 1:
|
||||
packBarCode = "" if entry["FPackBarCode"] == None else entry["FPackBarCode"].strip()
|
||||
packBillNo = "" if entry["FPackBillNo"] == None else entry["FPackBillNo"].strip()
|
||||
|
||||
if (rowType == 1 and packBillNo == "") or (rowType == 2 and packBarCode != "" and packBillNo == ""):
|
||||
materialId = entry["MaterialID_Id"]
|
||||
entryId = entry["Id"]
|
||||
rowId = entry["RowId"]
|
||||
pRowId = entry["ParentRowId"]
|
||||
sqlL.Add("SELECT {0} 'MaterialId',{1} 'EntryId',{2} 'EntrySeq','{3}' AS 'PackBarCode',{4} AS 'FRowType','{5}' AS 'rowId','{6}' AS 'pRwoId'".format(materialId,entryId,idx,packBarCode,rowType,rowId,pRowId));
|
||||
|
||||
if sqlL.Count > 0:
|
||||
sqlUnion = " UNION ALL ".join(sqlL);
|
||||
sql = """/*dialect*/
|
||||
|
||||
WITH #基础数据 AS (
|
||||
{0}
|
||||
)
|
||||
, #初步处理 AS (
|
||||
SELECT t0.MaterialId,t0.EntryId,t0.EntrySeq
|
||||
,CASE WHEN t0.FRowType = 1 THEN (
|
||||
SELECT TOP 1 t1.PackBarCode FROM #基础数据 t1 WHERE t1.pRwoId = t0.rowId
|
||||
) ELSE t0.PackBarCode END 'PackBarCode'
|
||||
,t0.FRowType,t0.rowId,t0.pRwoId
|
||||
FROM #基础数据 t0
|
||||
)
|
||||
SELECT tt.*
|
||||
,t0.FBARCODE,t1.FBILLNO,t0.FBILLID,t0.FBILLENTRYID,t0.FBILLSEQ,t0.FBILLFORMID
|
||||
FROM #初步处理 tt
|
||||
INNER JOIN T_UNW_WMS_BARCODE t0 on t0.FBARCODE = tt.PackBarCode
|
||||
INNER JOIN T_PRD_PACKAGEINSTOCK t1 on t1.FSRCBILLENTRYID = t0.FBILLENTRYID
|
||||
WHERE t0.FBILLFORMID = 'PLN_FORECAST'
|
||||
ORDER BY tt.EntrySeq
|
||||
|
||||
""".format(sqlUnion);
|
||||
# raise Exception(sql);
|
||||
|
||||
res = DBServiceHelper.ExecuteDynamicObject(this.Context, sql)
|
||||
|
||||
if res != None and res.Count > 0:
|
||||
for item in res:
|
||||
seq = item["EntrySeq"];
|
||||
entries[seq]["FPackBarCode"] = item["PackBarCode"];
|
||||
entries[seq]["FPackBillNo"] = item["FBILLNO"];
|
||||
# entries[seq]["FPackBillSeq"] = item["FSeq"];
|
||||
# entries[seq]["FPackBillEntryId"] = item["FEntryID"];
|
||||
|
||||
return;
|
||||
Reference in New Issue
Block a user