From 782634954ec1a821a7987c38edaf53252bc26954 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 11 一月 2025 16:19:15 +0800
Subject: [PATCH] 优化辅料
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs | 116 ++++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 84 insertions(+), 32 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
index 3f5b0aa..483ba11 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/OutboundOrderService.cs"
@@ -43,9 +43,11 @@
public IOutboundOrderRepository Repository => BaseDal;
private readonly IInvokeERPService _invokeERPService;
private readonly IOutStockLockInfoService _outStockLockInfoService;
+ private readonly IOutboundOrderRepository _outboundOrderRepository;
- public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper,IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
- IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService, IOutStockLockInfoService outStockLockInfoService) : base(BaseDal)
+ public OutboundOrderService(IOutboundOrderRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundOrderDetailRepository outboundOrderDetailRepository, IStockInfoService stockInfoService,
+ IStockInfoRepository stockInfoRepository, IInvokeERPService invokeERPService, IOutStockLockInfoService outStockLockInfoService,
+ IOutboundOrderRepository outboundOrderRepository) : base(BaseDal)
{
_mapper = mapper;
_unitOfWorkManage = unitOfWorkManage;
@@ -55,8 +57,47 @@
_stockInfoRepository = stockInfoRepository;
_invokeERPService = invokeERPService;
_outStockLockInfoService = outStockLockInfoService;
+ _outboundOrderRepository = outboundOrderRepository;
}
+ public override WebResponseContent AddData(SaveModel saveModel)
+ {
+ if (saveModel.MainData.TryGetValue(nameof(Dt_OutboundOrder.UpperOrderNo).FirstLetterToLower(), out object? upperOrderNo) && upperOrderNo != null && !string.IsNullOrEmpty(upperOrderNo.ToString()))
+ {
+ Dt_OutboundOrder outboundOrder = BaseDal.QueryFirst(x => x.UpperOrderNo == upperOrderNo.ToString() && x.WarehouseId == Convert.ToInt32(saveModel.MainData[nameof(Dt_OutboundOrder.WarehouseId).FirstLetterToLower()]));
+ if (outboundOrder != null)
+ {
+ return WebResponseContent.Instance.Error($"{upperOrderNo}棰嗘枡鍗曞彿宸插瓨鍦�");
+ }
+ }
+ saveModel.DetailData[0].Add("orderDetailStatus", OrderDetailStatusEnum.New.ObjToInt());
+ return base.AddData(saveModel);
+ }
+ public WebResponseContent GetOutboundOrders(SaveModel saveModel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ int pageNo = saveModel.MainData["pageNo"].ObjToInt();
+ string? orderNo = saveModel.MainData["orderNo"].ToString();
+ int warehouseId = saveModel.MainData["warehouseId"].ObjToInt();
+ List<Dt_OutboundOrder> dt_ReceiveOrders = new List<Dt_OutboundOrder>();
+ if (string.IsNullOrEmpty(orderNo))
+ {
+ dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => x.OrderStatus < OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5);
+ }
+ else
+ {
+ dt_ReceiveOrders = Db.Queryable<Dt_OutboundOrder>().Where(x => (x.OrderNo.Contains(orderNo)) && x.OrderStatus < OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && x.WarehouseId == warehouseId).ToPageList(pageNo, 5);
+ }
+ content.OK(data: dt_ReceiveOrders);
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
public WebResponseContent ReceiveOutOrder(ErpOutOrderDTO model)
{
try
@@ -112,10 +153,11 @@
MaterielName = materielInfo.MaterielName,
OrderDetailStatus = OrderDetailStatusEnum.New.ObjToInt(),
OrderQuantity = model.Qty,
+ Unit = materielInfo.MaterielUnit
};
Dt_OutboundOrder outboundOrder = new Dt_OutboundOrder()
{
- OrderNo=model.OrderNo,
+ OrderNo = model.OrderNo,
UpperOrderNo = model.OrderNo,
OrderStatus = OutOrderStatusEnum.鏈紑濮�.ObjToInt(),
OrderType = OutOrderTypeEnum.Issue.ObjToInt(),
@@ -172,31 +214,45 @@
}
}
//涓婃姤鍑哄簱瀹屾垚
- public WebResponseContent TestOutUpload(int id,List<Dt_OutStockLockInfo>? outStockLockInfos)
+ public WebResponseContent TestOutUpload(int id, List<Dt_OutStockLockInfo>? outStockLockInfos)
{
try
{
- Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x=>x.Id==id).Includes(x=>x.Details).First();
+ Dt_OutboundOrder outboundOrder = Db.Queryable<Dt_OutboundOrder>().Where(x => x.Id == id).Includes(x => x.Details).First();
Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == outboundOrder.WarehouseId);
ERPIssueModel issueModel = new ERPIssueModel();
List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
- List<Dt_OutStockLockInfo> _OutStockLockInfos=new List<Dt_OutStockLockInfo>();
+ List<Dt_OutStockLockInfo> _OutStockLockInfos = new List<Dt_OutStockLockInfo>();
+ int overCount = outboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).Count();
+ if (outboundOrder.Details.Count == overCount)
+ {
+ outboundOrder.OrderStatus = OutOrderStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+ _outboundOrderRepository.UpdateData(outboundOrder);
+ }
+ if (outboundOrder == null)
+ {
+ return WebResponseContent.Instance.Error("鍑哄簱鍗曚笉瀛樺湪");
+ }
+ if (outboundOrder.CreateType == OrderCreateTypeEnum.CreateInSystem.ObjToInt())
+ {
+ return WebResponseContent.Instance.OK();
+ }
//娴嬭瘯鏋跺簱缁橢RP涓婃姤鍑哄簱瀹屾垚
- if (outStockLockInfos.Count<=0 || outStockLockInfos==null)
+ if (warehouse.WarehouseCode == WarehouseEnum.HA64.ToString())
{
stockInfos = TestOutStocksUpdate(warehouse).Data as List<Dt_StockInfo> ?? new List<Dt_StockInfo>();
- List<ERPPickItemModel> eRPOutPick =new List<ERPPickItemModel>();
+ List<ERPPickItemModel> eRPOutPick = new List<ERPPickItemModel>();
for (int i = 0; i < stockInfos.Count; i++)
{
ERPPickItemModel pickItemModel = new ERPPickItemModel()
{
- Lotno= stockInfos[i].Details[0].BatchNo,
- Qty= stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
- Location= warehouse.WarehouseCode
+ Lotno = stockInfos[i].Details[0].BatchNo,
+ Qty = stockInfos[i].Details[0].StockQuantity.ObjToInt().ToString(),
+ Location = warehouse.WarehouseCode
};
eRPOutPick.Add(pickItemModel);
}
-
+
ERPPickModel pickModel = new ERPPickModel()
{
Rowindex = outboundOrder.Details[0].RowNo,
@@ -225,8 +281,8 @@
}
else
{
- List<ERPPickModel> eRPPickModels= new List<ERPPickModel>();
-
+ List<ERPPickModel> eRPPickModels = new List<ERPPickModel>();
+
//鑾峰彇鍑哄簱璇︽儏鍗�
foreach (var item in outStockLockInfos)
{
@@ -234,7 +290,7 @@
{
Lotno = item.BatchNo,
Qty = item.AssignQuantity.ObjToInt().ToString(),
- Location = item.LocationCode
+ Location = warehouse.WarehouseCode
};
//鑾峰彇鍑哄簱鍗曟槑缁�
Dt_OutboundOrderDetail outboundOrderDetail = outboundOrder.Details.FirstOrDefault(x => x.Id == item.OrderDetailId);
@@ -245,7 +301,10 @@
Qty = pickItemModel.Qty,
Dataitem = new List<ERPPickItemModel> { pickItemModel }
};
- item.Status= OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+ if (item.OrderQuantity == item.AssignQuantity)
+ {
+ item.Status = OutLockStockStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+ }
eRPPickModels.Add(pickModel);
_OutStockLockInfos.Add(item);
}
@@ -263,29 +322,22 @@
Deptno = outboundOrder.DepartmentCode,
Deptname = outboundOrder.DepartmentName,
Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- Createuser = outboundOrder.Creater,
+ Createuser = outStockLockInfos.FirstOrDefault().Creater,
Issitem = new List<ERPIssueItemModel>() { issueItemModel },
};
}
-
- string response = _invokeERPService.InvokeOutStandardsApi(issueModel);
- ErpRequestContent requestContent = response.DeserializeObject<ErpRequestContent>();
- if (requestContent.res == 1)
+
+ if (stockInfos.Count > 0)
{
- if (stockInfos.Count>0)
- {
- _stockInfoRepository.UpdateData(stockInfos);
- }
- else
- {
- _outStockLockInfoService.Repository.UpdateData(_OutStockLockInfos);
- }
- return WebResponseContent.Instance.OK(requestContent.Data);
+ _stockInfoRepository.UpdateData(stockInfos);
}
else
{
- return WebResponseContent.Instance.Error(requestContent.Data);
+ _outStockLockInfoService.Repository.UpdateData(_OutStockLockInfos);
}
+ //鍑哄簱瀹屾垚涓婃姤ERP 娴嬭瘯娉ㄩ噴
+ _invokeERPService.InvokeOutStandardsApi(issueModel);
+ return WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
@@ -304,7 +356,7 @@
{
//鑾峰彇鍑哄簱鍗曞簱瀛�
List<Dt_StockInfo> stockInfos = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.WarehouseId == warehouse.WarehouseId).Includes(x => x.Details).ToList();
- if (stockInfos.Count<=0)
+ if (stockInfos.Count <= 0)
{
return WebResponseContent.Instance.Error($"搴撳瓨涓嶈冻");
}
--
Gitblit v1.9.3