新增自定义接口,获取销售订单收款金额
This commit is contained in:
@@ -348,9 +348,12 @@
|
|||||||
<Compile Include="SAL_ORDERList\ListUpFJ.cs" />
|
<Compile Include="SAL_ORDERList\ListUpFJ.cs" />
|
||||||
<Compile Include="SAL_ORDER\DataChage.cs" />
|
<Compile Include="SAL_ORDER\DataChage.cs" />
|
||||||
<Compile Include="SAL_ORDER\SaveWL.cs" />
|
<Compile Include="SAL_ORDER\SaveWL.cs" />
|
||||||
|
<Compile Include="ScheduleService\SaleOrderReceiveAmount.cs" />
|
||||||
<Compile Include="ScheduleService\SaleOrderSumSicsAmountRefresh.cs" />
|
<Compile Include="ScheduleService\SaleOrderSumSicsAmountRefresh.cs" />
|
||||||
|
<Compile Include="Services\OrgService.cs" />
|
||||||
<Compile Include="Services\SaleOrderService.cs" />
|
<Compile Include="Services\SaleOrderService.cs" />
|
||||||
<Compile Include="Services\SaleSicsService.cs" />
|
<Compile Include="Services\SaleSicsService.cs" />
|
||||||
|
<Compile Include="Services\TempTableService.cs" />
|
||||||
<Compile Include="T_IV_SALESIC\ServicePlugIn\Audit.cs" />
|
<Compile Include="T_IV_SALESIC\ServicePlugIn\Audit.cs" />
|
||||||
<Compile Include="T_IV_SALESIC\ServicePlugIn\Submit.cs" />
|
<Compile Include="T_IV_SALESIC\ServicePlugIn\Submit.cs" />
|
||||||
<Compile Include="T_IV_SALESIC\ServicePlugIn\UnAudit.cs" />
|
<Compile Include="T_IV_SALESIC\ServicePlugIn\UnAudit.cs" />
|
||||||
|
|||||||
101
ScheduleService/SaleOrderReceiveAmount.cs
Normal file
101
ScheduleService/SaleOrderReceiveAmount.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
|
using GZ_LTHPilot_ORDER.Models.VO;
|
||||||
|
using GZ_LTHPilot_ORDER.Service;
|
||||||
|
using GZ_LTHPilot_ORDER.Services;
|
||||||
|
using Kingdee.BOS;
|
||||||
|
using Kingdee.BOS.App;
|
||||||
|
using Kingdee.BOS.Contracts;
|
||||||
|
using Kingdee.BOS.Core;
|
||||||
|
using Kingdee.BOS.ServiceHelper;
|
||||||
|
using Kingdee.BOS.Util;
|
||||||
|
using Kingdee.BOS.WebApi.FormService;
|
||||||
|
using Kingdee.K3.FIN.App.Core.Match.Object;
|
||||||
|
using NPOI.SS.Formula.Functions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace GZ_LTHPilot_ORDER.ScheduleService
|
||||||
|
{
|
||||||
|
[Description("定时刷新销售订单累计核销金额#"), HotUpdate]
|
||||||
|
public class SaleOrderReceiveAmount : IScheduleService
|
||||||
|
{
|
||||||
|
public void Run(Context ctx, Schedule schedule)
|
||||||
|
{
|
||||||
|
TempTableService tempTableService = new TempTableService(ctx);
|
||||||
|
OrgService orgService = new OrgService(ctx);
|
||||||
|
SaleOrderService saleOrderService = new SaleOrderService(ctx);
|
||||||
|
var orgList = orgService.GetOrgList();
|
||||||
|
var tableName = tempTableService.CreateTempTable();
|
||||||
|
CreateTempTable(ctx, tableName);
|
||||||
|
foreach (var item in orgList)
|
||||||
|
{
|
||||||
|
var advanceAays = GetAdvanceAays(schedule);
|
||||||
|
var orgId = item["FORGID"].ToString();
|
||||||
|
// 提前天的日期
|
||||||
|
var startDate = DateTime.Now.Date.AddDays(-advanceAays - 1);
|
||||||
|
var endDate = DateTime.Now;
|
||||||
|
var receiveAmountList = saleOrderService.GetSaleOrderReceiveAmountByDate(orgId, startDate, endDate);
|
||||||
|
InsertDataToTempTable(ctx, tableName, orgId, receiveAmountList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int InsertDataToTempTable(Context ctx, string tableName, string orgId, List<SaleExecuteOut> saleExecuteOuts)
|
||||||
|
{
|
||||||
|
var values = saleExecuteOuts.Select(n => $"({orgId},'{n.FSALEORGNAME}','{n.FBILLNO}',{n.FALLMATCHAMOUNT},'{n.FDate}')");
|
||||||
|
var valuesString = string.Join(",", values);
|
||||||
|
var sqlTemp = $@"
|
||||||
|
INSERT INTO
|
||||||
|
{tableName} (FORGID, FORGNAME, FBILLNO, FAMOUNT, FDATE)
|
||||||
|
VALUES
|
||||||
|
{valuesString}
|
||||||
|
";
|
||||||
|
return DBServiceHelper.Execute(ctx, sqlTemp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateTempTable(Context ctx, string tableName)
|
||||||
|
{
|
||||||
|
var sql = $@"
|
||||||
|
CREATE TABLE
|
||||||
|
{tableName} (
|
||||||
|
FORGID int,
|
||||||
|
FORGNAME NVARCHAR (100),
|
||||||
|
FBILLNO NVARCHAR (100),
|
||||||
|
FAMOUNT decimal,
|
||||||
|
FDATE DATETIME,
|
||||||
|
);
|
||||||
|
";
|
||||||
|
DBServiceHelper.Execute(ctx, sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 参数获取提前天
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="schedule"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private int GetAdvanceAays(Schedule schedule)
|
||||||
|
{
|
||||||
|
// 参数获取提前天
|
||||||
|
var advanceAaysStr = schedule.Parameters;
|
||||||
|
int advanceAays;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
advanceAays = Convert.ToInt32(advanceAaysStr);
|
||||||
|
if (advanceAays < 0)
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw new Exception("获取参数提前天失败,参数格式为整数,且大于等于0");
|
||||||
|
}
|
||||||
|
return advanceAays;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ using System.ComponentModel;
|
|||||||
|
|
||||||
namespace GZ_LTHPilot_ORDER.ScheduleService
|
namespace GZ_LTHPilot_ORDER.ScheduleService
|
||||||
{
|
{
|
||||||
[Description("定时刷新#"), HotUpdate]
|
[Description("定时刷新销售订单累计开票金额#"), HotUpdate]
|
||||||
public class SaleOrderSumSicsAmountRefresh : IScheduleService
|
public class SaleOrderSumSicsAmountRefresh : IScheduleService
|
||||||
{
|
{
|
||||||
public void Run(Context ctx, Schedule schedule)
|
public void Run(Context ctx, Schedule schedule)
|
||||||
|
|||||||
33
Services/OrgService.cs
Normal file
33
Services/OrgService.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using Kingdee.BOS;
|
||||||
|
using Kingdee.BOS.Orm.DataEntity;
|
||||||
|
using Kingdee.BOS.ServiceHelper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GZ_LTHPilot_ORDER.Services
|
||||||
|
{
|
||||||
|
public class OrgService
|
||||||
|
{
|
||||||
|
public Context ctx;
|
||||||
|
public OrgService(Context ctx)
|
||||||
|
{
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
public DynamicObjectCollection GetOrgList()
|
||||||
|
{
|
||||||
|
var sql = @"/*dialect*/SELECT
|
||||||
|
t0.FORGID,
|
||||||
|
t0l.FNAME,
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
T_ORG_ORGANIZATIONS t0
|
||||||
|
LEFT JOIN T_ORG_ORGANIZATIONS_L t0L ON t0.FORGID = t0L.FORGID
|
||||||
|
AND FLOCALEID = 2052
|
||||||
|
";
|
||||||
|
return DBServiceHelper.ExecuteDynamicObject(this.ctx, sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,12 +86,16 @@ WHERE
|
|||||||
var result = JsonConvert.DeserializeObject<KingdeeResult<SaleExecuteOut>>(resultString);
|
var result = JsonConvert.DeserializeObject<KingdeeResult<SaleExecuteOut>>(resultString);
|
||||||
var rows = result.Result.Rows;
|
var rows = result.Result.Rows;
|
||||||
var dataRow = rows.Where(n => n.FBILLNO == billNo).FirstOrDefault();
|
var dataRow = rows.Where(n => n.FBILLNO == billNo).FirstOrDefault();
|
||||||
if (dataRow != null)
|
if (dataRow == null)
|
||||||
{
|
{
|
||||||
return Convert.ToDecimal(dataRow.FALLMATCHAMOUNT);
|
|
||||||
}
|
|
||||||
return 0m;
|
return 0m;
|
||||||
}
|
}
|
||||||
|
if (dataRow.FALLMATCHAMOUNT.IsNullOrEmptyOrWhiteSpace())
|
||||||
|
{
|
||||||
|
return 0m;
|
||||||
|
}
|
||||||
|
return Convert.ToDecimal(dataRow.FALLMATCHAMOUNT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public DynamicObject GetSaleOrderByBillNoAndOrgId(string orgId, string billNo)
|
public DynamicObject GetSaleOrderByBillNoAndOrgId(string orgId, string billNo)
|
||||||
@@ -125,7 +129,7 @@ WHERE
|
|||||||
{
|
{
|
||||||
FSaleOrgList = orgId,
|
FSaleOrgList = orgId,
|
||||||
FSoFromDate = startDate,
|
FSoFromDate = startDate,
|
||||||
FSoToDate = startDate,
|
FSoToDate = endDate,
|
||||||
FFormCloseStatus = "ALL",
|
FFormCloseStatus = "ALL",
|
||||||
FFormStatus = "C",
|
FFormStatus = "C",
|
||||||
FPriceFrom = "SALORDERBILL",
|
FPriceFrom = "SALORDERBILL",
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ FROM
|
|||||||
AND FCANCELSTATUS = 'A'
|
AND FCANCELSTATUS = 'A'
|
||||||
AND FSALEORGID = '{0}'
|
AND FSALEORGID = '{0}'
|
||||||
AND F_PaperNumber = '{1}'
|
AND F_PaperNumber = '{1}'
|
||||||
|
AND FDATE >= '2025-01-01'
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
'100302' FSALEORGID, -- 销售组织
|
'100302' FSALEORGID, -- 销售组织
|
||||||
|
|||||||
47
Services/TempTableService.cs
Normal file
47
Services/TempTableService.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
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_LTHPilot_ORDER.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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user