From ec233a6f745c1a0fb8241f7a761282656f4cc9ea Mon Sep 17 00:00:00 2001
From: 刘磊 <1161824510@qq.com>
Date: 星期二, 26 十一月 2024 08:45:36 +0800
Subject: [PATCH] 1
---
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs | 201 ++++++++++++++++++++++
.gitignore | 3
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs | 330 ++++++++++++++++++++++++++++++++++++
3 files changed, 534 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index dc26e52..ada6a8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1516,3 +1516,6 @@
/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/WIDESEA_WMSServer.csproj.user
/椤圭洰璧勬枡/椤圭洰鍥剧焊/鐢佃姱2F鍥剧焊涓庣數姘旂紪鍙峰鐓э紙08椤圭洰锛�/08浜屾ゼ杈撻�佸竷灞�鐐逛綅鍥�1106(4).dwg.lck
/椤圭洰璧勬枡/椤圭洰鍥剧焊/鍖呰2F鍥剧焊涓庣數姘旂紪鍙峰鐓э紙09椤圭洰锛�/09浜屾ゼ鍖呰杈撻�佸竷灞�鐐逛綅鍥�1109.dwg.bak
+*.props
+*.a
+/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/obj/Debug/net6.0/WIDESEAWCS_Server.csproj.BuildWithSkipAnalyzers
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
new file mode 100644
index 0000000..ddf4b01
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/CommonConveyorLine_GWJob.cs
@@ -0,0 +1,330 @@
+锘�#region MyRegion
+#region << 鐗� 鏈� 娉� 閲� >>
+
+/*----------------------------------------------------------------
+ * 鍛藉悕绌洪棿锛歐IDESEAWCS_Tasks.ConveyorLineJob
+ * 鍒涘缓鑰咃細鑳$搴�
+ * 鍒涘缓鏃堕棿锛�2024/8/2 16:13:36
+ * 鐗堟湰锛歏1.0.0
+ * 鎻忚堪锛�
+ *
+ * ----------------------------------------------------------------
+ * 淇敼浜猴細
+ * 淇敼鏃堕棿锛�
+ * 鐗堟湰锛歏1.0.1
+ * 淇敼璇存槑锛�
+ *
+ *----------------------------------------------------------------*/
+
+#endregion << 鐗� 鏈� 娉� 閲� >>
+
+using AutoMapper;
+using HslCommunication;
+using Microsoft.AspNetCore.Server.HttpSys;
+using Newtonsoft.Json;
+using Quartz;
+using SqlSugar;
+using System.Diagnostics.CodeAnalysis;
+using System.Reflection;
+using System.Threading.Tasks;
+using WIDESEAWCS_BasicInfoRepository;
+using WIDESEAWCS_BasicInfoService;
+using WIDESEAWCS_Common;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_IProcessRepository;
+using WIDESEAWCS_ISystemRepository;
+using WIDESEAWCS_ISystemServices;
+using WIDESEAWCS_ITaskInfoRepository;
+using WIDESEAWCS_ITaskInfoService;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
+using WIDESEAWCS_QuartzJob.Service;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
+
+namespace WIDESEAWCS_Tasks
+{
+ [DisallowConcurrentExecution]
+ public partial class CommonConveyorLine_GWJob : JobBase, IJob
+ {
+ public readonly ITaskService _taskService;
+ private readonly ITaskRepository _taskRepository;
+ private readonly ITaskExecuteDetailService _taskExecuteDetailService;
+ private readonly IRouterService _routerService;
+ private readonly IPlatFormRepository _platFormRepository;
+ private readonly ISys_ConfigService _sys_ConfigService;
+ private readonly IMapper _mapper;
+ private readonly IDt_StationManagerRepository _stationManagerRepository;
+
+ public CommonConveyorLine_GWJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IPlatFormRepository platFormRepository, ISys_ConfigService sys_ConfigService, IDt_StationManagerRepository stationManagerRepository)
+ {
+ _taskService = taskService;
+ _taskExecuteDetailService = taskExecuteDetailService;
+ _routerService = routerService;
+ _mapper = mapper;
+ _taskRepository = taskRepository;
+ _platFormRepository = platFormRepository;
+ _sys_ConfigService = sys_ConfigService;
+ _stationManagerRepository = stationManagerRepository;
+ }
+
+ public Task Execute(IJobExecutionContext context)
+ {
+ try
+ {
+ CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)context.JobDetail.JobDataMap.Get("JobParams");
+ if (conveyorLine != null)
+ {
+ #region 绔欏彴鏂瑰紡
+ //List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
+
+ //foreach (var station in stationManagers)
+ //{
+ // ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(station.stationChildCode);
+
+ // DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString());
+ // if (deviceProtocolDetails != null)
+ // {
+ // MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType);
+ // if (method != null)
+ // {
+ // method.Invoke(this, new object[] { conveyorLine, command, station });
+ // }
+ // }
+ //}
+ #endregion
+
+ #region 璺敱鏂瑰紡
+ List<string> childDeviceCodes = _routerService.QueryAllPositions(conveyorLine.DeviceCode);
+ foreach (string childDeviceCode in childDeviceCodes)
+ {
+ ConveyorLineTaskCommand_After command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand_After>(childDeviceCode);
+
+ if (command.ConveyorLineBarcode.Trim().Contains("\0")) command.ConveyorLineBarcode = "";
+
+ DeviceProtocolDetailDTO? deviceProtocolDetails = conveyorLine.DeviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(ConveyorLineTaskCommand_After.InteractiveSignal) && x.ProtocalDetailValue == command.InteractiveSignal.ToString());
+ if (deviceProtocolDetails != null)
+ {
+ MethodInfo? method = GetType().GetMethod(deviceProtocolDetails.ProtocolDetailType);
+ if (method != null)
+ {
+ method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode });
+ }
+ }
+ }
+ #endregion
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.Out.WriteLine(nameof(CommonConveyorLine_AfterJob) + ":" + ex.ToString());
+ }
+ finally
+ {
+ //WriteDebug("CommonConveyorLineJob", "test");
+ //Console.Out.WriteLine(DateTime.Now);
+ }
+ return Task.CompletedTask;
+ }
+
+
+ /// <summary>
+ /// 杈撻�佺嚎璇锋眰鍏ュ簱
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+ public void RequestInbound(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ try
+ {
+ var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
+ //HandleTaskOut(conveyorLine, command, childDeviceCode, task);
+ // && command.ConveyorLineBarcode != "NoRead" && !command.ConveyorLineBarcode.IsNotEmptyOrNull()
+ if (task == null)
+ {
+ HandleNewTask(conveyorLine, command, childDeviceCode);
+
+ }
+ }
+ catch (Exception ex)
+ {
+ Console.Out.WriteLine(ex.ToString());
+ }
+ }
+
+ /// <summary>
+ /// 杈撻�佺嚎鍏ュ簱瀹屾垚
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+ public void ConveyorLineInFinish(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
+ if (task != null && task.TaskState != (int)TaskInStatusEnum.Line_InFinish)
+ {
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+
+ WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
+
+ if(content.Status)
+ {
+ conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+ }
+
+ Console.Out.WriteLine(content.Serialize());
+ }
+ }
+
+ /// <summary>
+ /// 杈撻�佺嚎璇锋眰鍑轰俊鎭�
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+ public void RequestOutbound(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int ProtocalDetailValue)
+ {
+ var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+ if (task != null)
+ {
+ ConveyorLineTaskCommand taskCommand = _mapper.Map<ConveyorLineTaskCommand>(task);
+ taskCommand.InteractiveSignal = command.InteractiveSignal;
+ conveyorLine.SendCommand(taskCommand, childDeviceCode);
+
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+ _taskService.UpdateTaskStatusToNext(task);
+ }
+ }
+ /// <summary>
+ /// 杈撻�佺嚎鍑哄簱瀹屾垚
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ public void ConveyorLineOutFinish(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
+ if (task != null)
+ {
+ WebResponseContent content = new WebResponseContent();
+ ConveyorLineTaskCommand_After taskCommand = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+ taskCommand.InteractiveSignal = command.InteractiveSignal;
+ if (task.PalletCode != command.ConveyorLineBarcode)
+ {
+ var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == task.TargetAddress).Capacity;
+ taskCommand.ConveyorLineTargetAddress = (short)NGAddress;
+ }
+ else
+ {
+ taskCommand.ConveyorLineTargetAddress = 1000;
+ }
+
+ conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+ content = _taskService.UpdateTaskStatusToNext(task);
+ }
+ }
+
+ /// <summary>
+ /// 杈撻�佺嚎浜や簰瀹屾垚
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ /// <param name="ProtocalDetailValue">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+ /// <param name="value">鍊�</param>
+ //public void ConveyorLineSendFinish(CommonConveyorLine conveyorLine, string childDeviceCode, int ProtocalDeValue, bool value)
+ //{
+ // DeviceProDTO? devicePro = conveyorLine.DeviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceChildCode == childDeviceCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+ // string[] x = devicePro.DeviceProAddress.Split('.');
+ // x[x.Length - 1] = (ProtocalDetailValue + 1).ToString();
+ // string DeviceProAddress = string.Join(".", x);
+ // conveyorLine.Communicator.Write(DeviceProAddress, value);
+ //}
+
+ /// <summary>
+ /// 鐩戞祴绌烘墭鐩樺疄鐩樺嚭搴�
+ /// </summary>
+ /// <param name="conveyorLine">杈撻�佺嚎瀹炰緥瀵硅薄</param>
+ /// <param name="command">璇诲彇鐨勮姹備俊鎭�</param>
+ /// <param name="childDeviceCode">瀛愯澶囩紪鍙�</param>
+ /// <param name="index">绾夸綋褰撳墠bool璇诲彇鍋忕Щ鍦板潃</param>
+ public async void EmptyTrayReturn(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int index, Platform platform)
+ {
+ try
+ {
+ TaskOutboundTypeEnum taskOutboundTypeEnum;
+ if (platform.PlatformType.Contains("OutTray"))
+ taskOutboundTypeEnum = TaskOutboundTypeEnum.OutTray;
+ else
+ taskOutboundTypeEnum = TaskOutboundTypeEnum.Outbound;
+ await CheckAndCreateTask(taskOutboundTypeEnum, childDeviceCode, index, platform.Stacker);
+ }
+ catch (Exception)
+ {
+ }
+ }
+
+ /// <summary>
+ /// 妫�鏌ヤ换鍔″苟鍒涘缓鏂颁换鍔�
+ /// </summary>
+ private async Task CheckAndCreateTask(TaskOutboundTypeEnum taskType, string childDeviceCode, int index, string roadWay, List<string> roadways = null)
+ {
+ var tasks = _taskRepository.QueryData(x => x.TaskType == (int)taskType && x.TargetAddress == childDeviceCode);
+ if (tasks.Count < index)
+ {
+ #region 璋冪敤WMS鑾峰彇鍑哄簱浠诲姟
+
+ WMSTaskDTO taskDTO = new WMSTaskDTO();
+
+ // 鑾峰彇WMSip鍦板潃
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var requestTrayOutTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayOutTask)?.ConfigValue;
+ if (wmsBase == null || requestTrayOutTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + requestTrayOutTask;
+
+
+ var result = await HttpHelper.PostAsync(wmsIpAddress, new { position = childDeviceCode, tag = (int)taskType, areaCdoe = roadWay, roadways = roadways }.ToJsonString());
+ //var result = await HttpHelper.PostAsync("http://localhost:5000/api/Task/RequestTrayOutTaskAsync", dynamic.ToJsonString());
+
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+
+ // 妫�鏌ョ姸鎬佸苟杩斿洖
+ if (!content.Status)
+ return;
+
+ taskDTO = JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+
+ #endregion
+
+ CreateAndSendTask(taskDTO);
+ }
+ }
+
+ /// <summary>
+ /// 鍒涘缓浠诲姟
+ /// </summary>
+ public WebResponseContent CreateAndSendTask(WMSTaskDTO taskDTO)
+ {
+ var content = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { taskDTO });
+ if (content.Status)
+ {
+ Console.WriteLine($"{taskDTO.TaskType}鍛煎彨鎴愬姛");
+ }
+ return content;
+ }
+
+ }
+}
+#endregion
\ No newline at end of file
diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
new file mode 100644
index 0000000..e89cfb3
--- /dev/null
+++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob_GW/GWTask/RequestInbound.cs
@@ -0,0 +1,201 @@
+锘縰sing Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEAWCS_Common.TaskEnum;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_DTO.TaskInfo;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob;
+using WIDESEAWCS_Tasks.ConveyorLineJob;
+using HslCommunication;
+using WIDESEAWCS_DTO.WMS;
+using WIDESEAWCS_Common;
+
+namespace WIDESEAWCS_Tasks
+{
+ public partial class CommonConveyorLine_GWJob
+ {
+ /// <summary>
+ /// 澶勭悊鍑哄簱浠诲姟
+ /// </summary>
+ private void HandleTaskOut(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode, int ProtocalDetailValue, Dt_Task taskOut)
+ {
+ if (taskOut == null) return;
+
+ var taskCommand = MapTaskCommand(taskOut, command);
+
+ bool isOutTray = taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray;
+ bool isOutboundAndOutFinish = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.SC_OutFinish;
+ bool isOutboundAndLineOutExecuting = taskOut.TaskType == (int)TaskOutboundTypeEnum.Outbound && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting;
+
+ if (isOutTray || isOutboundAndOutFinish || !isOutboundAndLineOutExecuting)
+ {
+ conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+ _taskService.UpdateTaskStatusToNext(taskOut);
+ }
+ else if (taskOut.TaskType == (int)TaskOutboundTypeEnum.OutTray && taskOut.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting)
+ {
+ CompleteWmsTask(taskOut, command, conveyorLine, childDeviceCode, ProtocalDetailValue);
+ }
+ }
+
+ /// <summary>
+ /// 澶勭悊鏂颁换鍔�
+ /// </summary>
+ private void HandleNewTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.stationPLC == conveyorLine.DeviceCode && x.stationChildCode == childDeviceCode);
+ if ((conveyorLine.DeviceCode == "1003" && childDeviceCode == "1016") || (conveyorLine.DeviceCode == "1005" && childDeviceCode == "1048"))
+ {
+ CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode);
+ }
+ else if (stationManager.stationType == 1)
+ {
+ var task = _taskService.QueryExecutingConveyorLineTask(command.ConveyorLineTaskNum, childDeviceCode);
+ if (task != null)
+ {
+ ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
+ }
+ else
+ {
+ RequestWmsTask(conveyorLine, command, childDeviceCode);
+ }
+
+ }
+ else if ((conveyorLine.DeviceCode == "1001" && childDeviceCode == "1068"))
+ {
+ ConveyorLineOutFinish(conveyorLine, command, childDeviceCode);
+ }
+ }
+
+ /// <summary>
+ /// 鏄犲皠浠诲姟鍛戒护
+ /// </summary>
+ private ConveyorLineTaskCommand_After MapTaskCommand(Dt_Task task, ConveyorLineTaskCommand_After command)
+ {
+ var comm = _mapper.Map<ConveyorLineTaskCommand_After>(task);
+ comm.InteractiveSignal = command.InteractiveSignal;
+ return comm;
+ }
+
+ /// <summary>
+ /// 瀹屾垚WMS浠诲姟
+ /// </summary>
+ private void CompleteWmsTask(Dt_Task taskOut, ConveyorLineTaskCommand_After command, CommonConveyorLine_GW conveyorLine, string childDeviceCode, int ProtocalDetailValue)
+ {
+ if (command.ConveyorLineBarcode == "NoRead")
+ {
+ var NGAddress = _platFormRepository.QueryFirst(x => x.PlatCode == taskOut.TargetAddress).Capacity;
+ taskOut.TargetAddress = NGAddress.ToString();
+ }
+
+ var keys = new Dictionary<string, object>()
+ {
+ {"taskNum", taskOut.TaskNum}
+ };
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var completeTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.CompleteTask)?.ConfigValue;
+ if (wmsBase == null || completeTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddress = wmsBase + completeTask;
+
+ var result = HttpHelper.GetAsync(wmsIpAddress, keys).Result;
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+ if (content.Status)
+ {
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+ _taskService.UpdateTaskStatusToNext(taskOut);
+ }
+ }
+
+ /// <summary>
+ /// 鍒涘缓骞跺彂閫佺┖鎵樼洏浠诲姟
+ /// </summary>
+ public void CreateAndSendEmptyTrayTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ if (command.ConveyorLineBarcode != "NoRead")
+ {
+ var taskDTO = CreateEmptyTrayTaskDto(command.ConveyorLineBarcode, childDeviceCode);
+
+ if (_taskRepository.QueryFirst(x => x.PalletCode == taskDTO.PalletCode) != null)
+ {
+ WriteInfo(conveyorLine.DeviceName, "褰撳墠鎵樼洏瀛樺湪浠诲姟");
+ return;
+ }
+
+ var content = CreateAndSendTask(taskDTO);
+ if (content.Status)
+ {
+ var task = _taskService.QueryConveyorLineTask(conveyorLine.DeviceCode, childDeviceCode);
+ if (task != null)
+ {
+ var taskCommand = MapTaskCommand(task, command);
+ conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, true);
+ _taskService.UpdateTaskStatusToNext(task);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// 鍒涘缓绌烘墭鐩樹换鍔TO
+ /// </summary>
+ private WMSTaskDTO CreateEmptyTrayTaskDto(string barcode, string childDeviceCode)
+ {
+ var request = new RequestTaskDto()
+ {
+ Position = childDeviceCode,
+ PalletCode = barcode,
+ };
+
+ var config = _sys_ConfigService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
+ var wmsBase = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.WMSIP_BASE)?.ConfigValue;
+ var requestTrayInTask = config.FirstOrDefault(x => x.ConfigKey == SysConfigKeyConst.RequestTrayInTask)?.ConfigValue;
+ if (wmsBase == null || requestTrayInTask == null)
+ {
+ throw new InvalidOperationException("WMS IP 鏈厤缃�");
+ }
+ var wmsIpAddrss = wmsBase + requestTrayInTask;
+ var result = HttpHelper.PostAsync(wmsIpAddrss, request.ToJsonString()).Result;
+ if (result == null)
+ return new WMSTaskDTO();
+
+ WebResponseContent content = JsonConvert.DeserializeObject<WebResponseContent>(result);
+ if (!content.Status)
+ return new WMSTaskDTO();
+
+ return JsonConvert.DeserializeObject<WMSTaskDTO>(content.Data.ToString());
+ }
+
+ /// <summary>
+ /// 璇锋眰WMS浠诲姟
+ /// </summary>
+ private async void RequestWmsTask(CommonConveyorLine_GW conveyorLine, ConveyorLineTaskCommand_After command, string childDeviceCode)
+ {
+ var content = await _taskService.RequestWMSTask(command.ConveyorLineBarcode, childDeviceCode);
+ if (content.Status)
+ {
+ var task = _taskService.QueryBarCodeConveyorLineTask(command.ConveyorLineBarcode, childDeviceCode);
+ if (task != null)
+ {
+ conveyorLine.SetValue(ConveyorLineDBName_After.ResponState, 1, childDeviceCode);
+ conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineTargetAddress, task.NextAddress, childDeviceCode);
+ //conveyorLine.SendCommand(taskCommand, childDeviceCode);
+ //ConveyorLineSendFinish(conveyorLine, childDeviceCode, ProtocalDetailValue, true);
+ _taskService.UpdateTaskStatusToNext(task);
+ }
+ }
+ else
+ WriteInfo(conveyorLine.DeviceName, content.Message);
+ }
+ }
+}
--
Gitblit v1.9.3