模板接口更改
This commit is contained in:
parent
3c3002766e
commit
c5afe87e3c
@ -21,4 +21,6 @@ public class SingletonRunContextResp {
|
||||
private LocalDateTime endTime;
|
||||
private String duration;
|
||||
private String logId;
|
||||
private String userId;
|
||||
private String nickName;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import cd.casic.ci.process.process.dataObject.pipeline.PipPipeline;
|
||||
import cd.casic.ci.process.process.dataObject.stage.PipStage;
|
||||
import cd.casic.ci.process.process.service.pipeline.PipelineService;
|
||||
import cd.casic.ci.process.process.service.stage.StageService;
|
||||
import cd.casic.ci.process.util.WebFrameworkUtils;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import cd.casic.framework.mq.redis.core.RedisMQTemplate;
|
||||
@ -23,6 +24,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -98,6 +100,12 @@ public class DefaultPipelineExecutor implements PipelineExecutor {
|
||||
if (context ==null) {
|
||||
return;
|
||||
}
|
||||
if (context instanceof PipelineRunContext pipelineRunContext) {
|
||||
pipelineRunContext.setUserId(WebFrameworkUtils.getLoginUserIdStr());
|
||||
pipelineRunContext.setUserId(WebFrameworkUtils.getLoginNickName());
|
||||
pipelineRunContext.setStartTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
allContextList.add(context);
|
||||
Collection<BaseRunContext> stageContextList = context.getChildContext().values();
|
||||
allContextList.addAll(stageContextList);
|
||||
|
@ -2,6 +2,7 @@ package cd.casic.ci.process.process.dataObject.template;
|
||||
|
||||
import cd.casic.ci.process.process.dataObject.base.PipBaseElement;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -19,6 +20,7 @@ import java.util.Map;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName(autoResultMap = true)
|
||||
public class TemplateTask extends PipBaseElement {
|
||||
/**
|
||||
* 阶段ID
|
||||
|
@ -106,7 +106,10 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
pipeline.setState(1);
|
||||
|
||||
this.save(pipeline);
|
||||
|
||||
// 默认模板id,以后数据库迁移需要更换
|
||||
if (StringUtils.isEmpty(pipelineReq.getTemplateId())) {
|
||||
pipelineReq.setTemplateId("732923254863433728");
|
||||
}
|
||||
//根据模板ID初始化
|
||||
if (!ObjectUtils.isEmpty(pipelineReq.getTemplateId())){
|
||||
TemplateFindResp template = templateService.findTemplateById(pipelineReq.getTemplateId());
|
||||
@ -479,6 +482,8 @@ public class PipelineServiceImpl extends ServiceImpl<PipelineDao, PipPipeline> i
|
||||
pipeline.setState(pipelineRunContext.getState().get());
|
||||
pipeline.setStartTime(pipelineRunContext.getStartTime());
|
||||
pipeline.setEndTime(pipelineRunContext.getEndTime());
|
||||
pipeline.setUserId(pipelineRunContext.getUserId());
|
||||
pipeline.setNickName(pipelineRunContext.getNickName());
|
||||
Map<String,TreeRunContextResp> secondStageStateMap = new HashMap<>(pipelineRunContext.getChildContext().size());
|
||||
Map<String, BaseRunContext> childContext = pipelineRunContext.getChildContext();
|
||||
pipeline.setChild(secondStageStateMap);
|
||||
|
@ -14,6 +14,8 @@ import cd.casic.ci.process.process.dataObject.template.TemplateManager;
|
||||
import cd.casic.ci.process.process.dataObject.template.TemplateStage;
|
||||
import cd.casic.ci.process.process.dataObject.template.TemplateTask;
|
||||
import cd.casic.ci.process.process.service.template.TemplateManagerService;
|
||||
import cd.casic.ci.process.process.service.template.TemplateStageService;
|
||||
import cd.casic.ci.process.process.service.template.TemplateTaskService;
|
||||
import cd.casic.ci.process.util.snowflake.SnowflakeIdentifierGenerator;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
@ -62,6 +64,8 @@ public class TemplateManagerServiceImpl extends ServiceImpl<TemplateManagerDao,
|
||||
@Resource
|
||||
private TemplateConverter templateConverter;
|
||||
@Resource
|
||||
private TemplateStageService templateStageService;
|
||||
@Resource
|
||||
private SnowflakeIdentifierGenerator idWork;
|
||||
|
||||
public String createTemplateManager(TemplateCreateReq req){
|
||||
@ -205,27 +209,9 @@ public class TemplateManagerServiceImpl extends ServiceImpl<TemplateManagerDao,
|
||||
|
||||
|
||||
private void setStageAndTask(TemplateFindResp o) {
|
||||
List<TemplateStageResp> list = new ArrayList<>();
|
||||
|
||||
//拼接流水线模板主节点
|
||||
List<TemplateStage> stageMainStage = findAllMainStage(o.getId());
|
||||
if (!stageMainStage.isEmpty()){
|
||||
for (TemplateStage stage : stageMainStage) {
|
||||
String stagesId = stage.getId();
|
||||
//获取从节点
|
||||
List<TemplateStage> allStageStage = findSecondStageAndTask(stagesId);
|
||||
List<TemplateStageResp> stageRespList = allStageStage.stream().map(it -> {
|
||||
// BeanUtils.copyProperties(it, stageResp);
|
||||
return JSON.parseObject(JSON.toJSONString(it), TemplateStageResp.class);
|
||||
}).toList();
|
||||
TemplateStageResp stageResp = templateConverter.stageTemplateToResp(stage);
|
||||
stageResp.setStageList(stageRespList);
|
||||
list.add(stageResp);
|
||||
}
|
||||
list.sort(Comparator.comparing(TemplateStageResp::getStageSort));
|
||||
}
|
||||
|
||||
o.setStageList(list);
|
||||
List<TemplateStageResp> allStagesTask = templateStageService.findAllStagesTask(o.getId());
|
||||
o.setStageList(allStagesTask);
|
||||
}
|
||||
|
||||
private List<TemplateStage> findSecondStageAndTask(String stagesId) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user