pan
2025-11-20 8a718d4a371257af9afa5816989791865f21f696
提交
已添加1个文件
已修改5个文件
96 ■■■■ 文件已修改
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_DTO/Stock/StockSelectViewDTO.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_BasicService/ErpApiService.cs
@@ -226,10 +226,10 @@
                }
                else
                {
                    materialRequest.modifyDateStart = DateTime.Now.AddDays(-1).Date.ToString("yyyy-MM-dd") + " 00:00:01";
                    materialRequest.modifyDateEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm") + ":01";
                    materialRequest.pageNum = 1;
                    materialRequest.pageSize = 5000;
                    //materialRequest.modifyDateStart = DateTime.Now.AddDays(-1).Date.ToString("yyyy-MM-dd") + " 00:00:01";
                    //materialRequest.modifyDateEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm") + ":01";
                    //materialRequest.pageNum = 1;
                    //materialRequest.pageSize = 5000;
                    var result = await PostAsync<MaterialRequest, MaterialResponse>("erp/getMaterialInfo", materialRequest, true, true);
                    if (result != null && result.data != null && result.data.Any())
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_DTO/Stock/StockSelectViewDTO.cs
@@ -18,5 +18,7 @@
        public string PalletCode { get; set; }
        public string LocationCode { get; set; }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs
@@ -148,8 +148,7 @@
            List<Dt_OutboundOrderDetail>? orderDetails = null;
            List<Dt_OutStockLockInfo>? outStockLockInfos = null;
            List<Dt_LocationInfo>? locationInfos = null;
            //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
            {
                (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
                if (result.Item1 != null && result.Item1.Count > 0)
                {
@@ -184,17 +183,6 @@
                {
                    throw new Exception("无库存");
                }
            }
            //else
            //{
            //    List<Dt_OutStockLockInfo> stockLockInfos = _outboundService.OutboundStockLockInfoService.GetByOrderDetailId(outboundOrderDetail.OrderId, OutLockStockStatusEnum.已分配);
            //    if (stockLockInfos != null && stockLockInfos.Count > 0)
            //    {
            //        List<Dt_StockInfo> stocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCodes(stockLockInfos.Select(x => x.PalletCode).Distinct().ToList());
            //        tasks = GetTasks(stocks);
            //    }
            //}
            return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
        }
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,50 @@
using Quartz;
using SqlSugar;
using WIDESEA_DTO.Basic;
namespace WIDESEA_WMSServer.Jobs
{
    [DisallowConcurrentExecution]
    public class ErpJob : IJob
    {
        private readonly ILogger<ErpJob> _logger;
        private readonly ISqlSugarClient _db;
        private readonly WIDESEA_IBasicService.IErpApiService _erpApiService;
        // é€šè¿‡æž„造函数直接注入依赖
        public ErpJob(ILogger<ErpJob> logger, ISqlSugarClient db, WIDESEA_IBasicService.IErpApiService erpApiService)
        {
            _logger = logger;
            _db = db;
            _erpApiService = erpApiService;
        }
        public async Task Execute(IJobExecutionContext context)
        {
            _logger.LogInformation($"定时任务开始执行,时间:{DateTime.Now:yyyy-MM-dd HH:mm:ss}");
            try
            {
                 await _erpApiService.GetSuppliersAsync();
                await _erpApiService.GetMaterialUnitAsync();
                var materialRequest = new MaterialRequest
                {
                    modifyDateStart = DateTime.Now.AddDays(-10).Date.ToString("yyyy-MM-dd") + " 00:00:01",
                    modifyDateEnd = DateTime.Now.ToString("yyyy-MM-dd HH:mm") + ":01",
                    pageNum = 1,
                    pageSize = 5000
                };
                await _erpApiService.GetMaterialInfoAsync(materialRequest);
                _logger.LogInformation($"定时任务执行成功");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "定时任务执行失败");
            }
        }
    }
}
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
@@ -22,6 +22,8 @@
//using WIDESEA_Core.HostedService;
using WIDESEA_Core.Middlewares;
using WIDESEA_WMSServer.Filter;
using Quartz;
using WIDESEA_WMSServer.Jobs;
var builder = WebApplication.CreateBuilder(args);
@@ -147,9 +149,25 @@
});
builder.Services.AddQuartz(q =>
{
    var jobKey = new JobKey("ErpJob");
    q.AddJob<ErpJob>(opts => opts.WithIdentity(jobKey));
    // æ·»åŠ è§¦å‘å™¨ - æ¯å¤©10:00, 14:00, 20:00执行
    q.AddTrigger(opts => opts
        .ForJob(jobKey)
        .WithIdentity("ErpJob-trigger")
        .WithCronSchedule("0 0 10,14,20 * * ?"));
});
builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
var app = builder.Build();
// 3、配置中间件
app.UseMiniProfiler();//性能分析器
app.ConfigureApplication();//配置文件
app.UseApplicationSetup();//启动配置
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj
@@ -47,6 +47,8 @@
    </ItemGroup>
    
    <ItemGroup>
      <PackageReference Include="Quartz" Version="3.13.1" />
      <PackageReference Include="Quartz.Extensions.Hosting" Version="3.13.1" />
      <PackageReference Include="Serilog" Version="4.3.0" />
      <PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
      <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.7.3" />