From 452132d37fd32cc7f39ed5f70328cd3de1fd4732 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 16 一月 2025 10:30:11 +0800
Subject: [PATCH] 优化入库完成上报ERP
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 122 +++++++++++++++++++++++++++-------------
1 files changed, 83 insertions(+), 39 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
index 108f974..875c1e5 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs"
@@ -16,6 +16,7 @@
#endregion << 鐗� 鏈� 娉� 閲� >>
using AutoMapper;
+using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Newtonsoft.Json;
using SqlSugar;
using System.Reflection.Emit;
@@ -111,7 +112,35 @@
{
x.AGVArea = agvDescription;
});
- string response = HttpHelper.Post("http://127.0.0.1:9281/api/Task/ReceiveTask", taskDTOs.Serialize());
+ string url = AppSettings.Get("WCS");
+ if (string.IsNullOrEmpty(url))
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒癢CSApi鍦板潃,璇锋鏌ラ厤缃枃浠�");
+ }
+ string response = HttpHelper.Post($"{url}/api/Task/ReceiveTask", taskDTOs.Serialize());
+
+ return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+ }
+ /// <summary>
+ /// 鏀捐揣瀹屾垚
+ /// </summary>
+ /// <param name="code"></param>
+ /// <returns></returns>
+ public WebResponseContent PutFinish(string code)
+ {
+ try
+ {
+ string url = AppSettings.Get("WCS");
+ if (string.IsNullOrEmpty(url))
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒癢CSAApi鍦板潃,璇锋鏌ラ厤缃枃浠�");
+ }
+ string response = HttpHelper.Post($"{url}/api/CTU_AGV/PutFinish?code=" + code);
return JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("杩斿洖閿欒");
}
@@ -147,7 +176,7 @@
return WebResponseContent.Instance.Error($"璇ユ墭鐩樺凡缁戝畾璐т綅");
}
- if (stockInfo.Details.Count == 0)
+ if (stockInfo.Details.Count == 0 && stockInfo.PalletType != PalletTypeEnum.Empty.ObjToInt())
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌鎵樼洏搴撳瓨鏄庣粏淇℃伅");
}
@@ -168,21 +197,35 @@
Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseId == task.WarehouseId);
stockInfo.LocationCode = locationInfo.LocationCode;
+
+ #region 绌虹鍏ュ簱/鎷i�夊洖搴�
+ if (task.TaskType == TaskTypeEnum.InEmpty.ObjToInt() || task.TaskType == TaskTypeEnum.InPick.ObjToInt())
+ {
+ stockInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
+ task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
+ _unitOfWorkManage.BeginTran();
+ BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? OperateTypeEnum.浜哄伐瀹屾垚 : OperateTypeEnum.鑷姩瀹屾垚);
+ _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.InStock, stockInfo.WarehouseId);
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted);
+ _unitOfWorkManage.CommitTran();
+ return WebResponseContent.Instance.OK();
+ }
+ #endregion
+
Dt_InboundOrder? inboundOrder = _inboundRepository.InboundOrderRepository.Db.Queryable<Dt_InboundOrder>().Where(x => x.InboundOrderNo == stockInfo.Details.FirstOrDefault().OrderNo).Includes(x => x.Details).First();
- List<Dt_InboundOrderDetail> inboundOrderDetails = new List<Dt_InboundOrderDetail>();
+ if (inboundOrder == null)
+ {
+ return WebResponseContent.Instance.Error($"瀵瑰簲鍏ュ簱鍗曚笉瀛樺湪");
+ }
+ //鏌ヨ鍘熷畬鎴愮殑鍏ュ簱鏄庣粏鏁伴噺
+ int overCount = inboundOrder.Details.Where(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count;
+ Dt_InboundOrderDetail? inboundOrderDetail = null;
if (stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt())
{
- //鎺ㄩ�佸叆搴撳畬鎴愮粰Erp
- if (inboundOrder == null)
- {
- return WebResponseContent.Instance.Error($"瀵瑰簲鍏ュ簱鍗曚笉瀛樺湪");
- }
-
- List<ERPInboundDetailModel> detailModels = new List<ERPInboundDetailModel>();
-
+ inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == stockInfo.Details.FirstOrDefault()?.InboundOrderRowNo);
foreach (var item in stockInfo.Details)
{
- Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.RowNo == item.InboundOrderRowNo);
if (inboundOrderDetail == null)
{
continue;
@@ -199,34 +242,28 @@
ReceiptCode = inboundOrder.UpperOrderNo,
ReceiptSerNo = item.InboundOrderRowNo.ToString()
};
- inboundOrderDetail.OverInQuantity += detailModel.Quantity.ObjToInt();
+ inboundOrderDetail.OverInQuantity += item.StockQuantity;
if (inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity)
{
inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
+ overCount += 1;
}
- inboundOrderDetails.Add(inboundOrderDetail);
- detailModels.Add(detailModel);
+ else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+ {
+ inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Inbounding.ObjToInt();
+ }
}
-
- //鍏ュ簱鏄庣粏鏂板瀹屾垚鏁伴噺
- int newCount = inboundOrderDetails.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count;
- //鍏ュ簱鏄庣粏鍘熷畬鎴愭暟閲�
- int oldCount = inboundOrder.Details.Select(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()).ToList().Count;
- if (inboundOrder.Details.Count == (newCount + oldCount))
- {
- inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
- }
- if (!_inboundOrderService.FeedbackInboundOrder(stockInfo, inboundOrder, detailModels).Status)//todo 淇敼澶勭悊
- {
- return WebResponseContent.Instance.Error($"鍏ュ簱鍚屾Erp澶辫触");
- }
+ }
+ if (inboundOrder.Details.Count == overCount)
+ {
+ inboundOrder.OrderStatus = InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt();
}
if ((stockInfo.StockStatus == StockStatusEmun.鍏ュ簱纭.ObjToInt() || stockInfo.StockStatus == StockStatusEmun.鎵嬪姩缁勭洏鍏ュ簱纭.ObjToInt()) && warehouse.WarehouseCode == WarehouseEnum.HA64.ToString())
{
foreach (var model in stockInfo.Details)
{
- TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, Life = int.TryParse(model.Remark, out int val) ? val : 1000 });
+ TestSynStock(new TestToolSynInfo() { ToolCode = model.BatchNo, MaterialName = model.MaterielName, Life = int.TryParse(model.Remark, out int val) ? val : 1000 });
}
}
@@ -253,12 +290,14 @@
_stockRepository.StockInfoDetailRepository.UpdateData(stockInfo.Details);
_recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, lastStatus, LocationStatusEnum.InStock, LocationChangeType.InboundCompleted);
_recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, stockInfo.Details.Sum(x => x.StockQuantity), stockInfo.Details.Sum(x => x.StockQuantity), StockChangeTypeEnum.Inbound, taskNum);
- if (inboundOrder != null)
+ _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ if (inboundOrderDetail != null)
{
- _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetails);
- _inboundRepository.InboundOrderRepository.UpdateData(inboundOrder);
+ _inboundRepository.InboundOrderDetailRepository.UpdateData(inboundOrderDetail);
}
_unitOfWorkManage.CommitTran();
+ if (inboundOrder.OrderStatus == InOrderStatusEnum.鍏ュ簱瀹屾垚.ObjToInt())
+ _inboundOrderService.FeedbackInboundOrder(inboundOrder);
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
@@ -299,7 +338,7 @@
List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
List<Dt_MesOutboundOrder> mesOutboundOrders = new List<Dt_MesOutboundOrder>();
- if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString())
+ if ((outStockLockInfos == null || outStockLockInfos.Count == 0) && warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType != TaskTypeEnum.OutEmpty.ObjToInt())
{
return WebResponseContent.Instance.Error($"鏈壘鍒板嚭搴撹鎯呬俊鎭�");
}
@@ -309,7 +348,7 @@
{
if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
{
- Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.Id == item.OrderDetailId);
+ Dt_MesOutboundOrder mesOutboundOrder = _outboundService.MesOutboundOrderService.Repository.QueryFirst(x => x.TaskNo == item.OrderNo);
if (mesOutboundOrder != null)
{
mesOutboundOrder.OverOutQuantity = item.AssignQuantity;
@@ -325,7 +364,7 @@
Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.Id == item.OrderDetailId);
if (outboundOrderDetail != null)
{
- outboundOrderDetail.OverOutQuantity = item.AssignQuantity;
+ outboundOrderDetail.OverOutQuantity += item.AssignQuantity;
if (outboundOrderDetail.OverOutQuantity == outboundOrderDetail.OrderQuantity)
{
outboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
@@ -337,9 +376,10 @@
}
}
+ task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
_unitOfWorkManage.BeginTran();
- if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
+ if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandPickOutbound.ObjToInt() || task.TaskType == TaskTypeEnum.MesHandOutbound.ObjToInt())
{
if (outboundOrderDetails.Count > 0)
{
@@ -349,6 +389,11 @@
stockInfo.LocationCode = "";
stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
_stockService.StockInfoService.Repository.UpdateData(stockInfo);
+ }
+ else if (task.TaskType == TaskTypeEnum.OutEmpty.ObjToInt())
+ {
+ _basicService.LocationInfoService.UpdateLocationStatus(locationInfo, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
+ _stockService.StockInfoService.Repository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
}
else if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
{
@@ -369,12 +414,11 @@
if (warehouse.WarehouseCode != WarehouseEnum.HA64.ToString() && task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
{
- _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().Id, outStockLockInfos);
+ _outboundService.OutboundOrderService.TestOutUpload(outboundOrderDetails.FirstOrDefault().OrderId, outStockLockInfos);
}
if (task.TaskType == TaskTypeEnum.MesOutbound.ObjToInt())
{
- MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, mesOutboundOrders.FirstOrDefault().OrderQuantity);
-
+ MesMaterialLotaAceptModel model = GetMesMaterialLotaAceptModel(stockInfo, stockInfo.Details.FirstOrDefault(), mesOutboundOrders.FirstOrDefault().TaskNo, warehouse.WarehouseCode, stockInfo.Details.Where(x => x.MaterielCode == mesOutboundOrders.FirstOrDefault().MaterialCode).Sum(x => x.StockQuantity));
UploadMesMaterialLotaAcept(model);
}
return WebResponseContent.Instance.OK();
--
Gitblit v1.9.3