|  | @@ -218,10 +218,14 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          if (checkOrgType(org.getType())) {
 | 
	
		
			
				|  |  |              plan.setStandard(1);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        //如果是省联社或者办事处,不需要下发
 | 
	
		
			
				|  |  | +        if (checkNeedPublish(org.getType())) {
 | 
	
		
			
				|  |  | +            plan.setStandard(2);
 | 
	
		
			
				|  |  | +            plan.setPlanStatus(EduTrainingPlanStatus.USING.getCode());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          int insert = coreEduTrainingPlanMapper.insert(plan);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //如果不是省联社或者办事处行社,状态启用,并且是无周期或者立即生效
 | 
	
		
			
				|  |  | -        if ((!checkOrgType(org.getType())) && ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus()) && (ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE.getCode(), plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow()))) {
 | 
	
		
			
				|  |  | +        if (checkCanBuildTaskNow(org.getType(), plan)) {
 | 
	
		
			
				|  |  |              CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(plan.getId());
 | 
	
		
			
				|  |  |              coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -229,6 +233,27 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          return insert;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public Boolean checkCanBuildTaskNow(Integer orgType, CoreEduTrainingPlan plan) {
 | 
	
		
			
				|  |  | +        //创建机构是否是省联社或者办事处及行社? 如果是则需要下发,不能立即创建任务
 | 
	
		
			
				|  |  | +        boolean orgFlag = !checkOrgType(orgType);
 | 
	
		
			
				|  |  | +        //使用中,如果不是使用中状态不能立即生成任务
 | 
	
		
			
				|  |  | +        boolean statusFlag = ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus());
 | 
	
		
			
				|  |  | +        //无周期?有周期的不能立即生成任务
 | 
	
		
			
				|  |  | +        boolean cycleFlag = ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE.getCode(), plan.getPlanCycle());
 | 
	
		
			
				|  |  | +        //是否需要立即生效 不是则不能立即生成任务
 | 
	
		
			
				|  |  | +        boolean buildFlag = ObjectUtil.equal(1, plan.getBuildTaskNow());
 | 
	
		
			
				|  |  | +        //是否需要下发:如果需要下发,不能立即生成任务
 | 
	
		
			
				|  |  | +        boolean publishFlag = checkNeedPublish(orgType);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return (orgFlag && statusFlag && (cycleFlag || buildFlag))||publishFlag;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private Boolean checkNeedPublish(Integer orgType) {
 | 
	
		
			
				|  |  | +        return ObjectUtil.equal(orgType, OrgTypeEnum.SHEGN_LIAN_SHE.getCode())
 | 
	
		
			
				|  |  | +                || ObjectUtil.equal(orgType, OrgTypeEnum.BAN_SHI_CHU.getCode());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private Boolean checkOrgType(Integer orgType) {
 | 
	
		
			
				|  |  |          if (ObjectUtil.isEmpty(orgType)) {
 | 
	
	
		
			
				|  | @@ -740,7 +765,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
 | 
	
		
			
				|  |  |          Integer isExecute = coreEduTrainingTaskMapper.selectCount(new LambdaQueryWrapper<CoreEduTrainingTask>()
 | 
	
		
			
				|  |  |                          .in(CoreEduTrainingTask::getPlanId, list)
 | 
	
		
			
				|  |  |                          .eq(CoreEduTrainingTask::getStatus, EduTrainingDoStatus.DONE.getCode()))
 | 
	
		
			
				|  |  | -                        .intValue();
 | 
	
		
			
				|  |  | +                .intValue();
 | 
	
		
			
				|  |  |          if (ObjectUtil.equal(isExecute, 0) || EduTrainingPlanCycleEnum.NONE.getCode().equals(plan.getPlanCycle())) {
 | 
	
		
			
				|  |  |              coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(list, null, null);
 | 
	
		
			
				|  |  |          }
 |