Commit 0228b3e3 by huangfusuper

增加当前任务流接口 增加版本节点接口 增加当前版本节点接口

parent 581c3c18
......@@ -86,8 +86,8 @@ public class ApiNodeController {
}
@PostMapping("runTask")
public ResponseResult runTask(String jobName){
apiNodeService.runTask(jobName);
public ResponseResult runTask(String param){
apiNodeService.runTask(param);
return ResponseResult.ok("SUCCESS");
}
......
package com.byit.view;
import com.byit.model.vo.FlowVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.model.vo.FlowVersionVoDep;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 工作流视图界面
* @author huangfu
*/
@RestController
@RequestMapping("view/flow/version")
public class FlowVersionViewController {
private final FlowVersionService flowVersionService;
public FlowVersionViewController(FlowVersionService flowVersionService) {
this.flowVersionService = flowVersionService;
}
@PostMapping("getAllFlowVersion")
public List<FlowVersionVoDep> getAllFlowVersion(){
return flowVersionService.findAllFlow();
}
@PostMapping("findAllVersion")
public List<FlowVersionVo> findAllVersion(){
return flowVersionService.findAllVersion();
}
}
package com.byit.view;
import com.byit.service.FlowVersionService;
import com.byit.vo.FlowVersionVo;
import com.byit.model.Flow;
import com.byit.model.vo.FlowViewVo;
import com.byit.service.FlowService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -9,19 +10,25 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 工作流视图界面
* 当前运行工作流
* @author huangfu
*/
@RestController
@RequestMapping("view/flow")
@RequestMapping("view/flow/")
public class FlowViewController {
private final FlowVersionService flowVersionService;
private final FlowService flowService;
public FlowViewController(FlowVersionService flowVersionService) {
this.flowVersionService = flowVersionService;
public FlowViewController(FlowService flowService) {
this.flowService = flowService;
}
@PostMapping("getAllFlowVersion")
public List<FlowVersionVo> getAllFlowVersion(){
return flowVersionService.findAllFlow();
@PostMapping("findAllThisVersionFlow")
public List<Flow> findAllThisVersionFlow(){
return flowService.findAllFlow();
}
@PostMapping("findAllFlowViewVo")
public List<FlowViewVo> findAllFlowViewVo(){
return flowService.findAllFlowViewVo();
}
}
package com.byit.view;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import com.byit.service.NodeVersionService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author huangfu
*/
@RestController
@RequestMapping("view/node")
public class NodeVersionViewController {
private final NodeVersionService nodeVersionService;
public NodeVersionViewController(NodeVersionService nodeVersionService) {
this.nodeVersionService = nodeVersionService;
}
@RequestMapping("/getFlowNodeVersionVo")
public List<FlowNodeVersionVo> getFlowNodeVersionVo(){
return nodeVersionService.findAll();
}
@RequestMapping("/findAllNodeVersionByFlowId")
public List<NodeVersion> findAllNodeVersionByFlowId(Integer id){
return nodeVersionService.findAllByFlowId(id);
}
}
package com.byit.view;
import com.byit.model.Node;
import com.byit.service.FlowService;
import com.byit.service.NodeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author huangfu
*/
@RestController
@RequestMapping("view/node")
public class NodeViewController {
private final NodeService nodeService;
public NodeViewController(NodeService nodeService) {
this.nodeService = nodeService;
}
@RequestMapping("findNodes")
public List<Node> findNodes(Integer flowId){
return nodeService.findNodeByFlowIdAndVersionName(flowId);
}
}
......@@ -6,7 +6,11 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface FlowMapper {
/**
* 查询全部的任务流数据
* @return
*/
List<Flow> findAllFlow();
/**
* 根据ID查询
* @param id
......
package com.byit.mapper;
import com.byit.model.NodeVersion;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface NodeVersionMapper {
/**
* 查询全部数据 根据工作里ID
* @param flowId
* @return
*/
List<NodeVersion> findAllByFlowId(Integer flowId);
/**
* 查询全部的节点版本
* @return
*/
List<NodeVersion> findAll();
int deleteById(Integer nodeVersionId);
int insertSelective(NodeVersion record);
......
package com.byit.model.vo;
import com.byit.model.NodeVersion;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 工作流对应节点版本的工作流
* @author huangfu
*/
@Data
@ApiModel("工作流对应节点版本的工作流")
@Deprecated
public class FlowNodeVersionVo {
@ApiModelProperty("工作流名称")
private String flowName;
@ApiModelProperty("版本名称")
private String versionName;
@ApiModelProperty("对应的节点的集合")
private List<NodeVersion> nodeVersions;
}
package com.byit.model.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 工作流版本名称
* @author huangfu
*/
@Data
@ApiModel("工作流版本名称")
public class FlowVersionVo {
@ApiModelProperty("ROW-KEY VUE使用")
private String nodeId;
@ApiModelProperty("工作流版本呢的id")
private Integer flowVersionId;
@ApiModelProperty("工作流名称")
private String flowName;
@ApiModelProperty("工作流版本名称")
private String versionName;
@ApiModelProperty("是否存在节点")
private boolean hasChildren;
}
package com.byit.vo;
package com.byit.model.vo;
import com.byit.model.FlowVersion;
import io.swagger.annotations.ApiModel;
......@@ -11,10 +11,12 @@ import java.util.List;
/**
* 工作流版本的视图载体
* @author huangfu
* Search {@link FlowVersionVo}
*/
@ApiModel("工作流版本的视图载体")
@Data
public class FlowVersionVo implements Serializable {
@Deprecated
public class FlowVersionVoDep implements Serializable {
/**
* 工作流名字
*/
......
package com.byit.model.vo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 工作流视图的试图映射
* @author huangfu
*/
@Data
@ApiModel("工作流视图的试图映射")
public class FlowViewVo {
@ApiModelProperty("row-key vue使用")
private String nodeId;
@ApiModelProperty("工作流id")
private Integer flowId;
@ApiModelProperty("工作流名字")
private String flowName;
@ApiModelProperty("版本名称")
private String versionName;
@ApiModelProperty("是否存在节点")
private boolean hasChildren;
}
package com.byit.service;
import com.byit.model.Flow;
import com.byit.model.vo.FlowViewVo;
import com.byit.model.vo.FlowVo;
import com.byit.model.vo.NodeVo;
import org.apache.ibatis.annotations.Param;
......@@ -13,6 +14,17 @@ import java.util.List;
* @create: 2019-12-23 17:33
*/
public interface FlowService {
/**
* 查询全部的任务流数据
* @return
*/
List<FlowViewVo> findAllFlowViewVo();
/**
* 查询全部的任务流数据
* @return
*/
List<Flow> findAllFlow();
/**
* 根据ID查询
* @param id
......
package com.byit.service;
import com.byit.model.FlowVersion;
import com.byit.vo.FlowVersionVo;
import com.byit.model.vo.FlowVersionVo;
import com.byit.model.vo.FlowVersionVoDep;
import java.util.List;
......@@ -13,5 +14,11 @@ public interface FlowVersionService {
* 查询全部的工作流
* @return
*/
List<FlowVersionVo> findAllFlow();
List<FlowVersionVoDep> findAllFlow();
/**
* 查询全部的工作流
* @return
*/
List<FlowVersionVo> findAllVersion();
}
package com.byit.service;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import java.util.List;
/**
* 节点版本的业务
* @author huangfu
*/
public interface NodeVersionService {
/**
* 查询全部的节点版本
* @return 全部
*/
List<FlowNodeVersionVo> findAll();
/**
* 查询全部数据 根据工作里ID
* @param flowId
* @return
*/
List<NodeVersion> findAllByFlowId(Integer flowId);
}
......@@ -10,6 +10,7 @@ import com.byit.enums.NodePropertyEnum;
import com.byit.job.utils.CronExpression;
import com.byit.mapper.*;
import com.byit.model.*;
import com.byit.model.vo.FlowViewVo;
import com.byit.model.vo.FlowVo;
import com.byit.model.vo.NodeVo;
import com.byit.service.FlowService;
......@@ -23,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
/**
* @description: 工作流业务逻辑实现类
......@@ -49,6 +51,26 @@ public class FlowServiceImpl implements FlowService {
@Resource
private WorkspaceMapper workspaceMapper;
@Override
public List<FlowViewVo> findAllFlowViewVo() {
List<Flow> allFlow = findAllFlow();
return allFlow.stream().map(flow -> {
FlowViewVo flowViewVo = new FlowViewVo();
flowViewVo.setFlowId(flow.getFlowId());
flowViewVo.setFlowName(flow.getFlowName());
flowViewVo.setNodeId(UUID.randomUUID().toString().replace("", "-"));
flowViewVo.setVersionName(flow.getVersionName());
flowViewVo.setHasChildren(true);
return flowViewVo;
}).collect(Collectors.toList());
}
@Override
public List<Flow> findAllFlow() {
return flowMapper.findAll();
}
@Override
public Flow findFlowById(Integer id) {
return flowMapper.getById(id);
......
......@@ -2,14 +2,17 @@ package com.byit.service.impl;
import com.byit.mapper.FlowVersionMapper;
import com.byit.model.FlowVersion;
import com.byit.model.vo.FlowVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.vo.FlowVersionVo;
import com.byit.model.vo.FlowVersionVoDep;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 工作流版本业务的实现
......@@ -24,16 +27,30 @@ public class FlowVersionServiceImpl implements FlowVersionService {
}
@Override
public List<FlowVersionVo> findAllFlow() {
public List<FlowVersionVoDep> findAllFlow() {
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
Map<String, List<FlowVersion>> versionColl = allFlow.stream().collect(Collectors.groupingBy(FlowVersion::getFlowName));
List<FlowVersionVo> flowVersionVos = new ArrayList<>();
List<FlowVersionVoDep> flowVersionVoDeps = new ArrayList<>();
versionColl.forEach((key,value) ->{
FlowVersionVo flowVersionVo = new FlowVersionVo();
flowVersionVo.setFlowName(key);
flowVersionVo.setChildren(value);
flowVersionVos.add(flowVersionVo);
FlowVersionVoDep flowVersionVoDep = new FlowVersionVoDep();
flowVersionVoDep.setFlowName(key);
flowVersionVoDep.setChildren(value);
flowVersionVoDeps.add(flowVersionVoDep);
});
return flowVersionVos;
return flowVersionVoDeps;
}
@Override
public List<FlowVersionVo> findAllVersion() {
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
return allFlow.stream().map(flowVersion -> {
FlowVersionVo flowVersionVo = new FlowVersionVo();
flowVersionVo.setNodeId(UUID.randomUUID().toString().replace("-",""));
flowVersionVo.setFlowVersionId(flowVersion.getFlowVersionId());
flowVersionVo.setFlowName(flowVersion.getFlowName());
flowVersionVo.setVersionName(flowVersion.getVersionName());
flowVersionVo.setHasChildren(true);
return flowVersionVo;
}).collect(Collectors.toList());
}
}
package com.byit.service.impl;
import com.byit.mapper.FlowVersionMapper;
import com.byit.mapper.NodeVersionMapper;
import com.byit.model.FlowVersion;
import com.byit.model.NodeVersion;
import com.byit.model.vo.FlowNodeVersionVo;
import com.byit.service.FlowVersionService;
import com.byit.service.NodeVersionService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 节点版本的业务
* @author huangfu
*/
@Service
public class NodeVersionServiceImpl implements NodeVersionService {
private final NodeVersionMapper nodeVersionMapper;
private final FlowVersionMapper flowVersionMapper;
public NodeVersionServiceImpl(NodeVersionMapper nodeVersionMapper, FlowVersionMapper flowVersionMapper) {
this.nodeVersionMapper = nodeVersionMapper;
this.flowVersionMapper = flowVersionMapper;
}
@Override
public List<FlowNodeVersionVo> findAll() {
List<FlowNodeVersionVo> flowNodeVersionVos = new ArrayList<>();
List<NodeVersion> nodeVersionMapperAll = nodeVersionMapper.findAll();
List<FlowVersion> allFlow = flowVersionMapper.findAllFlow();
allFlow.forEach(flow ->{
FlowNodeVersionVo flowNodeVersionVo = new FlowNodeVersionVo();
flowNodeVersionVo.setFlowName(flow.getFlowName());
flowNodeVersionVo.setVersionName(flow.getVersionName());
List<NodeVersion> nodeVersions = nodeVersionMapperAll.stream()
.filter(nodeVersion -> flow.getFlowId().equals(nodeVersion.getFlowId()))
.collect(Collectors.toList());
flowNodeVersionVo.setNodeVersions(nodeVersions);
flowNodeVersionVos.add(flowNodeVersionVo);
});
return flowNodeVersionVos;
}
@Override
public List<NodeVersion> findAllByFlowId(Integer flowId) {
return nodeVersionMapper.findAllByFlowId(flowId);
}
}
......@@ -34,6 +34,12 @@
schedule_follow, is_update, scan_mark
</sql>
<select id="findAllFlow" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from flow
</select>
<select id="findHalfAnHourFlow" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
......
......@@ -56,6 +56,20 @@
run_source
</sql>
<select id="findAllByFlowId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from node_version
where remove_mark = '1' and flow_version_id = #{flowId,jdbcType=INTEGER}
</select>
<select id="findAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from node_version
where remove_mark = '1'
</select>
<select id="getById" parameterType="java.lang.Integer" resultMap="ResultMapWithBLOBs">
<!-- generated @mbg.generated date: 2019-12-31 -->
select
......
package com.byit.dto.web;
import com.byit.enums.IEnum;
import com.byit.enums.TransferResultEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -32,8 +33,8 @@ public class ResponseResult<T> implements Serializable {
*/
public static<T> ResponseResult<T> ok(T t){
ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setCode("0000000");
tResponseResult.setMsg("成功");
tResponseResult.setCode(TransferResultEnum.SUCCESS.getCode());
tResponseResult.setMsg(TransferResultEnum.SUCCESS.getMsg());
tResponseResult.setResult(t);
return tResponseResult;
}
......@@ -44,8 +45,8 @@ public class ResponseResult<T> implements Serializable {
*/
public static<T> ResponseResult<T> ok(){
ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setCode("0000000");
tResponseResult.setMsg("成功");
tResponseResult.setCode(TransferResultEnum.SUCCESS.getCode());
tResponseResult.setMsg(TransferResultEnum.SUCCESS.getMsg());
return tResponseResult;
}
......@@ -71,7 +72,7 @@ public class ResponseResult<T> implements Serializable {
public static<T> ResponseResult<T> error(String msg){
ResponseResult<T> tResponseResult = new ResponseResult<>();
tResponseResult.setMsg(msg);
tResponseResult.setCode("00000500");
tResponseResult.setCode(TransferResultEnum.ERROR.getCode());
return tResponseResult;
}
......@@ -94,7 +95,7 @@ public class ResponseResult<T> implements Serializable {
*/
public boolean isSuccess(){
//成功
if ("0000000".equals(this.code)){
if (TransferResultEnum.SUCCESS.getCode().equals(this.code)){
return true;
}
//失败
......
package com.byit.enums;
/**
* 调用结果枚举 标准
* @author huangfu
*/
public enum TransferResultEnum implements IEnum {
SUCCESS("000000","调用成功"),
ERROR("500000","发生错误")
;
private String code;
private String msg;
TransferResultEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
@Override
public String getCode() {
return code;
}
@Override
public String getMsg() {
return msg;
}
}
......@@ -2,6 +2,7 @@ package com.byit.web.advice;
import com.byit.dto.web.ResponseResult;
import com.byit.enums.IEnum;
import com.byit.enums.TransferResultEnum;
import com.byit.exception.DataValidationException;
import com.byit.job.exceptions.IException;
import org.springframework.web.bind.annotation.ExceptionHandler;
......@@ -26,7 +27,7 @@ public class ExceptionHandle {
if(e instanceof IException){
return error(e);
}else if(e instanceof DataValidationException){
return ResponseResult.error("500",e.getMessage());
return ResponseResult.error(TransferResultEnum.ERROR.getCode(),e.getMessage());
}
return ResponseResult.error(e.getMessage());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment