From d4d524ace9ec2befa6bcd9321384daf05c68d415 Mon Sep 17 00:00:00 2001 From: huangxiaoqiang <1247017146@qq.com> Date: 星期二, 20 五月 2025 15:22:58 +0800 Subject: [PATCH] 1 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_StorageSocketServices/SocketClientService.cs | 117 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 78 insertions(+), 39 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageSocketServices/SocketClientService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageSocketServices/SocketClientService.cs" index 898832d..55d993b 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageSocketServices/SocketClientService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_StorageSocketServices/SocketClientService.cs" @@ -1,35 +1,24 @@ 锘縰sing LogLibrary.Log; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using MimeKit; using Newtonsoft.Json; -using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; -using Org.BouncyCastle.Tls; -using System; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Text; using WIDESEA_Common; using WIDESEA_Core; -using WIDESEA_Core.BaseServices; using WIDESEA_Core.Enums; using WIDESEA_Core.Helper; -using WIDESEA_Core.Middlewares; using WIDESEA_DTO.AGV; using WIDESEA_DTO; -using WIDESEA_IServices; using WIDESEA_IStorageBasicRepository; using WIDESEA_IStorageSocketServices; using WIDESEA_IStorageTaskRepository; -using WIDESEA_IStorageTaskServices; using WIDESEA_Model.Models.AGV; using WIDESEA_Model.Models; using WIDESEAWCS_BasicInfoRepository; -//using static MailKit.Telemetry; using WIDESEAWCS_Model.Models; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; using WIDESEA_Core.BaseRepository; using AutoMapper; using Mapster; @@ -58,8 +47,8 @@ public SocketClientService(/*IDt_TaskService taskService*/IDt_TaskRepository TaskRepository, IDt_StationManagerRepository stationManagerRepository, ILogger<SocketClientService> logger) { //_taskService = taskService; - BaseDal= TaskRepository; - _stationManagerRepository= stationManagerRepository; + BaseDal = TaskRepository; + _stationManagerRepository = stationManagerRepository; _logger = logger; } @@ -153,7 +142,7 @@ } else { - LogFactory.GetLog("Socket鎺ユ敹鏁版嵁").Error(true, "鏃犳晥鎶ユ枃鏍煎紡"); + LogFactory.GetLog("Socket鎺ユ敹鏁版嵁").Error(true, "鏃犳晥鎶ユ枃鏍煎紡"); } } catch @@ -172,7 +161,7 @@ ReceiveCommandResponse(x); break; case "906": - AGVJobStartOrEndResponse(x.Substring(21, 1),x.Substring(22,1)); + AGVJobStartOrEndResponse(x.Substring(21, 1), x.Substring(22, 1)); break; case "902": DataReportResponse(x.Substring(21, 1)); @@ -249,7 +238,7 @@ int sum = 0; try { - for (int i = 0; i < x.Length-2; i++) + for (int i = 0; i < x.Length - 2; i++) { sum += x[i]; } @@ -626,12 +615,24 @@ { //OK case "0": - //UpdateTaskLocation(parseMessage); - InsertWMSTask(parseMessage); - Thread.Sleep(500); - //915 - JobReady("0"); - break; + var location = _locationRepository.QueryFirst(x => x.LocationCode == parseMessage.body.ToLocation); + if (location == null) + { + return; + } + if (location.LocationStatus == (int)LocationEnum.Free) + { + InsertWMSTask(parseMessage); + Thread.Sleep(500); + //915 + JobReady("0"); + return; + } + else + { + //todo璐т綅鏈夎揣閲嶅鍏ュ簱 + return; + } //NG case "1": break; @@ -696,7 +697,7 @@ { JobStartOrEnd("E", task.SourceAddress, task.TargetAddress, "O", task.PalletCode); } - CompleteInboundTask(task); + CompleteInboundTask(task); break; case (int)TaskOutboundTypeEnum.Outbound: //鍑哄簱 @@ -742,15 +743,29 @@ { //OK case "0": - var task = InsertWMSTask(parseMessage); - BaseDal.AddData(task); - InsertAGVTask(task); - Thread.Sleep(500); - //915 - JobReady("0"); - Thread.Sleep(500); - //104 - DeviceReceiveJobResponse("0"); + var location = _locationRepository.QueryFirst(x => x.LocationCode == parseMessage.body.ToLocation); + if (location == null) + { + return; + } + if (location.LocationStatus == (int)LocationEnum.InStock) + { + var task = InsertWMSTask(parseMessage); + BaseDal.AddData(task); + InsertAGVTask(task); + Thread.Sleep(500); + //915 + JobReady("0"); + Thread.Sleep(500); + //104 + DeviceReceiveJobResponse("0"); + } + else + { + //todo璐т綅鏃犺揣绌哄嚭搴� + return; + } + break; default: break; @@ -792,7 +807,7 @@ var taskStation = BaseDal.QueryFirst(x => x.SourceAddress == item.stationName || x.TargetAddress == item.stationName); outStationStatus.Add(new OutStationStatus() { - StationName = item.stationName, + StationName = item.HostName, StationEnable = station.StationEnable == "1" ? "0" : "1", IsDistributionTask = taskStation == null ? "0" : "1", Spare1 = "00" @@ -875,11 +890,13 @@ /// </summary> public void DeviceStatusReportRequest() { + AGVStatusRespone status = GetAGVStatus(); + HOSTAGVStatus AgvStatus = new HOSTAGVStatus() { - RuntimeStatus = "R", - AutoStatus = "1", - Ready = "1" + RuntimeStatus = CapitalizeFirstLetter(status.RuntimeStatus), + AutoStatus = status.AutoStatus == "MaintenanceMode" ? "1" : "0", + Ready = status.AutoStatus == "MaintenanceMode" ? "0" : "1", }; string axis = "000000"; DeviceStatusReportResponse(AgvStatus, axis, axis); @@ -1117,8 +1134,8 @@ { d_task_type = task.TaskType == (int)TaskTypeEnum.Inbound ? 1 : 2, d_floor = 1, - d_involed1 = task.SourceAddress, - d_involed2 = task.TargetAddress, + d_involed1 = InsertHyphenEveryTwoChars(task.SourceAddress), + d_involed2 = InsertHyphenEveryTwoChars(task.TargetAddress), d_involed5 = task.TaskNum, }; @@ -1156,7 +1173,7 @@ public StationStatus GetStationStatus(string stationName) { - string urlnew = url + "/ilns/strl/getStat"; + string urlnew = url + "/ilns/strl/getState"; var result = HttpsClient.PostAsync(urlnew, JsonConvert.DeserializeObject<Dictionary<string, object>>(new { strlName = stationName }.ToJson())).Result; return JsonConvert.DeserializeObject<StationStatus>(result.ToString()); } @@ -1170,7 +1187,29 @@ char firstChar = s[0]; return char.ToUpper(firstChar).ToString(); } + public string InsertHyphenEveryTwoChars(string input) + { + if (string.IsNullOrEmpty(input)) + { + return input; + } + StringBuilder result = new StringBuilder(); + + for (int i = 0; i < input.Length; i += 2) + { + // 娣诲姞涓や釜瀛楃 + result.Append(input.Substring(i, 2)); + + // 濡傛灉涓嶆槸鏈�鍚庝袱涓瓧绗︼紝娣诲姞涓�涓繛瀛楃 + if (i + 2 < input.Length) + { + result.Append('-'); + } + } + + return result.ToString(); + } #region 澶栭儴鎺ュ彛鏂规硶 public WebResponseContent CompleteInboundTask(Dt_Task task) -- Gitblit v1.9.3