wangyunpeng 3 týždňov pred
rodič
commit
fcd85f3df4

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/impl/ThirdPartyServiceImpl.java

@@ -95,7 +95,7 @@ public class ThirdPartyServiceImpl implements ThirdPartyService {
         GhDetail ghDetail = ghDetails.get(0);
         String channel = ghDetail.getChannel();
         if (channel == null) {
-            LarkRobotUtil.sendMessage("channel不存在,请查看详情 ghId=", param.getGhId());
+            LarkRobotUtil.sendMessage("channel不存在,请查看详情 ghId=" + param.getGhId());
             return CommonResponse.create(404, "ghId异常,请联系管理员检查");
         }
         if (!Objects.equals(account.getChannel(), channel)) {

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageServiceImpl.java

@@ -111,7 +111,7 @@ public class MessageServiceImpl implements MessageService {
             log.info("sendAutoReplyMessage res={}", res);
             Integer code = res.getInteger("errcode");
             msgResult.setErrcode(code);
-            if (code != 0) {
+            if (code != 0 && code != 41051) {
                 msgResult.setErrmsg(res.getString("errmsg"));
                 LarkRobotUtil.sendMessage("sendAutoReplyMessage error" + "res:" + res.toJSONString());
             }

+ 16 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/utils/LarkRobotUtil.java

@@ -21,7 +21,6 @@ public class LarkRobotUtil {
 
     private static final String WE_COM_NOT_PUSH_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/6fa54ed6-12f7-45c1-a33b-020d4f4483ef";
 
-
     private static final String AUTO_REPLY_VIDEO_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/0d80b7dc-47d1-4c27-a7e1-97f2fb6ba26e";
 
     private static final String WE_COM_THIRDPART_URL = "https://open.feishu.cn/open-apis/bot/v2/hook/d5a61df6-7a74-4fa1-808f-e388cfa9b16c";
@@ -50,6 +49,14 @@ public class LarkRobotUtil {
         }
     }
 
+    public static void sendMessage(JSONObject param) {
+        try {
+            HTTP_POOL_CLIENT_UTIL_DEFAULT.post(URL, param.toJSONString());
+        } catch (Exception e) {
+            log.error("Lark sendMessage error", e);
+        }
+    }
+
     public static void sendTipMessage(String msg) {
         sendTipMessage("text", "企微推送结果:" + msg);
     }
@@ -67,6 +74,14 @@ public class LarkRobotUtil {
         }
     }
 
+    public static void sendTipMessage(JSONObject param) {
+        try {
+            HTTP_POOL_CLIENT_UTIL_DEFAULT.post(TIP_URL, param.toJSONString());
+        } catch (Exception e) {
+            log.error("Lark sendMessage error", e);
+        }
+    }
+
 
     public static void sendAutoReplyVideoMessage(JSONObject param) {
         try {

+ 74 - 39
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -3,16 +3,13 @@ package com.tzld.piaoquan.offline.job;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
-import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
 import com.tzld.piaoquan.growth.common.common.constant.TimeConstant;
+import com.tzld.piaoquan.growth.common.common.enums.FieshuTableColumnDataTypeEnum;
 import com.tzld.piaoquan.growth.common.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
 import com.tzld.piaoquan.growth.common.component.ProxyHttpPoolClient;
 import com.tzld.piaoquan.growth.common.dao.mapper.*;
-import com.tzld.piaoquan.growth.common.model.bo.ExternalUser;
-import com.tzld.piaoquan.growth.common.model.bo.MiniprogramRecord;
-import com.tzld.piaoquan.growth.common.model.bo.SendDetail;
-import com.tzld.piaoquan.growth.common.model.bo.XxlJobParam;
+import com.tzld.piaoquan.growth.common.model.bo.*;
 import com.tzld.piaoquan.growth.common.model.po.*;
 import com.tzld.piaoquan.growth.common.service.*;
 import com.tzld.piaoquan.growth.common.utils.DateUtil;
@@ -151,14 +148,12 @@ public class WeComHistoryDataJob {
             sendDetail.setSendCountList(countList);
             sendDetailList.add(sendDetail);
         }
-        StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append(corpName).append("\n");
         long allCount = 0;
         long notSendCount = 0;
         long successSendCount = 0;
         long notFriendCount = 0;
         long failSendCount = 0;
-
+        List<JSONObject> rows = new ArrayList<>();
         for (SendDetail sendDetail : sendDetailList) {
             List<Long> sendCountList = sendDetail.getSendCountList();
             if (CollectionUtils.isEmpty(sendCountList)) {
@@ -168,41 +163,79 @@ public class WeComHistoryDataJob {
             if (count == 0) {
                 continue;
             }
-            stringBuilder.append(sendDetail.getRemark());
             allCount += count;
             notSendCount += sendCountList.get(0);
             successSendCount += sendCountList.get(1);
             notFriendCount += sendCountList.get(2);
             failSendCount += sendCountList.get(3);
             if (sendCountList.get(0) > 0 && !specialStaffIdList.contains(sendDetail.getStaffId())) {
-                LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
-                LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
+                //LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
+                //LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 //8点前报警
                 if (DateUtil.getHourOfDay() < 8 && (corpId == 1 || corpId == 3)) {
                     LarkRobotUtil.sendNotPushMessage("<at user_id=\"g6732afb\">王云鹏</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
                 }
             }
-            stringBuilder.append("总发送数量:").append(count).append("   ");
-            stringBuilder.append("未发送数量:").append(sendCountList.get(0)).append("   ");
-            stringBuilder.append("已发送数量:").append(sendCountList.get(1)).append("   ");
-            stringBuilder.append("不是好友发送失败数量:").append(sendCountList.get(2)).append("   ");
-            stringBuilder.append("已经收到其他群发消息失败发送数量:").append(sendCountList.get(3)).append("   ");
-            stringBuilder.append("\n");
+
+            JSONObject row = new JSONObject();
+            row.put("name", sendDetail.getRemark());
+            row.put("totalCount", count);
+            row.put("notSendCount", sendCountList.get(0));
+            row.put("successSendCount", sendCountList.get(1));
+            row.put("notFriendCount", sendCountList.get(2));
+            row.put("failSendCount", sendCountList.get(3));
+            rows.add(row);
         }
-        stringBuilder.append(corpName).append("汇总发送数量:").append("   ");
-        stringBuilder.append("总发送数量:").append(allCount).append("   ");
-        stringBuilder.append("未发送数量:").append(notSendCount).append("   ");
-        stringBuilder.append("已发送数量:").append(successSendCount).append("   ");
-        stringBuilder.append("不是好友发送失败数量:").append(notFriendCount).append("   ");
-        stringBuilder.append("已经收到其他群发消息失败发送数量:").append(failSendCount).append("   ");
-        stringBuilder.append("\n");
+
+        JSONObject row = new JSONObject();
+        row.put("name", "TOTAL");
+        row.put("totalCount", allCount);
+        row.put("notSendCount", notSendCount);
+        row.put("successSendCount", successSendCount);
+        row.put("notFriendCount", notFriendCount);
+        row.put("failSendCount", failSendCount);
+        rows.add(row);
         if (allCount > 0) {
-            LarkRobotUtil.sendMessage(stringBuilder.toString());
-            LarkRobotUtil.sendTipMessage(stringBuilder.toString());
+            JSONObject bodyParam = buildCheckQWMsg(corpName, rows);
+            LarkRobotUtil.sendMessage(bodyParam);
+            LarkRobotUtil.sendTipMessage(bodyParam);
         }
         return notSendCount;
     }
 
+    private JSONObject buildCheckQWMsg(String corpName, List<JSONObject> rows) {
+        List<FeishuTableDTO.Column> columns = buildCheckQWMsgSendColumns();
+        FeishuTableDTO tableDTO = FeishuTableDTO.createTable(corpName, columns, rows, false);
+        JSONObject content = JSONObject.parseObject(JSONObject.toJSONString(tableDTO));
+        JSONObject bodyParam = new JSONObject();
+        bodyParam.put("msg_type", "interactive");
+        bodyParam.put("card", content);
+        return bodyParam;
+    }
+
+    private List<FeishuTableDTO.Column> buildCheckQWMsgSendColumns() {
+        List<FeishuTableDTO.Column> columns = new ArrayList<>();
+        FeishuTableDTO.Column nameColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "name", "账号名称", null);
+        columns.add(nameColumn);
+        FeishuTableDTO.Column totalCountColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "totalCount", "总发送数量", null);
+        columns.add(totalCountColumn);
+        FeishuTableDTO.Column notSendCountColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "notSendCount", "未发送数量", null);
+        columns.add(notSendCountColumn);
+        FeishuTableDTO.Column successSendCountColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "successSendCount", "已发送数量", null);
+        columns.add(successSendCountColumn);
+        FeishuTableDTO.Column notFriendCountColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "notFriendCount", "不是好友发送失败数量", null);
+        columns.add(notFriendCountColumn);
+        FeishuTableDTO.Column failSendCountColumn = FeishuTableDTO.createFeishuColumns(
+                FieshuTableColumnDataTypeEnum.TEXT.getType(), "failSendCount", "已经收到其他群发消息失败发送数量", null);
+        columns.add(failSendCountColumn);
+        return columns;
+    }
+
 
     @XxlJob("saveHistoryMessageJob")
     public ReturnT<String> selectHistoryMessageByDay(String param) {
@@ -271,8 +304,7 @@ public class WeComHistoryDataJob {
             sendDetail.setSendCountList(countList);
             sendDetailList.add(sendDetail);
         }
-        StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append(corpName).append("\n");
+        List<JSONObject> rows = new ArrayList<>();
         for (SendDetail sendDetail : sendDetailList) {
             List<Long> sendCountList = sendDetail.getSendCountList();
             if (CollectionUtils.isEmpty(sendCountList)) {
@@ -282,25 +314,28 @@ public class WeComHistoryDataJob {
             if (count == 0) {
                 continue;
             }
-            stringBuilder.append(sendDetail.getRemark());
+
 
             if (count == sendCountList.get(0)) {
-                LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
+                //LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 if (sendDetail.getStaffId() == 3) {
-                    LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
+                    //LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
                 } else {
                     LarkRobotUtil.sendNotPushMessage("<at user_id=\"g6732afb\">王云鹏</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
                 }
             }
-            stringBuilder.append("总发送数量:").append(count).append("   ");
-            stringBuilder.append("未发送数量:").append(sendCountList.get(0)).append("   ");
-            stringBuilder.append("已发送数量:").append(sendCountList.get(1)).append("   ");
-            stringBuilder.append("不是好友发送失败数量:").append(sendCountList.get(2)).append("   ");
-            stringBuilder.append("已经收到其他群发消息失败发送数量:").append(sendCountList.get(3)).append("   ");
-            stringBuilder.append("\n");
+            JSONObject row = new JSONObject();
+            row.put("name", sendDetail.getRemark());
+            row.put("totalCount", count);
+            row.put("notSendCount", sendCountList.get(0));
+            row.put("successSendCount", sendCountList.get(1));
+            row.put("notFriendCount", sendCountList.get(2));
+            row.put("failSendCount", sendCountList.get(3));
+            rows.add(row);
         }
-        LarkRobotUtil.sendMessage(stringBuilder.toString());
-        LarkRobotUtil.sendTipMessage(stringBuilder.toString());
+        JSONObject bodyParam = buildCheckQWMsg(corpName, rows);
+        LarkRobotUtil.sendMessage(bodyParam);
+        LarkRobotUtil.sendTipMessage(bodyParam);
     }
 
     private void selectGroupMsgList(Long startTime, Long endTime, Long corpId, Long staffId) {