|
|
@@ -1,6 +1,7 @@
|
|
|
package com.xunmei.core.edu.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
@@ -11,6 +12,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
+import com.xunmei.common.core.domain.DateRange;
|
|
|
import com.xunmei.common.core.domain.IdName;
|
|
|
import com.xunmei.common.core.domain.edu.domain.*;
|
|
|
import com.xunmei.common.core.domain.edu.dto.CoreEduTrainingPlanEditDto;
|
|
|
@@ -22,7 +24,6 @@ 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;
|
|
|
@@ -204,13 +205,13 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
plan.setPlanStatus(EduTrainingPlanStatus.DRAFT.getCode());
|
|
|
plan.setStandard(0);
|
|
|
plan.setIssue(0);
|
|
|
- //省联社或者办事处创建的计划才存在下发
|
|
|
+ //省联社或者办事处及行社创建的计划才存在下发
|
|
|
if (checkOrgType(org.getType())) {
|
|
|
plan.setStandard(1);
|
|
|
}
|
|
|
int insert = coreEduTrainingPlanMapper.insert(plan);
|
|
|
|
|
|
- //如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
|
|
|
+ //如果不是省联社或者办事处行社,状态启用,并且是无周期或者立即生效
|
|
|
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());
|
|
|
@@ -224,8 +225,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
if (ObjectUtil.isEmpty(orgType)) {
|
|
|
throw new RuntimeException("当前用户所在机构类型无法确认!");
|
|
|
}
|
|
|
- //如果是省联社或者办事处则返回1,其他机构类型返回0
|
|
|
- return ObjectUtil.equal(orgType, OrgTypeEnum.SHEGN_LIAN_SHE.getCode()) || ObjectUtil.equal(orgType, OrgTypeEnum.BAN_SHI_CHU.getCode());
|
|
|
+ //如果是省联社或者办事处及行社
|
|
|
+ return ObjectUtil.equal(orgType, OrgTypeEnum.SHEGN_LIAN_SHE.getCode())
|
|
|
+ || ObjectUtil.equal(orgType, OrgTypeEnum.BAN_SHI_CHU.getCode())
|
|
|
+ || ObjectUtil.equal(orgType, OrgTypeEnum.HANG_SHE.getCode());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -238,6 +241,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int updateCoreEduTrainingPlan(CoreEduTrainingPlanEditDto request) {
|
|
|
final CoreEduTrainingPlan plan = getById(request.getId());
|
|
|
+
|
|
|
+ if (plan.getPlanStatus()==EduTrainingPlanStatus.DRAFT.getCode()) {
|
|
|
+ throw new RuntimeException("当前计划已被删除,无法修改!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//此处判断能否修改,如果可以 需要删除任务,且还需要判断是否需要生成任务
|
|
|
Boolean can = checkCanUpdate(request, plan);
|
|
|
if (!can) {
|
|
|
@@ -565,12 +574,8 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
|
|
|
public void publishPlan(Long planId) {
|
|
|
final CoreEduTrainingPlan plan = coreEduTrainingPlanMapper.selectById(planId);
|
|
|
- if (plan == null) {
|
|
|
- throw new SystemException("计划不存在!");
|
|
|
- }
|
|
|
- if (ObjectUtil.equal(plan.getIssue(), 1)) {
|
|
|
- throw new SystemException("计划已完成发布!");
|
|
|
- }
|
|
|
+ AssertUtil.isNotEmpty(plan, "计划不存在!");
|
|
|
+ AssertUtil.equal(plan.getIssue(), 0, "计划已完成下发!");
|
|
|
List<CoreEduTrainingPlan> list = buildPlanData(plan, new ArrayList<>(), true);
|
|
|
//下发后修改为使用中
|
|
|
plan.setPlanStatus(EduTrainingPlanStatus.USING.getCode());
|
|
|
@@ -615,7 +620,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
if (ObjectUtil.isEmpty(publishOrgList)) {
|
|
|
throw new RuntimeException("未能查询到行社数据!");
|
|
|
}
|
|
|
-
|
|
|
+ if (publishOrgList.get(0).getId().equals(plan.getBelongOrgId())) {
|
|
|
+ plan.setParentId(plan.getId());
|
|
|
+ return ListUtil.list(true, plan);
|
|
|
+ }
|
|
|
List<CoreEduTrainingPlanToExecOrg> planToExecOrgs = new ArrayList<>();
|
|
|
List<CoreEduTrainingPlan> list = new ArrayList<>();
|
|
|
for (SysOrg sysOrg : publishOrgList) {
|
|
|
@@ -627,7 +635,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
coreEduTrainingPlan.setBelongOrgPath(sysOrg.getPath());
|
|
|
coreEduTrainingPlan.setStandard(0);
|
|
|
coreEduTrainingPlan.setIssue(0);
|
|
|
- coreEduTrainingPlan.setPlanStatus(isPublish ? EduTrainingPlanStatus.USING.getCode():plan.getPlanStatus());
|
|
|
+ coreEduTrainingPlan.setPlanStatus(isPublish ? EduTrainingPlanStatus.USING.getCode() : plan.getPlanStatus());
|
|
|
coreEduTrainingPlan.setParentId(plan.getId());
|
|
|
coreEduTrainingPlan.setCreateTime(new Date());
|
|
|
coreEduTrainingPlan.setUpdateTime(new Date());
|
|
|
@@ -670,12 +678,11 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
@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());
|
|
|
+ DateRange range = DateUtils.getStartAndEnd(new Date(), plan.getPlanCycle());
|
|
|
+ List<Long> list = coreEduTrainingPlanMapper.selectIdByParentId(planId);
|
|
|
+ coreEduTrainingPlanMapper.updatePlanStatusByIdOrParentId(planId, EduTrainingPlanStatus.DELETED.getCode());
|
|
|
+ coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(list,range.getStartTime(),range.getEndTime());
|
|
|
return coreEduTrainingPlanMapper.updateById(plan);
|
|
|
}
|
|
|
|