|
|
@@ -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=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
|
|
|
+ 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=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
|
|
|
+ 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) {
|