From 266e4bf654c55ce2f7e9271048e4625f1b8b49f6 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 29 十二月 2025 14:36:08 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 268 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 214 insertions(+), 54 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 8e55ec4..4d53ab6 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,4 +1,5 @@
-锘縰sing AutoMapper;
+锘縰sing System.Reflection.Emit;
+using AutoMapper;
using Dm.filter;
using MailKit.Search;
using Mapster;
@@ -7,8 +8,8 @@
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;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Common.StockEnum;
@@ -17,6 +18,7 @@
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.CodeConfigEnum;
using WIDESEA_Core.Helper;
+using WIDESEA_DTO.Basic;
using WIDESEA_DTO.CalcOut;
using WIDESEA_DTO.ReturnMES;
using WIDESEA_IBasicService;
@@ -24,6 +26,7 @@
using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
+using static HslCommunication.Profinet.Knx.KnxCode;
namespace WIDESEA_OutboundService
{
@@ -53,8 +56,23 @@
private readonly IFeedbackMesService _feedbackMesService;
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;
- 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)
+ private Dictionary<string, string> stations = new Dictionary<string, string>
+ {
+ {"2-1","2-9" },
+ {"3-1","3-9" },
+ };
+
+ private Dictionary<string, string> movestations = new Dictionary<string, string>
+ {
+ {"2-1","2-5" },
+ {"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, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -74,6 +92,9 @@
_feedbackMesService = feedbackMesService;
_taskRepository = taskRepository;
_locationInfoService = locationInfoService;
+ _eSSApiService = eSSApiService;
+ _allocateOrderRepository = allocateOrderRepository;
+ _allocateMaterialInfoRepository = allocateMaterialInfoRepository;
}
#region 鍑哄簱鍒嗛厤
@@ -89,6 +110,7 @@
PickingOutboundResponseDTO response = new PickingOutboundResponseDTO();
try
{
+ _unitOfWorkManage.BeginTran();
// 1. 璁$畻鍑哄簱鏁伴噺閫昏緫
OutboundCalculationDTO calculationResult = CalcOutboundQuantity(request);
@@ -149,7 +171,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)
{
@@ -227,14 +250,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.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())
@@ -255,7 +287,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());
@@ -342,7 +374,6 @@
.GroupBy(x => new
{
x.MaterielCode,
- x.MaterielName,
x.BatchNo,
x.SupplyCode,
x.WarehouseCode
@@ -350,7 +381,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,
@@ -402,13 +432,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>();
@@ -517,7 +549,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))
@@ -822,8 +854,7 @@
}
#endregion
-
-
+ #region 鏁寸鍑哄簱
public WebResponseContent CompleteOutboundWithPallet(OutboundCompletePalletRequestDTO request)
{
WebResponseContent content = WebResponseContent.Instance;
@@ -937,6 +968,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();
@@ -957,34 +1015,41 @@
//}
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;
+
foreach (var stockDetail in stockInfoDetails)
{
- if (item.LockQuantity - item.OverOutQuantity >= stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity)
+ if (itemQuantity >= stockDetail.StockQuantity - stockDetail.OutboundQuantity)
{
Barcodes barcodes = new Barcodes
{
Barcode = stockDetail.Barcode,
- Qty = stockDetail.StockQuantity - stockInfoDetail.OutboundQuantity,
+ Qty = stockDetail.StockQuantity - stockDetail.OutboundQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
Unit = stockDetail?.Unit ?? ""
};
- stockDetail.StockQuantity = stockInfoDetail.OutboundQuantity;
+ itemQuantity -= (stockDetail.StockQuantity - stockDetail.OutboundQuantity);
+ stockDetail.OutboundQuantity = stockDetail.StockQuantity;
barcodesList.Add(barcodes);
+
+ if (itemQuantity <= 0) break;
}
else
{
Barcodes barcodes = new Barcodes
{
Barcode = stockDetail.Barcode,
- Qty = item.LockQuantity - item.OverOutQuantity,
+ Qty = itemQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
Unit = stockDetail?.Unit ?? ""
};
- stockInfoDetail.OutboundQuantity += item.LockQuantity - item.OverOutQuantity;
+ stockDetail.OutboundQuantity += itemQuantity;
barcodesList.Add(barcodes);
+ break;
}
}
@@ -1049,8 +1114,11 @@
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
+ if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+ {
+ _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+ }
- //todo: 鍥炰紶MES
}
}
catch (Exception ex)
@@ -1115,6 +1183,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);
@@ -1147,6 +1217,7 @@
_stockDetailRepository.DeleteData(stockInfo.Details);
_stockChangeRepository.AddData(changeRecords);
}
+ #endregion
#region 鎷i��
/// <summary>
@@ -1253,21 +1324,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;
@@ -1309,7 +1435,7 @@
List<Barcodes> barcodesList = new List<Barcodes>();
Barcodes barcodes = new Barcodes
{
- Barcode = request.Barcode,
+ Barcode = isUnpacked ? newBarcode : stockDetail?.Barcode,
Qty = barcodeQuantity,
SupplyCode = stockDetail?.SupplyCode ?? "",
BatchNo = stockDetail?.BatchNo ?? "",
@@ -1369,13 +1495,21 @@
response.ScannedDetail = scannedDetail;
response.UpdatedDetails = updateDetails;
+ if (!string.IsNullOrEmpty(newBarcode))
+ {
+ // 鐗╂枡鏂版潯鐮佸洖浼�
+ _feedbackMesService.BarcodeFeedback(newBarcode);
+ }
+
// 妫�鏌ュ嚭搴撳崟鏄惁瀹屾垚
if (CheckOutboundOrderCompleted(request.OrderNo))
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
-
- //todo: 鍥炰紶MES
+ if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+ {
+ _feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
+ }
}
}
catch (Exception ex)
@@ -1442,14 +1576,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)
+ private (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);
@@ -1473,9 +1607,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);
@@ -1486,7 +1622,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);
}
@@ -1508,11 +1644,11 @@
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>
@@ -1542,6 +1678,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}"
};
@@ -1596,7 +1734,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>();
@@ -1617,7 +1755,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);
@@ -1636,7 +1778,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);
@@ -1696,7 +1842,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)
{
@@ -1710,7 +1856,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);
@@ -1726,30 +1872,38 @@
#endregion
- #region
- public async Task<WebResponseContent> ReturnToWarehouse(string palletCode,string OrderNo,string station)
+ #region 鍥炲簱
+ public async Task<WebResponseContent> ReturnToWarehouse(string palletCode, string OrderNo, string station)
{
WebResponseContent content = new WebResponseContent();
try
{
var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
- if(stock == null)
+ if (stock == null)
{
return content.Error($"鏈壘鍒版墭鐩榹palletCode}搴撳瓨淇℃伅涓嶅厑璁稿洖搴�");
}
- if (stock.Details.Count > 0)
+ if (stock.Details.Count <= 0)
+ {
+ stock.PalletType = (int)PalletTypeEnum.Empty;
+ stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+ stock.LocationCode = "";
+ }
+ else if (stock.Details.Count > 0)
{
Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
- x.OrderNo == OrderNo &&
- x.StockId == stock.Id &&
- x.PalletCode == palletCode);
+ x.OrderNo == OrderNo &&
+ x.StockId == stock.Id &&
+ x.PalletCode == palletCode);
if (lockInfo != null && lockInfo.SortedQuantity != lockInfo.AssignQuantity)
{
return content.Error($"鎵樼洏{palletCode}搴撳瓨鏈嫞閫夊畬涓嶅厑璁稿洖搴�");
}
+ stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+ stock.LocationCode = "";
}
var task = await _taskRepository.Db.Queryable<Dt_Task>()
@@ -1766,21 +1920,27 @@
var newTask = new Dt_Task()
{
- CurrentAddress = station,
+ CurrentAddress = stations.GetValueOrDefault(station) ?? "",
Grade = 0,
PalletCode = palletCode,
NextAddress = "",
OrderNo = OrderNo,
Roadway = newLocation.RoadwayNo,
- SourceAddress = station,
+ SourceAddress = stations.GetValueOrDefault(station) ?? "",
TargetAddress = newLocation.LocationCode,
TaskStatus = (int)TaskStatusEnum.New,
- TaskType = stock.Details.Count > 0 ? (int)TaskTypeEnum.InPick : (int)TaskTypeEnum.OutEmpty,
+ TaskType = stock.Details.Count > 0 ? (int)TaskTypeEnum.InPick : (int)TaskTypeEnum.InEmpty,
PalletType = stock.PalletType,
WarehouseId = stock.WarehouseId
};
-
+ _stockInfoRepository.UpdateData(stock);
_taskRepository.AddData(newTask);
+
+ var moveResult = await _eSSApiService.MoveContainerAsync(new MoveContainerRequest
+ {
+ slotCode = movestations[station],
+ containerCode = palletCode
+ });
return content.OK();
}
--
Gitblit v1.9.3