|
|
|
@ -1,23 +1,25 @@ |
|
|
|
package com.ccsens.defaultwbs.service; |
|
|
|
|
|
|
|
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.vo.UserVo; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
|
import com.ccsens.common.persist.dao.*; |
|
|
|
import com.ccsens.common.bean.po.*; |
|
|
|
import com.ccsens.common.bean.vo.ProjectVo; |
|
|
|
import com.ccsens.common.persist.mapper.*; |
|
|
|
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.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.util.CodeEnum; |
|
|
|
import com.ccsens.util.ExcelUtil; |
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.StringUtil; |
|
|
|
import com.ccsens.util.cron.CronConstant; |
|
|
|
import com.ccsens.util.cron.NatureToDate; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
|
@ -31,8 +33,9 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
|
@ -47,9 +50,9 @@ public class ImportService implements IImportService { |
|
|
|
@Resource |
|
|
|
private ProTaskDetailDao taskDetailDao; |
|
|
|
@Resource |
|
|
|
private ProTaskSubMapper taskSubMapper; |
|
|
|
private ProTaskSubDao taskSubDao; |
|
|
|
@Resource |
|
|
|
private ProTaskVersionMapper taskVersionMapper; |
|
|
|
private ProTaskVersionDao taskVersionMapper; |
|
|
|
@Resource |
|
|
|
private SubLabelDao subLabelDao; |
|
|
|
@Resource |
|
|
|
@ -63,13 +66,21 @@ public class ImportService implements IImportService { |
|
|
|
@Resource |
|
|
|
private ProRoleRepulsionDao repulsionDao; |
|
|
|
@Resource |
|
|
|
private LabelBusinessMapper labelBusinessMapper; |
|
|
|
private LabelBusinessDao labelBusinessDao; |
|
|
|
@Resource |
|
|
|
private ProParentTaskMapper parentTaskMapper; |
|
|
|
private ProParentTaskDao parentTaskMapper; |
|
|
|
@Resource |
|
|
|
private ProRoleTaskMapper roleTaskMapper; |
|
|
|
private ProRoleTaskDao roleTaskMapper; |
|
|
|
@Resource |
|
|
|
private TallFeignClient tallFeignClient; |
|
|
|
private UserDao userDao; |
|
|
|
@Resource |
|
|
|
private SProjectDao projectDao; |
|
|
|
@Resource |
|
|
|
private STaskDao sTaskDao; |
|
|
|
@Resource |
|
|
|
private SPluginDao sTaskPluginDao; |
|
|
|
@Resource |
|
|
|
private ProTaskPluginDao proTaskPluginDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取wbs文件 |
|
|
|
@ -78,12 +89,10 @@ public class ImportService implements IImportService { |
|
|
|
* @throws Exception 异常 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void importWbs(String path, Long userId) throws Exception { |
|
|
|
public void importWbs(String path, Long userId,Long projectId) throws Exception { |
|
|
|
//获取excel文件
|
|
|
|
InputStream is = new FileInputStream(path); |
|
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is); |
|
|
|
//项目
|
|
|
|
ProjectVo.SysProject project = new ProjectVo.SysProject(); |
|
|
|
//角色
|
|
|
|
Map<String, Long> roleMap = new HashMap<>(); |
|
|
|
//成员
|
|
|
|
@ -92,13 +101,13 @@ public class ImportService implements IImportService { |
|
|
|
Map<String, Long> taskMap = new HashMap<>(); |
|
|
|
|
|
|
|
//读取文件
|
|
|
|
readExcel(xssfWorkbook, userId, project, roleMap, memberMap, taskMap); |
|
|
|
readExcel(xssfWorkbook, userId, roleMap, memberMap, taskMap,projectId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取每个sheet |
|
|
|
*/ |
|
|
|
private void readExcel(XSSFWorkbook wb, Long userId, ProjectVo.SysProject project, Map<String, Long> roleMap, Map<String, Long> memberMap, Map<String, Long> taskMap) { |
|
|
|
private void readExcel(XSSFWorkbook wb, Long userId, Map<String, Long> roleMap, Map<String, Long> memberMap, Map<String, Long> taskMap,Long projectId) { |
|
|
|
//获取wbsSheet
|
|
|
|
XSSFSheet wbsSheet = wb.getSheet(Constant.WbsExcel.WBS_SHEET); |
|
|
|
if (ObjectUtil.isNull(wbsSheet)) { |
|
|
|
@ -140,7 +149,7 @@ public class ImportService implements IImportService { |
|
|
|
throw new BaseException(DefaultCodeError.WSB_NOT_TASK_HEADER); |
|
|
|
} |
|
|
|
//添加项目
|
|
|
|
project = readProject(wbsSheet, projectStart, userId); |
|
|
|
ProjectVo.SysProject project = readProject(wbsSheet, projectStart, userId,projectId); |
|
|
|
if(ObjectUtil.isNull(project)){ |
|
|
|
throw new BaseException(DefaultCodeError.WSB_NOT_PROJECT_HEADER); |
|
|
|
} |
|
|
|
@ -148,12 +157,14 @@ public class ImportService implements IImportService { |
|
|
|
readMemberSheet(memberSheet,project.getId(),roleMap,memberMap); |
|
|
|
//添加任务
|
|
|
|
readTask(wbsSheet,taskStart,project,roleMap); |
|
|
|
//TODO 在tall客户端添加项目和用户的关联信息
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 读取项目信息 |
|
|
|
*/ |
|
|
|
private ProjectVo.SysProject readProject(XSSFSheet wbsSheet, int projectStart, Long userId) { |
|
|
|
private ProjectVo.SysProject readProject(XSSFSheet wbsSheet, int projectStart, Long userId,Long projectId) { |
|
|
|
ProjectVo.SysProject project = new ProjectVo.SysProject(); |
|
|
|
//获取项目信息的那一行
|
|
|
|
XSSFRow row = wbsSheet.getRow(projectStart + 1); |
|
|
|
@ -173,9 +184,19 @@ public class ImportService implements IImportService { |
|
|
|
//版本
|
|
|
|
String version = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); |
|
|
|
if (StrUtil.isEmpty(projectName)) { |
|
|
|
throw new BaseException(CodeEnum.WBS_NOT_PROJECT_NAME); |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_PROJECT_NAME); |
|
|
|
} |
|
|
|
//项目名不能重复(当前用户创建的项目内名字不能重复)
|
|
|
|
//根据userId查找已创建的项目
|
|
|
|
List<ProjectVo.SysProject> sysProjectList = projectDao.queryByCreator(userId); |
|
|
|
if(CollectionUtil.isNotEmpty(sysProjectList)){ |
|
|
|
sysProjectList.forEach(p -> { |
|
|
|
if(projectName.equalsIgnoreCase(p.getName())){ |
|
|
|
//如果名称重复则提示错误信息
|
|
|
|
throw new BaseException(DefaultCodeError.PROJECT_NAME_REPEAT); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
//TODO 项目名不能重复(当前用户创建的项目内名字不能重复)
|
|
|
|
//判断时间是否正确
|
|
|
|
String begin = ExcelUtil.getCellValue(row.getCell(3)); |
|
|
|
String end = ExcelUtil.getCellValue(row.getCell(4)); |
|
|
|
@ -205,7 +226,7 @@ public class ImportService implements IImportService { |
|
|
|
taskSub.setPlanStartTime(bTime); |
|
|
|
taskSub.setPlanEndTime(eTime); |
|
|
|
taskSub.setPlanDuration(eTime - bTime); |
|
|
|
taskSubMapper.insertSelective(taskSub); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
project.setBeginTime(bTime); |
|
|
|
project.setEndTime(eTime); |
|
|
|
//添加版本信息
|
|
|
|
@ -219,8 +240,18 @@ public class ImportService implements IImportService { |
|
|
|
Long labelId = subLabelDao.getLabelByTypeAndLevel(1, 0); |
|
|
|
//添加任务标签关联信息
|
|
|
|
saveLabelTask(taskDetail.getId(), labelId); |
|
|
|
//TODO 在tall客户端添加项目和用户的关联信息
|
|
|
|
//TODO 处理创建人的权限问题
|
|
|
|
|
|
|
|
//处理创建人的权限问题(添加创建人角色)
|
|
|
|
//查找创建者标签id
|
|
|
|
Long roleLabelId = subLabelDao.getLabelByTypeAndLevel(5, 5); |
|
|
|
//添加创建者角色
|
|
|
|
ProRole role = new ProRole(); |
|
|
|
role.setId(snowflake.nextId()); |
|
|
|
role.setName("创建者"); |
|
|
|
role.setProjectId(taskDetail.getId()); |
|
|
|
role.setLabelId(roleLabelId); |
|
|
|
roleDao.insertSelective(role); |
|
|
|
|
|
|
|
return project; |
|
|
|
} |
|
|
|
|
|
|
|
@ -234,7 +265,7 @@ public class ImportService implements IImportService { |
|
|
|
labelBusiness.setBusinessType((byte) 0); |
|
|
|
labelBusiness.setBusinessId(taskDetailId); |
|
|
|
labelBusiness.setLabelId(labelId); |
|
|
|
labelBusinessMapper.insertSelective(labelBusiness); |
|
|
|
labelBusinessDao.insertSelective(labelBusiness); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -293,41 +324,38 @@ public class ImportService implements IImportService { |
|
|
|
} |
|
|
|
//添加成员
|
|
|
|
if(StrUtil.isNotEmpty(memberName) && !"/".equalsIgnoreCase(roleName)){ |
|
|
|
//TODO 根据成员手机号查找userId 成员关联userId
|
|
|
|
Long memberUserId = null; |
|
|
|
JsonResponse<Long> result = tallFeignClient.getUserIdByPhone(memberPhone); |
|
|
|
if (result.getCode() == CodeEnum.SUCCESS.getCode().longValue()) { |
|
|
|
memberUserId = result.getData(); |
|
|
|
//如果成员名和手机号重复当做一个人来处理
|
|
|
|
Long memberId = memberMap.get(memberName + "_" + memberPhone); |
|
|
|
if(ObjectUtil.isNull(memberId)){ |
|
|
|
//TODO 根据成员手机号查找userId 成员关联userId
|
|
|
|
Long userId = userDao.getUserIdByPhone(memberPhone); |
|
|
|
//添加成员至数据库
|
|
|
|
ProMember proMember = new ProMember(); |
|
|
|
proMember.setId(snowflake.nextId()); |
|
|
|
proMember.setName(memberName); |
|
|
|
proMember.setPhone(memberPhone); |
|
|
|
proMember.setProjectId(projectId); |
|
|
|
proMember.setUserId(userId); |
|
|
|
memberDao.insertSelective(proMember); |
|
|
|
memberMap.put(memberName+"_"+memberPhone,proMember.getId()); |
|
|
|
memberId = proMember.getId(); |
|
|
|
} |
|
|
|
//添加成员至数据库
|
|
|
|
ProMember proMember = new ProMember(); |
|
|
|
proMember.setId(snowflake.nextId()); |
|
|
|
proMember.setName(memberName); |
|
|
|
proMember.setPhone(memberPhone); |
|
|
|
proMember.setProjectId(projectId); |
|
|
|
proMember.setUserId(memberUserId); |
|
|
|
memberDao.insertSelective(proMember); |
|
|
|
memberMap.put(memberName+"_"+memberPhone,proMember.getId()); |
|
|
|
//添加角色成员关联信息
|
|
|
|
ProRoleMember roleMember = new ProRoleMember(); |
|
|
|
roleMember.setId(snowflake.nextId()); |
|
|
|
roleMember.setRoleId(roleId); |
|
|
|
roleMember.setMemberId(proMember.getId()); |
|
|
|
roleMember.setMemberId(memberId); |
|
|
|
roleMemberDao.insertSelective(roleMember); |
|
|
|
//添加奖惩干系人
|
|
|
|
if(StrUtil.isNotEmpty(stakeholderName) && !"/".equalsIgnoreCase(roleName)){ |
|
|
|
//TODO 根据干系人手机号查找userId 奖惩干系人关联userId
|
|
|
|
Long stakeholderUserId = null; |
|
|
|
JsonResponse<Long> stakeholderUser = tallFeignClient.getUserIdByPhone(stakeholderPhone); |
|
|
|
if (result.getCode() == CodeEnum.SUCCESS.getCode().longValue()) { |
|
|
|
stakeholderUserId = stakeholderUser.getData(); |
|
|
|
} |
|
|
|
Long userId = userDao.getUserIdByPhone(memberPhone); |
|
|
|
ProMemberStakeholder memberStakeholder = new ProMemberStakeholder(); |
|
|
|
memberStakeholder.setId(snowflake.nextId()); |
|
|
|
memberStakeholder.setMemeberId(proMember.getId()); |
|
|
|
memberStakeholder.setMemeberId(memberId); |
|
|
|
memberStakeholder.setStakeholderName(stakeholderName); |
|
|
|
memberStakeholder.setStakeholderPhone(stakeholderPhone); |
|
|
|
memberStakeholder.setUserId(stakeholderUserId); |
|
|
|
memberStakeholder.setUserId(userId); |
|
|
|
memberStakeholderMapper.insertSelective(memberStakeholder); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -384,6 +412,7 @@ public class ImportService implements IImportService { |
|
|
|
|
|
|
|
//一级任务id
|
|
|
|
Long firstTaskId = null; |
|
|
|
Long taskStartTime = project.getBeginTime(); |
|
|
|
for (int i = taskStart + 1; i <= wbsSheet.getLastRowNum(); i++) { |
|
|
|
//获取当前行
|
|
|
|
XSSFRow row = wbsSheet.getRow(i); |
|
|
|
@ -412,6 +441,12 @@ public class ImportService implements IImportService { |
|
|
|
String beginTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(4))); |
|
|
|
//结束时间
|
|
|
|
String endTime = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(5))); |
|
|
|
//时长
|
|
|
|
String duration = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(6))); |
|
|
|
//插件
|
|
|
|
String plugin1 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(12))); |
|
|
|
String plugin2 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(13))); |
|
|
|
String plugin3 = StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(14))); |
|
|
|
if(StrUtil.isNotEmpty(taskName)){ |
|
|
|
//添加二级任务信息(任务详情)
|
|
|
|
ProTaskDetail taskDetail = new ProTaskDetail(); |
|
|
|
@ -435,7 +470,7 @@ public class ImportService implements IImportService { |
|
|
|
labelBusiness.setBusinessType((byte) 0); |
|
|
|
labelBusiness.setBusinessId(taskDetail.getId()); |
|
|
|
labelBusiness.setLabelId(labelId); |
|
|
|
labelBusinessMapper.insertSelective(labelBusiness); |
|
|
|
labelBusinessDao.insertSelective(labelBusiness); |
|
|
|
//任务和角色关联
|
|
|
|
if(StrUtil.isEmpty(executorRole)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_NOT_FIND_ROLE); |
|
|
|
@ -452,54 +487,180 @@ public class ImportService implements IImportService { |
|
|
|
roleTask.setTaskId(taskDetail.getId()); |
|
|
|
roleTaskMapper.insertSelective(roleTask); |
|
|
|
} |
|
|
|
|
|
|
|
//处理时间、添加任务分解、添加任务标签
|
|
|
|
if(StrUtil.isEmpty(beginTime) || "日常".equalsIgnoreCase(beginTime)){ |
|
|
|
//添加任务分解
|
|
|
|
ProTaskSub taskSub = new ProTaskSub(); |
|
|
|
taskSub.setId(snowflake.nextId()); |
|
|
|
taskSub.setTaskDetailId(taskDetail.getId()); |
|
|
|
taskSubMapper.insertSelective(taskSub); |
|
|
|
//查找日常任务标签并关联信息
|
|
|
|
Long label = subLabelDao.getLabelByTypeAndLevel(1, 2); |
|
|
|
saveLabelTask(taskDetail.getId(),label); |
|
|
|
}else { |
|
|
|
Long bTime; |
|
|
|
Long eTime; |
|
|
|
try { |
|
|
|
bTime = Long.parseLong(beginTime); |
|
|
|
eTime = Long.parseLong(endTime); |
|
|
|
//添加任务分解
|
|
|
|
ProTaskSub taskSub = new ProTaskSub(); |
|
|
|
taskSub.setId(snowflake.nextId()); |
|
|
|
taskSub.setTaskDetailId(taskDetail.getId()); |
|
|
|
taskSub.setPlanEndTime(eTime); |
|
|
|
taskSub.setPlanStartTime(bTime); |
|
|
|
taskSub.setPlanDuration(eTime - bTime); |
|
|
|
taskSubMapper.insertSelective(taskSub); |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetail.getId(),taskLabel); |
|
|
|
//添加时间颗粒度标签并关联
|
|
|
|
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
saveLabelTask(taskDetail.getId(),timeLabel); |
|
|
|
}catch (Exception e){ |
|
|
|
//TODO 其他情况暂不处理
|
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
taskStartTime = taskSaveTime(taskStartTime, project, beginTime, endTime, duration, taskDetail.getId()); |
|
|
|
//添加时间颗粒度标签并关联
|
|
|
|
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
saveLabelTask(taskDetail.getId(),timeLabel); |
|
|
|
//TODO 插件
|
|
|
|
plugin(plugin1,taskDetail.getId(),1); |
|
|
|
plugin(plugin2,taskDetail.getId(),2); |
|
|
|
plugin(plugin3,taskDetail.getId(),3); |
|
|
|
// //处理时间、添加任务分解、添加任务标签
|
|
|
|
// if(StrUtil.isEmpty(beginTime) || "日常".equalsIgnoreCase(beginTime)){
|
|
|
|
// //添加任务分解
|
|
|
|
// ProTaskSub taskSub = new ProTaskSub();
|
|
|
|
// taskSub.setId(snowflake.nextId());
|
|
|
|
// taskSub.setTaskDetailId(taskDetail.getId());
|
|
|
|
// taskSubMapper.insertSelective(taskSub);
|
|
|
|
// //查找日常任务标签并关联信息
|
|
|
|
// Long label = subLabelDao.getLabelByTypeAndLevel(1, 2);
|
|
|
|
// saveLabelTask(taskDetail.getId(),label);
|
|
|
|
// }else {
|
|
|
|
// Long bTime;
|
|
|
|
// Long eTime;
|
|
|
|
// try {
|
|
|
|
// bTime = Long.parseLong(beginTime);
|
|
|
|
// eTime = Long.parseLong(endTime);
|
|
|
|
// //添加任务分解
|
|
|
|
// ProTaskSub taskSub = new ProTaskSub();
|
|
|
|
// taskSub.setId(snowflake.nextId());
|
|
|
|
// taskSub.setTaskDetailId(taskDetail.getId());
|
|
|
|
// taskSub.setPlanEndTime(eTime);
|
|
|
|
// taskSub.setPlanStartTime(bTime);
|
|
|
|
// taskSub.setPlanDuration(eTime - bTime);
|
|
|
|
// taskSubMapper.insertSelective(taskSub);
|
|
|
|
// //查找定期任务标签并关联任务
|
|
|
|
// Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3);
|
|
|
|
// saveLabelTask(taskDetail.getId(),taskLabel);
|
|
|
|
// //添加时间颗粒度标签并关联
|
|
|
|
// Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4);
|
|
|
|
// saveLabelTask(taskDetail.getId(),timeLabel);
|
|
|
|
// }catch (Exception e){
|
|
|
|
// //TODO 其他情况暂不处理
|
|
|
|
// throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
} |
|
|
|
//TODO 检查人
|
|
|
|
//TODO 及时奖惩
|
|
|
|
//TODO 交付物
|
|
|
|
//TODO 插件
|
|
|
|
//TODO 添加默认插件
|
|
|
|
} |
|
|
|
} |
|
|
|
private void plugin(String plugin,Long taskId,int row) { |
|
|
|
if(StrUtil.isNotEmpty(plugin)){ |
|
|
|
//根据插件名称查找插件id
|
|
|
|
Long pluginId = sTaskPluginDao.getPluginIdByName(plugin); |
|
|
|
if(ObjectUtil.isNull(pluginId)){ |
|
|
|
throw new BaseException(DefaultCodeError.PLUGIN_NAME_ERROR); |
|
|
|
} |
|
|
|
//添加插件
|
|
|
|
ProTaskPlugin proTaskPlugin = new ProTaskPlugin(); |
|
|
|
proTaskPlugin.setId(snowflake.nextId()); |
|
|
|
proTaskPlugin.setTaskDetailId(taskId); |
|
|
|
proTaskPlugin.setPluginId(pluginId); |
|
|
|
proTaskPlugin.setPlginRow(row); |
|
|
|
proTaskPlugin.setPlginCol(1); |
|
|
|
proTaskPlugin.setRowspan(1); |
|
|
|
proTaskPlugin.setColspan(1); |
|
|
|
proTaskPluginDao.insertSelective(proTaskPlugin); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private Long taskSaveTime(Long taskStartTime,ProjectVo.SysProject project, String beginTime, String endTime, String duration, Long taskDetailId) { |
|
|
|
|
|
|
|
if(StrUtil.isEmpty(beginTime) || "日常".equalsIgnoreCase(beginTime)){ |
|
|
|
if(StrUtil.isEmpty(beginTime) && StrUtil.isNotEmpty(duration)){ |
|
|
|
//获取时长内的字符串
|
|
|
|
String str = "[0-9]"; |
|
|
|
Pattern pStr = Pattern.compile(str); |
|
|
|
Matcher mStr = pStr.matcher(duration); |
|
|
|
String trimStr = mStr.replaceAll("").trim(); |
|
|
|
Long aLong = Constant.WBS_DURATION.get(trimStr); |
|
|
|
if(ObjectUtil.isNull(aLong)){ |
|
|
|
throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR); |
|
|
|
} |
|
|
|
//获取字符串内的数字
|
|
|
|
String num = "[^0-9]"; |
|
|
|
Pattern pNum = Pattern.compile(num); |
|
|
|
Matcher mNum = pNum.matcher(duration); |
|
|
|
String trimNum = mNum.replaceAll("").trim(); |
|
|
|
//计算时长
|
|
|
|
Long durationTime = Long.parseLong(trimNum) * aLong; |
|
|
|
//添加任务分解
|
|
|
|
ProTaskSub taskSub = new ProTaskSub(); |
|
|
|
taskSub.setId(snowflake.nextId()); |
|
|
|
taskSub.setTaskDetailId(taskDetailId); |
|
|
|
taskSub.setPlanDuration(durationTime); |
|
|
|
taskSub.setPlanStartTime(taskStartTime); |
|
|
|
taskStartTime += durationTime; |
|
|
|
taskSub.setPlanEndTime(taskStartTime); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetailId,taskLabel); |
|
|
|
|
|
|
|
}else { |
|
|
|
//添加任务分解
|
|
|
|
ProTaskSub taskSub = new ProTaskSub(); |
|
|
|
taskSub.setId(snowflake.nextId()); |
|
|
|
taskSub.setTaskDetailId(taskDetailId); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找日常任务标签并关联信息
|
|
|
|
Long label = subLabelDao.getLabelByTypeAndLevel(1, 2); |
|
|
|
saveLabelTask(taskDetailId,label); |
|
|
|
} |
|
|
|
}else { |
|
|
|
Long bTime; |
|
|
|
Long eTime; |
|
|
|
try { |
|
|
|
bTime = Long.parseLong(beginTime); |
|
|
|
eTime = Long.parseLong(endTime); |
|
|
|
//添加任务分解
|
|
|
|
ProTaskSub taskSub = new ProTaskSub(); |
|
|
|
taskSub.setId(snowflake.nextId()); |
|
|
|
taskSub.setTaskDetailId(taskDetailId); |
|
|
|
taskSub.setPlanEndTime(eTime); |
|
|
|
taskSub.setPlanStartTime(bTime); |
|
|
|
taskSub.setPlanDuration(eTime - bTime); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//查找定期任务标签并关联任务
|
|
|
|
Long taskLabel = subLabelDao.getLabelByTypeAndLevel(1, 3); |
|
|
|
saveLabelTask(taskDetailId,taskLabel); |
|
|
|
//添加时间颗粒度标签并关联
|
|
|
|
Long timeLabel = subLabelDao.getLabelByTypeAndLevel(0, 4); |
|
|
|
saveLabelTask(taskDetailId,timeLabel); |
|
|
|
}catch (Exception e){ |
|
|
|
Date startDate = new Date(project.getBeginTime()); |
|
|
|
Date endDate = new Date(project.getEndTime()); |
|
|
|
try { |
|
|
|
List<CronConstant.TaskDate> taskDateList = |
|
|
|
NatureToDate.generateDates(beginTime, startDate, endDate); |
|
|
|
if (CollectionUtil.isEmpty(taskDateList)) { |
|
|
|
return taskStartTime; |
|
|
|
} |
|
|
|
List<ProTaskSub> proTaskSubList = new ArrayList<>(); |
|
|
|
for (CronConstant.TaskDate taskDate : taskDateList) { |
|
|
|
|
|
|
|
ProTaskSub proTaskSub = new ProTaskSub(); |
|
|
|
proTaskSub.setId(snowflake.nextId()); |
|
|
|
proTaskSub.setTaskDetailId(taskDetailId); |
|
|
|
proTaskSub.setPlanStartTime(taskDate.getStartDate().getTime()); |
|
|
|
proTaskSub.setPlanEndTime(taskDate.getEndDate().getTime()); |
|
|
|
proTaskSub.setPlanDuration(proTaskSub.getPlanEndTime() - proTaskSub.getPlanStartTime()); |
|
|
|
proTaskSubList.add(proTaskSub); |
|
|
|
} |
|
|
|
if(CollectionUtil.isNotEmpty(proTaskSubList)){ |
|
|
|
sTaskDao.insertSelectiveList(proTaskSubList); |
|
|
|
} |
|
|
|
}catch (Exception e1){ |
|
|
|
throw new BaseException(String.valueOf(e1)); |
|
|
|
// throw new BaseException(DefaultCodeError.WBS_PROJECT_TIME_ERROR);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return taskStartTime; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 添加一级任务 |
|
|
|
*/ |
|
|
|
private Long saveFirstTask(ProjectVo.SysProject project, String firstTaskName) { |
|
|
|
Long firstTaskId;//添加一级任务信息(任务详情)
|
|
|
|
//TODO 一级任务负责人是项目经理
|
|
|
|
Long firstTaskId; |
|
|
|
ProTaskDetail taskDetail = new ProTaskDetail(); |
|
|
|
taskDetail.setId(snowflake.nextId()); |
|
|
|
taskDetail.setName(firstTaskName); |
|
|
|
@ -512,7 +673,7 @@ public class ImportService implements IImportService { |
|
|
|
taskSub.setPlanStartTime(project.getBeginTime()); |
|
|
|
taskSub.setPlanEndTime(project.getEndTime()); |
|
|
|
taskSub.setPlanDuration(project.getEndTime() - project.getBeginTime()); |
|
|
|
taskSubMapper.insertSelective(taskSub); |
|
|
|
taskSubDao.insertSelective(taskSub); |
|
|
|
//任务关联信息(关联项目)
|
|
|
|
ProParentTask parentTask = new ProParentTask(); |
|
|
|
parentTask.setId(snowflake.nextId()); |
|
|
|
|