1、判断和
import clr
clr.AddReference("System")
clr.AddReference("System.Web.Extensions")
#clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Newtonsoft.Json")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference("mscorlib")
clr.AddReference("Kingdee.BOS.ServiceHelper")
clr.AddReference("Kingdee.BOS.DataEntity")
import sys
from System import *
from System.Collections.Generic import *
from System.Threading import *
from System.IO import *
from System.Net import *
from System.Text import *
from System.Security.Cryptography import *
from System.Web.Script.Serialization import *
from System.Collections.Generic import Dictionary
from Newtonsoft.Json.Linq import *
from System.Collections.Generic import List
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.App.Data import *
def OnPreparePropertys(e):
e.FieldKeys.Add("FSrcInterId0")
e.FieldKeys.Add("FMaterialId")
def EndOperationTransaction(e):
#zzbmDH = this.Context.UserPhone
# zzbmDH='18282958350'
for billObj in e.DataEntitys:
ddt=billObj['Entity'] #单据体
#rr=billObj ['ReferDetail'] #参考值
for i in ddt:
wlbmID=("{0}").format(i["MaterialId"]["Id"])
wdID=("{0}").format(i["SrcInterId"])
sql="select 物料.FMATERIALID as 物料编码 , sum(单据体.FINSPECTQTY) as 合计 from T_QM_INSPECTBILL as 单据头 join T_QM_INSPECTBILLENTRY AS 单据体 ON 单据头.FID=单据体.FID join T_QM_INSPECTBILLENTRY_A as 物料 ON 单据体.FENTRYID=物料.FENTRYID where 物料.FSRCINTERID ='"+wdID+"' and 物料.FMATERIALID='"+wlbmID+"' GROUP BY FMATERIALID"
ds = DBServiceHelper.ExecuteDataSet(this.Context, sql)
AllRows = ds.Tables[0].Rows;
if (AllRows.Count <= 0):
continue;
orgList = List[str]();
for r in AllRows:
wlbm=("{0}").format(r["物料编码"])
wlbmhj=("{0}").format(r["合计"])
sqlT = "select 体.FMATERIALID as 物料编码, sum(体.FACTRECEIVEQTY) as 合计 from T_PUR_Receive as 头 join T_PUR_ReceiveEntry as 体 on 头.FID=体.FID where 头. FID ='"+wdID+"' and 体.FMATERIALID='"+wlbmID+"' GROUP BY 体.FMATERIALID"
ds_01 = DBServiceHelper.ExecuteDataSet(this.Context, sqlT)
AllRows_S = ds_01.Tables[0].Rows;
for u in AllRows_S:
wlbm_t= ("{0}").format(u["物料编码"])
wlbmhj_t = ("{0}").format(u["合计"])
if (wlbm==wlbm_t) and (wlbmhj != wlbmhj_t):
#raise Exception(str(" '"+wlbmhj+"' '"+wlbmhj_t+"'" ))
raise Exception("选单数量和收料通知单数量不一致!!<_>请重新选单")