Jelajahi Sumber

增加获取指定员工历史记录

xueyiming 7 bulan lalu
induk
melakukan
54456d6d28

+ 16 - 5
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -109,7 +109,7 @@ public class WeComHistoryDataJob {
         }
         for (Corp corp : corps) {
             for (; startTime < endTime; startTime += TimeConstant.DAY) {
-                selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime), corp.getId());
+                selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime), corp.getId(), xxlJobParam.getStaffId());
             }
         }
         for (Corp corp : corps) {
@@ -159,8 +159,8 @@ public class WeComHistoryDataJob {
         LarkRobotUtil.sendMessage(stringBuilder.toString());
     }
 
-    private void selectGroupMsgList(Long startTime, Long endTime, Long corpId) {
-        delHistoryMessageList(startTime, endTime);
+    private void selectGroupMsgList(Long startTime, Long endTime, Long corpId, Long staffId) {
+        delHistoryMessageList(startTime, endTime, corpId, staffId);
         try {
             String cursor = "";
             do {
@@ -224,6 +224,12 @@ public class WeComHistoryDataJob {
                             LarkRobotUtil.sendMessage("企微推送报警:carrierId不存在请检查 " + carrierId);
                             continue;
                         }
+                        //指定id以后  过滤其他id
+                        if (staffId != null) {
+                            if (!Objects.equals(staffList.get(0).getId(), staffId)) {
+                                continue;
+                            }
+                        }
                         List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, carrierId, corpId);
                         if (CollectionUtils.isEmpty(externalUsers)) {
                             continue;
@@ -333,11 +339,16 @@ public class WeComHistoryDataJob {
         return httpPoolClient.post(url, param.toJSONString());
     }
 
-    private void delHistoryMessageList(Long startTime, Long endTime) {
+    private void delHistoryMessageList(Long startTime, Long endTime, Long corpId, Long staffId) {
         HistoryMessage historyMessage = new HistoryMessage();
         historyMessage.setIsDelete(1);
         HistoryMessageExample example = new HistoryMessageExample();
-        example.createCriteria().andSendTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000));
+        HistoryMessageExample.Criteria criteria =
+                example.createCriteria().andSendTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000))
+                        .andCorpIdEqualTo(corpId);
+        if (staffId != null) {
+            criteria.andStaffIdEqualTo(staffId);
+        }
         historyMessageMapper.updateByExampleSelective(historyMessage, example);
 
     }