提交 b237fd37 authored 作者: 黄夏豪's avatar 黄夏豪

新增了分页工具 和 流程的条件查询接口

上级 01504290
package com.tykj.workflowcore.base.page;
import lombok.Data;
import org.springframework.data.domain.Sort;
/**
* 描述:Jpa排序类
*
* @author HuangXiahao
* @version V1.0
* @data 2020/5/13
**/
@Data
public class JpaCustomOrder {
private String coulmn;
private Sort.Direction direction;
}
package com.tykj.workflowcore.base.page;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.List;
/**
* JPA分页类
* @author HuangXiahao
* @class CustomOrder
* @data 2020/5/13
**/
public class JpaCustomPage {
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer page = 0;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private Integer size = 15;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private List<JpaCustomOrder> orders = new ArrayList<>();
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public Integer getSize() {
return size;
}
public void setSize(Integer size) {
Assert.isTrue(page >= 0, "分页信息错误!");
this.size = size;
}
public List<JpaCustomOrder> getOrders() {
return orders;
}
public void setOrders(List<JpaCustomOrder> orders) {
this.orders = orders;
}
@JsonIgnore
public long getOffset() {
return page * size;
}
@JsonIgnore
public Integer getLimit() {
return size;
}
@JsonIgnore
public PageRequest getPageable() {
if (orders.size() != 0) {
List<Sort.Order> orders = new ArrayList<>();
this.orders.stream().forEach(item ->
orders.add(new Sort.Order(item.getDirection(), item.getCoulmn())));
return PageRequest.of(getPage(), getLimit(), Sort.by(orders));
}
return PageRequest.of(getPage(), getLimit());
}
}
...@@ -39,7 +39,6 @@ public class TableInfo implements Serializable { ...@@ -39,7 +39,6 @@ public class TableInfo implements Serializable {
@Column(nullable = false,name = "cn_name") @Column(nullable = false,name = "cn_name")
private String cnName; private String cnName;
@Column(name = "description") @Column(name = "description")
private String desc; private String desc;
...@@ -49,8 +48,9 @@ public class TableInfo implements Serializable { ...@@ -49,8 +48,9 @@ public class TableInfo implements Serializable {
@Column(name = "reviser") @Column(name = "reviser")
private String reviser; private String reviser;
@Lob @Lob
@Column(name = "xml",columnDefinition="TEXT") @Column(name = "xml")
private String XML; private String XML;
@Column(name = "update_time") @Column(name = "update_time")
......
package com.tykj.workflowcore.workflow_editer.controller; package com.tykj.workflowcore.workflow_editer.controller;
import com.tykj.workflowcore.base.result.ResultObj;
import com.tykj.workflowcore.base.result.ResultUtil; import com.tykj.workflowcore.base.result.ResultUtil;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.VariableStorage; import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import com.tykj.workflowcore.workflow_editer.entity.vo.SearchFlowInfoVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.VariableStorageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.VariableStorageVo;
import com.tykj.workflowcore.workflow_editer.service.*; import com.tykj.workflowcore.workflow_editer.service.*;
import com.tykj.workflowcore.workflow_editer.vo.DeployedVo; import com.tykj.workflowcore.workflow_editer.vo.DeployedVo;
...@@ -46,35 +48,12 @@ public class FlowsInfoController { ...@@ -46,35 +48,12 @@ public class FlowsInfoController {
@Autowired @Autowired
private VariableStorageService variableStorageService; private VariableStorageService variableStorageService;
@PostMapping("/getAllFlowsInfo")
@ApiOperation(value = "查询所有流程",notes = "分页查询")
public Page<FlowsInfo> getAllFlowsInfo(@RequestBody PageVo pageVo){
if (pageVo.getPageNum() == 0){
pageVo.setPageNum(1);
}
return flowInfoService.getAllFlowsInfo(pageVo);
}
@PostMapping("/searchFlowInfo")
@PostMapping("/getDeployedFlowsInfo") @ApiOperation(value = "查询流程信息")
@ApiOperation(value = "查询已经部署的流程") public ResponseEntity searchFlowInfo(SearchFlowInfoVo searchFlowInfoVo){
public List<DeployedVo> getDeployedFlowsInfo(){ Page<FlowsInfo> flowsInfoList = flowInfoService.searchFlowInfo(searchFlowInfoVo);
ArrayList<DeployedVo> deployedVos = new ArrayList<>(); return ResultUtil.success(flowsInfoList,"查询成功");
//查询已经部署的流程
List<FlowsInfo> deployedFlowsInfo = flowInfoService.getDeployedFlowsInfo();
for (FlowsInfo flowsInfo : deployedFlowsInfo) {
String flowKey = flowsInfo.getFlowKey();
String flowName = flowsInfo.getFlowName();
String startId = flowsInfo.getStartId();
DeployedVo deployedVo = new DeployedVo();
BeanUtils.copyProperties(flowsInfo,deployedVo);
//通过节点id得到pageId
Long pageId = nodeInfoService.findByNodeId(startId);
deployedVo.setPageId(pageId);
deployedVos.add(deployedVo);
}
return deployedVos;
} }
@GetMapping("/deploy") @GetMapping("/deploy")
......
...@@ -66,6 +66,9 @@ public class FlowsInfo { ...@@ -66,6 +66,9 @@ public class FlowsInfo {
@ApiModelProperty("开始节点的id") @ApiModelProperty("开始节点的id")
private String startId; private String startId;
@ApiModelProperty("开始节点的id")
private String startPageId;
@ApiModelProperty("流程实例id") @ApiModelProperty("流程实例id")
private String processInstanceId; private String processInstanceId;
/** /**
......
package com.tykj.workflowcore.workflow_editer.entity.vo;
import com.tykj.workflowcore.base.page.JpaCustomPage;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author HuangXiahao
* @version V1.0
* @class SearchFlowInfoVo
* @packageName com.tykj.workflowcore.workflow_editer.entity.vo
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SearchFlowInfoVo extends JpaCustomPage {
@ApiModelProperty(value = "部署状态",notes = "0 已部署,1 未部署")
private Integer state;
@ApiModelProperty("流程名称")
private String flowName;
@ApiModelProperty("流程主键")
private String flowKey;
}
package com.tykj.workflowcore.workflow_editer.service; package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.vo.SearchFlowInfoVo;
import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo; import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo;
import com.tykj.workflowcore.workflow_editer.vo.PageVo; import com.tykj.workflowcore.workflow_editer.vo.PageVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
...@@ -18,18 +19,6 @@ import java.util.List; ...@@ -18,18 +19,6 @@ import java.util.List;
*/ */
public interface FlowInfoService { public interface FlowInfoService {
/**
* 查询所有流程
* @param pageVo 分页
* @return 返回所有的流程
*/
Page<FlowsInfo> getAllFlowsInfo(@RequestBody PageVo pageVo);
/**
* 查看已经部署的流程
* @return
*/
List<FlowsInfo> getDeployedFlowsInfo();
/** /**
* 根据id查询出一个flowsInfo对象 * 根据id查询出一个flowsInfo对象
* @param id flowInfo Id * @param id flowInfo Id
...@@ -78,4 +67,12 @@ public interface FlowInfoService { ...@@ -78,4 +67,12 @@ public interface FlowInfoService {
*/ */
FlowsInfo disableFlow(Long flowInfoId); FlowsInfo disableFlow(Long flowInfoId);
/**
* 有条件的查询flowinfo
* @param searchFlowInfoVo
* @return
*/
Page<FlowsInfo> searchFlowInfo(SearchFlowInfoVo searchFlowInfoVo);
} }
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.github.wenhao.jpa.PredicateBuilder;
import com.github.wenhao.jpa.Specifications; import com.github.wenhao.jpa.Specifications;
import com.tykj.workflowcore.base.result.ApiException; import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo; import com.tykj.workflowcore.workflow_editer.entity.FlowsInfo;
import com.tykj.workflowcore.workflow_editer.entity.vo.SearchFlowInfoVo;
import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.mapper.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.service.FlowInfoService; import com.tykj.workflowcore.workflow_editer.service.FlowInfoService;
import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo; import com.tykj.workflowcore.workflow_editer.vo.FlowsInfoVo;
...@@ -30,21 +32,6 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -30,21 +32,6 @@ public class FlowInfoServiceImpl implements FlowInfoService {
@Autowired @Autowired
private FlowsInfoMapper flowsInfoMapper; private FlowsInfoMapper flowsInfoMapper;
@Override
public Page<FlowsInfo> getAllFlowsInfo(@RequestBody PageVo pageVo) {
PageRequest pageRequest = PageRequest.of(pageVo.getPageNum()+1, pageVo.getPageSize());
return flowsInfoMapper.findAll(pageRequest);
}
@Override
public List<FlowsInfo> getDeployedFlowsInfo() {
FlowsInfo flowsInfo = new FlowsInfo();
flowsInfo.setState(0);
Specification<FlowsInfo> state = Specifications.<FlowsInfo>and().eq("state", flowsInfo.getState()).build();
return flowsInfoMapper.findAll(state);
}
@Override @Override
public FlowsInfo findById(Long id) { public FlowsInfo findById(Long id) {
...@@ -101,4 +88,13 @@ public class FlowInfoServiceImpl implements FlowInfoService { ...@@ -101,4 +88,13 @@ public class FlowInfoServiceImpl implements FlowInfoService {
} }
return null; return null;
} }
@Override
public Page<FlowsInfo> searchFlowInfo(SearchFlowInfoVo searchFlowInfoVo) {
PredicateBuilder<FlowsInfo> and = Specifications.and();
and.eq(searchFlowInfoVo.getState()!=null,"state",searchFlowInfoVo.getState());
and.eq(searchFlowInfoVo.getFlowKey()!=null,"flowKey",searchFlowInfoVo.getState());
and.eq(searchFlowInfoVo.getFlowName()!=null,"flowName",searchFlowInfoVo.getState());
return flowsInfoMapper.findAll(and.build(), searchFlowInfoVo.getPageable());
}
} }
...@@ -141,11 +141,9 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -141,11 +141,9 @@ public class WorkFlowServiceImpl implements WorkFlowService {
@Override @Override
public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) { public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) {
Long id = flowsInfoVo.getId(); Long id = flowsInfoVo.getId();
String flowKey = flowsInfoVo.getFlowKey(); String flowKey = flowsInfoVo.getFlowKey();
String fileXml = flowsInfoVo.getFileXml(); String fileXml = flowsInfoVo.getFileXml();
//生成xml文件 //生成xml文件
File f = null; File f = null;
try { try {
......
...@@ -21,7 +21,6 @@ import lombok.NoArgsConstructor; ...@@ -21,7 +21,6 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public class DeployedVo { public class DeployedVo {
private FlowsInfoVo flowsInfoVo; private FlowsInfoVo flowsInfoVo;
@ApiModelProperty("节点的第一个绑定的页面id") @ApiModelProperty("节点的第一个绑定的页面id")
......
...@@ -54,6 +54,9 @@ public class FlowsInfoVo { ...@@ -54,6 +54,9 @@ public class FlowsInfoVo {
@ApiModelProperty("开始节点的id") @ApiModelProperty("开始节点的id")
private String startId; private String startId;
@ApiModelProperty("开始节点的id")
private String startPageId;
@ApiModelProperty() @ApiModelProperty()
private List<NodeInfo> nodeInfoList; private List<NodeInfo> nodeInfoList;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论