Python插件 - 树形账表服务端插件示例原创
14人赞赏了该文章
2,524次浏览
编辑于2021年11月17日 09:39:51
树形账表服务端插件的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;
如果保存时报如下错误,直接点确定,不用理会。
treeReport_py.zip(1.14KB)
赞 14
14人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!