From 490f37fa4eb02aa02919fed7cdc885affb56673d Mon Sep 17 00:00:00 2001 From: 18209 Date: Tue, 19 May 2026 14:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=BD=93=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=9C=80=E5=A4=9A=E4=B8=8D=E8=B6=85=E8=BF=87?= =?UTF-8?q?20=E4=B8=AA=E5=85=83=E7=B4=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- consumers/consumerESDeepExcavation.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/consumers/consumerESDeepExcavation.go b/consumers/consumerESDeepExcavation.go index 52a69d3..380e8d9 100644 --- a/consumers/consumerESDeepExcavation.go +++ b/consumers/consumerESDeepExcavation.go @@ -109,11 +109,13 @@ func (c *consumerESDeepExcavation) Work() { } if len(dataList) > 0 { - err := c.sendData(dataList) - if err != nil { - log.Printf("发送数据失败: %v", err) - } else { - log.Printf("成功发送 %d 条数据", len(dataList)) + for i, data := range dataList { + err := c.sendData(data) + if err != nil { + log.Printf("发送第 %d 条数据失败: %v", i+1, err) + } else { + log.Printf("成功发送第 %d 条数据", i+1) + } } } @@ -298,7 +300,7 @@ func (c *consumerESDeepExcavation) transformFactor31(theme models.EsTheme) *Deep } } -func (c *consumerESDeepExcavation) sendData(dataList []DeepExcavationData) error { +func (c *consumerESDeepExcavation) sendData(data DeepExcavationData) error { // 生成签名 sign := generateSign(c.Info.Secret, c.Info.Appid, c.Info.ProjectId) @@ -306,8 +308,8 @@ func (c *consumerESDeepExcavation) sendData(dataList []DeepExcavationData) error fullURL := fmt.Sprintf("%s?appid=%s&projectId=%s&sign=%s", c.Info.URL, c.Info.Appid, c.Info.ProjectId, sign) - // 序列化数据 - bodyBytes, err := json.Marshal(dataList) + // 序列化数据(每个请求只发送一个数据,包装成数组) + bodyBytes, err := json.Marshal([]DeepExcavationData{data}) if err != nil { return fmt.Errorf("序列化数据失败: %v", err) }