|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package org.springblade.system.user.service.impl; |
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import io.swagger.models.auth.In; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl; |
|
|
|
|
import org.springblade.core.secure.utils.AuthUtil; |
|
|
|
|
@ -16,12 +17,19 @@ import org.springblade.system.user.service.ITeacherService; |
|
|
|
|
import org.springblade.system.user.service.ITrainPersonService; |
|
|
|
|
import org.springblade.system.user.service.ITrainService; |
|
|
|
|
import org.springblade.system.user.service.ITrainSpeakService; |
|
|
|
|
import org.springblade.system.user.util.ThreadPoolFactory; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
import java.time.OffsetDateTime; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
import java.util.concurrent.ScheduledExecutorService; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 培训计划服务实现类 |
|
|
|
|
@ -45,6 +53,17 @@ public class TrainServiceImpl extends BaseServiceImpl<TrainMapper, Train> implem |
|
|
|
|
|
|
|
|
|
private final ISysClient sysClient; |
|
|
|
|
|
|
|
|
|
// private ScheduledExecutorService executorService = Executors.newScheduledThreadPool(100);
|
|
|
|
|
//
|
|
|
|
|
// @PostConstruct
|
|
|
|
|
// public void init() {
|
|
|
|
|
// ScheduledExecutorService executorService;
|
|
|
|
|
// //cpu核心数
|
|
|
|
|
// int i = Runtime.getRuntime().availableProcessors();
|
|
|
|
|
// //创建执行定时任务的线程池
|
|
|
|
|
// executorService = Executors.newScheduledThreadPool(i == 0 ? 10 : i * 8);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public boolean saveTrain(Train train) { |
|
|
|
|
@ -54,6 +73,19 @@ public class TrainServiceImpl extends BaseServiceImpl<TrainMapper, Train> implem |
|
|
|
|
train.setNum(split.length); |
|
|
|
|
train.setStatus(-1); |
|
|
|
|
this.save(train); |
|
|
|
|
|
|
|
|
|
//计算相关时间
|
|
|
|
|
//提前通知时间 分钟
|
|
|
|
|
Integer remind = Integer.parseInt(train.getRemind()); |
|
|
|
|
//会议开始时间
|
|
|
|
|
Date startTime = train.getStartTime(); |
|
|
|
|
//会议开始时间的毫秒数
|
|
|
|
|
long time = startTime.getTime(); |
|
|
|
|
//应该开始提醒的毫秒数
|
|
|
|
|
long time1 = time - remind * 60 *1000; |
|
|
|
|
//当前时间的毫秒数
|
|
|
|
|
Long now = LocalDateTime.now().toInstant(OffsetDateTime.now().getOffset()).toEpochMilli(); |
|
|
|
|
|
|
|
|
|
// 参训人员入库
|
|
|
|
|
if (train.getTrainPerson() != null && !"".equals(train.getTrainPerson())) { |
|
|
|
|
List<TrainPerson> personList = new ArrayList<>(); |
|
|
|
|
@ -110,6 +142,26 @@ public class TrainServiceImpl extends BaseServiceImpl<TrainMapper, Train> implem |
|
|
|
|
teacher.setRecentTrain(list.get(0).getName()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//异步执行提前通知参会人员的任务
|
|
|
|
|
ThreadPoolFactory.sheduleThreadPool.schedule(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
for (String s : split) { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "会议提醒", |
|
|
|
|
"您有新的会议将在" + train.getDuration() + "分钟后开始,请准时参加!", 1, 5, s, "/train/project"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
},time1 - now, TimeUnit.MILLISECONDS); |
|
|
|
|
|
|
|
|
|
//异步执行提前通知讲师的任务
|
|
|
|
|
ThreadPoolFactory.sheduleThreadPool.schedule(new Runnable() { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
messageClient.event(SysTypeEnum.INFORM.getValue(), "会议提醒", |
|
|
|
|
"您有新的会议将在" + train.getDuration() + "分钟后开始,请准时参加!", 1, 5, train.getTeacher().toString(), "/train/project"); |
|
|
|
|
} |
|
|
|
|
},time1 - now, TimeUnit.MILLISECONDS); |
|
|
|
|
|
|
|
|
|
return teacherService.updateById(teacher); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -214,4 +266,5 @@ public class TrainServiceImpl extends BaseServiceImpl<TrainMapper, Train> implem |
|
|
|
|
teacherService.updateById(teacher); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|