| | |
| | | } |
| | | 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()) |
| | |
| | | public string PalletCode { get; set; } |
| | | |
| | | public string LocationCode { get; set; } |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | 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) |
| | | { |
| | |
| | | { |
| | | 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); |
| | | } |
| | | |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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, "宿¶ä»»å¡æ§è¡å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | //using WIDESEA_Core.HostedService; |
| | | using WIDESEA_Core.Middlewares; |
| | | using WIDESEA_WMSServer.Filter; |
| | | using Quartz; |
| | | using WIDESEA_WMSServer.Jobs; |
| | | |
| | | var builder = WebApplication.CreateBuilder(args); |
| | | |
| | |
| | | |
| | | }); |
| | | |
| | | 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();//å¯å¨é
ç½® |
| | |
| | | </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" /> |