| 
														
															@@ -5,11 +5,11 @@ import com.alibaba.fastjson.JSONObject; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.common.constant.TimeConstant; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.common.constant.TimeConstant; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.tzld.piaoquan.wecom.dao.mapper.StaffWithUserMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.tzld.piaoquan.wecom.model.po.HistoryMessage; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-import com.tzld.piaoquan.wecom.model.po.MessageAttachment; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.tzld.piaoquan.wecom.model.bo.StaffWithUserParam; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import com.tzld.piaoquan.wecom.model.po.*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.service.AccessTokenService; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.service.AccessTokenService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.service.HistoryMessageService; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.service.HistoryMessageService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import com.tzld.piaoquan.wecom.service.MessageAttachmentService; 
														 | 
														
														 | 
														
															 import com.tzld.piaoquan.wecom.service.MessageAttachmentService; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -22,6 +22,7 @@ import com.xxl.job.core.handler.annotation.XxlJob; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
														
														 | 
														
															 import lombok.extern.slf4j.Slf4j; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.apache.commons.lang3.ObjectUtils; 
														 | 
														
														 | 
														
															 import org.apache.commons.lang3.ObjectUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.apache.commons.lang3.StringUtils; 
														 | 
														
														 | 
														
															 import org.apache.commons.lang3.StringUtils; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+import org.checkerframework.checker.units.qual.A; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
														
														 | 
														
															 import org.springframework.beans.factory.annotation.Autowired; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.stereotype.Component; 
														 | 
														
														 | 
														
															 import org.springframework.stereotype.Component; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 import org.springframework.util.CollectionUtils; 
														 | 
														
														 | 
														
															 import org.springframework.util.CollectionUtils; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -56,29 +57,35 @@ public class WeComHistoryDataJob { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @Autowired 
														 | 
														
														 | 
														
															     @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     private MessageAttachmentService messageAttachmentService; 
														 | 
														
														 | 
														
															     private MessageAttachmentService messageAttachmentService; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    @Autowired 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private StaffWithUserMapper staffWithUserMapper; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     @XxlJob("saveHistoryMessageJob") 
														 | 
														
														 | 
														
															     @XxlJob("saveHistoryMessageJob") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     public ReturnT<String> selectHistoryMessageByDay(String param) { 
														 | 
														
														 | 
														
															     public ReturnT<String> selectHistoryMessageByDay(String param) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        long endTime; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        long startTime; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (StringUtils.isEmpty(param)) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        StaffWithUserParam staffWithUserParam = new StaffWithUserParam(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (StringUtils.isNotEmpty(param)) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            staffWithUserParam = JSONObject.parseObject(param, StaffWithUserParam.class); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (staffWithUserParam.getStartTime() == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             HistoryMessageExample example = new HistoryMessageExample(); 
														 | 
														
														 | 
														
															             HistoryMessageExample example = new HistoryMessageExample(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             example.setOrderByClause("create_time desc"); 
														 | 
														
														 | 
														
															             example.setOrderByClause("create_time desc"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             example.setPage(new Page<>(1, 1)); 
														 | 
														
														 | 
														
															             example.setPage(new Page<>(1, 1)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             List<HistoryMessage> historyMessages = historyMessageMapper.selectByExample(example); 
														 | 
														
														 | 
														
															             List<HistoryMessage> historyMessages = historyMessageMapper.selectByExample(example); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            startTime = historyMessages.get(0).getCreateTime().getTime() / 1000; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            endTime = System.currentTimeMillis() / 1000; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            String[] split = param.split(","); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            startTime = Long.parseLong(split[0]); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            endTime = Long.parseLong(split[1]); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            staffWithUserParam.setStartTime(historyMessages.get(0).getCreateTime().getTime() / 1000); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (staffWithUserParam.getEndTime() == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            staffWithUserParam.setEndTime(System.currentTimeMillis() / 1000); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Long startTime = staffWithUserParam.getStartTime(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        Long endTime = staffWithUserParam.getEndTime(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (; startTime < endTime; startTime += TimeConstant.DAY) { 
														 | 
														
														 | 
														
															         for (; startTime < endTime; startTime += TimeConstant.DAY) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            selectHistoryMessage(startTime, Math.min(startTime + TimeConstant.DAY, endTime)); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            selectHistoryMessage(startTime, Math.min(startTime + TimeConstant.DAY, endTime), staffWithUserParam.getStaffId()); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return ReturnT.SUCCESS; 
														 | 
														
														 | 
														
															         return ReturnT.SUCCESS; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    public void selectHistoryMessage(Long startTime, Long endTime) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    public void selectHistoryMessage(Long startTime, Long endTime, Long staffId) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         try { 
														 | 
														
														 | 
														
															         try { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             Integer total = getHistoryDataTotal(startTime, endTime); 
														 | 
														
														 | 
														
															             Integer total = getHistoryDataTotal(startTime, endTime); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (total == null || total == 0) { 
														 | 
														
														 | 
														
															             if (total == null || total == 0) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -131,7 +138,7 @@ public class WeComHistoryDataJob { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                         } 
														 | 
														
														 | 
														
															                         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                         allExternalUserList.addAll(externalUserList); 
														 | 
														
														 | 
														
															                         allExternalUserList.addAll(externalUserList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     } 
														 | 
														
														 | 
														
															                     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                    insertHistoryMessageList(allExternalUserList, miniprogramRecordList, createdAt); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    insertHistoryMessageList(allExternalUserList, miniprogramRecordList, createdAt, staffId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     messageAttachmentService.addMiniprogram(messageAttachmentList); 
														 | 
														
														 | 
														
															                     messageAttachmentService.addMiniprogram(messageAttachmentList); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 } 
														 | 
														
														 | 
														
															                 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -141,13 +148,21 @@ public class WeComHistoryDataJob { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    private void insertHistoryMessageList(List<String> allExternalUserList, List<MiniprogramRecord> miniprogramRecordList, Date sendTime) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    private void insertHistoryMessageList(List<String> allExternalUserList, List<MiniprogramRecord> miniprogramRecordList, Date sendTime, Long staffId) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         List<HistoryMessage> historyMessageList = new ArrayList<>(); 
														 | 
														
														 | 
														
															         List<HistoryMessage> historyMessageList = new ArrayList<>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         for (String externalUserId3rdParty : allExternalUserList) { 
														 | 
														
														 | 
														
															         for (String externalUserId3rdParty : allExternalUserList) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             Long userId = userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty); 
														 | 
														
														 | 
														
															             Long userId = userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if (userId == null) { 
														 | 
														
														 | 
														
															             if (userId == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 continue; 
														 | 
														
														 | 
														
															                 continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             } 
														 | 
														
														 | 
														
															             } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            if (staffId != null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                StaffWithUserExample example = new StaffWithUserExample(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                example.createCriteria().andStaffIdEqualTo(staffId).andUserIdEqualTo(userId); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                if (staffWithUserList == null) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    continue; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             for (MiniprogramRecord miniprogramRecord : miniprogramRecordList) { 
														 | 
														
														 | 
														
															             for (MiniprogramRecord miniprogramRecord : miniprogramRecordList) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 HistoryMessage historyMessage = new HistoryMessage(); 
														 | 
														
														 | 
														
															                 HistoryMessage historyMessage = new HistoryMessage(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                 historyMessage.setSendTime(sendTime); 
														 | 
														
														 | 
														
															                 historyMessage.setSendTime(sendTime); 
														 |