From d01658c63cd541fe4ea5cec5c4bd7f23b9408cdb Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 18 十月 2025 15:04:56 +0800
Subject: [PATCH] 前端,pda,后端接口更改,新增,优化
---
WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs | 123 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 117 insertions(+), 6 deletions(-)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
index a39efd8..b103c2a 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
@@ -10,6 +10,7 @@
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.ERP;
using WIDESEA_DTO.Stock;
using WIDESEA_IBasicRepository;
using WIDESEA_IBasicService;
@@ -23,8 +24,11 @@
namespace WIDESEA_OutboundService
{
+
+
public partial class OutboundOrderDetailService : ServiceBase<Dt_OutboundOrderDetail, IOutboundOrderDetailRepository>, IOutboundOrderDetailService
{
+
public WebResponseContent LockOutboundStock(int orderDetailId)
{
Dt_OutboundOrderDetail outboundOrderDetail = BaseDal.QueryFirst(x => x.Id == orderDetailId);
@@ -137,7 +141,7 @@
decimal needQuantity = originalNeedQuantity;
- List<Dt_StockInfo> outStocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCode(stockSelectViews.Select(x => x.BatchNo).ToList());
+ List<Dt_StockInfo> outStocks = _stockService.StockInfoService.Repository.GetStockInfosByPalletCode(stockSelectViews.Select(x => x.PalletCode).ToList());
//List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrder.MaterialCode, "", outboundOrder.WarehouseId);
if (!outStocks.Any())
@@ -165,7 +169,7 @@
if (outboundOrderDetail.OrderQuantity > outboundOrderDetail.LockQuantity)
{
List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(outboundOrderDetail.MaterielCode);
- stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.BatchNo).Contains(x.BatchNo)).ToList();
+ stockInfos = stockInfos.Where(x => !stockSelectViews.Select(v => v.PalletCode).Contains(x.PalletCode)).ToList();
List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, outboundOrderDetail.MaterielCode, needQuantity, out decimal residueQuantity);
outboundOrderDetail.LockQuantity += needQuantity - residueQuantity;
outStocks.AddRange(autoAssignStocks);
@@ -273,6 +277,14 @@
List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList();
if (addOutStockLockInfos != null && addOutStockLockInfos.Any())
{
+ if (tasks != null)
+ {
+ addOutStockLockInfos.ForEach(x =>
+ {
+ x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum;
+ });
+ }
+
_outStockLockInfoService.Repository.AddData(addOutStockLockInfos);
}
List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList();
@@ -310,8 +322,16 @@
}
Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
- List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo }).ToList();
- Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseCode == outboundOrder.OutWareHouse);
+ List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo , x.LocationName}).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo,LocationName = x.Key.LocationName}).ToList();
+ List<Dt_Warehouse> warehouse = new List<Dt_Warehouse>();
+ if (outboundOrder.OutWareHouse == "SC01_BC")
+ {
+ warehouse = _basicService.WarehouseService.Repository.QueryData(x => x.WarehouseDes == outboundOrder.OutWareHouse || x.WarehouseDes =="SC02_BC");
+ }
+ else
+ {
+ warehouse = _basicService.WarehouseService.Repository.QueryData(x => x.WarehouseDes == outboundOrder.OutWareHouse);
+ }
List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
foreach (var item in groupDetails)
@@ -320,7 +340,17 @@
decimal needQuantity = originalNeedQuantity;
- List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse.WarehouseId);
+ List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
+ ///鍑哄簱鎸囧畾搴撲綅鍑哄簱鍒ゆ柇
+ if (item.LocationName != null && item.LocationName != "")
+ {
+ stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse).Where(x=>x.LocationCode == item.LocationName).ToList();
+ }
+ else
+ {
+ stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse);
+ }
+
if (!stockInfos.Any())
{
throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
@@ -366,7 +396,6 @@
}
}
}
-
locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
}
@@ -440,5 +469,87 @@
}
return (true, "鎴愬姛");
}
+
+
+ public string ToCancelOutFeedbackERP = WIDESEA_Core.Helper.AppSettings.Configuration["CancelOutFeedbackERP"];
+ public WebResponseContent CancelOutFeedbackERP(int[] keys)
+ {
+ List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundRepository.OutboundOrderDetailRepository.QueryData(x => keys.Contains(x.Id));
+
+ if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
+ {
+ return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+ }
+ if (outboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus > OrderDetailStatusEnum.New.ObjToInt() && x.OrderDetailStatus != OrderDetailStatusEnum.AssignOverPartial.ObjToInt()) != null)
+ {
+ return WebResponseContent.Instance.Error("鎵�閫夊嚭搴撳崟鏄庣粏瀛樺湪鍑哄簱涓垨宸插畬鎴�");
+ }
+ Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails[0].OrderId);
+ if(outboundOrder == null)
+ {
+ return WebResponseContent.Instance.Error("鏈�氳繃璇ユ槑缁嗘壘鍒板嚭搴撳崟淇℃伅");
+ }
+ if (!outboundOrder.System.Equals("ERP"))
+ {
+ return WebResponseContent.Instance.Error("璇ュ嚭搴撳崟鎹潪ERP鎺ㄩ�侊紝鏃犳硶鍙栨秷");
+ }
+ string ids ="";
+ foreach (var item in outboundOrderDetails)
+ {
+ ids = item.LinId;
+ var postContent = new MultipartFormDataContent();
+ postContent.Headers.Add("ContentType", $"multipart/form-data");
+ postContent.Add(new StringContent(ids), "ids");
+ string result = string.Empty;
+ HttpClient client = null;
+ try
+ {
+ using (client = new HttpClient())
+ {
+ HttpResponseMessage response = client.PostAsync(ToCancelOutFeedbackERP, postContent)
+ .ConfigureAwait(false).GetAwaiter().GetResult();
+
+ // 纭繚鍝嶅簲鎴愬姛
+ response.EnsureSuccessStatusCode();
+ result = response.Content.ReadAsStringAsync()
+ .ConfigureAwait(false).GetAwaiter().GetResult();
+ }
+ _unitOfWorkManage.BeginTran();
+ _outboundRepository.OutboundOrderDetailRepository.DeleteAndMoveIntoHty(outboundOrderDetails, OperateType.浜哄伐鍙栨秷);
+
+ //妫�鏌ヨ涓昏鍗曟槸鍚﹁繕鏈夊墿浣欐槑缁�
+ int remainingDetailsCount = _outboundRepository.OutboundOrderDetailRepository
+ .Db.Queryable<Dt_OutboundOrderDetail>()
+ .Where(d => d.OrderId == outboundOrder.Id)
+ .Count();
+
+ // 濡傛灉娌℃湁鍓╀綑鏄庣粏锛屽啀鍒犻櫎涓昏鍗�
+ if (remainingDetailsCount == 0)
+ {
+ _outboundRepository.OutboundOrderRepository.DeleteAndMoveIntoHty(outboundOrder, OperateType.浜哄伐鍙栨秷);
+ }
+ _unitOfWorkManage.CommitTran();
+ // 鍋囪ERP杩斿洖鎴愬姛鏃惰繑鍥炴垚鍔熷搷搴�
+ return WebResponseContent.Instance.OK(result);
+
+ }
+ catch (HttpRequestException ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ // 澶勭悊HTTP璇锋眰鐩稿叧寮傚父
+ return WebResponseContent.Instance.Error($"HTTP璇锋眰閿欒: {ex.Message}");
+
+ }
+ catch (Exception ex)
+ {
+ _unitOfWorkManage.RollbackTran();
+ // 澶勭悊鍏朵粬寮傚父
+ return WebResponseContent.Instance.Error($"澶勭悊澶辫触: {ex.Message}");
+ }
+
+ }
+ return WebResponseContent.Instance.OK();
+ }
+
}
}
--
Gitblit v1.9.3