From a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 03 十一月 2025 08:23:05 +0800
Subject: [PATCH] ERP接口代码更新,WCS代码优化,出入库分配优化
---
项目代码/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs | 287 +++++++++++++++++----------------------------------------
1 files changed, 85 insertions(+), 202 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 2b514ef..23c0dea 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -96,17 +96,17 @@
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌鍏ュ簱浠诲姟");
}
- if (_agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress) != null)
+ if (_basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress) != null)
{
return WebResponseContent.Instance.OK(data: task.TargetAddress);
}
- Dt_AGVStationInfo? aGVStationInfo = _agvStationInfoRepository.QueryData(x => x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�) && x.IsOccupied == WhetherEnum.False.ObjToInt()).OrderByDescending(x => x.Depth).FirstOrDefault();
+ Dt_AGVStationInfo? aGVStationInfo = _basicRepository.AGVStationInfoRepository.QueryData(x => x.StationArea == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�) && x.IsOccupied == WhetherEnum.False.ObjToInt()).OrderByDescending(x => x.Depth).FirstOrDefault();
if (aGVStationInfo==null)
{
return content.Error("鏈壘鍒板彲鍒嗛厤鐨勫嚭搴撶珯鐐�");
}
aGVStationInfo.IsOccupied = WhetherEnum.True.ObjToInt();
- _agvStationInfoRepository.UpdateData(aGVStationInfo);
+ _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfo);
content.OK("鎴愬姛",data: aGVStationInfo.AGVStationCode);
}
catch (Exception ex)
@@ -162,10 +162,12 @@
{
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
_unitOfWorkManage.BeginTran();
+ //澶勭悊搴撳瓨鏁版嵁
if (task.TaskType == TaskTypeEnum.OldYLOutbound.ObjToInt())
{
stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
stockInfo.WarehouseId = WarehouseEnum.LLDOldCache.ObjToInt();
+ stockInfo.LocationCode = "";
_stockRepository.StockInfoRepository.UpdateData(stockInfo);
}
else
@@ -250,7 +252,7 @@
Dt_LocationInfo locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode);
if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
{
- Dt_Task task = new()
+ Dt_Task task = new ()
{
CurrentAddress = stockInfo.LocationCode,
Grade = 0,
@@ -264,6 +266,7 @@
TaskNum = BaseDal.GetTaskNum(nameof(SequenceEnum.SeqTaskNum)),
PalletType = stockInfo.PalletType,
WarehouseId = stockInfo.WarehouseId,
+ MaterielCode= stockInfo.proStockInfoDetails?.FirstOrDefault().ProductCode ?? "" ,
Quantity = 0,
};
tasks.Add(task);
@@ -281,14 +284,17 @@
WebResponseContent content = new WebResponseContent();
try
{
- List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt());
+ List<Dt_AGVStationInfo> aGVStationInfos = _basicRepository.AGVStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt());
int useCount=aGVStationInfos.Count;
if (targetId == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�))
{
//鑾峰彇鎵�鏈夋湀鍙板嚭搴撲换鍔�
List<Dt_Task> _TasksOut = BaseDal.QueryData(x => x.TaskType == TaskTypeEnum.OutProduct.ObjToInt() && x.TargetAddress == nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�));
- useCount -= _TasksOut.Count;
+ if (_TasksOut.Count>0)
+ {
+ useCount -= _TasksOut.Count;
+ }
}
if (useCount < Count)
{
@@ -299,7 +305,7 @@
List<Dt_ProStockInfo> stockInfos = new List<Dt_ProStockInfo>();
if (materialCode=="1")
{
- stockInfos = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() && x.ProStockAttribute==ProStockAttributeEnum.绌烘墭.ObjToInt()).Take(Count).ToList();
+ stockInfos = BaseDal.Db.Queryable<Dt_ProStockInfo>().Where(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() && x.ProStockAttribute==ProStockAttributeEnum.绌烘墭.ObjToInt()).Take(Count).OrderBy(x => x.CreateDate).ToList();
}
else
{
@@ -307,7 +313,7 @@
.Where(x => x.proStockInfoDetails
.Any(v =>
v.ProductCode == materialCode)
- ).Take(Count).ToList();
+ ).Take(Count).OrderBy(x=>x.CreateDate).ToList();
}
if (stockInfos.Count!=Count)
@@ -333,7 +339,9 @@
nameof(AGVStationAreaEnum.涓�妤煎垎鍒�) => TaskTypeEnum.OutFenQie,
nameof(AGVStationAreaEnum.涓�妤兼ā鍒�) => TaskTypeEnum.OutMoQie,
nameof(AGVStationAreaEnum.涓�妤煎啿鍒�) => TaskTypeEnum.OutChongQie,
- nameof(AGVStationAreaEnum.浜屾ゼ绾歌) => TaskTypeEnum.OutCarton,
+ nameof(AGVStationAreaEnum.浜屾ゼ绾歌) or
+ nameof(AGVStationAreaEnum.浜屾ゼ鏃犵汉甯冭) or
+ nameof(AGVStationAreaEnum.浜屾ゼ绾告澂) => TaskTypeEnum.OutCarton,
_ => throw new Exception("鏈壘鍒板搴斾换鍔�")
};
if (materialCode == "1" && typeEnum!= TaskTypeEnum.OutCarton)
@@ -345,7 +353,7 @@
{
return content.Error($"鐢熸垚浠诲姟澶辫触");
}
- //鎴愬搧浠诲姟涓嶇洿鎺ュ垎閰嶇粓鐐�
+ //鏈堝彴浠诲姟涓嶇洿鎺ュ垎閰嶇粓鐐�
if (targetId != nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�))
{
for (int i = 0; i < tasks.Count; i++)
@@ -365,7 +373,7 @@
_unitOfWorkManage.BeginTran();
//鏇存柊搴撳瓨鐘舵��
_stockRepository.ProStockInfoRepository.UpdateData(stockInfos);
- _agvStationInfoRepository.UpdateData(aGVStationInfos);
+ _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfos);
//鏇存柊璐т綅鐘舵��
_basicRepository.LocationInfoRepository.UpdateLocationStatus(AssignLocations, LocationStatusEnum.Lock);
//鍔犲叆璐т綅鍙樺姩璁板綍
@@ -453,157 +461,7 @@
}
return content;
}
- /// <summary>
- /// 鍒涘缓鍘熺焊鐢熶骇鎺掔▼鍑哄簱浠诲姟
- /// </summary>
- /// <param name="keys"></param>
- /// <returns></returns>
- public WebResponseContent CreateBSTOutboundTasks(int[] keys)
- {
- WebResponseContent content=new WebResponseContent();
- try
- {
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
- List<Dt_OutBSTOrderDetail> outBSTOrderDetails = new List<Dt_OutBSTOrderDetail>();
- List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
- List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
- //鐢熸垚浠诲姟銆佸簱瀛樼瓑淇℃伅
- (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutBSTOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
- if (result.Item2 != null && result.Item2.Count > 0)
- {
- stockInfos.AddRange(result.Item2);
- }
- if (result.Item3 != null && result.Item3.Count > 0)
- {
- outBSTOrderDetails.AddRange(result.Item3);
- }
- if (result.Item4 != null && result.Item4.Count > 0)
- {
- outStockLockInfos.AddRange(result.Item4);
- }
- if (result.Item5 != null && result.Item5.Count > 0)
- {
- locationInfos.AddRange(result.Item5);
- }
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- tasks.AddRange(result.Item1);
- }
- //澶勭悊鍑哄簱鏁版嵁
- return GenerateOutboundTaskDataUpdate(tasks, stockInfos, outBSTOrderDetails, outStockLockInfos, locationInfos);
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- content.Error(ex.Message);
- }
- return content;
- }
-
- /// <summary>
- /// 鍑哄簱浠诲姟鏁版嵁澶勭悊
- /// </summary>
- /// <param name="orderDetailId"></param>
- /// <param name="stockSelectViews"></param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutBSTOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) OutboundTaskDataHandle(int[] keys)
- {
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_OutBSTOrderDetail> outboundOrderDetails = _outBSTOrderDetailRepository.QueryData(x => keys.Contains(x.Id));
-
- if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
- {
- throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
- }
- Dt_OutBSTOrderDetail? outBSTOrderDetail = outboundOrderDetails.FirstOrDefault(x => x.OutBSTOrderDetailStatus != OutOrderStatusEnum.鏈紑濮�.ObjToInt());
- if (outBSTOrderDetail!=null)
- {
- throw new Exception($"鍑哄簱鏄庣粏鐗╂枡{outBSTOrderDetail.MaterialNo},鍑哄簱涓垨宸插畬鎴�");
- }
- List<Dt_StockInfo>? stockInfos = null;
- List<Dt_OutBSTOrderDetail>? orderDetails = null;
- List<Dt_OutStockLockInfo>? outStockLockInfos = null;
- List<Dt_LocationInfo>? locationInfos = null;
-
- //鍒嗛厤搴撳瓨
- (List<Dt_StockInfo>, List<Dt_OutBSTOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outBSTOrderDetailService.AssignStockOutbound(outboundOrderDetails);
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- Dt_OutBSTOrder outBSTOrder = _outBSTOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OutBSTOrderId);
- //鑾峰彇浠诲姟
- tasks = GetTasks(result.Item1, TaskTypeEnum.OldYLOutbound);
- tasks.ForEach(x =>
- {
- x.OrderNo = outBSTOrder.BoardMpsNo;
- });
- result.Item2.ForEach(x =>
- {
- x.OutBSTOrderDetailStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
- });
- result.Item3.ForEach(x =>
- {
- x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
- });
-
- stockInfos = result.Item1;
- orderDetails = result.Item2;
- outStockLockInfos = result.Item3;
- locationInfos = result.Item4;
- }
- else
- {
- throw new Exception("鏃犲簱瀛�");
- }
-
- return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
- }
-
- /// <summary>
- /// 鐢熸垚鍑哄簱浠诲姟鍚庢暟鎹洿鏂板埌鏁版嵁搴�
- /// </summary>
- public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutBSTOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
- {
- try
- {
- _unitOfWorkManage.BeginTran();
-
- BaseDal.AddData(tasks);
- if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
- {
- stockInfos.ForEach(x =>
- {
- x.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
- });
- outboundOrderDetails.ForEach(x =>
- {
- x.OutBSTOrderDetailStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
- });
- Dt_OutBSTOrder outBSTOrder = _outBSTOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OutBSTOrderId);
- if (outBSTOrder.OutBSTOrderStatus == OutOrderStatusEnum.鏈紑濮�.ObjToInt())
- {
- outBSTOrder.OutBSTOrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
- _outBSTOrderRepository.UpdateData(outBSTOrder);
- }
- WebResponseContent content = _outBSTOrderDetailService.LockOutboundStockDataUpdate(stockInfos, outboundOrderDetails, outStockLockInfos, locationInfos, tasks: tasks);
- if (!content.Status)
- {
- _unitOfWorkManage.RollbackTran();
- return content;
- }
- }
- _unitOfWorkManage.CommitTran();
- PushTasksToWCS(tasks);
- return WebResponseContent.Instance.OK();
- }
- catch (Exception ex)
- {
- _unitOfWorkManage.RollbackTran();
- return WebResponseContent.Instance.Error(ex.Message);
- }
-
- }
+
/// <summary>
/// 鍒涘缓鍘熺焊鐢熺鎺掔▼鍑哄簱浠诲姟
/// </summary>
@@ -762,6 +620,24 @@
}
}
+ /// <summary>
+ /// BST棰嗘枡淇℃伅鍚屾
+ /// </summary>
+ /// <param name="bSTPickInfoDTO"></param>
+ /// <returns></returns>
+ public WebResponseContent ReceivePicking(BSTPickInfoDTO bSTPickInfoDTO)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
List<string> GradeCodes = new List<string>
{
"001"
@@ -800,11 +676,18 @@
List<Dt_MaterielInfo> materielInfos = _basicRepository.MaterielInfoRepository.QueryData(x => x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt());
//鑾峰彇鎵�鏈夐鏂欒鍒�
List<Dt_OutMESOrder> outMESOrders = _outboundRepository.OutMESOrderRepository.QueryData();
+ //鑾峰彇鎵�鏈夊姞宸ヤ腑蹇�
+ List<Dt_MakeCenterInfo> makeCenterInfos = _basicRepository.MakeCenterInfoRepository.QueryData();
OutMESOrderDTO? CheckMaterialCode = outMESOrderDTOs.FirstOrDefault(x => !materielInfos.Select(x => x.MaterielCode).Contains(x.MaterialCode));
if (CheckMaterialCode != null)
{
return content.Error($"鐗╂枡缂栫爜{nameof(OutMESOrderDTO.MaterialCode)}:{CheckMaterialCode.MaterialCode}淇℃伅涓嶅瓨鍦�");
+ }
+ OutMESOrderDTO? CheckMakeCenterCode = outMESOrderDTOs.FirstOrDefault(x => !makeCenterInfos.Select(x => x.MakeCode).Contains(x.MakeCode));
+ if (CheckMakeCenterCode!=null)
+ {
+ return content.Error($"鍔犲伐涓績{nameof(OutMESOrderDTO.MakeCode)}:{CheckMakeCenterCode.MakeCode}淇℃伅涓嶅瓨鍦�");
}
Dt_OutMESOrder? OldoutMESOrder = outMESOrders.FirstOrDefault(x => outMESOrderDTOs.Select(x => x.OutDetailId).Contains(x.OutDetailId));
if (OldoutMESOrder != null)
@@ -823,49 +706,49 @@
_outboundRepository.OutMESOrderRepository.AddData(AddoutMESOrders);
- List<Dt_Task> tasks = new List<Dt_Task>();
- List<Dt_StockInfo>? stockInfos = null;
- List<Dt_OutMESOrder>? Orders = null;
- List<Dt_OutStockLockInfo>? outStockLockInfos = null;
- List<Dt_LocationInfo>? locationInfos = null;
- {
- //鍒嗛厤搴撳瓨
- (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(AddoutMESOrders);
- if (result.Item1 != null && result.Item1.Count > 0)
- {
- //鍒涘缓浠诲姟
- tasks = GetTasks(result.Item1, TaskTypeEnum.PrintYLOutbound);
- result.Item2.ForEach(x =>
- {
- OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
- });
- result.Item3.ForEach(x =>
- {
- x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
- });
+ //List<Dt_Task> tasks = new List<Dt_Task>();
+ //List<Dt_StockInfo>? stockInfos = null;
+ //List<Dt_OutMESOrder>? Orders = null;
+ //List<Dt_OutStockLockInfo>? outStockLockInfos = null;
+ //List<Dt_LocationInfo>? locationInfos = null;
+ //{
+ // //鍒嗛厤搴撳瓨
+ // (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutMESOrderService.AssignStockOutbound(AddoutMESOrders);
+ // if (result.Item1 != null && result.Item1.Count > 0)
+ // {
+ // //鍒涘缓浠诲姟
+ // tasks = GetTasks(result.Item1, TaskTypeEnum.PrintYLOutbound);
+ // result.Item2.ForEach(x =>
+ // {
+ // OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
+ // });
+ // result.Item3.ForEach(x =>
+ // {
+ // x.Status = OutLockStockStatusEnum.鍑哄簱涓�.ObjToInt();
+ // });
- stockInfos = result.Item1;
- Orders = result.Item2;
- outStockLockInfos = result.Item3;
- locationInfos = result.Item4;
- }
- else
- {
- throw new Exception("鏃犲簱瀛�");
- }
- }
- int id = BaseDal.AddData(tasks);
+ // stockInfos = result.Item1;
+ // Orders = result.Item2;
+ // outStockLockInfos = result.Item3;
+ // locationInfos = result.Item4;
+ // }
+ // else
+ // {
+ // throw new Exception("鏃犲簱瀛�");
+ // }
+ //}
+ //int id = BaseDal.AddData(tasks);
- if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
- {
- WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
+ //if (stockInfos != null && stockInfos.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
+ //{
+ // WebResponseContent contentResponse = _outboundService.OutMESOrderService.LockOutboundStockDataUpdate(stockInfos, Orders, outStockLockInfos, locationInfos, tasks: tasks);
- if (!contentResponse.Status)
- {
- _unitOfWorkManage.RollbackTran();
- return content.Error(contentResponse.Message);
- }
- }
+ // if (!contentResponse.Status)
+ // {
+ // _unitOfWorkManage.RollbackTran();
+ // return content.Error(contentResponse.Message);
+ // }
+ //}
_unitOfWorkManage.CommitTran();
--
Gitblit v1.9.3