Files
梁骏愉 2306c8b7cf 1
2025-03-15 15:03:34 +08:00

108 lines
3.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#引入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')
clr.AddReference('Kingdee.BOS.WebApi.FormService')
#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 *
from Kingdee.BOS.WebApi.FormService import *
def OnPreparePropertys(e):
e.FieldKeys.Add("FVersions");
e.FieldKeys.Add("FBillNo");
def EndOperationTransaction(e):
# raise Exception("A")
if this.FormOperation.OperationId == 1:
DoClosePLN_FORECAST(e);
def DoClosePLN_FORECAST(e):
for entity in e.DataEntitys:
billNo = entity["BillNo"]
billId = entity["Id"]
sqlL = """/*dialect*/
SELECT t0.FBILLNO,t0.FID,t0.FCONVERTBILLNO,t0e.FENTRYID,t0e.FCLOSESTATUS,t0.FBILLTYPEID
FROM (
SELECT top 1 t0.FID
FROM T_PLN_FORECAST t0
WHERE 1= 1 AND t0.FCONVERTBILLNO != '{0}'
--AND t0.FBILLTYPEID = '67707a90214919' --年度
--AND t0.FBILLTYPEID = '6771142c2149d1' --w+5
AND t0.FBILLTYPEID = '6771142c2149d1' --N+3
ORDER BY t0.FBILLNO DESC,t0.FDATE DESC
) tt INNER JOIN T_PLN_FORECAST t0 on t0.FID = tt.FID
INNER JOIN T_PLN_FORECASTENTRY t0e on t0e.FID = t0.FID
WHERE 1= 1
AND (t0e.FCLOSESTATUS = 'A' OR t0e.FCLOSESTATUS = '')
""".format(billNo)
# raise Exception(sqlL);
dataList = DBServiceHelper.ExecuteDynamicObject(this.Context, sqlL)
if dataList.Count == 0:
return;
# 请求参数
id = dataList[0]["FID"]
pkEntryIds = List[str]()
para = {"CreateOrgId":this.Context.UserId,"Numbers":[],"Ids":"","PkEntryIds":[],"UseOrgId":this.Context.CurrentOrganizationInfo.ID,"NetworkCtrl":"","IgnoreInterationFlag":""}
for item in dataList:
# pkEntryIds.Add(str(item["FENTRYID"]))
para["PkEntryIds"].Add({"Id":str(item["FID"]),"EntryIds":str(item["FENTRYID"])})
# raise Exception(JsonUtil.Serialize(para))
# 业务对象标识
formId = "PLN_FORECAST"
# 操作接口编码
operateNumber = "BillClose"
resultJson = WebApiServiceCall.Execute(this.Context, formId, operateNumber, JsonUtil.Serialize(para));
# raise Exception(JsonUtil.Serialize(resultJson))
if resultJson !=None :
IsSuccess = resultJson["Result"]["ResponseStatus"]["IsSuccess"]
if IsSuccess==False:
raise Exception(JsonUtil.Serialize(resultJson))
updSql = """/*dialect*/
WITH #上版本 AS (
SELECT TOP 1 t1.*
FROM T_PLN_FORECAST2N3 t0
INNER JOIN T_PLN_FORECAST2N3 t1 on t0.FFORECASTYEAR = t1.FFORECASTYEAR
WHERE t0.FBILLNO = '{0}'
AND t1.FBILLNO != '{0}'
ORDER By t1.FBILLNO DESC
)
UPDATE T_PLN_FORECAST2N3 SET FIsClose = 'B'
FROM T_PLN_FORECAST2N3 t0
INNER JOIN #上版本 t1 on t1.FID = t0.FID
WHERE t1.FIsClose != 'B'
""".format(billNo)
res = DBServiceHelper.Execute(this.Context, updSql)
return;