xueyiming 7 hónapja
szülő
commit
54f818fe2f

+ 2 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/impl/CoreServiceImpl.java

@@ -14,6 +14,7 @@ import com.tzld.piaoquan.longarticle.model.po.PlanAccount;
 import com.tzld.piaoquan.longarticle.model.vo.*;
 import com.tzld.piaoquan.longarticle.service.CoreService;
 import com.tzld.piaoquan.longarticle.utils.DateUtil;
+import com.tzld.piaoquan.longarticle.utils.LarkRobotUtil;
 import com.tzld.piaoquan.longarticle.utils.TimeZoneUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -262,6 +263,7 @@ public class CoreServiceImpl implements CoreService {
         if (planAccount.getRetryCount() >= 3) {
             planAccount.setStatus(3);
             planAccountMapper.updateByPrimaryKeySelective(planAccount);
+            LarkRobotUtil.sendMessage("计划发布失败3次,请查看 账号计划id为" + planAccount.getPlanId());
             return false;
         }
 

+ 40 - 0
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/utils/LarkRobotUtil.java

@@ -0,0 +1,40 @@
+package com.tzld.piaoquan.longarticle.utils;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.binary.Base64;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+@Slf4j
+public class LarkRobotUtil {
+
+
+    private static final String URL = "https://open.feishu.cn/open-apis/bot/v2/hook/93787b70-33d3-42c1-beae-c09310c9b38b";
+
+    private static final HttpPoolClientUtil HTTP_POOL_CLIENT_UTIL_DEFAULT = HttpClientUtil.create(3000, 10000, 20, 100, 3, 3000);
+
+
+    public static void sendMessage(String msg) {
+        sendMessage("text", "长文发布报警:" + msg);
+    }
+
+    public static void sendMessage(String type, String msg) {
+        try {
+            JSONObject param = new JSONObject();
+            param.put("msg_type", type);
+            JSONObject content = new JSONObject();
+            content.put("text", msg);
+            param.put("content", content);
+            HTTP_POOL_CLIENT_UTIL_DEFAULT.post(URL, param.toJSONString());
+        } catch (Exception e) {
+            log.error("Lark sendMessage error", e);
+        }
+    }
+
+
+}