工序汇报二开案例-反写工序计划
由于工序汇报的上游单据工序计划是单据头-单据体-子单据体结构,而BOS不支持对子单据体的反写,因此要想将工序汇报的字段值反写到工序计划的工序列表上去,就无法通过配置反写规则来实现了,而需要通过操作服务插件来反写。
下面介绍一个范例,由工序汇报分录中新增的数量字段反写工序计划的可超额汇报数量。
总体思路:在工序汇报中增加字段,在审核操作中用插件实现数量的累加反写,并在反审核操作中用插件实现数量的累减反写,审核与反审核操作一定要成对配置。
1. 扩展工序汇报元数据,在汇总分录中增加数量字段TTestQty,绑定为工序单位数量。
2. 在审核操作中注册Python插件,累加反写到工序计划的可超额汇报数量中。此处将扩展的字段作为工序单位数量,分别计算出生产单位数量和基本单位数量,累加反写到工序计划的相应数量上。
注意,保存Python插件时,若提示如下图这种找不到引用的错误,可以忽略,直接点击确定保存,运行时会加载到该引用的。
参考Python:
clr.AddReference("Kingdee.K3.MFG.App")
clr.AddReference("Kingdee.K3.MFG.Contracts")
clr.AddReference("Kingdee.BOS.App")
from Kingdee.K3.MFG.App import *
from Kingdee.K3.MFG.Contracts import *
from Kingdee.BOS.App import *
from Kingdee.BOS.App.Data import *
def OnPreparePropertys(e):
e.FieldKeys.Add("FENTRYID")
e.FieldKeys.Add("FOptPlanOptId")
e.FieldKeys.Add("FMaterialId")
e.FieldKeys.Add("FPrdUnitID")
e.FieldKeys.Add("FBaseUnitID")
e.FieldKeys.Add("FUnitTransHeadQty")
e.FieldKeys.Add("FUnitTransOperQty")
e.FieldKeys.Add("FTestQty")
def EndOperationTransaction(e):
sqlStrs = []
testQtyDic={}
materialIdDic={}
unitDic={}
baseUnitDic={}
transHeadQtyDic={}
transOperQtyDic={}
for dataEntity in e.DataEntitys:
dataEntries = dataEntity["OptRptEntry"]
for dataEntry in dataEntries:
detailId = dataEntry["OptPlanOptId"]
if (testQtyDic.has_key(detailId)):
testQtyDic[detailId]=testQtyDic[detailId]+dataEntry["TestQty"]
else:
testQtyDic[detailId]=dataEntry["TestQty"]
materialIdDic[detailId]=dataEntry["MaterialId_Id"]
unitDic[detailId]=dataEntry["PrdUnitID"]
baseUnitDic[detailId]=dataEntry["BaseUnitID"]
transHeadQtyDic[detailId]=dataEntry["UnitTransHeadQty"]
transOperQtyDic[detailId]=dataEntry["UnitTransOperQty"]
if(testQtyDic!=None and testQtyDic.Count>0):
for detailId in testQtyDic.keys():
testQty = testQtyDic[detailId]
materialId = materialIdDic[detailId]
unit = unitDic[detailId]
baseunit = baseUnitDic[detailId]
unitId = unit["Id"]
transHeadQty = transHeadQtyDic[detailId]
transOperQty = transOperQtyDic[detailId]
iservice = MFGServiceFactory.GetOperUnitConvertService(this.Context)
baseQty = iservice.CalcBaseQty(this.Context,materialId,unitId,transHeadQty,transOperQty,testQty,baseunit)
prdQty = iservice.CalcProQtyByOper(transHeadQty,transOperQty,testQty,unit)
sqlStr="UPDATE T_SFC_OPERPLANNINGDETAIL_D SET FBaseExcessCtrlQty=FBaseExcessCtrlQty+"+baseQty.ToString()+",FPrdExcessCtrlQty=FPrdExcessCtrlQty+"+prdQty.ToString()+",FOperExcessCtrlQty=FOperExcessCtrlQty+"+testQty.ToString()+" WHERE FDETAILID="+detailId.ToString()
sqlStrs.append(sqlStr)
DBUtils.Execute(this.Context, sqlStr)
3. 在反审核操作中注册Python插件,累减反写到工序计划的可超额汇报数量中。与审核操作的处理过程相同,只是数量计算使用的是累减。
参考Python:
clr.AddReference("Kingdee.K3.MFG.App")
clr.AddReference("Kingdee.K3.MFG.Contracts")
clr.AddReference("Kingdee.BOS.App")
from Kingdee.K3.MFG.App import *
from Kingdee.K3.MFG.Contracts import *
from Kingdee.BOS.App import *
from Kingdee.BOS.App.Data import *
def OnPreparePropertys(e):
e.FieldKeys.Add("FENTRYID")
e.FieldKeys.Add("FOptPlanOptId")
e.FieldKeys.Add("FMaterialId")
e.FieldKeys.Add("FPrdUnitID")
e.FieldKeys.Add("FBaseUnitID")
e.FieldKeys.Add("FUnitTransHeadQty")
e.FieldKeys.Add("FUnitTransOperQty")
e.FieldKeys.Add("FTestQty")
def EndOperationTransaction(e):
sqlStrs = []
testQtyDic={}
materialIdDic={}
unitDic={}
baseUnitDic={}
transHeadQtyDic={}
transOperQtyDic={}
for dataEntity in e.DataEntitys:
dataEntries = dataEntity["OptRptEntry"]
for dataEntry in dataEntries:
detailId = dataEntry["OptPlanOptId"]
if (testQtyDic.has_key(detailId)):
testQtyDic[detailId]=testQtyDic[detailId]+dataEntry["TestQty"]
else:
testQtyDic[detailId]=dataEntry["TestQty"]
materialIdDic[detailId]=dataEntry["MaterialId_Id"]
unitDic[detailId]=dataEntry["PrdUnitID"]
baseUnitDic[detailId]=dataEntry["BaseUnitID"]
transHeadQtyDic[detailId]=dataEntry["UnitTransHeadQty"]
transOperQtyDic[detailId]=dataEntry["UnitTransOperQty"]
if(testQtyDic!=None and testQtyDic.Count>0):
for detailId in testQtyDic.keys():
testQty = testQtyDic[detailId]
materialId = materialIdDic[detailId]
unit = unitDic[detailId]
baseunit = baseUnitDic[detailId]
unitId = unit["Id"]
transHeadQty = transHeadQtyDic[detailId]
transOperQty = transOperQtyDic[detailId]
iservice = MFGServiceFactory.GetOperUnitConvertService(this.Context)
baseQty = iservice.CalcBaseQty(this.Context,materialId,unitId,transHeadQty,transOperQty,testQty,baseunit)
prdQty = iservice.CalcProQtyByOper(transHeadQty,transOperQty,testQty,unit)
sqlStr="UPDATE T_SFC_OPERPLANNINGDETAIL_D SET FBaseExcessCtrlQty=FBaseExcessCtrlQty-"+baseQty.ToString()+",FPrdExcessCtrlQty=FPrdExcessCtrlQty-"+prdQty.ToString()+",FOperExcessCtrlQty=FOperExcessCtrlQty-"+testQty.ToString()+" WHERE FDETAILID="+detailId.ToString()
sqlStrs.append(sqlStr)
DBUtils.Execute(this.Context, sqlStr)
OnPreparePropertys重写了哪个类的方法?
工序汇报二开案例-反写工序计划
本文2024-09-16 17:48:26发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-18070.html