|  | @@ -360,7 +360,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |              coreEduTrainingTaskMapper.updateTaskNameByParentPlanId(planId, plan.getPlanName(), range.getStartTime(), range.getEndTime());
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              doUpdatePlan(plan, request);
 | 
	
		
			
				|  |  | -            delAllByParentPlanId(planId);
 | 
	
		
			
				|  |  | +            delAllByParentPlanId(plan);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              List<CoreEduTrainingPlan> planList = null;
 | 
	
		
			
				|  |  |              if (plan.getIssue() == 1) {
 | 
	
	
		
			
				|  | @@ -368,6 +368,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  planList = ListUtil.list(true, plan);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            if (checkOrgType(plan.getExecOrgType())) {
 | 
	
		
			
				|  |  | +                planList.add(plan);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              //List<CoreEduTrainingPlan> planList = buildPlanData(plan, null, false);
 | 
	
		
			
				|  |  |              List<CoreEduTrainingPlan> finalPlanList = planList;
 | 
	
		
			
				|  |  |              TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
 | 
	
	
		
			
				|  | @@ -392,20 +395,31 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void delAllByParentPlanId(Long planId) {
 | 
	
		
			
				|  |  | -        List<Long> planIdList = coreEduTrainingPlanMapper.selectIdByParentId(planId);
 | 
	
		
			
				|  |  | +    private void delAllByParentPlanId(CoreEduTrainingPlan plan) {
 | 
	
		
			
				|  |  | +        List<Long> planIdList = coreEduTrainingPlanMapper.selectIdByParentIdOrId(plan.getId());
 | 
	
		
			
				|  |  |          if (ObjectUtil.isEmpty(planIdList)) {
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
 | 
	
		
			
				|  |  | +        // 下发给省联社/办事处/行社的计划 在下发时会把id设置为parentId,所以这里不需要删除
 | 
	
		
			
				|  |  | +        if (plan.getId().equals(plan.getParentId())) {
 | 
	
		
			
				|  |  | +            List<Long> list = new ArrayList<>(planIdList);
 | 
	
		
			
				|  |  | +            list.remove(plan.getId());
 | 
	
		
			
				|  |  | +            if (!list.isEmpty()) {
 | 
	
		
			
				|  |  | +                coreEduTrainingPlanMapper.deleteBatchIds(list);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                coreEduTrainingPlanToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToRole>()
 | 
	
		
			
				|  |  | +                        .in(CoreEduTrainingPlanToRole::getPlanId, list));
 | 
	
		
			
				|  |  | +                coreEduTrainingPlanToExecOrgMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToExecOrg>()
 | 
	
		
			
				|  |  | +                        .in(CoreEduTrainingPlanToExecOrg::getPlanId, list));
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          coreEduTrainingPlanToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToRole>()
 | 
	
		
			
				|  |  |                  .in(CoreEduTrainingPlanToRole::getPlanId, planIdList));
 | 
	
		
			
				|  |  |          coreEduTrainingPlanToExecOrgMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToExecOrg>()
 | 
	
		
			
				|  |  |                  .in(CoreEduTrainingPlanToExecOrg::getPlanId, planIdList));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(planIdList, null, null);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private void populateProperties(CoreEduTrainingPlan source, CoreEduTrainingPlan target) {
 | 
	
	
		
			
				|  | @@ -598,7 +612,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |              return all.stream().filter(org -> collect.contains(org.getType())).collect(Collectors.toList());*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            return all.stream().filter(org->ObjectUtil.isNotNull(org.getType())).filter(org -> org.getType().equals(plan.getExecOrgType())).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            return all.stream().filter(org -> ObjectUtil.isNotNull(org.getType())).filter(org -> org.getType().equals(plan.getExecOrgType())).collect(Collectors.toList());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -620,8 +634,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |              List<Long> collect = planList.stream().map(CoreEduTrainingPlan::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |              coreEduTrainingPlanMapper.updatePlanStatusByIdList(collect, EduTrainingPlanStatus.USING.getCode());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if (checkOrgType(plan.getExecOrgType())){
 | 
	
		
			
				|  |  | +        if (checkOrgType(plan.getExecOrgType())) {
 | 
	
		
			
				|  |  |              planList.add(plan);
 | 
	
		
			
				|  |  | +            plan.setParentId(planId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //下发后修改为使用中
 | 
	
		
			
				|  |  |          plan.setPlanStatus(EduTrainingPlanStatus.USING.getCode());
 | 
	
	
		
			
				|  | @@ -679,7 +694,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          List<CoreEduTrainingPlanToExecOrg> planToExecOrgs = new ArrayList<>();
 | 
	
		
			
				|  |  |          List<CoreEduTrainingPlan> list = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (SysOrgVO sysOrg : planPublishOrgList) {
 | 
	
		
			
				|  |  | -            if (checkOrgType(plan.getExecOrgType())){
 | 
	
		
			
				|  |  | +            if (checkOrgType(plan.getExecOrgType())) {
 | 
	
		
			
				|  |  |                  continue;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              CoreEduTrainingPlan coreEduTrainingPlan = new CoreEduTrainingPlan();
 |