|
@@ -10,6 +10,7 @@ import org.springblade.manager.entity.SystemMsg;
|
|
|
import org.springblade.manager.service.ISystemMsgService;
|
|
|
import org.springblade.websocket.vo.MsgVO;
|
|
|
import org.springblade.websocket.vo.SystMsgVO;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -34,11 +35,18 @@ public class SystemMsgJob {
|
|
|
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+ // 读取配置并设置默认值
|
|
|
+ @Value("${scheduler.enabled:true}")
|
|
|
+ private boolean schedulerEnabled;
|
|
|
+
|
|
|
/**
|
|
|
* 定时推送公告-取消公告-修改公告状态,不想污染日志,使用jdbc
|
|
|
*/
|
|
|
- @Scheduled(cron = "0/10 * * * * ?")
|
|
|
+ @Scheduled(cron = "0/10 * * * * ?")
|
|
|
public void autoUpdateMsgStatus(){
|
|
|
+ // 本地环境跳过执行(可添加日志输出)
|
|
|
+ if (!schedulerEnabled) return;
|
|
|
+
|
|
|
/** 普通公告推送*/
|
|
|
String sql1 = "select * from m_system_msg where is_deleted = 0 and msg_type = 2 and push_status = 1 and now()<=push_end_date_time and now()>=push_date_time ";
|
|
|
List<SystemMsg> list1 = jdbcTemplate.query(sql1,new BeanPropertyRowMapper<>(SystemMsg.class));
|
|
@@ -63,13 +71,13 @@ public class SystemMsgJob {
|
|
|
.in(SystemMsg::getId,list2.stream().map(SystemMsg::getId).collect(Collectors.toList())));
|
|
|
}
|
|
|
/** 维护倒计时*/
|
|
|
- // String sql3 = "select * from m_system_msg where is_deleted = 0 and msg_type = 1 and status != 3 and TIMESTAMPADD(SECOND, 1, NOW()) >= push_count_down_date_time and now() < push_date_time ";
|
|
|
+ // String sql3 = "select * from m_system_msg where is_deleted = 0 and msg_type = 1 and status != 3 and TIMESTAMPADD(SECOND, 1, NOW()) >= push_count_down_date_time and now() < push_date_time ";
|
|
|
String sql3 = "select * from m_system_msg where is_deleted = 0 and msg_type = 1 and status != 3 and TIMESTAMPDIFF(SECOND,push_count_down_date_time,sysdate())>0 ";
|
|
|
List<SystemMsg> list3 = jdbcTemplate.query(sql3,new BeanPropertyRowMapper<>(SystemMsg.class));
|
|
|
if (list3.size() > 0){
|
|
|
SystemMsg msg = list3.get(0);
|
|
|
msg.setMsgType(3);
|
|
|
- // msg.setMsgContent(Duration.between(LocalDateTime.now(), msg.getPushDateTime()).getSeconds()+"");
|
|
|
+ // msg.setMsgContent(Duration.between(LocalDateTime.now(), msg.getPushDateTime()).getSeconds()+"");
|
|
|
msg.setMsgContent((msg.getMsgCountDownTime()*60)+"");
|
|
|
systemMsgService.pushSystemMsgToAllUser(msg);
|
|
|
systemMsgService.update(new LambdaUpdateWrapper<SystemMsg>()
|