|
@@ -91,41 +91,39 @@ public class WeComHistoryDataJob {
|
|
|
@Autowired
|
|
|
private WeComSendService weComSendService;
|
|
|
|
|
|
- private static final String START_TIME_KEY = "start_time_key";
|
|
|
+ private static final String START_TIME_KEY = "start_time_key_%s";
|
|
|
|
|
|
@XxlJob("saveHistoryMessageJob1")
|
|
|
public ReturnT<String> saveHistoryMessageJob1(String param) {
|
|
|
- Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(START_TIME_KEY);
|
|
|
- Long dayStartTime = DateUtil.getBeforeDayStart(0);
|
|
|
- Long startTime;
|
|
|
- if (startTimeVal == null) {
|
|
|
- startTime = DateUtil.getBeforeDayStart(0);
|
|
|
- } else {
|
|
|
- if (dayStartTime > startTimeVal) {
|
|
|
- startTime = dayStartTime;
|
|
|
- } else {
|
|
|
- startTime = (long) startTimeVal;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Long endTime = System.currentTimeMillis() / 1000;
|
|
|
CorpExample example = new CorpExample();
|
|
|
List<Corp> corps = corpMapper.selectByExample(example);
|
|
|
if (CollectionUtils.isEmpty(corps)) {
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
|
for (Corp corp : corps) {
|
|
|
+ String key = String.format(START_TIME_KEY, corp.getId());
|
|
|
+ Integer startTimeVal = (Integer) redisTemplate.opsForValue().get(key);
|
|
|
+ Long dayStartTime = DateUtil.getBeforeDayStart(0);
|
|
|
+ Long startTime;
|
|
|
+ if (startTimeVal == null) {
|
|
|
+ startTime = DateUtil.getBeforeDayStart(0);
|
|
|
+ } else {
|
|
|
+ if (dayStartTime > startTimeVal) {
|
|
|
+ startTime = dayStartTime;
|
|
|
+ } else {
|
|
|
+ startTime = (long) startTimeVal;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long endTime = System.currentTimeMillis() / 1000;
|
|
|
selectGroupMsgList(startTime, endTime, corp.getId(), null);
|
|
|
- }
|
|
|
- boolean isAllSend = true;
|
|
|
- for (Corp corp : corps) {
|
|
|
+ boolean isAllSend = true;
|
|
|
long notSentCount = newSelectAlertHistoryMessage(startTime, endTime + TimeConstant.HOUR, corp.getId(), corp.getName());
|
|
|
if (notSentCount > 0) {
|
|
|
isAllSend = false;
|
|
|
}
|
|
|
- }
|
|
|
- if (isAllSend) {
|
|
|
- redisTemplate.opsForValue().set(START_TIME_KEY, endTime, 1, TimeUnit.DAYS);
|
|
|
+ if (isAllSend) {
|
|
|
+ redisTemplate.opsForValue().set(key, endTime, 1, TimeUnit.DAYS);
|
|
|
+ }
|
|
|
}
|
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
@@ -177,7 +175,7 @@ public class WeComHistoryDataJob {
|
|
|
LarkRobotUtil.sendMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
|
|
|
LarkRobotUtil.sendTipMessage(sendDetail.getRemark() + "存在未发送记录,请检查");
|
|
|
//8点前报警
|
|
|
- if (DateUtil.getHourOfDay() < 8) {
|
|
|
+ if (DateUtil.getHourOfDay() < 8 && corpId == 1) {
|
|
|
LarkRobotUtil.sendNotPushMessage("<at user_id=\"all\">所有人</at> " + sendDetail.getRemark() + " 存在未发送记录,请检查");
|
|
|
}
|
|
|
}
|
|
@@ -482,6 +480,9 @@ public class WeComHistoryDataJob {
|
|
|
String cursor = "";
|
|
|
do {
|
|
|
String res = getGroupMsgTask(msgId, cursor, corpId);
|
|
|
+ if (StringUtils.isEmpty(res)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
Integer errCode = jsonObject.getInteger("errcode");
|
|
|
if (errCode != 0) {
|
|
@@ -645,8 +646,8 @@ public class WeComHistoryDataJob {
|
|
|
+ "?access_token=" + accessToken;
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("chat_type", "single");
|
|
|
- param.put("start_time", startTime);
|
|
|
- param.put("end_time", endTime);
|
|
|
+ param.put("start_time", String.valueOf(startTime));
|
|
|
+ param.put("end_time", String.valueOf(endTime));
|
|
|
param.put("limit", 100);
|
|
|
if (StringUtils.isNotEmpty(cursor)) {
|
|
|
param.put("cursor", cursor);
|