|
|
@ -5,6 +5,7 @@ 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.carbasics.bean.dto.TaskDto; |
|
|
|
import com.ccsens.carbasics.service.IImportService; |
|
|
|
import com.ccsens.cloudutil.bean.tall.dto.ProjectDto; |
|
|
|
import com.ccsens.cloudutil.feign.Tall3FeignClient; |
|
|
@ -109,18 +110,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_SHEET); |
|
|
|
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(0))); |
|
|
|
//插件2
|
|
|
|
String pluginParam2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); |
|
|
|
//插件3
|
|
|
|
String pluginParam3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(0))); |
|
|
|
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)) { |
|
|
@ -169,7 +220,7 @@ 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); |
|
|
@ -546,7 +597,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; |
|
|
@ -598,6 +649,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)){ |
|
|
@ -675,9 +728,11 @@ public class ImportService implements IImportService { |
|
|
|
Long timeLabel = subLabelDao.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 +740,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 +758,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) { |
|
|
|