From aa201fcecc1ce93da4f660a833f7b1176fc037cb Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 02 十二月 2025 18:04:54 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs | 243 ++++++++++++++++++++++++++----------------------
1 files changed, 130 insertions(+), 113 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
index cd322d0..a6376fd 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Dt_TaskService.cs"
@@ -105,6 +105,13 @@
WebResponseContent content = new WebResponseContent();
try
{
+ if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
+ {
+ var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.Free, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticOutbound);
+ await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1);
+ await _locationRepository.UpdateDataAsync(result1.Item2);
+ }
+
task.TaskState = (int)TaskOutStatusEnum.OutFinish;
var taskHty = task.Adapt<Dt_Task_Hty>();
taskHty.FinishTime = DateTime.Now;
@@ -113,14 +120,15 @@
stock.ModifyDate = DateTime.Now;
stock.LocationCode = task.TargetAddress;
var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.InStock, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticOutbound);
+
DtStockInfo_Hty stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
var orderDetails = _orderOutDetailsRepository.QueryData(x => x.PalletCode == task.PalletCode);
List<Dt_OrderOutDetails_Hty> orderdetailshtys = new List<Dt_OrderOutDetails_Hty>();
orderDetails.ForEach(item =>
- {
- orderdetailshtys.Add(item.Adapt<Dt_OrderOutDetails_Hty>());
- });
+ {
+ orderdetailshtys.Add(item.Adapt<Dt_OrderOutDetails_Hty>());
+ });
await ERPAllocateOut(stock);
@@ -172,8 +180,9 @@
boxingInfo.BoxingInfoDetails = mergedDetails;
}
- await _unitOfWorkManage.UseTranAsync(async () =>
- {
+ //await _unitOfWorkManage.UseTranAsync(async () =>
+ //{
+ _unitOfWorkManage.BeginTran();
await DeleteStockInfoAsync(stock.Id);
_boxingInfoRepository.UpdateDataNav(boxingInfo);
await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
@@ -185,12 +194,14 @@
await DeleteTaskAsync(task.TaskId);
await AddTaskHtyAsync(taskHty);
- });
+ _unitOfWorkManage.CommitTran();
+ //});
content.OK("鍑哄簱瀹屾垚");
}
catch (Exception ex)
{
+ _unitOfWorkManage.RollbackTran();
task.ErrorMessage = ex.Message;
await BaseDal.UpdateDataAsync(task);
return content.Error(ex.Message);
@@ -268,7 +279,15 @@
{
return content.Error("鏈壘鍒扮粍鐩樻暟鎹�");
}
- await ERPAllocate(boxinfo);
+
+ if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
+ {
+ var result1 = UpdateLocationStatus(task.SourceAddress, LocationEnum.Free, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticInbound);
+ await _locationStatusChangeRecordRepository.AddDataAsync(result1.Item1);
+ await _locationRepository.UpdateDataAsync(result1.Item2);
+ }
+
+
var stock = CreateStock(boxinfo, task);
@@ -280,18 +299,22 @@
var result2 = UpdateLocationStatus(task.TargetAddress, LocationEnum.InStock, task.TaskNum.Value, StatusChangeTypeEnum.AutomaticInbound);
- await _unitOfWorkManage.UseTranAsync(async () =>
- {
- await _stockInfoRepository.AddDataNavAsync(stock);
+ //await _unitOfWorkManage.UseTranAsync(async () =>
+ //{
+ _unitOfWorkManage.BeginTran();
+ await _stockInfoRepository.AddDataNavAsync(stock);
await DeleteTaskAsync(task.TaskId);
await AddTaskHtyAsync(taskHty);
await _locationStatusChangeRecordRepository.AddDataAsync(result2.Item1);
await _locationRepository.UpdateDataAsync(result2.Item2);
- });
+ _unitOfWorkManage.CommitTran();
+ //});
+ await ERPAllocate(boxinfo);
content.OK("鍏ュ簱瀹屾垚");
}
catch (Exception ex)
{
+ _unitOfWorkManage.RollbackTran();
task.ErrorMessage = ex.Message;
await BaseDal.UpdateDataAsync(task);
return content.Error(ex.Message);
@@ -339,64 +362,6 @@
};
}
#endregion 鍏ュ簱浠诲姟瀹屾垚
-
- #region AGV鎼繍浠诲姟瀹屾垚
- public async Task<WebResponseContent> CompleteCarryTaskAsync(Dt_Task task,DtStockInfo stockInfo)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- var Sourcelocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.SourceAddress);
- var Targetlocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == task.TargetAddress);
-
- //UpdateLocationStatus(Sourcelocation, LocationEnum.Free);
- //UpdateLocationStatus(Targetlocation, LocationEnum.InStock);
-
- task.TaskState = (int)TaskAGVCarryStatusEnum.CarryFinish;
- var taskHty = task.Adapt<Dt_Task_Hty>();
- taskHty.FinishTime = DateTime.Now;
- taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚;
- taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
- await _unitOfWorkManage.UseTranAsync(async () =>
- {
- await DeleteTaskAsync(task.TaskId);
- await AddTaskHtyAsync(taskHty);
- });
- }
- catch (Exception ex)
- {
- return content.Error(ex.Message);
- }
- return content;
- }
-
- #endregion
-
- #region AGV璺ㄦゼ灞備换鍔″畬鎴�
- public async Task<WebResponseContent> CompleteAcrossFloorTaskAsync(Dt_Task task, DtStockInfo stockInfo)
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryFinish;
- var taskHty = task.Adapt<Dt_Task_Hty>();
- taskHty.FinishTime = DateTime.Now;
- taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚;
- taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
- await _unitOfWorkManage.UseTranAsync(async () =>
- {
- await DeleteTaskAsync(task.TaskId);
- await AddTaskHtyAsync(taskHty);
- });
- }
- catch (Exception ex)
- {
- return content.Error(ex.Message);
- }
- return content;
- }
-
- #endregion
#region 浠诲姟瀹屾垚
@@ -499,14 +464,14 @@
return content.Error("鎵樼洏淇℃伅涓嶅瓨鍦紝璇风‘璁ゆ墭鐩樺凡缁勭洏鎴愬姛");
}
- foreach (var item in boxingInfo.BoxingInfoDetails)
- {
- var ERPStock = SqlSugarHelper.DBERPtext.Queryable<鐢ㄥ弸鍗虫椂搴撳瓨_ST>().Where(x => x.瀛樺偍鍦扮偣鍚嶇О == item.Warehouse && x.鏂欏彿 == item.MaterielCode && x.鍝佸悕 == item.MaterielName && x.搴撳瓨鏁伴噺 >= item.Quantity).ToList().FirstOrDefault();
- if (ERPStock == null)
- {
- return content.Error($"缁勭洏鏁版嵁鏈湪ERP搴撳瓨鏁版嵁涓紝璇蜂汉宸ョ‘璁ゆ暟鎹槸鍚︽纭�");
- }
- }
+ //foreach (var item in boxingInfo.BoxingInfoDetails)
+ //{
+ // var ERPStock = SqlSugarHelper.DBERP.Queryable<鐢ㄥ弸鍗虫椂搴撳瓨_ST>().Where(x => x.瀛樺偍鍦扮偣鍚嶇О == item.Warehouse && x.鏂欏彿 == item.MaterielCode && x.鍝佸悕 == item.MaterielName && x.搴撳瓨鏁伴噺 >= item.Quantity).ToList().FirstOrDefault();
+ // if (ERPStock == null)
+ // {
+ // return content.Error($"缁勭洏鏁版嵁鏈湪ERP搴撳瓨鏁版嵁涓紝璇蜂汉宸ョ‘璁ゆ暟鎹槸鍚︽纭�");
+ // }
+ //}
var StartAddress = await _locationRepository.QueryFirstAsync(x => x.LocationCode == taskDto.Position);
if (StartAddress == null)
@@ -543,6 +508,7 @@
case 4:
case 5:
case 6:
+ case 7:
taskNew = InboundAGVCacheArea(taskDto, StartAddress, area);
break;
default:
@@ -649,7 +615,7 @@
/// </summary>
/// <param name="palletCode"></param>
/// <returns></returns>
- public async Task<WebResponseContent> OutBoundTaskAsync(string palletCode,string remark)
+ public async Task<WebResponseContent> OutBoundTaskAsync(string palletCode,string remark,int doubleTray)
{
WebResponseContent content = new WebResponseContent();
try
@@ -676,7 +642,7 @@
return content.Error("璇ユ墭鐩樺簱瀛樺凡鍦ㄥ嚭搴撶紦瀛樺尯");
}
- Dt_Task taskNew = await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.Outbound });
+ Dt_Task taskNew = await RequestOutboundTaskAsync(new RequestTaskDto { PalletCode = palletCode, AreaId = 2, Position = stcok.LocationCode, TaskType = (int)TaskOutboundTypeEnum.Outbound, DoubleTray= doubleTray });
List<Dt_InventoryRecord> records = new List<Dt_InventoryRecord>();
stcok.StockInfoDetails.ForEach(x =>
{
@@ -709,6 +675,12 @@
}
}
+
+ /// <summary>
+ /// 鍏朵粬鍑哄簱
+ /// </summary>
+ /// <param name="details"></param>
+ /// <returns></returns>
public async Task<WebResponseContent> OtherOutBoundTaskAsync(List<DtStockInfoDetail> details)
{
@@ -915,6 +887,7 @@
case 4:
case 5:
case 6:
+ case 7:
return OutboundAGVCacheArea(taskDto, StartAddress, area);
default:
throw new Exception("璇烽�夋嫨姝g‘鐨勫尯鍩熶俊鎭�");
@@ -963,6 +936,74 @@
}
#endregion 璇锋眰鍑哄簱锛堝疄鐩�&绌虹洏锛�
+
+ #region 璇锋眰绉诲簱浠诲姟
+ public async Task<WebResponseContent> RequestRelocationTaskAsync(string SourceAddress,string TargetAddress)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ var startLocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == SourceAddress);
+ var endLocation = await _locationRepository.QueryFirstAsync(x => x.LocationCode == TargetAddress);
+
+ if (!startLocation.IsNotEmptyOrNull() || !endLocation.IsNotEmptyOrNull())
+ {
+ return content.Error("搴撲綅淇℃伅涓嶅瓨鍦�");
+ }
+ if (endLocation.LocationStatus != (int)LocationEnum.Free)
+ {
+ return content.Error($"缁堢偣搴撲綅{endLocation.LocationCode}鏈浜庣┖闂茬姸鎬侊紝璇蜂汉宸ョ‘璁ゅ簱浣嶇姸鎬�");
+ }
+ if ((startLocation.AreaId == 1 || endLocation.AreaId == 1) && startLocation.AreaId != endLocation.AreaId)
+ {
+ return content.Error("绉诲簱璧风偣搴撲綅涓庣粓鐐瑰簱浣嶄笉鍦ㄥ悓涓�鍖哄煙");
+ }
+ if (startLocation.Floor != endLocation.Floor)
+ {
+ return content.Error("绉诲簱璧风偣搴撲綅涓庣粓鐐瑰簱浣嶄笉鍦ㄥ悓涓�妤煎眰");
+ }
+
+ var stock = await _stockInfoRepository.QueryFirstAsync(x => x.LocationCode == startLocation.LocationCode);
+ var taskNew = new Dt_Task
+ {
+ Grade = startLocation.Floor == "1F" ? 10 : 1,
+ Roadway = endLocation.RoadwayNo,
+ TargetAddress = endLocation.LocationCode,
+ Dispatchertime = DateTime.Now,
+ MaterialNo = "",
+ NextAddress = endLocation.LocationCode,
+ OrderNo = null,
+ PalletCode = stock == null ? "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000) : stock.PalletCode,
+ SourceAddress = startLocation.LocationCode,
+ CurrentAddress = startLocation.LocationCode,
+ TaskState = startLocation.AreaId == 1 ? (int)TaskRelocationStatusEnum.RelocationNew : (int)TaskRelocationStatusEnum.RelocationNewAGV,
+ TaskType = (int)TaskRelocationTypeEnum.Relocation,
+ TaskNum = BaseDal.GetTaskNo().Result,
+ CreateDate = DateTime.Now,
+ TaskId = 0,
+ AGVTaskNum = GenerateUniqueId(),
+ Floor = startLocation.Floor,
+ };
+
+
+ var result = AddTaskAsync(new List<Dt_Task>() { taskNew });
+ await _unitOfWorkManage.UseTranAsync(async () =>
+ {
+ await _locationStatusChangeRecordRepository.AddDataAsync(result.Item2);
+ await _locationRepository.UpdateDataAsync(result.Item1);
+ await BaseDal.AddDataAsync(taskNew);
+ });
+ await SendWCSTask(CreateListTaskDTO(taskNew));
+ return content.OK("鎴愬姛");
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
+ }
+
+
+ #endregion
#region 璇锋眰璺ㄦゼ灞�2浠诲姟
/// <summary>
@@ -1058,6 +1099,7 @@
Remark = StartAddress.AreaId.ToString(),
AGVTaskNum = GenerateUniqueId(),
Floor = StartAddress.Floor,
+ DoubleTray = taskDto.DoubleTray,
};
}
@@ -1204,6 +1246,7 @@
switch (location.AreaId)
{
case 2:
+ case 7:
locationInfos = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark && x.AreaId == location.AreaId);
break;
case 5:
@@ -1258,7 +1301,7 @@
PalletCode = stock == null ? "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000) : stock.PalletCode,
SourceAddress = item.LocationCode,
CurrentAddress = item.LocationCode,
- TaskState = (int)TaskAGVCarryStatusEnum.CarryNew,
+ TaskState = (int)TaskRelocationStatusEnum.RelocationNewAGV,
TaskType = (int)TaskRelocationTypeEnum.Relocation,
TaskNum = BaseDal.GetTaskNo().Result,
CreateDate = DateTime.Now,
@@ -1339,6 +1382,7 @@
case 4:
case 5:
case 6:
+ case 7:
locationInfo = await GetAGVEmptyCacheLocation(areaInfo.AreaID, location);
break;
default:
@@ -1404,37 +1448,6 @@
}
return content;
}
- #endregion
-
- #region 鑾峰彇浠诲姟鏁版嵁
- public async Task<WebResponseContent> GetTaskData()
- {
- WebResponseContent content = new WebResponseContent();
- try
- {
- var task = await BaseDal.QueryDataAsync(x => true);
- var taskData = new List<TaskData>
- {
- new TaskData { Status = "宸插彇娑�", Count = task.Count+50 },
- new TaskData { Status = "宸插畬鎴�", Count = 735 }
- };
-
- // 鏋勫缓绗﹀悎瑕佹眰鐨勬牸寮�
- var result = taskData.Select(item => new
- {
- value = item.Count,
- name = item.Status,
- itemStyle = new { color = item.Status == "宸插彇娑�" ? "#FF0000" : "#00FF00" }
- }).ToList();
-
- return content.OK(data: result);
- }
- catch (Exception ex)
- {
- return content.Error(ex.Message);
- }
- }
-
#endregion
#endregion 澶栭儴鎺ュ彛鏂规硶
@@ -2011,7 +2024,7 @@
}
}
}
- else if (location.AreaId == 2)
+ else if (location.AreaId == 2 || location.AreaId == 7)
{
var locationLateral = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark);
if (locationLateral.Count > 0)
@@ -2049,6 +2062,7 @@
TaskType = task.TaskType,
Floor =task.Floor,
AGVTaskNum = task.AGVTaskNum,
+ DoubleTray = task.DoubleTray,
} };
}
@@ -2068,6 +2082,7 @@
AGVTaskNum = task.AGVTaskNum,
Remark = task.Remark,
Floor = task.Floor,
+ DoubleTray = task.DoubleTray,
};
}
private List<WMSTaskDTO> CreateTaskDTO(List<Dt_Task> task)
@@ -2089,6 +2104,7 @@
AGVTaskNum = item.AGVTaskNum,
Remark = item.Remark,
Floor = item.Floor,
+ DoubleTray = item.DoubleTray,
});
}
@@ -2385,6 +2401,7 @@
switch (AreaId)
{
case 2:
+ case 7:
return await FromShallowToDeep(AreaId, loc);
case 3:
return await AGVLIKU(AreaId);
@@ -2516,7 +2533,7 @@
}
}
- else if (location.AreaId == 2)
+ else if (location.AreaId == 2 || location.AreaId == 7)
{
var locationLateral = _locationRepository.QueryData(x => x.Row == location.Row && x.Column > location.Column && x.Remark == location.Remark);
--
Gitblit v1.9.3