|
|
@ -5,22 +5,20 @@ import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; |
|
|
|
import com.ccsens.cloudutil.feign.Tall3FeignClient; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.common.persist.dao.*; |
|
|
|
import com.ccsens.common.bean.po.*; |
|
|
|
import com.ccsens.common.persist.mapper.*; |
|
|
|
import com.ccsens.defaultwbs.bean.dto.RoleDto; |
|
|
|
import com.ccsens.defaultwbs.bean.dto.TaskDto; |
|
|
|
import com.ccsens.defaultwbs.bean.vo.ProjectVo; |
|
|
|
import com.ccsens.defaultwbs.persist.dao.SProjectDao; |
|
|
|
import com.ccsens.defaultwbs.persist.dao.SPluginDao; |
|
|
|
import com.ccsens.defaultwbs.persist.dao.SProjectDao; |
|
|
|
import com.ccsens.defaultwbs.persist.dao.STaskDao; |
|
|
|
import com.ccsens.defaultwbs.persist.dao.SubLabelDao; |
|
|
|
import com.ccsens.common.bean.po.LabelBusiness; |
|
|
|
import com.ccsens.common.bean.po.ProMemberStakeholder; |
|
|
|
import com.ccsens.defaultwbs.util.DefaultCodeError; |
|
|
|
import com.ccsens.defaultwbs.util.Constant; |
|
|
|
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; |
|
|
|
import com.ccsens.cloudutil.feign.Tall3FeignClient; |
|
|
|
import com.ccsens.common.bean.po.*; |
|
|
|
import com.ccsens.common.persist.dao.*; |
|
|
|
import com.ccsens.common.persist.mapper.ProMemberStakeholderMapper; |
|
|
|
import com.ccsens.defaultwbs.util.DefaultCodeError; |
|
|
|
import com.ccsens.util.ExcelUtil; |
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.PropUtil; |
|
|
@ -63,6 +61,8 @@ public class ImportService implements IImportService { |
|
|
|
@Resource |
|
|
|
private SubLabelDao subLabelDao; |
|
|
|
@Resource |
|
|
|
private LabelDao labelDao; |
|
|
|
@Resource |
|
|
|
private ProRoleDao roleDao; |
|
|
|
@Resource |
|
|
|
private ProMemberDao memberDao; |
|
|
@ -108,18 +108,68 @@ public class ImportService implements IImportService { |
|
|
|
//成员
|
|
|
|
Map<String, RoleDto.WbsMember> memberMap = new HashMap<>(); |
|
|
|
//任务
|
|
|
|
Map<String, Long> taskMap = new HashMap<>(); |
|
|
|
Map<String, Object> taskMap = new HashMap<>(); |
|
|
|
|
|
|
|
//读取文件
|
|
|
|
readExcel(xssfWorkbook, userId, roleMap, memberMap, taskMap,projectId,projectInfo); |
|
|
|
|
|
|
|
//读取插件配置表
|
|
|
|
readPluginConfig(xssfWorkbook,taskMap); |
|
|
|
|
|
|
|
return projectInfo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取插件配置表 |
|
|
|
*/ |
|
|
|
private void readPluginConfig(XSSFWorkbook wb, Map<String, Object> taskMap) { |
|
|
|
//获取插件配置表Sheet
|
|
|
|
XSSFSheet wbsSheet = wb.getSheet(Constant.WbsExcel.WBS_PLUGIN_CONFIG); |
|
|
|
if (ObjectUtil.isNotNull(wbsSheet)) { |
|
|
|
for (int i = 0; i <= wbsSheet.getLastRowNum(); i++) { |
|
|
|
//获取行
|
|
|
|
XSSFRow row = wbsSheet.getRow(i); |
|
|
|
if (row == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
//序号
|
|
|
|
String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); |
|
|
|
//任务名
|
|
|
|
String taskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); |
|
|
|
if(StrUtil.isEmpty(taskName)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
//插件1
|
|
|
|
String pluginParam1 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(2))); |
|
|
|
//插件2
|
|
|
|
String pluginParam2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(3))); |
|
|
|
//插件3
|
|
|
|
String pluginParam3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); |
|
|
|
Object o = taskMap.get(sequence + "_" + taskName); |
|
|
|
if(ObjectUtil.isNull(o)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
TaskDto.TaskPluginId taskPlugin = (TaskDto.TaskPluginId) o; |
|
|
|
if(StrUtil.isNotEmpty(pluginParam1)){ |
|
|
|
//修改插件表的param
|
|
|
|
sTaskPluginDao.updateParamById(pluginParam1,taskPlugin.getTaskPluginId1()); |
|
|
|
} |
|
|
|
if(StrUtil.isNotEmpty(pluginParam2)){ |
|
|
|
//修改插件表的param
|
|
|
|
sTaskPluginDao.updateParamById(pluginParam2,taskPlugin.getTaskPluginId2()); |
|
|
|
} |
|
|
|
if(StrUtil.isNotEmpty(pluginParam3)){ |
|
|
|
//修改插件表的param
|
|
|
|
sTaskPluginDao.updateParamById(pluginParam3,taskPlugin.getTaskPluginId3()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取每个sheet |
|
|
|
*/ |
|
|
|
private void readExcel(XSSFWorkbook wb, Long userId, Map<String, Long> roleMap, Map<String, RoleDto.WbsMember> memberMap, Map<String, Long> taskMap,Long projectId,ProjectVo.ProjectInfo projectInfo) { |
|
|
|
private void readExcel(XSSFWorkbook wb, Long userId, Map<String, Long> roleMap, Map<String, RoleDto.WbsMember> memberMap, Map<String, Object> taskMap,Long projectId,ProjectVo.ProjectInfo projectInfo) { |
|
|
|
//获取wbsSheet
|
|
|
|
XSSFSheet wbsSheet = wb.getSheet(Constant.WbsExcel.WBS_SHEET); |
|
|
|
if (ObjectUtil.isNull(wbsSheet)) { |
|
|
@ -168,13 +218,13 @@ public class ImportService implements IImportService { |
|
|
|
//读取成员表
|
|
|
|
readMemberSheet(memberSheet,project,roleMap,memberMap); |
|
|
|
//添加任务
|
|
|
|
readTask(wbsSheet,taskStart,project,roleMap); |
|
|
|
readTask(wbsSheet,taskStart,project,roleMap,taskMap); |
|
|
|
//获取用户列表
|
|
|
|
Set<Long> userIdSet = new HashSet<>(); |
|
|
|
userIdSet.add(userId); |
|
|
|
//处理创建人的权限问题(添加创建人角色)
|
|
|
|
//查找创建者标签id
|
|
|
|
Long roleLabelId = subLabelDao.getLabelByTypeAndLevel(5, 5); |
|
|
|
Long roleLabelId = labelDao.getLabelByTypeAndLevel(5, 5); |
|
|
|
//添加创建者角色
|
|
|
|
ProRole role = new ProRole(); |
|
|
|
role.setId(snowflake.nextId()); |
|
|
@ -345,7 +395,7 @@ public class ImportService implements IImportService { |
|
|
|
taskVersion.setAddress(address); |
|
|
|
taskVersionMapper.insertSelective(taskVersion); |
|
|
|
//查找项目标签
|
|
|
|
Long labelId = subLabelDao.getLabelByTypeAndLevel(1, 0); |
|
|
|
Long labelId = labelDao.getLabelByTypeAndLevel(1, 0); |
|
|
|
//添加任务标签关联信息
|
|
|
|
saveLabelTask(taskDetail.getId(), labelId); |
|
|
|
|
|
|
@ -545,7 +595,7 @@ public class ImportService implements IImportService { |
|
|
|
/** |
|
|
|
* 读取任务信息 |
|
|
|
*/ |
|
|
|
private void readTask(XSSFSheet wbsSheet, int taskStart, ProjectVo.SysProject project, Map<String, Long> roleMap) { |
|
|
|
private void readTask(XSSFSheet wbsSheet, int taskStart, ProjectVo.SysProject project, Map<String, Long> roleMap, Map<String, Object> taskMap) { |
|
|
|
|
|
|
|
//一级任务id
|
|
|
|
Long firstTaskId = null; |
|
|
@ -597,6 +647,8 @@ public class ImportService implements IImportService { |
|
|
|
//获取当前行
|
|
|
|
XSSFRow row = wbsSheet.getRow(i); |
|
|
|
if(ObjectUtil.isNull(row)){ continue; } |
|
|
|
//序号
|
|
|
|
String sequence = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); |
|
|
|
//一级任务名
|
|
|
|
String firstTaskName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(1))); |
|
|
|
if(StrUtil.isEmpty(firstTaskName) && ObjectUtil.isNull(firstTaskId)){ |
|
|
@ -657,7 +709,6 @@ public class ImportService implements IImportService { |
|
|
|
} |
|
|
|
String[] split = executorRole.split(Constant.STRING_REGEX); |
|
|
|
for (String repulsionName : split) { |
|
|
|
//TODO 全体成员
|
|
|
|
Long executorRoleId = roleMap.get(repulsionName); |
|
|
|
if(ObjectUtil.isNull(executorRoleId)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,repulsionName)); |
|
|
@ -672,12 +723,14 @@ public class ImportService implements IImportService { |
|
|
|
//处理时间、添加任务分解、添加任务标签
|
|
|
|
taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId(),wbsSheet,i+1); |
|
|
|
//添加时间颗粒度标签并关联
|
|
|
|
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
Long timeLabel = labelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
saveLabelTask(taskDetail.getId(),timeLabel); |
|
|
|
//插件
|
|
|
|
plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1); |
|
|
|
plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1); |
|
|
|
plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1); |
|
|
|
Long taskPlugin1 = plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1); |
|
|
|
Long taskPlugin2 = plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1); |
|
|
|
Long taskPlugin3 = plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1); |
|
|
|
TaskDto.TaskPluginId taskPlugin = new TaskDto.TaskPluginId(taskPlugin1,taskPlugin2,taskPlugin3); |
|
|
|
taskMap.put(sequence + "_" + taskName, taskPlugin); |
|
|
|
} |
|
|
|
//TODO 检查人
|
|
|
|
//TODO 及时奖惩
|
|
|
@ -685,7 +738,8 @@ public class ImportService implements IImportService { |
|
|
|
//TODO 添加默认插件
|
|
|
|
} |
|
|
|
} |
|
|
|
private void plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) { |
|
|
|
private Long plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) { |
|
|
|
Long taskPlugin = null; |
|
|
|
if(StrUtil.isNotEmpty(plugin)){ |
|
|
|
//根据插件名称查找插件id
|
|
|
|
Long pluginId = sTaskPluginDao.getPluginIdByName(plugin); |
|
|
@ -702,7 +756,9 @@ public class ImportService implements IImportService { |
|
|
|
proTaskPlugin.setRowspan(1); |
|
|
|
proTaskPlugin.setColspan(1); |
|
|
|
proTaskPluginDao.insertSelective(proTaskPlugin); |
|
|
|
taskPlugin = proTaskPlugin.getId(); |
|
|
|
} |
|
|
|
return taskPlugin; |
|
|
|
} |
|
|
|
|
|
|
|
private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId,XSSFSheet wbsSheet,int row) { |
|
|
@ -735,7 +791,7 @@ public class ImportService implements IImportService { |
|
|
|
taskSub.setPlanEndTime(taskStartTime); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetailId,taskLabel); |
|
|
|
|
|
|
|
}else { |
|
|
@ -745,7 +801,7 @@ public class ImportService implements IImportService { |
|
|
|
taskSub.setTaskDetailId(taskDetailId); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找日常任务标签并关联信息
|
|
|
|
Long label = subLabelDao.getLabelByTypeAndLevel(1, 2); |
|
|
|
Long label = labelDao.getLabelByTypeAndLevel(1, 2); |
|
|
|
saveLabelTask(taskDetailId,label); |
|
|
|
} |
|
|
|
}else { |
|
|
@ -763,7 +819,7 @@ public class ImportService implements IImportService { |
|
|
|
taskSub.setPlanDuration(eTime - bTime); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetailId,taskLabel); |
|
|
|
// //添加时间颗粒度标签并关联
|
|
|
|
// Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4);
|
|
|
@ -792,11 +848,11 @@ public class ImportService implements IImportService { |
|
|
|
sTaskDao.insertSelectiveList(proTaskSubList); |
|
|
|
} |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
Long taskLabel = labelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetailId,taskLabel); |
|
|
|
}catch (Exception e1){ |
|
|
|
throw new BaseException(String.valueOf(e1)); |
|
|
|
// throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR);
|
|
|
|
// throw new BaseException(SportsCodeError.WBS_PROJECT_TIME_ERROR);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -830,9 +886,11 @@ public class ImportService implements IImportService { |
|
|
|
parentTask.setParentTaskDetailId(project.getId()); |
|
|
|
parentTaskMapper.insertSelective(parentTask); |
|
|
|
//查找一级任务标签
|
|
|
|
Long labelId = subLabelDao.getLabelByTypeAndLevel(1, 1); |
|
|
|
Long labelId = labelDao.getLabelByTypeAndLevel(1, 1); |
|
|
|
//添加任务标签关联信息
|
|
|
|
saveLabelTask(taskDetail.getId(), labelId); |
|
|
|
return firstTaskId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|