From 29f20b28392d212c04c0c40a512894f8622cfa53 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 16 四月 2025 09:32:01 +0800
Subject: [PATCH] 合并
---
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs | 183 ++++++++++++++++++---------------------------
1 files changed, 75 insertions(+), 108 deletions(-)
diff --git a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
index b3773a2..306512f 100644
--- a/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
+++ b/CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -2,12 +2,14 @@
using Mapster;
using Newtonsoft.Json;
using System.Diagnostics.CodeAnalysis;
+using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.Helper;
using WIDESEAWCS_DTO.TaskInfo;
using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob.Models;
namespace WIDESEAWCS_TaskInfoService
{
@@ -214,7 +216,6 @@
WebResponseContent content = new WebResponseContent();
try
{
- StaticVariable.isLineRun = false;
// 妫�鏌ュ綋鍓嶆墭鐩樻槸鍚﹀瓨鍦ㄤ换鍔�
if (await HasTask(palletCode))
@@ -222,31 +223,28 @@
return content.Error("褰撳墠鎵樼洏瀛樺湪浠诲姟");
}
- // 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩存帴鍑哄簱浠诲姟
- if (await HasDirectOutboundTask(stationManager))
- {
- return content.Error($"銆恵stationManager.stationChildCode}銆戝凡瀛樺湪鐩存帴鍑哄簱浠诲姟浠诲姟");
- }
+ //// 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩存帴鍑哄簱浠诲姟
+ //if (await HasDirectOutboundTask(stationManager))
+ //{
+ // return content.Error($"銆恵stationManager.stationChildCode}銆戝凡瀛樺湪鐩存帴鍑哄簱浠诲姟浠诲姟");
+ //}
- if (StaticVariable.isStackerRun)
- {
- if (stationManager.stationType == 7)
- {
- var result = await HandleStationType7(palletCode, stationManager);
- if (result != null)
- {
- return result;
- }
- }
- else if (stationManager.stationType == 6)
- {
- var result = await HandleStationType6(palletCode, stationManager);
- if (result != null)
- {
- return result;
- }
- }
- }
+ //if (stationManager.stationType == 7)
+ //{
+ // var result = await HandleStationType7(palletCode, stationManager);
+ // if (result != null)
+ // {
+ // return result;
+ // }
+ //}
+ //else if (stationManager.stationType == 6)
+ //{
+ // var result = await HandleStationType6(palletCode, stationManager);
+ // if (result != null)
+ // {
+ // return result;
+ // }
+ //}
// 鍙戣捣璇锋眰鑾峰彇鍏ュ簱浠诲姟
content = await RequestInTask(palletCode, stationManager);
@@ -264,10 +262,6 @@
catch (Exception ex)
{
return WebResponseContent.Instance.Error(ex.Message);
- }
- finally
- {
- StaticVariable.isLineRun = true;
}
}
@@ -287,38 +281,9 @@
}
// 澶勭悊 stationType 涓� 7 鐨勬儏鍐�
- private async Task<WebResponseContent> HandleStationType7(string palletCode, Dt_StationManager stationManager)
+ private async Task<WebResponseContent> HandleStationType7(Dt_StationManager stationManager)
{
- var station = await _stationManagerRepository.QueryFirstAsync(x => x.stationType == 6 && x.productLine == stationManager.productLine && x.stationArea == stationManager.stationArea);
- var runTask = await BaseDal.QueryFirstAsync(x => x.CurrentAddress == station.stationChildCode && x.TaskState == (int)TaskInStatusEnum.Line_InFinish && x.TaskType == (int)TaskInboundTypeEnum.InTray);
-
- if (runTask != null)
- {
- runTask.TargetAddress = stationManager.stationLocation;
- runTask.NextAddress = stationManager.stationChildCode;
- runTask.Grade = 3;
- runTask.TaskType = (int)TaskOutboundTypeEnum.InToOut;
- runTask.TaskState = (int)TaskOutStatusEnum.OutNew;
-
- var wmsIpAddrss = GetWmsIpAddress(SysConfigKeyConst.SetEmptyOutbyInToOutAsync);
- var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = runTask.PalletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = station.stationChildCode }.ToJsonString());
- var content = JsonConvert.DeserializeObject<WebResponseContent>(result);
-
- if (content.Status)
- {
- await BaseDal.UpdateDataAsync(runTask);
- ConsoleHelper.WriteSuccessLine($"銆恵runTask.PalletCode}鐩存帴鍑哄簱鑷充簩灏併��");
- return content.OK("鎴愬姛");
- }
- else
- {
- ConsoleHelper.WriteErrorLine(content.Message);
- }
- }
- else
- {
- ConsoleHelper.WriteErrorLine($"銆恵station.stationChildCode}銆戞湭鎵惧埌绌烘墭鐩樺叆搴撲换鍔�");
- }
+ var station = await _taskNeedBarcodeRepository.QueryFirstAsync(x => x.toArea == stationManager.stationChildCode && x.productLine == stationManager.productLine);
return null;
}
@@ -376,7 +341,7 @@
private async Task<WebResponseContent> RequestInTask(string palletCode, Dt_StationManager stationManager)
{
var wmsIpAddrss = GetWmsIpAddress(SysConfigKeyConst.RequestInTask);
- var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode }.ToJsonString());
+ var result = await HttpHelper.PostAsync(wmsIpAddrss, new { palletCode = palletCode, EquiCodeMOM = stationManager.stationEquipMOM, Roadways = stationManager.Roadway, area = stationManager.stationArea, Position = stationManager.stationChildCode, ProductionLine = stationManager.productLine}.ToJsonString());
return JsonConvert.DeserializeObject<WebResponseContent>(result);
}
@@ -406,9 +371,9 @@
var task = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
ConsoleHelper.WriteSuccessLine(content.Data.ToString());
-
+
content = ReceiveWMSTask(new List<WMSTaskDTO> { task });
-
+
return content;
}
catch (Exception ex)
@@ -425,6 +390,7 @@
public WebResponseContent ReceiveByWMSTask([NotNull] WMSTaskDTO taskDTO)
{
WebResponseContent content = new WebResponseContent();
+ ConsoleHelper.WriteSuccessLine($"鎺ユ敹鍒颁换鍔�,浠诲姟鏁版嵁锛歿JsonConvert.SerializeObject(taskDTO, Formatting.Indented)}");
try
{
if (BaseDal.QueryFirst(x => x.TaskNum == taskDTO.TaskNum || x.PalletCode == taskDTO.PalletCode) != null)
@@ -436,12 +402,47 @@
if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
{
- var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay);
- task.TaskState = (int)TaskOutStatusEnum.OutNew;
- task.CurrentAddress = taskDTO.RoadWay;
- task.NextAddress = stationinfo.stationChildCode;
- task.SourceAddress = taskDTO.SourceAddress;
- task.TargetAddress = taskDTO.TargetAddress;
+ if (task.TaskType == (int)TaskOutboundTypeEnum.OutTray)
+ {
+ // 鏌ヨ涓嬩竴涓矾鐢�
+ List<Dt_Router> routers = _routerService.QueryNextRoutes(taskDTO.RoadWay, taskDTO.TargetAddress);
+ if (routers.Count > 0)
+ {
+ // 璁剧疆浠诲姟鐘舵�佷负鍑哄簱鏂板缓
+ task.TaskState = (int)TaskOutStatusEnum.OutNew;
+ // 璁剧疆褰撳墠鍦板潃涓烘簮鍦板潃
+ task.CurrentAddress = taskDTO.SourceAddress;
+ // 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
+ task.NextAddress = routers.FirstOrDefault().ChildPosi;
+ }
+ else
+ {
+ // 鏌ヨ浠庢簮鍦板潃鍒扮洰鏍囧湴鍧�鐨勮矾鐢�
+ routers = _routerService.QueryNextRoutes(taskDTO.SourceAddress, taskDTO.TargetAddress);
+ if (routers.Count > 0)
+ {
+ // 璁剧疆浠诲姟鐘舵�佷负鍑哄簱瀹屾垚
+ task.TaskState = (int)TaskOutStatusEnum.SC_OutFinish;
+ // 璁剧疆褰撳墠鍦板潃涓烘簮鍦板潃
+ task.CurrentAddress = taskDTO.SourceAddress;
+ // 璁剧疆涓嬩竴涓湴鍧�涓虹涓�涓瓙浣嶇疆
+ task.NextAddress = routers.FirstOrDefault().ChildPosi;
+ }
+ }
+ }
+ else
+ {
+ var stationinfo = _stationManagerRepository.QueryFirst(x => x.stationLocation == taskDTO.TargetAddress && x.Roadway == taskDTO.RoadWay);
+ task.TaskState = (int)TaskOutStatusEnum.OutNew;
+ task.CurrentAddress = taskDTO.RoadWay;
+ task.NextAddress = stationinfo.stationChildCode;
+ task.SourceAddress = taskDTO.SourceAddress;
+ task.TargetAddress = taskDTO.TargetAddress;
+ //if (taskDTO.TaskType == (int)TaskOutboundTypeEnum.InToOut)
+ //{
+ // task.TaskState = (int)TaskInStatusEnum.Line_InFinish;
+ //}
+ }
}
else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)
{
@@ -621,30 +622,6 @@
var task = BaseDal.QueryFirst(x => x.TaskNum == taskNum);
if (task == null) return WebResponseContent.Instance.Error($"鏈壘鍒拌浠诲姟淇℃伅,浠诲姟鍙�:銆恵taskNum}銆�");
- //if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup && task.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting)
- //{
- // //todo
-
- //}
- //else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup && task.TaskState == (int)TaskInStatusEnum.SC_InExecuting)
- //{
- // //todo 鍚屾鍒癢MS
-
- // BaseDal.DeleteData(task);
-
- //}
- //else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
- //{
- // //todo 璋冪敤WMS绉诲簱瀹屾垚
- //}
- //else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OtherGroup)
- //{
- //}
- //else
- //{
- // throw new Exception($"浠诲姟绫诲瀷閿欒,鏈壘鍒拌浠诲姟绫诲瀷,浠诲姟鍙�:銆恵taskNum}銆�,浠诲姟绫诲瀷:銆恵task.TaskType}銆�");
- //}
-
#region WMS鍚屾浠诲姟瀹屾垚
var keys = new Dictionary<string, object>()
@@ -674,21 +651,7 @@
BaseDal.DeleteData(task);
}
- #region 鏇存柊浠诲姟鐘舵��
-
- //var updateTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.UpdateTask)?.ConfigValue;
- //if (wmsBase == null || updateTask == null)
- //{
- // throw new InvalidOperationException("WMS IP 鏈厤缃�");
- //}
- //wmsIpAddress = wmsBase + updateTask;
-
- //result = HttpHelper.PostAsync(wmsIpAddress, new { TaskNum = task.TaskNum, TaskState = task.TaskState }.ToJsonString()).Result;
- //content = JsonConvert.DeserializeObject<WebResponseContent>(result);
-
- #endregion 鏇存柊浠诲姟鐘舵��
-
- //content = WebResponseContent.Instance.OK();
+ content.OK(data: task);
}
catch (Exception ex)
{
@@ -696,5 +659,9 @@
}
return content;
}
+ //public override WebResponseContent DeleteData(Dt_Task entity)
+ //{
+ // return base.DeleteData(entity);
+ //}
}
}
\ No newline at end of file
--
Gitblit v1.9.3