Python插件 - 树形账表服务端插件示例
树形账表服务端插件的python脚本
import clr clr.AddReference("System") clr.AddReference("System.Core") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.DataEntity") clr.AddReference("Kingdee.BOS.Contracts") clr.AddReference("Kingdee.BOS.App") from Kingdee.BOS import * from Kingdee.BOS.JSON import * from Kingdee.BOS.Util import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Report import * from Kingdee.BOS.Core.Metadata import * from Kingdee.BOS.App.Data import * from System import * from System.Collections.Generic import * from System.Linq import * def Initialize(): this.ReportProperty.ReportType = ReportType.REPORTTYPE_TREE;##树形报表 this.ReportProperty.IsGroupSummary = True; this.ReportProperty.PrimaryKeyFieldName = "FBILLNO"; this.ReportProperty.ReportName = LocaleValue("树形报表"); this.IsCreateTempTableByPlugin = True;##临时表取数 def GetReportHeaders(filters): header = ReportHeader(); header.AddChild("FBillNo", LocaleValue("单据编号")); header.AddChild("FMaterialNumber", LocaleValue("物料代码")); header.AddChild("FMaterialName", LocaleValue("物料代码")); header.AddChild("FReqQty", LocaleValue("采购数量")); return header; def BuilderReportSqlAndTempTable(filters,tableName): sql="SELECT FID,FBillNo,FMaterialId,FMaterialNumber,FMaterialName,FReqQty,ROW_NUMBER() OVER(ORDER BY FMaterialId) FIDENTITYID INTO {} FROM ({}) Tab"; strFrom= GetSql(filters); sqlAll=sql.format(tableName,strFrom); DBUtils.Execute(this.Context, sqlAll); def GetTreeNodes(filters): sql="SELECT FMaterialId,FMaterialName FROM ({}) Tab group by FMaterialId,FMaterialName".format(GetSql(filters)) lst=DBUtils.ExecuteDynamicObject(this.Context, sql); nodes=List[TreeNode](); for item in lst: node=TreeNode(); node.id=str(item["FMaterialId"]); node.text=item["FMaterialName"]; nodes.Add(node); return nodes; def GetSql(filters): sql="SELECT T1.FID,T1.FBillNo,t0.FMaterialId,t0.FReqQty,t2.FNumber AS FMaterialNumber,t2L.FName AS FMaterialName FROM T_PUR_ReqEntry T0 LEFT JOIN T_PUR_Requisition T1 ON T0.FID=T1.FID LEFT JOIN T_BD_Material t2 on t0.FMaterialId=t2.FMaterialId LEFT JOIN T_BD_Material_L t2L on t0.FMaterialId=t2L.FMaterialId AND t2L.FLocaleId=2052 WHERE 1=1 "; if (this.CurrentGroupID<>None and this.CurrentGroupID.Trim()<>'' and this.CurrentGroupID <> "0"): sql=sql + " AND T0.FMaterialId={} ".format(this.CurrentGroupID); return sql;
如果保存时报如下错误,直接点确定,不用理会。
Python插件 - 树形账表服务端插件示例
树形账表服务端插件的python脚本import clrclr.AddReference("System")clr.AddReference("System.Core")clr.AddReference("Kingdee.BOS")cl...
点击下载文档
本文2024-09-16 17:20:14发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-15039.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章