123
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.ruoyi.cai.dto.admin.query.syspush;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ruoyi.common.constant.DateConstant;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -24,6 +27,8 @@ public class SysPushMasterDTO {
|
||||
private String onlyImage;
|
||||
|
||||
private Integer sendTimeType;
|
||||
@DateTimeFormat(pattern = DateConstant.PATTERN_DATETIME)
|
||||
@JsonFormat(pattern = DateConstant.PATTERN_DATETIME)
|
||||
private LocalDateTime sendTime;
|
||||
private String title;
|
||||
private Integer type;
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.ruoyi.cai.notice.data.child.MultipleImageTextData;
|
||||
import com.ruoyi.cai.notice.data.child.MultipleImageTextNode;
|
||||
import com.ruoyi.cai.notice.data.child.SimpleImageTextData;
|
||||
import com.ruoyi.cai.notice.enums.MessageBaseTypeEnum;
|
||||
import com.ruoyi.cai.service.SysPushLogService;
|
||||
import com.ruoyi.cai.service.SysPushService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import com.ruoyi.cai.util.CaiDateUtil;
|
||||
@@ -69,6 +70,8 @@ public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> impl
|
||||
private SystemConfigManager systemConfigManager;
|
||||
@Autowired
|
||||
private AmqpProducer amqpProducer;
|
||||
@Autowired
|
||||
private SysPushLogService sysPushLogService;
|
||||
|
||||
@Override
|
||||
public void saveSysPush(SysPushParams params) {
|
||||
@@ -97,12 +100,12 @@ public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> impl
|
||||
}
|
||||
sysPush.setSendTimeType(systemPushSendTime.getCode());
|
||||
if(systemPushSendTime == SystemPushSendTimeTypeEnum.SCHEDULED_SEND){
|
||||
long between = CaiDateUtil.diff(sysPush.getEndTime(), LocalDateTime.now());
|
||||
long between = CaiDateUtil.diff(master.getSendTime(), LocalDateTime.now());
|
||||
if(between < 0){
|
||||
throw new ServiceException("定时发送时间不能少于当前时间");
|
||||
}
|
||||
if(between < 60*3){
|
||||
throw new ServiceException("定时发送最低限制为3分钟以后");
|
||||
if(between < 60){
|
||||
throw new ServiceException("定时发送最低限制为1分钟以后");
|
||||
}
|
||||
sysPush.setSendTime(master.getSendTime());
|
||||
}
|
||||
@@ -174,13 +177,13 @@ public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> impl
|
||||
this.save(sysPush);
|
||||
try {
|
||||
// 小于 < 12小时
|
||||
long between = CaiDateUtil.diff(sysPush.getEndTime(), LocalDateTime.now());
|
||||
long between = CaiDateUtil.diff(sysPush.getSendTime(), LocalDateTime.now());
|
||||
CommonDelayDto dto = new CommonDelayDto();
|
||||
dto.setSysPushId(sysPush.getId());
|
||||
dto.setType(CommonDelayTypeEnum.SYS_PUSH.getCode());
|
||||
amqpProducer.sendCommonDelayMq(dto,(int)between+2);
|
||||
}catch (Exception e){
|
||||
log.error("延时任务发送失败!");
|
||||
log.error("系统推送任务发送失败!",e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +221,6 @@ public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> impl
|
||||
if(SystemPushStatusEnum.COMPLETE.getCode().equals(status)){
|
||||
throw new ServiceException("不允许重复执行");
|
||||
}
|
||||
if(SystemPushStatusEnum.RUNNING.getCode().equals(status)
|
||||
|| SystemPushStatusEnum.QUEUE_RUNNING.getCode().equals(status)){
|
||||
throw new ServiceException("任务正在执行中,不允许重复执行");
|
||||
}
|
||||
boolean update = this.update(Wrappers.lambdaUpdate(SysPush.class)
|
||||
.eq(SysPush::getId, sysPush.getId())
|
||||
.eq(SysPush::getStatus, SystemPushStatusEnum.RUNNING.getCode())
|
||||
@@ -303,7 +302,7 @@ public class SysPushServiceImpl extends ServiceImpl<SysPushMapper, SysPush> impl
|
||||
sysPushLog.setStatus(SystemPushLogStatusEnum.SEND_FAIL.getCode());
|
||||
sysPushLog.setResult(e.getMessage());
|
||||
}
|
||||
this.save(sysPush);
|
||||
sysPushLogService.save(sysPushLog);
|
||||
}
|
||||
this.update(Wrappers.lambdaUpdate(SysPush.class)
|
||||
.eq(SysPush::getId, sysPush.getId())
|
||||
|
||||
@@ -92,7 +92,7 @@ public class UserForbidServiceImpl extends ServiceImpl<UserForbidMapper, UserFor
|
||||
dto.setType(CommonDelayTypeEnum.USER_FORBID.getCode());
|
||||
amqpProducer.sendCommonDelayMq(dto,(int)between+2);
|
||||
}catch (Exception e){
|
||||
log.error("延时任务发送失败!");
|
||||
log.error("用户封禁延时任务发送失败!",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user