Merge branch 'temp' of http://1.14.125.6:3000/mianbin/ops-pro into temp
This commit is contained in:
commit
c3d042144f
@ -13,22 +13,11 @@ import java.time.LocalDateTime;
|
||||
*/
|
||||
@Data
|
||||
public class PipelineCreateReq {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String createUserId;
|
||||
|
||||
private String updateUserId;
|
||||
|
||||
private String envId;
|
||||
|
||||
private String groupId;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* @pi.name:type
|
||||
* @pi.dataType:Integer
|
||||
@ -75,7 +64,7 @@ public class PipelineCreateReq {
|
||||
|
||||
private String pipelineTag;
|
||||
|
||||
private String resourceId;
|
||||
private String projectId;
|
||||
|
||||
private String remake;
|
||||
|
||||
@ -95,57 +84,5 @@ public class PipelineCreateReq {
|
||||
|
||||
private String executeStatus;
|
||||
|
||||
|
||||
// // 以下为统计信息
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @pi.model:execUser
|
||||
// * @pi.desc:用户(执行人)
|
||||
// */
|
||||
// private User execUser;
|
||||
//
|
||||
// /**
|
||||
// * @pi.name:number
|
||||
// * @pi.dataType:Integer
|
||||
// * @pi.desc:执行次数
|
||||
// * @pi.value:2
|
||||
// */
|
||||
// private Integer number;
|
||||
//
|
||||
// /**
|
||||
// * @pi.name:instanceId
|
||||
// * @pi.dataType:string
|
||||
// * @pi.desc:实例id
|
||||
// * @pi.value:instanceId
|
||||
// */
|
||||
// private String instanceId;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @pi.name:buildStatus
|
||||
// * @pi.dataType:string
|
||||
// * @pi.desc:最近构建状态
|
||||
// * @pi.value:buildStatus
|
||||
// */
|
||||
// private String buildStatus;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @pi.name:lastBuildTime
|
||||
// * @pi.dataType:string
|
||||
// * @pi.desc:最近构建时间
|
||||
// * @pi.value:lastBuildTime
|
||||
// */
|
||||
// private String lastBuildTime;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * @pi.name:isExec
|
||||
// * @pi.dataType:boolean
|
||||
// * @pi.desc:是否可以执行
|
||||
// * @pi.value:true
|
||||
// */
|
||||
// private Boolean isExec;
|
||||
private ResourceReq resourceReq;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cd.casic.ci.common.pipeline.req.pipeline;
|
||||
|
||||
import cd.casic.framework.commons.pojo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.util.List;
|
||||
* @Date 2025/5/10 9:54
|
||||
* @Version 1.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PipelineQueryReq extends PageParam {
|
||||
/**
|
||||
|
@ -109,4 +109,14 @@ public class PipPipeline {
|
||||
* 执行状态
|
||||
*/
|
||||
private String executeStatus;
|
||||
|
||||
/**
|
||||
* 流水线标签
|
||||
*/
|
||||
private String pipelineTag;
|
||||
|
||||
/**
|
||||
* 所属项目id
|
||||
*/
|
||||
private String projectId;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -85,6 +86,18 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
}
|
||||
|
||||
pipeline.setState(1);
|
||||
|
||||
//新增对应的配置类数据
|
||||
if (!ObjectUtils.isEmpty(pipelineReq.getResourceReq())){
|
||||
PipResource resource = new PipResource();
|
||||
BeanUtils.copyProperties(pipelineReq.getResourceReq(),resource);
|
||||
resource.setCreateUserId(pipeline.getCreateUserId());
|
||||
resource.setCreateTime(LocalDateTime.now());
|
||||
resourceService.save(resource);
|
||||
|
||||
pipeline.setResourceId(resource.getId());
|
||||
}
|
||||
|
||||
this.save(pipeline);
|
||||
|
||||
//TODO 根据模板覆写对应的阶段信息以及节点信息
|
||||
@ -97,6 +110,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
stageReq1.setPipelineId(pipeline.getId());
|
||||
stageReq1.setStageName("阶段-1");
|
||||
stageReq1.setCreateTime(LocalDateTime.now());
|
||||
stageReq1.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageReq1.setStageSort(1);
|
||||
stageReq1.setParentId("-1");
|
||||
stageReq1.setCode(true);
|
||||
@ -106,6 +120,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childStage1.setPipelineId(pipeline.getId());
|
||||
childStage1.setStageName("源码");
|
||||
childStage1.setCreateTime(LocalDateTime.now());
|
||||
childStage1.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childStage1.setStageSort(1);
|
||||
childStage1.setCode(false);
|
||||
childStage1.setParentId(stageReq1.getStageId());
|
||||
@ -116,6 +131,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
stageReq2.setPipelineId(pipeline.getId());
|
||||
stageReq2.setStageName("阶段-2");
|
||||
stageReq2.setCreateTime(LocalDateTime.now());
|
||||
stageReq2.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageReq2.setStageSort(2);
|
||||
stageReq2.setParentId("-1");
|
||||
stageReq2.setCode(true);
|
||||
@ -126,6 +142,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childStage21.setStageName("并行阶段-2-1");
|
||||
childStage21.setPipelineId(pipeline.getId());
|
||||
childStage21.setCreateTime(LocalDateTime.now());
|
||||
childStage21.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childStage21.setStageSort(1);
|
||||
childStage21.setCode(false);
|
||||
childStage21.setParentId(stageReq2.getStageId());
|
||||
@ -136,6 +153,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childTask21.setPipelineId(pipeline.getId());
|
||||
childTask21.setTaskName("串行任务-2-1");
|
||||
childTask21.setCreateTime(LocalDateTime.now());
|
||||
childTask21.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childTask21.setTaskType("test");
|
||||
childTask21.setTaskSort(1);
|
||||
childTask21.setStageId(childStage21.getStageId());
|
||||
@ -146,6 +164,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childStage22.setStageName("并行阶段-2-2");
|
||||
childStage22.setPipelineId(pipeline.getId());
|
||||
childStage22.setCreateTime(LocalDateTime.now());
|
||||
childStage22.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childStage22.setStageSort(2);
|
||||
childStage22.setCode(false);
|
||||
childStage22.setParentId(stageReq2.getStageId());
|
||||
@ -153,6 +172,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
|
||||
PipTask childTask22 = new PipTask();
|
||||
childTask22.setCreateTime(LocalDateTime.now());
|
||||
childTask22.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childTask22.setTaskName("串行任务-2-2");
|
||||
childTask22.setPipelineId(pipeline.getId());
|
||||
childTask22.setTaskType("test");
|
||||
@ -165,6 +185,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
stageReq3.setPipelineId(pipeline.getId());
|
||||
stageReq3.setStageName("阶段-3");
|
||||
stageReq3.setCreateTime(LocalDateTime.now());
|
||||
stageReq3.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageReq3.setStageSort(3);
|
||||
stageReq3.setParentId("-1");
|
||||
stageReq3.setCode(true);
|
||||
@ -174,6 +195,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childStage31.setStageName("并行任务-3-1");
|
||||
childStage31.setPipelineId(pipeline.getId());
|
||||
childStage31.setCreateTime(LocalDateTime.now());
|
||||
childStage31.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childStage31.setStageSort(1);
|
||||
childStage31.setCode(false);
|
||||
childStage31.setParentId(stageReq3.getStageId());
|
||||
@ -181,6 +203,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
|
||||
PipTask childTask31 = new PipTask();
|
||||
childTask31.setCreateTime(LocalDateTime.now());
|
||||
childTask31.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childTask31.setTaskName("串行任务-3-1");
|
||||
childTask31.setPipelineId(pipeline.getId());
|
||||
childTask31.setTaskType("test");
|
||||
@ -193,6 +216,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
stageReq4.setPipelineId(pipeline.getId());
|
||||
stageReq4.setStageName("阶段-4");
|
||||
stageReq4.setCreateTime(LocalDateTime.now());
|
||||
stageReq4.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageReq4.setStageSort(4);
|
||||
stageReq4.setParentId("-1");
|
||||
stageReq4.setCode(true);
|
||||
@ -202,6 +226,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
childStage41.setStageName("并行任务-4-1");
|
||||
childStage41.setPipelineId(pipeline.getId());
|
||||
childStage41.setCreateTime(LocalDateTime.now());
|
||||
childStage41.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childStage41.setStageSort(1);
|
||||
childStage41.setCode(false);
|
||||
childStage41.setParentId(stageReq4.getStageId());
|
||||
@ -209,6 +234,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
|
||||
PipTask childTask41 = new PipTask();
|
||||
childTask41.setCreateTime(LocalDateTime.now());
|
||||
childTask41.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
childTask41.setTaskName("串行任务-4-1");
|
||||
childTask41.setPipelineId(pipeline.getId());
|
||||
childTask41.setTaskType("test");
|
||||
@ -218,14 +244,6 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
|
||||
//TODO 创建对应的鉴权关系
|
||||
//TODO 创建对应的消息分发
|
||||
|
||||
//新增对应的配置类数据
|
||||
if (!ObjectUtils.isEmpty(pipelineReq.getResourceReq())){
|
||||
PipResource resource = new PipResource();
|
||||
BeanUtils.copyProperties(pipelineReq.getResourceReq(),resource);
|
||||
resource.setPipelineId(pipeline.getId());
|
||||
resourceService.save(resource);
|
||||
}
|
||||
return pipeline.getId();
|
||||
}
|
||||
|
||||
@ -301,12 +319,12 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
}
|
||||
|
||||
//删除resource表数据
|
||||
QueryWrapper<PipResource> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pipeline_id",pipelineId);
|
||||
List<PipResource> pipResources = pipResourceDao.selectList(wrapper);
|
||||
if (!CollectionUtils.isEmpty(pipResources)){
|
||||
List<String> list = pipResources.stream().map(PipResource::getId).toList();
|
||||
pipResourceDao.deleteByIds(list);
|
||||
if (StringUtils.isNotEmpty(pipeline.getResourceId())){
|
||||
PipResource pipResource = pipResourceDao.selectById(pipeline.getResourceId());
|
||||
|
||||
if (!ObjectUtils.isEmpty(pipResource)){
|
||||
pipResourceDao.deleteById(pipeline.getResourceId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,6 +332,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
public void updatePipeline(PipelineUpdateReq pipeline) {
|
||||
PipPipeline pipPipeline = new PipPipeline();
|
||||
BeanUtils.copyProperties(pipeline,pipPipeline);
|
||||
pipPipeline.setUpdateTime(LocalDateTime.now());
|
||||
pipPipeline.setUpdateUserId(String.valueOf(WebFrameworkUtils.getLoginUserId()));
|
||||
pipelineDao.updateById(pipPipeline);
|
||||
}
|
||||
|
||||
@ -365,6 +385,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
//复制pipeline
|
||||
pipeline.setId(null);
|
||||
pipeline.setName(pipelineName);
|
||||
pipeline.setCreateTime(LocalDateTime.now());
|
||||
pipeline.setCreateUserId(String.valueOf(WebFrameworkUtils.getLoginUserId()));
|
||||
this.save(pipeline);
|
||||
|
||||
//复制stage
|
||||
@ -386,6 +408,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
//对查询结束的stage进行复制
|
||||
o.setStageId(null);
|
||||
o.setPipelineId(pipeline.getId());
|
||||
o.setCreateTime(LocalDateTime.now());
|
||||
o.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageService.save(o);
|
||||
|
||||
if (!CollectionUtils.isEmpty(pipStageChildList)){
|
||||
@ -401,6 +425,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
j.setStageId(null);
|
||||
j.setParentId(o.getStageId());
|
||||
j.setPipelineId(pipeline.getId());
|
||||
j.setCreateTime(LocalDateTime.now());
|
||||
j.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
stageService.save(j);
|
||||
|
||||
if (!CollectionUtils.isEmpty(taskList)){
|
||||
@ -408,6 +434,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
k.setTaskId(null);
|
||||
k.setStageId(j.getStageId());
|
||||
k.setPipelineId(pipeline.getId());
|
||||
k.setCreateTime(LocalDateTime.now());
|
||||
k.setCreateUserId(WebFrameworkUtils.getLoginUserId());
|
||||
});
|
||||
taskService.saveBatch(taskList);
|
||||
}
|
||||
@ -416,5 +444,7 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
//TODO 复制状态下资源处理不明确,暂时只做resourceId的继承保留
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user