xueyiming 6 місяців тому
батько
коміт
fdc37baec8

+ 43 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java

@@ -2,11 +2,13 @@ package com.tzld.piaoquan.wecom.job;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
 import com.tzld.piaoquan.wecom.common.constant.TimeConstant;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.wecom.dao.mapper.*;
 import com.tzld.piaoquan.wecom.model.bo.ExternalUser;
 import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord;
+import com.tzld.piaoquan.wecom.model.bo.SendDetail;
 import com.tzld.piaoquan.wecom.model.bo.XxlJobParam;
 import com.tzld.piaoquan.wecom.model.po.*;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
@@ -88,9 +90,50 @@ public class WeComHistoryDataJob1 {
         for (; startTime < endTime; startTime += TimeConstant.DAY) {
             selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime));
         }
+        selectAlertHistoryMessage(xxlJobParam.getStartTime(), xxlJobParam.getEndTime());
         return ReturnT.SUCCESS;
     }
 
+    public void selectAlertHistoryMessage(Long startTime, Long endTime) {
+
+        StaffExample staffExample = new StaffExample();
+        List<Staff> staffList = staffMapper.selectByExample(staffExample);
+        ArrayList<Integer> statusList = Lists.newArrayList(0, 1, 2, 3);
+        List<SendDetail> sendDetailList = new ArrayList<>();
+        for (Staff staff : staffList) {
+            SendDetail sendDetail = new SendDetail();
+            sendDetail.setRemark(staff.getRemark());
+            List<Long> countList = new ArrayList<>();
+            for (Integer status : statusList) {
+                HistoryMessageExample example = new HistoryMessageExample();
+                example.createCriteria().andSendTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000))
+                        .andStaffIdEqualTo(staff.getId())
+                        .andStatusEqualTo(status)
+                        .andIsDeleteEqualTo(0);
+                long l = historyMessageMapper.countByExample(example);
+                countList.add(l);
+            }
+            sendDetail.setSendCountList(countList);
+            sendDetailList.add(sendDetail);
+        }
+        StringBuilder stringBuilder = new StringBuilder();
+        for (SendDetail sendDetail : sendDetailList) {
+            List<Long> sendCountList = sendDetail.getSendCountList();
+            if (CollectionUtils.isEmpty(sendCountList)) {
+                continue;
+            }
+            stringBuilder.append(sendDetail.getRemark());
+            long count = sendCountList.get(0) + sendCountList.get(1) + sendCountList.get(2) + sendCountList.get(3);
+            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");
+        }
+        LarkRobotUtil.sendMessage(stringBuilder.toString());
+    }
+
     public void selectGroupMsgList(Long startTime, Long endTime) {
         delHistoryMessageList(startTime, endTime);
         try {

+ 13 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/SendDetail.java

@@ -0,0 +1,13 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class SendDetail {
+
+    private String remark;
+
+    private List<Long> sendCountList;
+}