|
|
@@ -112,13 +112,13 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
request.setId(record.getId());
|
|
|
List<CoreEduTrainingPlanPageVo> children = coreEduTrainingPlanMapper.selectChildrenPlan(request);
|
|
|
record.setChildren(children);
|
|
|
- record.setHasChildren(ObjectUtil.isNotEmpty(children));
|
|
|
for (CoreEduTrainingPlanPageVo child : children) {
|
|
|
if (ObjectUtil.equal(child.getCreateOrgId(), orgId)) {
|
|
|
child.setCreateByTopOrg(1);
|
|
|
}
|
|
|
child.setPlanRoleNameList(roleNameList);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -265,13 +265,18 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
Long planId = plan.getId();
|
|
|
//删除原有数据, 然后重新生成计划,任务
|
|
|
List<Long> planIdList = coreEduTrainingPlanMapper.selectIdByParentId(planId);
|
|
|
- coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
|
|
|
- coreEduTrainingPlanToExecOrgMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToExecOrg>().in(CoreEduTrainingPlanToExecOrg::getPlanId, planIdList));
|
|
|
- coreEduTrainingPlanToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToRole>().in(CoreEduTrainingPlanToRole::getPlanId, planIdList));
|
|
|
+ if (ObjectUtil.isNotEmpty(planIdList)) {
|
|
|
+ coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
|
|
|
+ coreEduTrainingPlanToExecOrgMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToExecOrg>().in(CoreEduTrainingPlanToExecOrg::getPlanId, planIdList));
|
|
|
+ coreEduTrainingPlanToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToRole>().in(CoreEduTrainingPlanToRole::getPlanId, planIdList));
|
|
|
+ }
|
|
|
List<CoreEduTrainingTask> taskIdList = coreEduTrainingTaskMapper.selectList(new LambdaQueryWrapper<CoreEduTrainingTask>().in(CoreEduTrainingTask::getPlanId, planIdList).select(CoreEduTrainingTask::getId));
|
|
|
List<Long> collect = taskIdList.stream().map(CoreEduTrainingTask::getId).collect(Collectors.toList());
|
|
|
- coreEduTrainingTaskMapper.deleteBatchIds(collect);
|
|
|
- coreEduTrainingTaskToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingTaskToRole>().in(CoreEduTrainingTaskToRole::getEduTrainingTaskId, collect));
|
|
|
+ if (ObjectUtil.isNotEmpty(collect)) {
|
|
|
+ coreEduTrainingTaskMapper.deleteBatchIds(collect);
|
|
|
+ coreEduTrainingTaskToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingTaskToRole>().in(CoreEduTrainingTaskToRole::getEduTrainingTaskId, collect));
|
|
|
+
|
|
|
+ }
|
|
|
List<CoreEduTrainingPlan> planList = buildPlanData(plan, trainingPlanToRoleList);
|
|
|
|
|
|
for (CoreEduTrainingPlan trainingPlan : planList) {
|
|
|
@@ -406,17 +411,53 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
/**
|
|
|
* 批量删除教育培训计划
|
|
|
*
|
|
|
- * @param ids 需要删除的教育培训计划主键
|
|
|
+ * @param id 需要删除的教育培训计划主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int deleteCoreEduTrainingPlanByIds(Long[] ids) {
|
|
|
- Integer count = coreEduTrainingTaskMapper.checkHasTaskIsDone(Arrays.asList(ids));
|
|
|
+ public int deleteCoreEduTrainingPlanByIds(Long id) {
|
|
|
+ Integer count = coreEduTrainingTaskMapper.checkHasTaskIsDone(Collections.singletonList(id));
|
|
|
if (count != null && count > 0) {
|
|
|
throw new RuntimeException("已有任务完成,无法删除");
|
|
|
}
|
|
|
- return coreEduTrainingPlanMapper.deleteBatchIds(Arrays.asList((ids)));
|
|
|
+ final Integer done = coreEduTrainingTaskMapper.checkHasTaskIsDoneByPlanParentId(id);
|
|
|
+ if (done != null && done > 0) {
|
|
|
+ throw new RuntimeException("已有任务完成,无法删除");
|
|
|
+ }
|
|
|
+ final CoreEduTrainingPlan plan = getById(id);
|
|
|
+ if (plan.getStandard() == 0) {
|
|
|
+ //自建计划
|
|
|
+ final List<CoreEduTrainingTask> coreEduTrainingTasks = coreEduTrainingTaskMapper.selectList(new LambdaQueryWrapper<CoreEduTrainingTask>()
|
|
|
+ .eq(CoreEduTrainingTask::getPlanId, id)
|
|
|
+ .select(CoreEduTrainingTask::getId));
|
|
|
+ final List<Long> taskIdList = coreEduTrainingTasks.stream().map(CoreEduTrainingTask::getId).collect(Collectors.toList());
|
|
|
+ //删除任务相关
|
|
|
+ if (ObjectUtil.isNotEmpty(taskIdList)){
|
|
|
+ coreEduTrainingTaskMapper.deleteBatchIds(taskIdList);
|
|
|
+ coreEduTrainingTaskToRoleMapper.deleteByMap(MapUtil.of("edu_training_task_id", taskIdList));
|
|
|
+ return coreEduTrainingPlanMapper.deleteBatchIds(Collections.singletonList((id)));
|
|
|
+ }
|
|
|
+ //删除计划
|
|
|
+ return coreEduTrainingPlanMapper.deleteBatchIds(Collections.singletonList((id)));
|
|
|
+ } else {
|
|
|
+ //标准计划
|
|
|
+ List<Long> planIdList = coreEduTrainingPlanMapper.selectIdByParentId(id);
|
|
|
+ if (ObjectUtil.isNotEmpty(planIdList)) {
|
|
|
+ //删除任务相关
|
|
|
+ final List<CoreEduTrainingTask> trainingTaskList = coreEduTrainingTaskMapper.selectList(new LambdaQueryWrapper<CoreEduTrainingTask>()
|
|
|
+ .in(CoreEduTrainingTask::getPlanId, planIdList)
|
|
|
+ .select(CoreEduTrainingTask::getId));
|
|
|
+ final List<Long> taskIdList = trainingTaskList.stream().map(CoreEduTrainingTask::getId).collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(taskIdList)){
|
|
|
+ coreEduTrainingTaskMapper.deleteBatchIds(taskIdList);
|
|
|
+ coreEduTrainingTaskToRoleMapper.deleteByMap(MapUtil.of("edu_training_task_id", taskIdList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //删除计划
|
|
|
+ planIdList.add(id);
|
|
|
+ return coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|