From 576daf5974df0cd9512252c56f9483613d8da8ce Mon Sep 17 00:00:00 2001 From: lucas Date: Thu, 21 May 2026 10:43:10 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E8=B0=83=E6=95=B4=E6=B0=B4=E6=B3=A5?= =?UTF-8?q?=E4=B8=8A=E6=8A=A5=EF=BC=8C=E6=94=B9=E7=94=A8=E4=BA=91=E4=B8=8A?= =?UTF-8?q?es=20=E4=BB=A3=E7=90=86=E6=9F=A5=E8=AF=A2tools.anxinyun.cn/iot/?= =?UTF-8?q?es-router?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...隅水泥_河北矿山_冀东唐山.json | 4 ++-- ...宝山_广东矿山_大宝山矿业.json | 6 +++--- ...德金隅水泥_河北矿山_东山.json | 2 +- ...隅水泥_河北矿山_四方洞子.json | 2 +- ...金隅水泥_河北矿山_大斜阳.json | 2 +- ...金隅水泥_河北矿山_太平堡.json | 2 +- ...隅水泥_河北矿山_滦州冀东.json | 2 +- consumers/consumerCDJYSN.go | 3 ++- dbOperate/httpHelper.go | 20 +++++++++++++------ 9 files changed, 26 insertions(+), 17 deletions(-) rename configFiles/{弃用备份 => }/config_承德金隅水泥_河北矿山_冀东唐山.json (94%) rename configFiles/{ => 弃用备份}/config_广州大宝山_广东矿山_大宝山矿业.json (85%) diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_冀东唐山.json b/configFiles/config_承德金隅水泥_河北矿山_冀东唐山.json similarity index 94% rename from configFiles/弃用备份/config_承德金隅水泥_河北矿山_冀东唐山.json rename to configFiles/config_承德金隅水泥_河北矿山_冀东唐山.json index 03bf1cc..ec2f07e 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_冀东唐山.json +++ b/configFiles/config_承德金隅水泥_河北矿山_冀东唐山.json @@ -3,9 +3,9 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, - "cronStr": "48 0/1 * * *" + "cronStr": "39 0/1 * * *" }, "out": { "file": { diff --git a/configFiles/config_广州大宝山_广东矿山_大宝山矿业.json b/configFiles/弃用备份/config_广州大宝山_广东矿山_大宝山矿业.json similarity index 85% rename from configFiles/config_广州大宝山_广东矿山_大宝山矿业.json rename to configFiles/弃用备份/config_广州大宝山_广东矿山_大宝山矿业.json index 8f7e046..aa3ade3 100644 --- a/configFiles/config_广州大宝山_广东矿山_大宝山矿业.json +++ b/configFiles/弃用备份/config_广州大宝山_广东矿山_大宝山矿业.json @@ -3,13 +3,13 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, - "cronStr": "38 0/1 * * *" + "cronStr": "31 0/1 * * *" }, "out": { "file": { - "directory": "E:\\01资料\\设备\\2025-12-11 数据上报\\dabaoshan", + "directory": "E:\\dabaoshan", "fileNameExtension": ".txt" } } diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_东山.json b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_东山.json index ce5bd63..fecfc0e 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_东山.json +++ b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_东山.json @@ -3,7 +3,7 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, "cronStr": "19 0/1 * * *" }, diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_四方洞子.json b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_四方洞子.json index 85b988d..61a65ce 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_四方洞子.json +++ b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_四方洞子.json @@ -3,7 +3,7 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, "cronStr": "34 0/1 * * *" }, diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_大斜阳.json b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_大斜阳.json index e5722dd..acc98fa 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_大斜阳.json +++ b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_大斜阳.json @@ -3,7 +3,7 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, "cronStr": "0/1 * * * *" }, diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_太平堡.json b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_太平堡.json index b408ca4..b34199f 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_太平堡.json +++ b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_太平堡.json @@ -3,7 +3,7 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, "cronStr": "18 0/1 * * *" }, diff --git a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_滦州冀东.json b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_滦州冀东.json index 5d86a0a..abdb4fa 100644 --- a/configFiles/弃用备份/config_承德金隅水泥_河北矿山_滦州冀东.json +++ b/configFiles/弃用备份/config_承德金隅水泥_河北矿山_滦州冀东.json @@ -3,7 +3,7 @@ "ioConfig": { "in": { "http": { - "url": "https://esproxy.anxinyun.cn/anxincloud_themes/_search" + "url": "https://tools.anxinyun.cn/iot/es-router/anxincloud_themes/_search" }, "cronStr": "32 0/1 * * *" }, diff --git a/consumers/consumerCDJYSN.go b/consumers/consumerCDJYSN.go index 5a2350a..450aa29 100644 --- a/consumers/consumerCDJYSN.go +++ b/consumers/consumerCDJYSN.go @@ -301,7 +301,8 @@ func (the *consumerCDJYSN) getEsData() { } } `, structureId, start, end) - auth := map[string]string{"Authorization": "Bear 85a441d4-022b-4613-abba-aaa8e2693bf7"} + auth := map[string]string{"Authorization": "Basic YWRtaW46RnJlZXN1bl8xMjM="} + //the.InHttp.HttpClient.SetAuth("admin", "Freesun_123") esAggResult := the.InHttp.HttpClient.HttpGetWithHeader(esQuery, auth) var needPush []byte diff --git a/dbOperate/httpHelper.go b/dbOperate/httpHelper.go index 0b82989..a4243ac 100644 --- a/dbOperate/httpHelper.go +++ b/dbOperate/httpHelper.go @@ -15,8 +15,10 @@ import ( ) type HttpHelper struct { - Url string - Token string + Url string + Token string + userName string + passWord string client http.Client } @@ -24,19 +26,25 @@ type HttpHelper struct { func (the *HttpHelper) Initial() { the.client = http.Client{} the.client.Timeout = time.Minute +} +func (the *HttpHelper) SetAuth(userName, passWord string) { + the.userName = userName + the.passWord = passWord } func (the *HttpHelper) HttpGet(queryBody string) string { - url := the.Url client := the.client - req, err := http.NewRequest("GET", url, strings.NewReader(queryBody)) + req, err := http.NewRequest("GET", the.Url, strings.NewReader(queryBody)) + if the.userName != "" && the.passWord != "" { + req.SetBasicAuth(the.userName, the.passWord) + } req.Header.Set("Content-Type", "application/json") resp, err := client.Do(req) if err != nil { fmt.Println(err) } defer resp.Body.Close() - log.Println("http get 请求,url", url, " <- code=", resp.StatusCode) + log.Println("http get 请求,url", the.Url, " <- code=", resp.StatusCode) body, err := io.ReadAll(resp.Body) return string(body) } @@ -65,8 +73,8 @@ func (the *HttpHelper) HttpGetWithHeader(queryBody string, headerMap map[string] } } }(resp) - log.Println("http get 请求,url", url, " <- code=", resp.StatusCode) body, err := io.ReadAll(resp.Body) + log.Printf("http get 请求,url=%s, -> code=%d,respBody=%s", url, resp.StatusCode, body) return string(body) } func (the *HttpHelper) Publish(messageBytes []byte) (string, error) {