bug修复
This commit is contained in:
parent
2d20dc7e09
commit
96033d6353
@ -2,6 +2,7 @@ package cd.casic.ci.process.process.dataObject.task;
|
|||||||
|
|
||||||
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -28,6 +29,7 @@ public class PipTask extends PipBaseElement {
|
|||||||
//@ApiProperty(name="stageId",desc="阶段",eg="@selectOne")
|
//@ApiProperty(name="stageId",desc="阶段",eg="@selectOne")
|
||||||
private String stageId;
|
private String stageId;
|
||||||
// task节点配置
|
// task节点配置
|
||||||
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
private JSONObject taskProperties;
|
private JSONObject taskProperties;
|
||||||
|
|
||||||
// 执行实例id
|
// 执行实例id
|
||||||
|
@ -80,9 +80,12 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
} else {
|
} else {
|
||||||
PipStage stageQuery = new PipStage();
|
PipStage stageQuery = new PipStage();
|
||||||
stageQuery.setId(firstStageId);
|
stageQuery.setId(firstStageId);
|
||||||
|
stageQuery.setParentId("-1");
|
||||||
List<PipStage> pipStageList = getPipStageList(stageQuery);
|
List<PipStage> pipStageList = getPipStageList(stageQuery);
|
||||||
if (!CollectionUtils.isEmpty(pipStageList)) {
|
if (!CollectionUtils.isEmpty(pipStageList)) {
|
||||||
firstStage = pipStageList.get(0);
|
firstStage = pipStageList.get(0);
|
||||||
|
} else {
|
||||||
|
throw new ServiceException(GlobalErrorCodeConstants.PIPELINE_ERROR.getCode(),"阶段不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (firstStage == null) {
|
if (firstStage == null) {
|
||||||
@ -116,6 +119,15 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
if (secondStage == null) {
|
if (secondStage == null) {
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"创建节点失败");
|
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
|
// 保存task
|
||||||
PipTask pipTask = new PipTask();
|
PipTask pipTask = new PipTask();
|
||||||
pipTask.setTaskType(taskType);
|
pipTask.setTaskType(taskType);
|
||||||
@ -175,6 +187,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteStagesOrTask(String taskId) {
|
public void deleteStagesOrTask(String taskId) {
|
||||||
PipTask taskQuery = new PipTask();
|
PipTask taskQuery = new PipTask();
|
||||||
taskQuery.setId(taskId);
|
taskQuery.setId(taskId);
|
||||||
@ -187,14 +200,14 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
// 查询上一级stage下有无其他task 没有则连着stage删除
|
// 查询上一级stage下有无其他task 没有则连着stage删除
|
||||||
String stageId = task.getStageId();
|
String stageId = task.getStageId();
|
||||||
String pipelineId = task.getPipelineId();
|
String pipelineId = task.getPipelineId();
|
||||||
taskQuery.setId("");
|
taskQuery = new PipTask();
|
||||||
taskQuery.setStageId(stageId);
|
taskQuery.setStageId(stageId);
|
||||||
List<PipTask> otherTask = taskService.getTask(task);
|
List<PipTask> otherTask = taskService.getTask(taskQuery);
|
||||||
if (CollectionUtils.isEmpty(otherTask)) {
|
if (CollectionUtils.isEmpty(otherTask)) {
|
||||||
// 删除当前task的父stage,然后判断父stage的父级有无其他子集如果没有就继续删除当前阶段
|
// 删除当前task的父stage,然后判断父stage的父级有无其他子级如果没有就继续删除当前阶段
|
||||||
|
|
||||||
PipStage stageQuery = new PipStage();
|
PipStage stageQuery = new PipStage();
|
||||||
stageQuery.setPipelineId(stageId);
|
stageQuery.setPipelineId(pipelineId);
|
||||||
|
stageQuery.setId(stageId);
|
||||||
List<PipStage> currStageList = getPipStageList(stageQuery);
|
List<PipStage> currStageList = getPipStageList(stageQuery);
|
||||||
if (CollectionUtils.isEmpty(currStageList)) {
|
if (CollectionUtils.isEmpty(currStageList)) {
|
||||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"stage不存在");
|
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);
|
PipStage currStage = currStageList.get(0);
|
||||||
deleteStages(stageId);
|
deleteStages(stageId);
|
||||||
String parentId = currStage.getParentId();
|
String parentId = currStage.getParentId();
|
||||||
|
stageQuery = new PipStage();
|
||||||
stageQuery.setParentId(parentId);
|
stageQuery.setParentId(parentId);
|
||||||
stageQuery.setId(null);
|
|
||||||
// 查询同阶段其他二级stage,如果不存在其他stage则删除阶段stage并整理sort值
|
// 查询同阶段其他二级stage,如果不存在其他stage则删除阶段stage并整理sort值
|
||||||
List<PipStage> otherStageList = getPipStageList(stageQuery);
|
List<PipStage> otherStageList = getPipStageList(stageQuery);
|
||||||
if (CollectionUtils.isEmpty(otherStageList)) {
|
if (CollectionUtils.isEmpty(otherStageList)) {
|
||||||
@ -215,6 +228,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
stage.setStageSort(stage.getStageSort()-1);
|
stage.setStageSort(stage.getStageSort()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateBatchById(otherStageList);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (PipTask pipTask : otherTask) {
|
for (PipTask pipTask : otherTask) {
|
||||||
@ -222,6 +236,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
pipTask.setTaskSort(pipTask.getTaskSort()-1);
|
pipTask.setTaskSort(pipTask.getTaskSort()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
taskService.updateBatchById(otherTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -397,6 +412,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
|||||||
//获取阶段配置及任务
|
//获取阶段配置及任务
|
||||||
String otherId = stage.getId();
|
String otherId = stage.getId();
|
||||||
List<PipTask> allStageTask = stageIdTaskMap.get(otherId);
|
List<PipTask> allStageTask = stageIdTaskMap.get(otherId);
|
||||||
|
allStageTask.sort(Comparator.comparing(PipTask::getTaskSort));
|
||||||
stage.setTaskValues(allStageTask);
|
stage.setTaskValues(allStageTask);
|
||||||
list.add(stage);
|
list.add(stage);
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class StageController {
|
|||||||
stageService.copyStage(stageId);
|
stageService.copyStage(stageId);
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
@PostMapping("/deleteFirstStage")
|
@PostMapping("/deleteFirstStage/{stageId}")
|
||||||
public CommonResult<Void> deleteFirstStage(@PathVariable String stageId){
|
public CommonResult<Void> deleteFirstStage(@PathVariable String stageId){
|
||||||
stageService.deleteFirstStage(stageId);
|
stageService.deleteFirstStage(stageId);
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user