From 5bbb8e206ae8328a5e1233eb43ed4ecb2a02a98e Mon Sep 17 00:00:00 2001
From: yangpeixing <yangpeixing@hnkhzn.com>
Date: 星期二, 25 十一月 2025 11:06:46 +0800
Subject: [PATCH] 1
---
项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 201 ++++++++++++++++++++++++++++---------------------
1 files changed, 115 insertions(+), 86 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index b7f0721..4eceba9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -3,6 +3,7 @@
using LogLibrary.Log;
using Mapster;
using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SqlSugar;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
@@ -123,28 +124,23 @@
task.NextAddress = station.stationChildCode;
- task.Floor = "1F";
+ task.Floor = item.Floor;
task.AGVSign = "";
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
+ var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
- if (station != null)
- {
- var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
+ task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
- task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
+ task.CurrentAddress = item.SourceAddress;
- task.CurrentAddress = item.SourceAddress;
+ task.NextAddress = next.stationChildCode;
- task.NextAddress = next.stationChildCode;
+ task.Floor = item.Floor;
- task.Floor = station.stationFloor;
-
- task.AGVSign = "";
- }
+ task.AGVSign = "";
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
{
@@ -180,22 +176,17 @@
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
+ var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
- if (station != null)
- {
- var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
+ task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
- task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
+ task.CurrentAddress = item.SourceAddress;
- task.CurrentAddress = item.SourceAddress;
+ task.NextAddress = next.stationChildCode;
- task.NextAddress = next.stationChildCode;
+ task.Floor = item.Floor;
- task.Floor = station.stationFloor;
-
- task.AGVSign = "";
- }
+ task.AGVSign = "";
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
{
@@ -218,7 +209,7 @@
{
if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.RelocationGroup)
{
- task.TaskState = (int)TaskRelocationStatusEnum.RelocationNew;
+ //task.TaskState = (int)TaskRelocationStatusEnum.RelocationNew;
task.CurrentAddress = item.SourceAddress;
@@ -230,26 +221,20 @@
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
+ var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
- if (station != null)
- {
- var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
+ task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
- task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
+ task.CurrentAddress = item.SourceAddress;
- task.CurrentAddress = item.SourceAddress;
+ task.NextAddress = next.stationChildCode;
- task.NextAddress = next.stationChildCode;
+ task.Floor = item.Floor;
- task.Floor = station.stationFloor;
-
- task.AGVSign = "";
- }
+ task.AGVSign = "";
}
else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.CarryGroup)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
task.TaskState = (int)TaskAGVCarryStatusEnum.CarryNew;
@@ -257,7 +242,7 @@
task.NextAddress = task.TargetAddress;
- task.Floor = station.stationFloor;
+ task.Floor = item.Floor;
task.AGVSign = "";
}
@@ -267,23 +252,19 @@
{
if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.AcrossFloorGroup)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == item.SourceAddress);
+ var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == item.Floor);
- if (station != null)
- {
- var next = _stationManagerRepository.QueryFirst(x => x.stationType == 5 && x.stationFloor == station.stationFloor);
+ task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
- task.TaskState = (int)TaskAcrossFloorStatusEnum.CarryNew;
+ task.CurrentAddress = item.SourceAddress;
- task.CurrentAddress = item.SourceAddress;
+ task.NextAddress = next.stationChildCode;
- task.NextAddress = next.stationChildCode;
+ task.Floor = item.Floor;
- task.Floor = station.stationFloor;
-
- task.AGVSign = "";
- }
+ task.AGVSign = "";
}
+
}
// 灏嗚浆鎹㈠悗鐨勪换鍔℃坊鍔犲埌浠诲姟鍒楄〃涓�
@@ -487,8 +468,13 @@
}
if (task.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
{
- var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
- SendAgvTask(station.stationRemark, task.TaskNum);
+ string TargetAddress = GetLocation(task.PalletCode);
+ if (TargetAddress == "")
+ {
+ return content.Error($"鏈幏鍙栧嚭搴撶粓鐐硅揣浣嶄俊鎭�");
+ }
+ task.NextAddress = TargetAddress;
+ task.TargetAddress = TargetAddress;
}
}
@@ -501,45 +487,21 @@
{
#region 鍏ュ簱璋冪敤鎺ュ彛鑾峰彇璐т綅鍦板潃
- //var taskDto = new RequestTaskDto()
- //{
- // Position = task.NextAddress,
- // PalletCode = task.PalletCode,
- //};
-
- //// 鑾峰彇WMSip鍦板潃
- //var configz = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
- //var wmsBasez = configz.Where(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE).FirstOrDefault()?.ConfigValue;
- //var requestLocation = configz.Where(x => x.ConfigKey == SysConfigKeyConst.RequestLocation).FirstOrDefault()?.ConfigValue;
- //if (wmsBasez == null || requestLocation == null)
- //{
- // throw new InvalidOperationException("WMS IP 鏈厤缃�");
- //}
- //var wmsIpAddrss = wmsBasez + requestLocation;
-
- //// 鍙戦�佽姹傚苟绛夊緟鍝嶅簲
- //var abc = HttpHelper.PostAsync(wmsIpAddrss, taskDto.ToJsonString()).Result;
- //if (abc == null)
- // return content.Error();
- //// 鍙嶅簭鍒楀寲鍝嶅簲鍐呭
- //content = JsonConvert.DeserializeObject<WebResponseContent>(abc);
-
- //LogFactory.WriteError($"鑾峰彇璐т綅", $"鑾峰彇璐т綅,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙凤細銆恵task.PalletCode}銆戣繑鍥炲弬鏁般�恵JsonConvert.SerializeObject(content)}銆�");
-
- //// 妫�鏌ョ姸鎬佸苟杩斿洖
- //if (!content.Status)
- //{
- // return content;
- //}
-
- //// 鍙嶅簭鍒楀寲浠诲姟鏁版嵁
- //var taskResult = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+ string TargetAddress= GetLocation(task.PalletCode);
+ if (TargetAddress == null)
+ {
+ return content.Error($"鏈幏鍙栧叆搴撶粓鐐硅揣浣嶄俊鎭�");
+ }
task.CurrentAddress = task.NextAddress;
- task.NextAddress = task.TargetAddress;
- task.TargetAddress = task.NextAddress;
+ task.NextAddress = TargetAddress;
+ task.TargetAddress = TargetAddress;
#endregion 鍏ュ簱璋冪敤鎺ュ彛鑾峰彇璐т綅鍦板潃
+ }
+ else if (task.TaskState == (int)TaskInStatusEnum.Line_InExecuting)
+ {
+ UpdateStartLocationInfo(task);
}
else if (task.TaskState == (int)TaskInStatusEnum.SC_InFinish)
{
@@ -565,6 +527,26 @@
task.TaskState = nextStatus;
if (task.TaskState == (int)TaskAGVCarryStatusEnum.AGV_CarryFinish)
+ {
+ CompletedTask(task.TaskNum);
+
+ task.ModifyDate = DateTime.Now;
+ task.Modifier = "System";
+
+ Dt_Task_Hty task_Hty = _mapper.Map<Dt_Task_Hty>(task);
+ task_Hty.TaskId = 0;
+
+ BaseDal.DeleteData(task);
+ _taskHtyRepository.AddData(task_Hty);
+ }
+ }
+ else if (task.TaskState.GetTaskStateGroup() == TaskStateGroup.RelocationGroup)
+ {
+ int nextStatus = task.TaskState.GetNextNotCompletedStatus<TaskRelocationStatusEnum>();
+
+ task.TaskState = nextStatus;
+
+ if (task.TaskState == (int)TaskRelocationStatusEnum.SC_RelocationFinish|| task.TaskState == (int)TaskRelocationStatusEnum.AGV_RelocationFinish)
{
CompletedTask(task.TaskNum);
@@ -649,7 +631,7 @@
taskNew.CurrentAddress = stationManager.stationChildCode;
- taskNew.NextAddress = task.TargetAddress;
+ taskNew.NextAddress = taskDTO.TargetAddress;
taskNew.Floor = stationManager.stationFloor;
@@ -712,6 +694,46 @@
return content;
}
+ public string GetLocation(string palletCode)
+ {
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestLocation)?.ConfigValue;
+ if (wmsBase == null || updateTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + updateTask;
+ var keys = new Dictionary<string, object>()
+ {
+ {"palletCode", palletCode}
+ };
+ var result = HttpHelper.GetAsync(wmsIpAddress, keys).Result;
+ WebResponseContent? content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+ if (content.Status)
+ {
+ return content.Data.ToString();
+ }
+ else
+ {
+ return string.Empty;
+ }
+ }
+
+ public void UpdateStartLocationInfo(Dt_Task task)
+ {
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateStartLocationInfo)?.ConfigValue;
+ if (wmsBase == null || updateTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + updateTask;
+
+ var result = HttpHelper.PostAsync(wmsIpAddress, task.ToJsonString()).Result;
+ }
+
public void CompletedTask(int taskNum)
{
#region WMS鍚屾浠诲姟瀹屾垚
@@ -759,6 +781,8 @@
task.ModifyDate = DateTime.Now;
task.Modifier = "System";
BaseDal.UpdateData(task);
+
+ UpdateStartLocationInfo(task);
content.OK(data: task);
@@ -908,6 +932,11 @@
return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskType == (int)TaskRelocationTypeEnum.Relocation && x.TaskState == (int)TaskRelocationStatusEnum.RelocationNew);
}
+ public Dt_Task QueryExecutingTask(string deviceNo)
+ {
+ return BaseDal.QueryFirst(x => x.Roadway == deviceNo &&( x.TaskState == (int)TaskRelocationStatusEnum.SC_RelocationExecuting || x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting));
+ }
+
private string GetIpAddress(string baseIp, string name)
{
--
Gitblit v1.9.3