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

14
Config/ContextConfig.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GZ_LTHPilot_ORDER.Config
{
internal class ContextConfig
{
public static string DefaultUserName = "ERP6";
public static int DefaultUserId = 131409;
}
}

View File

@ -332,6 +332,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Config\ContextConfig.cs" />
<Compile Include="Models\K3Request\ReportDataParam.cs" />
<Compile Include="Models\K3Result\KingdeeResult.cs" />
<Compile Include="Models\K3Result\ListResult.cs" />
@ -377,6 +378,7 @@
<Compile Include="SQL\SqlManage.cs" />
<Compile Include="SUB_PPBOM\AuditPOM.cs" />
<Compile Include="T_IV_SALESIC\UnAuditS_Order.cs" />
<Compile Include="Utils\ContextUtil.cs" />
<Compile Include="Utils\LogUtil.cs" />
<Compile Include="WebApiService\SaleOrderApiService.cs" />
<Compile Include="XMYSLRB\AfterSave.cs" />
@ -442,6 +444,7 @@
</Target>
<Import Project="packages\SkiaSharp.NativeAssets.Win32.2.88.8\build\net462\SkiaSharp.NativeAssets.Win32.targets" Condition="Exists('packages\SkiaSharp.NativeAssets.Win32.2.88.8\build\net462\SkiaSharp.NativeAssets.Win32.targets')" />
<PropertyGroup>
<PostBuildEvent>copy $(TargetPath) "D:\kingdee\K3Cloud\WebSite\Bin\$(TargetFileName)"</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>

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

38
Utils/ContextUtil.cs Normal file
View File

@ -0,0 +1,38 @@
using GZ_LTHPilot_ORDER.Config;
using Kingdee.BOS;
using Kingdee.BOS.ServiceHelper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GZ_LTHPilot_ORDER.Utils
{
public class ContextUtil
{
Context ctx { get; set; }
public ContextUtil(Context ctx)
{
this.ctx = ctx;
}
public Context GetDefaultContext()
{
var userName = ContextConfig.DefaultUserName;
var userId = ContextConfig.DefaultUserId;
return GetNewContext(userId, userName);
}
public Context GetNewContext(long userId, string userName)
{
Context newCtx = DataCenterService.GetDataCenterContextByID(ctx.DBId);
newCtx.UserId = userId;
newCtx.UserName = userName;
newCtx.ServiceType = WebType.WebSite;
newCtx.CurrentOrganizationInfo.ID = 1;
return newCtx;
}
}
}