|
@@ -11369,8 +11369,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(startDate, endDate);
|
|
|
List<ProjectQueryResponse> projectQueryResponses = xmlResponseData.getProjectQueryResponses();
|
|
|
List<Map<String,Object>> idsMapList=new ArrayList<>();
|
|
|
+ LocalDate localDate=LocalDate.now();
|
|
|
if(projectQueryResponses!=null&&projectQueryResponses.size()>0){
|
|
|
- List<Stages> stagesList=new ArrayList<>();
|
|
|
for (ProjectQueryResponse item : projectQueryResponses) {
|
|
|
Project project=new Project();
|
|
|
//处理项目分类
|
|
@@ -11431,64 +11431,98 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
project.setId(any.get().getId());
|
|
|
}
|
|
|
saveOrUpdate(project);
|
|
|
+ if(project.getProjectCode().equals("CPSP2250001")){
|
|
|
+ System.out.println(1);
|
|
|
+ }
|
|
|
//处理项目下任务 ----> 工时管家生成任务分组
|
|
|
List<ProjectTask> projectTasks = item.getProjectTasks();
|
|
|
if(projectTasks!=null&&projectTasks.size()>0){
|
|
|
- projectTasks.forEach(ps->{
|
|
|
- boolean match = idsMapList.stream().anyMatch(i -> i.get("taskGroupUUID").equals(ps.getUUID()));
|
|
|
- if(!match){
|
|
|
- if(StringUtils.isEmpty(ps.getParentTaskUUID())){
|
|
|
- TaskGroup taskGroup=new TaskGroup();
|
|
|
- taskGroup.setProjectId(project.getId());
|
|
|
- taskGroup.setTaskGroupCode(ps.getProjectElementID());
|
|
|
- taskGroup.setName(ps.getTaskGroupName()==null?"":ps.getTaskGroupName().getName());
|
|
|
- TaskGroup one = taskGroupMapper.selectOne(new QueryWrapper<TaskGroup>().eq("project_id", project.getId()).eq("task_group_code", ps.getProjectElementID()));
|
|
|
- if(one!=null){
|
|
|
- taskGroup.setId(one.getId());
|
|
|
- }
|
|
|
- taskGroupService.saveOrUpdate(taskGroup);
|
|
|
- Map<String,Object> map=new HashMap<>();
|
|
|
- map.put("groupId",taskGroup.getId());
|
|
|
- map.put("taskGroupUUID",ps.getUUID());
|
|
|
- map.put("projectId",project.getId());
|
|
|
- idsMapList.add(map);
|
|
|
- }else {
|
|
|
- Optional<ProjectTask> task = projectTasks.stream().filter(p -> p.getUUID().equals(ps.getParentTaskUUID())).findFirst();
|
|
|
- if(task.isPresent()){
|
|
|
- Stages stage = new Stages();
|
|
|
- Optional<Map<String, Object>> exist = idsMapList.stream().filter(i -> i.get("taskGroupUUID").equals(task.get().getUUID())).findFirst();
|
|
|
- if(exist.isPresent()){
|
|
|
- stage.setGroupId(Integer.valueOf(String.valueOf(exist.get().get("groupId"))));
|
|
|
- }else {
|
|
|
- //避免排序问题导致 上级数据未添加 漏掉子数据
|
|
|
- TaskGroup taskGroup=new TaskGroup();
|
|
|
- taskGroup.setProjectId(project.getId());
|
|
|
- taskGroup.setTaskGroupCode(ps.getProjectElementID());
|
|
|
- taskGroup.setName(ps.getTaskGroupName()==null?"":ps.getTaskGroupName().getName());
|
|
|
- TaskGroup one = taskGroupMapper.selectOne(new QueryWrapper<TaskGroup>().eq("project_id", project.getId()).eq("task_group_code", ps.getProjectElementID()));
|
|
|
- if(one!=null){
|
|
|
- taskGroup.setId(one.getId());
|
|
|
- }
|
|
|
- taskGroupService.saveOrUpdate(taskGroup);
|
|
|
- Map<String,Object> map=new HashMap<>();
|
|
|
- map.put("groupId",taskGroup.getId());
|
|
|
- map.put("taskGroupUUID",ps.getUUID());
|
|
|
- map.put("projectId",project.getId());
|
|
|
- idsMapList.add(map);
|
|
|
- stage.setGroupId(taskGroup.getId());
|
|
|
- }
|
|
|
- stage.setSequence(1);
|
|
|
- stage.setProjectId(project.getId());
|
|
|
- stage.setStagesName(ps.getTaskGroupName()==null?"":ps.getTaskGroupName().getName());
|
|
|
- Stages one = stagesMapper.selectOne(new QueryWrapper<Stages>().eq("project_id", project.getId()).eq("stages_name", ps.getProjectElementID()).eq("group_id",stage.getGroupId()));
|
|
|
- if(one!=null){
|
|
|
- stage.setId(one.getId());
|
|
|
- }
|
|
|
- stagesService.saveOrUpdate(stage);
|
|
|
- }
|
|
|
+ //找到任务列表中 作为项目出现的第一级列表
|
|
|
+ Optional<ProjectTask> targetProject = projectTasks.stream().filter(p -> p.getProjectElementID().equals(project.getProjectCode())).findFirst();
|
|
|
+ String targetUUID = targetProject.get().getUUID();
|
|
|
+ //按照层级抽取数据
|
|
|
+ //项目下第一层 作为任务分组数据
|
|
|
+ List<ProjectTask> taskGroupList = projectTasks.stream().filter(p -> p.getParentTaskUUID() != null && p.getParentTaskUUID().equals(targetUUID) && p.getSummaryTaskIndicator()!=null&& p.getSummaryTaskIndicator().equals("true")).collect(Collectors.toList());
|
|
|
+ //抽调任务分组下级数据 作为阶段数据(是没有下级数据的情况下 作为最末级--->工时管家任务)
|
|
|
+ List<String> taskGroupUUIDList = taskGroupList.stream().map(ProjectTask::getUUID).collect(Collectors.toList());
|
|
|
+ List<ProjectTask> stagesList = projectTasks.stream().filter(p -> p.getParentTaskUUID() != null && taskGroupUUIDList.contains(p.getParentTaskUUID()) && p.getSummaryTaskIndicator()!=null&& p.getSummaryTaskIndicator().equals("true")).collect(Collectors.toList());
|
|
|
+ //抽调出最末级
|
|
|
+ List<ProjectTask> taskList = projectTasks.stream().filter(p ->p.getSummaryTaskIndicator()==null||(p.getSummaryTaskIndicator()!=null && !p.getSummaryTaskIndicator().equals("true"))).collect(Collectors.toList());
|
|
|
+ if(taskGroupList!=null && taskGroupList.size()>0){
|
|
|
+ for (ProjectTask group : taskGroupList) {
|
|
|
+ TaskGroup taskGroup=new TaskGroup();
|
|
|
+ taskGroup.setProjectId(project.getId());
|
|
|
+ taskGroup.setTaskGroupCode(group.getProjectElementID());
|
|
|
+ taskGroup.setName(group.getTaskGroupName()==null?"":group.getTaskGroupName().getName());
|
|
|
+ TaskGroup one = taskGroupMapper.selectOne(new QueryWrapper<TaskGroup>().eq("project_id", project.getId()).eq("task_group_code", group.getProjectElementID()));
|
|
|
+ if(one!=null){
|
|
|
+ taskGroup.setId(one.getId());
|
|
|
+ }
|
|
|
+ taskGroupService.saveOrUpdate(taskGroup);
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("groupId",taskGroup.getId());
|
|
|
+ map.put("taskGroupUUID",group.getUUID());
|
|
|
+ map.put("projectId",project.getId());
|
|
|
+ idsMapList.add(map);
|
|
|
+ //当没有作为阶段的数据时 创建默认阶段数据
|
|
|
+ if(stagesList==null || stagesList.size()==0){
|
|
|
+ Stages stage = new Stages();
|
|
|
+ stage.setSequence(1);
|
|
|
+ stage.setProjectId(project.getId());
|
|
|
+ stage.setGroupId(taskGroup.getId());
|
|
|
+ stage.setStagesName("工作开展");
|
|
|
+ stagesService.saveOrUpdate(stage);
|
|
|
+ Map<String,Object> map1=new HashMap<>();
|
|
|
+ map1.put("groupId",taskGroup.getId());
|
|
|
+ map1.put("taskGroupUUID",group.getUUID());
|
|
|
+ map1.put("stageId",stage.getId());
|
|
|
+ map1.put("projectId",project.getId());
|
|
|
+ idsMapList.add(map1);
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ if(stagesList!=null&&stagesList.size()>0){
|
|
|
+ for (ProjectTask targetStage : stagesList) {
|
|
|
+ Optional<Map<String, Object>> targetGroup = idsMapList.stream().filter(i -> i.get("taskGroupUUID").equals(targetStage.getParentTaskUUID())).findFirst();
|
|
|
+ if(!targetGroup.isPresent()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Stages stage = new Stages();
|
|
|
+ stage.setSequence(1);
|
|
|
+ stage.setProjectId(project.getId());
|
|
|
+ stage.setGroupId(Integer.valueOf(String.valueOf(targetGroup.get().get("groupId"))));
|
|
|
+ stage.setStagesCode(targetStage.getProjectElementID());
|
|
|
+ stage.setStagesName(targetStage.getTaskGroupName()==null?"":targetStage.getTaskGroupName().getName());
|
|
|
+ Stages one = stagesMapper.selectOne(new QueryWrapper<Stages>().eq("project_id", project.getId()).eq("stages_name", targetStage.getProjectElementID()).eq("group_id",stage.getGroupId()));
|
|
|
+ if(one!=null){
|
|
|
+ stage.setId(one.getId());
|
|
|
+ }
|
|
|
+ stagesService.saveOrUpdate(stage);
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("groupId",targetGroup.get().get("groupId"));
|
|
|
+ map.put("stageId",stage.getId());
|
|
|
+ map.put("taskGroupUUID",targetGroup.get().get("taskGroupUUID"));
|
|
|
+ map.put("projectId",project.getId());
|
|
|
+ idsMapList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (ProjectTask targetTask : taskList) {
|
|
|
+ Optional<Map<String, Object>> targetMapOp = idsMapList.stream().filter(i -> i.get("taskGroupUUID").equals(targetTask.getParentTaskUUID())&&i.get("stageId")!=null).findFirst();
|
|
|
+ if(targetMapOp.isPresent()){
|
|
|
+// if(StringUtils.isEmpty(targetTask.getTaskGroupName())){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+ Map<String, Object> targetMap = targetMapOp.get();
|
|
|
+ Task task=new Task();
|
|
|
+ task.setProjectId(project.getId());
|
|
|
+ task.setGroupId(Integer.valueOf(String.valueOf(targetMap.get("groupId"))));
|
|
|
+ task.setStagesId(Integer.valueOf(String.valueOf(targetMap.get("stageId"))));
|
|
|
+ task.setCreateDate(localDate);
|
|
|
+ task.setCompanyId(companyId);
|
|
|
+ task.setName(targetTask.getTaskGroupName()==null?"空的任务名称":targetTask.getTaskGroupName().getName());
|
|
|
+ taskService.saveOrUpdate(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|