From 89051aef8a2c1a85d457914cf6317fe70e0e321c Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期日, 29 十二月 2024 04:33:10 +0800
Subject: [PATCH] 1
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 82 ++++++++++++++++++++++++++++++++++------
1 files changed, 69 insertions(+), 13 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 35f3322..f5ec2dd 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -27,6 +27,7 @@
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+using WIDESEAWCS_Common.APIEnum;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseServices;
@@ -38,6 +39,7 @@
using WIDESEAWCS_ITaskInfoRepository;
using WIDESEAWCS_ITaskInfoService;
using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_QuartzJob.Service;
@@ -54,6 +56,7 @@
private readonly ITaskExecuteDetailRepository _taskExecuteDetailRepository;
private readonly IStationMangerRepository _stationMangerRepository;
private readonly IRouterRepository _routerRepository;
+ private List<Dt_ApiInfo> apiInfos;
private Dictionary<string, OrderByType> _taskOrderBy = new()
{
@@ -65,9 +68,9 @@
public Dictionary<string, OrderByType> TaskOrderBy { get { return _taskOrderBy; } set { _taskOrderBy = value; } }
- public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList();
+ public List<int> TaskInboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList();
- public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 500 && x < 900).ToList();
+ public List<int> TaskOutboundTypes => typeof(TaskTypeEnum).GetEnumIndexList().Where(x => x >= 100 && x < 500).ToList();
public TaskService(ITaskRepository BaseDal, IMapper mapper, ICacheService cacheService, IRouterService routerService, ITaskExecuteDetailService taskExecuteDetailService, ITaskExecuteDetailRepository taskExecuteDetailRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository) : base(BaseDal)
{
@@ -85,6 +88,21 @@
Warehouses = JsonConvert.DeserializeObject<List<Dt_Warehouse>>(cacheStr);
}
+
+ string? apiInfoStr = _cacheService.Get("apiInfos");
+ if (!string.IsNullOrEmpty(apiInfoStr))
+ {
+ List<Dt_ApiInfo>? infos = JsonConvert.DeserializeObject<List<Dt_ApiInfo>>(apiInfoStr);
+ if (infos == null || infos.Count == 0)
+ {
+ apiInfos = new List<Dt_ApiInfo>();
+ }
+ else
+ {
+ apiInfos = infos;
+ }
+ }
+
}
public WebResponseContent TaskCompleted(int taskNum)
@@ -94,10 +112,18 @@
Dt_Task task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
if (task != null)
{
-
+ BaseDal.DeleteAndMoveIntoHty(task, App.User == null ? OperateTypeEnum.鑷姩瀹屾垚 : OperateTypeEnum.浜哄伐瀹屾垚);
}
-
- return WebResponseContent.Instance.OK();
+ string? url = apiInfos.FirstOrDefault(x => x.ApiCode == APIEnum.FeedBackWMSTaskCompleted.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(url))
+ {
+ _taskExecuteDetailService.AddTaskExecuteDetail(taskNum, $"鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ UpdateTaskExceptionMessage(taskNum, $"鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ return WebResponseContent.Instance.Error($"{taskNum},鏈壘鍒癢MS浠诲姟瀹屾垚鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ }
+ string responseStr = HttpHelper.Get(url + "?taskNum=" + taskNum);
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(responseStr) ?? WebResponseContent.Instance.Error($"{taskNum},鏈帴鏀跺埌浠诲姟瀹屾垚杩斿洖鍊�");
+ return content;
}
catch (Exception ex)
{
@@ -141,7 +167,7 @@
return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃俊鎭�");
}
- List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (stationManger.StationDeviceCode == x.StartPosi || stationManger.StackerCraneCode == x.StartPosi));
+ List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && (stationManger.StationCode == x.StartPosi || stationManger.StackerCraneCode == x.StartPosi));
if (routers.FirstOrDefault() == null)
{
return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
@@ -150,18 +176,48 @@
if (routers.Count == 1)
{
task.NextAddress = router?.NextPosi ?? "";
+ task.DeviceCode = stationManger.StationDeviceCode;
+ }
+ else
+ {
+ task.NextAddress = "";
+ task.DeviceCode = "";
}
}
else
{
- List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
- if (routers.FirstOrDefault() == null)
+ if (item.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
- }
- router = routers.FirstOrDefault();
+ List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.NextPosi);
+ if (routers.FirstOrDefault() == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+ }
+ router = routers.FirstOrDefault();
- task.NextAddress = router?.NextPosi ?? "";
+ task.NextAddress = router?.StartPosi ?? "";
+ task.DeviceCode = item.RoadWay;
+ task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
+ }
+ else
+ {
+ List<Dt_Router> routers = _routerRepository.QueryData(x => x.InOutType == item.TaskType && item.AGVArea == x.StartPosi);
+ if (routers.FirstOrDefault() == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒拌矾鐢遍厤缃俊鎭�");
+ }
+ router = routers.FirstOrDefault();
+ string stationCode = router?.NextPosi ?? "";
+ Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == stationCode);
+ if (stationManger == null)
+ {
+ return WebResponseContent.Instance.Error($"鏈壘鍒扮珯鍙伴厤缃俊鎭�");
+ }
+
+ task.NextAddress = stationManger?.AGVStationCode ?? "";
+ task.DeviceCode = "AGV";
+ task.TaskState = TaskStatusEnum.AGV_Execute.ObjToInt();
+ }
}
tasks.Add(task);
@@ -254,7 +310,7 @@
public Dt_Task QueryStackerCraneTask(string deviceNo, string currentAddress = "")
{
if (string.IsNullOrEmpty(currentAddress))
- return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.TaskState == (int)TaskStatusEnum.New, TaskOrderBy);
+ return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy);
else
return BaseDal.QueryFirst(x => x.DeviceCode == deviceNo && x.CurrentAddress == currentAddress && x.TaskState == (int)TaskStatusEnum.SC_Execute, TaskOrderBy);
}
--
Gitblit v1.9.3