From f35b2018109a6e010f89be225137916f2ccfab51 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Fri, 28 Aug 2026 20:00:31 +0800 Subject: [PATCH] =?UTF-8?q?7001=20=E7=AB=AF=E5=8F=A3=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=207071/7072=20=E6=95=85=E9=9A=9C?= =?UTF-8?q?=E8=BD=AC=E7=A7=BB=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Wms.php | 31 ++++++++++++++++++------ application/index/controller/wms/Wms.php | 14 +++++++++-- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/application/api/controller/Wms.php b/application/api/controller/Wms.php index 94461fd..557c4cd 100644 --- a/application/api/controller/Wms.php +++ b/application/api/controller/Wms.php @@ -335,18 +335,26 @@ class Wms extends Api $tmp_code = base64_encode(json_encode(["uuid"=>$uuid])); $gzt->tmp_code = $tmp_code; $gzt->save(); - $url="http://127.0.0.1:7001/tool/backMsg"; + // 端口故障转移:优先 7071/7072 保活端口,7001 作兜底 + $ports = ['7071','7072','7001']; + $options = []; $requsetData = [ 'sid'=>$sid, 'method'=>"binded", 'data'=>$tmp_code ]; - $options = []; $urlEncodedString = http_build_query($requsetData); - $req = Http::sendRequest($url, $urlEncodedString, 'POST', $options); - \think\Log::error("[gzt_bind] binded 请求结果: " . json_encode($req, JSON_UNESCAPED_UNICODE)); + $req = ['ret'=>false]; + foreach ($ports as $port) { + $url = "http://127.0.0.1:{$port}/tool/backMsg"; + $req = Http::sendRequest($url, $urlEncodedString, 'POST', $options); + \think\Log::error("[gzt_bind] binded 请求结果(port={$port}): " . json_encode($req, JSON_UNESCAPED_UNICODE)); + if($req['ret']){ + break; + } + } if(!$req['ret']){ - \think\Log::error("[gzt_bind] binded 发送失败: " . json_encode($req, JSON_UNESCAPED_UNICODE)); + \think\Log::error("[gzt_bind] binded 发送失败,所有端口均不可用"); } if($sid2){ $requsetData = [ @@ -355,10 +363,17 @@ class Wms extends Api 'data'=>"" ]; $urlEncodedString = http_build_query($requsetData); - $req = Http::sendRequest($url, $urlEncodedString, 'POST', $options); - \think\Log::error("[gzt_bind] cheakBind 请求结果: " . json_encode($req, JSON_UNESCAPED_UNICODE)); + $req = ['ret'=>false]; + foreach ($ports as $port) { + $url = "http://127.0.0.1:{$port}/tool/backMsg"; + $req = Http::sendRequest($url, $urlEncodedString, 'POST', $options); + \think\Log::error("[gzt_bind] cheakBind 请求结果(port={$port}): " . json_encode($req, JSON_UNESCAPED_UNICODE)); + if($req['ret']){ + break; + } + } if(!$req['ret']){ - \think\Log::error("[gzt_bind] cheakBind 发送失败: " . json_encode($req, JSON_UNESCAPED_UNICODE)); + \think\Log::error("[gzt_bind] cheakBind 发送失败,所有端口均不可用"); } } $this->success('绑定成功'); diff --git a/application/index/controller/wms/Wms.php b/application/index/controller/wms/Wms.php index 81ab245..0c6e4bf 100644 --- a/application/index/controller/wms/Wms.php +++ b/application/index/controller/wms/Wms.php @@ -3701,8 +3701,18 @@ class Wms extends Frontend 'POSTNUM'=>$r["POSTNUM"], 'method'=>'picks' ]; - $url="http://127.0.0.1:7001/test"; - $res = Http::post($url,$requsetData); + // 端口故障转移:优先 7071/7072 保活端口,7001 作兜底 + $res = ''; + foreach (['7071','7072','7001'] as $port) { + $url = "http://127.0.0.1:{$port}/test"; + $res = Http::post($url,$requsetData); + if ($res !== '') { + break; + } + } + if ($res === '') { + \think\Log::error("[getcar2] picks 通知发送失败,所有端口均不可用: " . json_encode($requsetData, JSON_UNESCAPED_UNICODE)); + } } } if(!$data2){