@ -7,13 +7,13 @@ import cn.hutool.core.util.StrUtil;
import com.ccsens.ptccsens.bean.dto.RoleDto ;
import com.ccsens.ptccsens.bean.dto.TaskDto ;
import com.ccsens.ptccsens.bean.po.* ;
import com.ccsens.ptccsens.util.Constant ;
import com.ccsens.ptccsens.bean.vo.ProjectVo ;
import com.ccsens.ptccsens.persist.dao.* ;
import com.ccsens.ptccsens.persist.mapper.ProMemberStakeholderMapper ;
import com.ccsens.ptccsens.util.BasicsCodeError ;
import com.ccsens.ptccsens.util.BasicsConstant ;
import com.ccsens.ptccsens.util.Constant ;
import com.ccsens.util.ExcelUtil ;
import com.ccsens.util.PropUtil ;
import com.ccsens.util.StringUtil ;
import com.ccsens.util.cron.CronConstant ;
import com.ccsens.util.cron.NatureToDate ;
@ -62,7 +62,7 @@ public class ImportService implements IImportService {
@Resource
private ProRoleMemberDao roleMemberDao ;
@Resource
private ProMemberStakeholderMapper memberStakeholderMapper ;
private ProMemberStakeholderDao memberStakeholderDao ;
@Resource
private ProRoleRepulsionDao repulsionDao ;
@Resource
@ -203,7 +203,7 @@ public class ImportService implements IImportService {
throw new BaseException ( BasicsCodeError . WSB_NOT_TASK_HEADER ) ;
}
//添加项目
ProjectVo . SysProject project = readProject ( wbsSheet , projectStart , userId , projectId ) ;
ProjectVo . SysProject project = readProject ( wbsSheet , projectStart , userId ) ;
if ( ObjectUtil . isNull ( project ) ) {
throw new BaseException ( BasicsCodeError . WSB_NOT_PROJECT_HEADER ) ;
}
@ -253,36 +253,54 @@ public class ImportService implements IImportService {
roleMember . setRoleId ( role . getId ( ) ) ;
roleMember . setMemberId ( memberId ) ;
roleMemberDao . insertSelective ( roleMember ) ;
// //TODO 在tall客户端添加项目和用户的关联信息
// ProjectDto.SaveProjectDto saveProjectDto = new ProjectDto.SaveProjectDto();
// saveProjectDto.setId(project.getId());
// saveProjectDto.setName(project.getName());
// saveProjectDto.setStartTime(project.getBeginTime());
// saveProjectDto.setEndTime(project.getEndTime());
// saveProjectDto.setUrl(PropUtil.domain);
//
// saveProjectDto.setUserIdList(userIdSet);
// JsonResponse jsonResponse = tall3FeignClient.saveProjectList(saveProjectDto);
// if (null == jsonResponse){
// throw new BaseException(BasicsCodeError.FEIGN_ERROR);
// }
//获取项目信息
// BeanUtil.copyProperties(saveProjectDto,projectInfo);
//返回项目信息
projectInfo . setId ( project . getId ( ) ) ;
projectInfo . setName ( project . getName ( ) ) ;
projectInfo . setStartTime ( project . getBeginTime ( ) ) ;
projectInfo . setEndTime ( project . getEndTime ( ) ) ;
projectInfo . setUrl ( PropUtil . notGatewayUrl ) ;
projectInfo . setBusinessCode ( Constant . BUSINESS_CODE ) ;
}
/ * *
* 读取项目信息
* /
private ProjectVo . SysProject readProject ( XSSFSheet wbsSheet , int projectStart , Long userId , Long projectId ) {
private ProjectVo . SysProject readProject ( XSSFSheet wbsSheet , int projectStart , Long userId ) {
ProjectVo . SysProject project = new ProjectVo . SysProject ( ) ;
// TODO 查询是否项目是否存在
if ( ObjectUtil . isNotNull ( projectId ) ) {
//获取项目信息的那一行
XSSFRow row = wbsSheet . getRow ( projectStart + 1 ) ;
if ( ObjectUtil . isNull ( row ) ) {
throw new BaseException ( BasicsCodeError . WSB_NOT_PROJECT_HEADER ) ;
}
//项目名
String projectName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 0 ) ) ) ;
//项目id
String projectIdCell = ExcelUtil . getCellComment ( row . getCell ( 0 ) ) ;
//详情
String description = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 1 ) ) ) ;
//项目地点
String address = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 2 ) ) ) ;
//开始时间
String beginTime = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 3 ) ) ) ;
//结束时间
String endTime = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 4 ) ) ) ;
//版本
String version = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 5 ) ) ) ;
if ( StrUtil . isEmpty ( projectName ) ) {
throw new BaseException ( BasicsCodeError . WBS_NOT_PROJECT_NAME . addMsg ( wbsSheet . getSheetName ( ) , projectStart + 1 ) ) ;
}
//TODO 验证是否有项目id且项目id合法
Long projectId = null ;
if ( StrUtil . isNotBlank ( projectIdCell ) ) {
try {
projectId = Long . parseLong ( projectIdCell ) ;
} catch ( Exception e ) {
log . info ( "项目id分解异常" ) ;
}
project = projectDao . selectById ( projectId ) ;
if ( ObjectUtil . isNotNull ( project ) ) {
project . setId ( projectId ) ;
project . setImportType ( ( byte ) 1 ) ;
project . setImportType ( ( byte ) 1 ) ;
//删除之前的项目详情
projectDao . updateStatusById ( projectId ) ;
//删除之前的项目分解
@ -305,36 +323,18 @@ public class ImportService implements IImportService {
labelBusinessDao . updateByExampleSelective ( labelBusiness , labelBusinessExample ) ;
}
}
//获取项目信息的那一行
XSSFRow row = wbsSheet . getRow ( projectStart + 1 ) ;
if ( ObjectUtil . isNull ( row ) ) {
throw new BaseException ( BasicsCodeError . WSB_NOT_PROJECT_HEADER ) ;
}
//项目名
String projectName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 0 ) ) ) ;
//详情
String description = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 1 ) ) ) ;
//项目时间
String address = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 2 ) ) ) ;
//开始时间
String beginTime = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 3 ) ) ) ;
//结束时间
String endTime = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 4 ) ) ) ;
//版本
String version = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 5 ) ) ) ;
if ( StrUtil . isEmpty ( projectName ) ) {
throw new BaseException ( BasicsCodeError . WBS_NOT_PROJECT_NAME . addMsg ( wbsSheet . getSheetName ( ) , projectStart + 1 ) ) ;
}
//项目名不能重复(当前用户创建的项目内名字不能重复)
//根据userId查找已创建的项目
List < ProjectVo . SysProject > sysProjectList = projectDao . queryByCreator ( userId ) ;
if ( CollectionUtil . isNotEmpty ( sysProjectList ) ) {
sysProjectList . forEach ( p - > {
if ( projectName . equalsIgnoreCase ( p . getName ( ) ) ) {
//如果名称重复则提示错误信息
throw new BaseException ( BasicsCodeError . PROJECT_NAME_REPEAT . addMsg ( wbsSheet . getSheetName ( ) , projectStart + 1 , projectName ) ) ;
}
} ) ;
if ( 0 = = project . getImportType ( ) ) {
List < ProjectVo . SysProject > sysProjectList = projectDao . queryByCreator ( userId ) ;
if ( CollectionUtil . isNotEmpty ( sysProjectList ) ) {
sysProjectList . forEach ( p - > {
if ( projectName . equalsIgnoreCase ( p . getName ( ) ) ) {
//如果名称重复则提示错误信息
throw new BaseException ( BasicsCodeError . PROJECT_NAME_REPEAT . addMsg ( wbsSheet . getSheetName ( ) , projectStart + 1 , projectName ) ) ;
}
} ) ;
}
}
//判断时间是否正确
String begin = ExcelUtil . getCellValue ( row . getCell ( 3 ) ) ;
@ -351,24 +351,14 @@ public class ImportService implements IImportService {
//日期格式错误
throw new BaseException ( BasicsCodeError . WBS_PROJECT_TIME_ERROR . addMsg ( wbsSheet . getSheetName ( ) , projectStart + 1 ) ) ;
}
//添加项目信息(任务详情)
ProTaskDetail taskDetail = new ProTaskDetail ( ) ;
if ( 0 = = project . getImportType ( ) ) {
taskDetail . setId ( snowflake . nextId ( ) ) ;
}
if ( 1 = = project . getImportType ( ) ) {
taskDetail . setId ( projectId ) ;
}
taskDetail . setId ( ( 1 = = project . getImportType ( ) & & projectId ! = null ) ? projectId : snowflake . nextId ( ) ) ;
taskDetail . setName ( projectName ) ;
taskDetail . setDescription ( description ) ;
if ( 0 = = project . getImportType ( ) ) {
taskDetailDao . insertSelective ( taskDetail ) ;
}
if ( 1 = = project . getImportType ( ) ) {
taskDetailDao . updateByPrimaryKeySelective ( taskDetail ) ;
}
project . setId ( taskDetail . getId ( ) ) ;
project . setName ( projectName ) ;
// taskDetailDao.insertSelective(taskDetail);
taskDetailDao . insertReplace ( taskDetail ) ;
//添加(任务分解)
ProTaskSub taskSub = new ProTaskSub ( ) ;
taskSub . setId ( snowflake . nextId ( ) ) ;
@ -377,8 +367,6 @@ public class ImportService implements IImportService {
taskSub . setPlanEndTime ( eTime ) ;
taskSub . setPlanDuration ( eTime - bTime ) ;
taskSubDao . insertSelective ( taskSub ) ;
project . setBeginTime ( bTime ) ;
project . setEndTime ( eTime ) ;
//添加版本信息
ProTaskVersion taskVersion = new ProTaskVersion ( ) ;
taskVersion . setId ( snowflake . nextId ( ) ) ;
@ -391,6 +379,10 @@ public class ImportService implements IImportService {
//添加任务标签关联信息
saveLabelTask ( taskDetail . getId ( ) , labelId ) ;
project . setId ( taskDetail . getId ( ) ) ;
project . setName ( projectName ) ;
project . setBeginTime ( bTime ) ;
project . setEndTime ( eTime ) ;
return project ;
}
@ -435,7 +427,7 @@ public class ImportService implements IImportService {
memberStakeholder . setRecStatus ( ( byte ) 2 ) ;
ProMemberStakeholderExample memberStakeholderExample = new ProMemberStakeholderExample ( ) ;
memberStakeholderExample . createCriteria ( ) . andMemeberIdIn ( memberIdList ) ;
memberStakeholderMapper . updateByExampleSelective ( memberStakeholder , memberStakeholderExample ) ;
memberStakeholderDao . updateByExampleSelective ( memberStakeholder , memberStakeholderExample ) ;
//删除对谁不可见
ProRoleRepulsion roleRepulsion = new ProRoleRepulsion ( ) ;
roleRepulsion . setRecStatus ( ( byte ) 2 ) ;
@ -470,9 +462,12 @@ public class ImportService implements IImportService {
//项目角色
String roleName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 2 ) ) ) ;
if ( ( StrUtil . isEmpty ( roleName ) | | "/" . equalsIgnoreCase ( roleName ) ) & & ObjectUtil . isNull ( roleId ) ) { continue ; }
//角色id
String roleIdCell = ExcelUtil . getCellComment ( row . getCell ( 2 ) ) ;
//成员
String memberName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 3 ) ) ) ;
//成员id
String memberIdCell = ExcelUtil . getCellComment ( row . getCell ( 3 ) ) ;
//角色手机号
String memberPhone = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 4 ) ) ) ;
if ( ( StrUtil . isNotEmpty ( memberName ) & & ! "/" . equalsIgnoreCase ( memberName ) ) & & ( StrUtil . isEmpty ( memberPhone ) | | ! memberPhone . matches ( Constant . PHONE_REGEX ) ) ) {
@ -480,6 +475,8 @@ public class ImportService implements IImportService {
}
//奖惩干系人
String stakeholderName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 5 ) ) ) ;
//奖惩干系人id
String stakeholderIdCell = ExcelUtil . getCellComment ( 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 ) ) ) {
@ -487,12 +484,19 @@ public class ImportService implements IImportService {
}
//添加角色
if ( StrUtil . isNotEmpty ( roleName ) & & ! "/" . equalsIgnoreCase ( roleName ) ) {
if ( StrUtil . isNotBlank ( roleIdCell ) ) {
try {
roleId = Long . parseLong ( roleIdCell ) ;
} catch ( Exception e ) {
log . info ( "角色id解析失败" ) ;
}
}
ProRole role = new ProRole ( ) ;
role . setId ( snowflake . nextId ( ) ) ;
role . setId ( ( 1 = = project . getImportType ( ) & & roleId ! = null ) ? roleId : snowflake . nextId ( ) ) ;
role . setName ( roleName ) ;
role . setProjectId ( project . getId ( ) ) ;
role . setLabelId ( sysRoleId ) ;
roleDao . insertSelective ( role ) ;
roleDao . insertReplac e ( role ) ;
roleId = role . getId ( ) ;
roleMap . put ( roleName , role . getId ( ) ) ;
}
@ -505,8 +509,13 @@ public class ImportService implements IImportService {
memberId = wbsMembers . getId ( ) ;
}
if ( ObjectUtil . isNull ( memberId ) ) {
//TODO 根据成员手机号查找userId 成员关联userId
if ( StrUtil . isNotBlank ( memberIdCell ) ) {
try {
memberId = Long . parseLong ( memberIdCell ) ;
} catch ( Exception e ) {
log . info ( "成员id解析失败" ) ;
}
}
//根据手机号获取userId
ProUser user = userDao . getUserIdByPhone ( memberPhone ) ;
if ( ObjectUtil . isNull ( user ) ) {
@ -519,15 +528,42 @@ public class ImportService implements IImportService {
Long userId = user . getId ( ) ;
//添加成员至数据库
ProMember proMember = new ProMember ( ) ;
proMember . setId ( snowflake . nextId ( ) ) ;
proMember . setId ( ( 1 = = project . getImportType ( ) & & memberId ! = null ) ? memberId : snowflake . nextId ( ) ) ;
proMember . setName ( memberName ) ;
proMember . setPhone ( memberPhone ) ;
proMember . setProjectId ( project . getId ( ) ) ;
proMember . setUserId ( userId ) ;
memberDao . insertSelectiv e ( proMember ) ;
memberDao . insertReplac e ( proMember ) ;
RoleDto . WbsMember member = new RoleDto . WbsMember ( proMember . getId ( ) , userId ) ;
memberMap . put ( memberName + "_" + memberPhone , member ) ;
memberId = proMember . getId ( ) ;
//添加奖惩干系人
if ( StrUtil . isNotEmpty ( stakeholderName ) & & ! "/" . equalsIgnoreCase ( roleName ) ) {
//根据干系人手机号查找userId 奖惩干系人关联userId
ProUser stakeholderUser = userDao . getUserIdByPhone ( stakeholderPhone ) ;
if ( ObjectUtil . isNull ( stakeholderUser ) ) {
//如果未查到用户则添加一条新的用户信息
stakeholderUser = new ProUser ( ) ;
stakeholderUser . setId ( snowflake . nextId ( ) ) ;
stakeholderUser . setPhone ( stakeholderPhone ) ;
userDao . insertSelective ( stakeholderUser ) ;
}
Long stakeholderId = null ;
if ( StrUtil . isNotBlank ( stakeholderIdCell ) ) {
try {
stakeholderId = Long . parseLong ( stakeholderIdCell ) ;
} catch ( Exception e ) {
log . info ( "奖惩干系人id解析失败" ) ;
}
}
ProMemberStakeholder memberStakeholder = new ProMemberStakeholder ( ) ;
memberStakeholder . setId ( ( 1 = = project . getImportType ( ) & & stakeholderId ! = null ) ? stakeholderId : snowflake . nextId ( ) ) ;
memberStakeholder . setMemeberId ( memberId ) ;
memberStakeholder . setStakeholderName ( stakeholderName ) ;
memberStakeholder . setStakeholderPhone ( stakeholderPhone ) ;
memberStakeholder . setUserId ( stakeholderUser . getId ( ) ) ;
memberStakeholderDao . insertReplace ( memberStakeholder ) ;
}
}
//添加角色成员关联信息
ProRoleMember roleMember = new ProRoleMember ( ) ;
@ -535,26 +571,6 @@ public class ImportService implements IImportService {
roleMember . setRoleId ( roleId ) ;
roleMember . setMemberId ( memberId ) ;
roleMemberDao . insertSelective ( roleMember ) ;
//添加奖惩干系人
if ( StrUtil . isNotEmpty ( stakeholderName ) & & ! "/" . equalsIgnoreCase ( roleName ) ) {
//TODO 根据干系人手机号查找userId 奖惩干系人关联userId
ProUser user = userDao . getUserIdByPhone ( stakeholderPhone ) ;
if ( ObjectUtil . isNull ( user ) ) {
//TODO 如果未查到用户则添加一条新的用户信息
user = new ProUser ( ) ;
user . setId ( snowflake . nextId ( ) ) ;
user . setPhone ( stakeholderPhone ) ;
userDao . insertSelective ( user ) ;
}
Long userId = user . getId ( ) ;
ProMemberStakeholder memberStakeholder = new ProMemberStakeholder ( ) ;
memberStakeholder . setId ( snowflake . nextId ( ) ) ;
memberStakeholder . setMemeberId ( memberId ) ;
memberStakeholder . setStakeholderName ( stakeholderName ) ;
memberStakeholder . setStakeholderPhone ( stakeholderPhone ) ;
memberStakeholder . setUserId ( userId ) ;
memberStakeholderMapper . insertSelective ( memberStakeholder ) ;
}
}
}
//添加对谁不可见
@ -664,21 +680,29 @@ public class ImportService implements IImportService {
if ( StrUtil . isEmpty ( firstTaskName ) & & ObjectUtil . isNull ( firstTaskId ) ) {
continue ;
}
//一级任务id
String firstTaskIdCell = ExcelUtil . getCellComment ( row . getCell ( 1 ) ) ;
if ( StrUtil . isNotEmpty ( firstTaskName ) ) {
//添加一级任务
firstTaskId = saveFirstTask ( project , firstTaskName ) ;
firstTaskId = saveFirstTask ( project , firstTaskName , firstTaskIdCell ) ;
}
//二级任务名
String taskName = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 2 ) ) ) ;
if ( StrUtil . isEmpty ( taskName ) ) {
continue ;
}
//二级任务分解id
String subIdCell = ExcelUtil . getCellComment ( row . getCell ( 2 ) ) ;
//二级任务详情id
String detailIdCell = ExcelUtil . getCellComment ( row . getCell ( 3 ) ) ;
//任务描述
String description = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 3 ) ) ) ;
//重要性标签
String vitalLabel = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 7 ) ) ) ;
//负责人
String executorRole = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 8 ) ) ) ;
//检查人
String checkerRole = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 9 ) ) ) ;
//开始时间
String beginTime = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 4 ) ) ) ;
//结束时间
@ -687,17 +711,30 @@ public class ImportService implements IImportService {
String duration = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 6 ) ) ) ;
//交付物
String deliver = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 10 ) ) ) ;
//二级任务详情id
String deliverIdCell = ExcelUtil . getCellComment ( row . getCell ( 10 ) ) ;
//插件
String plugin1 = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 12 ) ) ) ;
String pluginIdCell1 = ExcelUtil . getCellComment ( row . getCell ( 12 ) ) ;
String plugin2 = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 13 ) ) ) ;
String pluginIdCell2 = ExcelUtil . getCellComment ( row . getCell ( 13 ) ) ;
String plugin3 = StringUtil . replaceStrSpace ( ExcelUtil . getCellValue ( row . getCell ( 14 ) ) ) ;
String pluginIdCell3 = ExcelUtil . getCellComment ( row . getCell ( 14 ) ) ;
if ( StrUtil . isNotEmpty ( taskName ) ) {
Long detailId = null ;
if ( StrUtil . isNotBlank ( detailIdCell ) ) {
try {
detailId = Long . parseLong ( detailIdCell ) ;
} catch ( Exception e ) {
log . info ( "任务详情id解析失败" ) ;
}
}
//添加二级任务信息(任务详情)
ProTaskDetail taskDetail = new ProTaskDetail ( ) ;
taskDetail . setId ( snowflake . nextId ( ) ) ;
taskDetail . setId ( ( 1 = = project . getImportType ( ) & & detailId ! = null ) ? detailId : snowflake . nextId ( ) ) ;
taskDetail . setName ( taskName ) ;
taskDetail . setDescription ( description ) ;
taskDetailDao . insertSelective ( taskDetail ) ;
taskDetailDao . insertReplac e ( taskDetail ) ;
//任务关联信息(关联一级任务)
ProParentTask parentTask = new ProParentTask ( ) ;
parentTask . setId ( snowflake . nextId ( ) ) ;
@ -715,7 +752,7 @@ public class ImportService implements IImportService {
labelBusiness . setBusinessId ( taskDetail . getId ( ) ) ;
labelBusiness . setLabelId ( labelId ) ;
labelBusinessDao . insertSelective ( labelBusiness ) ;
//任务和角色 关联
//任务和负责人 关联
if ( StrUtil . isEmpty ( executorRole ) ) {
throw new BaseException ( BasicsCodeError . WBS_NOT_FIND_ROLE . addMsg ( wbsSheet . getSheetName ( ) , i + 1 , executorRole ) ) ;
}
@ -732,15 +769,47 @@ public class ImportService implements IImportService {
roleTaskMapper . insertSelective ( roleTask ) ;
}
//任务和检查人关联
if ( StrUtil . isNotEmpty ( checkerRole ) ) {
Long checkerRoleId = roleMap . get ( checkerRole ) ;
if ( ObjectUtil . isNull ( checkerRoleId ) ) {
throw new BaseException ( BasicsCodeError . WBS_NOT_FIND_ROLE . addMsg ( wbsSheet . getSheetName ( ) , i + 1 , checkerRole ) ) ;
}
ProRoleTask roleTask = new ProRoleTask ( ) ;
roleTask . setId ( snowflake . nextId ( ) ) ;
roleTask . setRoleDuty ( ( byte ) 1 ) ;
roleTask . setRoleId ( checkerRoleId ) ;
roleTask . setTaskId ( taskDetail . getId ( ) ) ;
roleTaskMapper . insertSelective ( roleTask ) ;
} else {
throw new BaseException ( BasicsCodeError . WBS_NOT_FIND_ROLE . addMsg ( wbsSheet . getSheetName ( ) , i + 1 , executorRole ) ) ;
}
//处理时间、添加任务分解、添加任务标签
taskStartTime = taskSaveTime ( taskStartTime , project , beginTime , endTime , duration , taskDetail . getId ( ) , wbsSheet , i + 1 , deliver ) ;
Long subId = null ;
if ( StrUtil . isNotBlank ( subIdCell ) ) {
try {
subId = Long . parseLong ( subIdCell ) ;
} catch ( Exception e ) {
log . info ( "任务分解id解析失败" ) ;
}
}
Long deliverId = null ;
if ( StrUtil . isNotBlank ( deliverIdCell ) ) {
try {
deliverId = Long . parseLong ( deliverIdCell ) ;
} catch ( Exception e ) {
log . info ( "交付物id解析失败" ) ;
}
}
taskStartTime = taskSaveTime ( subId , taskStartTime , project , beginTime , endTime , duration , taskDetail . getId ( ) , wbsSheet , i + 1 , deliver , deliverId ) ;
//添加时间颗粒度标签并关联
Long timeLabel = labelDao . getLabelByTypeAndLevel ( 0 , 4 ) ;
saveLabelTask ( taskDetail . getId ( ) , timeLabel ) ;
//TODO 插件
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 ) ;
Long taskPlugin1 = plugin ( project , pluginIdCell1 , p lugin1 , taskDetail . getId ( ) , 1 , wbsSheet , i + 1 ) ;
Long taskPlugin2 = plugin ( project , pluginIdCell2 , p lugin2 , taskDetail . getId ( ) , 2 , wbsSheet , i + 1 ) ;
Long taskPlugin3 = plugin ( project , pluginIdCell3 , p lugin3 , taskDetail . getId ( ) , 3 , wbsSheet , i + 1 ) ;
TaskDto . TaskPluginId taskPlugin = new TaskDto . TaskPluginId ( taskPlugin1 , taskPlugin2 , taskPlugin3 ) ;
taskMap . put ( sequence + "_" + taskName , taskPlugin ) ;
}
@ -751,22 +820,23 @@ public class ImportService implements IImportService {
//TODO 添加默认插件
}
}
private Long plugin ( String plugin , Long taskId , int row , XSSFSheet wbsSheet , int errorRow ) {
private Long plugin ( ProjectVo . SysProject project , String pluginIdCell , String plugin , Long taskId , int row , XSSFSheet wbsSheet , int errorRow ) {
Long taskPlugin = null ;
if ( StrUtil . isNotEmpty ( plugin ) ) {
//根据插件名称查找插件id
// Long pluginId = taskPluginDao.getPluginIdByName(plugin);
// Long pluginId = 1L;
// if(ObjectUtil.isNull(pluginId)){
// throw new BaseException(BasicsCodeError.PLUGIN_NAME_ERROR.addMsg(wbsSheet.getSheetName(),errorRow,plugin));
// }
if ( StrUtil . isNotBlank ( pluginIdCell ) ) {
try {
taskPlugin = Long . parseLong ( pluginIdCell ) ;
} catch ( Exception e ) {
log . info ( "任务插件id解析失败" ) ;
}
}
TallPluginVo . BusinessPluginInfo pluginByCodeAndName = PluginUtil . getPluginByCodeAndName ( Constant . BUSINESS_CODE , plugin ) ;
if ( ObjectUtil . isNull ( pluginByCodeAndName ) ) {
throw new BaseException ( BasicsCodeError . PLUGIN_NAME_ERROR . addMsg ( wbsSheet . getSheetName ( ) , errorRow , plugin ) ) ;
}
//添加插件
ProTaskPlugin proTaskPlugin = new ProTaskPlugin ( ) ;
proTaskPlugin . setId ( snowflake . nextId ( ) ) ;
proTaskPlugin . setId ( ( 1 = = project . getImportType ( ) & & taskPlugin ! = null ) ? taskPlugin : snowflake . nextId ( ) ) ;
proTaskPlugin . setTaskDetailId ( taskId ) ;
proTaskPlugin . setPluginId ( pluginByCodeAndName . getPluginId ( ) ) ;
proTaskPlugin . setBusinessPluginId ( pluginByCodeAndName . getBusinessPluginId ( ) ) ;
@ -777,13 +847,13 @@ public class ImportService implements IImportService {
proTaskPlugin . setRowspan ( 1 ) ;
proTaskPlugin . setColspan ( 1 ) ;
proTaskPlugin . setCode ( plugin ) ;
proTaskPluginDao . insertSelectiv e ( proTaskPlugin ) ;
proTaskPluginDao . insertReplac e ( 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 , String deliver ) {
private Long taskSaveTime ( Long subId , Long taskStartTime , ProjectVo . SysProject project , String beginTime , String endTime , String duration , Long taskDetailId , XSSFSheet wbsSheet , int row , String deliver , Long deliverId ) {
if ( StrUtil . isEmpty ( beginTime ) | | "日常" . equalsIgnoreCase ( beginTime ) ) {
if ( StrUtil . isEmpty ( beginTime ) & & StrUtil . isNotEmpty ( duration ) ) {
@ -805,17 +875,17 @@ public class ImportService implements IImportService {
Long durationTime = Long . parseLong ( trimNum ) * aLong ;
//添加任务分解
ProTaskSub taskSub = new ProTaskSub ( ) ;
taskSub . setId ( snowflake . nextId ( ) ) ;
taskSub . setId ( ( 1 = = project . getImportType ( ) & & subId ! = null ) ? subId : snowflake . nextId ( ) ) ;
taskSub . setTaskDetailId ( taskDetailId ) ;
taskSub . setPlanDuration ( durationTime ) ;
taskSub . setPlanStartTime ( taskStartTime ) ;
taskStartTime + = durationTime ;
taskSub . setPlanEndTime ( taskStartTime ) ;
taskSubDao . insertSelectiv e ( taskSub ) ;
taskSubDao . insertReplac e ( taskSub ) ;
//TODO 添加交付物信息
//添加交付物信息
if ( StrUtil . isNotBlank ( deliver ) ) {
saveDeliver ( deliver , taskSub ) ;
saveDeliver ( project , deliverId , deliver , taskSub ) ;
}
//查找定期任务标签并关联任务
Long taskLabel = labelDao . getLabelByTypeAndLevel ( 1 , 3 ) ;
@ -824,12 +894,12 @@ public class ImportService implements IImportService {
} else {
//添加任务分解
ProTaskSub taskSub = new ProTaskSub ( ) ;
taskSub . setId ( snowflake . nextId ( ) ) ;
taskSub . setId ( ( 1 = = project . getImportType ( ) & & subId ! = null ) ? subId : snowflake . nextId ( ) ) ;
taskSub . setTaskDetailId ( taskDetailId ) ;
taskSubDao . insertSelectiv e ( taskSub ) ;
taskSubDao . insertReplac e ( taskSub ) ;
//添加交付物信息
if ( StrUtil . isNotBlank ( deliver ) ) {
saveDeliver ( deliver , taskSub ) ;
saveDeliver ( project , deliverId , deliver , taskSub ) ;
}
//查找日常任务标签并关联信息
Long label = labelDao . getLabelByTypeAndLevel ( 1 , 2 ) ;
@ -843,15 +913,15 @@ public class ImportService implements IImportService {
eTime = StrUtil . isEmpty ( endTime ) ? project . getEndTime ( ) : Long . parseLong ( endTime ) ;
//添加任务分解
ProTaskSub taskSub = new ProTaskSub ( ) ;
taskSub . setId ( snowflake . nextId ( ) ) ;
taskSub . setId ( ( 1 = = project . getImportType ( ) & & subId ! = null ) ? subId : snowflake . nextId ( ) ) ;
taskSub . setTaskDetailId ( taskDetailId ) ;
taskSub . setPlanEndTime ( eTime ) ;
taskSub . setPlanStartTime ( bTime ) ;
taskSub . setPlanDuration ( eTime - bTime ) ;
taskSubDao . insertSelectiv e ( taskSub ) ;
taskSubDao . insertReplac e ( taskSub ) ;
//添加交付物信息
if ( StrUtil . isNotBlank ( deliver ) ) {
saveDeliver ( deliver , taskSub ) ;
saveDeliver ( project , deliverId , deliver , taskSub ) ;
}
//查找定期任务标签并关联任务
Long taskLabel = labelDao . getLabelByTypeAndLevel ( 1 , 3 ) ;
@ -904,25 +974,33 @@ public class ImportService implements IImportService {
return taskStartTime ;
}
private void saveDeliver ( String deliver , ProTaskSub taskSub ) {
private void saveDeliver ( ProjectVo . SysProject project , Long deliverId , String deliver , ProTaskSub taskSub ) {
PluDeliver pluDeliver = new PluDeliver ( ) ;
pluDeliver . setId ( snowflake . nextId ( ) ) ;
pluDeliver . setId ( ( 1 = = project . getImportType ( ) & & deliverId ! = null ) ? deliverId : snowflake . nextId ( ) ) ;
pluDeliver . setTaskSubId ( taskSub . getId ( ) ) ;
pluDeliver . setName ( deliver ) ;
pluDeliverDao . insertSelectiv e ( pluDeliver ) ;
pluDeliverDao . insertReplac e ( pluDeliver ) ;
}
/ * *
* 添加一级任务
* /
private Long saveFirstTask ( ProjectVo . SysProject project , String firstTaskName ) {
private Long saveFirstTask ( ProjectVo . SysProject project , String firstTaskName , String firstIdCell ) {
Long firstTaskId = null ;
if ( StrUtil . isNotBlank ( firstIdCell ) ) {
try {
firstTaskId = Long . parseLong ( firstIdCell ) ;
} catch ( Exception e ) {
log . info ( "一级任务id解析失败" ) ;
}
}
//TODO 一级任务负责人是项目经理
Long firstTaskId ;
ProTaskDetail taskDetail = new ProTaskDetail ( ) ;
taskDetail . setId ( snowflake . nextId ( ) ) ;
taskDetail . setId ( ( 1 = = project . getImportType ( ) & & firstTaskId ! = null ) ? firstTaskId : snowflake . nextId ( ) ) ;
taskDetail . setName ( firstTaskName ) ;
taskDetailDao . insertSelective ( taskDetail ) ;
taskDetailDao . insertReplac e ( taskDetail ) ;
firstTaskId = taskDetail . getId ( ) ;
//添加任务分解
ProTaskSub taskSub = new ProTaskSub ( ) ;