|
@@ -8,7 +8,7 @@ import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
|
|
|
import com.tzld.piaoquan.wecom.component.HttpPoolClient;
|
|
|
import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
|
|
|
import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
|
|
|
-import com.tzld.piaoquan.wecom.dao.mapper.SubjectMapper;
|
|
|
+import com.tzld.piaoquan.wecom.dao.mapper.CorpMapper;
|
|
|
import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
|
|
|
import com.tzld.piaoquan.wecom.model.bo.ExternalUser;
|
|
|
import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord;
|
|
@@ -69,7 +69,7 @@ public class WeComHistoryDataJob {
|
|
|
private UserService userService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SubjectMapper subjectMapper;
|
|
|
+ private CorpMapper corpMapper;
|
|
|
|
|
|
|
|
|
@XxlJob("saveHistoryMessageJob")
|
|
@@ -95,26 +95,26 @@ public class WeComHistoryDataJob {
|
|
|
}
|
|
|
Long startTime = xxlJobParam.getStartTime();
|
|
|
Long endTime = xxlJobParam.getEndTime();
|
|
|
- SubjectExample example = new SubjectExample();
|
|
|
- if (xxlJobParam.getSubjectId() != null) {
|
|
|
- example.createCriteria().andIdEqualTo(xxlJobParam.getSubjectId());
|
|
|
+ CorpExample example = new CorpExample();
|
|
|
+ if (xxlJobParam.getCorpId() != null) {
|
|
|
+ example.createCriteria().andIdEqualTo(xxlJobParam.getCorpId());
|
|
|
}
|
|
|
- List<Subject> subjects = subjectMapper.selectByExample(example);
|
|
|
- if (CollectionUtils.isEmpty(subjects)) {
|
|
|
+ List<Corp> corps = corpMapper.selectByExample(example);
|
|
|
+ if (CollectionUtils.isEmpty(corps)) {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
- for (Subject subject : subjects) {
|
|
|
+ for (Corp corp : corps) {
|
|
|
for (; startTime < endTime; startTime += TimeConstant.DAY) {
|
|
|
- selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime), subject.getId());
|
|
|
+ selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime), corp.getId());
|
|
|
}
|
|
|
}
|
|
|
- for (Subject subject : subjects) {
|
|
|
- selectAlertHistoryMessage(xxlJobParam.getStartTime(), xxlJobParam.getEndTime(), subject.getId(), subject.getName());
|
|
|
+ for (Corp corp : corps) {
|
|
|
+ selectAlertHistoryMessage(xxlJobParam.getStartTime(), xxlJobParam.getEndTime(), corp.getId(), corp.getName());
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
|
|
|
- private void selectAlertHistoryMessage(Long startTime, Long endTime, Long subjectId, String subjectName) {
|
|
|
+ private void selectAlertHistoryMessage(Long startTime, Long endTime, Long corpId, String corpName) {
|
|
|
StaffExample staffExample = new StaffExample();
|
|
|
List<Staff> staffList = staffMapper.selectByExample(staffExample);
|
|
|
ArrayList<Integer> statusList = Lists.newArrayList(0, 1, 2, 3);
|
|
@@ -129,7 +129,7 @@ public class WeComHistoryDataJob {
|
|
|
.andStaffIdEqualTo(staff.getId())
|
|
|
.andStatusEqualTo(status)
|
|
|
.andIsDeleteEqualTo(0)
|
|
|
- .andSubjectIdEqualTo(subjectId);
|
|
|
+ .andCorpIdEqualTo(corpId);
|
|
|
long l = historyMessageMapper.countByExample(example);
|
|
|
countList.add(l / MAX_VIDEO_NUM);
|
|
|
}
|
|
@@ -137,7 +137,7 @@ public class WeComHistoryDataJob {
|
|
|
sendDetailList.add(sendDetail);
|
|
|
}
|
|
|
StringBuilder stringBuilder = new StringBuilder();
|
|
|
- stringBuilder.append(subjectName).append("\n");
|
|
|
+ stringBuilder.append(corpName).append("\n");
|
|
|
for (SendDetail sendDetail : sendDetailList) {
|
|
|
List<Long> sendCountList = sendDetail.getSendCountList();
|
|
|
if (CollectionUtils.isEmpty(sendCountList)) {
|
|
@@ -155,12 +155,12 @@ public class WeComHistoryDataJob {
|
|
|
LarkRobotUtil.sendMessage(stringBuilder.toString());
|
|
|
}
|
|
|
|
|
|
- private void selectGroupMsgList(Long startTime, Long endTime, Long subjectId) {
|
|
|
+ private void selectGroupMsgList(Long startTime, Long endTime, Long corpId) {
|
|
|
delHistoryMessageList(startTime, endTime);
|
|
|
try {
|
|
|
String cursor = "";
|
|
|
do {
|
|
|
- String res = getGroupMsgList(startTime, endTime, cursor, subjectId);
|
|
|
+ String res = getGroupMsgList(startTime, endTime, cursor, corpId);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
Integer errCode = jsonObject.getInteger("errcode");
|
|
|
if (errCode != 0) {
|
|
@@ -208,7 +208,7 @@ public class WeComHistoryDataJob {
|
|
|
messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
|
|
|
messageAttachmentList.add(messageAttachment);
|
|
|
}
|
|
|
- List<String> userIdList = selectGroupMsgTask(msgId, subjectId);
|
|
|
+ List<String> userIdList = selectGroupMsgTask(msgId, corpId);
|
|
|
if (CollectionUtils.isEmpty(userIdList)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -220,11 +220,11 @@ public class WeComHistoryDataJob {
|
|
|
LarkRobotUtil.sendMessage("企微推送报警:userId不存在请检查 " + userId);
|
|
|
continue;
|
|
|
}
|
|
|
- List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId, subjectId);
|
|
|
+ List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId, corpId);
|
|
|
if (CollectionUtils.isEmpty(externalUsers)) {
|
|
|
continue;
|
|
|
}
|
|
|
- insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList, createTime, subjectId);
|
|
|
+ insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList, createTime, corpId);
|
|
|
messageAttachmentService.addMiniProgram(messageAttachmentList);
|
|
|
}
|
|
|
}
|
|
@@ -240,11 +240,11 @@ public class WeComHistoryDataJob {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<ExternalUser> selectGroupMsgSendResult(String msgId, String userId, Long subjectId) throws IOException {
|
|
|
+ private List<ExternalUser> selectGroupMsgSendResult(String msgId, String userId, Long corpId) throws IOException {
|
|
|
List<ExternalUser> resList = new ArrayList<>();
|
|
|
String cursor = "";
|
|
|
do {
|
|
|
- String res = getGroupMsgSendResult(msgId, userId, cursor, subjectId);
|
|
|
+ String res = getGroupMsgSendResult(msgId, userId, cursor, corpId);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
Integer errCode = jsonObject.getInteger("errcode");
|
|
|
if (errCode != 0) {
|
|
@@ -272,8 +272,8 @@ public class WeComHistoryDataJob {
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
- private String getGroupMsgSendResult(String msgId, String userId, String cursor, Long subjectId) throws IOException {
|
|
|
- String accessToken = accessTokenService.getWeComAccessToken(subjectId);
|
|
|
+ private String getGroupMsgSendResult(String msgId, String userId, String cursor, Long corpId) throws IOException {
|
|
|
+ String accessToken = accessTokenService.getWeComAccessToken(corpId);
|
|
|
String url = POST_WE_COM_GROUP_MSG_SEND_RESULT
|
|
|
+ "?access_token=" + accessToken;
|
|
|
JSONObject param = new JSONObject();
|
|
@@ -286,11 +286,11 @@ public class WeComHistoryDataJob {
|
|
|
return httpPoolClient.post(url, param.toJSONString());
|
|
|
}
|
|
|
|
|
|
- private List<String> selectGroupMsgTask(String msgId, Long subjectId) throws IOException {
|
|
|
+ private List<String> selectGroupMsgTask(String msgId, Long corpId) throws IOException {
|
|
|
List<String> resList = new ArrayList<>();
|
|
|
String cursor = "";
|
|
|
do {
|
|
|
- String res = getGroupMsgTask(msgId, cursor, subjectId);
|
|
|
+ String res = getGroupMsgTask(msgId, cursor, corpId);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
Integer errCode = jsonObject.getInteger("errcode");
|
|
|
if (errCode != 0) {
|
|
@@ -313,8 +313,8 @@ public class WeComHistoryDataJob {
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
- private String getGroupMsgTask(String msgId, String cursor, Long subjectId) throws IOException {
|
|
|
- String accessToken = accessTokenService.getWeComAccessToken(subjectId);
|
|
|
+ private String getGroupMsgTask(String msgId, String cursor, Long corpId) throws IOException {
|
|
|
+ String accessToken = accessTokenService.getWeComAccessToken(corpId);
|
|
|
String url = POST_WE_COM_GROUP_MSG_TASK
|
|
|
+ "?access_token=" + accessToken;
|
|
|
JSONObject param = new JSONObject();
|
|
@@ -335,7 +335,7 @@ public class WeComHistoryDataJob {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList, Long createTime, Long subjectId) {
|
|
|
+ private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList, Long createTime, Long corpId) {
|
|
|
if (CollectionUtils.isEmpty(externalUsers) || CollectionUtils.isEmpty(miniprogramRecordList)) {
|
|
|
return;
|
|
|
}
|
|
@@ -363,7 +363,7 @@ public class WeComHistoryDataJob {
|
|
|
historyMessage.setUserId(userId);
|
|
|
historyMessage.setStaffId(staff.getId());
|
|
|
historyMessage.setStatus(status);
|
|
|
- historyMessage.setSubjectId(subjectId);
|
|
|
+ historyMessage.setCorpId(corpId);
|
|
|
historyMessageList.add(historyMessage);
|
|
|
if (status == 2) {
|
|
|
userService.delStaffWithUser(userId, staff.getId(), sendTime);
|
|
@@ -373,8 +373,8 @@ public class WeComHistoryDataJob {
|
|
|
historyMessageService.batchInsertHistoryMessage(historyMessageList);
|
|
|
}
|
|
|
|
|
|
- private String getGroupMsgList(Long startTime, Long endTime, String cursor, Long subjectId) throws IOException {
|
|
|
- String accessToken = accessTokenService.getWeComAccessToken(subjectId);
|
|
|
+ private String getGroupMsgList(Long startTime, Long endTime, String cursor, Long corpId) throws IOException {
|
|
|
+ String accessToken = accessTokenService.getWeComAccessToken(corpId);
|
|
|
String url = POST_WE_COM_GROUP_MSG_LIST_URL
|
|
|
+ "?access_token=" + accessToken;
|
|
|
JSONObject param = new JSONObject();
|