1
yangpeixing
2026-04-01 73569b329e4ed2293a63e5a739d5fb0314fc4fd8
WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -502,28 +502,20 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                // 获取LED服务地址配置
                string ledApiAddress = AppSettings.Get("LEDApiAddress");
                if (string.IsNullOrEmpty(ledApiAddress))
                {
                    return WebResponseContent.Instance.Error("未找到LED服务地址");
                }
                // 解析IP地址(处理可能包含的http://前缀)
                string ipAddress = ledApiAddress;
                int port = 8888; // 默认端口
                // 拼接推送格式
                string sendData = $"{stationCode}|{palletCode}|{taskType}";
                // TCP连接WinForm
                using (TcpClient tcpClient = new TcpClient())
                {
                    // 设置连接超时
                    tcpClient.ReceiveTimeout = 5000;
                    tcpClient.SendTimeout = 5000;
                    // 连接TCP服务
                    tcpClient.Connect(ipAddress, port);
                    NetworkStream stream = tcpClient.GetStream();
@@ -1027,5 +1019,30 @@
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        /// <summary>
        /// 任务手动完成
        /// </summary>
        /// <param name="taskNum"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<WebResponseContent> ManualTaskCompleted(int taskNum)
        {
            try
            {
                string url = "http://localhost:9290";
                if (string.IsNullOrEmpty(url))
                {
                    return await Task.FromResult(WebResponseContent.Instance.Error($"未找到WCSApi地址,请检查配置文件"));
                }
                string response = HttpHelper.Post($"{url}/api/Task/TaskCompleted?taskNum=" + taskNum,taskNum.ToString());
                return await Task.FromResult(JsonConvert.DeserializeObject<WebResponseContent>(response) ?? WebResponseContent.Instance.Error("返回错误"));
            }
            catch (Exception ex)
            {
                return await Task.FromResult(WebResponseContent.Instance.Error(ex.Message));
            }
        }
    }
}