1
This commit is contained in:
215
JiXiaoKanBan/ResultsKanbanSumReport_bak.cs
Normal file
215
JiXiaoKanBan/ResultsKanbanSumReport_bak.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using GZ_LTHReportForms.Services;
|
||||
using Kingdee.BOS;
|
||||
using Kingdee.BOS.App.Data;
|
||||
using Kingdee.BOS.Contracts.Report;
|
||||
using Kingdee.BOS.Core.Enums;
|
||||
using Kingdee.BOS.Core.Report;
|
||||
using Kingdee.BOS.Orm.DataEntity;
|
||||
using Kingdee.BOS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GZ_LTHReportForms.JiXiaoKanBan
|
||||
{
|
||||
[Description("【列表插件】绩效看板汇总报表【报表】"), HotUpdate]
|
||||
public class ResultsKanbanSumReport_bak : SysReportBaseService
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
this.ReportProperty.ReportName = new LocaleValue("绩效看板汇总", base.Context.UserLocale.LCID);
|
||||
this.ReportProperty.IsUIDesignerColumns = false;
|
||||
// 简单账表类型:普通、树形、分页
|
||||
this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
|
||||
this.IsCreateTempTableByPlugin = true;
|
||||
//
|
||||
this.IsCreateTempTableByPlugin = true;
|
||||
//支持分组汇总
|
||||
this.ReportProperty.IsGroupSummary = true;
|
||||
//
|
||||
this.ReportProperty.SimpleAllCols = false;
|
||||
//
|
||||
this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true;
|
||||
|
||||
// 设置精度控制
|
||||
var list = new List<DecimalControlField>
|
||||
{
|
||||
new DecimalControlField("FDECIMALS", "OrigInvoiceAmount"),
|
||||
new DecimalControlField("FDECIMALS", "ExchangeRate"),
|
||||
new DecimalControlField("FDECIMALS", "InvoiceAmountTHB"),
|
||||
new DecimalControlField("FDECIMALS", "MonthEndExRate"),
|
||||
new DecimalControlField("FDECIMALS", "RevaluationAountInTHB"),
|
||||
new DecimalControlField("FDECIMALS", "UnrealizedGainLoss"),
|
||||
};
|
||||
this.ReportProperty.DecimalControlFieldList = list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充过滤条件
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public override ReportTitles GetReportTitles(IRptParams filter)
|
||||
{
|
||||
|
||||
ReportTitles reportTitles = new ReportTitles();
|
||||
DynamicObject customFilter = filter.FilterParameter.CustomFilter;
|
||||
if (customFilter == null)
|
||||
{
|
||||
return reportTitles;
|
||||
}
|
||||
// 供需组织 List
|
||||
var salesPersons = customFilter["F_Salesperson"] as DynamicObjectCollection;
|
||||
if (salesPersons.Count > 0)
|
||||
{
|
||||
reportTitles.AddTitle("F_Salesperson", string.Join(",", salesPersons.Select(n => (n["F_Salesperson"] as DynamicObject)["Name"].ToString())));
|
||||
}
|
||||
var startDate = Convert.ToDateTime(customFilter["FSDate"]);
|
||||
var endDate = Convert.ToDateTime(customFilter["FEDate"]);
|
||||
reportTitles.AddTitle("FStartDate", startDate.ToString("yyyy-MM-dd"));
|
||||
reportTitles.AddTitle("FEndDate", endDate.ToString("yyyy-MM-dd"));
|
||||
return reportTitles;
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示报表数据
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <param name="tableName"></param>
|
||||
public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
|
||||
{
|
||||
base.BuilderReportSqlAndTempTable(filter, tableName);
|
||||
//获取过滤条件
|
||||
string Filter = GetFilterWhere(filter);
|
||||
|
||||
|
||||
DynamicObject customFilter = filter.FilterParameter.CustomFilter;
|
||||
DateTime startDate = Convert.ToDateTime(customFilter["FSDate"]);
|
||||
DateTime endDate = Convert.ToDateTime(customFilter["FEDate"]);
|
||||
if (startDate.Year != endDate.Year)
|
||||
{
|
||||
throw new Exception("开始时间和结束时间必须是同一年份");
|
||||
}
|
||||
if (startDate > endDate)
|
||||
{
|
||||
throw new Exception("开始时间不能大于结束时间");
|
||||
}
|
||||
JixiaoKanBanService jixiaoKanBanService = new JixiaoKanBanService(this.Context);
|
||||
var thisDateChange = jixiaoKanBanService.GetThisDateChangedSaleOrder(startDate, endDate);
|
||||
var lastDateChange = jixiaoKanBanService.GetLastDateChangedSaleOrder(startDate);
|
||||
var excludeOrder = jixiaoKanBanService.GetExcludeOrder();
|
||||
// 获取当期和往期的金额
|
||||
var thisDateOrderAmount = jixiaoKanBanService.GetThisDateOrderAmount(startDate, endDate);
|
||||
var lastDateOrderAmount = jixiaoKanBanService.GetLastDateOrderAmount(startDate);
|
||||
var sumAmount = jixiaoKanBanService.GetThisDateSumAmount();
|
||||
string sql = $@"/*dialect*/SELECT
|
||||
*,
|
||||
0 本年华夏云联业绩_万元,
|
||||
0 去年合计业绩额_万元,
|
||||
0 回款额_万元,
|
||||
0 已发货应收款_万元,
|
||||
0 已到期应收款_万元,
|
||||
ROW_NUMBER() OVER (
|
||||
ORDER BY
|
||||
销售员
|
||||
) FIDENTITYID INTO {tableName}
|
||||
FROM
|
||||
{sumAmount}
|
||||
";
|
||||
DBUtils.Execute(this.Context, sql);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报表列表头
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
public override ReportHeader GetReportHeaders(IRptParams filter)
|
||||
{
|
||||
base.GetReportHeaders(filter);
|
||||
DynamicObject customFilter = filter.FilterParameter.CustomFilter;
|
||||
DateTime startDate = Convert.ToDateTime(customFilter["FSDate"]);
|
||||
ReportHeader header = new ReportHeader();
|
||||
var year = startDate.Year;
|
||||
|
||||
header.AddChild("F_SBU", new LocaleValue("SBU"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("F_MXQY", new LocaleValue("明细区域"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("销售员", new LocaleValue("销售员"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("本年业绩目标_万元", new LocaleValue("" + year + "年业绩目标(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年派诺业绩_万元", new LocaleValue("" + year + "派诺业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年兴诺业绩_万元", new LocaleValue("" + year + "兴诺业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年武汉派诺_万元", new LocaleValue("" + year + "武汉派诺(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年碳索业绩_万元", new LocaleValue("" + year + "碳索业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年香港派诺业绩_万元", new LocaleValue("" + year + "香港派诺业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年华夏云联业绩_万元", new LocaleValue("" + year + "华夏云联业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年诺瓦数能业绩_万元", new LocaleValue("" + year + "诺瓦数能业绩(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("往年订单变更金额_万元", new LocaleValue("往年订单变更金额(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("本年业绩合计_万元", new LocaleValue("" + year + "合计业绩额(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("达标率", new LocaleValue("达标率"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("去年合计业绩额_万元", new LocaleValue("" + (year - 1) + "合计业绩额(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("同比增长率", new LocaleValue("同比增长率"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("本年回款目标_万元", new LocaleValue("" + year + "回款目标(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("回款额_万元", new LocaleValue("回款额(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("回款率", new LocaleValue("回款率"), SqlStorageType.Sqlvarchar);
|
||||
header.AddChild("已发货应收款_万元", new LocaleValue("已发货应收款(万元)"), SqlStorageType.SqlDecimal);
|
||||
header.AddChild("已到期应收款_万元", new LocaleValue("已到期应收款(万元)"), SqlStorageType.SqlDecimal);
|
||||
|
||||
foreach (var item in header.GetChilds())
|
||||
{
|
||||
item.Width = 160;
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//报表过滤条件-多选销售员
|
||||
private string GetFilterWhere(IRptParams filter)
|
||||
{
|
||||
DynamicObject customFilter = filter.FilterParameter.CustomFilter;
|
||||
StringBuilder strwhere = new StringBuilder(); //创建字符串构建器;
|
||||
strwhere.AppendLine("WHERE 1=1");
|
||||
var xsy = customFilter["F_Salesperson"] as DynamicObjectCollection;
|
||||
if (xsy.Count > 0)
|
||||
{
|
||||
List<string> xsyList = new List<string>();
|
||||
//循环获取物料信息
|
||||
foreach (DynamicObject dobj in xsy)
|
||||
{
|
||||
DynamicObject dynamic = dobj["F_Salesperson"] as DynamicObject;
|
||||
xsyList.Add(dynamic["Name"].ToString());
|
||||
}
|
||||
strwhere.AppendLine(string.Format(@"AND 销售员 IN ({0})", string.Join(",", xsyList.Select(x => $"'{x}'"))));
|
||||
}
|
||||
return strwhere.ToString();
|
||||
}
|
||||
|
||||
//设置报表合计列
|
||||
public override List<SummaryField> GetSummaryColumnInfo(IRptParams filter)
|
||||
{
|
||||
var result = base.GetSummaryColumnInfo(filter);
|
||||
result.Add(new SummaryField("本年业绩目标_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年派诺业绩_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年兴诺业绩_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年武汉派诺_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年碳索业绩_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年香港派诺业绩_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年华夏云联业绩_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("往年订单变更金额_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("本年业绩合计_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("去年合计业绩额_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("回款额_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("已发货应收款_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
result.Add(new SummaryField("已到期应收款_万元", BOSEnums.Enu_SummaryType.SUM));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user