最终版本:
(但如果给一个人设置了两个目标,会出现完成率全部为最底部目标的计算值)
解决办法:在开单时设置销售员目标唯一性
import clr
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App')
from Kingdee.BOS.App.Data import *
def OnInitialize(e):
# this.View.ShowMessage(str(XSYID))
#销售员ID
shitSQL = """/*dialect*/SELECT F_XJKM_XSY,F_XJKM_INTEGER from XJKM_t_Cust_Entry100001"""
SHIT = DBUtils.ExecuteDynamicObject(this.Context, shitSQL)
for SHITNUM in SHIT:
FARTSQL = """/*dialect*/SELECT TARRE.FALLAMOUNTFOR FROM t_AR_receivableEntry as TARRE
INNER JOIN t_AR_receivable as TARR ON TARRE.FID = TARR.FID
WHERE TARR.FSALEERID = '{0}' AND FDOCUMENTSTATUS = 'C'
ORDER BY FENTRYID DESC""".format(str(SHITNUM["F_XJKM_XSY"]))
FART = DBUtils.ExecuteDynamicObject(this.Context, FARTSQL)
FART_FLOAT = 0.0
ASS_STR = ""
for FARTNUM in FART:
FART_FLOAT += float(FARTNUM["FALLAMOUNTFOR"])
ASS = (FART_FLOAT / float(SHITNUM["F_XJKM_INTEGER"])) * 100
ASS_STR = "{:.2f}%".format(ASS)
PEESQL = """/*dialect*/UPDATE t
SET F_XJKM_INTEGER1 = '{0}',F_XJKM_TEXT = '{1}'
FROM XJKM_t_Cust_Entry100001 t
WHERE F_XJKM_XSY = '{2}'""".format(int(FART_FLOAT),str(ASS_STR),str(SHITNUM["F_XJKM_XSY"]))
FINAL_EXECUTE=DBUtils.Execute(this.Context,PEESQL);
this.View.UpdateView("F_XJKM_Integer1")
this.View.UpdateView("F_XJKM_Text")