|  | @@ -46,6 +46,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Propagation;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.support.TransactionSynchronizationAdapter;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.support.TransactionSynchronizationManager;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  import java.util.concurrent.CompletableFuture;
 | 
	
	
		
			
				|  | @@ -254,24 +256,21 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |                     2:计划生成了任务且执行了,但是没有修改到关键信息,此时则不能删除任务,只允许修改计划信息
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          final Integer done = coreEduTrainingTaskMapper.checkHasTaskIsDone(Arrays.asList(plan.getId()));
 | 
	
		
			
				|  |  | -        if (ObjectUtil.equal(1,done)){
 | 
	
		
			
				|  |  | +        if (ObjectUtil.equal(1, done)) {
 | 
	
		
			
				|  |  |              //此为情况二, 计划生成了任务且执行 不能删除任务,只允许修改计划信息,所以直接返回
 | 
	
		
			
				|  |  |              //TODO 考虑是否同步修改已生成的任务的名称
 | 
	
		
			
				|  |  |              return i;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        final Integer hasTask = coreEduTrainingTaskMapper.checkHasTask(plan.getId());
 | 
	
		
			
				|  |  | -        if (ObjectUtil.equal(1,plan.getBuildTaskNow())){
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        // final Integer hasTask = coreEduTrainingTaskMapper.checkHasTask(plan.getId());
 | 
	
		
			
				|  |  |          //此为情况一,计划没有生成任务或者生成了任务但未执行
 | 
	
		
			
				|  |  | -        coreEduTrainingTaskMapper.deleteByMap(MapUtil.of("plan_id", request.getId()));
 | 
	
		
			
				|  |  | -        CompletableFuture.runAsync(()->{
 | 
	
		
			
				|  |  | -            //说明有任务并且都没执行过,需要重新生成任务
 | 
	
		
			
				|  |  | -            final CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(request.getId());
 | 
	
		
			
				|  |  | -            coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
 | 
	
		
			
				|  |  | -        });
 | 
	
		
			
				|  |  | +        final CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(request.getId());
 | 
	
		
			
				|  |  | +        if (ObjectUtil.equal(1, plan.getBuildTaskNow())) {
 | 
	
		
			
				|  |  | +            coreEduTrainingTaskMapper.deleteByMap(MapUtil.of("plan_id", request.getId()));
 | 
	
		
			
				|  |  | +            CompletableFuture.runAsync(() -> {
 | 
	
		
			
				|  |  | +                //说明有任务并且都没执行过,需要重新生成任务
 | 
	
		
			
				|  |  | +                coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return i;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -400,7 +399,6 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<SysOrg> getExecuteOrg(CoreEduTrainingPlan plan) {
 | 
	
		
			
				|  |  | -        Integer execOrgType = plan.getExecOrgType();
 | 
	
		
			
				|  |  |          List<SysOrg> orgList;
 | 
	
		
			
				|  |  |          //优先判断是否存在具体的执行机构,如果存在则直接返回,否则根据机构类型进行查询
 | 
	
		
			
				|  |  |          QueryWrapper<CoreEduTrainingPlanToExecOrg> eos = new QueryWrapper<>();
 | 
	
	
		
			
				|  | @@ -408,10 +406,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          List<CoreEduTrainingPlanToExecOrg> execOrg = coreEduTrainingPlanToExecOrgMapper.selectList(eos);
 | 
	
		
			
				|  |  |          if (ObjectUtil.isNotEmpty(execOrg)) {
 | 
	
		
			
				|  |  |              final List<Long> list = execOrg.stream().map(CoreEduTrainingPlanToExecOrg::getOrgId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -            orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgByIdList(list, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
 | 
	
		
			
				|  |  | +            orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectParentHs(list, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
 | 
	
		
			
				|  |  |              return orgList;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectByOrgType(execOrgType, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
 | 
	
		
			
				|  |  | +        orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectChildHs(plan.getCreateOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
 | 
	
		
			
				|  |  |          return orgList;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -433,7 +431,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          ros.eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
 | 
	
		
			
				|  |  |          List<CoreEduTrainingPlanToRole> planRoleList = coreEduTrainingPlanToRoleMapper.selectList(ros);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //获取执行机构
 | 
	
		
			
				|  |  | +        //获取所有行社机构
 | 
	
		
			
				|  |  |          List<SysOrg> executeOrg = this.getExecuteOrg(plan);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<CoreEduTrainingPlan> list = new ArrayList<>();
 | 
	
	
		
			
				|  | @@ -470,15 +468,22 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          plan.setIssue(1);
 | 
	
		
			
				|  |  |          this.updateById(plan);
 | 
	
		
			
				|  |  | -        for (CoreEduTrainingPlan trainingPlan : list) {
 | 
	
		
			
				|  |  | -            CompletableFuture.runAsync(()->{
 | 
	
		
			
				|  |  | -                //如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
 | 
	
		
			
				|  |  | -                if ((ObjectUtil.equal(0, plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
 | 
	
		
			
				|  |  | -                    CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(trainingPlan.getId());
 | 
	
		
			
				|  |  | -                    coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
 | 
	
		
			
				|  |  | +        //事务提交后执行
 | 
	
		
			
				|  |  | +        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
 | 
	
		
			
				|  |  | +            @Override
 | 
	
		
			
				|  |  | +            public void afterCommit() {
 | 
	
		
			
				|  |  | +                for (CoreEduTrainingPlan trainingPlan : list) {
 | 
	
		
			
				|  |  | +                    CompletableFuture.runAsync(() -> {
 | 
	
		
			
				|  |  | +                        //如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
 | 
	
		
			
				|  |  | +                        if ((ObjectUtil.equal(0, plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
 | 
	
		
			
				|  |  | +                            CoreEduTrainingPlanDataVo detailPlanData = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
 | 
	
		
			
				|  |  | +                            coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 |