|
|
@@ -5,6 +5,7 @@ import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
@@ -244,6 +245,25 @@ 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<>();
|
|
|
+ eos.lambda().eq(CoreEduTrainingPlanToExecOrg::getPlanId, plan.getId());
|
|
|
+ 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), "未能查找到具体的培训机构,请联系管理员!");
|
|
|
+ return orgList;
|
|
|
+ }
|
|
|
+ Assert.notNull(execOrgType, "未能查找到具体的培训机构,请联系管理员!");
|
|
|
+ orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectByOrgType(execOrgType, SecurityConstants.INNER), "获取机构信息失败!");
|
|
|
+ Assert.notEmpty(orgList, "无法根据培训机构类型找到具体机构,请修改计划内容!");
|
|
|
+ return orgList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void publishPlan(Long planId) {
|
|
|
final CoreEduTrainingPlan plan = coreEduTrainingPlanMapper.selectById(planId);
|
|
|
@@ -255,30 +275,47 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
|
|
|
//获取执行角色
|
|
|
- QueryWrapper<CoreEduTrainingPlanToRole> ros = new QueryWrapper<>();
|
|
|
- ros.lambda().eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
|
|
|
+ LambdaQueryWrapper<CoreEduTrainingPlanToRole> ros = new LambdaQueryWrapper<>();
|
|
|
+ ros.eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
|
|
|
List<CoreEduTrainingPlanToRole> planRoleList = coreEduTrainingPlanToRoleMapper.selectList(ros);
|
|
|
|
|
|
+ //获取执行机构
|
|
|
+ List<SysOrg> executeOrg = this.getExecuteOrg(plan);
|
|
|
|
|
|
- final Integer execOrgType = plan.getExecOrgType();
|
|
|
- List<SysOrg> orgList;
|
|
|
- if (execOrgType != null) {
|
|
|
- //获取具体执行检查的机构
|
|
|
- try {
|
|
|
- orgList = orgService.selectByOrgType(execOrgType, SecurityConstants.INNER);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("远程调用错误:获取机构信息失败!,{}", e.getMessage());
|
|
|
- throw new SystemException("远程调用错误:获取机构信息失败!");
|
|
|
+ List<CoreEduTrainingPlan> list = new ArrayList<>();
|
|
|
+ for (SysOrg sysOrg : executeOrg) {
|
|
|
+ CoreEduTrainingPlan coreEduTrainingPlan = new CoreEduTrainingPlan();
|
|
|
+ BeanUtils.copyProperties(coreEduTrainingPlan, plan);
|
|
|
+ coreEduTrainingPlan.setId(IdWorker.getId());
|
|
|
+ coreEduTrainingPlan.setBuildTaskNow(0);
|
|
|
+ coreEduTrainingPlan.setBelongOrgId(sysOrg.getId());
|
|
|
+ coreEduTrainingPlan.setBelongOrgName(sysOrg.getName());
|
|
|
+ coreEduTrainingPlan.setBelongOrgPath(sysOrg.getPath());
|
|
|
+ coreEduTrainingPlan.setStandard(0);
|
|
|
+ coreEduTrainingPlan.setIssue(0);
|
|
|
+ coreEduTrainingPlan.setParentId(planId);
|
|
|
+ coreEduTrainingPlan.setCreateTime(new Date());
|
|
|
+ coreEduTrainingPlan.setUpdateTime(new Date());
|
|
|
+ list.add(coreEduTrainingPlan);
|
|
|
+ }
|
|
|
+ List<CoreEduTrainingPlanToRole> insertPlanRoleList = new ArrayList<>();
|
|
|
+ for (CoreEduTrainingPlan coreEduTrainingPlan : list) {
|
|
|
+ //保存执行角色
|
|
|
+ for (CoreEduTrainingPlanToRole planRole : planRoleList) {
|
|
|
+ CoreEduTrainingPlanToRole role = new CoreEduTrainingPlanToRole();
|
|
|
+ role.setPlanId(coreEduTrainingPlan.getId());
|
|
|
+ role.setRoleId(planRole.getRoleId());
|
|
|
+ insertPlanRoleList.add(role);
|
|
|
}
|
|
|
- Assert.notEmpty(orgList, "无法根据培训机构类型找到具体机构,请修改计划内容!");
|
|
|
- } else {
|
|
|
- QueryWrapper<CoreEduTrainingPlanToExecOrg> eos = new QueryWrapper<>();
|
|
|
- eos.lambda().eq(CoreEduTrainingPlanToExecOrg::getPlanId, plan.getId());
|
|
|
- List<CoreEduTrainingPlanToExecOrg> execOrg = coreEduTrainingPlanToExecOrgMapper.selectList(eos);
|
|
|
- Assert.notEmpty(execOrg, "未能查找到具体的培训机构,请联系管理员!");
|
|
|
- final List<Long> list = execOrg.stream().map(CoreEduTrainingPlanToExecOrg::getOrgId).collect(Collectors.toList());
|
|
|
- orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgByIdList(list, SecurityConstants.INNER), "未能查找到具体的培训机构,请联系管理员!");
|
|
|
}
|
|
|
+ if (list.size() > 0) {
|
|
|
+ this.saveBatch(list);
|
|
|
+ }
|
|
|
+ if (insertPlanRoleList.size() > 0) {
|
|
|
+ coreEduTrainingPlanToRoleService.saveBatch(insertPlanRoleList);
|
|
|
+ }
|
|
|
+ plan.setIssue(1);
|
|
|
+ this.updateById(plan);
|
|
|
|
|
|
}
|
|
|
}
|