|
|
@@ -3,6 +3,8 @@ package com.xunmei.core.edu.service.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
@@ -21,7 +23,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.exception.SystemException;
|
|
|
+import com.xunmei.common.core.util.BeanHelper;
|
|
|
import com.xunmei.common.core.utils.DateUtils;
|
|
|
+import com.xunmei.common.core.vo.IdNameVo;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
import com.xunmei.core.edu.mapper.CoreEduTrainingPlanMapper;
|
|
|
@@ -32,7 +36,9 @@ import com.xunmei.core.edu.service.ICoreEduTrainingPlanService;
|
|
|
import com.xunmei.core.edu.service.ICoreEduTrainingPlanToExecOrgService;
|
|
|
import com.xunmei.core.edu.service.ICoreEduTrainingPlanToRoleService;
|
|
|
import com.xunmei.core.edu.service.ICoreEduTrainingTaskService;
|
|
|
+import com.xunmei.system.api.Eto.RoleConditionEto;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.RemoteRoleService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -43,10 +49,7 @@ import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -74,6 +77,8 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
private CoreEduTrainingTaskMapper coreEduTrainingTaskMapper;
|
|
|
@Autowired
|
|
|
private RemoteOrgService orgService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteRoleService remoteRoleService;
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo selectPage(CoreEduTrainingPlanPageDto request) {
|
|
|
@@ -86,17 +91,12 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
//获取数据
|
|
|
Page<CoreEduTrainingPlanPageVo> page = coreEduTrainingPlanMapper.selectPageData(request.getPage(), request);
|
|
|
SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectTopOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
- for (CoreEduTrainingPlanPageVo record : page.getRecords()) {
|
|
|
- record.setNo(page.getRecords().indexOf(record) + 1);
|
|
|
- if (ObjectUtil.equal(record.getCreateOrgId(), sysOrg.getId())) {
|
|
|
- record.setCreateByTopOrg(1);
|
|
|
- }
|
|
|
- String roleNameList = coreEduTrainingPlanToRoleMapper.selectRoleNameByPlanId(record.getId()).stream().map(CoreEduTrainingPlanRoleVo::getRoleName).collect(Collectors.joining(","));
|
|
|
- record.setPlanRoleNameList(roleNameList);
|
|
|
-
|
|
|
+ List<CoreEduTrainingPlanPageVo> records = page.getRecords();
|
|
|
+ for (CoreEduTrainingPlanPageVo record : records) {
|
|
|
+ dealData(record, records, sysOrg.getId());
|
|
|
}
|
|
|
//抓换为TableDataInfo适配前端
|
|
|
- TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
+ TableDataInfo<CoreEduTrainingPlanPageVo> tableDataInfo = new TableDataInfo();
|
|
|
tableDataInfo.setMsg("操作成功");
|
|
|
tableDataInfo.setCode(200);
|
|
|
tableDataInfo.setTotal(page.getTotal());
|
|
|
@@ -106,6 +106,32 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void dealData(CoreEduTrainingPlanPageVo record, List<CoreEduTrainingPlanPageVo> records, Long orgId) {
|
|
|
+ record.setNo(records.indexOf(record) + 1);
|
|
|
+ if (ObjectUtil.equal(record.getCreateOrgId(), orgId)) {
|
|
|
+ record.setCreateByTopOrg(1);
|
|
|
+ }
|
|
|
+ String roleNameList = coreEduTrainingPlanToRoleMapper.selectRoleNameByPlanId(record.getId()).stream().map(CoreEduTrainingPlanRoleVo::getRoleName).collect(Collectors.joining(","));
|
|
|
+ record.setPlanRoleNameList(roleNameList);
|
|
|
+ List<CoreEduTrainingPlan> planList = coreEduTrainingPlanMapper.selectList(new LambdaQueryWrapper<CoreEduTrainingPlan>().eq(CoreEduTrainingPlan::getParentId, record.getId()));
|
|
|
+ List<CoreEduTrainingPlanPageVo> children = BeanHelper.copyProperties(planList, CoreEduTrainingPlanPageVo.class);
|
|
|
+ final List<Long> collect = children.stream().map(CoreEduTrainingPlanPageVo::getUpdateBy).map(Long::valueOf).distinct().collect(Collectors.toList());
|
|
|
+ final List<IdNameVo> idNameVos = RemoteCallHandlerExecutor.executeRemoteCall(() -> remoteRoleService.getNames(new RoleConditionEto(collect)), ErrorMsgConstants.QUERY_ROLE_DATA_ERROR);
|
|
|
+
|
|
|
+ //将idNameVos使用steam转为map
|
|
|
+ final Map<Long, String> idNameMap = idNameVos.stream().collect(Collectors.toMap(IdNameVo::getId, IdNameVo::getName));
|
|
|
+ record.setChildren(children);
|
|
|
+ record.setHasChildren(ObjectUtil.isNotEmpty(children));
|
|
|
+ for (CoreEduTrainingPlanPageVo child : children) {
|
|
|
+ if (ObjectUtil.equal(child.getCreateOrgId(), orgId)) {
|
|
|
+ child.setCreateByTopOrg(1);
|
|
|
+ }
|
|
|
+ final String name = idNameMap.get(Long.valueOf(child.getUpdateBy()));
|
|
|
+ child.setUpdateBy(name);
|
|
|
+ child.setPlanRoleNameList(roleNameList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询教育培训计划
|
|
|
@@ -118,6 +144,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
final CoreEduTrainingPlan plan = coreEduTrainingPlanMapper.selectById(id);
|
|
|
CoreEduTrainingPlanDetailVo vo = new CoreEduTrainingPlanDetailVo();
|
|
|
BeanUtils.copyProperties(plan, vo);
|
|
|
+ vo.setFileList(ObjectUtil.isNotEmpty(plan.getFileList()) ? JSON.parseArray(plan.getFileList(), String.class) : null);
|
|
|
final List<CoreEduTrainingPlanToExecOrg> execOrgList = coreEduTrainingPlanToExecOrgMapper.selectByMap(MapUtil.of("plan_id", id));
|
|
|
final List<Long> execOrgIdList = execOrgList.stream().map(CoreEduTrainingPlanToExecOrg::getOrgId).collect(Collectors.toList());
|
|
|
vo.setPlanExecOrgIdList(ObjectUtil.isEmpty(execOrgIdList) ? null : execOrgIdList);
|
|
|
@@ -150,6 +177,9 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
if (ObjectUtil.isAllEmpty(request.getExecOrgType(), request.getPlanExecOrgIdList())) {
|
|
|
throw new RuntimeException("培训机构类型和执行机构不能同时为空!");
|
|
|
}
|
|
|
+ if (ObjectUtil.equal(request.getPlanCycle(), 0) && ObjectUtil.hasEmpty(request.getStartDate(), request.getEndDate())) {
|
|
|
+ throw new RuntimeException("当计划为无周期的时候,请填入开始时间和结束时间!");
|
|
|
+ }
|
|
|
CoreEduTrainingPlan plan = new CoreEduTrainingPlan();
|
|
|
BeanUtils.copyProperties(request, plan);
|
|
|
plan.setId(IdWorker.getId());
|
|
|
@@ -167,6 +197,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
plan.setBelongOrgId(orgId);
|
|
|
plan.setBelongOrgName(r.getName());
|
|
|
plan.setBelongOrgPath(r.getPath());
|
|
|
+ plan.setFileList(ObjectUtil.isNotEmpty(request.getFileList()) ? JSON.toJSONString(request.getFileList()) : null);
|
|
|
batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
|
|
|
batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
|
|
|
//省联社或者办事处创建的计划才存在下发
|
|
|
@@ -178,7 +209,7 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
//如果不是省联社或者办事处,并且是无周期或者立即生效
|
|
|
if ((!checkOrgType(plan.getExecOrgType())) && (ObjectUtil.equal(0, plan.getPlanCycle()) || ObjectUtil.equal(0, plan.getBuildTaskNow()))) {
|
|
|
- CoreEduTrainingPlanDataVo detailPlanData = coreEduTrainingPlanMapper.getDetailPlanData(plan.getId());
|
|
|
+ CoreEduTrainingPlanDataVo detailPlanData = this.getCoreEduTrainingPlanDataVo(plan.getId());
|
|
|
coreEduTrainingTaskService.createTaskForNow(detailPlanData, plan.getStartDate(), plan.getEndDate());
|
|
|
}
|
|
|
|
|
|
@@ -215,13 +246,33 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
}
|
|
|
BeanUtils.copyProperties(request, plan);
|
|
|
plan.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ 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()));
|
|
|
coreEduTrainingPlanToExecOrgMapper.deleteByMap(MapUtil.of("plan_id", plan.getId()));
|
|
|
batchSavePlanToRole(request.getPlanRoleId(), plan.getId());
|
|
|
batchSavePlanToExecOrg(request.getPlanExecOrgIdList(), plan.getId());
|
|
|
- return coreEduTrainingPlanMapper.updateById(plan);
|
|
|
+ final int i = coreEduTrainingPlanMapper.updateById(plan);
|
|
|
+ if (ObjectUtil.equal(plan.getStandard(), 0) && ObjectUtil.equal(plan.getIssue(), 0)) {
|
|
|
+ //说明是行方自己创建的计划,修改后需要重新下发
|
|
|
+ Integer exit = coreEduTrainingTaskMapper.checkHasTask(request.getId());
|
|
|
+ Integer hasDone = coreEduTrainingTaskMapper.checkHasTaskIsDone(Collections.singletonList(request.getId()));
|
|
|
+ if (ObjectUtil.equal(exit, 1) && ObjectUtil.isNull(hasDone)) {
|
|
|
+ coreEduTrainingTaskMapper.deleteByMap(MapUtil.of("plan_id", request.getId()));
|
|
|
+ //说明有任务并且都没执行过,需要重新生成任务
|
|
|
+ final CoreEduTrainingPlanDataVo dataVo = getCoreEduTrainingPlanDataVo(request.getId());
|
|
|
+ coreEduTrainingTaskService.createTaskForNow(dataVo, plan.getStartDate(), plan.getEndDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CoreEduTrainingPlanDataVo getCoreEduTrainingPlanDataVo(Long id) {
|
|
|
+ final CoreEduTrainingPlanDataVo dataVo = coreEduTrainingPlanMapper.getDetailPlanData(id);
|
|
|
+ dataVo.setFileList(ObjectUtil.isNotEmpty(dataVo.getFile()) ? JSON.parseArray(dataVo.getFile(), String.class) : null);
|
|
|
+ return dataVo;
|
|
|
}
|
|
|
|
|
|
public void batchSavePlanToRole(List<Long> roleIdList, Long planId) {
|
|
|
@@ -301,12 +352,10 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
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), "未能查找到具体的培训机构,请联系管理员!");
|
|
|
+ orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectOrgByIdList(list, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
return orgList;
|
|
|
}
|
|
|
- Assert.notNull(execOrgType, "未能查找到具体的培训机构,请联系管理员!");
|
|
|
orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectByOrgType(execOrgType, SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
- Assert.notEmpty(orgList, "无法根据培训机构类型找到具体机构,请修改计划内容!");
|
|
|
return orgList;
|
|
|
}
|
|
|
|
|
|
@@ -369,8 +418,4 @@ public class CoreEduTrainingPlanServiceImpl extends ServiceImpl<CoreEduTrainingP
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public CoreEduTrainingPlanDataVo getDetailPlanData(Long id) {
|
|
|
- return coreEduTrainingPlanMapper.getDetailPlanData(id);
|
|
|
- }
|
|
|
}
|