This commit is contained in:
2025-08-23 15:43:34 +08:00
10 changed files with 911 additions and 44 deletions

View File

@@ -37,6 +37,10 @@
<Reference Include="Kingdee.BOS.App">
<HintPath>..\..\GZ_LTHUPDATEVIEW\bin\Debug\Kingdee.BOS.App.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.App.Core, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.App.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Contracts">
<HintPath>..\..\GZ_LTHUPDATEVIEW\bin\Debug\Kingdee.BOS.Contracts.dll</HintPath>
</Reference>
@@ -46,17 +50,129 @@
<Reference Include="Kingdee.BOS.DataEntity">
<HintPath>..\..\GZ_LTHYJZZHTH\bin\Debug\Kingdee.BOS.DataEntity.dll</HintPath>
</Reference>
<Reference Include="NPOI">
<HintPath>..\..\派诺裴豪-报表\派诺报表\代码\Pilot.Report\Pilot.Report\Pilot.Report.Exploitation\bin\Debug\NPOI.dll</HintPath>
<Reference Include="Kingdee.BOS.ServiceHelper, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.ServiceHelper.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML">
<HintPath>..\..\派诺裴豪-报表\派诺报表\代码\Pilot.Report\Pilot.Report\Pilot.Report.Exploitation\bin\Debug\NPOI.OOXML.dll</HintPath>
<Reference Include="Kingdee.BOS.VerificationHelper, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.VerificationHelper.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net">
<HintPath>..\..\派诺裴豪-报表\派诺报表\代码\Pilot.Report\Pilot.Report\Pilot.Report.Exploitation\bin\Debug\NPOI.OpenXml4Net.dll</HintPath>
<Reference Include="Kingdee.BOS.Web, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.Web.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats">
<HintPath>..\..\派诺裴豪-报表\派诺报表\代码\Pilot.Report\Pilot.Report\Pilot.Report.Exploitation\bin\Debug\NPOI.OpenXmlFormats.dll</HintPath>
<Reference Include="Kingdee.BOS.Web.HTML, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.Web.HTML.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.Web.HTML.Core, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.Web.HTML.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.BOS.WebApi.FormService, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.BOS.WebApi.FormService.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.BD.Contracts, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.BD.Contracts.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.BD.ServiceHelper, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.BD.ServiceHelper.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.Core, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.Business.PlugIn, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.Business.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.Core, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.HS.Business.PlugIn, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.HS.Business.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.HS.Common.BusinessEntity, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.HS.Common.BusinessEntity.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.HS.Contracts, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.HS.Contracts.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.HS.ServiceHelper, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.HS.ServiceHelper.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.FIN.ServiceHelper, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.FIN.ServiceHelper.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.App, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.App.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.BusinessCommon, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.BusinessCommon.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.Contracts, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.Contracts.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.PLN.App.Core, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.PLN.App.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.PLN.App.MrpModel, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.PLN.App.MrpModel.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.PLN.Business.PlugIn, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.PLN.Business.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.PLN.Report.PlugIn, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.PLN.Report.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.MFG.ServiceHelper, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.MFG.ServiceHelper.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.SCM.App.Core, Version=9.0.116.12, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.SCM.App.Core.dll</HintPath>
</Reference>
<Reference Include="Kingdee.K3.SCM.Common.BusinessEntity, Version=9.0.78.3, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Kingdee.K3.SCM.Common.BusinessEntity.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.1.5, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NPOI, Version=2.5.6.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\NPOI.dll</HintPath>
</Reference>
<Reference Include="NPOI.OOXML, Version=2.5.6.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\NPOI.OOXML.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXml4Net, Version=2.5.6.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\NPOI.OpenXml4Net.dll</HintPath>
</Reference>
<Reference Include="NPOI.OpenXmlFormats, Version=2.5.6.1, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Library\NPOI.OpenXmlFormats.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
@@ -69,9 +185,12 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DDWFHMX.cs" />
<Compile Include="JiXiaoKanBan\ResultsKanbanSumReport_bak.cs" />
<Compile Include="JiXiaoKanBan\ResultsKanbanSumReport.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReportGSH\FormServicePlugIn.cs" />
<Compile Include="Services\JixiaoKanBanService.cs" />
<Compile Include="Services\TempTableService.cs" />
<Compile Include="YeJiPaiHangBang\PHBSaleOrderReport.cs" />
<Compile Include="YingShouBaoBiao\YingShouHTXZ.cs" />
<Compile Include="YingShouBaoBiao\YingShouQDNF.cs" />

View File

@@ -68,11 +68,20 @@ namespace GZ_LTHReportForms.JiXiaoKanBan
var salesPersons = customFilter["F_Salesperson"] as DynamicObjectCollection;
if (salesPersons.Count > 0)
{
reportTitles.AddTitle("F_Salesperson", string.Join(",", salesPersons.Select(n => n["Name"].ToString())));
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"]);
if (startDate.Year != endDate.Year)
{
throw new Exception("开始时间和结束时间必须是同一年份");
}
if (startDate > endDate)
{
throw new Exception("开始时间不能大于结束时间");
}
reportTitles.AddTitle("FStartDate", startDate.ToString("yyyy-MM-dd"));
reportTitles.AddTitle("FEndDate", endDate.ToString("yyyy-MM-dd"));
@@ -102,7 +111,7 @@ namespace GZ_LTHReportForms.JiXiaoKanBan
customFilter["FEDate"]).ToString("yyyy-MM-dd");
string sql = string.Format(@"/*dialect*/
EXEC GZ_JXKBHZB_LTH '{0}','{1}'
EXEC GZ_JXKBHZB_LTH '{0}','{1}','1'
SELECT
ROW_NUMBER() OVER (ORDER BY F_SBU DESC) AS FID,
ROW_NUMBER() OVER (ORDER BY F_SBU DESC) AS FIDENTITYID,

View 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;
}
}
}

View File

@@ -0,0 +1,415 @@
using Kingdee.BOS;
using Kingdee.BOS.App;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.ServiceHelper;
namespace GZ_LTHReportForms.Services
{
public class JixiaoKanBanService
{
/// <summary>
/// 金蝶上下文类
/// </summary>
private Context ctx;
/// <summary>
/// 临时表列表
/// </summary>
private Dictionary<string, string> tempTableDict;
/// <summary>
/// 临时表服务
/// </summary>
private TempTableService tempTableService;
public JixiaoKanBanService(Context ctx)
{
this.ctx = ctx;
tempTableService = new TempTableService(ctx);
tempTableDict = new Dictionary<string, string>();
}
public void DeleteTempTable()
{
foreach (var item in tempTableDict.Values)
{
tempTableService.DropTempTable(item);
}
}
/// <summary>
/// 获取当期变更单
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
public string GetThisDateChangedSaleOrder(DateTime startDate, DateTime endDate)
{
var ThisYearChange = tempTableService.CreateTempTable();
this.tempTableDict.Add("ThisYearChange", ThisYearChange);
var sql = $@"/*dialect*/SELECT
MAX(t1.FID) ChangeOrderId, -- 变更单ID
t1.FPKIDX
INTO {ThisYearChange}
FROM
T_SAL_XORDER t1
INNER JOIN T_SAL_XORDERFIN t1fin ON t1.FID = t1fin.FID
WHERE
1 = 1
AND t1fin.FISACTIVE = 'B'
AND t1fin.FACTIVEDATE >= {startDate.ToString("yyyy-MM-dd")}
AND t1fin.FACTIVEDATE <= {endDate.ToString("yyyy-MM-dd")}
GROUP BY
t1.FPKIDX;
";
DBServiceHelper.Execute(ctx, sql);
return ThisYearChange;
}
/// <summary>
/// 获取往期变更单
/// </summary>
/// <param name="startDate"></param>
/// <returns></returns>
public string GetLastDateChangedSaleOrder(DateTime startDate)
{
var LastYearChange = tempTableService.CreateTempTable();
this.tempTableDict.Add("LastYearChange", LastYearChange);
var sql = $@"/*dialect*/SELECT
MAX(t1.FID) ChangeOrderId, -- 变更单ID
t1.FPKIDX
INTO {LastYearChange}
FROM
T_SAL_XORDER t1
INNER JOIN T_SAL_XORDERFIN t1fin ON t1.FID = t1fin.FID
WHERE
1 = 1
AND t1fin.FISACTIVE = 'B'
AND t1fin.FACTIVEDATE <= {startDate.ToString("yyyy-MM-dd")}
GROUP BY
t1.FPKIDX;
";
DBServiceHelper.Execute(ctx, sql);
return LastYearChange;
}
/// <summary>
/// 获取需要排除的销售订单
/// </summary>
/// <returns></returns>
public string GetExcludeOrder()
{
var ExcludeOrder = tempTableService.CreateTempTable();
this.tempTableDict.Add("ExcludeOrder", ExcludeOrder);
var sql = $@"/*dialect*/SELECT
A.FID AS 'FID' --,a.FSALERID,
INTO {ExcludeOrder}
FROM
T_SAL_ORDER A --销售订单表头
INNER JOIN T_ORG_ORGANIZATIONS_L B ON A.FSALEORGID = B.FORGID --组织表
INNER JOIN T_BD_CUSTOMER_L C ON C.FCUSTID = A.FCUSTID
AND C.FLOCALEID = 2052 --客户表
LEFT JOIN V_BD_SALESMAN_L L ON L.fid = A.FSALERID
LEFT JOIN T_PerformanceSharing M ON M.FSOURCEBILLNO = A.FBILLNO
AND M.FDOCUMENTSTATUS = 'C' --业绩分摊单表头
LEFT JOIN T_PerformanceSharingEntry N ON N.FID = M.FID --业绩分摊单表体
LEFT JOIN V_BD_SALESMAN_L O ON O.fid = N.FSALEID
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACO ON ACO.名称 = O.FNAME --对接人力信息
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACL ON ACL.名称 = L.FNAME --对接人力信息
WHERE
A.FSALEORGID = 100302 -- 销售组织=珠海派诺
AND (
ACO.区域 = '碳索智控'
OR ACL.区域 = '碳索智控'
OR C.FNAME IN ('派诺科技(香港有限公司)', '武汉派诺科技发展有限公司') --
OR (
C.FCUSTID = 1150173
AND (
ACO.区域 = '决策团队'
OR ACL.区域 = '决策团队'
)
) --1150173对应的是珠海兴诺能源技术有限公司
OR L.FNAME = '兴诺总'
OR A.FID IN (110185, 207800) -- 样机订单
)
";
DBServiceHelper.Execute(ctx, sql);
return ExcludeOrder;
}
/// <summary>
/// 全组织根据日期显示订单金额(当期)
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
public string GetThisDateOrderAmount(DateTime startDate, DateTime endDate)
{
var ThisYearChange = tempTableDict["ThisYearChange"];
var ExcludeOrder = tempTableDict["ExcludeOrder"];
var ThisDateOrderAmount = tempTableService.CreateTempTable();
tempTableDict.Add("ThisDateOrderAmount", ThisDateOrderAmount);
var sql = $@"/*dialect*/SELECT
A.FBILLNO,
A.FSALEORGID AS FSALEORGID,
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN ACL.区域
ELSE ACO.区域
END AS 'F_SBU',
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN ACL.明细区域
ELSE ACO.明细区域
END AS 'F_MXQY',
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN L.FNAME
ELSE O.FNAME
END AS '销售员',
CASE
WHEN n.FSHARERATE IS NULL THEN CASE
WHEN t1.ChangeOrderId IS NULL THEN ROUND(A.F_AMOUNTSTAR, 10)
ELSE ROUND(t1fen.FBILLALLAMOUNT_LC, 10)
END
ELSE CASE
WHEN t1.ChangeOrderId IS NULL THEN ROUND(A.F_AMOUNTSTAR * (n.FSHARERATE / 100), 10)
ELSE ROUND(
t1fen.FBILLALLAMOUNT_LC * (n.FSHARERATE / 100),
10
)
END
END AS '合同总价'
INTO {ThisDateOrderAmount}
FROM
T_SAL_ORDER A --销售订单表头
INNER JOIn T_SAL_ORDERFIN A_FIN on A.FID = A_FIN.FID -- 表头财务信息
LEFT JOIN {ThisYearChange} t1 on t1.FPKIDX = A.FID -- 今年变更的销售订单新变更单
LEFT JOIN T_SAL_XORDERFIN t1fen on t1.ChangeOrderId = t1fen.FID -- 关联变更单的金额
LEFT JOIN V_BD_SALESMAN_L L ON L.fid = A.FSALERID
left JOIN T_PerformanceSharing M ON M.FSOURCEBILLNO = A.FBILLNO
AND M.FDOCUMENTSTATUS = 'C'
left JOIN T_PerformanceSharingEntry N ON N.FID = M.FID
LEFT JOIN V_BD_SALESMAN_L O ON O.fid = N.FSALEID
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACO ON ACO.名称 = O.FNAME
AND ISNULL (ACO.明细区域, '') != '' --对接人力信息
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACL ON ACL.名称 = L.FNAME
AND ISNULL (ACL.明细区域, '') != '' --对接人力信息
WHERE
1 = 1
AND A.FAPPROVEDATE >= {startDate.ToString("yyyy-MM-dd")} --订单审核日期
AND A.FAPPROVEDATE < {endDate.AddDays(1).ToString("yyyy-MM-dd")} --
AND A.FDocumentStatus = 'C'
AND A.FManualClose <> '1'
AND A.FID NOT IN (
SELECT
FID
FROM
{ExcludeOrder}
)
AND A.F_contractnumber NOT LIKE 'Z%'
";
DBServiceHelper.Execute(ctx, sql);
return ThisDateOrderAmount;
}
/// <summary>
/// 查询全组织根据往期日期显示订单金额
/// </summary>
/// <param name="startDate"></param>
/// <returns></returns>
public string GetLastDateOrderAmount(DateTime startDate)
{
var ThisYearChange = tempTableDict["ThisYearChange"];
var LastYearChange = tempTableDict["LastYearChange"];
var ExcludeOrder = tempTableDict["ExcludeOrder"];
var LastDateOrderAmount = tempTableService.CreateTempTable();
tempTableDict.Add("LastDateOrderAmount", LastDateOrderAmount);
var sql = $@"/*dialect*/SELECT
A.FBILLNO,
A.FSALEORGID AS FSALEORGID,
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN ACL.区域
ELSE ACO.区域
END AS 'F_SBU',
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN ACL.明细区域
ELSE ACO.明细区域
END AS 'F_MXQY',
CASE
WHEN ISNULL (O.FNAME, '') = '' THEN L.FNAME
ELSE O.FNAME
END AS '销售员',
CASE
WHEN n.FSHARERATE IS NULL THEN CASE
WHEN t2fen.FBILLALLAMOUNT_LC IS NULL THEN t1fen.FBILLALLAMOUNT_LC - A.F_AMOUNTSTAR
ELSE t1fen.FBILLALLAMOUNT_LC - t2fen.FBILLALLAMOUNT_LC
END
ELSE CASE
WHEN t1.ChangeOrderId IS NULL THEN ROUND(
t1fen.FBILLALLAMOUNT_LC - A.F_AMOUNTSTAR * (n.FSHARERATE / 100),
10
)
ELSE ROUND(
t1fen.FBILLALLAMOUNT_LC - t2fen.FBILLALLAMOUNT_LC * (n.FSHARERATE / 100),
10
)
END
END AS '变更金额'
INTO {LastDateOrderAmount}
FROM
T_SAL_ORDER A --销售订单表头
INNER JOIn T_SAL_ORDERFIN A_FIN on A.FID = A_FIN.FID -- 表头财务信息
INNER JOIN {ThisYearChange} t1 on t1.FPKIDX = A.FID -- 当期变更的销售订单新变更单
LEFT JOIN T_SAL_XORDERFIN t1fen on t1.ChangeOrderId = t1fen.FID -- 关联变更单的金额
LEFT JOIN {LastYearChange} t2 on t1.FPKIDX = A.FID -- 往期变更的销售订单新变更单
LEFT JOIN T_SAL_XORDERFIN t2fen on t2.ChangeOrderId = t2fen.FID -- 关联变更单的金额
LEFT JOIN V_BD_SALESMAN_L L ON L.fid = A.FSALERID
left JOIN T_PerformanceSharing M ON M.FSOURCEBILLNO = A.FBILLNO
AND M.FDOCUMENTSTATUS = 'C'
left JOIN T_PerformanceSharingEntry N ON N.FID = M.FID
LEFT JOIN V_BD_SALESMAN_L O ON O.fid = N.FSALEID
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACO ON ACO.名称 = O.FNAME
AND ISNULL (ACO.明细区域, '') != ''
LEFT JOIN ERPTOHR.HYHRV3.dbo.v_erp_empinfo ACL ON ACL.名称 = L.FNAME
AND ISNULL (ACL.明细区域, '') != ''
WHERE
1 = 1
AND A.FAPPROVEDATE < {startDate.ToString("yyyy-MM-dd")} --订单审核日期
AND A.FDocumentStatus = 'C'
AND A.FManualClose <> '1'
AND A.FID NOT IN (
SELECT
FID
FROM
{ExcludeOrder}
)
AND A.F_contractnumber NOT LIKE 'Z%'
";
DBServiceHelper.Execute(ctx, sql);
return LastDateOrderAmount;
}
public string GetThisDateSumAmount()
{
var ThisDateOrderAmount = tempTableDict["ThisDateOrderAmount"];
var LastDateOrderAmount = tempTableDict["LastDateOrderAmount"];
var SumAmount = tempTableService.CreateTempTable();
var ThisDateOrderAmountTemp = tempTableService.CreateTempTable();
var LastDateOrderAmountTemp = tempTableService.CreateTempTable();
var YJMB = tempTableService.CreateTempTable();
tempTableDict.Add("SumAmount", SumAmount);
tempTableDict.Add("ThisDateOrderAmountTemp", ThisDateOrderAmountTemp);
tempTableDict.Add("LastDateOrderAmountTemp", LastDateOrderAmountTemp);
tempTableDict.Add("YJMB", YJMB);
var sql1 = $@"/*dialect*/SELECT
F_SBU,
F_MXQY,
销售员,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '100302'
) 本年派诺业绩_万元,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '100303'
) 本年兴诺业绩_万元,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '100305'
) 本年武汉派诺_万元,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '438223'
) 本年碳索业绩_万元,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '438224'
) 本年香港派诺业绩_万元,
(
SELECT
ISNULL (SUM(合同总价), 0)
FROM
{ThisDateOrderAmount}
WHERE
FSALEORGID = '1467475'
) 本年诺瓦数能业绩_万元
INTO {ThisDateOrderAmountTemp}
FROM
{ThisDateOrderAmount} t1
GROUP BY
F_SBU,
F_MXQY,
销售员
";
DBServiceHelper.Execute(ctx, sql1);
var sql2 = $@"/*dialect*/SELECT
F_SBU,
F_MXQY,
销售员,
SUM(变更金额) 变更金额 INTO {LastDateOrderAmountTemp}
FROM
{LastDateOrderAmount} t1
GROUP BY
F_SBU,
F_MXQY,
销售员
";
DBServiceHelper.Execute(ctx, sql2);
var sql3 = $@"/*dialect*/SELECT
FORMAT (A.F_VRYF_Date_83g, 'yyyy') AS '业绩日期',
C.FNAME AS '销售员',
B.FPerformanceTargets AS '业绩目标_万元',
B.FPAYMENTSUM AS '回款目标_万元'
INTO {YJMB}
FROM
MBBA_t_Cust100002 A
INNER JOIN MBBA_t_Cust_Entry100003 B ON A.FID = B.FID
INNEr JOIN V_BD_SALESMAN_L C ON C.fid = B.FNAME
WHERE
FORMAT (A.F_VRYF_Date_83g, 'yyyy') = '{2025}'
";
DBServiceHelper.Execute(ctx, sql3);
var sql = $@"/*dialect*/SELECT
t1.*,
t2.变更金额 往年订单变更金额_万元,
t3.业绩日期,
t3.业绩目标_万元 本年业绩目标_万元,
t3.回款目标_万元,
本年派诺业绩_万元 + 本年兴诺业绩_万元 + 本年武汉派诺_万元 + 本年碳索业绩_万元 + 本年香港派诺业绩_万元 + 本年诺瓦数能业绩_万元 + 变更金额 AS 本年业绩合计_万元
INTO {SumAmount}
FROM
{ThisDateOrderAmountTemp} t1
LEFT JOIN {LastDateOrderAmountTemp} t2 ON t1.F_SBU = t2.F_SBU
AND t1.F_MXQY = t2.F_MXQY
AND t1.销售员 = t2.销售员
LEFT JOIN {YJMB} t3 ON t1.销售员 = t3.销售员
";
DBServiceHelper.Execute(ctx, sql);
return SumAmount;
}
}
}

View File

@@ -0,0 +1,48 @@
using Kingdee.BOS;
using Kingdee.BOS.App;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GZ_LTHReportForms.Services
{
internal class TempTableService
{
private Context ctx;
public TempTableService(Context ctx)
{
this.ctx = ctx;
}
/// <summary>
/// 删除临时表
/// </summary>
/// <param name="ctx"></param>
/// <param name="tempTable"></param>
public void DropTempTable(string tableName)
{
if (!tableName.IsNullOrEmptyOrWhiteSpace())
{
IDBService dbservice = ServiceHelper.GetService<IDBService>();
dbservice.DeleteTemporaryTableName(ctx, new string[] { tableName });
}
}
/// <summary>
/// 创建临时表
/// </summary>
/// <param name="ctx"></param>
/// <returns></returns>
public string CreateTempTable()
{
IDBService dbservice = ServiceHelper.GetService<IDBService>();
string[] temptables = dbservice.CreateTemporaryTableName(ctx, 1);
return temptables[0];
}
}
}

View File

@@ -94,7 +94,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivableStatements
header.AddChild("PPBillingAmount", new LocaleValue("星空普票开票金额"), SqlStorageType.SqlDecimal);
header.AddChild("ZPBillingDate", new LocaleValue("专票开票日期"), SqlStorageType.Sqlvarchar);
header.AddChild("ZPBillingAmount", new LocaleValue("星空专票开票金额"), SqlStorageType.SqlDecimal);
header.AddChild("BillingAmount", new LocaleValue("总票金额"), SqlStorageType.SqlDecimal);
header.AddChild("BillingAmount", new LocaleValue("总票金额"), SqlStorageType.SqlDecimal);
header.AddChild("PaymentDate", new LocaleValue("回款日期"), SqlStorageType.Sqlvarchar);
header.AddChild("PaymentAmount", new LocaleValue("回款金额"), SqlStorageType.SqlDecimal);
header.AddChild("ShippedDebt", new LocaleValue("已出货欠款"), SqlStorageType.SqlDecimal);

View File

@@ -35,7 +35,18 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// 判断 应收对账单【明细版】按钮
if (e.BarItemKey == "Test_Button_1")
{
string FPath = "应收账款对账单【明细版】.xlsx";
var reportModel = this.SysReportModel;
//单据头
var rptTitles = reportModel.ReportTitles;
string fClient = rptTitles.FirstOrDefault(a => a.TitleKey == "FClient").TitleValue.ToString();
string fDate = rptTitles.FirstOrDefault(a => a.TitleKey == "FDate").TitleValue.ToString();
string fProject = rptTitles.FirstOrDefault(a => a.TitleKey == "FProject").TitleValue.ToString();
string FState = rptTitles.FirstOrDefault(a => a.TitleKey == "FState").TitleValue.ToString();
string F_SFYJKH = rptTitles.FirstOrDefault(a => a.TitleKey == "F_SFYJKH").TitleValue.ToString();
//string FPath = "应收账款对账单【明细版】.xlsx";
string FPath = string.Format("{0}-{1}-应收账款对账单【明细版】.xlsx", DateTime.Now.ToString("yyyyMMdd"), fClient);
// 在临时文件目录,生成一个完整的文件名: C:\Program Files\Kingdee\K3Cloud\WebSite\...\JD.xls
string filePath = PathUtils.GetPhysicalPath(KeyConst.TEMPFILEPATH, Path.GetFileName(FPath));
@@ -49,15 +60,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
//显示
this.View.ShowForm(showParameter);
var reportModel = this.SysReportModel;
//单据头
var rptTitles = reportModel.ReportTitles;
string fClient = rptTitles.FirstOrDefault(a => a.TitleKey == "FClient").TitleValue.ToString();
string fDate = rptTitles.FirstOrDefault(a => a.TitleKey == "FDate").TitleValue.ToString();
string fProject = rptTitles.FirstOrDefault(a => a.TitleKey == "FProject").TitleValue.ToString();
string FState = rptTitles.FirstOrDefault(a => a.TitleKey == "FState").TitleValue.ToString();
string F_SFYJKH = rptTitles.FirstOrDefault(a => a.TitleKey == "F_SFYJKH").TitleValue.ToString();
//单据体
var list = reportModel.DataSource.Rows;
@@ -110,6 +113,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
cellStyle.Alignment = HorizontalAlignment.Center;
// 设置垂直居中对齐
cellStyle.VerticalAlignment = VerticalAlignment.Center;
//设置数值格式保留两位小数
cellStyle.DataFormat = workbook.CreateDataFormat().GetFormat("0.00");
// 创建一个单元格样式---------------------------------
ICellStyle cellStyle2 = workbook.CreateCellStyle();
@@ -167,6 +172,21 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
// 将字体应用到单元格样式
style3.SetFont(font3);
// 创建一个单元格样式-------------------------------
ICellStyle style4 = workbook.CreateCellStyle();
// 设置边框样式
style4.BorderTop = BorderStyle.Thin;
style4.BorderBottom = BorderStyle.Thin;
style4.BorderLeft = BorderStyle.Thin;
style4.BorderRight = BorderStyle.Thin;
// 设置水平居中对齐
style4.Alignment = HorizontalAlignment.Left;
// 设置垂直居中对齐
style4.VerticalAlignment = VerticalAlignment.Center;
// 将字体应用到单元格样式
style4.SetFont(font3);
style4.DataFormat = workbook.CreateDataFormat().GetFormat("0.00");
#endregion
#region
@@ -181,7 +201,8 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
{
YFHpriceSum = Math.Round(Convert.ToDecimal(list[i]["ShippedDebt"]), 2);
YFPpriceSum = Math.Round(Convert.ToDecimal(list[i]["InvoicedDebt"]), 2);
priceSum = Math.Round(Convert.ToDecimal(list[i]["ShippedDebt"]) + Convert.ToDecimal(list[i]["InvoicedDebt"]), 2);
//priceSum = Math.Round(Convert.ToDecimal(list[i]["ShippedDebt"]) + Convert.ToDecimal(list[i]["InvoicedDebt"]), 2);
priceSum = Math.Round(Convert.ToDecimal(list[i]["OwedTickets"]), 2);
}
}
@@ -242,7 +263,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
string BillingDate = string.IsNullOrWhiteSpace(list[i]["ZPBillingDate"].ToString()) ? "" : list[i]["ZPBillingDate"].ToString().Split(' ')[0];
string ReturnDate = string.IsNullOrWhiteSpace(list[i]["ReturnDate"].ToString()) ? "" : list[i]["ReturnDate"].ToString().Split(' ')[0];
BillingDate += string.IsNullOrWhiteSpace(list[i]["PPBillingDate"].ToString()) ? "" : (string.IsNullOrWhiteSpace(BillingDate) ?"":",")+list[i]["PPBillingDate"].ToString().Split(' ')[0];
//BillingDate += string.IsNullOrWhiteSpace(list[i]["PPBillingDate"].ToString()) ? "" : (string.IsNullOrWhiteSpace(BillingDate) ?"":",")+list[i]["PPBillingDate"].ToString().Split(' ')[0];
//将合计行放到最下方
IRow rowi = sheet.CreateRow(j + i);
@@ -262,28 +283,28 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
if(!string.IsNullOrWhiteSpace(list[i]["FQty"].ToString()))
{
int FQty = Convert.ToInt32(list[i]["FQty"]);
c6.SetCellValue("" + FQty + ""); c6.CellStyle = cellStyle; //数量
c6.SetCellValue(Convert.ToDouble(FQty)); c6.CellStyle = cellStyle; //数量
}
ICell c7 = rowi.CreateCell(6); c7.SetCellValue(""); c7.CellStyle = cellStyle;
if(!string.IsNullOrWhiteSpace(list[i]["FTaxPrice"].ToString()))
{
decimal FTaxPrice = Math.Round(Convert.ToDecimal(list[i]["FTaxPrice"]), 2);
c7.SetCellValue("" + FTaxPrice + ""); c7.CellStyle = cellStyle;
c7.SetCellValue(Convert.ToDouble(FTaxPrice )); c7.CellStyle = cellStyle;
}
ICell c8 = rowi.CreateCell(7); c8.SetCellValue(""); c8.CellStyle = cellStyle;
if(!string.IsNullOrWhiteSpace(list[i]["FAllAmount"].ToString()))
{
decimal FAllAmount = Math.Round(Convert.ToDecimal(list[i]["FAllAmount"]), 2);
c8.SetCellValue("" + FAllAmount + ""); c8.CellStyle = cellStyle;
c8.SetCellValue(Convert.ToDouble(FAllAmount)); c8.CellStyle = cellStyle;
}
ICell c9 = rowi.CreateCell(8); c9.SetCellValue(""); c9.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["OrderAmount"].ToString()))
{
decimal OrderAmount = Math.Round(Convert.ToDecimal(list[i]["OrderAmount"]), 2);
c9.SetCellValue("" + OrderAmount + ""); c9.CellStyle = cellStyle;
c9.SetCellValue(Convert.ToDouble(OrderAmount)); c9.CellStyle = cellStyle;
}
@@ -291,28 +312,28 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
if (!string.IsNullOrWhiteSpace(list[i]["ShipmentsNum"].ToString()))
{
int ShipmentsNum = Convert.ToInt32(list[i]["ShipmentsNum"]);
c11.SetCellValue("" + ShipmentsNum + ""); c11.CellStyle = cellStyle;
c11.SetCellValue(Convert.ToDouble(ShipmentsNum)); c11.CellStyle = cellStyle;
}
ICell c12 = rowi.CreateCell(11); c12.SetCellValue(""); c12.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["ShipmentsAmount"].ToString()))
{
decimal ShipmentsAmount = Math.Round(Convert.ToDecimal(list[i]["ShipmentsAmount"]), 2);
c12.SetCellValue("" + ShipmentsAmount + ""); c12.CellStyle = cellStyle;
c12.SetCellValue(Convert.ToDouble(ShipmentsAmount)); c12.CellStyle = cellStyle;
}
ICell c14 = rowi.CreateCell(13); c14.SetCellValue(""); c14.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["ReturnNum"].ToString()))
{
int ReturnNum = Convert.ToInt32(list[i]["ReturnNum"]);
c14.SetCellValue("" + ReturnNum + ""); c14.CellStyle = cellStyle;
c14.SetCellValue(Convert.ToDouble(ReturnNum)); c14.CellStyle = cellStyle;
}
ICell c15 = rowi.CreateCell(14); c15.SetCellValue(""); c15.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["ReturnAmount"].ToString()))
{
decimal ReturnAmount = Math.Round(Convert.ToDecimal(list[i]["ReturnAmount"]), 2);
c15.SetCellValue("" + ReturnAmount + ""); c15.CellStyle = cellStyle;
c15.SetCellValue(Convert.ToDouble(ReturnAmount)); c15.CellStyle = cellStyle;
}
ICell c19 = rowi.CreateCell(18); c19.SetCellValue(""); c19.CellStyle = cellStyle;
@@ -320,21 +341,21 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
{
decimal PaymentAmount = Math.Round(Convert.ToDecimal(list[i]["PaymentAmount"]), 2);
c19.SetCellValue("" + PaymentAmount + ""); c19.CellStyle = cellStyle;
c19.SetCellValue(Convert.ToDouble(PaymentAmount)); c19.CellStyle = cellStyle;
}
ICell c20 = rowi.CreateCell(19); c20.SetCellValue(""); c20.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["ShippedDebt"].ToString()))
{
decimal ShippedDebt = Math.Round(Convert.ToDecimal(list[i]["ShippedDebt"]), 2);
c20.SetCellValue("" + ShippedDebt + ""); c20.CellStyle = cellStyle;
c20.SetCellValue(Convert.ToDouble(ShippedDebt)); c20.CellStyle = cellStyle;
}
ICell c21 = rowi.CreateCell(20); c21.SetCellValue(""); c21.CellStyle = cellStyle;
if (!string.IsNullOrWhiteSpace(list[i]["InvoicedDebt"].ToString()))
{
decimal InvoicedDebt = Math.Round(Convert.ToDecimal(list[i]["InvoicedDebt"]), 2);
c21.SetCellValue("" + InvoicedDebt + ""); c21.CellStyle = cellStyle;
c21.SetCellValue(Convert.ToDouble(InvoicedDebt)); c21.CellStyle = cellStyle;
}
ICell c17 = rowi.CreateCell(16); c17.SetCellValue(""); c17.CellStyle = cellStyle;
@@ -342,7 +363,7 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
{
decimal BillingAmount = Math.Round(Convert.ToDecimal(list[i]["BillingAmount"]), 2);
c17.SetCellValue("" + BillingAmount + ""); c17.CellStyle = cellStyle;
c17.SetCellValue(Convert.ToDouble(BillingAmount )); c17.CellStyle = cellStyle;
}
ICell c10 = rowi.CreateCell(9); c10.SetCellValue(ShipmentsDate); c10.CellStyle = cellStyle2;//发货日期
@@ -456,9 +477,9 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
ICell cc1 = rr1.GetCell(6);
ICell cc2 = rr2.GetCell(6);
ICell cc3 = rr3.GetCell(6);
cc1.SetCellValue("" + YFHpriceSum + "");
cc2.SetCellValue("" + YFPpriceSum + "");
cc3.SetCellValue("" + priceSum + "");
cc1.SetCellValue(Convert.ToDouble(YFHpriceSum));
cc2.SetCellValue(Convert.ToDouble(YFPpriceSum));
cc3.SetCellValue(Convert.ToDouble(priceSum));
#endregion
@@ -490,10 +511,15 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
}
ICell CR1 = r1.CreateCell(i);
CR1.SetCellValue(test1);
if (i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9)
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
{
CR1.CellStyle = style;
}
else if (i == 6)
{
CR1.SetCellValue(Convert.ToDouble(test1));
CR1.CellStyle = style4;
}
else
{
CR1.CellStyle = style2;
@@ -510,10 +536,15 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
}
ICell CR1 = r2.CreateCell(i);
CR1.SetCellValue(test1);
if (i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9)
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
{
CR1.CellStyle = style;
}
else if (i == 6)
{
CR1.SetCellValue(Convert.ToDouble(test1));
CR1.CellStyle = style4;
}
else
{
CR1.CellStyle = style2;
@@ -530,10 +561,15 @@ namespace Pilot.Report.Exploitation.AccountsReceivable
}
ICell CR1 = r3.CreateCell(i);
CR1.SetCellValue(test1);
if (i == 4 || i == 5 || i == 6 || i == 7 || i == 8 || i == 9)
if (i == 4 || i == 5 || i == 7 || i == 8 || i == 9)
{
CR1.CellStyle = style;
}
else if (i == 6)
{
CR1.SetCellValue(Convert.ToDouble(test1));
CR1.CellStyle = style4;
}
else
{
CR1.CellStyle = style2;

View File

@@ -193,7 +193,8 @@ WHERE B.
SELECT
A.FID,
A.FENTRYID,
SUM(ISNULL(A.ZPBillingAmount,0)) + SUM(ISNULL(A.PPBillingAmount,0)) + SUM(ISNULL(A.K3רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)) + SUM(ISNULL(A.K3<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)) AS 'רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
--SUM(ISNULL(A.ZPBillingAmount,0)) + SUM(ISNULL(A.PPBillingAmount,0)) + SUM(ISNULL(A.K3רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)) + SUM(ISNULL(A.K3<EFBFBD><EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)) AS 'רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
SUM(ISNULL(A.ZPBillingAmount,0)) + SUM(ISNULL(A.K3רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)) AS 'רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
INTO #TEMP3
FROM YingShouZhanKuanMX_GZTH A
WHERE A.[<EFBFBD>Ƿ<EFBFBD>K3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>] = 0
@@ -259,6 +260,7 @@ WHERE B.
UPDATE YingShouZhanKuanMX_GZTH
SET OrderAmount=0,PaymentAmount=0,ShippedDebt=0,InvoicedDebt=0,IsEnded = NULL ,OwedTickets= 0,BillingAmount=0,PPBillingAmount=0,ZPBillingAmount=0,ZPBillingDate='',PPBillingDate='',PaymentDate = '',ShipmentsDate = ''
,ShipmentsAmount = 0,ReturnAmount = 0
from (
SELECT CASE WHEN ROW_NUMBER() OVER(PARTITION BY FBILLNO ORDER BY fid) = 1 THEN FBILLNO
END AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,* FROM YingShouZhanKuanMX_GZTH
@@ -269,7 +271,7 @@ WHERE B.
UPDATE A
SET OwedTickets = B.QP
FROM YingShouZhanKuanMX_GZTH A
JOIN (SELECT FID,SUM(ShipmentsAmount) - SUM(BillingAmount) AS 'QP'--SUM(OrderAmount) - SUM(BillingAmount) AS 'QP'
JOIN (SELECT FID,SUM(ShipmentsAmount) -SUM(ReturnNum)- SUM(BillingAmount) AS 'QP' --SUM(ShipmentsAmount)- SUM(BillingAmount) AS 'QP'
FROM YingShouZhanKuanMX_GZTH GROUP BY FID) B ON A.FID = B.FID
WHERE A.[<EFBFBD>Ƿ<EFBFBD>K3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>] = 0 AND A.row_num = 1

View File

@@ -353,4 +353,16 @@ AND B.
AND B.ShouKuanFDate < @EndDate
--SELECT OrderAmount,PaymentAmount,ShippedDebt,InvoicedDebt,IsEnded ,OwedTickets,BillingAmount, CASE WHEN ROW_NUMBER() OVER(PARTITION BY FBILLNO ORDER BY fid) = 1 THEN FBILLNO
--END AS <EFBFBD><EFBFBD><EFBFBD><EFBFBD>,* FROM YingShouZhanKuanMX_GZTH
--<EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע
SELECT A.FID,SUM(A.ShipmentsAmount) AS '<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', SUM(A.ReturnAmount) AS '<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',
STUFF((SELECT DISTINCT ','+ReturnDate FROM YingShouZhanKuanMX_GZTH WHERE FID = a.FID FOR XML PATH('')),1,1,'') AS '<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
INTO #TEMP4
FROM YingShouZhanKuanMX_GZTH A
GROUP BY A.FID
UPDATE A
SET A.ShipmentsAmount = ISNULL(B.<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0),A.ReturnAmount = ISNULL(B.<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0),A.ReturnDate = ISNULL(B.<EFBFBD>˻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'')
FROM YingShouZhanKuanMX_GZTH A
INNER JOIN #TEMP4 B ON A.FID = B.FID
END

View File

@@ -51,6 +51,17 @@ INNER JOIN #CFTEMP1 B On A.FID = B.FID
DELETE FROM YingShouZhanKuanJY_GZTH
WHERE row_num <> 1;
UPDATE A
SET A.Number = B.row_num1
FROM YingShouZhanKuanJY_GZTH A
INNER JOIN (
SELECT
FID,
ROW_NUMBER() OVER (ORDER BY FID) as row_num1
FROM YingShouZhanKuanJY_GZTH
) B On A.FID = B.FID
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>רƱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʊ<EFBFBD>Ŀ<EFBFBD>Ʊʱ<EFBFBD><EFBFBD>
UPDATE A
SET A.PPBillingDate = B.PPBillingDate,A.ZPBillingDate = B.ZPBillingDate