This commit is contained in:
2025-08-08 10:36:02 +08:00
parent ec10996079
commit d040b97cbc
4 changed files with 67 additions and 17 deletions

View File

@@ -3,6 +3,7 @@ using Gatedge.Enpower.BOS.PlugIn.Utils;
using GZ_LTHPilot_ORDER.Models.VO;
using GZ_LTHPilot_ORDER.Service;
using GZ_LTHPilot_ORDER.Services;
using GZ_LTHPilot_ORDER.Utils;
using Kingdee.BOS;
using Kingdee.BOS.App;
using Kingdee.BOS.Contracts;
@@ -27,23 +28,17 @@ namespace GZ_LTHPilot_ORDER.ScheduleService
/// 查询周期单位:月
/// </summary>
int Cycle = 12;
public void Run(Context ctx, Schedule schedule)
public void Run(Context oldCtx, Schedule schedule)
{
var ctxString = JsonConvert.SerializeObject(ctx);
Context newCtx = DataCenterService.GetDataCenterContextByID(ctx.DBId);
newCtx.UserId = 131409; //服务操作用户暂时记为Administrator
newCtx.UserName = "ERP6";
newCtx.ServiceType = WebType.WebSite;
newCtx.CurrentOrganizationInfo.ID = 1;
LogUtil.Log("UserContext", ctxString);
TempTableService tempTableService = new TempTableService(newCtx);
OrgService orgService = new OrgService(newCtx);
SaleOrderService saleOrderService = new SaleOrderService(newCtx);
var ctxString = JsonConvert.SerializeObject(oldCtx);
ContextUtil contextUtil = new ContextUtil(oldCtx);
var ctx = contextUtil.GetDefaultContext();
TempTableService tempTableService = new TempTableService(ctx);
OrgService orgService = new OrgService(ctx);
SaleOrderService saleOrderService = new SaleOrderService(ctx);
var orgList = orgService.GetOrgList();
var tableName = tempTableService.CreateTempTable();
CreateTempTable(newCtx, tableName);
CreateTempTable(ctx, tableName);
var advanceAays = GetAdvanceAays(schedule);
var planStartDate = DateTime.Now;
Dictionary<string, string> orgDict = new Dictionary<string, string>();
@@ -66,14 +61,14 @@ namespace GZ_LTHPilot_ORDER.ScheduleService
var receiveAmountList = saleOrderService.GetSaleOrderReceiveAmountByDate(saleOrgIds, startDate, endDate);
if (receiveAmountList.Count > 0)
{
InsertDataToTempTable(newCtx, tableName, orgDict, receiveAmountList);
InsertDataToTempTable(ctx, tableName, orgDict, receiveAmountList);
}
startDate = startDate.AddMonths(Cycle);
endDate = startDate.AddMonths(Cycle);
}
UpdateSaleOrderReceiveAmount(newCtx, tableName);
UpdateSaleOrderReceiveAmount(ctx, tableName);
tempTableService.DropTempTable(tableName);
}