|
|
@ -26,7 +26,7 @@ import java.util.*; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Service |
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
|
public class ProjectService implements IProjectService { |
|
|
|
@Autowired |
|
|
|
private SysProjectDao sysProjectDao; |
|
|
@ -61,12 +61,13 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据名字查找此用户创建的项目 |
|
|
|
* |
|
|
|
* @param subProject |
|
|
|
* @param currentUserId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public SysProject selectByNameAndUserId(String subProject, Long currentUserId) throws Exception{ |
|
|
|
public SysProject selectByNameAndUserId(String subProject, Long currentUserId) throws Exception { |
|
|
|
SysProject project = new SysProject(); |
|
|
|
SysProjectExample projectExample = new SysProjectExample(); |
|
|
|
projectExample.createCriteria().andCreatorIdEqualTo(currentUserId).andNameEqualTo(subProject); |
|
|
@ -79,6 +80,7 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 查找本月哪一天有项目 |
|
|
|
* |
|
|
|
* @param currentUserId |
|
|
|
* @param date |
|
|
|
* @return |
|
|
@ -87,22 +89,23 @@ public class ProjectService implements IProjectService { |
|
|
|
public List<String> haveProjectDay(Long currentUserId, String date) throws Exception { |
|
|
|
List<String> dateList = new ArrayList<>(); |
|
|
|
//获取日期的开始结束时间
|
|
|
|
Map<String,Long> timeMap = new HashMap<>(); |
|
|
|
Map<String, Long> timeMap = new HashMap<>(); |
|
|
|
timeMap = DateUtil.projectFormatDateTime(date); |
|
|
|
Long startMillisTime = timeMap.get("startMillisTime"); |
|
|
|
Long endMillisTime = timeMap.get("endMillisTime"); |
|
|
|
//查找此用户关注的项目
|
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId,startMillisTime,endMillisTime); |
|
|
|
if(CollectionUtil.isNotEmpty(projectList)){ |
|
|
|
for(SysProject sysProject:projectList){ |
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId, startMillisTime, endMillisTime); |
|
|
|
if (CollectionUtil.isNotEmpty(projectList)) { |
|
|
|
for (SysProject sysProject : projectList) { |
|
|
|
startMillisTime = sysProject.getBeginTime() > startMillisTime ? sysProject.getBeginTime() : startMillisTime; |
|
|
|
endMillisTime = sysProject.getEndTime() < endMillisTime ? sysProject.getEndTime() : endMillisTime; |
|
|
|
dateList = getTimeList(dateList,startMillisTime,endMillisTime); |
|
|
|
dateList = getTimeList(dateList, startMillisTime, endMillisTime); |
|
|
|
} |
|
|
|
} |
|
|
|
return dateList; |
|
|
|
} |
|
|
|
private List<String> getTimeList(List<String> dateList, Long startTime,Long endTime){ |
|
|
|
|
|
|
|
private List<String> getTimeList(List<String> dateList, Long startTime, Long endTime) { |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd"); |
|
|
|
Date s = new Date(startTime); |
|
|
|
Date e = new Date(endTime); |
|
|
@ -113,8 +116,8 @@ public class ProjectService implements IProjectService { |
|
|
|
max.setTime(e); |
|
|
|
Calendar curr = min; |
|
|
|
while (curr.before(max)) { |
|
|
|
for(String str:dateList){ |
|
|
|
if(!sdf.format(min.getTime()).equalsIgnoreCase(str)){ |
|
|
|
for (String str : dateList) { |
|
|
|
if (!sdf.format(min.getTime()).equalsIgnoreCase(str)) { |
|
|
|
dateList.add(sdf.format(min.getTime())); |
|
|
|
} |
|
|
|
} |
|
|
@ -125,6 +128,7 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据用户和日期查找项目 |
|
|
|
* |
|
|
|
* @param currentUserId |
|
|
|
* @param date |
|
|
|
* @return |
|
|
@ -134,13 +138,13 @@ public class ProjectService implements IProjectService { |
|
|
|
public List<ProjectVo.ProjectInfo> getProjectInfo(Long currentUserId, String date) throws Exception { |
|
|
|
List<ProjectVo.ProjectInfo> projectInfoList = new ArrayList<>(); |
|
|
|
//获取日期的开始结束时间
|
|
|
|
Map<String,Long> timeMap = new HashMap<>(); |
|
|
|
Map<String, Long> timeMap = new HashMap<>(); |
|
|
|
timeMap = DateUtil.projectFormatDateTime(date); |
|
|
|
Long startMillisTime = timeMap.get("startMillisTime"); |
|
|
|
Long endMillisTime = timeMap.get("endMillisTime"); |
|
|
|
//查找此用户关注的项目
|
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId,startMillisTime,endMillisTime); |
|
|
|
projectInfoList = projectInfoByProject(projectList,currentUserId); |
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId, startMillisTime, endMillisTime); |
|
|
|
projectInfoList = projectInfoByProject(projectList, currentUserId); |
|
|
|
// if(CollectionUtil.isNotEmpty(projectList)){
|
|
|
|
// ProjectVo.ProjectInfo projectInfo = null;
|
|
|
|
// for(SysProject project:projectList){
|
|
|
@ -172,17 +176,18 @@ public class ProjectService implements IProjectService { |
|
|
|
// }
|
|
|
|
return projectInfoList; |
|
|
|
} |
|
|
|
private List<ProjectVo.ProjectInfo> projectInfoByProject(List<SysProject> projectList, Long currentUserId){ |
|
|
|
|
|
|
|
private List<ProjectVo.ProjectInfo> projectInfoByProject(List<SysProject> projectList, Long currentUserId) { |
|
|
|
List<ProjectVo.ProjectInfo> projectInfoList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(projectList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(projectList)) { |
|
|
|
ProjectVo.ProjectInfo projectInfo = null; |
|
|
|
for(SysProject project:projectList){ |
|
|
|
for (SysProject project : projectList) { |
|
|
|
projectInfo = new ProjectVo.ProjectInfo(); |
|
|
|
BeanUtil.copyProperties(project,projectInfo); |
|
|
|
BeanUtil.copyProperties(project, projectInfo); |
|
|
|
projectInfo.setCreator(false); |
|
|
|
projectInfo.setRoles(new ArrayList<>()); |
|
|
|
//是否是创建者
|
|
|
|
if(project.getCreatorId().longValue()==currentUserId.longValue()){ |
|
|
|
if (project.getCreatorId().longValue() == currentUserId.longValue()) { |
|
|
|
projectInfo.getRoles().add(WebConstant.ROLE_NAME.Creator.phase); |
|
|
|
projectInfo.setCreator(true); |
|
|
|
} |
|
|
@ -193,11 +198,11 @@ public class ProjectService implements IProjectService { |
|
|
|
projectInfo.getRoles().add(proRole.getDescription()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isEmpty(projectInfo.getRoles())){ |
|
|
|
if (CollectionUtil.isEmpty(projectInfo.getRoles())) { |
|
|
|
projectInfo.getRoles().add(WebConstant.ROLE_NAME.Attention.phase); |
|
|
|
} |
|
|
|
//用户在项目中的最高权限
|
|
|
|
int power = proRoleService.selectPowerByRoleName(currentUserId,project.getId()); |
|
|
|
int power = proRoleService.selectPowerByRoleName(currentUserId, project.getId()); |
|
|
|
projectInfo.setPower(power); |
|
|
|
|
|
|
|
projectInfoList.add(projectInfo); |
|
|
@ -208,6 +213,7 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 通过项目id查询项目 |
|
|
|
* |
|
|
|
* @param userId 用户id |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
@ -216,11 +222,11 @@ public class ProjectService implements IProjectService { |
|
|
|
public ProjectVo.ProjectInfo getProjectInfoById(Long userId, Long projectId) { |
|
|
|
SysProject sysProject = sysProjectDao.selectByPrimaryKey(projectId); |
|
|
|
ProjectVo.ProjectInfo projectInfo = new ProjectVo.ProjectInfo(); |
|
|
|
BeanUtil.copyProperties(sysProject,projectInfo); |
|
|
|
BeanUtil.copyProperties(sysProject, projectInfo); |
|
|
|
projectInfo.setCreator(false); |
|
|
|
projectInfo.setRoles(new ArrayList<>()); |
|
|
|
//是否是创建者
|
|
|
|
if(sysProject.getCreatorId().longValue()==userId.longValue()){ |
|
|
|
if (sysProject.getCreatorId().longValue() == userId.longValue()) { |
|
|
|
projectInfo.getRoles().add(WebConstant.ROLE_NAME.Creator.phase); |
|
|
|
projectInfo.setCreator(true); |
|
|
|
} |
|
|
@ -231,17 +237,17 @@ public class ProjectService implements IProjectService { |
|
|
|
projectInfo.getRoles().add(proRole.getDescription()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(CollectionUtil.isEmpty(projectInfo.getRoles())){ |
|
|
|
if (CollectionUtil.isEmpty(projectInfo.getRoles())) { |
|
|
|
projectInfo.getRoles().add(WebConstant.ROLE_NAME.Attention.phase); |
|
|
|
} |
|
|
|
//用户在项目中的最高权限
|
|
|
|
int power = proRoleService.selectPowerByRoleName(userId,projectId); |
|
|
|
int power = proRoleService.selectPowerByRoleName(userId, projectId); |
|
|
|
projectInfo.setPower(power); |
|
|
|
//获取项目配置
|
|
|
|
ProShowExample proShowExample = new ProShowExample(); |
|
|
|
proShowExample.createCriteria().andProjectIdEqualTo(projectId); |
|
|
|
List<ProShow> proShowList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(proShowList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(proShowList)) { |
|
|
|
ProjectVo.ProjectConfig projectConfig = new ProjectVo.ProjectConfig(); |
|
|
|
projectConfig.setSlide(proShowList.get(0).getSlide()); |
|
|
|
projectConfig.setFilter(proShowList.get(0).getFilter()); |
|
|
@ -253,6 +259,7 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据类型查项目 项目类型 0普通项目 1模板项目 2常驻项目 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
@ -275,8 +282,8 @@ public class ProjectService implements IProjectService { |
|
|
|
@Override |
|
|
|
public List<ProjectVo.TemplateStatus> getForever() { |
|
|
|
List<ProjectVo.TemplateStatus> templateProject = sysProjectDao.selectByTemplateStatus(2); |
|
|
|
if(CollectionUtil.isNotEmpty(templateProject)){ |
|
|
|
for(ProjectVo.TemplateStatus templateStatus:templateProject){ |
|
|
|
if (CollectionUtil.isNotEmpty(templateProject)) { |
|
|
|
for (ProjectVo.TemplateStatus templateStatus : templateProject) { |
|
|
|
templateStatus.setProcess(1); |
|
|
|
} |
|
|
|
} |
|
|
@ -294,18 +301,18 @@ public class ProjectService implements IProjectService { |
|
|
|
//获取日期的开始结束时间
|
|
|
|
Long startMillisTime = null; |
|
|
|
Long endMillisTime = null; |
|
|
|
Map<String,Long> timeMap = null; |
|
|
|
if(StrUtil.isNotEmpty(start)){ |
|
|
|
Map<String, Long> timeMap = null; |
|
|
|
if (StrUtil.isNotEmpty(start)) { |
|
|
|
timeMap = DateUtil.projectFormatDateTime(start); |
|
|
|
startMillisTime = timeMap.get("startMillisTime"); |
|
|
|
} |
|
|
|
if(StrUtil.isNotEmpty(end)){ |
|
|
|
if (StrUtil.isNotEmpty(end)) { |
|
|
|
timeMap = DateUtil.projectFormatDateTime(start); |
|
|
|
endMillisTime = timeMap.get("endMillisTime"); |
|
|
|
} |
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId,startMillisTime,endMillisTime); |
|
|
|
List<SysProject> projectList = sysProjectDao.findProjectIdByUserId(currentUserId, startMillisTime, endMillisTime); |
|
|
|
// List<SysProject> projectList = attentionService.findProjectIdByUserId(currentUserId);
|
|
|
|
projectInfoList = projectInfoByProject(projectList,currentUserId); |
|
|
|
projectInfoList = projectInfoByProject(projectList, currentUserId); |
|
|
|
//关键字模糊查询和是否创建者
|
|
|
|
if (CollectionUtil.isNotEmpty(projectInfoList) && StrUtil.isNotEmpty(key)) { |
|
|
|
Iterator<ProjectVo.ProjectInfo> it = projectInfoList.iterator(); |
|
|
@ -314,10 +321,10 @@ public class ProjectService implements IProjectService { |
|
|
|
if (!projectInfo.getName().contains(key)) { |
|
|
|
it.remove(); |
|
|
|
} |
|
|
|
if(StrUtil.isNotEmpty(role)){ |
|
|
|
if("创建者".equalsIgnoreCase(role)&&!projectInfo.isCreator()){ |
|
|
|
if (StrUtil.isNotEmpty(role)) { |
|
|
|
if ("创建者".equalsIgnoreCase(role) && !projectInfo.isCreator()) { |
|
|
|
it.remove(); |
|
|
|
}else if("参与者".equalsIgnoreCase(role)&&projectInfo.isCreator()){ |
|
|
|
} else if ("参与者".equalsIgnoreCase(role) && projectInfo.isCreator()) { |
|
|
|
it.remove(); |
|
|
|
} |
|
|
|
} |
|
|
@ -366,33 +373,38 @@ public class ProjectService implements IProjectService { |
|
|
|
@Override |
|
|
|
public List<ProjectVo.ProjectByKey> getProjectByKey(Long currentUserId, String key) throws Exception { |
|
|
|
|
|
|
|
return sysProjectDao.getProjectByKey(currentUserId,key); |
|
|
|
return sysProjectDao.getProjectByKey(currentUserId, key); |
|
|
|
} |
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
/** |
|
|
|
* 删除项目 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void deleteProject(Long currentUserId, Long projectId) throws Exception { |
|
|
|
//本用户在项目中的角色
|
|
|
|
List<ProRole> proRoles = proRoleService.getProRoleByProjectIdAndUserId(projectId, currentUserId); |
|
|
|
SysProject project = sysProjectDao.selectByPrimaryKey(projectId); |
|
|
|
if (ObjectUtil.isNotNull(project)) { |
|
|
|
//用户在项目中的最高权限
|
|
|
|
int power = proRoleService.selectPowerByRoleName(currentUserId,projectId); |
|
|
|
if(power>1){ |
|
|
|
int power = proRoleService.selectPowerByRoleName(currentUserId, projectId); |
|
|
|
if (power > 1) { |
|
|
|
// //修改项目状态
|
|
|
|
// SysProject project = sysProjectDao.selectByPrimaryKey(projectId);
|
|
|
|
// project.setRecStatus((byte) 1);
|
|
|
|
// sysProjectDao.updateByPrimaryKeySelective(project);
|
|
|
|
//彻底删除项目
|
|
|
|
deleteProjectById(projectId); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.NOT_POWER); |
|
|
|
} |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.NOT_PROJECT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除项目 |
|
|
|
*/ |
|
|
|
private void deleteProjectById(Long projectId){ |
|
|
|
private void deleteProjectById(Long projectId) { |
|
|
|
//删除任务下的角色
|
|
|
|
proRoleService.deleteRoleByProjectId(projectId); |
|
|
|
//删除这个项目被关注的信息
|
|
|
@ -407,13 +419,13 @@ public class ProjectService implements IProjectService { |
|
|
|
* 复制项目 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ProjectVo.ProjectInfo copyProject(Long userId ,Long projectId) { |
|
|
|
public ProjectVo.ProjectInfo copyProject(Long userId, Long projectId) { |
|
|
|
ProjectVo.ProjectInfo projectInfo = new ProjectVo.ProjectInfo(); |
|
|
|
|
|
|
|
SysProject oldProject = sysProjectDao.selectByPrimaryKey(projectId); |
|
|
|
SysProject newProject = new SysProject(); |
|
|
|
if(ObjectUtil.isNotNull(oldProject)){ |
|
|
|
BeanUtil.copyProperties(oldProject,newProject); |
|
|
|
if (ObjectUtil.isNotNull(oldProject)) { |
|
|
|
BeanUtil.copyProperties(oldProject, newProject); |
|
|
|
newProject.setId(snowflake.nextId()); |
|
|
|
newProject.setCreatorId(userId); |
|
|
|
saveProject(newProject); |
|
|
@ -424,8 +436,8 @@ public class ProjectService implements IProjectService { |
|
|
|
userAttention.setProjectId(newProject.getId()); |
|
|
|
attentionDao.insertSelective(userAttention); |
|
|
|
//添加角色
|
|
|
|
copyRole(oldProject.getId(),newProject.getId()); |
|
|
|
}else { |
|
|
|
copyRole(oldProject.getId(), newProject.getId()); |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.NOT_PROJECT); |
|
|
|
} |
|
|
|
//返回参数
|
|
|
@ -441,52 +453,54 @@ public class ProjectService implements IProjectService { |
|
|
|
|
|
|
|
return projectInfo; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 复制角色 |
|
|
|
*/ |
|
|
|
private void copyRole(Long oldProjectId,Long newProjectId){ |
|
|
|
private void copyRole(Long oldProjectId, Long newProjectId) { |
|
|
|
//查找被复制的项目下的二级角色
|
|
|
|
Map<Long,String> oldRoleMap = new HashMap<>(); |
|
|
|
Map<String,Long> newRoleMap = new HashMap<>(); |
|
|
|
Map<Long, String> oldRoleMap = new HashMap<>(); |
|
|
|
Map<String, Long> newRoleMap = new HashMap<>(); |
|
|
|
List<ProRole> newRoleList = new ArrayList<>(); |
|
|
|
ProRoleExample roleExample = new ProRoleExample(); |
|
|
|
roleExample.createCriteria().andProjectIdEqualTo(oldProjectId); |
|
|
|
List<ProRole> oldRoleList = proRoleDao.selectByExample(roleExample); |
|
|
|
if(CollectionUtil.isNotEmpty(oldRoleList)){ |
|
|
|
for(ProRole oldRole:oldRoleList){ |
|
|
|
oldRoleMap.put(oldRole.getId(),oldRole.getName()); |
|
|
|
if (CollectionUtil.isNotEmpty(oldRoleList)) { |
|
|
|
for (ProRole oldRole : oldRoleList) { |
|
|
|
oldRoleMap.put(oldRole.getId(), oldRole.getName()); |
|
|
|
//创建新的角色
|
|
|
|
ProRole newRole = new ProRole(); |
|
|
|
BeanUtil.copyProperties(oldRole,newRole); |
|
|
|
BeanUtil.copyProperties(oldRole, newRole); |
|
|
|
newRole.setId(snowflake.nextId()); |
|
|
|
newRole.setProjectId(newProjectId); |
|
|
|
proRoleDao.insertSelective(newRole); |
|
|
|
newRoleList.add(newRole); |
|
|
|
newRoleMap.put(newRole.getName(),newRole.getId()); |
|
|
|
newRoleMap.put(newRole.getName(), newRole.getId()); |
|
|
|
} |
|
|
|
//修改角色的parentId
|
|
|
|
if(CollectionUtil.isNotEmpty(newRoleList)){ |
|
|
|
for(ProRole role:newRoleList){ |
|
|
|
if(role.getParentId() != 0){ |
|
|
|
if (CollectionUtil.isNotEmpty(newRoleList)) { |
|
|
|
for (ProRole role : newRoleList) { |
|
|
|
if (role.getParentId() != 0) { |
|
|
|
role.setParentId(newRoleMap.get(oldRoleMap.get(role.getParentId()))); |
|
|
|
proRoleDao.updateByPrimaryKeySelective(role); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//添加对谁不可见
|
|
|
|
copyRoleExeclude(oldRoleList,oldRoleMap,newRoleMap); |
|
|
|
copyRoleExeclude(oldRoleList, oldRoleMap, newRoleMap); |
|
|
|
//复制任务
|
|
|
|
copyTask(oldProjectId,newProjectId,oldRoleMap,newRoleMap); |
|
|
|
copyTask(oldProjectId, newProjectId, oldRoleMap, newRoleMap); |
|
|
|
} |
|
|
|
} |
|
|
|
private void copyRoleExeclude(List<ProRole> oldRoleList, Map<Long,String> oldRoleMap, Map<String,Long> newRoleMap){ |
|
|
|
if(CollectionUtil.isNotEmpty(oldRoleList)) { |
|
|
|
|
|
|
|
private void copyRoleExeclude(List<ProRole> oldRoleList, Map<Long, String> oldRoleMap, Map<String, Long> newRoleMap) { |
|
|
|
if (CollectionUtil.isNotEmpty(oldRoleList)) { |
|
|
|
for (ProRole oldRole : oldRoleList) { |
|
|
|
ProRoleExcludeExample execludeExample = new ProRoleExcludeExample(); |
|
|
|
execludeExample.createCriteria().andRoleIdEqualTo(oldRole.getId()); |
|
|
|
List<ProRoleExclude> roleExecludeList = roleExcludeDao.selectByExample(execludeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(roleExecludeList)){ |
|
|
|
for(ProRoleExclude roleExeclude:roleExecludeList){ |
|
|
|
if (CollectionUtil.isNotEmpty(roleExecludeList)) { |
|
|
|
for (ProRoleExclude roleExeclude : roleExecludeList) { |
|
|
|
ProRoleExclude newRoleExeclude = new ProRoleExclude(); |
|
|
|
newRoleExeclude.setRoleId(newRoleMap.get(oldRoleMap.get(roleExeclude.getRoleId()))); |
|
|
|
newRoleExeclude.setOtherRoleId(newRoleMap.get(oldRoleMap.get(roleExeclude.getRoleId()))); |
|
|
@ -500,18 +514,18 @@ public class ProjectService implements IProjectService { |
|
|
|
/** |
|
|
|
* 复制任务 |
|
|
|
*/ |
|
|
|
private void copyTask(Long oldProjectId,Long newProjectId,Map<Long,String> oldRoleMap, Map<String,Long> newRoleMap){ |
|
|
|
private void copyTask(Long oldProjectId, Long newProjectId, Map<Long, String> oldRoleMap, Map<String, Long> newRoleMap) { |
|
|
|
ProTaskDetailExample detailExample = new ProTaskDetailExample(); |
|
|
|
detailExample.createCriteria().andProjectIdEqualTo(oldProjectId).andLevelEqualTo((byte) 1); |
|
|
|
List<ProTaskDetail> detailList = taskDetailDao.selectByExample(detailExample); |
|
|
|
if(CollectionUtil.isNotEmpty(detailList)){ |
|
|
|
for(ProTaskDetail oldDetail: detailList){ |
|
|
|
if (CollectionUtil.isNotEmpty(detailList)) { |
|
|
|
for (ProTaskDetail oldDetail : detailList) { |
|
|
|
ProTaskDetail newDetail = new ProTaskDetail(); |
|
|
|
BeanUtil.copyProperties(oldDetail,newDetail); |
|
|
|
BeanUtil.copyProperties(oldDetail, newDetail); |
|
|
|
newDetail.setId(snowflake.nextId()); |
|
|
|
newDetail.setProjectId(newProjectId); |
|
|
|
newDetail.setExecutorRole(newRoleMap.get(oldRoleMap.get(newDetail.getExecutorRole()))); |
|
|
|
if(newDetail.getCheckerRole() != 0){ |
|
|
|
if (newDetail.getCheckerRole() != 0) { |
|
|
|
newDetail.setCheckerRole(newRoleMap.get(oldRoleMap.get(newDetail.getCheckerRole()))); |
|
|
|
} |
|
|
|
taskDetailDao.insertSelective(newDetail); |
|
|
@ -519,15 +533,15 @@ public class ProjectService implements IProjectService { |
|
|
|
ProTaskDetailExample oldSecondTask = new ProTaskDetailExample(); |
|
|
|
oldSecondTask.createCriteria().andParentIdEqualTo(oldDetail.getId()).andLevelEqualTo((byte) 2); |
|
|
|
List<ProTaskDetail> secondTaskList = taskDetailDao.selectByExample(oldSecondTask); |
|
|
|
if(CollectionUtil.isNotEmpty(secondTaskList)){ |
|
|
|
for(ProTaskDetail oldSecondDetail: secondTaskList){ |
|
|
|
if (CollectionUtil.isNotEmpty(secondTaskList)) { |
|
|
|
for (ProTaskDetail oldSecondDetail : secondTaskList) { |
|
|
|
ProTaskDetail newSecondDetail = new ProTaskDetail(); |
|
|
|
BeanUtil.copyProperties(oldSecondDetail,newSecondDetail); |
|
|
|
BeanUtil.copyProperties(oldSecondDetail, newSecondDetail); |
|
|
|
newSecondDetail.setId(snowflake.nextId()); |
|
|
|
newSecondDetail.setProjectId(newProjectId); |
|
|
|
newSecondDetail.setParentId(newDetail.getId()); |
|
|
|
newSecondDetail.setExecutorRole(newRoleMap.get(oldRoleMap.get(newSecondDetail.getExecutorRole()))); |
|
|
|
if(newSecondDetail.getCheckerRole() != 0){ |
|
|
|
if (newSecondDetail.getCheckerRole() != 0) { |
|
|
|
newSecondDetail.setCheckerRole(newRoleMap.get(oldRoleMap.get(newSecondDetail.getCheckerRole()))); |
|
|
|
} |
|
|
|
taskDetailDao.insertSelective(newSecondDetail); |
|
|
@ -537,27 +551,27 @@ public class ProjectService implements IProjectService { |
|
|
|
ProTaskDetailExample oldSubTask = new ProTaskDetailExample(); |
|
|
|
oldSubTask.createCriteria().andParentIdEqualTo(oldSecondDetail.getId()).andLevelEqualTo((byte) 3); |
|
|
|
List<ProTaskDetail> subTaskList = taskDetailDao.selectByExample(oldSubTask); |
|
|
|
if(CollectionUtil.isNotEmpty(subTaskList)){ |
|
|
|
for(ProTaskDetail oldSubDetail: subTaskList){ |
|
|
|
if (CollectionUtil.isNotEmpty(subTaskList)) { |
|
|
|
for (ProTaskDetail oldSubDetail : subTaskList) { |
|
|
|
ProTaskDetail newSubDetail = new ProTaskDetail(); |
|
|
|
BeanUtil.copyProperties(oldSubDetail,newSubDetail); |
|
|
|
BeanUtil.copyProperties(oldSubDetail, newSubDetail); |
|
|
|
newSubDetail.setId(snowflake.nextId()); |
|
|
|
newSubDetail.setProjectId(newProjectId); |
|
|
|
newSubDetail.setParentId(newSecondDetail.getId()); |
|
|
|
newSubDetail.setExecutorRole(newRoleMap.get(oldRoleMap.get(newSubDetail.getExecutorRole()))); |
|
|
|
if(newSubDetail.getCheckerRole() != 0){ |
|
|
|
if (newSubDetail.getCheckerRole() != 0) { |
|
|
|
newSubDetail.setCheckerRole(newRoleMap.get(oldRoleMap.get(newSubDetail.getCheckerRole()))); |
|
|
|
} |
|
|
|
taskDetailDao.insertSelective(newSubDetail); |
|
|
|
//分解时间
|
|
|
|
taskToSubTime(newSubDetail); |
|
|
|
copyPluginAndDeliver(oldDetail.getId(),newDetail.getId(),oldRoleMap,newRoleMap); |
|
|
|
copyPluginAndDeliver(oldDetail.getId(), newDetail.getId(), oldRoleMap, newRoleMap); |
|
|
|
} |
|
|
|
} |
|
|
|
copyPluginAndDeliver(oldDetail.getId(),newDetail.getId(),oldRoleMap,newRoleMap); |
|
|
|
copyPluginAndDeliver(oldDetail.getId(), newDetail.getId(), oldRoleMap, newRoleMap); |
|
|
|
} |
|
|
|
} |
|
|
|
copyPluginAndDeliver(oldDetail.getId(),newDetail.getId(),oldRoleMap,newRoleMap); |
|
|
|
copyPluginAndDeliver(oldDetail.getId(), newDetail.getId(), oldRoleMap, newRoleMap); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -565,9 +579,9 @@ public class ProjectService implements IProjectService { |
|
|
|
/** |
|
|
|
* 根据时间分解任务 |
|
|
|
*/ |
|
|
|
private void taskToSubTime(ProTaskDetail taskDetail){ |
|
|
|
private void taskToSubTime(ProTaskDetail taskDetail) { |
|
|
|
//cycle为空,只加一条数据
|
|
|
|
if(ObjectUtil.isNotNull(taskDetail)) { |
|
|
|
if (ObjectUtil.isNotNull(taskDetail)) { |
|
|
|
if (StrUtil.isEmpty(taskDetail.getCycle())) { |
|
|
|
ProTaskSubTime proTaskSubTime = new ProTaskSubTime(); |
|
|
|
proTaskSubTime.setId(snowflake.nextId()); |
|
|
@ -597,15 +611,15 @@ public class ProjectService implements IProjectService { |
|
|
|
/** |
|
|
|
* 复制插件和交付物 |
|
|
|
*/ |
|
|
|
private void copyPluginAndDeliver(Long oldTaskId,Long newTaskId,Map<Long,String> oldRoleMap, Map<String,Long> newRoleMap){ |
|
|
|
private void copyPluginAndDeliver(Long oldTaskId, Long newTaskId, Map<Long, String> oldRoleMap, Map<String, Long> newRoleMap) { |
|
|
|
//插件
|
|
|
|
ProTaskPluginExample pluginExample = new ProTaskPluginExample(); |
|
|
|
pluginExample.createCriteria().andTaskDetailIdEqualTo(oldTaskId); |
|
|
|
List<ProTaskPlugin> pluginList = pluginDao.selectByExample(pluginExample); |
|
|
|
if(CollectionUtil.isNotEmpty(pluginList)){ |
|
|
|
for(ProTaskPlugin plugin:pluginList){ |
|
|
|
if (CollectionUtil.isNotEmpty(pluginList)) { |
|
|
|
for (ProTaskPlugin plugin : pluginList) { |
|
|
|
ProTaskPlugin newPlugin = new ProTaskPlugin(); |
|
|
|
BeanUtil.copyProperties(plugin,newPlugin); |
|
|
|
BeanUtil.copyProperties(plugin, newPlugin); |
|
|
|
newPlugin.setId(snowflake.nextId()); |
|
|
|
newPlugin.setTaskDetailId(newTaskId); |
|
|
|
newPlugin.setMemberRoleId(newRoleMap.get(oldRoleMap.get(newPlugin.getMemberRoleId()))); |
|
|
@ -616,10 +630,10 @@ public class ProjectService implements IProjectService { |
|
|
|
ProTaskDeliverExample deliverExample = new ProTaskDeliverExample(); |
|
|
|
deliverExample.createCriteria().andTaskDetailIdEqualTo(oldTaskId); |
|
|
|
List<ProTaskDeliver> proTaskDeliverList = taskDeliverDao.selectByExample(deliverExample); |
|
|
|
if(CollectionUtil.isNotEmpty(proTaskDeliverList)){ |
|
|
|
for(ProTaskDeliver taskDeliver:proTaskDeliverList){ |
|
|
|
if (CollectionUtil.isNotEmpty(proTaskDeliverList)) { |
|
|
|
for (ProTaskDeliver taskDeliver : proTaskDeliverList) { |
|
|
|
ProTaskDeliver newTaskDeliver = new ProTaskDeliver(); |
|
|
|
BeanUtil.copyProperties(taskDeliver,newTaskDeliver); |
|
|
|
BeanUtil.copyProperties(taskDeliver, newTaskDeliver); |
|
|
|
newTaskDeliver.setId(snowflake.nextId()); |
|
|
|
newTaskDeliver.setTaskDetailId(newTaskId); |
|
|
|
newTaskDeliver.setCheckStatus(0); |
|
|
|