From 1866b69e8f67e382a0a75268d63e6418c8ae02e7 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期二, 13 一月 2026 09:55:01 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 365 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 291 insertions(+), 74 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_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 ecc4177..6adef6d 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"
@@ -1,13 +1,14 @@
-锘縰sing AutoMapper;
+锘縰sing System.Reflection.Emit;
+using AutoMapper;
using Dm.filter;
using MailKit.Search;
using Mapster;
+using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Crypto;
using SqlSugar;
-using System.Reflection.Emit;
using WIDESEA_BasicService;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
@@ -18,6 +19,7 @@
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Base;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.CalcOut;
using WIDESEA_DTO.ReturnMES;
@@ -26,6 +28,7 @@
using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
+using static HslCommunication.Profinet.Knx.KnxCode;
namespace WIDESEA_OutboundService
{
@@ -56,6 +59,8 @@
private readonly IRepository<Dt_Task> _taskRepository;
private readonly ILocationInfoService _locationInfoService;
private readonly IESSApiService _eSSApiService;
+ private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
+ private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository;
private Dictionary<string, string> stations = new Dictionary<string, string>
{
@@ -69,7 +74,7 @@
{"3-1","3-5" },
};
- public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService)
+ public OutboundService(IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IRepository<Dt_OutboundOrderDetail> detailRepository, IRepository<Dt_OutboundOrder> outboundRepository, IRepository<Dt_OutStockLockInfo> outboundLockInfoRepository, IRepository<Dt_StockInfo> stockInfoRepository, IRepository<Dt_StockInfoDetail> stockDetailRepository, IRepository<Dt_StockQuantityChangeRecord> stockChangeRepository, IRepository<Dt_StockInfoDetail_Hty> stockDetailHistoryRepository, IBasicService basicService, IOutboundOrderDetailService outboundOrderDetailService, IOutboundOrderService outboundOrderService, IOutStockLockInfoService outboundStockLockInfoService, IFeedbackMesService feedbackMesService, IRepository<Dt_Task> taskRepository, ILocationInfoService locationInfoService, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -90,6 +95,8 @@
_taskRepository = taskRepository;
_locationInfoService = locationInfoService;
_eSSApiService = eSSApiService;
+ _allocateOrderRepository = allocateOrderRepository;
+ _allocateMaterialInfoRepository = allocateMaterialInfoRepository;
}
#region 鍑哄簱鍒嗛厤
@@ -105,6 +112,7 @@
PickingOutboundResponseDTO response = new PickingOutboundResponseDTO();
try
{
+ _unitOfWorkManage.BeginTran();
// 1. 璁$畻鍑哄簱鏁伴噺閫昏緫
OutboundCalculationDTO calculationResult = CalcOutboundQuantity(request);
@@ -165,7 +173,8 @@
pickedDetails.AddRange(materielPickedDetails.PickedDetails);
- decimal allallocatedQuantity = materielCalc.UnallocatedQuantity;
+ decimal allallocatedQuantity = Math.Min(materielCalc.UnallocatedQuantity, materielPickedDetails.PickedDetails.Sum(x => x.OutboundQuantity));
+ materielCalc.UnallocatedQuantity = allallocatedQuantity;
// 鏇存柊鍑哄簱鍗曟槑缁嗭紙澧炲姞閿佸畾鏁伴噺锛屼笉澧炲姞宸插嚭鏁伴噺锛�
foreach (var detail in materielCalc.Details)
{
@@ -243,14 +252,23 @@
}
result.FactoryArea = outboundOrder.FactoryArea;
+ List<Dt_OutboundOrderDetail> selectedDetails = new List<Dt_OutboundOrderDetail>();
- // 鑾峰彇閫夋嫨鐨勫嚭搴撴槑缁�
- List<Dt_OutboundOrderDetail> selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && request.DetailIds.Contains(x.Id));
-
- if (outboundOrder.IsBatch == 1)
+ if (request.DetailIds == null || !request.DetailIds.Any())
{
- selectedDetails = _detailRepository.QueryData(x => x.OrderId == selectedDetails.First().OrderId && x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode);
+ selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id);
}
+ else
+ {
+ // 鑾峰彇閫夋嫨鐨勫嚭搴撴槑缁�
+ selectedDetails = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && request.DetailIds.Contains(x.Id));
+ }
+
+
+ //if (outboundOrder.IsBatch == 1 && request.DetailIds.Count == 1)
+ //{
+ // selectedDetails = _detailRepository.QueryData(x => x.OrderId == selectedDetails.First().OrderId && x.WarehouseCode == selectedDetails.First().WarehouseCode && x.MaterielCode == selectedDetails.First().MaterielCode && x.BatchNo == selectedDetails.First().BatchNo && x.SupplyCode == selectedDetails.First().SupplyCode);
+ //}
if (!selectedDetails.Any())
@@ -271,7 +289,7 @@
result.OutboundOrder = outboundOrder;
result.SelectedDetails = selectedDetails;
- if (outboundOrder.IsBatch == 0)
+ if (outboundOrder.IsBatch == 0 || request.DetailIds.Count != 1)
{
// 澶氭槑缁嗗嚭搴擄細鎸夌墿鏂欏垎缁勫鐞�
result.MaterielCalculations = CalcMaterielOutboundQuantities(outboundOrder, selectedDetails.ToList());
@@ -358,7 +376,6 @@
.GroupBy(x => new
{
x.MaterielCode,
- x.MaterielName,
x.BatchNo,
x.SupplyCode,
x.WarehouseCode
@@ -366,7 +383,6 @@
.Select(g => new MaterielOutboundCalculationDTO
{
MaterielCode = g.Key.MaterielCode,
- MaterielName = g.Key.MaterielName,
BatchNo = g.Key.BatchNo,
SupplyCode = g.Key.SupplyCode,
WarehouseCode = g.Key.WarehouseCode,
@@ -418,13 +434,15 @@
Dictionary<int, List<Dt_OutStockLockInfo>> lockStockMap = data.LockStockMap;
// 楠岃瘉鎬诲彲鐢ㄥ簱瀛樻槸鍚︽弧瓒冲嚭搴撻渶姹�
- if (totalAvailableStock < materielCalc.UnallocatedQuantity)
- {
- throw new Exception($"鐗╂枡 {materielCalc.MaterielCode} 鍙敤搴撳瓨 {totalAvailableStock} 涓嶈冻鍑哄簱鏁伴噺 {materielCalc.UnallocatedQuantity}");
- }
+ //if (totalAvailableStock < materielCalc.UnallocatedQuantity)
+ //{
+ // throw new Exception($"鐗╂枡 {materielCalc.MaterielCode} 鍙敤搴撳瓨 {totalAvailableStock} 涓嶈冻鍑哄簱鏁伴噺 {materielCalc.UnallocatedQuantity}");
+ //}
+ // 闇�鍒嗛厤鏁伴噺
+ decimal remainingQuantity = Math.Min(totalAvailableStock, materielCalc.UnallocatedQuantity);
// 闇�鍒嗛厤鏁伴噺
- decimal remainingQuantity = materielCalc.UnallocatedQuantity;
+ //decimal remainingQuantity = materielCalc.UnallocatedQuantity;
// 宸插垎閰嶇殑鎵樼洏鍒楄〃
List<string> allocatedPallets = new List<string>();
@@ -533,7 +551,7 @@
private List<Dt_StockInfo> BuildStockQueryWithInfo(MaterielOutboundCalculationDTO materielCalc, string factoryArea)
{
// 鍩虹鏌ヨ鏉′欢锛氱墿鏂欑紪鍙枫�佹壒娆″彿锛堝鏋滄彁渚涳級銆佸簱瀛樻暟閲�>0
- ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0);
+ ISugarQueryable<Dt_StockInfoDetail> stockDetails = _stockDetailRepository.Db.Queryable<Dt_StockInfoDetail>().Where(x => x.MaterielCode == materielCalc.MaterielCode && x.StockQuantity > 0 && (x.Status == (int)StockStatusEmun.鍏ュ簱瀹屾垚 || x.Status == (int)StockStatusEmun.鎵嬪姩瑙i攣));
// 鏍规嵁鏉′欢娣诲姞渚涘簲鍟嗙紪鍙峰尮閰嶏紙涓嶄负绌烘椂鎵嶉渶瑕佸尮閰嶏級
if (!string.IsNullOrEmpty(materielCalc.SupplyCode))
@@ -838,8 +856,7 @@
}
#endregion
-
-
+ #region 鏁寸鍑哄簱
public WebResponseContent CompleteOutboundWithPallet(OutboundCompletePalletRequestDTO request)
{
WebResponseContent content = WebResponseContent.Instance;
@@ -860,22 +877,6 @@
{
response.Success = false;
response.Message = $"鎵樼洏 {request.PalletCode} 瀵瑰簲鐨勫簱瀛樻槑缁嗕笉瀛樺湪";
- return WebResponseContent.Instance.Error(response.Message);
- }
-
- bool isMatMixed = stockInfo.Details.GroupBy(x => new
- {
- x.MaterielCode,
- x.MaterielName,
- x.BatchNo,
- x.SupplyCode,
- x.WarehouseCode
- }).Count() > 1;
-
- if (isMatMixed)
- {
- response.Success = false;
- response.Message = $"娣锋枡鎵樼洏 {request.PalletCode} 涓嶈兘鏁寸鍑哄簱";
return WebResponseContent.Instance.Error(response.Message);
}
@@ -901,6 +902,67 @@
{
response.Success = false;
response.Message = $"璇ュ簱瀛樻病鏈夊垎閰嶅嚭搴撻噺锛屾墭鐩樺彿锛歿request.PalletCode}";
+ return WebResponseContent.Instance.Error(response.Message);
+ }
+
+ //bool isMatMixed = stockInfo.Details.GroupBy(x => new
+ //{
+ // x.MaterielCode,
+ // x.MaterielName,
+ // x.BatchNo,
+ // x.SupplyCode,
+ // x.WarehouseCode
+ //}).Count() > 1;
+ bool isMatMixed = false;
+
+ bool includeBatchNo = !string.IsNullOrEmpty(lockInfo.BatchNo);
+ bool includeSupplyCode = !string.IsNullOrEmpty(lockInfo.SupplyCode);
+
+ if (includeBatchNo && includeSupplyCode)
+ {
+ isMatMixed = stockInfo.Details.GroupBy(x => new
+ {
+ x.MaterielCode,
+ x.MaterielName,
+ x.BatchNo,
+ x.SupplyCode,
+ x.WarehouseCode
+ }).Count() > 1;
+ }
+ else if (includeBatchNo && !includeSupplyCode)
+ {
+ isMatMixed = stockInfo.Details.GroupBy(x => new
+ {
+ x.MaterielCode,
+ x.MaterielName,
+ x.BatchNo,
+ x.WarehouseCode
+ }).Count() > 1;
+ }
+ else if (!includeBatchNo && includeSupplyCode)
+ {
+ isMatMixed = stockInfo.Details.GroupBy(x => new
+ {
+ x.MaterielCode,
+ x.MaterielName,
+ x.SupplyCode,
+ x.WarehouseCode
+ }).Count() > 1;
+ }
+ else
+ {
+ isMatMixed = stockInfo.Details.GroupBy(x => new
+ {
+ x.MaterielCode,
+ x.MaterielName,
+ x.WarehouseCode
+ }).Count() > 1;
+ }
+
+ if (isMatMixed)
+ {
+ response.Success = false;
+ response.Message = $"娣锋枡鎵樼洏 {request.PalletCode} 涓嶈兘鏁寸鍑哄簱";
return WebResponseContent.Instance.Error(response.Message);
}
@@ -953,6 +1015,33 @@
// 鏁寸鍑哄簱鏃犻渶鎷嗗寘
PerformFullOutboundOperation(stockInfo, request, lockInfo.TaskNum.GetValueOrDefault());
+ if (outboundOrder.OrderType != 0)
+ {
+ Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo);
+ if (allocateOrder != null)
+ {
+ List<Dt_AllocateMaterialInfo> allocateMaterialInfos = new List<Dt_AllocateMaterialInfo>();
+ foreach (var item in stockInfo.Details)
+ {
+ Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo()
+ {
+ Barcode = item.Barcode,
+ BatchNo = item.BatchNo,
+ FactoryArea = item.FactoryArea,
+ MaterialCode = item.MaterielCode,
+ MaterialName = item.MaterielName,
+ OrderId = outboundOrder.Id,
+ OrderNo = outboundOrder.OrderNo,
+ Quantity = item.StockQuantity,
+ SupplyCode = item.SupplyCode,
+ Unit = item.Unit,
+ WarehouseCode = allocateOrder.ToWarehouse
+ };
+ allocateMaterialInfos.Add(allocateMaterialInfo);
+ }
+ _allocateMaterialInfoRepository.AddData(allocateMaterialInfos);
+ }
+ }
decimal allocatedQuantity = actualOutboundQuantity;
List<Dt_OutboundOrderDetail> updateDetails = new();
@@ -973,34 +1062,47 @@
//}
List<Barcodes> barcodesList = new List<Barcodes>();
List<Dt_StockInfoDetail> stockInfoDetails = stockInfo.Details.Where((x => x.StockQuantity > x.OutboundQuantity)).ToList();
+
+ decimal itemQuantity = item.LockQuantity - item.OverOutQuantity;
+ decimal unitbarcodeQuantity;
foreach (var stockDetail in stockInfoDetails)
{
- if (item.LockQuantity - item.OverOutQuantity >= stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity)
+
+
+ if (itemQuantity >= stockDetail.StockQuantity - stockDetail.OutboundQuantity)
{
+ unitbarcodeQuantity = stockDetail.StockQuantity - stockDetail.OutboundQuantity;
+ UnitConvertResultDTO currentResult = _basicService.UnitQuantityConvert(item.MaterielCode, item.Unit, item.BarcodeUnit, unitbarcodeQuantity);
+
Barcodes barcodes = new Barcodes
{
Barcode = stockDetail.Barcode,
- Qty = stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity,
+ Qty = currentResult.ToQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
- Unit = stockDetail?.Unit ?? ""
+ Unit = currentResult.ToUnit ?? ""
};
- stockDetail.StockQuantity = stockInfoDetail.OutboundQuantity;
+ itemQuantity -= (stockDetail.StockQuantity - stockDetail.OutboundQuantity);
+ stockDetail.OutboundQuantity = stockDetail.StockQuantity;
barcodesList.Add(barcodes);
+
+ if (itemQuantity <= 0) break;
}
else
{
+ UnitConvertResultDTO currentResult = _basicService.UnitQuantityConvert(item.MaterielCode, item.Unit, item.BarcodeUnit, itemQuantity);
Barcodes barcodes = new Barcodes
{
Barcode = stockDetail.Barcode,
- Qty = item.LockQuantity - item.OverOutQuantity,
+ Qty = currentResult.ToQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
- Unit = stockDetail?.Unit ?? ""
+ Unit = currentResult.ToUnit ?? ""
};
- stockInfoDetail.OutboundQuantity += item.LockQuantity - item.OverOutQuantity;
+ stockDetail.OutboundQuantity += itemQuantity;
barcodesList.Add(barcodes);
+ break;
}
}
@@ -1065,8 +1167,11 @@
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
+ if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+ {
+ _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+ }
- //todo: 鍥炰紶MES
}
}
catch (Exception ex)
@@ -1131,6 +1236,8 @@
FactoryArea = item.FactoryArea,
WarehouseCode = item.WarehouseCode,
Barcode = item.Barcode,
+ CreateDate = item.CreateDate,
+ Creater = item.Creater,
Remark = $"鏁寸鍑哄簱瀹屾垚鍒犻櫎锛屾潯鐮侊細{request.PalletCode}锛屽師鏁伴噺锛歿item.StockQuantity}锛屽嚭搴撴暟閲忥細{item.StockQuantity}锛屾搷浣滆�咃細{request.Operator}"
};
historyRecords.Add(historyRecord);
@@ -1163,6 +1270,7 @@
_stockDetailRepository.DeleteData(stockInfo.Details);
_stockChangeRepository.AddData(changeRecords);
}
+ #endregion
#region 鎷i��
/// <summary>
@@ -1269,21 +1377,76 @@
// 8. 鍒ゆ柇鏄惁闇�瑕佹媶鍖咃紙褰撳嚭搴撴暟閲忓皬浜庡簱瀛樻暟閲忔椂闇�瑕佹媶鍖咃級
bool isUnpacked = actualOutboundQuantity < stockDetail.StockQuantity;
List<MaterialCodeReturnDTO> returnDTOs = new List<MaterialCodeReturnDTO>();
-
+ string newBarcode = string.Empty;
// 9. 寮�鍚簨鍔�
_unitOfWorkManage.BeginTran();
try
{
decimal beforeQuantity = stockDetail.StockQuantity; // 鍘熷搴撳瓨閲�
+ Dt_AllocateMaterialInfo allocateMaterialInfo = new Dt_AllocateMaterialInfo();
+
// 鏍规嵁鏄惁鎷嗗寘鎵ц涓嶅悓鐨勬搷浣�
if (isUnpacked)
{
- returnDTOs = PerformUnpackOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault());
+ (string NewBarcode, List<MaterialCodeReturnDTO> MaterialCodeReturnDTOs) result = PerformUnpackOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault(), outboundOrder.Id, outboundOrder.OrderNo);
+
+ returnDTOs = result.MaterialCodeReturnDTOs;
+ newBarcode = result.NewBarcode;
+
+ MaterialCodeReturnDTO returnDTO = returnDTOs.First(x => x.Barcode == newBarcode);
+
+ if (outboundOrder.OrderType != 0)
+ {
+ allocateMaterialInfo = new Dt_AllocateMaterialInfo()
+ {
+ Barcode = returnDTO.Barcode,
+ BatchNo = returnDTO.BatchNo,
+ FactoryArea = returnDTO.FactoryArea,
+ MaterialCode = returnDTO.MaterialCode,
+ MaterialName = returnDTO.MaterialName,
+ OrderId = outboundOrder.Id,
+ OrderNo = outboundOrder.OrderNo,
+ Quantity = returnDTO.Quantity,
+ SupplyCode = returnDTO.SuplierCode,
+ Unit = stockDetail.Unit
+ };
+ }
+
}
else
{
PerformFullOutboundOperation(stockDetail, stockInfo, actualOutboundQuantity, request, beforeQuantity, lockInfo.TaskNum.GetValueOrDefault());
+
+ if (outboundOrder.OrderType != 0)
+ {
+ allocateMaterialInfo = new Dt_AllocateMaterialInfo()
+ {
+ Barcode = stockDetail.Barcode,
+ BatchNo = stockDetail.BatchNo,
+ FactoryArea = stockDetail.FactoryArea,
+ MaterialCode = stockDetail.MaterielCode,
+ MaterialName = stockDetail.MaterielName,
+ OrderId = outboundOrder.Id,
+ OrderNo = outboundOrder.OrderNo,
+ Quantity = stockDetail.StockQuantity,
+ SupplyCode = stockDetail.SupplyCode,
+ Unit = stockDetail.Unit
+ };
+ }
+
+ }
+
+ // 鍒ゆ柇鏄惁鏄皟鎷ㄥ崟
+ if (outboundOrder.OrderType != 0)
+ {
+ Dt_AllocateOrder allocateOrder = _allocateOrderRepository.QueryFirst(x => x.OrderNo == outboundOrder.OrderNo);
+ if (allocateOrder != null)
+ {
+ allocateMaterialInfo.WarehouseCode = allocateOrder.ToWarehouse;
+
+ _allocateMaterialInfoRepository.AddData(allocateMaterialInfo);
+ }
}
decimal allocatedQuantity = actualOutboundQuantity;
@@ -1291,7 +1454,6 @@
foreach (var item in outboundOrderDetails)
{
if (allocatedQuantity <= 0) break;
-
//if (item.OrderQuantity - item.MoveQty - item.OverOutQuantity >= allocatedQuantity)
//{
@@ -1323,13 +1485,15 @@
updateDetails.Add(item);
List<Barcodes> barcodesList = new List<Barcodes>();
+ UnitConvertResultDTO currentResult = _basicService.UnitQuantityConvert(item.MaterielCode, item.Unit, item.BarcodeUnit, barcodeQuantity);
+
Barcodes barcodes = new Barcodes
{
- Barcode = request.Barcode,
- Qty = barcodeQuantity,
+ Barcode = isUnpacked ? newBarcode : stockDetail?.Barcode,
+ Qty = currentResult.ToQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
- Unit = stockDetail?.Unit ?? ""
+ Unit = currentResult.ToUnit ?? ""
};
if (!string.IsNullOrEmpty(item.ReturnJsonData))
{
@@ -1345,7 +1509,7 @@
lockInfo.SortedQuantity = lockInfo.SortedQuantity + actualOutboundQuantity;
- if (lockInfo.SortedQuantity == lockInfo.AssignQuantity)
+ if (lockInfo.SortedQuantity >= lockInfo.AssignQuantity)
{
_outboundLockInfoRepository.DeleteAndMoveIntoHty(lockInfo, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
}
@@ -1385,14 +1549,39 @@
response.ScannedDetail = scannedDetail;
response.UpdatedDetails = updateDetails;
+ if (!string.IsNullOrEmpty(newBarcode))
+ {
+ // 鐗╂枡鏂版潯鐮佸洖浼�
+ _feedbackMesService.BarcodeFeedback(newBarcode);
+ }
+
+ // 鍒犻櫎閿佸畾璁板綍锛堝鏋滃嚭搴撴槑缁嗗叏閮ㄥ畬鎴愶級 涓嶤alculateActualOutboundQuantity鏂规硶閲岄潰娉ㄩ噴浠g爜2閫�1浣跨敤
+ if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails.First()))
+ {
+ Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode;
+
+ Func<Dt_OutStockLockInfo, bool> wareWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().WarehouseCode) ? true : x.WarehouseCode == outboundOrderDetails.First().WarehouseCode;
+
+ List<Dt_OutStockLockInfo> stockLockInfos = _outboundLockInfoRepository.QueryData(x =>
+ x.OrderNo == request.OrderNo &&
+ x.MaterielCode == stockDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+ if (stockLockInfos != null && stockLockInfos.Any())
+ {
+ _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
+ }
+ }
+
// 妫�鏌ュ嚭搴撳崟鏄惁瀹屾垚
if (CheckOutboundOrderCompleted(request.OrderNo))
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
-
- //todo: 鍥炰紶MES
+ if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+ {
+ _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+ }
}
+
}
catch (Exception ex)
{
@@ -1440,6 +1629,8 @@
/// </summary>
private decimal CalculateActualOutboundQuantity(Dt_StockInfoDetail stockDetail, List<Dt_OutboundOrderDetail> outboundDetails, Dt_OutStockLockInfo lockInfo)
{
+ // decimal availableOutboundQuantity = lockInfo.AssignQuantity - lockInfo.SortedQuantity;
+
decimal availableOutboundQuantity = lockInfo.AssignQuantity;
decimal detailRemainingQuantity = outboundDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity - x.MoveQty);//outboundDetail.OrderQuantity - outboundDetail.OverOutQuantity;
@@ -1458,14 +1649,14 @@
/// <param name="beforeQuantity"></param>
/// <param name="taskNum"></param>
/// <returns></returns>
- private List<MaterialCodeReturnDTO> PerformUnpackOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo,
- decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum)
+ public (string NewBarcode, List<MaterialCodeReturnDTO> MaterialCodeReturnDTOs) PerformUnpackOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo,
+ decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum, int orderId, string orderNo)
{
string newBarcode = GenerateNewBarcode();
string remark = $"鎷嗗寘璁板綍锛屽師鏉$爜锛歿request.Barcode}锛屽師鏁伴噺锛歿stockDetail.StockQuantity}锛屽嚭搴撴潯鐮侊細{newBarcode}锛� 鍑哄簱鏁伴噺锛歿actualOutboundQuantity}锛屽洖搴撴潯鐮侊細{request.Barcode}锛屽洖搴撴暟閲忥細{stockDetail.StockQuantity - actualOutboundQuantity},鎿嶄綔鑰咃細{request.Operator}";
- List<Dt_MaterialCodeInfo> materialCodeInfos = CreateMaterialCodeInfos(stockDetail, newBarcode, actualOutboundQuantity, remark);
+ List<Dt_MaterialCodeInfo> materialCodeInfos = CreateMaterialCodeInfos(stockDetail, newBarcode, actualOutboundQuantity, remark, taskNum, orderId, orderNo);
List<MaterialCodeReturnDTO> returnDTOs = _mapper.Map<List<MaterialCodeReturnDTO>>(materialCodeInfos);
@@ -1489,9 +1680,11 @@
Unit = stockDetail.Unit,
InboundOrderRowNo = stockDetail.InboundOrderRowNo,
SupplyCode = stockDetail.SupplyCode,
+ Creater = stockDetail.Creater,
+ CreateDate = stockDetail.CreateDate,
FactoryArea = stockDetail.FactoryArea,
WarehouseCode = stockDetail.WarehouseCode,
- Remark = $"鎷嗗寘鍓嶅師濮嬭褰曪紝鍘熸潯鐮侊細{request.Barcode}锛屽師鏁伴噺锛歿stockDetail.StockQuantity}锛屽嚭搴撴暟閲忥細{actualOutboundQuantity}锛屾搷浣滆�咃細{request.Operator}"
+ Remark = $"鎷嗗寘鍓嶅師濮嬭褰曪紝鍑哄簱鍗曞彿锛歿orderNo}锛屽嚭搴撳崟涓婚敭锛歿orderId}锛屽師鏉$爜锛歿request.Barcode}锛屽師鏁伴噺锛歿stockDetail.StockQuantity}锛屽嚭搴撴暟閲忥細{actualOutboundQuantity}锛屾搷浣滆�咃細{request.Operator}"
};
_stockDetailHistoryRepository.AddData(originalHistoryRecord);
@@ -1502,7 +1695,7 @@
// 鏇存柊鍘熷簱瀛樻槑缁�
stockDetail.StockQuantity = remainingQuantity;
//stockDetail.Barcode = newBarcode;
- stockDetail.Remark = $"鎷嗗寘鍚庢洿鏂帮紝鍘熸潯鐮侊細{request.Barcode}锛屾柊鏁伴噺锛歿remainingQuantity}锛屾搷浣滆�咃細{request.Operator}";
+ stockDetail.Remark = $"鎷嗗寘鍚庢洿鏂帮紝鍑哄簱鍗曞彿锛歿orderNo}锛屽嚭搴撳崟涓婚敭锛歿orderId}锛屽師鏉$爜锛歿request.Barcode}锛屾柊鏁伴噺锛歿remainingQuantity}锛屾搷浣滆�咃細{request.Operator}";
_stockDetailRepository.UpdateData(stockDetail);
}
@@ -1524,17 +1717,17 @@
AfterQuantity = beforeQuantity - actualOutboundQuantity,
SupplyCode = stockDetail.SupplyCode,
WarehouseCode = stockDetail.WarehouseCode,
- Remark = $"鎷嗗寘鍑哄簱锛屽師鏉$爜锛歿request.Barcode}锛屾柊鏉$爜锛歿newBarcode}锛屽嚭搴撴暟閲忥細{actualOutboundQuantity}锛屽墿浣欙細{remainingQuantity}锛屾搷浣滆�咃細{request.Operator}"
+ Remark = $"鎷嗗寘鍑哄簱锛屽嚭搴撳崟鍙凤細{orderNo}锛屽嚭搴撳崟涓婚敭锛歿orderId}锛屽師鏉$爜锛歿request.Barcode}锛屾柊鏉$爜锛歿newBarcode}锛屽嚭搴撴暟閲忥細{actualOutboundQuantity}锛屽墿浣欙細{remainingQuantity}锛屾搷浣滆�咃細{request.Operator}"
};
_stockChangeRepository.AddData(unpackChangeRecord);
- return returnDTOs;
+ return (newBarcode, returnDTOs);
}
/// <summary>
/// 鎵ц瀹屾暣鍑哄簱鎿嶄綔锛堜笉鎷嗗寘锛�
/// </summary>
- private void PerformFullOutboundOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo,
+ public void PerformFullOutboundOperation(Dt_StockInfoDetail stockDetail, Dt_StockInfo stockInfo,
decimal actualOutboundQuantity, OutboundCompleteRequestDTO request, decimal beforeQuantity, int taskNum)
{
// 淇濆瓨搴撳瓨鏄庣粏鍒板巻鍙茶褰�
@@ -1558,6 +1751,8 @@
InboundOrderRowNo = stockDetail.InboundOrderRowNo,
SupplyCode = stockDetail.SupplyCode,
FactoryArea = stockDetail.FactoryArea,
+ Creater = stockDetail.Creater,
+ CreateDate = stockDetail.CreateDate,
WarehouseCode = stockDetail.WarehouseCode,
Remark = $"鍑哄簱瀹屾垚鍒犻櫎锛屾潯鐮侊細{request.Barcode}锛屽師鏁伴噺锛歿stockDetail.StockQuantity}锛屽嚭搴撴暟閲忥細{actualOutboundQuantity}锛屾搷浣滆�咃細{request.Operator}"
};
@@ -1612,7 +1807,7 @@
/// <param name="afterQuantity"></param>
/// <param name="remark"></param>
/// <returns></returns>
- private List<Dt_MaterialCodeInfo> CreateMaterialCodeInfos(Dt_StockInfoDetail stockDetail, string newBarcode, decimal splitQuantity, string remark)
+ private List<Dt_MaterialCodeInfo> CreateMaterialCodeInfos(Dt_StockInfoDetail stockDetail, string newBarcode, decimal splitQuantity, string remark, int taskNum, int orderId, string orderNo)
{
List<Dt_MaterialCodeInfo> materialCodeInfos = new List<Dt_MaterialCodeInfo>();
@@ -1633,7 +1828,11 @@
SuplierCode = stockDetail.SupplyCode,
Unit = stockDetail.Unit,
Date = DateTime.Now.ToString("yyyy-MM-dd"),
- Remark = remark
+ Remark = remark,
+ WarehouseCode = stockDetail.WarehouseCode,
+ OrderNo = orderNo,
+ OrderId = orderId,
+ ReturnStatus = 0
};
materialCodeInfos.Add(outMaterialCodeInfo);
@@ -1652,7 +1851,11 @@
SuplierCode = stockDetail.SupplyCode,
Unit = stockDetail.Unit,
Date = DateTime.Now.ToString("yyyy-MM-dd"),
- Remark = remark
+ Remark = remark,
+ WarehouseCode = stockDetail.WarehouseCode,
+ OrderNo = orderNo,
+ OrderId = orderId,
+ ReturnStatus = 0
};
materialCodeInfos.Add(returnMaterialCodeInfo);
@@ -1704,6 +1907,20 @@
return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty);
}
+ /// <summary>
+ /// 妫�鏌ュ嚭搴撳崟鏄庣粏鏄惁瀹屾垚
+ /// </summary>
+ public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, Dt_OutboundOrderDetail outboundOrderDetail)
+ {
+ Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
+ if (outboundOrder == null) return false;
+
+ List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x => x.OrderId == outboundOrder.Id && x.MaterielCode == materialCode && (string.IsNullOrEmpty(outboundOrderDetail.SupplyCode) || x.SupplyCode == outboundOrderDetail.SupplyCode) && (string.IsNullOrEmpty(outboundOrderDetail.WarehouseCode) || x.WarehouseCode == outboundOrderDetail.WarehouseCode));
+
+ // 妫�鏌ユ墍鏈夋槑缁嗙殑宸插嚭鏁伴噺鏄惁閮界瓑浜庡崟鎹暟閲�
+ return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty);
+ }
+
#endregion
#region 鍙栫┖绠�
@@ -1712,7 +1929,7 @@
WebResponseContent content = new WebResponseContent();
try
{
- var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x=>x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
+ var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
if (stock == null)
{
@@ -1726,7 +1943,7 @@
stockInfo_Hty.SourceId = stock.Id;
stockInfo_Hty.OperateType = "鍙栫┖绠�";
stockInfo_Hty.InsertTime = DateTime.Now;
-
+
_unitOfWorkManage.BeginTran();
await _outboundRepository.Db.InsertNav(stockInfo_Hty).IncludesAllFirstLayer().ExecuteCommandAsync();
await _stockInfoRepository.DeleteDataByIdAsync(stock.Id);
@@ -1742,7 +1959,7 @@
#endregion
- #region
+ #region 鍥炲簱
public async Task<WebResponseContent> ReturnToWarehouse(string palletCode, string OrderNo, string station)
{
WebResponseContent content = new WebResponseContent();
@@ -1790,13 +2007,13 @@
var newTask = new Dt_Task()
{
- CurrentAddress = stations[station],
+ CurrentAddress = stations.GetValueOrDefault(station) ?? "",
Grade = 0,
PalletCode = palletCode,
NextAddress = "",
OrderNo = OrderNo,
Roadway = newLocation.RoadwayNo,
- SourceAddress = stations[station],
+ SourceAddress = stations.GetValueOrDefault(station) ?? "",
TargetAddress = newLocation.LocationCode,
TaskStatus = (int)TaskStatusEnum.New,
TaskType = stock.Details.Count > 0 ? (int)TaskTypeEnum.InPick : (int)TaskTypeEnum.InEmpty,
@@ -1806,11 +2023,11 @@
_stockInfoRepository.UpdateData(stock);
_taskRepository.AddData(newTask);
- //var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
- //{
- // slotCode = movestations[station],
- // containerCode = palletCode
- //});
+ var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
+ {
+ slotCode = movestations[station],
+ containerCode = palletCode
+ });
return content.OK();
}
--
Gitblit v1.9.3