|
@@ -9,14 +9,8 @@ import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
-import com.rongwei.training.domain.EmpExamDo;
|
|
|
-import com.rongwei.training.domain.PlanDo;
|
|
|
-import com.rongwei.training.domain.PlanPaperDo;
|
|
|
-import com.rongwei.training.domain.TrainingDemandSurveyBackupsDo;
|
|
|
-import com.rongwei.trainingcommon.sys.service.EmpExamService;
|
|
|
-import com.rongwei.trainingcommon.sys.service.PlanPaperService;
|
|
|
-import com.rongwei.trainingcommon.sys.service.PlanService;
|
|
|
-import com.rongwei.trainingcommon.sys.service.TrainingSendNotifyService;
|
|
|
+import com.rongwei.training.domain.*;
|
|
|
+import com.rongwei.trainingcommon.sys.service.*;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -40,12 +34,6 @@ import static com.rongwei.safecommon.utils.SaveConstans.NotifyType.*;
|
|
|
@Service
|
|
|
public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService {
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
|
|
|
- public static final ThreadPoolExecutor threadPool = ExecutorBuilder.create()
|
|
|
- .setCorePoolSize(8)
|
|
|
- .setMaxPoolSize(16)
|
|
|
- .setKeepAliveTime(0, TimeUnit.SECONDS)
|
|
|
- .build();
|
|
|
-
|
|
|
@Autowired
|
|
|
private PlanService planService;
|
|
|
@Autowired
|
|
@@ -60,6 +48,10 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
private TrainingSendNotifyServiceImpl sendNotifyService;
|
|
|
@Autowired
|
|
|
private TrainingDemandSurveyBackupsServiceImpl demandSurveyBackupsService;
|
|
|
+ @Autowired
|
|
|
+ private PlanCourseServiceImpl planCourseService;
|
|
|
+ @Autowired
|
|
|
+ private EmpCourseServiceImpl empCourseService;
|
|
|
|
|
|
|
|
|
// 培训计划已发布
|
|
@@ -69,45 +61,58 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
public void endReminderEmail() {
|
|
|
// 获取培训计划
|
|
|
List<PlanDo> planDoList = planService.list(new LambdaQueryWrapper<PlanDo>().eq(BaseDo::getDeleted, "0")
|
|
|
- .eq(PlanDo::getPublish, TRAINING_PLAN_PUBLISH));
|
|
|
+ .eq(PlanDo::getPublish, TRAINING_PLAN_PUBLISH)
|
|
|
+ .last("and( DATEDIFF(TRAININGENDTIMT, NOW()) =3 or DATEDIFF(TRAININGENDTIMT, NOW()) =0)"));
|
|
|
if (planDoList.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
log.info("获取到培训计划:{}", planDoList);
|
|
|
- // 根据培训计划获取对应的试卷信息
|
|
|
- List<PlanPaperDo> planPaperList = planPaperService.list(new LambdaQueryWrapper<PlanPaperDo>()
|
|
|
+ List<String> planId = planDoList.stream().map(PlanDo::getId).collect(Collectors.toList());
|
|
|
+ List<PlanCourseDo> planCourseDoList = planCourseService.list(new LambdaQueryWrapper<PlanCourseDo>()
|
|
|
.eq(BaseDo::getDeleted, "0")
|
|
|
- .in(PlanPaperDo::getTrainingplanid, planDoList.stream().map(PlanDo::getId).collect(Collectors.toSet())));
|
|
|
- log.info("获取到的试卷信息:{}", planPaperList);
|
|
|
+ .in(PlanCourseDo::getTrainingplanid,planId));
|
|
|
+ // 根据培训计划获取对应的试卷信息
|
|
|
+// List<PlanPaperDo> planPaperList = planPaperService.list(new LambdaQueryWrapper<PlanPaperDo>()
|
|
|
+// .eq(BaseDo::getDeleted, "0")
|
|
|
+// .in(PlanPaperDo::getTrainingplanid, planDoList.stream().map(PlanDo::getId).collect(Collectors.toSet())));
|
|
|
+
|
|
|
+ log.info("获取到的课程信息:{}", planCourseDoList);
|
|
|
// 筛选出距离截止日期还有3天的试卷信息
|
|
|
- List<PlanPaperDo> closePlanPaper = planPaperList
|
|
|
- .parallelStream()
|
|
|
- .filter(planPaper -> planPaper.getDeadline() != null && sendMailService.aFewDaysApart(planPaper.getDeadline()) == 3)
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (closePlanPaper.isEmpty()) {
|
|
|
- return;
|
|
|
- }
|
|
|
+// List<PlanPaperDo> closePlanPaper = planPaperList
|
|
|
+// .parallelStream()
|
|
|
+// .filter(planPaper -> planPaper.getDeadline() != null && sendMailService.aFewDaysApart(planPaper.getDeadline()) == 3)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// if (closePlanPaper.isEmpty()) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
// 即将截止的试卷Id
|
|
|
- Set<String> paperId = closePlanPaper.stream().map(PlanPaperDo::getPaperid).collect(Collectors.toSet());
|
|
|
- // 试卷所属的培训计划
|
|
|
- Set<String> planId = closePlanPaper.stream().map(PlanPaperDo::getTrainingplanid).collect(Collectors.toSet());
|
|
|
- /*****获取没有参与考试的培训员工******/
|
|
|
- List<EmpExamDo> toTestInfoList = empExamService.list(new LambdaQueryWrapper<EmpExamDo>()
|
|
|
- .eq(BaseDo::getDeleted, "0").eq(EmpExamDo::getExamstatus, "待考试").in(EmpExamDo::getPlanid, planId)
|
|
|
- .in(EmpExamDo::getPaperid, paperId));
|
|
|
+// Set<String> paperId = closePlanPaper.stream().map(PlanPaperDo::getPaperid).collect(Collectors.toSet());
|
|
|
+// // 试卷所属的培训计划
|
|
|
+// Set<String> planId = closePlanPaper.stream().map(PlanPaperDo::getTrainingplanid).collect(Collectors.toSet());
|
|
|
+ /*****获取没有参与课程培训的培训员工******/
|
|
|
+ List<EmpCourseDo> toTestInfoList = empCourseService.list(new LambdaQueryWrapper<EmpCourseDo>()
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
+ .in(EmpCourseDo::getPlanid, planId)
|
|
|
+ .in(EmpCourseDo::getPlancourseid,planCourseDoList.stream().map(PlanCourseDo::getId))
|
|
|
+ .last("and COURSETIME*60 <> ifnull(COURSEUSETIME,0)")
|
|
|
+ );
|
|
|
if (toTestInfoList.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
- // 按照培训计划ID 进行分组
|
|
|
- Map<String, List<EmpExamDo>> infoMap = toTestInfoList.stream()
|
|
|
- .collect(Collectors.groupingBy(EmpExamDo::getPlanid, Collectors.toList()));
|
|
|
+ // 对数据按照 培训计划已经课程信息进行分组
|
|
|
+ Map<String, Map<String, List<String>>> collect = toTestInfoList.stream()
|
|
|
+ .collect(Collectors.groupingBy(EmpCourseDo::getPlanid, Collectors.groupingBy(EmpCourseDo::getCoursename,
|
|
|
+ Collectors.mapping(EmpCourseDo::getEmpid,Collectors.toList()))));
|
|
|
+
|
|
|
// 发送考试截止提醒邮件
|
|
|
- infoMap.forEach((k, v) -> {
|
|
|
+ collect.forEach((k, v) -> {
|
|
|
PlanDo planDo = planDoList.stream().filter(info -> info.getId().equals(k)).findFirst().get();
|
|
|
- log.info("准备发送考试截止提醒邮件");
|
|
|
- CXCommonUtils.sendNotify(CUT_OFF_TRAIN_TITLE, String.format(CUT_OFF_TRAIN_CONTENT, planDo.getTrainingendtimt()), "",
|
|
|
- v.stream().map(EmpExamDo::getEmpid).distinct().filter(StringUtils::isNotBlank).collect(Collectors.toList())
|
|
|
- , planDo.getId(), TRAINING);
|
|
|
+ v.forEach((courseName,infos)->{
|
|
|
+ log.info("准备发送课程截止提醒邮件");
|
|
|
+ CXCommonUtils.sendNotify(CUT_OFF_TRAIN_TITLE, String.format(CUT_OFF_TRAIN_CONTENT,courseName, planDo.getTrainingendtimt()), "",
|
|
|
+ infos.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList())
|
|
|
+ , planDo.getId(), TRAINING);
|
|
|
+ });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -196,12 +201,12 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
public void sendTrainingPlanNotify(Map<PlanDo, Set<String>> planAndUserIdMap) {
|
|
|
// 获取用户id
|
|
|
planAndUserIdMap.forEach((k, v) -> {
|
|
|
- CXCommonUtils.sendNotify(TRAIN_NOTIFY_TITLE, String.format(TRAIN_NOTIFY_CONTENT, k.getCoursename(),
|
|
|
- k.getTrainingstarttime(), k.getTrainingendtimt()), "", new ArrayList<>(v),
|
|
|
- k.getId(), TRAINING);
|
|
|
- CXCommonUtils.sendNotify(COURSE_NOTIFY_TITLE, String.format(TRAIN_NOTIFY_CONTENT, k.getCoursename(),
|
|
|
- k.getTrainingstarttime(), k.getTrainingendtimt()), "", new ArrayList<>(v),
|
|
|
- k.getId(), COURSE);
|
|
|
+// CXCommonUtils.sendNotify(TRAIN_NOTIFY_TITLE, String.format(TRAIN_NOTIFY_CONTENT, k.getCoursename(),
|
|
|
+// k.getTrainingstarttime(), k.getTrainingendtimt()), "", new ArrayList<>(v),
|
|
|
+// k.getId(), TRAINING);
|
|
|
+// CXCommonUtils.sendNotify(COURSE_NOTIFY_TITLE, String.format(TRAIN_NOTIFY_CONTENT, k.getCoursename(),
|
|
|
+// k.getTrainingstarttime(), k.getTrainingendtimt()), "", new ArrayList<>(v),
|
|
|
+// k.getId(), COURSE);
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -211,10 +216,10 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
*
|
|
|
* @param planAndUserIdMap
|
|
|
*/
|
|
|
- public void sendTrainingPlanCancelNotify(Map<PlanDo, Set<String>> planAndUserIdMap) {
|
|
|
+ public void sendTrainingPlanCancelNotify(Map<String, List<String>> planAndUserIdMap) {
|
|
|
planAndUserIdMap.forEach((k, v) -> {
|
|
|
- CXCommonUtils.sendNotify(CANCEL_TRAIN_TITLE, String.format(CANCEL_TRAIN_CONTENT, k.getCoursename()), "",
|
|
|
- new ArrayList<>(v), null, TRAINING);
|
|
|
+ CXCommonUtils.sendNotify(CANCEL_TRAIN_TITLE, String.format(CANCEL_TRAIN_CONTENT, k), "",
|
|
|
+ v, null, TRAINING);
|
|
|
});
|
|
|
}
|
|
|
|