|
|
@@ -22,7 +22,7 @@ import com.xunmei.common.core.domain.edu.vo.CoreEduTrainingPlanDataVo;
|
|
|
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.EduTrainingPlanCycleEnum;
|
|
|
+import com.xunmei.common.core.enums.edu.EduTrainingPlanCycleEnum;
|
|
|
import com.xunmei.common.core.enums.OrgTypeEnum;
|
|
|
import com.xunmei.common.core.enums.edu.EduTrainingPlanStatus;
|
|
|
import com.xunmei.common.core.utils.AssertUtil;
|
|
|
@@ -39,6 +39,7 @@ import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
@@ -213,7 +214,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
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()))) {
|
|
|
+ if ((!checkOrgType(org.getType())) && ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus()) && (ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE.getCode(), plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow()))) {
|
|
|
CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(plan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
@@ -289,21 +290,27 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
Long planId = plan.getId();
|
|
|
// 判断标准计划能否修改:存在下发的计划生成了任务且任务存在已执行
|
|
|
Integer standardPlanHasDone = coreEduTrainingTaskMapper.checkHasTaskIsDoneByPlanParentId(planId);
|
|
|
- if (standardPlanHasDone == 1) {
|
|
|
+ if (ObjectUtil.equal(standardPlanHasDone, 1)) {
|
|
|
//验证修改的字段是否符合要求
|
|
|
String errorMsg = "有任务已执行或已过期,仅允许修改培训主题!";
|
|
|
validatePlanForStandard(request, plan, errorMsg, 1);
|
|
|
doUpdatePlan(plan, request);
|
|
|
} else {
|
|
|
doUpdatePlan(plan, request);
|
|
|
- List<CoreEduTrainingPlan> list = lambdaQuery().eq(CoreEduTrainingPlan::getParentId, planId).select(CoreEduTrainingPlan::getId).list();
|
|
|
+ List<CoreEduTrainingPlan> list = lambdaQuery().eq(CoreEduTrainingPlan::getParentId, planId).list();
|
|
|
+ for (CoreEduTrainingPlan trainingPlan : list) {
|
|
|
+ populateProperties(plan, trainingPlan);
|
|
|
+ updateById(trainingPlan);
|
|
|
+ coreEduTrainingPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
+ batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
|
|
|
+ }
|
|
|
List<Long> collect = list.stream().map(CoreEduTrainingPlan::getId).collect(Collectors.toList());
|
|
|
coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(collect, null, null);
|
|
|
for (CoreEduTrainingPlan trainingPlan : list) {
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
//如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
|
|
|
if ((ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus())
|
|
|
- && (ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
+ && (ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE.getCode(), plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
CoreEduTrainingPlanDataVo detailPlanData = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
@@ -316,6 +323,19 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void populateProperties(CoreEduTrainingPlan source, CoreEduTrainingPlan target) {
|
|
|
+ target.setPlanName(source.getPlanName());
|
|
|
+ target.setPlanCycle(source.getPlanCycle());
|
|
|
+ target.setExecTimes(source.getExecTimes());
|
|
|
+ target.setPlanStatus(source.getPlanStatus());
|
|
|
+ target.setExecOrgType(source.getExecOrgType());
|
|
|
+ target.setStartDate(source.getStartDate());
|
|
|
+ target.setEndDate(source.getEndDate());
|
|
|
+ target.setBuildTaskNow(source.getBuildTaskNow());
|
|
|
+ target.setRemark(source.getRemark());
|
|
|
+ target.setFileList(source.getFileList());
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
private void validatePlanForStandard(CoreEduTrainingPlanEditDto request, CoreEduTrainingPlan plan, String errorMsg, Integer type) {
|
|
|
validateFieldForStandard(request.getPlanCycle(), plan.getPlanCycle(), errorMsg);
|
|
|
@@ -323,7 +343,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
List<Long> execOrgIdList = coreEduTrainingPlanToExecOrgMapper.selectOrgIdByPlanId(plan.getId());
|
|
|
validateListForStandard(execOrgIdList, request.getPlanExecOrgIdList(), errorMsg);
|
|
|
validateFieldForStandard(request.getRemark(), plan.getRemark(), errorMsg);
|
|
|
- validateFieldForStandard(JSON.toJSONString(request.getFileList()), plan.getFileList(), errorMsg);
|
|
|
+ validateFileListForStandard(request.getFileList(), JSON.parseArray(plan.getFileList(), String.class), errorMsg);
|
|
|
if (type == 0) {
|
|
|
//标准计划可以修改名称
|
|
|
validateFieldForStandard(request.getPlanName(), plan.getPlanName(), errorMsg);
|
|
|
@@ -334,8 +354,24 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void validateFileListForStandard(List<String> requestFileList, List<String> sourceFileList, String errorMsg) {
|
|
|
+ if (ObjectUtil.isEmpty(requestFileList) && ObjectUtil.isEmpty(sourceFileList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isEmpty(requestFileList) && ObjectUtil.isNotEmpty(sourceFileList)) {
|
|
|
+ throw new RuntimeException(errorMsg);
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(requestFileList) && ObjectUtil.isEmpty(sourceFileList)) {
|
|
|
+ throw new RuntimeException(errorMsg);
|
|
|
+ }
|
|
|
+ if (sourceFileList.size() != requestFileList.size() || !sourceFileList.containsAll(requestFileList)) {
|
|
|
+ throw new RuntimeException(errorMsg);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void validateFieldForStandard(Object requestValue, Object planValue, String errorMessage) {
|
|
|
- if (ObjectUtil.notEqual(requestValue, planValue)) {
|
|
|
+ if (ObjectUtil.notEqual(requestValue, planValue) || ObjectUtils.allNull(requestValue, planValue)) {
|
|
|
throw new RuntimeException(errorMessage);
|
|
|
}
|
|
|
}
|
|
|
@@ -389,10 +425,11 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public int deleteCoreEduTrainingPlanByIds(Long id) {
|
|
|
+ public void deleteCoreEduTrainingPlanByIds(Long id) {
|
|
|
CoreEduTrainingPlan plan = getById(id);
|
|
|
if (EduTrainingPlanStatus.DRAFT.getCode() == plan.getPlanStatus()) {
|
|
|
removeById(id);
|
|
|
+ coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(Arrays.asList(id), null, null);
|
|
|
}
|
|
|
final Integer done = coreEduTrainingTaskMapper.checkHasTaskIsDoneByPlanParentId(id);
|
|
|
if (done != null && done > 0) {
|
|
|
@@ -401,9 +438,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
List<Long> list = baseMapper.selectIdByParentId(id);
|
|
|
list.add(id);
|
|
|
coreEduTrainingTaskService.delByStartTimeAndEndTimeAndPlanIdList(list, null, null);
|
|
|
+ removeByIds(list);
|
|
|
|
|
|
-
|
|
|
- Integer count = coreEduTrainingTaskMapper.checkHasTaskIsDone(Collections.singletonList(id));
|
|
|
+ /* Integer count = coreEduTrainingTaskMapper.checkHasTaskIsDone(Collections.singletonList(id));
|
|
|
if (count != null && count > 0) {
|
|
|
throw new RuntimeException("已有任务完成,无法删除");
|
|
|
}
|
|
|
@@ -433,7 +470,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
//删除计划
|
|
|
planIdList.add(id);
|
|
|
return coreEduTrainingPlanMapper.deleteBatchIds(planIdList);
|
|
|
- }
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -492,9 +529,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
AssertUtil.isNotEmpty(plan, "计划不存在!");
|
|
|
AssertUtil.equal(plan.getIssue(), 0, "计划已完成下发!");
|
|
|
List<CoreEduTrainingPlan> planList = lambdaQuery().eq(CoreEduTrainingPlan::getParentId, planId).select(CoreEduTrainingPlan::getId).list();
|
|
|
- if (planList.isEmpty()){
|
|
|
+ if (planList.isEmpty()) {
|
|
|
planList = buildPlanData(plan, new ArrayList<>(), true);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
planList.forEach(plan1 -> plan1.setPlanStatus(EduTrainingPlanStatus.USING.getCode()));
|
|
|
List<Long> collect = planList.stream().map(CoreEduTrainingPlan::getId).collect(Collectors.toList());
|
|
|
coreEduTrainingPlanMapper.updatePlanStatusByIdList(collect, EduTrainingPlanStatus.USING.getCode());
|
|
|
@@ -512,7 +549,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
CompletableFuture.runAsync(() -> {
|
|
|
//如果不是省联社或者办事处,状态启用,并且是无周期或者立即生效
|
|
|
if ((ObjectUtil.equal(EduTrainingPlanStatus.USING.getCode(), plan.getPlanStatus())
|
|
|
- && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
+ && (ObjectUtil.equal(EduTrainingPlanCycleEnum.NONE.getCode(), plan.getPlanCycle()) || ObjectUtil.equal(1, plan.getBuildTaskNow())))) {
|
|
|
CoreEduTrainingPlanDataVo detailPlanData = getCoreEduTrainingPlanDataVo(trainingPlan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
@@ -602,6 +639,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
public Integer revocationPlan(Long planId) {
|
|
|
CoreEduTrainingPlan plan = getById(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());
|