|
|
@@ -21,7 +21,9 @@ import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanDetailVo;
|
|
|
import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanPageVo;
|
|
|
import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanRoleVo;
|
|
|
import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
+import com.xunmei.common.core.enums.edu.EduTrainingPlanStatus;
|
|
|
import com.xunmei.common.core.exception.SystemException;
|
|
|
+import com.xunmei.common.core.utils.AssertUtil;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
@@ -199,6 +201,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
plan.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
|
|
|
//batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
|
|
|
batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
|
|
|
+ plan.setPlanStatus(EduTrainingPlanStatus.DRAFT.getCode());
|
|
|
plan.setStandard(0);
|
|
|
plan.setIssue(0);
|
|
|
//省联社或者办事处创建的计划才存在下发
|
|
|
@@ -208,7 +211,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
int insert = coreEduTrainingPlanMapper.insert(plan);
|
|
|
|
|
|
//如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
|
|
|
- if ((!checkOrgType(org.getType())) && ObjectUtil.equal(0, plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow()))) {
|
|
|
+ if ((!checkOrgType(org.getType())) && ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow()))) {
|
|
|
CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(plan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
@@ -246,13 +249,13 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
plan.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
|
|
|
plan.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
|
|
|
coreEduTrainingPlanToRoleMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
- List<CoreEduTrainingPlanToRole> trainingPlanToRoleList = batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
|
|
|
+ //List<CoreEduTrainingPlanToRole> trainingPlanToRoleList = batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
|
|
|
coreEduTrainingPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
|
|
|
final int i = coreEduTrainingPlanMapper.updateById(plan);
|
|
|
if (plan.getStandard() == 1) {
|
|
|
//如果标准计划可以修改,那么需要删除所有计划与任务,重新创建计划任务
|
|
|
- updateStandardPlan(plan, trainingPlanToRoleList);
|
|
|
+ updateStandardPlan(plan, null);//移除角色属性
|
|
|
} else {
|
|
|
//普通计划
|
|
|
updateCommonPlan(plan);
|
|
|
@@ -268,8 +271,29 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
return;
|
|
|
}
|
|
|
Long planId = plan.getId();
|
|
|
+ deletePlanAndTaskByParentPlanId(planId);
|
|
|
+ List<CoreEduTrainingPlan> planList = buildPlanData(plan, trainingPlanToRoleList, false);
|
|
|
+
|
|
|
+ if (plan.getPlanStatus() == EduTrainingPlanStatus.DELETED.getCode()) {
|
|
|
+ log.info("计划已被修改为" + EduTrainingPlanStatus.DELETED.getDesc() + ",不再生成任务!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (CoreEduTrainingPlan trainingPlan : planList) {
|
|
|
+ CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ //说明有任务并且都没执行过,需要重新生成任务
|
|
|
+ coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void deletePlanAndTaskByParentPlanId(Long planId) {
|
|
|
//删除原有数据, 然后重新生成计划,任务
|
|
|
List<Long> planIdList = coreEduTrainingPlanMapper.selectAllIdByParentId(planId);
|
|
|
+ if (ObjectUtil.isEmpty(planIdList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (ObjectUtil.isNotEmpty(planIdList)) {
|
|
|
coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
|
|
|
coreEduTrainingPlanToExecOrgMapper.delete(new LambdaQueryWrapper<CoreEduTrainingPlanToExecOrg>().in(CoreEduTrainingPlanToExecOrg::getPlanId, planIdList));
|
|
|
@@ -282,20 +306,6 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
coreEduTrainingTaskToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingTaskToRole>().in(CoreEduTrainingTaskToRole::getEduTrainingTaskId, collect));
|
|
|
|
|
|
}
|
|
|
- List<CoreEduTrainingPlan> planList = buildPlanData(plan, trainingPlanToRoleList);
|
|
|
-
|
|
|
- if (plan.getPlanStatus() == 1) {
|
|
|
- log.info("计划已被修改为禁用,不再生成任务!");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (CoreEduTrainingPlan trainingPlan : planList) {
|
|
|
- CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- //说明有任务并且都没执行过,需要重新生成任务
|
|
|
- coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
|
|
|
- },threadPoolTaskExecutor);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
private void updateCommonPlan(CoreEduTrainingPlan plan) {
|
|
|
@@ -311,18 +321,19 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
//TODO 考虑是否同步修改已生成的任务的名称
|
|
|
return;
|
|
|
}
|
|
|
- if (plan.getPlanStatus() == 1) {
|
|
|
- log.info("计划已被修改为禁用,不再生成任务!");
|
|
|
+ if (plan.getPlanStatus() == EduTrainingPlanStatus.DELETED.getCode()) {
|
|
|
+ log.info("计划已被修改为" + EduTrainingPlanStatus.DELETED.getDesc() + ",不再生成任务!");
|
|
|
return;
|
|
|
}
|
|
|
//此为情况一,计划没有生成任务或者生成了任务但未执行
|
|
|
final CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(plan.getId());
|
|
|
if (ObjectUtil.equal(1, plan.getBuildTaskNow()) && ObjectUtil.equal(0, plan.getPlanStatus())) {
|
|
|
coreEduTrainingTaskMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
+ coreEduTrainingTaskToRoleMapper.delete(new LambdaQueryWrapper<CoreEduTrainingTaskToRole>().eq(CoreEduTrainingTaskToRole::getEduTrainingTaskId, plan.getId()));
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
//说明有任务并且都没执行过,需要重新生成任务
|
|
|
coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
|
|
|
- },threadPoolTaskExecutor);
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -375,12 +386,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
private void validateRoleAndOrgForStandard(CoreEduTrainingPlanEditDto request, CoreEduTrainingPlan plan) {
|
|
|
// 执行角色
|
|
|
- List<Long> roleIdLit = coreEduTrainingPlanToRoleMapper.selectRoleIdByPlanId(plan.getId());
|
|
|
+ /* List<Long> roleIdLit = coreEduTrainingPlanToRoleMapper.selectRoleIdByPlanId(plan.getId());
|
|
|
List<Long> planRoleId = request.getPlanRoleId();
|
|
|
if (ObjectUtil.isEmpty(planRoleId)) {
|
|
|
throw new RuntimeException("下发计划仅允许修改培训次数!");
|
|
|
}
|
|
|
- validateListForStandard(roleIdLit, planRoleId, "下发计划仅允许修改培训次数!");
|
|
|
+ validateListForStandard(roleIdLit, planRoleId, "下发计划仅允许修改培训次数!");*/
|
|
|
|
|
|
// 执行机构
|
|
|
List<Long> execOrgIdList = coreEduTrainingPlanToExecOrgMapper.selectOrgIdByPlanId(plan.getId());
|
|
|
@@ -420,62 +431,6 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
return planList.size() == requestList.size() && planList.containsAll(requestList);
|
|
|
}
|
|
|
|
|
|
- /*private Boolean checkCanUpdate(CoreEduTrainingPlanEditDto request, CoreEduTrainingPlan plan) {
|
|
|
- if (ObjectUtil.isAllEmpty(request.getExecOrgType(), request.getPlanExecOrgIdList())) {
|
|
|
- throw new RuntimeException("培训机构类型和执行机构不能同时为空!");
|
|
|
- }
|
|
|
- //如果是下发的计划,执行频次不应低于省联社下发时设定的次数
|
|
|
- if (ObjectUtil.equal(plan.getStandard(), 0) && request.getExecTimes() < plan.getExecTimes()) {
|
|
|
- throw new RuntimeException("执行次数不应低于基准次数!");
|
|
|
- }
|
|
|
- final Long planId = plan.getId();
|
|
|
- boolean flag = true;
|
|
|
- //判断计划是否有任务已经执行过
|
|
|
- final Integer done = coreEduTrainingTaskMapper.checkHasTaskIsDone(Arrays.asList(planId));
|
|
|
- //判断标准计划能否修改:存在下发的计划生成了任务且任务存在已执行
|
|
|
- Integer standardPlanHasDone = coreEduTrainingTaskMapper.checkHasTaskIsDoneByPlanParentId(planId);
|
|
|
- if (standardPlanHasDone != null) {
|
|
|
- throw new RuntimeException("该计划下存在任务已执行的情况,无法修改!");
|
|
|
- }
|
|
|
- //计划状态
|
|
|
- if (ObjectUtil.notEqual(request.getPlanStatus(), plan.getPlanStatus())) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- //计划周期
|
|
|
- if (ObjectUtil.notEqual(request.getPlanCycle(), plan.getPlanCycle())) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- //执行机构类型
|
|
|
- if (ObjectUtil.notEqual(request.getExecOrgType(), plan.getExecOrgType())) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- //执行角色
|
|
|
- List<Long> roleIdLit = coreEduTrainingPlanToRoleMapper.selectRoleIdByPlanId(planId);
|
|
|
- List<Long> planRoleId = request.getPlanRoleId();
|
|
|
- if (ObjectUtil.isEmpty(planRoleId)) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- for (Long roleId : roleIdLit) {
|
|
|
- if (!planRoleId.contains(roleId)) {
|
|
|
- flag = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- //执行机构
|
|
|
- List<Long> execOrgIdList = coreEduTrainingPlanToExecOrgMapper.selectOrgIdByPlanId(planId);
|
|
|
- final List<Long> planExecOrgIdList = request.getPlanExecOrgIdList();
|
|
|
- if (execOrgIdList.size() != planExecOrgIdList.size()) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- for (Long orgId : execOrgIdList) {
|
|
|
- if (!planExecOrgIdList.contains(orgId)) {
|
|
|
- flag = false;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- return null == done || flag;
|
|
|
- }*/
|
|
|
-
|
|
|
@Override
|
|
|
public CoreEduTrainingPlanDataVo getCoreEduTrainingPlanDataVo(Long id) {
|
|
|
final CoreEduTrainingPlanDataVo dataVo = coreEduTrainingPlanMapper.getDetailPlanData(id);
|
|
|
@@ -624,8 +579,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}
|
|
|
// 下发 按钮显示逻辑:仅省联社安全保卫管理人员进入且由省联社管理安全保卫人员创建的计划才显示
|
|
|
//todo 判断当前人的角色信息
|
|
|
- List<CoreEduTrainingPlan> list = buildPlanData(plan, new ArrayList<>());
|
|
|
-
|
|
|
+ List<CoreEduTrainingPlan> list = buildPlanData(plan, new ArrayList<>(), true);
|
|
|
+ //下发后修改为使用中
|
|
|
+ plan.setPlanStatus(EduTrainingPlanStatus.USING.getCode());
|
|
|
plan.setIssue(1);
|
|
|
this.updateById(plan);
|
|
|
//事务提交后执行
|
|
|
@@ -635,24 +591,25 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
for (CoreEduTrainingPlan trainingPlan : list) {
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
//如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
|
|
|
- if ((ObjectUtil.equal(0, plan.getPlanStatus()) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
+ if ((ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus())
|
|
|
+ && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
CoreEduTrainingPlanDataVo detailPlanData = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
- },threadPoolTaskExecutor);
|
|
|
+ }, threadPoolTaskExecutor);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
- private List<CoreEduTrainingPlan> buildPlanData(CoreEduTrainingPlan plan, List<CoreEduTrainingPlanToRole> planRoleList) {
|
|
|
- if (ObjectUtil.isEmpty(planRoleList)) {
|
|
|
+ private List<CoreEduTrainingPlan> buildPlanData(CoreEduTrainingPlan plan, List<CoreEduTrainingPlanToRole> planRoleList, Boolean isPublish) {
|
|
|
+ /*if (ObjectUtil.isEmpty(planRoleList)) {
|
|
|
//获取执行角色
|
|
|
LambdaQueryWrapper<CoreEduTrainingPlanToRole> ros = new LambdaQueryWrapper<>();
|
|
|
ros.eq(CoreEduTrainingPlanToRole::getPlanId, plan.getId());
|
|
|
planRoleList = coreEduTrainingPlanToRoleMapper.selectList(ros);
|
|
|
- }
|
|
|
+ }*/
|
|
|
//获取计划具体执行机构
|
|
|
final List<SysOrg> planExecOrgList = this.getPlanExecOrg(plan);
|
|
|
|
|
|
@@ -678,6 +635,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
coreEduTrainingPlan.setBelongOrgPath(sysOrg.getPath());
|
|
|
coreEduTrainingPlan.setStandard(0);
|
|
|
coreEduTrainingPlan.setIssue(0);
|
|
|
+ coreEduTrainingPlan.setPlanStatus(isPublish ? EduTrainingPlanStatus.USING.getCode() : EduTrainingPlanStatus.DELETED.getCode());
|
|
|
coreEduTrainingPlan.setParentId(plan.getId());
|
|
|
coreEduTrainingPlan.setCreateTime(new Date());
|
|
|
coreEduTrainingPlan.setUpdateTime(new Date());
|
|
|
@@ -695,7 +653,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
if (planToExecOrgs.size() > 0) {
|
|
|
coreEduTrainingPlanToExecOrgService.saveBatch(planToExecOrgs);
|
|
|
}
|
|
|
- List<CoreEduTrainingPlanToRole> insertPlanRoleList = new ArrayList<>();
|
|
|
+ /* List<CoreEduTrainingPlanToRole> insertPlanRoleList = new ArrayList<>();
|
|
|
for (CoreEduTrainingPlan coreEduTrainingPlan : list) {
|
|
|
//保存执行角色
|
|
|
for (CoreEduTrainingPlanToRole planRole : planRoleList) {
|
|
|
@@ -705,16 +663,29 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
insertPlanRoleList.add(role);
|
|
|
}
|
|
|
}
|
|
|
- if (list.size() > 0) {
|
|
|
- this.saveBatch(list);
|
|
|
- }
|
|
|
if (insertPlanRoleList.size() > 0) {
|
|
|
coreEduTrainingPlanToRoleService.saveBatch(insertPlanRoleList);
|
|
|
+ }*/
|
|
|
+ if (list.size() > 0) {
|
|
|
+ this.saveBatch(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Integer revocationPlan(Long planId) {
|
|
|
+ CoreEduTrainingPlan plan = getById(planId);
|
|
|
+ //仅标准计划存在撤回的情况
|
|
|
+ Integer hasDoneTask = coreEduTrainingTaskMapper.checkHasTask(planId);
|
|
|
+ AssertUtil.notEqual(hasDoneTask, 1, "计划已有任务执行,无法撤销");
|
|
|
+ deletePlanAndTaskByParentPlanId(planId);
|
|
|
+ plan.setIssue(0);
|
|
|
+ plan.setPlanStatus(EduTrainingPlanStatus.DELETED.getCode());
|
|
|
+ return coreEduTrainingPlanMapper.updateById(plan);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<IdName<String, String>> planList(Long orgId) {
|
|
|
@@ -746,7 +717,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
.eq(CoreEduTrainingPlan::getStandard, standard)
|
|
|
.eq(CoreEduTrainingPlan::getIssue, issue)
|
|
|
.eq(CoreEduTrainingPlan::getDeleted, 0)
|
|
|
- .eq(CoreEduTrainingPlan::getPlanStatus, 0)
|
|
|
+ .eq(CoreEduTrainingPlan::getPlanStatus, EduTrainingPlanStatus.USING.getCode())
|
|
|
.select(CoreEduTrainingPlan::getId, CoreEduTrainingPlan::getPlanName)
|
|
|
);
|
|
|
}
|