类型迁移
This commit is contained in:
parent
57dd302228
commit
9005dd4fb5
@ -35,4 +35,7 @@ public class PipelineOpen {
|
||||
|
||||
//流水线执行统计信息
|
||||
private PipelineOverview pipelineOverview;
|
||||
public void setPipelineExecState(PipelineOverview pipelineOverview) {
|
||||
this.pipelineOverview = pipelineOverview;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package cd.casic.module.process.pipeline.definition.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PipelineEntity {
|
||||
//流水线id
|
||||
// @Id
|
||||
// @GeneratorValue(length = 12)
|
||||
// @Column(name = "id")
|
||||
private String id;
|
||||
|
||||
//流水线名称
|
||||
// @Column(name = "name")
|
||||
private String name;
|
||||
|
||||
//流水线创建人
|
||||
// @Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
//流水线创建时间
|
||||
// @Column(name = "create_time")
|
||||
private String createTime;
|
||||
|
||||
//流水线类型 1.多任务 2.多阶段
|
||||
// @Column(name = "type")
|
||||
private int type;
|
||||
|
||||
//运行状态 1.运行中 2.停止中
|
||||
// @Column(name = "state")
|
||||
private int state;
|
||||
|
||||
//项目作用域 1.全局 2.项目
|
||||
// @Column(name = "power")
|
||||
private int power;
|
||||
|
||||
//颜色 1~5随机生成
|
||||
// @Column(name="color")
|
||||
private int color;
|
||||
|
||||
// @Column(name="env_id")
|
||||
private String envId;
|
||||
|
||||
// @Column(name="group_id")
|
||||
private String groupId;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cd.casic.module.process.pipeline.definition.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
//@Entity
|
||||
//@Table(name="pip_other_open")
|
||||
@Data
|
||||
public class PipelineOpenEntity {
|
||||
|
||||
// @Id
|
||||
// @GeneratorValue(length = 12)
|
||||
// @Column(name = "open_id")
|
||||
private String openId;
|
||||
|
||||
// @Column(name = "pipeline_id")
|
||||
private String pipelineId;
|
||||
|
||||
//打开次数
|
||||
// @Column(name = "number")
|
||||
private int number ;
|
||||
|
||||
// @Column(name = "user_id")
|
||||
private String userId ;
|
||||
|
||||
// @Column(name = "create_time")
|
||||
private String createTime;
|
||||
|
||||
}
|
@ -0,0 +1,197 @@
|
||||
package cd.casic.module.process.pipeline.definition.impl;
|
||||
|
||||
import cd.casic.ci.commons.bean.process.definition.Pipeline;
|
||||
import cd.casic.ci.commons.bean.process.definition.PipelineOpen;
|
||||
import cd.casic.ci.commons.bean.support.count.PipelineOverview;
|
||||
import cd.casic.ci.commons.bean.utils.PipelineUtil;
|
||||
import cd.casic.module.process.pipeline.definition.PipelineOpenService;
|
||||
|
||||
import cd.casic.module.process.pipeline.definition.entity.PipelineEntity;
|
||||
import cd.casic.module.process.pipeline.definition.entity.PipelineOpenEntity;
|
||||
import cd.casic.module.process.pipeline.overview.service.PipelineOverviewService;
|
||||
import cd.casic.module.process.process.definition.dao.PipelineDao;
|
||||
import cd.casic.module.process.process.definition.dao.PipelineOpenDao;
|
||||
import cd.casic.module.process.support.authority.service.PipelineAuthorityService;
|
||||
import cd.casic.module.process.toolkit.beans.BeanMapper;
|
||||
import cd.casic.module.process.toolkit.join.JoinTemplate;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
//@Exporter
|
||||
public class PipelineOpenServiceImpl implements PipelineOpenService {
|
||||
|
||||
@Resource
|
||||
PipelineOpenDao pipelineOpenDao;
|
||||
|
||||
@Resource
|
||||
PipelineAuthorityService authorityService;
|
||||
|
||||
@Resource
|
||||
PipelineOverviewService overviewService;
|
||||
|
||||
@Resource
|
||||
JoinTemplate joinTemplate;
|
||||
|
||||
@Resource
|
||||
PipelineDao pipelineDao;
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteAllOpen(String pipelineId){
|
||||
List<PipelineOpen> allOpen = findAllOpenNoQuery();
|
||||
if (allOpen.isEmpty()){
|
||||
return;
|
||||
}
|
||||
for (PipelineOpen pipelineOpen : allOpen) {
|
||||
Pipeline pipeline = pipelineOpen.getPipeline();
|
||||
if (!pipeline.getId().equals(pipelineId)){
|
||||
continue;
|
||||
}
|
||||
deleteOpen(pipelineOpen.getOpenId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePipelineOpen(String pipelineId) {
|
||||
if (pipelineId.equals("undefined")){
|
||||
return;
|
||||
}
|
||||
// TODO
|
||||
// String userId = LoginContext.getLoginId();
|
||||
String userId = "";
|
||||
PipelineOpen pipelineOpen = new PipelineOpen();
|
||||
pipelineOpen.setPipeline(new Pipeline(pipelineId));
|
||||
pipelineOpen.setCreateTime(PipelineUtil.date(1));
|
||||
pipelineOpen.setUserId(userId);
|
||||
createOpen(pipelineOpen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PipelineOpen findOneOpen(String openId) {
|
||||
PipelineOpenEntity openEntity = pipelineOpenDao.findOneOpen(openId);
|
||||
PipelineOpen pipelineOpen = BeanMapper.map(openEntity, PipelineOpen.class);
|
||||
joinTemplate.joinQuery(pipelineOpen);
|
||||
return pipelineOpen;
|
||||
}
|
||||
|
||||
public PipelineOpen findOneOpenNoQuery(String openId) {
|
||||
PipelineOpenEntity openEntity = pipelineOpenDao.findOneOpen(openId);
|
||||
return BeanMapper.map(openEntity, PipelineOpen.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PipelineOpen> findAllOpen() {
|
||||
List<PipelineOpenEntity> allOpen = pipelineOpenDao.findAllOpen();
|
||||
if (Objects.isNull(allOpen)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<PipelineOpen> list = BeanMapper.mapList(allOpen, PipelineOpen.class);
|
||||
joinTemplate.joinQuery(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<PipelineOpen> findAllOpenNoQuery() {
|
||||
List<PipelineOpenEntity> allOpen = pipelineOpenDao.findAllOpen();
|
||||
if (Objects.isNull(allOpen)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return BeanMapper.mapList(allOpen, PipelineOpen.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PipelineOpen> findAllOpenList(List<String> idList) {
|
||||
List<PipelineOpenEntity> openList = pipelineOpenDao.findAllOpenList(idList);
|
||||
return BeanMapper.mapList(openList, PipelineOpen.class);
|
||||
}
|
||||
|
||||
//更新最近打开
|
||||
private void updateOpen(PipelineOpen pipelineOpen) {
|
||||
pipelineOpenDao.updateOpen(BeanMapper.map(pipelineOpen, PipelineOpenEntity.class));
|
||||
}
|
||||
|
||||
//删除最近打开
|
||||
private void deleteOpen(String openId) {
|
||||
pipelineOpenDao.deleteOpen(openId);
|
||||
}
|
||||
|
||||
//创建最近打开
|
||||
private void createOpen(PipelineOpen pipelineOpen) {
|
||||
pipelineOpenDao.createOpen(BeanMapper.map(pipelineOpen, PipelineOpenEntity.class));
|
||||
}
|
||||
|
||||
public List<String> findUserOpen(int number){
|
||||
// 获取用户流水线
|
||||
// TODO
|
||||
// String userId = LoginContext.getLoginId();
|
||||
String userId = "";
|
||||
String[] userPipeline = authorityService.findUserPipelineIdString(userId);
|
||||
if (userPipeline.length == 0){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < userPipeline.length; i++) {
|
||||
builder.append("'").append(userPipeline[i]).append("'");
|
||||
if (i != userPipeline.length-1){
|
||||
builder.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
List<String> pipelineIds = pipelineOpenDao.findUserOpen(userId, number,builder.toString());
|
||||
if (pipelineIds.isEmpty()){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return pipelineIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流水线最近打开
|
||||
* @param number 查询数量
|
||||
* @return 最近打开的流水线
|
||||
*/
|
||||
@Override
|
||||
public List<PipelineOpen> findUserAllOpen(int number) {
|
||||
|
||||
// 获取用户流水线
|
||||
// String userId = LoginContext.getLoginId();
|
||||
String userId = "";
|
||||
|
||||
List<String> pipelineIds = findUserOpen(number);
|
||||
if (pipelineIds.isEmpty()){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<PipelineOpen> openList = new ArrayList<>();
|
||||
|
||||
for (String pipelineId : pipelineIds) {
|
||||
PipelineOpen pipelineOpen = new PipelineOpen();
|
||||
|
||||
PipelineEntity pipelineEntity = pipelineDao.findPipelineById(pipelineId);
|
||||
Pipeline pipeline = BeanMapper.map(pipelineEntity, Pipeline.class);
|
||||
pipelineOpen.setPipeline(pipeline);
|
||||
|
||||
Integer openNumber = pipelineOpenDao.findUserOpenNumber(userId, pipelineId);
|
||||
pipelineOpen.setNumber(openNumber);
|
||||
|
||||
PipelineOverview pipelineOverview = overviewService.pipelineOverview(pipelineId);
|
||||
pipelineOpen.setPipelineExecState(pipelineOverview);
|
||||
|
||||
if (Objects.isNull(pipeline) || Objects.isNull(pipeline.getName())){
|
||||
deleteOpen(pipelineOpen.getOpenId());
|
||||
continue;
|
||||
}
|
||||
|
||||
openList.add(pipelineOpen);
|
||||
}
|
||||
return openList;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,8 +1,19 @@
|
||||
package cd.casic.module.process.process.definition.dao;
|
||||
|
||||
import cd.casic.ci.commons.bean.process.definition.PipelineQuery;
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cd.casic.module.process.pipeline.definition.entity.PipelineEntity;
|
||||
import cd.casic.module.process.process.definition.dataobject.PipelineDo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
@ -12,4 +23,88 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface PipelineDao extends BaseMapperX<PipelineDo> {
|
||||
/**
|
||||
* 创建流水线
|
||||
* @param pipelineEntity 流水线实体
|
||||
* @return 流水线id
|
||||
*/
|
||||
public String createPipeline(PipelineEntity pipelineEntity);
|
||||
|
||||
/**
|
||||
* 删除流水线
|
||||
* @param id 流水线id
|
||||
*/
|
||||
public void deletePipeline(String id);
|
||||
|
||||
/**
|
||||
* 更新流水线
|
||||
* @param pipelineEntity 流水线实体
|
||||
*/
|
||||
public void updatePipeline(PipelineEntity pipelineEntity);
|
||||
|
||||
/**
|
||||
* 查询单个流水线
|
||||
* @param id 流水线id
|
||||
* @return 流水线信息
|
||||
*/
|
||||
public PipelineEntity findPipelineById(String id);
|
||||
|
||||
/**
|
||||
* 查询所有流水线
|
||||
* @return 流水线列表
|
||||
*/
|
||||
public List<PipelineEntity> findAllPipeline();
|
||||
|
||||
|
||||
public List<PipelineEntity> findAllPipelineList(List<String> idList);
|
||||
|
||||
// 关联查询,查询出收藏的
|
||||
public PageResult<PipelineEntity> findPipelineListQuery(PipelineQuery query);
|
||||
|
||||
|
||||
// 第一个方法:将字符串中的所有字母都转换为小写
|
||||
// public static String toLowerCase(String input) {
|
||||
// if (input == null) {
|
||||
// return null;
|
||||
// }
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// for (char c : input.toCharArray()) {
|
||||
// // 如果是大写字母,转换为小写
|
||||
// if (Character.isUpperCase(c)) {
|
||||
// result.append(Character.toLowerCase(c));
|
||||
// } else {
|
||||
// result.append(c);
|
||||
// }
|
||||
// }
|
||||
// return result.toString();
|
||||
// }
|
||||
|
||||
// 第二个方法:将字符串中的所有字母都转换为大写
|
||||
// public static String toUpperCase(String input) {
|
||||
// if (input == null) {
|
||||
// return null;
|
||||
// }
|
||||
// StringBuilder result = new StringBuilder();
|
||||
// for (char c : input.toCharArray()) {
|
||||
// // 如果是小写字母,转换为大写
|
||||
// if (Character.isLowerCase(c)) {
|
||||
// result.append(Character.toUpperCase(c));
|
||||
// } else {
|
||||
// result.append(c);
|
||||
// }
|
||||
// }
|
||||
// return result.toString();
|
||||
// }
|
||||
|
||||
|
||||
public List<PipelineEntity> findPipelineList(PipelineQuery query);
|
||||
|
||||
public PageResult<PipelineEntity> findPipelinePage(PipelineQuery query);
|
||||
|
||||
// default String getLowerCase(String pipelineName) {
|
||||
// return toLowerCase(pipelineName);
|
||||
// }
|
||||
|
||||
public List<PipelineEntity> findRecentlyPipeline(Object[] pipelineIds, Integer number);
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,17 @@
|
||||
package cd.casic.module.process.process.definition.dao;
|
||||
|
||||
import cd.casic.ci.commons.bean.process.definition.PipelineOpenQuery;
|
||||
import cd.casic.framework.commons.pojo.PageResult;
|
||||
import cd.casic.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cd.casic.module.process.pipeline.definition.entity.PipelineOpenEntity;
|
||||
import cd.casic.module.process.process.definition.dataobject.PipelineOpenDo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author by mianbin
|
||||
@ -12,4 +21,67 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
*/
|
||||
@Mapper
|
||||
public interface PipelineOpenDao extends BaseMapperX<PipelineOpenDo> {
|
||||
/**
|
||||
* 创建次数
|
||||
* @param pipelineOpenEntity 次数
|
||||
* @return 次数id
|
||||
*/
|
||||
public String createOpen(PipelineOpenEntity pipelineOpenEntity);
|
||||
|
||||
/**
|
||||
* 删除次数
|
||||
* @param openId 次数id
|
||||
*/
|
||||
public void deleteOpen(String openId);
|
||||
|
||||
/**
|
||||
* 更新次数
|
||||
* @param pipelineOpenEntity 更新信息
|
||||
*/
|
||||
public void updateOpen(PipelineOpenEntity pipelineOpenEntity);
|
||||
|
||||
/**
|
||||
* 查询单个次数信息
|
||||
* @param openId 次数id
|
||||
* @return 次数信息
|
||||
*/
|
||||
public PipelineOpenEntity findOneOpen(String openId);
|
||||
|
||||
/**
|
||||
* 查询用户最近打开的流水线
|
||||
* @param userId 用户id
|
||||
* @return 最近打开信息
|
||||
*/
|
||||
public List<PipelineOpenEntity> findUserAllOpen(String userId);
|
||||
|
||||
public Integer findUserOpenNumberByTime(String userId,String pipelineId,String time);
|
||||
|
||||
|
||||
public Integer findUserOpenNumber(String userId,String pipelineId);
|
||||
|
||||
public List<String> findUserPipelineOpen(String userId,Integer number);
|
||||
|
||||
public List<String> findUserOpen(String userId,Integer number,String pipelineIds);
|
||||
|
||||
|
||||
public List<PipelineOpenEntity> findExpirePipelineOpen(String time);
|
||||
|
||||
|
||||
|
||||
public String findUserLastOpenPipeline(String userId,String pipelineId);
|
||||
|
||||
|
||||
public List<PipelineOpenEntity> findPipelineOpenList(PipelineOpenQuery query);
|
||||
|
||||
|
||||
public PageResult<PipelineOpenEntity> findPipelineOpenPage(PipelineOpenQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有次数
|
||||
* @return 次数集合
|
||||
*/
|
||||
public List<PipelineOpenEntity> findAllOpen();
|
||||
|
||||
public List<PipelineOpenEntity> findAllOpenList(List<String> idList);
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package cd.casic.module.process.service.support.count;
|
||||
|
||||
import cd.casic.ci.commons.bean.support.count.PipelineOverview;
|
||||
|
||||
/**
|
||||
* 流水线统计服务接口
|
||||
*/
|
||||
|
||||
public interface PipelineOverviewService {
|
||||
|
||||
|
||||
/**
|
||||
* 流水线执行信息统计
|
||||
* @param pipelineId 流水线id
|
||||
* @return 统计信息
|
||||
*/
|
||||
PipelineOverview pipelineOverview(String pipelineId);
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user