From 441b6f8d257a01b2998253ef0515a201777d7e68 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 04 七月 2025 14:06:49 +0800
Subject: [PATCH] 修改入库、移库、出库逻辑
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs | 64 +++++++++++++++++--------------
1 files changed, 35 insertions(+), 29 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs"
index 7bc0dac..e15310b 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs"
@@ -55,14 +55,6 @@
{
InboundOrderAddDTO orderAddDTO = saveModel.MainData.DicToModel<InboundOrderAddDTO>();
orderAddDTO.Details = saveModel.DetailData.DicToIEnumerable<InboundOrderDetailAddDTO>();
- List<string> LocationCodes = orderAddDTO.Details
- .Where(x => !string.IsNullOrEmpty(x.LocationCode))
- .Select(x => x.LocationCode).ToList();
- if (LocationCodes.Any())
- {
- var content = _basicService.LocationInfoService.UpdateStatus(LocationCodes, LocationStatusEnum.PalletLock.ObjToInt());
- if (!content.Status) return WebResponseContent.Instance.Error("鎸囧畾璐т綅寮傚父");
- }
return AddInboundOrder(orderAddDTO);
}
@@ -81,14 +73,28 @@
if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
#endregion
+ List<string> LocationCodes = orderAddDTO.Details
+ .Where(x => !string.IsNullOrEmpty(x.LocationCode))
+ .Select(x => x.LocationCode).ToList();
+
Dt_InboundOrder inboundOrder = _mapper.Map<Dt_InboundOrder>(orderAddDTO);
- inboundOrder.OrderNo = DateTime.Now.ToString("yyMMddHHmmss");
+ //inboundOrder.OrderNo = DateTime.Now.ToString("yyMMddHHmmss");
inboundOrder.OrderStatus = InboundStatusEnum.鏈紑濮�.ObjToInt();
- bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+ Db.Ado.BeginTran();
+ if (LocationCodes.Any())
+ {
+ content = _basicService.LocationInfoService.UpdateStatus(LocationCodes, LocationStatusEnum.PalletLock.ObjToInt());
+ if (!content.Status)
+ throw new Exception(content.Message);
+ }
+
+ BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
+ Db.Ado.CommitTran();
content = WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
+ Db.Ado.RollbackTran();
content = WebResponseContent.Instance.Error(ex.Message);
}
finally
@@ -105,13 +111,13 @@
{
if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) throw new Exception($"鍏ュ簱鍗曟槑缁嗕笉鑳戒负绌�");
List<InboundOrderDetailAddDTO> inboundOrderDetail = saveModel.DetailData.DicToIEnumerable<InboundOrderDetailAddDTO>();
- if (inboundOrderDetail.FirstOrDefault(x => x.OrderDetailStatus > 0) != null) throw new Exception($"璁㈠崟宸插紑濮嬬粍鐩樺叆搴�");
- var inboundOrderDetails = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => saveModel.DelKeys.Contains(x.Id)).ToList();
- if (inboundOrderDetails.Count > 0)
- {
- if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
- throw new Exception($"瀛樺湪宸茬粍鐩樺伐鍗曪紝宸插厛瑙g洏");
- }
+ //if (inboundOrderDetail.FirstOrDefault(x => x.OrderDetailStatus > 0) != null) throw new Exception($"璁㈠崟宸插紑濮嬬粍鐩樺叆搴�");
+ //var inboundOrderDetails = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => saveModel.DelKeys.Contains(x.Id)).ToList();
+ //if (inboundOrderDetails.Count > 0)
+ //{
+ // if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
+ // throw new Exception($"瀛樺湪宸茬粍鐩樺伐鍗曪紝宸插厛瑙g洏");
+ //}
content = base.UpdateData(saveModel);
}
catch (Exception ex)
@@ -126,19 +132,19 @@
WebResponseContent content = new WebResponseContent();
try
{
- var inboundOrders = BaseDal.QueryData(x => keys.Contains(x.Id));
- if (inboundOrders.FirstOrDefault(x => x.OrderStatus != InboundStatusEnum.鏈紑濮�.ObjToInt()) != null)
- throw new Exception($"鍏ュ簱鍗曞瓨鍦ㄧ粍鐩樺叆搴撲俊鎭�");
- foreach (var inboundOrder in inboundOrders)
+ //var inboundOrders = BaseDal.QueryData(x => keys.Contains(x.Id));
+ var inboundOrders = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(x => keys.Contains(x.Id)).ToList();
+ if (inboundOrders.Count < 1) throw new Exception("鏈壘鍒板叆搴撳崟");
+ List<Dt_InboundOrderDetail> orderDetails = new List<Dt_InboundOrderDetail>();
+ foreach (var item in inboundOrders)
{
- var inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrder.OrderNo).Details;
- if (inboundOrderDetails != null || inboundOrderDetails.Count > 0)
- {
- if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
- throw new Exception($"鍏ュ簱鍗曘�恵inboundOrder.OrderNo}銆戝瓨鍦ㄧ粍鐩樺叆搴撲俊鎭�");
- }
+ if (item.Details.Where(x => x.ReceiptQuantity != x.OverInQuantity).Any())
+ throw new Exception("瀛樺湪鏈叆搴撳畬鎴愭墭鐩�");
+ orderDetails.AddRange(item.Details);
+ item.Details = null;
}
- content = base.DeleteData(keys);
+ BaseDal.DeleteAndMoveIntoHty(inboundOrders, OperateType.浜哄伐鍒犻櫎);
+ content.Status = _inboundOrderDetailService.Repository.DeleteAndMoveIntoHty(orderDetails, OperateType.浜哄伐鍒犻櫎);
}
catch (Exception ex)
{
@@ -171,7 +177,7 @@
return (false, "鏈夌墿鏂欎俊鎭湭褰曞叆锛岃褰曞叆鐗╂枡淇℃伅", inboundOrderAddDTO);
}
- if (BaseDal.QueryFirst(x => x.UpperOrderNo == inboundOrderAddDTO.UpperOrderNo && !string.IsNullOrEmpty(x.UpperOrderNo)) != null)
+ if (BaseDal.QueryFirst(x => x.OrderNo == inboundOrderAddDTO.orderNo && !string.IsNullOrEmpty(x.OrderNo)) != null)
{
return (false, "鍗曟嵁宸插瓨鍦�", inboundOrderAddDTO);
}
--
Gitblit v1.9.3