|
|
@@ -35,6 +35,7 @@ import com.xunmei.common.core.enums.drill.DrillPlanStatus;
|
|
|
import com.xunmei.common.core.enums.edu.EduTrainingDoStatus;
|
|
|
import com.xunmei.common.core.enums.edu.EduTrainingPlanCycleEnum;
|
|
|
import com.xunmei.common.core.enums.edu.EduTrainingPlanStatus;
|
|
|
+import com.xunmei.common.core.exception.ServiceException;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
import com.xunmei.common.core.util.BeanHelper;
|
|
|
import com.xunmei.common.core.utils.AssertUtil;
|
|
|
@@ -66,6 +67,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
|
|
|
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
|
|
|
|
|
+import java.time.Duration;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -641,6 +643,7 @@ public class CoreDrillPlanServiceImpl extends ServiceImpl<CoreDrillPlanMapper, C
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void deleteCoreDrillPlanByIds(Long id) {
|
|
|
+ checkPlanIsCreatingTask(id,"删除");
|
|
|
List<Long> list = baseMapper.selectIdByParentId(id);
|
|
|
if (ObjectUtil.isEmpty(list)) {
|
|
|
//说明没有下发,还是草稿状态
|
|
|
@@ -734,12 +737,20 @@ public class CoreDrillPlanServiceImpl extends ServiceImpl<CoreDrillPlanMapper, C
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
planListFuture.thenAcceptAsync((result) -> {
|
|
|
+ String redisKey="Drill_Creating_Task" + planId;
|
|
|
+ RedisUtils.deleteObject(redisKey);
|
|
|
+ //仅当hashKey不存在时才设置
|
|
|
+ Boolean hasKey = RedisUtils.hasKey(redisKey);
|
|
|
+ if (!hasKey) {
|
|
|
+ RedisUtils.setCacheObject(redisKey, planId, Duration.ofMillis(1000 * 60*5));
|
|
|
+ }
|
|
|
for (CoreDrillPlan drillPlan : result) {
|
|
|
if (checkCanBuildTaskNow(drillPlan)) {
|
|
|
final CoreDrillPlanDataVo detailPlanData = getCoreDrillPlanDataVo(drillPlan.getId());
|
|
|
coreDrillTaskService.createTaskForNow(detailPlanData, drillPlan.getPlanStartDate(), drillPlan.getPlanEndDate());
|
|
|
}
|
|
|
}
|
|
|
+ RedisUtils.deleteObject(redisKey);
|
|
|
}, threadPoolTaskExecutor);
|
|
|
|
|
|
|
|
|
@@ -771,9 +782,19 @@ public class CoreDrillPlanServiceImpl extends ServiceImpl<CoreDrillPlanMapper, C
|
|
|
|| ObjectUtil.equal(orgType, OrgTypeEnum.YINGYE_WANGDIAN.getCode());
|
|
|
}
|
|
|
|
|
|
+ private void checkPlanIsCreatingTask(Long planId,String msg)
|
|
|
+ {
|
|
|
+ String redisKey="Drill_Creating_Task" + planId;
|
|
|
+ Boolean hasKey = RedisUtils.hasKey(redisKey);
|
|
|
+ if (hasKey) {
|
|
|
+ throw new ServiceException("该计划正在生成任务,现在不能被"+msg+",请稍后再试。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int revocationPlan(Long planId) {
|
|
|
+ checkPlanIsCreatingTask(planId,"撤回");
|
|
|
List<Long> list = coreDrillPlanMapper.selectIdByParentId(planId);
|
|
|
Integer isExecute = coreDrillTaskMapper.selectCount(new LambdaQueryWrapper<CoreDrillTask>()
|
|
|
.in(CoreDrillTask::getPlanId, list)
|