|
|
@@ -60,6 +60,7 @@ import com.xunmei.core.edu.service.ICoreEduTrainingPlanToRoleService;
|
|
|
import com.xunmei.core.edu.service.ICoreEduTrainingTaskService;
|
|
|
import com.xunmei.core.registerbook.service.ICoreRegisterBookPdfService;
|
|
|
import com.xunmei.core.reminder.service.ICoreReminderConfigurationService;
|
|
|
+import com.xunmei.core.reminder.service.ICoreReminderScheduleService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.domain.SysUser;
|
|
|
@@ -120,7 +121,8 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
private ICoreReminderConfigurationService reminderConfigurationService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ ICoreReminderScheduleService reminderScheduleService;
|
|
|
@Override
|
|
|
public TableDataInfo selectPage(CoreEduTrainingPlanPageDto request) throws InterruptedException {
|
|
|
|
|
|
@@ -644,12 +646,11 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void checkPlanIsCreatingTask(Long planId,String msg)
|
|
|
- {
|
|
|
- String redisKey="Edu_Creating_Task" + planId;
|
|
|
+ private void checkPlanIsCreatingTask(Long planId, String msg) {
|
|
|
+ String redisKey = "Edu_Creating_Task" + planId;
|
|
|
Boolean hasKey = RedisUtils.hasKey(redisKey);
|
|
|
if (hasKey) {
|
|
|
- throw new ServiceException("该任务正在生成中,现在不能被"+msg+",请稍后再试。");
|
|
|
+ throw new ServiceException("该任务正在生成中,现在不能被" + msg + ",请稍后再试。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -662,7 +663,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleteCoreEduTrainingPlanByIds(Long id) {
|
|
|
- checkPlanIsCreatingTask(id,"删除");
|
|
|
+ checkPlanIsCreatingTask(id, "删除");
|
|
|
List<Long> list = baseMapper.selectIdByParentId(id);
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
//说明没有下发,还是草稿状态
|
|
|
@@ -681,12 +682,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
} else {
|
|
|
//计划下有已完成:删除本轮次及以后的所有任务,计划本身做逻辑删除。
|
|
|
final CoreEduTrainingPlan plan = getById(id);
|
|
|
- Date date=null;
|
|
|
+ Date date = null;
|
|
|
if (plan.getPlanCycle().equals(EduTrainingPlanCycleEnum.NONE.getCode())) {
|
|
|
- date=DateUtil.beginOfDay(new Date());
|
|
|
+ date = DateUtil.beginOfDay(new Date());
|
|
|
} else {
|
|
|
final DateRange range = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
- date=DateUtil.beginOfDay(range.getStartTime());
|
|
|
+ date = DateUtil.beginOfDay(range.getStartTime());
|
|
|
}
|
|
|
final List<Long> del = coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(list, date, null);
|
|
|
for (Long taskId : del) {
|
|
|
@@ -776,11 +777,11 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
planListFuture.thenAcceptAsync((result) -> {
|
|
|
- String redisKey="Edu_Creating_Task" + planId;
|
|
|
+ String redisKey = "Edu_Creating_Task" + planId;
|
|
|
RedisUtils.deleteObject(redisKey);
|
|
|
Boolean hasKey = RedisUtils.hasKey(redisKey);
|
|
|
if (!hasKey) {
|
|
|
- RedisUtils.setCacheObject(redisKey, planId, Duration.ofMillis(1000 * 60*5));
|
|
|
+ RedisUtils.setCacheObject(redisKey, planId, Duration.ofMillis(1000 * 60 * 5));
|
|
|
}
|
|
|
for (CoreEduTrainingPlan eduPlan : result) {
|
|
|
if (checkCanBuildTaskNow(eduPlan)) {
|
|
|
@@ -911,7 +912,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer revocationPlan(Long planId) {
|
|
|
- checkPlanIsCreatingTask(planId,"撤回");
|
|
|
+ checkPlanIsCreatingTask(planId, "撤回");
|
|
|
List<Long> list = coreEduTrainingPlanMapper.selectIdByParentId(planId);
|
|
|
Integer isExecute = coreEduTrainingTaskMapper.selectCount(new LambdaQueryWrapper<CoreEduTrainingTask>()
|
|
|
.in(CoreEduTrainingTask::getPlanId, list)
|
|
|
@@ -1003,6 +1004,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}
|
|
|
|
|
|
private static final Set<OrgTypeEnum> INVALID_ORG_TYPES = Sets.newHashSet(OrgTypeEnum.SHEGN_LIAN_SHE, OrgTypeEnum.BAN_SHI_CHU, OrgTypeEnum.DIQU_HANG_SHE);
|
|
|
+
|
|
|
private void deducePlanAndBuildTask(CoreEduTrainingPlan trainingPlan, List<Long> orgIdList, List<SysOrgVO> orgCacheList) {
|
|
|
List<SysOrgVO> orgList = orgCacheList.stream().filter(org -> orgIdList.contains(org.getId())).collect(toList());
|
|
|
if (orgList.isEmpty()) {
|
|
|
@@ -1026,7 +1028,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
Map<String, Object> map = getHsOrg(orgCacheList, orgList, orgTypeEnum);
|
|
|
List<Long> hsPlanIdList = allHsPlanList.stream().map(CoreEduTrainingPlan::getId).collect(toList());
|
|
|
List<Long> hsOrgIdList = ((List<SysOrgVO>) map.get("list")).stream().map(SysOrgVO::getId).collect(toList());
|
|
|
- if (ObjectUtil.hasEmpty(hsPlanIdList, hsOrgIdList)){
|
|
|
+ if (ObjectUtil.hasEmpty(hsPlanIdList, hsOrgIdList)) {
|
|
|
return;
|
|
|
}
|
|
|
List<CoreEduTrainingPlan> reallyPlanIdList = findReallyPlanIdList(hsPlanIdList, hsOrgIdList);
|
|
|
@@ -1049,6 +1051,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
private void create(CoreEduTrainingPlan plan, List<Long> idList, ThreadPoolTaskExecutor executor) {
|
|
|
Long planId = plan.getId();
|
|
|
Date planStartDate = plan.getStartDate();
|
|
|
@@ -1120,17 +1123,18 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
map.put("underHsOrgType", underHsOrgType);
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void run(Runnable runnable, ThreadPoolTaskExecutor threadPoolTaskExecutor) {
|
|
|
CompletableFuture.runAsync(runnable, threadPoolTaskExecutor);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String,String>> queryPlanBySendModule() {
|
|
|
- LambdaQueryWrapper<CoreEduTrainingPlan> wrapper=new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(CoreEduTrainingPlan::getPlanStatus,DrillPlanStatus.USING.getCode());
|
|
|
- wrapper.eq(CoreEduTrainingPlan::getDeleted,0);
|
|
|
- wrapper.eq(CoreEduTrainingPlan::getStandard,1);
|
|
|
+ public List<Map<String, String>> queryPlanBySendModule() {
|
|
|
+ LambdaQueryWrapper<CoreEduTrainingPlan> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(CoreEduTrainingPlan::getPlanStatus, DrillPlanStatus.USING.getCode());
|
|
|
+ wrapper.eq(CoreEduTrainingPlan::getDeleted, 0);
|
|
|
+ wrapper.eq(CoreEduTrainingPlan::getStandard, 1);
|
|
|
List<CoreEduTrainingPlan> eduTrainingPlans = baseMapper.selectList(wrapper);
|
|
|
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
|
|
for (CoreEduTrainingPlan plan : eduTrainingPlans) {
|
|
|
@@ -1144,8 +1148,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
@Override
|
|
|
public List<CoreReminderSchedule> findTaskAndBuildReminderSchedule(List<CoreReminderConfigurationFullVo> configurationList) {
|
|
|
+ List<CoreReminderSchedule> exitTaskList = reminderScheduleService.findBySendModule(BusinessPlanType.EDU_TRAINING.getCode());
|
|
|
List<CoreReminderSchedule> scheduleArrayList = new ArrayList<>();
|
|
|
for (CoreReminderConfigurationFullVo configuration : configurationList) {
|
|
|
+ List<CoreReminderSchedule> exitTaskBySendModule = exitTaskList.stream().filter(r -> ObjectUtil.equal(r.getSendModule(), configuration.getSendModule())).collect(Collectors.toList());
|
|
|
Long planId = configuration.getPlanId();
|
|
|
//此计划可能是省联社或者行社创建的父计划
|
|
|
CoreEduTrainingPlan plan = getById(planId);
|
|
|
@@ -1172,21 +1178,18 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
list = coreEduTrainingTaskService.selectTaskByHsPlanIdList(allHsPlanIdList, startTime, endTime);
|
|
|
|
|
|
- if (ObjectUtil.isEmpty(list)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- //走到此处说明计划是行社创建的
|
|
|
- Date startTime = DateUtil.beginOfDay(new Date());
|
|
|
- Date endTime = DateUtil.endOfDay(new Date());
|
|
|
- if (CycleCommonEnum.NONE.getCode().equals(plan.getPlanCycle())) {
|
|
|
+ } else {
|
|
|
CycleCommonEnum commonEnum = CycleCommonEnum.getEnum(plan.getPlanCycle());
|
|
|
DateRange startAndEnd = DateUtils.getStartAndEnd(new Date(), commonEnum);
|
|
|
- startTime = startAndEnd.getStartTime();
|
|
|
- endTime = startAndEnd.getEndTime();
|
|
|
+ Date startTime = startAndEnd.getStartTime();
|
|
|
+ Date endTime = startAndEnd.getEndTime();
|
|
|
+ //走到此处说明计划是行社创建的
|
|
|
+ if (CycleCommonEnum.NONE.getCode().equals(plan.getPlanCycle())) {
|
|
|
+ startTime = DateUtil.beginOfDay(new Date());
|
|
|
+ endTime = DateUtil.endOfDay(new Date());
|
|
|
+ }
|
|
|
+ list = coreEduTrainingTaskService.selectTaskByHsPlanIdList(Lists.newArrayList(plan.getId()), startTime, endTime);
|
|
|
}
|
|
|
- list = coreEduTrainingTaskService.selectTaskByHsPlanIdList(Lists.newArrayList(plan.getId()), startTime, endTime);
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -1194,23 +1197,43 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
if (ObjectUtil.isEmpty(notificationUser)) {
|
|
|
continue;
|
|
|
}
|
|
|
+ List<SysOrgVO> cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
|
|
|
Map<Long, List<SysUser>> userMap = notificationUser.stream().collect(Collectors.groupingBy(SysUser::getOrgId));
|
|
|
+ for (Map.Entry<Long, List<SysUser>> userEntry : userMap.entrySet()) {
|
|
|
+ Long orgId = userEntry.getKey();
|
|
|
+ List<SysUser> userList = userEntry.getValue();
|
|
|
+ Optional<SysOrgVO> first = cacheList.stream().filter(org -> org.getId().equals(orgId)).findFirst();
|
|
|
+ if (!first.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String path = first.get().getPath();
|
|
|
+ List<CoreEduTrainingTask> taskList = list.stream().filter(task -> task.getOrgPath().contains(path)).collect(Collectors.toList());
|
|
|
|
|
|
- for (CoreEduTrainingTask task : list) {
|
|
|
- List<SysUser> userList = userMap.get(task.getOrgId());
|
|
|
- if (ObjectUtil.isEmpty(userList)) {
|
|
|
+ if (ObjectUtil.isEmpty(taskList)) {
|
|
|
continue;
|
|
|
}
|
|
|
for (SysUser sysUser : userList) {
|
|
|
- //找到每个任务的提醒时间
|
|
|
- Date notificationTime = reminderConfigurationService.getNotificationTime(task.getStartDate(),task.getEndDate(), configuration);
|
|
|
- CoreReminderSchedule schedule = new CoreReminderSchedule();
|
|
|
- schedule.setConfigId(configuration.getConfigId());
|
|
|
- schedule.setScheduledTime(DateUtils.toLocalDateTime(notificationTime));
|
|
|
- schedule.setStatus(0);
|
|
|
- schedule.setRecipient(sysUser.getPhone());
|
|
|
- schedule.setScheduleId(IdWorker.getId());
|
|
|
- scheduleArrayList.add(schedule);
|
|
|
+ for (CoreEduTrainingTask task : taskList) {
|
|
|
+ boolean exit = exitTaskBySendModule.stream().anyMatch(t -> ObjectUtil.equal(t.getTaskId(), String.valueOf(task.getId())));
|
|
|
+ if (exit){
|
|
|
+ //说明任务已经存在短信提醒任务
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //找到每个任务的提醒时间
|
|
|
+ Date notificationTime = reminderConfigurationService.getNotificationTime(task.getStartDate(), task.getEndDate(), configuration);
|
|
|
+ CoreReminderSchedule schedule = new CoreReminderSchedule();
|
|
|
+ schedule.setConfigId(configuration.getConfigId());
|
|
|
+ schedule.setReminderType(configuration.getReminderType());
|
|
|
+ schedule.setSendModule(configuration.getSendModule());
|
|
|
+ schedule.setTaskId(task.getId().toString());
|
|
|
+ schedule.setTaskName(task.getTitle());
|
|
|
+ schedule.setScheduledTime(DateUtils.toLocalDateTime(notificationTime));
|
|
|
+ schedule.setStatus(0);
|
|
|
+ schedule.setRecipientName(sysUser.getName());
|
|
|
+ schedule.setRecipient(sysUser.getPhone());
|
|
|
+ schedule.setScheduleId(IdWorker.getId());
|
|
|
+ scheduleArrayList.add(schedule);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|