From 6c663b92b0078aa89657df22ec188dff65599f04 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 21 十月 2025 17:24:38 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs | 102 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 98 insertions(+), 4 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs"
index 4ad04b1..6080888 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/AspNetCoreSchedule.cs"
@@ -1,13 +1,21 @@
-锘縰sing Masuit.Tools;
+锘縰sing MailKit.Search;
+using Masuit.Tools;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
-using System.Net.Mail;
+using SixLabors.Fonts;
+using SqlSugar;
+using System;
using System.Net;
+using System.Net.Mail;
using System.Text;
using WIDESEA_Cache;
using WIDESEA_Core.Const;
using WIDESEA_DTO.WMS;
+using WIDESEA_IOrderRepository;
using WIDESEA_IServices;
+using WIDESEA_Model.Models.ERP;
+using WIDESEA_Model.Models.Order;
+using WIDESEA_OrderRepository;
using WIDESEAWCS_BasicInfoRepository;
namespace WIDESEA_StorageTaskServices
@@ -21,10 +29,11 @@
private readonly IDt_StationManagerRepository _stationManagerRepository;
private readonly ISys_ConfigService _configService;
private readonly ILocationInfoRepository _locationRepository;
+ private readonly IDt_InboundOrderRepository _inboundOrderRepository;
private Timer _timer;
- public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IStockInfoRepository stockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService)
+ public MyBackgroundService(ILogger<MyBackgroundService> logger, ILocationInfoRepository locationRepository, IStockInfoRepository stockInfoRepository, IDt_AreaInfoRepository areaInfoRepository, IDt_TaskRepository taskRepository, IDt_StationManagerRepository stationManagerRepository, ISys_ConfigService configService,IDt_InboundOrderRepository inboundOrderRepository)
{
_logger = logger;
_locationRepository = locationRepository;
@@ -33,11 +42,12 @@
_taskRepository = taskRepository;
_stationManagerRepository = stationManagerRepository;
_configService = configService;
+ _inboundOrderRepository = inboundOrderRepository;
}
public Task StartAsync(CancellationToken cancellationToken)
{
- _timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(5));
+ _timer = new Timer(DoWork, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
return Task.CompletedTask;
}
@@ -45,13 +55,97 @@
{
try
{
+ List<WMS_閲囪喘鍏ユ垚鍝佸叆搴撹嚜鍔ㄦ墦鍗版竻鍗昣ST> ERPPrintChecklist =SqlSugarHelper.DBERP.Queryable<WMS_閲囪喘鍏ユ垚鍝佸叆搴撹嚜鍔ㄦ墦鍗版竻鍗昣ST>().Where(x => true).ToList();
+
+ var printCheckList = _inboundOrderRepository.QueryData(x => true);
+ List<Dt_InboundOrder> inboundOrderAdd = new List<Dt_InboundOrder>();
+ List<Dt_InboundOrder> inboundOrderUpdate = new List<Dt_InboundOrder>();
+ foreach (var item in ERPPrintChecklist)
+ {
+ var x = printCheckList.Where(x => x.MaterialNo == item.鏂欏彿 && x.OrderNo == item.鍗曞彿 && x.WarehouseName == item.鍏ュ簱浠撳簱鍚嶇О).FirstOrDefault();
+ if (x == null)
+ {
+ Dt_InboundOrder Print = new Dt_InboundOrder()
+ {
+ PrintCode = GetOrderPintCode(),
+ OrderNo = item.鍗曞彿,
+ DemandClassification = item.闇�姹傚垎绫�,
+ OrderType = item.鍗曟嵁绫诲瀷,
+ WarehouseName = item.鍏ュ簱浠撳簱鍚嶇О,
+ Datetime = item.鏃ユ湡.ToString(),
+ LineNumber = item.琛屽彿,
+ ProductDrawingNumber = item.浜у搧鍥惧彿,
+ MaterialNo = item.鏂欏彿,
+ MaterialName = item.鍝佸悕,
+ Weight = item.鍗曢噸,
+ Specs = item.瑙勬牸,
+ Unit = item.鍗曚綅,
+ Texture = item.鐢ㄥ弸鏉愯川,
+ Quantity = item.鍏ュ簱鏁伴噺,
+ OrderStatus = item.鍗曟嵁鐘舵��
+
+ };
+ inboundOrderAdd.Add(Print);
+ }
+ else
+ {
+ if (x.PrintCode == null || x.PrintCode == "")
+ {
+ x.PrintCode = GetOrderPintCode();
+ x.OrderNo = item.鍗曞彿;
+ x.DemandClassification = item.闇�姹傚垎绫�;
+ x.OrderType = item.鍗曟嵁绫诲瀷;
+ x.WarehouseName = item.鍏ュ簱浠撳簱鍚嶇О;
+ x.Datetime = item.鏃ユ湡.ToString();
+ x.LineNumber = item.琛屽彿;
+ x.ProductDrawingNumber = item.浜у搧鍥惧彿;
+ x.MaterialNo = item.鏂欏彿;
+ x.MaterialName = item.鍝佸悕;
+ x.Weight = item.鍗曢噸;
+ x.Specs = item.瑙勬牸;
+ x.Unit = item.鍗曚綅;
+ x.Texture = item.鐢ㄥ弸鏉愯川;
+ x.Quantity = item.鍏ュ簱鏁伴噺;
+ x.OrderStatus = item.鍗曟嵁鐘舵��;
+ inboundOrderUpdate.Add(x);
+ }
+ }
+ }
+ if (inboundOrderAdd.Count > 0)
+ {
+ _inboundOrderRepository.AddData(inboundOrderAdd);
+ }
+ if (inboundOrderUpdate.Count > 0)
+ {
+ _inboundOrderRepository.UpdateData(inboundOrderUpdate);
+ }
}
catch (Exception ex)
{
ConsoleHelper.WriteErrorLine($"閿欒淇℃伅锛�" + ex.Message);
}
}
+
+ public string GetOrderPintCode()
+ {
+ string PrintCode = "";
+ var PrintSetting = SqlSugarHelper.DbWMS.Queryable<Dt_PrintSetting>().Where(x => x.PrintCode == "OrderNo").ToList().FirstOrDefault();
+
+ if (PrintSetting.Spare1 == DateTime.Now.ToString("yyyyMMdd"))
+ {
+ PrintCode = PrintSetting.Spare1 + PrintSetting.PrintNo.ToString().PadLeft(PrintSetting.Spare2, '0');
+ PrintSetting.PrintNo = PrintSetting.PrintNo + 1;
+ }
+ else
+ {
+ PrintSetting.Spare1 = DateTime.Now.ToString("yyyyMMdd");
+ PrintSetting.PrintNo = 2;
+ PrintCode = PrintSetting.Spare1 + 1.ToString().PadLeft(PrintSetting.Spare2, '0');
+ }
+ SqlSugarHelper.DbWMS.Updateable(PrintSetting).ExecuteCommand();
+ return PrintCode;
+ }
public Task StopAsync(CancellationToken cancellationToken)
{
--
Gitblit v1.9.3