|
|
|
@ -249,7 +249,7 @@ public class ImportService implements IImportService { |
|
|
|
//版本
|
|
|
|
String version = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); |
|
|
|
if (StrUtil.isEmpty(projectName)) { |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_PROJECT_NAME); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_PROJECT_NAME.addMsg(wbsSheet.getSheetName(),projectStart+1)); |
|
|
|
} |
|
|
|
//项目名不能重复(当前用户创建的项目内名字不能重复)
|
|
|
|
//根据userId查找已创建的项目
|
|
|
|
@ -258,7 +258,7 @@ public class ImportService implements IImportService { |
|
|
|
sysProjectList.forEach(p -> { |
|
|
|
if(projectName.equalsIgnoreCase(p.getName())){ |
|
|
|
//如果名称重复则提示错误信息
|
|
|
|
throw new BaseException(DefaultCodeError.PROJECT_NAME_REPEAT); |
|
|
|
throw new BaseException(DefaultCodeError.PROJECT_NAME_REPEAT.addMsg(wbsSheet.getSheetName(),projectStart+1,projectName)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -266,7 +266,7 @@ public class ImportService implements IImportService { |
|
|
|
String begin = ExcelUtil.getCellValue(row.getCell(3)); |
|
|
|
String end = ExcelUtil.getCellValue(row.getCell(4)); |
|
|
|
if (StrUtil.isEmpty(begin) || StrUtil.isEmpty(end)) { |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_PROJECT_TIME); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_PROJECT_TIME.addMsg(wbsSheet.getSheetName(),projectStart+1)); |
|
|
|
} |
|
|
|
long bTime; |
|
|
|
long eTime; |
|
|
|
@ -275,7 +275,7 @@ public class ImportService implements IImportService { |
|
|
|
eTime = Long.parseLong(endTime); |
|
|
|
} catch (Exception e) { |
|
|
|
//日期格式错误
|
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR.addMsg(wbsSheet.getSheetName(),projectStart+1)); |
|
|
|
} |
|
|
|
//添加项目信息(任务详情)
|
|
|
|
ProTaskDetail taskDetail = new ProTaskDetail(); |
|
|
|
@ -344,7 +344,7 @@ public class ImportService implements IImportService { |
|
|
|
if(StrUtil.isNotEmpty(sysRole) && !"/".equalsIgnoreCase(sysRole)){ |
|
|
|
Long labelId = subLabelDao.getLabelByName(5,sysRole); |
|
|
|
if(ObjectUtil.isNull(labelId)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIRST_ROLE); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIRST_ROLE.addMsg(memberSheet.getSheetName(),i+1,sysRole)); |
|
|
|
} |
|
|
|
sysRoleId = labelId; |
|
|
|
} |
|
|
|
@ -357,14 +357,14 @@ public class ImportService implements IImportService { |
|
|
|
//角色手机号
|
|
|
|
String memberPhone = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); |
|
|
|
if((StrUtil.isNotEmpty(memberName) && !"/".equalsIgnoreCase(memberName)) && (StrUtil.isEmpty(memberPhone) || !memberPhone.matches(Constant.PHONE_REGEX))){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PHONE_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PHONE_ERROR.addMsg(memberSheet.getSheetName(),i+1,memberPhone)); |
|
|
|
} |
|
|
|
//奖惩干系人
|
|
|
|
String stakeholderName = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); |
|
|
|
//干系人电话
|
|
|
|
String stakeholderPhone = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(6))); |
|
|
|
if((StrUtil.isNotEmpty(stakeholderName) && !"/".equalsIgnoreCase(stakeholderName)) && (StrUtil.isEmpty(stakeholderPhone) || !stakeholderPhone.matches(Constant.PHONE_REGEX))){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PHONE_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PHONE_ERROR.addMsg(memberSheet.getSheetName(),i+1,stakeholderName)); |
|
|
|
} |
|
|
|
//添加角色
|
|
|
|
if(StrUtil.isNotEmpty(roleName) && !"/".equalsIgnoreCase(roleName)){ |
|
|
|
@ -453,7 +453,7 @@ public class ImportService implements IImportService { |
|
|
|
for (String repulsionName : split) { |
|
|
|
Long repulsionId = roleMap.get(repulsionName); |
|
|
|
if (ObjectUtil.isNull(repulsionId)) { |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE.addMsg(memberSheet.getSheetName(),i+1,repulsionName)); |
|
|
|
} |
|
|
|
//添加数据
|
|
|
|
ProRoleRepulsion roleRepulsion = new ProRoleRepulsion(); |
|
|
|
@ -523,7 +523,7 @@ public class ImportService implements IImportService { |
|
|
|
//查找重要性标签
|
|
|
|
Long labelId = subLabelDao.getLabelByName(2,vitalLabel); |
|
|
|
if(ObjectUtil.isNull(labelId)){ |
|
|
|
throw new BaseException(DefaultCodeError.TASK_VITAL_LABEL_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.TASK_VITAL_LABEL_ERROR.addMsg(wbsSheet.getSheetName(),i+1,vitalLabel)); |
|
|
|
} |
|
|
|
LabelBusiness labelBusiness = new LabelBusiness(); |
|
|
|
labelBusiness.setId(snowflake.nextId()); |
|
|
|
@ -533,13 +533,13 @@ public class ImportService implements IImportService { |
|
|
|
labelBusinessDao.insertSelective(labelBusiness); |
|
|
|
//任务和角色关联
|
|
|
|
if(StrUtil.isEmpty(executorRole)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,executorRole)); |
|
|
|
} |
|
|
|
String[] split = executorRole.split(Constant.STRING_REGEX); |
|
|
|
for (String repulsionName : split) { |
|
|
|
Long executorRoleId = roleMap.get(repulsionName); |
|
|
|
if(ObjectUtil.isNull(executorRoleId)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE.addMsg(wbsSheet.getSheetName(),i+1,repulsionName)); |
|
|
|
} |
|
|
|
ProRoleTask roleTask = new ProRoleTask(); |
|
|
|
roleTask.setId(snowflake.nextId()); |
|
|
|
@ -549,14 +549,14 @@ public class ImportService implements IImportService { |
|
|
|
} |
|
|
|
|
|
|
|
//处理时间、添加任务分解、添加任务标签
|
|
|
|
taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId()); |
|
|
|
taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId(),wbsSheet,i+1); |
|
|
|
//添加时间颗粒度标签并关联
|
|
|
|
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
saveLabelTask(taskDetail.getId(),timeLabel); |
|
|
|
//插件
|
|
|
|
plugin(plugin1,taskDetail.getId(),1); |
|
|
|
plugin(plugin2,taskDetail.getId(),2); |
|
|
|
plugin(plugin3,taskDetail.getId(),3); |
|
|
|
plugin(plugin1,taskDetail.getId(),1,wbsSheet,i+1); |
|
|
|
plugin(plugin2,taskDetail.getId(),2,wbsSheet,i+1); |
|
|
|
plugin(plugin3,taskDetail.getId(),3,wbsSheet,i+1); |
|
|
|
} |
|
|
|
//TODO 检查人
|
|
|
|
//TODO 及时奖惩
|
|
|
|
@ -564,12 +564,12 @@ public class ImportService implements IImportService { |
|
|
|
//TODO 添加默认插件
|
|
|
|
} |
|
|
|
} |
|
|
|
private void plugin(String plugin,Long taskId,int row) { |
|
|
|
private void plugin(String plugin,Long taskId,int row,XSSFSheet wbsSheet,int errorRow) { |
|
|
|
if(StrUtil.isNotEmpty(plugin)){ |
|
|
|
//根据插件名称查找插件id
|
|
|
|
Long pluginId = sTaskPluginDao.getPluginIdByName(plugin); |
|
|
|
if(ObjectUtil.isNull(pluginId)){ |
|
|
|
throw new BaseException(DefaultCodeError.PLUGIN_NAME_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.PLUGIN_NAME_ERROR.addMsg(wbsSheet.getSheetName(),errorRow,plugin)); |
|
|
|
} |
|
|
|
//添加插件
|
|
|
|
ProTaskPlugin proTaskPlugin = new ProTaskPlugin(); |
|
|
|
@ -584,7 +584,7 @@ public class ImportService implements IImportService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId) { |
|
|
|
private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId,XSSFSheet wbsSheet,int row) { |
|
|
|
|
|
|
|
if(StrUtil.isEmpty(beginTime) || "日常".equalsIgnoreCase(beginTime)){ |
|
|
|
if(StrUtil.isEmpty(beginTime) && StrUtil.isNotEmpty(duration)){ |
|
|
|
@ -595,7 +595,7 @@ public class ImportService implements IImportService { |
|
|
|
String trimStr = mStr.replaceAll("").trim(); |
|
|
|
Long aLong = Constant.WBS_DURATION.get(trimStr); |
|
|
|
if(ObjectUtil.isNull(aLong)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR.addMsg(wbsSheet.getSheetName(),row)); |
|
|
|
} |
|
|
|
//获取字符串内的数字
|
|
|
|
String num = "[^0-9]"; |
|
|
|
|