| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450 |
- package com.seecoder.dataanalysis.analysis.impl;
- import com.seecoder.dataanalysis.analysis.DevcloudDataAnalysisService;
- import com.seecoder.dataanalysis.data.dao.devcloud.*;
- import com.seecoder.dataanalysis.data.dao.eval.UserDao;
- import com.seecoder.dataanalysis.data.entity.devcloud.*;
- import com.seecoder.dataanalysis.data.entity.devcloud.display.*;
- import com.seecoder.dataanalysis.data.entity.eval.User;
- import com.seecoder.dataanalysis.vo.devcloud.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Optional;
- /**
- * @author Peng Yiyan
- * @since 2022/03/12
- */
- @Service
- public class DevcloudDataAnalysisServiceImpl implements DevcloudDataAnalysisService {
- @Autowired
- private DevcloudInfoDao devcloudInfoDao;
- @Autowired
- private DevcloudProjectDao devcloudProjectDao;
- @Autowired
- private DevcloudUserDao devcloudUserDao;
- // @Autowired
- // private ProjectRelateDao projectRelateDao;
- @Autowired
- private UserDao userDao;
- @Autowired
- private ProjectDao projectDao;
- @Override
- public DevcloudInfo updateDevInfoType100(BugInfoDTO bugInfoDTO){
- Integer projectId = bugInfoDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<BugInfo> bugInfoList = devcloudInfo.getBugList();
- boolean exist = false;
- for(int i=0;i<bugInfoList.size();i++){
- //如果已经存在bug_id,则视为对bugInfo的修改
- // System.out.println("--------"+bugInfoList.get(i).getBugId());
- if(bugInfoList.get(i).getBugId().equals(bugInfoDTO.getBugId())){
- exist = true;
- bugInfoList.get(i).setBugId(bugInfoDTO.getBugId());
- bugInfoList.get(i).setUserId(bugInfoDTO.getUserId());
- bugInfoList.get(i).setPriority(bugInfoDTO.getPriority());
- bugInfoList.get(i).setTitle(bugInfoDTO.getTitle());
- bugInfoList.get(i).setDescription(bugInfoDTO.getDescription());
- bugInfoList.get(i).setTimeToTake(bugInfoDTO.getTimeToTake());
- bugInfoList.get(i).setBugState(bugInfoDTO.getBugState());
- break;
- }
- }
- //如果不存在bug_id,将bugInfo加入List
- if(!exist){
- BugInfo bugInfoNew = new BugInfo();
- bugInfoNew.setBugId(bugInfoDTO.getBugId());
- bugInfoNew.setUserId(bugInfoDTO.getUserId());
- bugInfoNew.setPriority(bugInfoDTO.getPriority());
- bugInfoNew.setTitle(bugInfoDTO.getTitle());
- bugInfoNew.setDescription(bugInfoDTO.getDescription());
- bugInfoNew.setTimeToTake(bugInfoDTO.getTimeToTake());
- bugInfoNew.setBugState(bugInfoDTO.getBugState());
- bugInfoList.add(bugInfoNew);
- }
- devcloudInfo.setBugList(bugInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType101(CommitInfoDTO commitInfoDTO){
- Integer projectId = commitInfoDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<CommitInfo> commitInfoList = devcloudInfo.getCommitList();
- boolean exist = false;
- for(int i=0;i<commitInfoList.size();i++){
- if(commitInfoList.get(i).getCommitId().equals(commitInfoDTO.getCommitId())){
- exist = true;
- break;
- }
- }
- if(!exist){
- //新建commit信息
- CommitInfo commitInfo = new CommitInfo();
- commitInfo.setCommitId(commitInfoDTO.getCommitId());
- commitInfo.setUserId(commitInfoDTO.getUserId());
- commitInfo.setCommitName(commitInfoDTO.getCommitName());
- commitInfo.setCommitTime(commitInfoDTO.getCommitTime());
- commitInfo.setMessage(commitInfoDTO.getMessage());
- commitInfo.setType(commitInfoDTO.getType());
- commitInfoList.add(commitInfo);
- }else {
- System.out.println("请勿重复插入");
- }
- devcloudInfo.setCommitList(commitInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType102(TestInfoDTO testInfoDTO){
- Integer projectId = testInfoDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<TestInfo> testInfoList = devcloudInfo.getTestList();
- boolean exist = false;
- for(int i=0;i<testInfoList.size();i++){
- if(testInfoList.get(i).getApiTestId().equals(testInfoDTO.getApiTestId())){
- exist = true;
- break;
- }
- }
- //新建测试信息
- if(!exist){
- TestInfo testInfo = new TestInfo();
- testInfo.setApiTestId(testInfoDTO.getApiTestId());
- testInfo.setUserId(testInfoDTO.getUserId());
- testInfo.setSuccess(testInfoDTO.getSuccess());
- testInfo.setFailure(testInfoDTO.getFailure());
- testInfoList.add(testInfo);
- }else {
- System.out.println("请勿重复插入");
- }
- devcloudInfo.setTestList(testInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType103(PipelineCreationDTO pipelineCreationDTO){
- Integer projectId = pipelineCreationDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<PipelineInfo> pipelineInfoList = devcloudInfo.getPipelineList();
- boolean exist = false;
- for(int i=0;i<pipelineInfoList.size();i++){
- if(pipelineInfoList.get(i).getPipelineId().equals(pipelineCreationDTO.getPipelineId())){
- exist = true;
- break;
- }
- }
- //新建流水线信息
- if(!exist){
- // System.out.println(pipelineInfoList.size());
- // System.out.println(pipelineCreationDTO.getPipelineId());
- PipelineInfo pipelineInfo = new PipelineInfo();
- pipelineInfo.setPipelineId(pipelineCreationDTO.getPipelineId());
- pipelineInfoList.add(pipelineInfo);
- }else {
- System.out.println("请勿重复插入");
- }
- devcloudInfo.setPipelineList(pipelineInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType104(PipelineDeletionDTO pipelineDeletionDTO){
- Integer projectId = pipelineDeletionDTO.getProjectId();
- Integer pipelineId = pipelineDeletionDTO.getPipelineId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<PipelineInfo> pipelineInfoList = devcloudInfo.getPipelineList();
- //找到对应的id,删除
- for(int i=0;i<pipelineInfoList.size();i++){
- if(pipelineInfoList.get(i).getPipelineId().equals(pipelineId)){
- // System.out.println("will remove");
- pipelineInfoList.remove(i);
- break;
- }
- }
- devcloudInfo.setPipelineList(pipelineInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType105(PipelineDeployDTO pipelineDeployDTO){
- Integer projectId = pipelineDeployDTO.getProjectId();
- Integer pipelineId = pipelineDeployDTO.getPipelineId();
- // DevcloudInfo devcloudInfo = devcloudInfoDao.findById(projectId).get();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<PipelineInfo> pipelineInfoList = devcloudInfo.getPipelineList();
- //找到对应的id,存入部署信息
- for(int i=0;i<pipelineInfoList.size();i++){
- if(pipelineInfoList.get(i).getPipelineId().equals(pipelineId)){
- List<RecordInfo> recordInfoList = pipelineInfoList.get(i).getRecordList();
- RecordInfo recordInfo = new RecordInfo();
- recordInfo.setRecordId(pipelineDeployDTO.getRecordId());
- recordInfo.setUserId(pipelineDeployDTO.getUserId());
- recordInfo.setResult(pipelineDeployDTO.getResult());
- recordInfoList.add(recordInfo);
- break;
- }
- }
- devcloudInfo.setPipelineList(pipelineInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType106(TreeNodeInfoDTO treeNodeInfoDTO){
- Integer projectId = treeNodeInfoDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<TreeNodeInfo> treeNodeInfoList = devcloudInfo.getTreeNodeList();
- boolean exist = false;
- for(int i=0;i<treeNodeInfoList.size();i++){
- //如果已经存在node_id,则视为对节点信息的修改
- if(treeNodeInfoList.get(i).getNodeId().equals(treeNodeInfoDTO.getNodeId())){
- exist = true;
- treeNodeInfoList.get(i).setTitle(treeNodeInfoDTO.getTitle());
- treeNodeInfoList.get(i).setUserId(treeNodeInfoDTO.getUserId());
- treeNodeInfoList.get(i).setType(treeNodeInfoDTO.getType());
- treeNodeInfoList.get(i).setPriority(treeNodeInfoDTO.getPriority());
- treeNodeInfoList.get(i).setState(treeNodeInfoDTO.getState());
- treeNodeInfoList.get(i).setTimeToTake(treeNodeInfoDTO.getTimeToTake());
- treeNodeInfoList.get(i).setParentId(treeNodeInfoDTO.getParentId());
- treeNodeInfoList.get(i).setDeep(treeNodeInfoDTO.getDeep());
- break;
- }
- }
- //如果不存在node_id,则视为添加节点
- if(!exist){
- TreeNodeInfo treeNodeInfoNew = new TreeNodeInfo();
- treeNodeInfoNew.setNodeId(treeNodeInfoDTO.getNodeId());
- treeNodeInfoNew.setTitle(treeNodeInfoDTO.getTitle());
- treeNodeInfoNew.setUserId(treeNodeInfoDTO.getUserId());
- treeNodeInfoNew.setType(treeNodeInfoDTO.getType());
- treeNodeInfoNew.setPriority(treeNodeInfoDTO.getPriority());
- treeNodeInfoNew.setState(treeNodeInfoDTO.getState());
- treeNodeInfoNew.setTimeToTake(treeNodeInfoDTO.getTimeToTake());
- treeNodeInfoNew.setParentId(treeNodeInfoDTO.getParentId());
- treeNodeInfoNew.setDeep(treeNodeInfoDTO.getDeep());
- treeNodeInfoList.add(treeNodeInfoNew);
- }
- devcloudInfo.setTreeNodeList(treeNodeInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudInfo updateDevInfoType107(TreeNodeDeletionDTO treeNodeDeletionDTO){
- Integer projectId = treeNodeDeletionDTO.getProjectId();
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result = devcloudInfoDao.findById(projectId);
- if(!result.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- }else {
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- }
- List<TreeNodeInfo> treeNodeInfoList = devcloudInfo.getTreeNodeList();
- List<Integer> nodeIds = treeNodeDeletionDTO.getNodeIds();
- for(int i=0;i<nodeIds.size();i++){
- Integer nodeId = nodeIds.get(i);
- for(int j=0;j<treeNodeInfoList.size();j++){
- if(treeNodeInfoList.get(j).getNodeId().equals(nodeId)){
- treeNodeInfoList.remove(j);
- break;
- }
- }
- }
- devcloudInfo.setTreeNodeList(treeNodeInfoList);
- devcloudInfoDao.save(devcloudInfo);
- return devcloudInfo;
- }
- @Override
- public DevcloudProject updateDevInfoType108(AddProjectDTO addProjectDTO){
- Integer projectId = addProjectDTO.getProjectId();
- DevcloudProject devcloudProject;
- Optional<DevcloudProject> result = devcloudProjectDao.findById(projectId);
- //如果项目-用户信息不存在,则新建项目-用户信息,否则直接查询
- if(!result.isPresent()){
- devcloudProject = new DevcloudProject();
- devcloudProject.setProjectId(projectId);
- // devcloudProjectDao.save(devcloudProject);
- }else {
- devcloudProject = devcloudProjectDao.findById(projectId).get();
- }
- List<Integer> memberIds = devcloudProject.getUserIds();
- //如果该添加日志中的成员id还不在项目中,则加入
- if(!memberIds.contains(addProjectDTO.getUserId())){
- memberIds.add(addProjectDTO.getUserId());
- }
- devcloudProject.setUserIds(memberIds);
- devcloudProjectDao.save(devcloudProject);
- Integer userId = addProjectDTO.getUserId();
- // //查询该项目是否有关联项目,如果有关联项目,需要把该成员也加入关联项目中
- // Optional<ProjectRelate> result2 = projectRelateDao.findById(projectId);
- // Integer relateId = -1;
- // //如果存在关联项目
- // if(result2.isPresent()){
- // relateId = projectRelateDao.findById(projectId).get().getRelateId();
- // }
- //
- // DevcloudProject relateProject;
- // if(relateId != -1){
- // Optional<DevcloudProject> result3 = devcloudProjectDao.findById(relateId);
- // if(!result3.isPresent()){
- // relateProject = new DevcloudProject();
- // relateProject.setProjectId(relateId);
- // }else {
- // relateProject = devcloudProjectDao.findById(relateId).get();
- // }
- //
- // List<Integer> relateMembers = relateProject.getUserIds();
- // if(!relateMembers.contains(userId)){
- // relateMembers.add(userId);
- // relateProject.setUserIds(relateMembers);
- // }
- //
- // devcloudProjectDao.save(relateProject);
- // }
- //处理完项目-用户关系,现在处理用户-项目关系
- //所有的devcloudUser都在此处创建
- DevcloudUser devcloudUser;
- Optional<DevcloudUser> result1 = devcloudUserDao.findById(userId);
- if(!result1.isPresent()){
- devcloudUser = new DevcloudUser();
- devcloudUser.setUserId(userId);
- }else {
- devcloudUser = devcloudUserDao.findById(userId).get();
- }
- List<Integer> projectIds = devcloudUser.getProjectIds();
- if(!projectIds.contains(addProjectDTO.getProjectId())){
- projectIds.add(addProjectDTO.getProjectId());
- }
- // if(relateId!=-1){
- // if(!projectIds.contains(relateId)){
- // projectIds.add(relateId);
- // }
- // }
- devcloudUser.setProjectIds(projectIds);
- devcloudUserDao.save(devcloudUser);
- return devcloudProject;
- }
- @Override
- public int updateDevInfoType109(RelateProjectDTO relateProjectDTO){
- Integer projectAId = relateProjectDTO.getProjectAId();
- Integer projectBId = relateProjectDTO.getProjectBId();
- // ProjectRelate projectRelate;
- // Optional<ProjectRelate> result = projectRelateDao.findById(projectAId);
- // if(!result.isPresent()){
- // projectRelate = new ProjectRelate();
- // projectRelate.setProjectId(projectAId);
- // projectRelate.setRelateId(relateProjectDTO.getProjectBId());
- // projectRelateDao.save(projectRelate);
- // }else {
- // //项目的关联项目只能有一个
- // projectRelate = projectRelateDao.findById(projectAId).get();
- // projectRelate.setRelateId(relateProjectDTO.getProjectBId());
- // projectRelateDao.save(projectRelate);
- // }
- //增加关联后,A和B中的成员应该相同,每个成员也应该加入
- //先将A、B项目中的成员同步
- DevcloudProject projectA, projectB;
- Optional<DevcloudProject> result1 = devcloudProjectDao.findById(projectAId);
- if(!result1.isPresent()){
- projectA = new DevcloudProject();
- projectA.setProjectId(projectAId);
- }else {
- projectA = devcloudProjectDao.findById(projectAId).get();
- }
- Optional<DevcloudProject> result2 = devcloudProjectDao.findById(projectBId);
- if(!result2.isPresent()){
- projectB = new DevcloudProject();
- projectB.setProjectId(projectBId);
- }else {
- projectB = devcloudProjectDao.findById(projectBId).get();
- }
- //将A和B中的user_id进行合并
- List<Integer> totalMembers = new ArrayList<>();
- for(Integer id : projectA.getUserIds()){
- if(!totalMembers.contains(id)){
- totalMembers.add(id);
- }
- }
- for(Integer id : projectB.getUserIds()){
- if(!totalMembers.contains(id)){
- totalMembers.add(id);
- }
- }
- projectA.setUserIds(totalMembers);
- projectB.setUserIds(new ArrayList<>(totalMembers));
- devcloudProjectDao.save(projectA);
- devcloudProjectDao.save(projectB);
- //然后将小组成员遍历,将projectA、B都添加
- for(Integer userId : totalMembers){
- DevcloudUser devcloudUser;
- Optional<DevcloudUser> result3 = devcloudUserDao.findById(userId);
- if(!result3.isPresent()){
- devcloudUser = new DevcloudUser();
- devcloudUser.setUserId(userId);
- }else {
- devcloudUser = devcloudUserDao.findById(userId).get();
- }
- List<Integer> projectIds = devcloudUser.getProjectIds();
- if(!projectIds.contains(projectAId)){
- projectIds.add(projectAId);
- }
- if(!projectIds.contains(projectBId)){
- projectIds.add(projectBId);
- }
- devcloudUser.setProjectIds(projectIds);
- devcloudUserDao.save(devcloudUser);
- }
- return 1;
- }
- @Override
- public Project updateDevInfoType110(ProjectDTO projectDTO){
- Integer projectId = projectDTO.getProjectId();
- Project project;
- Optional<Project> result = projectDao.findById(projectId);
- if(!result.isPresent()){
- project = new Project();
- }else {
- System.out.println("请勿重复添加项目");
- return projectDao.findById(projectId).get();
- }
- project.setProjectId(projectId);
- project.setProjectName(projectDTO.getProjectName());
- project.setDescription(projectDTO.getDescription());
- projectDao.save(project);
- //添加项目之后,初始化项目的devInfo
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result2 = devcloudInfoDao.findById(projectId);
- if(!result2.isPresent()){
- devcloudInfo = new DevcloudInfo(projectId);
- devcloudInfoDao.save(devcloudInfo);
- }
- return project;
- }
- @Override
- public User updateDevInfoType111(UserDTO userDTO){
- Integer userId = userDTO.getUserId();
- User user;
- Optional<User> result = userDao.findById(userId);
- if(!result.isPresent()){
- user = new User();
- }else {
- System.out.println("该用户已存在");
- return userDao.findByUserId(userId);
- }
- user.setUserId(userId);
- user.setName(userDTO.getName());
- user.setRole(userDTO.getRole());
- user.setEmail(userDTO.getEmail());
- user.setPhone(userDTO.getPhone());
- userDao.save(user);
- return user;
- }
- @Override
- public FormatStudent getStudentAnalysis(Integer user_id){
- FormatStudent formatStudent = new FormatStudent();
- User user = userDao.findByUserId(user_id);
- DevcloudUser devcloudUser;
- Optional<DevcloudUser> result = devcloudUserDao.findById(user_id);
- //如果devcloudUser不存在,说明用户还没有加入任何项目
- //但如果存在对应的User信息,则帮用户新建devcloudUser
- if(!result.isPresent()){
- // System.out.println("没有查找到学生id");
- }else {
- devcloudUser = devcloudUserDao.findById(user_id).get();
- }
- //放入展示数据
- formatStudent.setUserId(user_id);
- formatStudent.setName(user.getName());
- formatStudent.setEmail(user.getEmail());
- //根据用户id找到和该用户关联的所有项目id
- List<Integer> projectList = devcloudUserDao.findById(user_id).get().getProjectIds();
- List<Project> projects = new ArrayList<>();
- for(int i=0;i<projectList.size();i++){
- projects.add(projectDao.findById(projectList.get(i)).get());
- }
- //放入个人包含的所有项目信息
- formatStudent.setProjects(projects);
- //放入个人Commit信息,测试信息,流水线信息
- Commit commit = new Commit();
- Test test = new Test();
- Pipeline pipeline = new Pipeline();
- //新增
- Bug bugList = new Bug();
- TreeNode treeNode = new TreeNode();
- Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
- List<String> commit_msg_overview = new ArrayList<>();
- Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
- Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
- //新增bugList和TreeNode
- Integer bug_times=0,high_times=0,finished_times=0;
- Integer treeNode_times=0,high_treeNode_times=0,finished_treeNode_times=0;
- //遍历所有相关项目
- for(int i=0;i<projectList.size();i++){
- Integer projectId = projectList.get(i);
- DevcloudInfo devcloudInfo = devcloudInfoDao.findById(projectId).get();
- //遍历devInfo中的commit信息
- List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
- for(CommitInfo commitInfo : commitInfos){
- if(commitInfo.getUserId() == null) {
- continue;
- }else if(commitInfo.getUserId().equals(user_id)){
- commit_times++;
- commit_msg_overview.add(commitInfo.getMessage());
- //如果是需求的commit
- if(commitInfo.getType().toLowerCase().equals("tree_id")){
- feature_commit++;
- }
- //如果是bug_list的commit
- if(commitInfo.getType().toLowerCase().equals("bug_id")){
- buglist_commit++;
- }
- //判断是否是有效的commit
- if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
- valid_commit_time++;
- }
- }
- }
- //遍历devInfo中的test信息
- List<TestInfo> testInfos = devcloudInfo.getTestList();
- for(TestInfo testInfo : testInfos){
- if(testInfo.getUserId() == null) {
- continue;
- }else if(testInfo.getUserId().equals(user_id)){
- test_times++;
- test_success += testInfo.getSuccess();
- test_failure += testInfo.getFailure();
- test_concurrency_count += testInfo.getSuccess();
- test_concurrency_count += testInfo.getFailure();
- }
- }
- //遍历devInfo中的pipeline信息
- List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
- for(PipelineInfo pipelineInfo : pipelineInfos){
- //遍历每个流水线中的部署记录
- List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
- for(RecordInfo recordInfo : recordInfos){
- if(recordInfo.getUserId() == null) {
- continue;
- }else if(recordInfo.getUserId().equals(user_id)){
- pipeline_deploy++;
- if(recordInfo.getResult().equals("部署成功")){
- pipeline_pass++;
- }
- if(recordInfo.getResult().equals("部署失败")){
- pipeline_failure++;
- }
- }
- }
- }
- //遍历devInfo中的bugList信息
- List<BugInfo> bugInfos = devcloudInfo.getBugList();
- for(BugInfo bugInfo : bugInfos){
- if(bugInfo.getUserId() == null){
- continue;
- }else if(bugInfo.getUserId().equals(user_id)){
- bug_times++;
- if(bugInfo.getPriority().toLowerCase().equals("high")){
- high_times++;
- }
- if(bugInfo.getBugState().toLowerCase().equals("finished")){
- finished_times++;
- }
- }
- }
- //遍历devInfo的treeNode信息
- List<TreeNodeInfo> treeNodeInfos = devcloudInfo.getTreeNodeList();
- for(TreeNodeInfo treeNodeInfo : treeNodeInfos){
- if(treeNodeInfo.getUserId() == null){
- continue;
- }else if(treeNodeInfo.getUserId().equals(user_id)){
- treeNode_times++;
- if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
- high_treeNode_times++;
- }
- if(treeNodeInfo.getState().toLowerCase().equals("finished")){
- finished_treeNode_times++;
- }
- }
- }
- }
- //commit
- commit.setCommit_times(commit_times);
- commit.setValid_commit_times(valid_commit_time);
- commit.setBuglist_commit(buglist_commit);
- commit.setFeature_commit(feature_commit);
- commit.setCommit_msg_overview(commit_msg_overview);
- //test
- test.setTest_times(test_times);
- test.setTest_concurrency_count(test_concurrency_count);
- test.setTest_concurrency_success(test_success);
- test.setTest_concurrency_failure(test_failure);
- //pipeline
- pipeline.setPipeline_deploy(pipeline_deploy);
- pipeline.setPipeline_pass(pipeline_pass);
- pipeline.setPipline_failure(pipeline_failure);
- //bugList
- bugList.setBug_times(bug_times);
- bugList.setHigh_times(high_times);
- bugList.setFinished_times(finished_times);
- //treeNode
- treeNode.setTreeNode_times(treeNode_times);
- treeNode.setHigh_treeNode_times(high_treeNode_times);
- treeNode.setFinished_treeNode_times(finished_treeNode_times);
- formatStudent.setCommit(commit);
- formatStudent.setTest(test);
- formatStudent.setPipeline(pipeline);
- formatStudent.setBuglist(bugList);
- formatStudent.setTreeNode(treeNode);
- return formatStudent;
- }
- @Override
- public FormatGroup getGroupAnalysis(Integer project_id){
- //暂时不存在GroupId,先使用ProjectId代替
- FormatGroup formatGroup = new FormatGroup();
- //记录该小组拥有的所有项目的id
- List<Integer> projectList = new ArrayList<>();
- //记录所有项目的信息,用于小组项目信息展示
- List<Project> projects = new ArrayList<>();
- // Integer projectAId = project_id;
- // Integer projectBId;
- // Optional<ProjectRelate> result1 = projectRelateDao.findById(project_id);
- // if(!result1.isPresent()){
- // System.out.println("没有找到关联项目");
- // }else {
- // projectBId = projectRelateDao.findById(project_id).get().getRelateId();
- // projectList.add(projectBId);
- // projects.add(projectDao.findById(projectBId).get());
- // }
- //先将传入的project加入List
- projectList.add(project_id);
- projects.add(projectDao.findById(project_id).get());
- Optional<DevcloudProject> result2 = devcloudProjectDao.findById(project_id);
- if(!result2.isPresent()){
- System.out.println("没有找到项目的成员信息");
- return null;
- }
- List<Integer> userIds = devcloudProjectDao.findById(project_id).get().getUserIds();
- //遍历加入项目中所有成员下拥有的项目,得到该小组所有的项目
- for(Integer userId : userIds){
- Optional<DevcloudUser> result = devcloudUserDao.findById(userId);
- if(!result.isPresent()){
- continue;
- }else {
- List<Integer> proIds = devcloudUserDao.findById(userId).get().getProjectIds();
- for(Integer proId : proIds){
- if(!projectList.contains(proId)){
- projectList.add(proId);
- projects.add(projectDao.findById(proId).get());
- }
- }
- }
- }
- //将所有的成员信息加入
- List<User> users = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Integer userId = userIds.get(i);
- users.add(userDao.findByUserId(userId));
- }
- int n = userIds.size();
- formatGroup.setProjects(projects);
- formatGroup.setStudents(users);
- //放入小组Commit信息,测试信息,流水线信息
- Commit commit = new Commit();
- Test test = new Test();
- Pipeline pipeline = new Pipeline();
- //新增
- Bug bugList = new Bug();
- TreeNode treeNode = new TreeNode();
- Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
- //记录小组不同成员的commit贡献
- int[] commitTimes = new int[n];
- List<String> commit_msg_overview = new ArrayList<>();
- Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
- //记录小组不同成员的test贡献
- int[] testTimes = new int[n];
- Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
- //记录小组不同成员的deploy贡献
- int[] pipeTimes = new int[n];
- //新增bugList,treeNode
- Integer bug_times=0,high_times=0,finished_times=0;
- //记录小组不同成员的bugList贡献
- int[] bugTimes = new int[n];
- Integer treeNode_times=0,high_treeNode_times=0,finished_treeNode_times=0;
- //记录小组不同成员的treeNode贡献
- int[] treeNodeTimes = new int[n];
- //遍历所有的项目,将整体信息作为小组的分析情况
- for(int i=0;i<projectList.size();i++){
- Integer projectId = projectList.get(i);
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result3 = devcloudInfoDao.findById(projectId);
- //如果找不到对应的项目信息则跳过该项目
- if(!result3.isPresent()){
- continue;
- }
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- //遍历devInfo中的commit信息
- List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
- // System.out.println("commitInfosSize: "+commitInfos.size());
- // commit_times += commitInfos.size();
- for(CommitInfo commitInfo : commitInfos){
- if(commitInfo.getUserId() == null || isInGroup(commitInfo.getUserId(),userIds)==false){
- continue;
- }else{
- commit_times++;
- commit_msg_overview.add(commitInfo.getMessage());
- //如果是需求的commit
- if(commitInfo.getType().toLowerCase().equals("tree_id")||commitInfo.getMessage().startsWith("feat:")){
- feature_commit++;
- }
- //如果是bug_list的commit
- if(commitInfo.getType().toLowerCase().equals("bug_id")||commitInfo.getMessage().startsWith("fix:")){
- buglist_commit++;
- }
- //判断是否是有效的commit
- if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
- valid_commit_time++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(commitInfo.getUserId() == null) {
- continue;
- }else if(commitInfo.getUserId().equals(user_id)){
- commitTimes[j]++;
- // //如果是需求的commit
- // if(commitInfo.getType().toLowerCase().equals("tree_id")||commitInfo.getMessage().startsWith("feat:")){
- // feature_commit++;
- // }
- // //如果是bug_list的commit
- // if(commitInfo.getType().toLowerCase().equals("bug_id")||commitInfo.getMessage().startsWith("fix:")){
- // buglist_commit++;
- // }
- // //判断是否是有效的commit
- // if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
- // valid_commit_time++;
- // }
- }
- }
- }
- //遍历devInfo中的test信息
- List<TestInfo> testInfos = devcloudInfo.getTestList();
- // test_times += testInfos.size();
- for(TestInfo testInfo : testInfos){
- if(testInfo.getUserId() == null || isInGroup(testInfo.getUserId(),userIds)==false){
- continue;
- }else {
- test_times++;
- test_success += testInfo.getSuccess();
- test_failure += testInfo.getFailure();
- test_concurrency_count += testInfo.getSuccess();
- test_concurrency_count += testInfo.getFailure();
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(testInfo.getUserId() == null) {
- continue;
- }else if(testInfo.getUserId().equals(user_id)){
- testTimes[j]++;
- // test_success += testInfo.getSuccess();
- // test_failure += testInfo.getFailure();
- // test_concurrency_count += testInfo.getSuccess();
- // test_concurrency_count += testInfo.getFailure();
- }
- }
- }
- //遍历devInfo中的pipeline信息
- List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
- for(PipelineInfo pipelineInfo : pipelineInfos){
- //遍历每个流水线中的部署记录
- List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
- // for(int j=0;j<userIds.size();j++){
- // Integer user_id = userIds.get(j);
- // for(RecordInfo recordInfo : recordInfos){
- // pipeline_deploy++;
- // if(recordInfo.getUserId() == null) {
- // continue;
- // }else if(recordInfo.getUserId().equals(user_id)){
- // pipeTimes[j]++;
- // if(recordInfo.getResult().equals("部署成功")){
- // pipeline_pass++;
- // }
- // if(recordInfo.getResult().equals("部署失败")){
- // pipeline_failure++;
- // }
- // }
- // }
- // }
- for(RecordInfo recordInfo : recordInfos){
- if(recordInfo.getUserId() == null || isInGroup(recordInfo.getUserId(),userIds)==false){
- continue;
- }else {
- pipeline_deploy++;
- if(recordInfo.getResult().equals("部署成功")){
- pipeline_pass++;
- }
- if(recordInfo.getResult().equals("部署失败")){
- pipeline_failure++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(recordInfo.getUserId() == null) {
- continue;
- }else if(recordInfo.getUserId().equals(user_id)){
- pipeTimes[j]++;
- }
- }
- }
- }
- //遍历devInfo中的bugList信息
- List<BugInfo> bugInfos = devcloudInfo.getBugList();
- for(BugInfo bugInfo : bugInfos){
- if(bugInfo.getUserId() == null || isInGroup(bugInfo.getUserId(),userIds)==false){
- continue;
- }else {
- bug_times++;
- if(bugInfo.getPriority().toLowerCase().equals("high")){
- high_times++;
- }
- if(bugInfo.getBugState().toLowerCase().equals("finished")){
- finished_times++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(bugInfo.getUserId() == null){
- continue;
- }else if(bugInfo.getUserId().equals(user_id)){
- bugTimes[j]++;
- // if(bugInfo.getPriority().toLowerCase().equals("high")){
- // high_times++;
- // }
- // if(bugInfo.getBugState().toLowerCase().equals("finished")){
- // finished_times++;
- // }
- }
- }
- }
- //遍历devInfo的treeNode信息
- List<TreeNodeInfo> treeNodeInfos = devcloudInfo.getTreeNodeList();
- for(TreeNodeInfo treeNodeInfo : treeNodeInfos){
- if(treeNodeInfo.getUserId() == null || isInGroup(treeNodeInfo.getUserId(),userIds)==false){
- continue;
- }else {
- treeNode_times++;
- if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
- high_treeNode_times++;
- }
- if(treeNodeInfo.getState().toLowerCase().equals("finished")){
- finished_treeNode_times++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(treeNodeInfo.getUserId() == null){
- continue;
- }else if(treeNodeInfo.getUserId().equals(user_id)){
- treeNodeTimes[j]++;
- // if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
- // high_treeNode_times++;
- // }
- // if(treeNodeInfo.getState().toLowerCase().equals("finished")){
- // finished_treeNode_times++;
- // }
- }
- }
- }
- }
- DecimalFormat df = new DecimalFormat("#.00");
- //commit
- commit.setCommit_times(commit_times);
- commit.setValid_commit_times(valid_commit_time);
- commit.setBuglist_commit(buglist_commit);
- commit.setFeature_commit(feature_commit);
- commit.setCommit_msg_overview(commit_msg_overview);
- List<Contribution> commitContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(commitTimes[i]);
- Double value;
- if(commit_times == 0){
- value = 0.0;
- }else {
- value = (double)commitTimes[i]/(double)commit_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- commitContribution.add(contribution);
- }
- commit.setCommit_contribution(commitContribution);
- //test
- test.setTest_times(test_times);
- test.setTest_concurrency_count(test_concurrency_count);
- test.setTest_concurrency_success(test_success);
- test.setTest_concurrency_failure(test_failure);
- List<Contribution> testContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(testTimes[i]);
- Double value;
- if(test_times == 0){
- value = 0.0;
- }else {
- value = (double)testTimes[i]/(double)test_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- testContribution.add(contribution);
- }
- test.setTest_contribution(testContribution);
- //pipeline
- pipeline.setPipeline_deploy(pipeline_deploy);
- pipeline.setPipeline_pass(pipeline_pass);
- pipeline.setPipline_failure(pipeline_failure);
- List<Contribution> deployContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(pipeTimes[i]);
- Double value;
- if(pipeline_deploy == 0){
- value = 0.0;
- }else {
- value = (double)pipeTimes[i]/(double)pipeline_deploy;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- deployContribution.add(contribution);
- }
- pipeline.setPipeline_contribution(deployContribution);
- //bugList
- bugList.setBug_times(bug_times);
- bugList.setHigh_times(high_times);
- bugList.setFinished_times(finished_times);
- List<Contribution> bugContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(bugTimes[i]);
- Double value;
- if(bug_times == 0){
- value = 0.0;
- }else {
- value = (double)bugTimes[i]/(double)bug_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- bugContribution.add(contribution);
- }
- bugList.setBug_contribution(bugContribution);
- //treeNode
- treeNode.setTreeNode_times(treeNode_times);
- treeNode.setHigh_treeNode_times(high_treeNode_times);
- treeNode.setFinished_treeNode_times(finished_treeNode_times);
- List<Contribution> treeNodeContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(treeNodeTimes[i]);
- Double value;
- if(bug_times == 0){
- value = 0.0;
- }else {
- value = (double)treeNodeTimes[i]/(double)treeNode_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- treeNodeContribution.add(contribution);
- }
- treeNode.setTreeNode_contribution(treeNodeContribution);
- formatGroup.setCommit(commit);
- formatGroup.setTest(test);
- formatGroup.setPipeline(pipeline);
- formatGroup.setBuglist(bugList);
- formatGroup.setTreeNode(treeNode);
- return formatGroup;
- }
- //判断该记录是否为组员提交的方法
- boolean isInGroup(int id,List<Integer> userIds){
- for(Integer userId : userIds){
- // System.out.println("userid: "+userId);
- // System.out.println("now Id: "+id);
- if(userId == id){
- return true;
- }
- }
- return false;
- }
- @Override
- public FormatGroup getProjectAnalysis(Integer project_id){
- //暂时不存在GroupId,先使用ProjectId代替
- FormatGroup formatGroup = new FormatGroup();
- //记录该小组拥有的所有项目的id
- List<Integer> projectList = new ArrayList<>();
- //记录所有项目的信息,用于小组项目信息展示
- List<Project> projects = new ArrayList<>();
- //先将传入的project加入List
- projectList.add(project_id);
- projects.add(projectDao.findById(project_id).get());
- Optional<DevcloudProject> result2 = devcloudProjectDao.findById(project_id);
- if(!result2.isPresent()){
- System.out.println("没有找到项目的成员信息");
- return null;
- }
- List<Integer> userIds = devcloudProjectDao.findById(project_id).get().getUserIds();
- //将所有的成员信息加入
- List<User> users = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Integer userId = userIds.get(i);
- users.add(userDao.findByUserId(userId));
- }
- int n = userIds.size();
- formatGroup.setProjects(projects);
- formatGroup.setStudents(users);
- //放入小组Commit信息,测试信息,流水线信息
- Commit commit = new Commit();
- Test test = new Test();
- Pipeline pipeline = new Pipeline();
- //新增
- Bug bugList = new Bug();
- TreeNode treeNode = new TreeNode();
- Integer commit_times=0,valid_commit_time=0,buglist_commit=0,feature_commit=0;
- //记录小组不同成员的commit贡献
- int[] commitTimes = new int[n];
- List<String> commit_msg_overview = new ArrayList<>();
- Integer test_success=0,test_failure=0,test_times=0,test_concurrency_count=0;
- //记录小组不同成员的test贡献
- int[] testTimes = new int[n];
- Integer pipeline_deploy=0,pipeline_pass=0,pipeline_failure=0;
- //记录小组不同成员的deploy贡献
- int[] pipeTimes = new int[n];
- //新增bugList,treeNode
- Integer bug_times=0,high_times=0,finished_times=0;
- //记录小组不同成员的bugList贡献
- int[] bugTimes = new int[n];
- Integer treeNode_times=0,high_treeNode_times=0,finished_treeNode_times=0;
- //记录小组不同成员的treeNode贡献
- int[] treeNodeTimes = new int[n];
- //遍历所有的项目,将整体信息作为小组的分析情况
- for(int i=0;i<projectList.size();i++){
- Integer projectId = projectList.get(i);
- DevcloudInfo devcloudInfo;
- Optional<DevcloudInfo> result3 = devcloudInfoDao.findById(projectId);
- //如果找不到对应的项目信息则跳过该项目
- if(!result3.isPresent()){
- continue;
- }
- devcloudInfo = devcloudInfoDao.findById(projectId).get();
- //遍历devInfo中的commit信息
- List<CommitInfo> commitInfos = devcloudInfo.getCommitList();
- // System.out.println("commitInfosSize: "+commitInfos.size());
- // commit_times += commitInfos.size();
- for(CommitInfo commitInfo : commitInfos){
- if(commitInfo.getUserId() == null || isInGroup(commitInfo.getUserId(),userIds)==false){
- continue;
- }else{
- commit_times++;
- commit_msg_overview.add(commitInfo.getMessage());
- //如果是需求的commit
- if(commitInfo.getType().toLowerCase().equals("tree_id")||commitInfo.getMessage().startsWith("feat:")){
- feature_commit++;
- }
- //如果是bug_list的commit
- if(commitInfo.getType().toLowerCase().equals("bug_id")||commitInfo.getMessage().startsWith("fix:")){
- buglist_commit++;
- }
- //判断是否是有效的commit
- if(commitInfo.getMessage().startsWith("feat:")||commitInfo.getMessage().startsWith("fix:")){
- valid_commit_time++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(commitInfo.getUserId() == null) {
- continue;
- }else if(commitInfo.getUserId().equals(user_id)){
- commitTimes[j]++;
- }
- }
- }
- //遍历devInfo中的test信息
- List<TestInfo> testInfos = devcloudInfo.getTestList();
- // test_times += testInfos.size();
- for(TestInfo testInfo : testInfos){
- if(testInfo.getUserId() == null || isInGroup(testInfo.getUserId(),userIds)==false){
- continue;
- }else {
- test_times++;
- test_success += testInfo.getSuccess();
- test_failure += testInfo.getFailure();
- test_concurrency_count += testInfo.getSuccess();
- test_concurrency_count += testInfo.getFailure();
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(testInfo.getUserId() == null) {
- continue;
- }else if(testInfo.getUserId().equals(user_id)){
- testTimes[j]++;
- }
- }
- }
- //遍历devInfo中的pipeline信息
- List<PipelineInfo> pipelineInfos = devcloudInfo.getPipelineList();
- for(PipelineInfo pipelineInfo : pipelineInfos){
- //遍历每个流水线中的部署记录
- List<RecordInfo> recordInfos = pipelineInfo.getRecordList();
- for(RecordInfo recordInfo : recordInfos){
- if(recordInfo.getUserId() == null || isInGroup(recordInfo.getUserId(),userIds)==false){
- continue;
- }else {
- pipeline_deploy++;
- if(recordInfo.getResult().equals("部署成功")){
- pipeline_pass++;
- }
- if(recordInfo.getResult().equals("部署失败")){
- pipeline_failure++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(recordInfo.getUserId() == null) {
- continue;
- }else if(recordInfo.getUserId().equals(user_id)){
- pipeTimes[j]++;
- }
- }
- }
- }
- //遍历devInfo中的bugList信息
- List<BugInfo> bugInfos = devcloudInfo.getBugList();
- for(BugInfo bugInfo : bugInfos){
- if(bugInfo.getUserId() == null || isInGroup(bugInfo.getUserId(),userIds)==false){
- continue;
- }else {
- bug_times++;
- if(bugInfo.getPriority().toLowerCase().equals("high")){
- high_times++;
- }
- if(bugInfo.getBugState().toLowerCase().equals("finished")){
- finished_times++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(bugInfo.getUserId() == null){
- continue;
- }else if(bugInfo.getUserId().equals(user_id)){
- bugTimes[j]++;
- }
- }
- }
- //遍历devInfo的treeNode信息
- List<TreeNodeInfo> treeNodeInfos = devcloudInfo.getTreeNodeList();
- for(TreeNodeInfo treeNodeInfo : treeNodeInfos){
- if(treeNodeInfo.getUserId() == null || isInGroup(treeNodeInfo.getUserId(),userIds)==false){
- continue;
- }else {
- treeNode_times++;
- if(treeNodeInfo.getPriority().toLowerCase().equals("high")){
- high_treeNode_times++;
- }
- if(treeNodeInfo.getState().toLowerCase().equals("finished")){
- finished_treeNode_times++;
- }
- }
- for(int j=0;j<userIds.size();j++){
- Integer user_id = userIds.get(j);
- if(treeNodeInfo.getUserId() == null){
- continue;
- }else if(treeNodeInfo.getUserId().equals(user_id)){
- treeNodeTimes[j]++;
- }
- }
- }
- }
- DecimalFormat df = new DecimalFormat("#.00");
- //commit
- commit.setCommit_times(commit_times);
- commit.setValid_commit_times(valid_commit_time);
- commit.setBuglist_commit(buglist_commit);
- commit.setFeature_commit(feature_commit);
- commit.setCommit_msg_overview(commit_msg_overview);
- List<Contribution> commitContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(commitTimes[i]);
- Double value;
- if(commit_times == 0){
- value = 0.0;
- }else {
- value = (double)commitTimes[i]/(double)commit_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- commitContribution.add(contribution);
- }
- commit.setCommit_contribution(commitContribution);
- //test
- test.setTest_times(test_times);
- test.setTest_concurrency_count(test_concurrency_count);
- test.setTest_concurrency_success(test_success);
- test.setTest_concurrency_failure(test_failure);
- List<Contribution> testContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(testTimes[i]);
- Double value;
- if(test_times == 0){
- value = 0.0;
- }else {
- value = (double)testTimes[i]/(double)test_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- testContribution.add(contribution);
- }
- test.setTest_contribution(testContribution);
- //pipeline
- pipeline.setPipeline_deploy(pipeline_deploy);
- pipeline.setPipeline_pass(pipeline_pass);
- pipeline.setPipline_failure(pipeline_failure);
- List<Contribution> deployContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(pipeTimes[i]);
- Double value;
- if(pipeline_deploy == 0){
- value = 0.0;
- }else {
- value = (double)pipeTimes[i]/(double)pipeline_deploy;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- deployContribution.add(contribution);
- }
- pipeline.setPipeline_contribution(deployContribution);
- //bugList
- bugList.setBug_times(bug_times);
- bugList.setHigh_times(high_times);
- bugList.setFinished_times(finished_times);
- List<Contribution> bugContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(bugTimes[i]);
- Double value;
- if(bug_times == 0){
- value = 0.0;
- }else {
- value = (double)bugTimes[i]/(double)bug_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- bugContribution.add(contribution);
- }
- bugList.setBug_contribution(bugContribution);
- //treeNode
- treeNode.setTreeNode_times(treeNode_times);
- treeNode.setHigh_treeNode_times(high_treeNode_times);
- treeNode.setFinished_treeNode_times(finished_treeNode_times);
- List<Contribution> treeNodeContribution = new ArrayList<>();
- for(int i=0;i<userIds.size();i++){
- Contribution contribution = new Contribution();
- contribution.setUserId(users.get(i).getUserId());
- contribution.setName(users.get(i).getName());
- contribution.setTimes(treeNodeTimes[i]);
- Double value;
- if(bug_times == 0){
- value = 0.0;
- }else {
- value = (double)treeNodeTimes[i]/(double)treeNode_times;
- }
- contribution.setProportion(Double.valueOf(df.format(value)));
- treeNodeContribution.add(contribution);
- }
- treeNode.setTreeNode_contribution(treeNodeContribution);
- formatGroup.setCommit(commit);
- formatGroup.setTest(test);
- formatGroup.setPipeline(pipeline);
- formatGroup.setBuglist(bugList);
- formatGroup.setTreeNode(treeNode);
- return formatGroup;
- }
- }
|