分享python简单账表开发原创
23人赞赏了该文章
3,480次浏览
编辑于2021年12月03日 07:58:16
import clr clr.AddReference("System") clr.AddReference("Kingdee.BOS") clr.AddReference("Kingdee.BOS.Core") clr.AddReference("Kingdee.BOS.DataEntity") clr.AddReference("Kingdee.BOS.App") clr.AddReference("Kingdee.BOS.Contracts") from Kingdee.BOS import * from Kingdee.BOS.Contracts import * from Kingdee.BOS.Contracts.Report import * from Kingdee.BOS.Core import * from Kingdee.BOS.Core.Metadata import * from Kingdee.BOS.Core.Report import * from Kingdee.BOS.Core.SqlBuilder import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.Orm.DataEntity import * from System import * from System.ComponentModel import * from System.Collections.Generic import * from System.Text import * from System.Threading.Tasks import * #初始化 def Initialize(): this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL; this.IsCreateTempTableByPlugin = True; this.ReportProperty.IsGroupSummary = True; #设置标题 def GetReportTitles(Filter): reportTitles = ReportTitles(); customFiler = Filter.FilterParameter.CustomFilter; if customFiler: #multiOrgNameValues = GetMulOrgnNameValues(customFiler["FOrgId"].ToString()); #startValue = customFiler["FStartDate"]; #endValue = customFiler["FEndDate"]; #BillNo = customFiler["FBillNo"]; #获取基础资料名称 baseDataNameValue = GetBaseDataNameValue(customFiler["FCustId"]); reportTitles.AddTitle("FCustName",baseDataNameValue); return reportTitles; #获取基础资料 #参考https://vip.kingdee.com/article/70549955693471488 def GetBaseDataNameValue(dyobj): name = ""; #raise Exception(str(dir(dyobj)));#抛出异常检查调试 if dyobj is None: return name; elif dyobj and dyobj.DynamicObjectType.Properties.Contains("Name"): name = dyobj["Name"].ToString(); else: for dynbj in dyobj: if dynbj and dynbj.DynamicObjectType.Properties.Contains("Name") == False: dynbj2 = dynbj[2] name = name + ",'" + dynbj2["Name"] + "'"; if name.Length > 0: name = name.Substring(1,name.Length - 1); return name; #设置单据列 def GetReportHeaders(Filter): header = ReportHeader(); headerch = ReportHeader(); header.AddChild("单据编号",LocaleValue("单据编号",this.Context.UserLocale.LCID),SqlStorageType.Sqlvarchar); header.AddChild("日期",LocaleValue("日期",this.Context.UserLocale.LCID),SqlStorageType.SqlDatetime); header.AddChild("客户编码",LocaleValue("客户编码",this.Context.UserLocale.LCID),SqlStorageType.Sqlvarchar); header.AddChild("客户",LocaleValue("客户",this.Context.UserLocale.LCID),SqlStorageType.Sqlvarchar); header.AddChild("价税合计",LocaleValue("价税合计",this.Context.UserLocale.LCID),SqlStorageType.SqlDecimal); return header; #创建临时报表 def BuilderReportSqlAndTempTable(Filter,tableName): strFilter = GetFilterWhere(Filter); seqFld = String.format(this.KSQL_SEQ,OrderColumn(Filter)); sql = String.format("""/*dialect*/ SELECT 单据编号, 日期, 客户编码, 客户, 价税合计,{0} INTO {1} FROM ( SELECT T0.FBILLNO AS 单据编号,T0.FDATE AS 日期,T2.FNUMBER AS 客户编码,T3.FNAME AS 客户,T1.FBILLALLAMOUNT_LC AS 价税合计 FROM T_SAL_ORDER T0 LEFT JOIN T_SAL_ORDERFIN T1 ON T1.FID = T0.FID LEFT JOIN T_BD_CUSTOMER T2 ON T2.FCUSTID = T0.FCUSTID LEFT JOIN T_BD_CUSTOMER_L T3 ON T3.FCUSTID = T2.FCUSTID AND T3.FLOCALEID = 2052 {2} ) t1 """,seqFld,tableName,strFilter); DBUtils.ExecuteDynamicObject(this.Context, sql);#之前发版,误删 #获取过滤条件 def GetFilterWhere(Filter): customFiler = Filter.FilterParameter.CustomFilter; strwhere = StringBuilder() strwhere.AppendLine("WHERE T0.FDOCUMENTSTATUS = 'C' "); strCustName = GetBaseDataNameValue(customFiler["FCustId"]); #if判断strCustName结果,方式不局限 strFilterCust = String.format(" AND T3.FNAME = '{0}' ",strCustName) if not String.IsNullOrWhiteSpace(strCustName) else " "; strwhere.AppendLine(strFilterCust); #实例过滤条件框未使用 '''strSDate = customFiler["FStartDate"]; strEDate = customFiler["FEndDate"]; strFilterDate = ""; if strSDate and strEDate: strFilterDate = String.format(" AND T0.FDATE >= '{0}' AND T0.FDATE <= '{1}' ",strSDate,strEDate); strwhere.AppendLine(strFilterDate);''' return strwhere.ToString(); #设置汇总信息 def GetSummaryColumnInfo(Filter): lstfield = List[SummaryField](); sField = SummaryField("价税合计",Core.Enums.BOSEnums.Enu_SummaryType.SUM) lstfield.Add(sField); return lstfield; #排序 def OrderColumn(Filter): OrderBy = ""; datasort = Filter.FilterParameter.SortString.ToString(); if datasort != "": OrderBy = datasort; else: OrderBy = " 日期 "; return OrderBy; #关闭清空临时表 def CloseReport(): this.DropTempTable();
赞 23
23人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读