From 557f7f6079c30cd6fe8d6005cea3d89468bbcd31 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期一, 09 三月 2026 09:23:13 +0800
Subject: [PATCH] 代码优化
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundService.cs | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 279 insertions(+), 20 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 14ca9ad..96577c1 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,14 +1,16 @@
-锘縰sing System.Reflection.Emit;
-using AutoMapper;
+锘縰sing AutoMapper;
using Dm.filter;
using MailKit.Search;
using Mapster;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Crypto;
using SqlSugar;
+using System;
+using System.Reflection.Emit;
using WIDESEA_BasicService;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.LocationEnum;
@@ -22,12 +24,14 @@
using WIDESEA_DTO.Base;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.CalcOut;
+using WIDESEA_DTO.Outbound;
using WIDESEA_DTO.ReturnMES;
using WIDESEA_IBasicService;
using WIDESEA_IOutboundService;
using WIDESEA_IRecordService;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
+using WIDESEA_Model.Models.Basic;
using WIDESEA_Model.Models.Check;
using static HslCommunication.Profinet.Knx.KnxCode;
@@ -62,6 +66,10 @@
private readonly IESSApiService _eSSApiService;
private readonly IRepository<Dt_AllocateOrder> _allocateOrderRepository;
private readonly IRepository<Dt_AllocateMaterialInfo> _allocateMaterialInfoRepository;
+ public readonly IRepository<Dt_InboundOrderDetail> _inboundOrderDetailRepository;
+ public readonly IRepository<Dt_InboundOrder> _inboundOrderRepository;
+ public readonly IRepository<Dt_WarehouseArea> _warehouseAreaRepository;
+ public readonly IRepository<Dt_LocationType> _locationTypeRepository;
private Dictionary<string, string> stations = new Dictionary<string, string>
{
@@ -75,7 +83,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, IRepository<Dt_AllocateOrder> allocateOrderRepository, 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, IESSApiService eSSApiService, IRepository<Dt_AllocateOrder> allocateOrderRepository, IRepository<Dt_AllocateMaterialInfo> allocateMaterialInfoRepository, IRepository<Dt_InboundOrderDetail> inboundOrderDetailRepository, IRepository<Dt_InboundOrder> inboundOrderRepository, IRepository<Dt_LocationType> locationTypeRepository, IRepository<Dt_WarehouseArea> warehouseAreaRepository)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -98,6 +106,37 @@
_eSSApiService = eSSApiService;
_allocateOrderRepository = allocateOrderRepository;
_allocateMaterialInfoRepository = allocateMaterialInfoRepository;
+ _inboundOrderDetailRepository = inboundOrderDetailRepository;
+ _inboundOrderRepository = inboundOrderRepository;
+ _locationTypeRepository = locationTypeRepository;
+ _warehouseAreaRepository = warehouseAreaRepository;
+ }
+
+ public WebResponseContent PrintFromData (string barcode)
+ {
+ var detail = _inboundOrderDetailRepository.QueryFirst(x => x.Barcode == barcode);
+ if(detail == null)
+ {
+ return WebResponseContent.Instance.Error();
+ }
+
+ var inbound = _inboundOrderRepository.QueryFirst(x=>x.Id == detail.OrderId);
+ if(inbound == null)
+ {
+ return WebResponseContent.Instance.Error();
+ }
+ var printFormData = new PrintFromDataDTO {
+ materialCode = detail.MaterielCode,
+ materialName = detail.MaterielName,
+ materialSpec = detail.Unit,
+ batchNo = detail.BatchNo,
+ pruchaseOrderNo = inbound.UpperOrderNo,
+ factoryArea = inbound.FactoryArea,
+ suplierCode = detail.SupplyCode,
+ quantity = detail.BarcodeQty
+ };
+
+ return WebResponseContent.Instance.OK(data:printFormData);
}
#region 鍑哄簱鍒嗛厤
@@ -112,6 +151,14 @@
PickingOutboundResponseDTO response = new PickingOutboundResponseDTO();
decimal totalNeedAllocate = 0; // 鎬婚渶姹傚垎閰嶉噺
decimal totalActualAllocate = 0; // 瀹為檯鎬诲垎閰嶉噺
+ string targetWarehouse = string.Empty;// 鐩爣浠撳簱
+ string targetLocationCode = string.Empty; // 鐩爣璐т綅
+ bool isWholeCaseOutbound = false; // 鏄惁鏁寸鍑哄簱
+ List<string> wholeCasePallets = new List<string>();
+ Dictionary<string, string> palletLocationMap = new Dictionary<string, string>();
+ Dictionary<string, bool> palletIsWholeCaseMap = new Dictionary<string, bool>();
+ int? targetLocationType = null;
+
try
{
@@ -127,6 +174,7 @@
// 璁板綍鎬婚渶姹傛暟閲�
totalNeedAllocate = calculationResult.MaterielCalculations.Sum(x => x.UnallocatedQuantity);
+
// 2. 澶勭悊鐗╂枡鍒嗛厤
List<PickedStockDetailDTO> pickedDetails = new List<PickedStockDetailDTO>();
Dt_OutboundOrder outboundOrder = calculationResult.OutboundOrder;
@@ -160,11 +208,116 @@
materielCalc.OutStockLockInfos.Add(item);
}
outStockLockInfos.Add(item);
- }
+
+ if (outboundOrder.OrderType == 117)
+ {
+ // 鍖归厤褰撳墠鍗曟嵁鐨勯攣瀹氳褰�
+ if (outboundOrder.OrderNo == item.OrderNo)
+ {
+ // 鏌ヨ搴撳瓨淇℃伅
+ var stockInfo = _stockInfoRepository.QueryFirst(x => x.PalletCode == item.PalletCode);
+ if (stockInfo == null)
+ {
+ content = WebResponseContent.Instance.Error($"鎵樼洏{item.PalletCode}鏈煡璇㈠埌搴撳瓨淇℃伅锛屾棤娉曞鐞嗘暣绠卞嚭搴�");
+ _unitOfWorkManage.RollbackTran();
+ return content;
+ }
+
+ // 璁$畻搴撳瓨鎬婚噺锛屽垽鏂槸鍚︽暣绠憋紙澧炲姞0鍊间繚鎶わ級
+ decimal stockQuantity = _stockDetailRepository.QueryData(x => x.StockId == stockInfo.Id).Sum(x => x.StockQuantity);
+ if (stockQuantity > 0 && stockQuantity == item.AssignQuantity)
+ {
+ // 鏍囪褰撳墠鎵樼洏涓烘暣绠憋紙鏍稿績淇锛氭寜鎵樼洏缁村害璁板綍鐘舵�侊級
+ if (!palletIsWholeCaseMap.ContainsKey(item.PalletCode))
+ {
+ palletIsWholeCaseMap.Add(item.PalletCode, true);
+ }
+ else
+ {
+ palletIsWholeCaseMap[item.PalletCode] = true;
+ }
+
+ // 鐩爣浠撳簱/璐т綅绫诲瀷鍙煡璇竴娆★紙鎬ц兘浼樺寲+绌哄�间繚鎶わ級
+ if (string.IsNullOrEmpty(targetWarehouse))
+ {
+ targetWarehouse = GetToWarehouseByOrderNo(request.OrderNo);
+ if (string.IsNullOrEmpty(targetWarehouse))
+ {
+ content = WebResponseContent.Instance.Error("鏅轰粨璋冩櫤浠撴暣绠卞嚭搴撳崟鎹湭閰嶇疆鐩爣浠撳簱");
+ _unitOfWorkManage.RollbackTran();
+ return content;
+ }
+
+ // 鏇挎崲First()涓篎irstOrDefault()锛岄伩鍏嶇┖鍊煎紓甯�
+ string warehouseAreaName = _warehouseAreaRepository.Db.Queryable<Dt_WarehouseArea>()
+ .Where(x => x.Code == targetWarehouse)
+ .Select(x => x.Name)
+ .First();
+ if (string.IsNullOrEmpty(warehouseAreaName))
+ {
+ content = WebResponseContent.Instance.Error($"鐩爣浠撳簱{targetWarehouse}鏈煡璇㈠埌瀵瑰簲鐨勫簱鍖哄悕绉�");
+ _unitOfWorkManage.RollbackTran();
+ return content;
+ }
+
+ int? locationType = _locationTypeRepository.Db.Queryable<Dt_LocationType>()
+ .Where(x => string.Equals(x.LocationTypeDesc, warehouseAreaName, StringComparison.OrdinalIgnoreCase))
+ .Select(x => x.LocationType)
+ .First();
+ if (!locationType.HasValue)
+ {
+ content = WebResponseContent.Instance.Error($"搴撳尯{warehouseAreaName}鏈尮閰嶅埌瀵瑰簲鐨勮揣浣嶇被鍨�");
+ _unitOfWorkManage.RollbackTran();
+ return content;
+ }
+ targetLocationType = locationType.Value;
+ }
+
+ // 鍒嗛厤鐩爣璐т綅锛堟瘡涓墭鐩樼嫭绔嬭揣浣嶏級
+ if (!palletLocationMap.ContainsKey(item.PalletCode) && targetLocationType.HasValue)
+ {
+ Dt_LocationInfo locationInfo = _locationInfoService.AssignLocation(targetLocationType.Value);
+ if (locationInfo == null || string.IsNullOrEmpty(locationInfo.LocationCode))
+ {
+ content = WebResponseContent.Instance.Error($"璐т綅绫诲瀷{targetLocationType.Value}鏈垎閰嶅埌鍙敤璐т綅锛堟墭鐩橈細{item.PalletCode}锛�");
+ _unitOfWorkManage.RollbackTran();
+ return content;
+ }
+ palletLocationMap.Add(item.PalletCode, locationInfo.LocationCode);
+ }
+
+ // 鍔犲叆鏁寸鎵樼洏鍒楄〃
+ if (!wholeCasePallets.Contains(item.PalletCode))
+ {
+ wholeCasePallets.Add(item.PalletCode);
+ }
+ }
+ else
+ {
+ if (!palletIsWholeCaseMap.ContainsKey(item.PalletCode))
+ {
+ palletIsWholeCaseMap.Add(item.PalletCode, false);
+ }
+ else
+ {
+ palletIsWholeCaseMap[item.PalletCode] = false;
+ }
+ }
+ }
+ }
+ }
// 澶勭悊浠诲姟
foreach (var item in materielPickedDetails.Tasks)
{
+ if (outboundOrder.OrderType == 117
+ && palletIsWholeCaseMap.ContainsKey(item.PalletCode)
+ && palletIsWholeCaseMap[item.PalletCode]
+ && palletLocationMap.ContainsKey(item.PalletCode))
+ {
+ item.TaskType = (int)TaskTypeEnum.Relocation;
+ item.TargetAddress = palletLocationMap[item.PalletCode];
+ }
if (tasks.FirstOrDefault(x => x.PalletCode == item.PalletCode) == null)
tasks.Add(item);
}
@@ -202,13 +355,37 @@
if (tasks.Any()) _taskRepository.AddData(tasks);
-
- _unitOfWorkManage.CommitTran();
+ if (outboundOrder.OrderType == 117 && wholeCasePallets.Any())
+ {
+ foreach (var palletCode in wholeCasePallets)
+ {
+ var completeReq = new OutboundCompletePalletRequestDTO
+ {
+ OrderNo = request.OrderNo,
+ PalletCode = palletCode
+ };
+
+ var res = CompleteOutboundWithPallet(completeReq);
+ if (!res.Status)
+ {
+ _unitOfWorkManage.RollbackTran();
+ return res;
+ }
+ }
+ }
+
+ _unitOfWorkManage.CommitTran();
// 4. 鏋勯�犲搷搴旓細鍖哄垎銆屽叏閮ㄥ垎閰嶃�嶅拰銆岄儴鍒嗗垎閰嶃��
string responseMsg = totalActualAllocate == totalNeedAllocate
? "鍒嗘嫞浠诲姟鍒嗛厤鎴愬姛"
: $"鍒嗘嫞浠诲姟鍒嗛厤瀹屾垚锛堝疄闄呭垎閰峽totalActualAllocate}锛岄渶姹倇totalNeedAllocate}锛屽簱瀛樹笉瓒抽儴鍒嗘湭鍒嗛厤锛�";
+ Dt_OutboundOrder outboundOrder1 = _outboundRepository.Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderNo == request.OrderNo).Includes(x=>x.Details).First();
+ if(totalActualAllocate == 0 && !outboundOrder1.Details.Any(x=>x.LockQuantity >0))
+ {
+ UpdateOutboundOrderStatus(request.OrderNo, (int)OutOrderStatusEnum.鏈紑濮�);
+ return WebResponseContent.Instance.Error("鍒嗛厤搴撳瓨鏁伴噺涓�0锛屾棤娉曞嚭搴�");
+ }
response.Success = true;
response.Message = responseMsg;
response.Tasks = tasks;
@@ -221,6 +398,18 @@
content = WebResponseContent.Instance.Error("澶勭悊鎷h揣鍑哄簱澶辫触锛�" + ex.Message);
}
return content;
+ }
+
+
+ /// <summary>
+ /// 鏍规嵁鍗曟嵁鍙疯幏鍙栫洰鏍囦粨搴�
+ /// </summary>
+ /// <param name="orderNo"></param>
+ /// <returns></returns>
+ public String GetToWarehouseByOrderNo(string orderNo)
+ {
+ var order =_allocateOrderRepository.QueryFirst(x => x.OrderNo == orderNo);
+ return order.ToWarehouse;
}
/// <summary>
@@ -768,6 +957,10 @@
Dt_OutboundOrder outboundOrder = _outboundRepository.QueryFirst(x => x.OrderNo == orderNo);
if (outboundOrder == null) return false;
outboundOrder.OrderStatus = status;
+ if(outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
+ {
+ outboundOrder.ReturnToMESStatus = 5;
+ }
_outboundRepository.UpdateData(outboundOrder);
return true;
}
@@ -1109,8 +1302,15 @@
{
barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
+ if(item.ReturnToMESStatus == 0)
+ {
+ item.CurrentDeliveryQty = item.LockQuantity;
+ }
+ else
+ {
+ item.CurrentDeliveryQty += item.LockQuantity - item.OverOutQuantity;
+ }
item.OverOutQuantity = item.LockQuantity;
- item.CurrentDeliveryQty = item.LockQuantity;
}
updateDetails.Add(item);
@@ -1157,7 +1357,22 @@
response.Success = true;
response.Message = "鍑哄簱瀹屾垚";
response.UpdatedDetails = updateDetails;
-
+
+ if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails))
+ {
+ 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 == stockInfoDetail.MaterielCode).Where(supWhere).Where(wareWhere).ToList();
+ if (stockLockInfos != null && stockLockInfos.Any())
+ {
+ _outboundLockInfoRepository.DeleteAndMoveIntoHty(stockLockInfos, WIDESEA_Core.Enums.OperateTypeEnum.鑷姩鍒犻櫎);
+ }
+ }
+
// 妫�鏌ュ嚭搴撳崟鏄惁瀹屾垚
if (CheckOutboundOrderCompleted(request.OrderNo))
{
@@ -1263,9 +1478,15 @@
_stockDetailHistoryRepository.AddData(historyRecords);
// 鍒犻櫎搴撳瓨鏄庣粏璁板綍
- _stockDetailRepository.DeleteData(stockInfo.Details);
+ var orderNo =_outboundRepository.QueryFirst(x => x.OrderNo == request.OrderNo);
+ if(orderNo.OrderType != 117)
+ {
+ _stockDetailRepository.DeleteData(stockInfo.Details);
+ }
_stockChangeRepository.AddData(changeRecords);
}
+
+
#endregion
#region 鎷i��
@@ -1474,10 +1695,21 @@
{
barcodeQuantity = item.LockQuantity - item.OverOutQuantity;
allocatedQuantity -= (item.LockQuantity - item.OverOutQuantity);
+ if (item.ReturnToMESStatus == 0)
+ {
+ item.CurrentDeliveryQty = item.LockQuantity;
+ }
+ else
+ {
+ item.CurrentDeliveryQty += item.LockQuantity - item.OverOutQuantity;
+ }
item.OverOutQuantity = item.LockQuantity;
- item.CurrentDeliveryQty = item.LockQuantity;
}
+ if (item.OverOutQuantity == item.OrderQuantity)
+ {
+ item.OrderDetailStatus = (int)OrderDetailStatusEnum.Over;
+ }
updateDetails.Add(item);
List<Barcodes> barcodesList = new List<Barcodes>();
@@ -1551,7 +1783,7 @@
_feedbackMesService.BarcodeFeedback(newBarcode);
}
- if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails.First()))
+ if (CheckOutboundOrderDetailCompletedByMatCode(request.OrderNo, lockInfo.MaterielCode, outboundOrderDetails))
{
Func<Dt_OutStockLockInfo, bool> supWhere = x => string.IsNullOrEmpty(outboundOrderDetails.First().SupplyCode) ? true : x.SupplyCode == outboundOrderDetails.First().SupplyCode;
@@ -1572,12 +1804,11 @@
{
UpdateOutboundOrderStatus(request.OrderNo, OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt());
- if (outboundOrder.OrderType != OutOrderTypeEnum.InternalAllocat.ObjToInt())
+ if (outboundOrder.CreateType!=OrderCreateTypeEnum.CreateInSystem.ObjToInt())
{
_feedbackMesService.OutboundFeedback(outboundOrder.OrderNo);
}
}
-
}
catch (Exception ex)
{
@@ -1906,14 +2137,30 @@
/// <summary>
/// 妫�鏌ュ嚭搴撳崟鏄庣粏鏄惁瀹屾垚
/// </summary>
- public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, Dt_OutboundOrderDetail outboundOrderDetail)
+ public bool CheckOutboundOrderDetailCompletedByMatCode(string orderNo, string materialCode, List<Dt_OutboundOrderDetail> outboundOrderDetails)
{
+ if (string.IsNullOrEmpty(orderNo) || string.IsNullOrEmpty(materialCode) || outboundOrderDetails == null || !outboundOrderDetails.Any())
+ return false;
+
+ // 鏌ヨ涓昏鍗曪紝涓嶅瓨鍦ㄧ洿鎺ヨ繑鍥瀎alse
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));
+ var firstDetail = outboundOrderDetails.FirstOrDefault();
+ string supplyCode = firstDetail.SupplyCode;
+ string warehouseCode = firstDetail.WarehouseCode;
+ List<int> ids = outboundOrderDetails.Select(x => x.Id).ToList();
- // 妫�鏌ユ墍鏈夋槑缁嗙殑宸插嚭鏁伴噺鏄惁閮界瓑浜庡崟鎹暟閲�
+ List<Dt_OutboundOrderDetail> details = _detailRepository.QueryData(x =>
+ x.OrderId == outboundOrder.Id
+ && x.MaterielCode == materialCode
+ && ids.Contains(x.Id)
+ && (string.IsNullOrEmpty(supplyCode) || x.SupplyCode == supplyCode)
+ && (string.IsNullOrEmpty(warehouseCode) || x.WarehouseCode == warehouseCode)
+ );
+
+ if (!details.Any()) return false;
+
return details.All(x => x.OverOutQuantity >= x.OrderQuantity - x.MoveQty);
}
@@ -1926,6 +2173,12 @@
try
{
var stock = await _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Includes(x => x.Details).Where(x => x.PalletCode == palletCode).FirstAsync();
+
+ Dt_Task task = _taskRepository.QueryFirst(x => x.PalletCode == palletCode);
+ if (task != null)
+ {
+ return WebResponseContent.Instance.Error("浠诲姟淇℃伅鍒楄〃瀛樺湪璇ユ墭鐩樼殑浠诲姟淇℃伅锛屼笉鍙彇璧扮┖绠憋紝璇锋鏌ヤ换鍔℃槸鍚﹀畬鎴�");
+ }
if (stock == null)
{
@@ -1971,21 +2224,20 @@
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)
{
Dt_OutStockLockInfo lockInfo = _outboundLockInfoRepository.QueryFirst(x =>
- x.OrderNo == OrderNo &&
x.StockId == stock.Id &&
x.PalletCode == palletCode);
if (lockInfo != null && lockInfo.SortedQuantity != lockInfo.AssignQuantity)
{
- return content.Error($"鎵樼洏{palletCode}搴撳瓨鏈嫞閫夊畬涓嶅厑璁稿洖搴�");
+ return content.Error($"鎵樼洏{palletCode}搴撳瓨锛屽湪鍗曟嵁{lockInfo.OrderNo}閲岄潰杩樻湭鎷i�夊畬鎴愶紝涓嶅厑璁稿洖搴�");
}
- stock.StockStatus = (int)StockStatusEmun.缁勭洏鏆傚瓨;
+ stock.StockStatus = (int)StockStatusEmun.鍏ュ簱纭;
stock.LocationCode = "";
}
@@ -2000,6 +2252,11 @@
// 鍒嗛厤鏂拌揣浣�
var newLocation = _locationInfoService.AssignLocation(stock.LocationType);
+
+ if(newLocation == null)
+ {
+ return WebResponseContent.Instance.Error("娌℃湁绌洪棽搴撲綅鍙洖搴�");
+ }
var newTask = new Dt_Task()
{
@@ -2095,5 +2352,7 @@
}
#endregion
+
+
}
}
--
Gitblit v1.9.3