From f506ae008db19791fd211c4c7ca8041a2bf00874 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期三, 28 一月 2026 11:44:39 +0800
Subject: [PATCH] 库存暂存增加,单据修改代码优化,erpjob开启

---
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs      |    1 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs |   12 ++++--
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs                    |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs      |    4 +-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs        |   35 ++++++++++++++++-
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs          |    2 
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/QuartzJobMildd.cs        |   20 ++++++++--
 项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs                |    2 
 8 files changed, 61 insertions(+), 17 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
index d678648..7dcdc17 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs"
@@ -440,13 +440,24 @@
                     //}
                 }
                 _mesReturnRecord.UpdateData(returnRecords);
+                //閲嶆柊鍥炶皟瀹屾垚鐨勫崟鎹紝鏇存柊搴撳瓨鐘舵��
+                foreach (var returnRecord in returnRecords)
+                {
+                    if (returnRecord.ReturnStatus == 1)
+                    {
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == returnRecord.OrderNo && returnRecord.RequestData.Contains(it.Barcode)).ExecuteCommand();
+                    }
+                }
 
                 var inboundOrderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrderDetail>()
-                                        .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus==(int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
+                                        .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus == (int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
                                         .ToList();
 
                 var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == (int)StockStatusEmun.鍏ュ簱瀹屾垚)
-                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo).Any())
+                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo && s.Status == StockStatusEmun.鍏ュ簱纭.ObjToInt()).Any())
                                             .ToList();
 
                 var stockIds = stocks.Select(s => s.Id).ToList();
@@ -467,6 +478,13 @@
                                     inbound => inbound.Barcode,
                                     stockdetail => stockdetail.Barcode,
                                     (inbound, stockdetail) => inbound.Id)
+                                .ToList();
+
+                var inbounddetailBarcode = inboundOrderDetail
+                                .Join(allDetailsData,
+                                    inbound => inbound.Barcode,
+                                    stockdetail => stockdetail.Barcode,
+                                    (inbound, stockdetail) => stockdetail.Barcode)
                                 .ToList();
 
                 var detail = allDetailsData.Where(x => matchedData.Contains(x.Barcode)).ToList();
@@ -512,6 +530,11 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                     }
                     else
                     {
@@ -535,7 +558,7 @@
                         details = FeedbackInboundDetailsModelDto(detail)
                     };
 
-                    if (feedmodel.details.Count<=0)
+                    if (feedmodel.details.Count <= 0)
                     {
                         if (returnRecords.Count() == returnRecords.Count(x => x.ReturnStatus == 1))
                         {
@@ -558,6 +581,11 @@
                     {
                         _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                         .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
+
+                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
+                        {
+                            Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()
+                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                     }
                     else
                     {
@@ -575,6 +603,7 @@
             }
         }
 
+
         public List<AllocateDtoDetail> GetAllocateDtoDetails(List<Dt_StockInfoDetail> stockInfoDetails)
         {
             var groupedData = stockInfoDetails.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
index eea7122..f051ef8 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
@@ -113,10 +113,6 @@
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
                 }
-                if (outboundOrder.OrderStatus != (int)OutOrderStatusEnum.鏈紑濮�)
-                {
-                    return WebResponseContent.Instance.Error($"璇ヨ鍗曠姸鎬佷笉鍏佽淇敼");
-                }
                 List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
                 List<Dt_OutboundOrderDetail> updateoutboundOrderDetails = new List<Dt_OutboundOrderDetail>();
                 List<int> detailIds = new List<int>();
@@ -161,6 +157,10 @@
                     }
                     else
                     {
+                        if(item.OrderQuantity > outboundOrderDetail.LockQuantity + outboundOrderDetail.MoveQty)
+                        {
+                            return WebResponseContent.Instance.Error($"淇敼鐨勮鍙穥item.lineNo}鏁伴噺瓒呰繃浜嗘櫤浠撳嚭搴撻攣瀹氭暟閲忓姞涓婃尓鏂欐暟閲忥紝涓嶅厑璁镐慨鏀�");
+                        }
                         outboundOrderDetail.lineNo = item.lineNo;
                         outboundOrderDetail.MaterielCode = item.MaterielCode;
                         outboundOrderDetail.SupplyCode = item.SupplyCode;
@@ -205,6 +205,10 @@
                 _outboundOrderDetailRepository.UpdateData(updateoutboundOrderDetails);
                 _outboundOrderDetailRepository.AddData(outboundOrderDetails);
 
+                if(outboundOrder.Details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty))
+                {
+                    outboundOrder.OrderStatus = (int)OutOrderStatusEnum.鍑哄簱瀹屾垚;
+                }
                 BaseDal.UpdateData(outboundOrder);
                 _unitOfWorkManage.CommitTran();
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
index 67e71f3..d47f8f6 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs"
@@ -2031,7 +2031,7 @@
                 if (stock.Details.Count <= 0)
                 {
                     stock.PalletType = (int)PalletTypeEnum.Empty;
-                    stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+                    stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
                     stock.LocationCode = "";
                 }
                 else if (stock.Details.Count > 0)
@@ -2045,7 +2045,7 @@
                     {
                         return content.Error($"鎵樼洏{palletCode}搴撳瓨鏈嫞閫夊畬涓嶅厑璁稿洖搴�");
                     }
-                    stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+                    stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
                     stock.LocationCode = "";
                 }
 
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index e656b72..f0b6ddf 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -303,7 +303,7 @@
             stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
             stockInfo.Details.ForEach(x =>
             {
-                x.Status = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+                x.Status = StockStatusEmun.鍏ュ簱纭.ObjToInt();
             });
             _stockService.StockInfoService.Repository.UpdateData(stockInfo);
             _stockService.StockInfoDetailService.Repository.UpdateData(stockInfo.Details);
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs"
index 1fa8fd0..e6aabe0 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/ErpJob.cs"
@@ -2,7 +2,7 @@
 using SqlSugar;
 using WIDESEA_DTO.Basic;
 
-namespace WIDESEA_WMSServer.Jobs
+namespace WIDESEA_WMSServer
 {
     [DisallowConcurrentExecution]
     public class ErpJob : IJob
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs"
index 240cea6..ceaea30 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/InventoryLockJob.cs"
@@ -4,7 +4,6 @@
 using WIDESEA_Common.StockEnum;
 using WIDESEA_Model.Models;
 using WIDESEA_Model.Models.Basic;
-using WIDESEA_WMSServer.Jobs;
 
 namespace WIDESEA_WMSServer
 {
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/QuartzJobMildd.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/QuartzJobMildd.cs"
index d923919..debec3a 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/QuartzJobMildd.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Jobs/QuartzJobMildd.cs"
@@ -47,14 +47,26 @@
                          JobGroup = "WIDESEA_WMSServer",
                          Name = "InventoryLockJob",
                          TriggerType = 0
+                    },new TasksQz()
+                    {
+                         Id = 3,
+                         AssemblyName = "WIDESEA_WMSServer",
+                         ClassName = "ErpJob",
+                         CreateTime = DateTime.Now,
+                         IntervalSecond = 50000,
+                         IsDeleted = false,
+                         IsStart = false,
+                         JobGroup = "WIDESEA_WMSServer",
+                         Name = "ErpJob",
+                         TriggerType = 0
                     },
 
                 };
 
-                if(App.HostEnvironment.IsDevelopment())
-                {
-                    return;
-                }
+                //if(App.HostEnvironment.IsDevelopment())
+                //{
+                //    return;
+                //}
                 foreach (var item in allQzServices)
                 {
                     var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
index d9dfa17..02c9b08 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs"
@@ -30,7 +30,6 @@
 using WIDESEA_DTO.Quartz;
 using WIDESEA_WMSServer;
 using WIDESEA_WMSServer.Filter;
-using WIDESEA_WMSServer.Jobs;
 using WIDESEAWCS_Core.LogHelper;
 
 var builder = WebApplication.CreateBuilder(args);
@@ -189,6 +188,7 @@
 builder.Services.AddSingleton<IJobFactory, JobFactory>();
 builder.Services.AddTransient<AgvTaskJob>();//Job使用瞬时依赖注入
 builder.Services.AddTransient<InventoryLockJob>();//Job使用瞬时依赖注入
+builder.Services.AddTransient<ErpJob>();//Job使用瞬时依赖注入
 builder.Services.AddSingleton<ISchedulerCenter, SchedulerCenterServer>();
 
 builder.Services.AddQuartz(q =>

--
Gitblit v1.9.3