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 | 440 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 259 insertions(+), 181 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 476fc92..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"
@@ -22,6 +22,9 @@
using WIDESEA_DTO.ERP;
using WIDESEA_Common.MaterielEnum;
using WIDESEA_Common.WareHouseEnum;
+using WIDESEA_DTO.MES;
+using WIDESEA_DTO.Outbound;
+using Microsoft.IdentityModel.Tokens;
namespace WIDESEA_TaskInfoService
{
@@ -79,6 +82,40 @@
return content;
}
/// <summary>
+ /// 鍚慦MS鐢宠鍑哄簱AGV缁堢偣
+ /// </summary>
+ /// <param name="taskNum">浠诲姟鍙�</param>
+ /// <returns></returns>
+ public WebResponseContent AssignOutTargetAddress(int taskNum)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
+ if (task == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌鍏ュ簱浠诲姟");
+ }
+ if (_basicRepository.AGVStationInfoRepository.QueryFirst(x => x.AGVStationCode == task.TargetAddress) != null)
+ {
+ return WebResponseContent.Instance.OK(data: task.TargetAddress);
+ }
+ 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();
+ _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfo);
+ content.OK("鎴愬姛",data: aGVStationInfo.AGVStationCode);
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
+ /// <summary>
/// 鍑哄簱浠诲姟瀹屾垚
/// </summary>
public WebResponseContent OutboundTaskCompleted(Dt_Task task)
@@ -125,8 +162,19 @@
{
task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
_unitOfWorkManage.BeginTran();
- stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
- _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ //澶勭悊搴撳瓨鏁版嵁
+ if (task.TaskType == TaskTypeEnum.OldYLOutbound.ObjToInt())
+ {
+ stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
+ stockInfo.WarehouseId = WarehouseEnum.LLDOldCache.ObjToInt();
+ stockInfo.LocationCode = "";
+ _stockRepository.StockInfoRepository.UpdateData(stockInfo);
+ }
+ else
+ {
+ stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt();
+ _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
+ }
_basicService.LocationInfoService.UpdateLocationStatus(locationInfoStart, stockInfo.PalletType, LocationStatusEnum.Free, stockInfo.WarehouseId);
BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.浜哄伐瀹屾垚 : WIDESEA_Core.Enums.OperateTypeEnum.鑷姩瀹屾垚);
_unitOfWorkManage.CommitTran();
@@ -176,6 +224,7 @@
PalletType = stockInfo.PalletType,
WarehouseId = stockInfo.WarehouseId,
MaterielCode = stockInfo.MaterielCode,
+ RfidCode = stockInfo.RfidCode,
Quantity = stockInfo.StockLength,
};
if (stockInfo.MaterielWide>0)
@@ -203,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,
@@ -217,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);
@@ -234,8 +284,19 @@
WebResponseContent content = new WebResponseContent();
try
{
- List<Dt_AGVStationInfo> aGVStationInfos = _agvStationInfoRepository.QueryData(x=>x.StationArea == targetId && x.IsOccupied==WhetherEnum.False.ObjToInt());
- if (aGVStationInfos.Count< Count)
+ 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.涓�妤兼湀鍙扮爜澶�));
+ if (_TasksOut.Count>0)
+ {
+ useCount -= _TasksOut.Count;
+ }
+ }
+ if (useCount < Count)
{
return content.Error($"鍙敤缂撳瓨鏁颁笉瓒�");
}
@@ -244,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
{
@@ -252,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)
@@ -274,9 +335,16 @@
nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�) => TaskTypeEnum.OutProduct,
nameof(AGVStationAreaEnum.涓�妤兼棤绾虹粐甯�) => TaskTypeEnum.OutWFB,
nameof(AGVStationAreaEnum.涓�妤兼棤绾烘穻鑶�) => TaskTypeEnum.OutWFBLM,
+ nameof(AGVStationAreaEnum.涓�妤肩焊寮犳穻鑶�) => TaskTypeEnum.OutPaperLM,
+ nameof(AGVStationAreaEnum.涓�妤煎垎鍒�) => TaskTypeEnum.OutFenQie,
+ nameof(AGVStationAreaEnum.涓�妤兼ā鍒�) => TaskTypeEnum.OutMoQie,
+ nameof(AGVStationAreaEnum.涓�妤煎啿鍒�) => TaskTypeEnum.OutChongQie,
+ nameof(AGVStationAreaEnum.浜屾ゼ绾歌) or
+ nameof(AGVStationAreaEnum.浜屾ゼ鏃犵汉甯冭) or
+ nameof(AGVStationAreaEnum.浜屾ゼ绾告澂) => TaskTypeEnum.OutCarton,
_ => throw new Exception("鏈壘鍒板搴斾换鍔�")
};
- if (materialCode == "1")
+ if (materialCode == "1" && typeEnum!= TaskTypeEnum.OutCarton)
{
typeEnum = TaskTypeEnum.OutEmpty;
}
@@ -285,16 +353,27 @@
{
return content.Error($"鐢熸垚浠诲姟澶辫触");
}
- for (int i = 0; i < tasks.Count; i++)
+ //鏈堝彴浠诲姟涓嶇洿鎺ュ垎閰嶇粓鐐�
+ if (targetId != nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�))
{
- aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt();
- tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode;
+ for (int i = 0; i < tasks.Count; i++)
+ {
+ aGVStationInfos[i].IsOccupied = WhetherEnum.True.ObjToInt();
+ tasks[i].TargetAddress = aGVStationInfos[i].AGVStationCode;
+ }
+ }
+ else
+ {
+ for (int i = 0; i < tasks.Count; i++)
+ {
+ tasks[i].TargetAddress = nameof(AGVStationAreaEnum.涓�妤兼湀鍙扮爜澶�);
+ }
}
//鍒ゆ柇鏄惁鏈夊嚭搴撳崟淇℃伅
_unitOfWorkManage.BeginTran();
//鏇存柊搴撳瓨鐘舵��
_stockRepository.ProStockInfoRepository.UpdateData(stockInfos);
- _agvStationInfoRepository.UpdateData(aGVStationInfos);
+ _basicRepository.AGVStationInfoRepository.UpdateData(aGVStationInfos);
//鏇存柊璐т綅鐘舵��
_basicRepository.LocationInfoRepository.UpdateLocationStatus(AssignLocations, LocationStatusEnum.Lock);
//鍔犲叆璐т綅鍙樺姩璁板綍
@@ -319,19 +398,22 @@
/// <param name="materielWide">鐗╂枡骞呭</param>
/// <param name="Count">鍗锋暟</param>
/// <returns></returns>
- public WebResponseContent RequestYLWMSTaskOut(string materielCode, int materielWide, int Count, string address = "")
+ public WebResponseContent RequestYLWMSTaskOut(YLWMSTaskOutDTO yLWMSTaskOutDTO)
{
WebResponseContent content = new WebResponseContent();
try
{
-
+ if (yLWMSTaskOutDTO==null)
+ {
+ return content.Error("璇峰~鍏ュ嚭搴撲俊鎭�");
+ }
//鑾峰彇璐т綅
List<Dt_LocationInfo> locationInfos = _basicRepository.LocationInfoRepository.QueryData(x => x.WarehouseId == WarehouseEnum.LLDYL.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyOut.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt());
//鑾峰彇瀵瑰簲搴撳瓨
- List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x=> locationInfos.Select(x=>x.LocationCode).Contains(x.LocationCode) && x.MaterielCode==materielCode && x.MaterielWide== materielWide && x.StockStatus==StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt()).OrderBy(x=>x.CreateDate).Take(Count).ToList();
- if (stockInfos.Count< Count)
+ List<Dt_StockInfo> stockInfos = _stockRepository.StockInfoRepository.QueryData(x => locationInfos.Select(x => x.LocationCode).Contains(x.LocationCode) && x.MaterielCode == yLWMSTaskOutDTO.MaterialCode && x.MaterielWide == yLWMSTaskOutDTO.Wide && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() && x.MaterielInvOrgId == MaterielInvOrgEnum.鏂板巶.ObjToInt()).OrderBy(x => x.CreateDate).Take(yLWMSTaskOutDTO.Count).ToList();
+ if (stockInfos.Count< yLWMSTaskOutDTO.Count)
{
- return content.Error($"搴撳瓨{materielCode}鏁伴噺涓嶈冻");
+ return content.Error($"搴撳瓨{yLWMSTaskOutDTO.MaterialCode}鏁伴噺涓嶈冻");
}
List<Dt_LocationInfo> AssignLocations =new List<Dt_LocationInfo>();
foreach (var item in stockInfos)
@@ -343,27 +425,21 @@
item.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
}
}
- //鍖哄垎浠诲姟
- TaskTypeEnum taskTypeEnum = new();
- if (stockInfos.FirstOrDefault()?.MaterielInvOrgId==MaterielInvOrgEnum.鑰佸巶.ObjToInt())
- {
- taskTypeEnum = TaskTypeEnum.OldYLOutbound;
- }
- else
- {
- taskTypeEnum = TaskTypeEnum.PrintYLOutbound;
- }
- List<Dt_Task> tasks = GetTasks(stockInfos, taskTypeEnum);
+ List<Dt_Task> tasks = GetTasks(stockInfos, TaskTypeEnum.PrintYLOutbound);
if (tasks == null || tasks.Count <= 0)
{
return content.Error($"鐢熸垚浠诲姟澶辫触");
}
- if (!string.IsNullOrEmpty(address))
+ if (!string.IsNullOrEmpty(yLWMSTaskOutDTO.Address))
{
tasks.ForEach(x =>
{
- x.TargetAddress= address;
+ x.TargetAddress= yLWMSTaskOutDTO.Address;
});
+ }
+ else
+ {
+ return content.Error("鍦板潃淇℃伅涓嶈兘涓虹┖");
}
//鍒ゆ柇鏄惁鏈夊嚭搴撳崟淇℃伅
_unitOfWorkManage.BeginTran();
@@ -385,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>
@@ -637,12 +563,24 @@
return (tasks, stockInfos, orderDetails, outStockLockInfos, locationInfos);
}
+ /// <summary>
+ /// 澶勭悊鍑哄簱鏁版嵁
+ /// </summary>
+ /// <returns></returns>
public WebResponseContent GenerateOutboundTaskDataUpdate(List<Dt_Task> tasks, List<Dt_StockInfo>? stockInfos = null, List<Dt_OutSGOrderDetail>? outboundOrderDetails = null, List<Dt_OutStockLockInfo>? outStockLockInfos = null, List<Dt_LocationInfo>? locationInfos = null)
{
try
{
_unitOfWorkManage.BeginTran();
+ if (outStockLockInfos != null && outStockLockInfos.Any())
+ {
+ tasks.ForEach(x =>
+ {
+ string orderNos = string.Join(",", outStockLockInfos.Where(x => x.PalletCode == x.PalletCode).Select(x => x.OrderNo).Distinct());
+ x.OrderNo = orderNos;
+ });
+ }
BaseDal.AddData(tasks);
if (stockInfos != null && stockInfos.Count > 0 && outboundOrderDetails != null && outboundOrderDetails.Count > 0 && outStockLockInfos != null && outStockLockInfos.Count > 0 && locationInfos != null && locationInfos.Count > 0)
{
@@ -682,5 +620,145 @@
}
}
+ /// <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"
+ };
+ /// <summary>
+ /// 鎺ユ敹MES棰嗘枡璁″垝
+ /// </summary>
+ /// <returns></returns>
+ public WebResponseContent ReceiveOutBound(List<OutMESOrderDTO> outMESOrderDTOs)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (outMESOrderDTOs == null || outMESOrderDTOs.Count <= 0)
+ {
+ return content.Error("棰嗘枡璁″垝浼犲叆淇℃伅涓虹┖");
+ }
+ outMESOrderDTOs.Select(x => x.OutDetailId);
+ List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData();
+ OutMESOrderDTO? CheckGradeCode = outMESOrderDTOs.FirstOrDefault(x => !GradeCodes.Contains(x.GradeCode));
+ if (CheckGradeCode != null)
+ {
+ return content.Error($"棰嗘枡璁″垝搴撳尯{nameof(OutMESOrderDTO.GradeCode)}:{CheckGradeCode.GradeCode}涓嶅瓨鍦�");
+ }
+ OutMESOrderDTO? CheckOutDetailId = outMESOrderDTOs.FirstOrDefault(x => x.OutDetailId <= 0);
+ if (CheckOutDetailId != null)
+ {
+ return content.Error($"棰嗘枡璁″垝{nameof(OutMESOrderDTO.OutDetailId)}:{CheckOutDetailId.ProductOrderNo}闇�瑕佸ぇ浜�0");
+ }
+ OutMESOrderDTO? CheckReqQuantity = outMESOrderDTOs.FirstOrDefault(x => x.ReqQuantity <= 0);
+ if (CheckReqQuantity != null)
+ {
+ return content.Error($"棰嗘枡璁″垝{nameof(OutMESOrderDTO.ReqQuantity)}:{CheckReqQuantity.ProductOrderNo}闇�瑕佸ぇ浜�0");
+ }
+ //鑾峰彇鎵�鏈夌墿鏂欎俊鎭�
+ 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)
+ {
+ return content.Error($"棰嗘枡璁″垝{nameof(OutMESOrderDTO.OutDetailId)}:{OldoutMESOrder.OutDetailId}淇℃伅宸插瓨鍦�");
+ }
+ List<Dt_OutMESOrder> AddoutMESOrders = outMESOrderDTOs.Select(x => _mapper.Map<Dt_OutMESOrder>(x)).ToList();
+ foreach (var item in AddoutMESOrders)
+ {
+ Dt_MaterielInfo materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MaterialCode);
+ item.WarehouseId = materielInfo.WarehouseId;
+ }
+
+
+ _unitOfWorkManage.BeginTran();
+
+ _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();
+ // });
+
+ // 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 (!contentResponse.Status)
+ // {
+ // _unitOfWorkManage.RollbackTran();
+ // return content.Error(contentResponse.Message);
+ // }
+ //}
+
+ _unitOfWorkManage.CommitTran();
+
+ return content.OK("鎺ユ敹鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3