bug修复

This commit is contained in:
even 2025-05-20 19:32:19 +08:00
parent 2d20dc7e09
commit 96033d6353
3 changed files with 25 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package cd.casic.ci.process.process.dataObject.task;
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.json.JSONObject;
@ -28,6 +29,7 @@ public class PipTask extends PipBaseElement {
//@ApiProperty(name="stageId",desc="阶段",eg="@selectOne")
private String stageId;
// task节点配置
@TableField(typeHandler = JacksonTypeHandler.class)
private JSONObject taskProperties;
// 执行实例id

View File

@ -80,9 +80,12 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
} else {
PipStage stageQuery = new PipStage();
stageQuery.setId(firstStageId);
stageQuery.setParentId("-1");
List<PipStage> pipStageList = getPipStageList(stageQuery);
if (!CollectionUtils.isEmpty(pipStageList)) {
firstStage = pipStageList.get(0);
} else {
throw new ServiceException(GlobalErrorCodeConstants.PIPELINE_ERROR.getCode(),"阶段不存在");
}
}
if (firstStage == null) {
@ -116,6 +119,15 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
if (secondStage == null) {
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"创建节点失败");
}
List<PipTask> taskValues = taskService.getTaskByStageIdList(Arrays.asList(secondStage.getId()));
if (!CollectionUtils.isEmpty(taskValues)) {
for (PipTask taskValue : taskValues) {
if (taskValue.getTaskSort()>=taskSort) {
taskValue.setTaskSort(taskValue.getTaskSort()+1);
}
}
taskService.updateBatchById(taskValues);
}
// 保存task
PipTask pipTask = new PipTask();
pipTask.setTaskType(taskType);
@ -175,6 +187,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteStagesOrTask(String taskId) {
PipTask taskQuery = new PipTask();
taskQuery.setId(taskId);
@ -187,14 +200,14 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
// 查询上一级stage下有无其他task 没有则连着stage删除
String stageId = task.getStageId();
String pipelineId = task.getPipelineId();
taskQuery.setId("");
taskQuery = new PipTask();
taskQuery.setStageId(stageId);
List<PipTask> otherTask = taskService.getTask(task);
List<PipTask> otherTask = taskService.getTask(taskQuery);
if (CollectionUtils.isEmpty(otherTask)) {
// 删除当前task的父stage然后判断父stage的父级有无其他子集如果没有就继续删除当前阶段
// 删除当前task的父stage然后判断父stage的父级有无其他子级如果没有就继续删除当前阶段
PipStage stageQuery = new PipStage();
stageQuery.setPipelineId(stageId);
stageQuery.setPipelineId(pipelineId);
stageQuery.setId(stageId);
List<PipStage> currStageList = getPipStageList(stageQuery);
if (CollectionUtils.isEmpty(currStageList)) {
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"stage不存在");
@ -202,8 +215,8 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
PipStage currStage = currStageList.get(0);
deleteStages(stageId);
String parentId = currStage.getParentId();
stageQuery = new PipStage();
stageQuery.setParentId(parentId);
stageQuery.setId(null);
// 查询同阶段其他二级stage如果不存在其他stage则删除阶段stage并整理sort值
List<PipStage> otherStageList = getPipStageList(stageQuery);
if (CollectionUtils.isEmpty(otherStageList)) {
@ -215,6 +228,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
stage.setStageSort(stage.getStageSort()-1);
}
}
updateBatchById(otherStageList);
}
} else {
for (PipTask pipTask : otherTask) {
@ -222,6 +236,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
pipTask.setTaskSort(pipTask.getTaskSort()-1);
}
}
taskService.updateBatchById(otherTask);
}
}
@ -397,6 +412,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
//获取阶段配置及任务
String otherId = stage.getId();
List<PipTask> allStageTask = stageIdTaskMap.get(otherId);
allStageTask.sort(Comparator.comparing(PipTask::getTaskSort));
stage.setTaskValues(allStageTask);
list.add(stage);
}

View File

@ -88,7 +88,7 @@ public class StageController {
stageService.copyStage(stageId);
return CommonResult.success();
}
@PostMapping("/deleteFirstStage")
@PostMapping("/deleteFirstStage/{stageId}")
public CommonResult<Void> deleteFirstStage(@PathVariable String stageId){
stageService.deleteFirstStage(stageId);
return CommonResult.success();