Commit 0a91088e authored by renandong's avatar renandong 🇨🇳

1.修改发送短信定时任务异常

parent 4c874e35
......@@ -122,7 +122,7 @@ public class PushCallBackServiceImpl extends ServiceImpl<PushCallBackDao, PushCa
List<PushCallBackEntity> list = new ArrayList<>();
while (matcher.find()) {
String group = matcher.group(1);
log.info("回调信息:{}", group);
log.error("回调信息:{}", group);
PushCallBackEntity callBackInfo = JSONObject.parseObject(group, PushCallBackEntity.class);
String desc = JSONObject.parseObject(group).getString("desc");
callBackInfo.setDescStr(desc);
......
......@@ -16,6 +16,7 @@ import com.weface.service.UserTagService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -52,6 +53,7 @@ public class UserTagsTask {
private MenuTagsService menuTagsService;
@Autowired
@Qualifier(value = "asyncServiceExecutor")
private ThreadPoolTaskExecutor asyncServiceExecutor;
@Autowired
......@@ -68,11 +70,9 @@ public class UserTagsTask {
@Scheduled(cron = "0 0 0/1 * * ? ")
public void sendMessage() {
try {
log.info("开始执行短信发送任务");
log.error("开始执行短信发送任务");
List<PushLogEntity> list = pushLogService.getPushLogByTime(TIME);
List<PushLogEntity> updateBatch = null;
if (!CollectionUtils.isEmpty(list)) {
updateBatch = new ArrayList<>(list.size());
DES des = DES.getInstanceDes();
for (PushLogEntity pushLogEntity : list) {
String phone = pushLogEntity.getPhone();
......@@ -86,18 +86,15 @@ public class UserTagsTask {
if (1001 == arriveStatus) {
boolean b = ShortMsgSend.sendMobileByRegister(pushContent, phone, messageTemplate);
if (b) {
log.info("执行短信发送成功");
log.error("执行短信发送成功");
pushLogEntity.setArriveStatus(1003);
pushLogEntity.setUpdateTime(new Date());
updateBatch.add(pushLogEntity);
pushLogService.updateById(pushLogEntity);
}
}
}
}
}
if (updateBatch != null) {
pushLogService.updateBatchById(updateBatch);
}
} catch (IOException e) {
log.error("执行短信发送失败:{}", e.getMessage());
e.printStackTrace();
......@@ -112,7 +109,7 @@ public class UserTagsTask {
public void updateRedisHashKey() {
try {
log.error("开始更新任务缓存");
HashSet<Object> hashSet = new HashSet<>();
Set<Object> hashSet = new HashSet<>();
Set<Object> keys = RedisUtil.HashOps.hKeys(Constant.PUSH_TASK_INFO);
for (Object key : keys) {
Object hashValue = RedisUtil.HashOps.hGet(Constant.PUSH_TASK_INFO, key.toString());
......@@ -125,7 +122,7 @@ public class UserTagsTask {
}
}
}
if (!hashSet.isEmpty()) {
if (!CollectionUtils.isEmpty(hashSet)) {
RedisUtil.HashOps.hDelete(Constant.PUSH_TASK_INFO, hashSet.toArray());
}
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment