Compare commits
No commits in common. "2459515c989ebc69e47f352417f5b94a35b589c8" and "81b7533da5300e6be15edfcac35e6725ee5228cb" have entirely different histories.
2459515c98
...
81b7533da5
@ -1,8 +0,0 @@
|
||||
package cd.casic.ci.common.pipeline.req.stage;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class StageUpdateReq {
|
||||
private
|
||||
}
|
@ -9,6 +9,6 @@ public class TaskCreateReq {
|
||||
private String taskName;
|
||||
private String pipelineId;
|
||||
private String taskType;
|
||||
private Integer taskSort;
|
||||
private String taskSort;
|
||||
private JSONObject taskProperties;
|
||||
}
|
||||
|
@ -24,13 +24,13 @@ public class PipStage {
|
||||
private String pipelineId;
|
||||
|
||||
//@ApiProperty(name="stageSort",desc="阶段顺序")
|
||||
private Integer stageSort;
|
||||
private int stageSort;
|
||||
|
||||
//@ApiProperty(name = "parentId",desc="主阶段")
|
||||
private String parentId;
|
||||
|
||||
//@ApiProperty(name = "code",desc="是否是源码")
|
||||
private Boolean code = false;
|
||||
private boolean code = false;
|
||||
|
||||
//@ApiProperty(name = "taskValues",desc="阶段任务")
|
||||
@TableField(exist = false)
|
||||
@ -41,7 +41,4 @@ public class PipStage {
|
||||
private List<PipStage> stageList;
|
||||
// 执行实例id
|
||||
private String instanceId;
|
||||
private LocalDateTime updateTime;
|
||||
private Long createUserId;
|
||||
private Long updateUserId;
|
||||
}
|
||||
|
@ -35,7 +35,4 @@ public class PipTask {
|
||||
|
||||
// 执行实例id
|
||||
private String instanceId;
|
||||
private LocalDateTime updateTime;
|
||||
private Long updateUserId;
|
||||
private Long createUserId;
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ import cd.casic.ci.process.process.service.task.TaskService;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import cd.casic.framework.commons.util.object.BeanUtils;
|
||||
import cd.casic.framework.commons.util.util.WebFrameworkUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@ -23,7 +22,6 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -41,7 +39,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
||||
private TaskService taskService;
|
||||
@Resource
|
||||
private PipStageDao stageDao;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@Override
|
||||
public String createStagesOrTask(StageCreateReq stageReq) {
|
||||
String firstStageId = stageReq.getStageId();
|
||||
@ -51,9 +49,8 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
||||
String secondStageId = task.getStageId();
|
||||
JSONObject taskProperties = task.getTaskProperties();
|
||||
String taskType = task.getTaskType();
|
||||
Integer taskSort = task.getTaskSort();
|
||||
String taskSort = task.getTaskSort();
|
||||
String pipelineId = task.getPipelineId();
|
||||
Long loginUserId = WebFrameworkUtils.getLoginUserId();
|
||||
PipStage firstStage = null;
|
||||
// 判断是否需要新建阶段,如果没有传第一级tageId而传了sort就是需要创建阶段
|
||||
if (StringUtils.isEmpty(firstStageId)) {
|
||||
@ -67,77 +64,11 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
||||
firstStage.setCreateTime(LocalDateTime.now());
|
||||
firstStage.setParentId("-1");
|
||||
firstStage.setPipelineId(pipelineId);
|
||||
|
||||
firstStage.setCreateUserId(loginUserId);
|
||||
firstStage.setUpdateUserId(loginUserId);
|
||||
firstStage.setUpdateTime(LocalDateTime.now());
|
||||
PipStage stageQuery = new PipStage();
|
||||
stageQuery.setPipelineId(pipelineId);
|
||||
stageQuery.setParentId("-1");
|
||||
List<PipStage> otherStageList = getPipStageList(stageQuery);
|
||||
if (!CollectionUtils.isEmpty(otherStageList)) {
|
||||
for (PipStage stage : otherStageList) {
|
||||
if (stageSort<=stage.getStageSort()) {
|
||||
stage.setStageSort(stage.getStageSort()+1);
|
||||
}
|
||||
}
|
||||
updateBatchById(otherStageList);
|
||||
}
|
||||
save(firstStage);
|
||||
// firstStage
|
||||
} else {
|
||||
PipStage stageQuery = new PipStage();
|
||||
stageQuery.setStageId(firstStageId);
|
||||
List<PipStage> pipStageList = getPipStageList(stageQuery);
|
||||
if (!CollectionUtils.isEmpty(pipStageList)) {
|
||||
firstStage = pipStageList.get(0);
|
||||
|
||||
}
|
||||
}
|
||||
if (firstStage == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"创建节点失败");
|
||||
}
|
||||
PipStage secondStage = null;
|
||||
if (secondStageId==null||taskSort==null) {
|
||||
// 添加并行节点
|
||||
secondStage = new PipStage();
|
||||
PipStage stageQuery = new PipStage();
|
||||
stageQuery.setParentId(firstStageId);
|
||||
stageQuery.setPipelineId(pipelineId);
|
||||
List<PipStage> pipStageList = getPipStageList(stageQuery);
|
||||
if (CollectionUtils.isEmpty(pipStageList)) {
|
||||
secondStage.setStageSort(1);
|
||||
} else {
|
||||
secondStage.setStageSort(pipStageList.size()+1);
|
||||
}
|
||||
secondStage.setCreateTime(LocalDateTime.now());
|
||||
secondStage.setUpdateTime(LocalDateTime.now());
|
||||
secondStage.setCreateUserId(loginUserId);
|
||||
secondStage.setParentId(firstStageId);
|
||||
secondStage.setPipelineId(pipelineId);
|
||||
secondStage.setUpdateUserId(loginUserId);
|
||||
save(secondStage);
|
||||
taskSort=1;
|
||||
secondStageId = secondStage.getStageId();
|
||||
} else {
|
||||
secondStage = getById(secondStageId);
|
||||
}
|
||||
if (secondStage == null) {
|
||||
throw new ServiceException(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(),"创建节点失败");
|
||||
}
|
||||
// 保存task
|
||||
PipTask pipTask = new PipTask();
|
||||
pipTask.setTaskType(taskType);
|
||||
pipTask.setTaskSort(taskSort);
|
||||
pipTask.setStageId(secondStageId);
|
||||
pipTask.setTaskName(taskName);
|
||||
pipTask.setCreateTime(LocalDateTime.now());
|
||||
pipTask.setTaskProperties(taskProperties);
|
||||
pipTask.setPipelineId(pipelineId);
|
||||
pipTask.setUpdateTime(LocalDateTime.now());
|
||||
pipTask.setCreateUserId(loginUserId);
|
||||
pipTask.setUpdateUserId(loginUserId);
|
||||
taskService.save(pipTask);
|
||||
return pipTask.getTaskId();
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* 更新主节点阶段顺序
|
||||
@ -343,7 +274,7 @@ public class StageServiceImpl extends ServiceImpl<PipStageDao, PipStage> impleme
|
||||
return;
|
||||
}
|
||||
for (PipStage stage : allStage) {
|
||||
if (stage.getCode()){
|
||||
if (stage.isCode()){
|
||||
throw new ServiceException(50001,"代码源已存在,无法再次创建。");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user