|
@@ -6,12 +6,10 @@ import com.rongwei.rwadmincommon.system.domain.SysUserDo;
|
|
|
import com.rongwei.rwadmincommon.system.service.SysUserOrgService;
|
|
|
import com.rongwei.rwadmincommon.system.vo.SysUserVo;
|
|
|
import com.rongwei.rwcommon.base.BaseDo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
import com.rongwei.rwcommon.utils.StringUtils;
|
|
|
import com.rongwei.safecommon.utils.CXCommonUtils;
|
|
|
-import com.rongwei.training.domain.EmpCourseDo;
|
|
|
-import com.rongwei.training.domain.PlanCourseDo;
|
|
|
-import com.rongwei.training.domain.PlanDo;
|
|
|
-import com.rongwei.training.domain.TrainingDemandSurveyBackupsDo;
|
|
|
+import com.rongwei.training.domain.*;
|
|
|
import com.rongwei.trainingcommon.sys.service.EmpExamService;
|
|
|
import com.rongwei.trainingcommon.sys.service.PlanPaperService;
|
|
|
import com.rongwei.trainingcommon.sys.service.PlanService;
|
|
@@ -61,19 +59,20 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
private static final String TRAINING_PLAN_PUBLISH = "y";
|
|
|
|
|
|
@Override
|
|
|
- public void endReminderEmail() {
|
|
|
+ public R endReminderEmail() {
|
|
|
// 获取培训计划
|
|
|
List<PlanDo> planDoList = planService.list(new LambdaQueryWrapper<PlanDo>().eq(BaseDo::getDeleted, "0")
|
|
|
.eq(PlanDo::getPublish, TRAINING_PLAN_PUBLISH)
|
|
|
.last("and( DATEDIFF(TRAININGENDTIMT, NOW()) =3 or DATEDIFF(TRAININGENDTIMT, NOW()) =0)"));
|
|
|
if (planDoList.isEmpty()) {
|
|
|
- return;
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
log.info("获取到培训计划:{}", planDoList);
|
|
|
List<String> planId = planDoList.stream().map(PlanDo::getId).collect(Collectors.toList());
|
|
|
List<PlanCourseDo> planCourseDoList = planCourseService.list(new LambdaQueryWrapper<PlanCourseDo>()
|
|
|
.eq(BaseDo::getDeleted, "0")
|
|
|
.in(PlanCourseDo::getTrainingplanid,planId));
|
|
|
+
|
|
|
// 根据培训计划获取对应的试卷信息
|
|
|
// List<PlanPaperDo> planPaperList = planPaperService.list(new LambdaQueryWrapper<PlanPaperDo>()
|
|
|
// .eq(BaseDo::getDeleted, "0")
|
|
@@ -94,29 +93,70 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
// 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).collect(Collectors.toList()))
|
|
|
- .last("and COURSETIME*60 <> ifnull(COURSEUSETIME,0)")
|
|
|
- );
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
+ .in(EmpCourseDo::getPlanid, planId)
|
|
|
+ .in(EmpCourseDo::getPlancourseid, planCourseDoList.stream().map(PlanCourseDo::getId).collect(Collectors.toList()))
|
|
|
+ .last("and COURSETIME*60 <> ifnull(COURSEUSETIME,0)")
|
|
|
+ );
|
|
|
if (toTestInfoList.isEmpty()) {
|
|
|
- return;
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
// 对数据按照 培训计划已经课程信息进行分组
|
|
|
Map<String, Map<String, List<String>>> collect = toTestInfoList.stream()
|
|
|
.collect(Collectors.groupingBy(EmpCourseDo::getPlanid, Collectors.groupingBy(EmpCourseDo::getCoursename,
|
|
|
Collectors.mapping(EmpCourseDo::getEmpid,Collectors.toList()))));
|
|
|
|
|
|
- // 发送考试截止提醒邮件
|
|
|
+ // 发送培训课程截止提醒邮件
|
|
|
collect.forEach((k, v) -> {
|
|
|
PlanDo planDo = planDoList.stream().filter(info -> info.getId().equals(k)).findFirst().get();
|
|
|
- v.forEach((courseName,infos)->{
|
|
|
+ v.forEach((courseName, infos) -> {
|
|
|
log.info("准备发送课程截止提醒邮件");
|
|
|
- CXCommonUtils.sendNotify(CUT_OFF_TRAIN_TITLE, String.format(CUT_OFF_TRAIN_CONTENT,planDo.getCoursename(), planDo.getTrainingendtimt()), "",
|
|
|
- infos.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList())
|
|
|
- , planDo.getId(), TRAINING);
|
|
|
+ CXCommonUtils.sendNotify(CUT_OFF_TRAIN_TITLE, String.format(CUT_OFF_TRAIN_CONTENT, planDo.getCoursename(), planDo.getTrainingendtimt()), "",
|
|
|
+ infos.stream().filter(StringUtils::isNotBlank).collect(Collectors.toList())
|
|
|
+ , planDo.getId(), COURSE);
|
|
|
});
|
|
|
});
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 培训试卷截止提醒
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public R endReminderPaperMail() {
|
|
|
+ // 获取培训计划
|
|
|
+ List<PlanDo> planDoList = planService.list(new LambdaQueryWrapper<PlanDo>().eq(BaseDo::getDeleted, "0")
|
|
|
+ .eq(PlanDo::getPublish, TRAINING_PLAN_PUBLISH));
|
|
|
+ if (planDoList.isEmpty()) {
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ List<String> planIds = planDoList.stream().map(PlanDo::getId).collect(Collectors.toList());
|
|
|
+ // 获取培训计划中 截止日期在3天和0填的试卷信息
|
|
|
+ List<PlanPaperDo> planPaperDos = planPaperService.list(new LambdaQueryWrapper<PlanPaperDo>()
|
|
|
+ .in(PlanPaperDo::getTrainingplanid, planIds)
|
|
|
+ .eq(BaseDo::getDeleted, "0")
|
|
|
+ .last("and( DATEDIFF(deadline, NOW()) =3 or DATEDIFF(deadline, NOW()) =0)")
|
|
|
+ );
|
|
|
+ List<String> planPaperIds = planPaperDos.stream().map(PlanPaperDo::getId).collect(Collectors.toList());
|
|
|
+ // 获取所有未考试的用户信息
|
|
|
+ List<EmpExamDo> examDoList = empExamService.list(new LambdaQueryWrapper<EmpExamDo>().eq(BaseDo::getDeleted, "0")
|
|
|
+ .in(EmpExamDo::getPlanid, planIds)
|
|
|
+ .in(EmpExamDo::getPlanpaperid,planPaperIds)
|
|
|
+ .eq(EmpExamDo::getExamstatus, "待考试")
|
|
|
+ );
|
|
|
+ Map<String, List<String>> paperMap = new HashMap<>();
|
|
|
+ // 对试卷按照试卷名称分组
|
|
|
+ Map<String, List<EmpExamDo>> collect = examDoList.stream().collect(Collectors.groupingBy(EmpExamDo::getPapername, Collectors.toList()));
|
|
|
+ collect.forEach((k,v)->{
|
|
|
+ paperMap.put(k, examDoList.stream().map(EmpExamDo::getEmpid).distinct().collect(Collectors.toList()));
|
|
|
+ });
|
|
|
+ // 培训课程取消提醒
|
|
|
+ paperMap.forEach((k, v) -> {
|
|
|
+ CXCommonUtils.sendNotify(CUT_OFF_PAPER_TITLE, String.format(CUT_OFF_PAPER_CONTENT, k), "",
|
|
|
+ v, null, TRAINING);
|
|
|
+ });
|
|
|
+ return R.ok();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -217,13 +257,19 @@ public class TrainingSendNotifyServiceImpl implements TrainingSendNotifyService
|
|
|
/**
|
|
|
* 培训计划取消提醒
|
|
|
*
|
|
|
- * @param planAndUserIdMap
|
|
|
+ * @param courseMap
|
|
|
+ * @param paperMap
|
|
|
*/
|
|
|
- public void sendTrainingPlanCancelNotify(Map<String, List<String>> planAndUserIdMap) {
|
|
|
- planAndUserIdMap.forEach((k, v) -> {
|
|
|
+ public void sendTrainingPlanCancelNotify(Map<String, List<String>> courseMap,
|
|
|
+ Map<String, List<String>> paperMap) {
|
|
|
+ courseMap.forEach((k, v) -> {
|
|
|
CXCommonUtils.sendNotify(CANCEL_TRAIN_TITLE, String.format(CANCEL_TRAIN_CONTENT, k), "",
|
|
|
v, null, COURSE);
|
|
|
});
|
|
|
+ paperMap.forEach((k, v) -> {
|
|
|
+ CXCommonUtils.sendNotify(CANCEL_TRAIN_TITLE, String.format(CANCEL_TRAIN_CONTENT, k), "",
|
|
|
+ v, null, TRAINING);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|