提交 183ff408 authored 作者: zhoushaopan's avatar zhoushaopan

[工作流模块] 校验bpmn文件

上级 e9aba5d6
...@@ -16,6 +16,7 @@ import org.springframework.http.ResponseEntity; ...@@ -16,6 +16,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -34,7 +35,6 @@ public class ModelController { ...@@ -34,7 +35,6 @@ public class ModelController {
@Autowired @Autowired
private ModelService modelService; private ModelService modelService;
/** /**
* @param * @param
* @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo> * @return java.util.List<com.tykj.workflowcore.model_layer.model.TableInfo>
......
...@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page; ...@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.xml.stream.XMLStreamException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -61,7 +62,7 @@ public class FlowsInfoController { ...@@ -61,7 +62,7 @@ public class FlowsInfoController {
@PostMapping("/saveXml") @PostMapping("/saveXml")
@ApiOperation(value = "保存xml以及其他流程信息") @ApiOperation(value = "保存xml以及其他流程信息")
public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) { public ResponseEntity saveXml(@RequestBody FlowsInfoVo flowsInfoVo) throws FileNotFoundException, XMLStreamException {
//保存节点信息 //保存节点信息
nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList()); nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息 //保存xml信息
......
...@@ -6,7 +6,7 @@ import com.tykj.workflowcore.workflow_editer.entity.FormPage; ...@@ -6,7 +6,7 @@ import com.tykj.workflowcore.workflow_editer.entity.FormPage;
//import com.tykj.workflowcore.workflow_editer.entity.PageEntity; //import com.tykj.workflowcore.workflow_editer.entity.PageEntity;
import com.tykj.workflowcore.workflow_editer.service.FormPageService; import com.tykj.workflowcore.workflow_editer.service.FormPageService;
//import com.tykj.workflowcore.workflow_editer.service.PageEntityService; //import com.tykj.workflowcore.workflow_editer.service.PageEntityService;
import com.tykj.workflowcore.workflow_editer.entity.vo.InFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -35,7 +35,7 @@ public class FormPageController { ...@@ -35,7 +35,7 @@ public class FormPageController {
@ApiOperation("保存页面") @ApiOperation("保存页面")
@PostMapping("/savePage") @PostMapping("/savePage")
public ResponseEntity savePage(@RequestBody InFormPageVo inFormPageVo){ public ResponseEntity savePage(@RequestBody FormPageVo inFormPageVo){
if (inFormPageVo.getId() == null){ if (inFormPageVo.getId() == null){
Integer pageId = formPageService.savePage(inFormPageVo); Integer pageId = formPageService.savePage(inFormPageVo);
return ResultUtil.success(pageId,"页面保存成功"); return ResultUtil.success(pageId,"页面保存成功");
...@@ -48,7 +48,7 @@ public class FormPageController { ...@@ -48,7 +48,7 @@ public class FormPageController {
} }
@ApiOperation("回显页面") @ApiOperation("回显页面")
@GetMapping("/EchoPage") @GetMapping("/EchoPage")
public FormPage EchoPage(Integer id){ public FormPageVo EchoPage(Integer id){
return formPageService.getPage(id); return formPageService.getPage(id);
} }
...@@ -66,6 +66,7 @@ public class FormPageController { ...@@ -66,6 +66,7 @@ public class FormPageController {
return ResultUtil.success("删除页面成功"); return ResultUtil.success("删除页面成功");
} }
@ApiOperation("通过页面id查询所对应的数据模型")
@PostMapping("/findByPages") @PostMapping("/findByPages")
public List<TableInfo> findByPages(@RequestBody List<Integer> pageIds){ public List<TableInfo> findByPages(@RequestBody List<Integer> pageIds){
return formPageService.findByPageIds(pageIds); return formPageService.findByPageIds(pageIds);
......
...@@ -2,7 +2,7 @@ package com.tykj.workflowcore.workflow_editer.entity; ...@@ -2,7 +2,7 @@ package com.tykj.workflowcore.workflow_editer.entity;
import com.tykj.workflowcore.base.entity.BaseEntity; import com.tykj.workflowcore.base.entity.BaseEntity;
import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan; import com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan;
import com.tykj.workflowcore.workflow_editer.entity.vo.OutFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
...@@ -13,7 +13,8 @@ import org.hibernate.annotations.Where; ...@@ -13,7 +13,8 @@ import org.hibernate.annotations.Where;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Arrays;
import java.util.List;
/** /**
* ClassName: FormPage * ClassName: FormPage
...@@ -52,21 +53,20 @@ public class FormPage extends BaseEntity { ...@@ -52,21 +53,20 @@ public class FormPage extends BaseEntity {
@Lob @Lob
private String css; private String css;
// @ApiModelProperty("创建的时间")
// private Date createTime;
//
// @ApiModelProperty("修改的时间")
// private Date updateTime;
@ApiModelProperty("json描述文件") @ApiModelProperty("json描述文件")
private String descFile; private String descFile;
@ApiModelProperty("实体类id") @ApiModelProperty("实体类id")
private String entityId; private String entityId;
public OutFormPageVo toEntityVo(){ public FormPageVo toEntityVo(){
OutFormPageVo outFormPageVo = new OutFormPageVo(); FormPageVo inFormPageVo = new FormPageVo();
BeanUtils.copyProperties(this,outFormPageVo); BeanUtils.copyProperties(this,inFormPageVo);
return outFormPageVo; //将string还原成list
String entityId = this.getEntityId();
String str[] = entityId.split(",");
List<String> entityIds = Arrays.asList(str);
inFormPageVo.setEntityIds(entityIds);
return inFormPageVo;
} }
} }
...@@ -22,7 +22,7 @@ import java.util.List; ...@@ -22,7 +22,7 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class InFormPageVo { public class FormPageVo {
@ApiModelProperty("页面id") @ApiModelProperty("页面id")
private Integer id; private Integer id;
...@@ -59,6 +59,13 @@ public class InFormPageVo { ...@@ -59,6 +59,13 @@ public class InFormPageVo {
public FormPage toEntity(){ public FormPage toEntity(){
FormPage formPage = new FormPage(); FormPage formPage = new FormPage();
StringBuffer IdStr = new StringBuffer();
for (String entityId : entityIds) {
IdStr.append(entityId);
IdStr.append(",");
}
formPage.setEntityId(IdStr.toString());
BeanUtils.copyProperties(this,formPage); BeanUtils.copyProperties(this,formPage);
return formPage; return formPage;
} }
......
...@@ -2,10 +2,9 @@ package com.tykj.workflowcore.workflow_editer.service; ...@@ -2,10 +2,9 @@ package com.tykj.workflowcore.workflow_editer.service;
import com.tykj.workflowcore.model_layer.entity.TableInfo; import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage; import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.entity.vo.InFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.List; import java.util.List;
...@@ -25,7 +24,7 @@ public interface FormPageService { ...@@ -25,7 +24,7 @@ public interface FormPageService {
* @param inFormPageVo 页面实体 * @param inFormPageVo 页面实体
* @return 主键id * @return 主键id
*/ */
Integer savePage(@RequestBody InFormPageVo inFormPageVo); Integer savePage(@RequestBody FormPageVo inFormPageVo);
/** /**
* 更新页面 * 更新页面
...@@ -38,7 +37,7 @@ public interface FormPageService { ...@@ -38,7 +37,7 @@ public interface FormPageService {
* @param id 页面id * @param id 页面id
* @return 页面信息 * @return 页面信息
*/ */
FormPage getPage(Integer id); FormPageVo getPage(Integer id);
/** /**
* 根据页面id删除页面 * 根据页面id删除页面
......
...@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.stream.XMLStreamException;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
...@@ -35,7 +36,7 @@ public interface WorkFlowService { ...@@ -35,7 +36,7 @@ public interface WorkFlowService {
* 接收前端的流程文件 * 接收前端的流程文件
* @param flowsInfoVo * @param flowsInfoVo
*/ */
void flowXml(@RequestBody FlowsInfoVo flowsInfoVo); void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, FileNotFoundException;
/** /**
* 创建流程 * 创建流程
......
...@@ -8,17 +8,18 @@ import com.tykj.workflowcore.model_layer.entity.TableInfo; ...@@ -8,17 +8,18 @@ import com.tykj.workflowcore.model_layer.entity.TableInfo;
import com.tykj.workflowcore.workflow_editer.entity.FormPage; import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import com.tykj.workflowcore.workflow_editer.dao.FormPageMapper; import com.tykj.workflowcore.workflow_editer.dao.FormPageMapper;
import com.tykj.workflowcore.workflow_editer.service.FormPageService; import com.tykj.workflowcore.workflow_editer.service.FormPageService;
import com.tykj.workflowcore.workflow_editer.entity.vo.InFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo;
import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo; import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* ClassName: PageEntityServiceImpl * ClassName: PageEntityServiceImpl
...@@ -36,7 +37,7 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -36,7 +37,7 @@ public class FormPageServiceImpl implements FormPageService {
@Autowired @Autowired
private TableInfoDao tableInfoDao; private TableInfoDao tableInfoDao;
@Override @Override
public Integer savePage(@RequestBody InFormPageVo inFormPageVo) { public Integer savePage(@RequestBody FormPageVo inFormPageVo) {
inFormPageVo.setCreateTime(new Date()); inFormPageVo.setCreateTime(new Date());
FormPage formPage = inFormPageVo.toEntity(); FormPage formPage = inFormPageVo.toEntity();
FormPage formPage1 = formPageMapper.save(formPage); FormPage formPage1 = formPageMapper.save(formPage);
...@@ -50,18 +51,17 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -50,18 +51,17 @@ public class FormPageServiceImpl implements FormPageService {
} }
@Override @Override
public FormPage getPage(Integer id) { public FormPageVo getPage(Integer id) {
FormPage formPage = formPageMapper.findById(id).get(); FormPage formPage = formPageMapper.findById(id).get();
//时间排序
return formPage; return formPage.toEntityVo();
} }
@Override @Override
public void deletePage(Integer id) { public void deletePage(Integer id) {
FormPage formPage = formPageMapper.findById(id).get(); FormPage formPage = formPageMapper.findById(id).get();
formPage.setDeleted(1); formPageMapper.delete(formPage);
formPageMapper.save(formPage);
} }
@Override @Override
...@@ -77,18 +77,23 @@ public class FormPageServiceImpl implements FormPageService { ...@@ -77,18 +77,23 @@ public class FormPageServiceImpl implements FormPageService {
return formPagePage; return formPagePage;
} }
@Override @Override
public List<TableInfo> findByPageIds(List<Integer> pageIds) { public List<TableInfo> findByPageIds(List<Integer> pageIds) {
ArrayList<TableInfo> list = new ArrayList<>(); ArrayList<TableInfo> list = new ArrayList<>();
for (Integer pageId : pageIds) {
//通过pageId 查询出表id PredicateBuilder<FormPage> builder = Specifications.and();
String entityId = formPageMapper.findById(pageId).get().getEntityId(); builder.in("id", pageIds);
//根据entityId查询出表 List<FormPage> tableInfoList = formPageMapper.findAll(builder.build());
PredicateBuilder<TableInfo> builder = Specifications.and(); StringBuffer entityIds = new StringBuffer();
builder.eq("id",entityId); for (FormPage formPage : tableInfoList) {
List<TableInfo> tableInfoList = tableInfoDao.findAll(builder.build()); String entityId = formPage.getEntityId();
list.addAll(tableInfoList); entityIds.append(entityId);
entityIds.append(",");
} }
String[] split = entityIds.toString().split(",");
List<String> lastEntityIds = Arrays.asList(split).stream().distinct().collect(Collectors.toList());
//todo
return list; return list;
} }
......
package com.tykj.workflowcore.workflow_editer.service.impl; package com.tykj.workflowcore.workflow_editer.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.tykj.workflowcore.api.entity.InvokeRequest;
import com.tykj.workflowcore.api.entity.Parameter;
import com.tykj.workflowcore.api.service.SpringBeanService; import com.tykj.workflowcore.api.service.SpringBeanService;
import com.tykj.workflowcore.base.result.ApiException; import com.tykj.workflowcore.base.result.ApiException;
import com.tykj.workflowcore.base.util.FileUtil; import com.tykj.workflowcore.base.util.FileUtil;
import com.tykj.workflowcore.workflow_editer.validate.ProcessValidatorFactoryExt;
import com.tykj.workflowcore.workflow_editer.entity.*; import com.tykj.workflowcore.workflow_editer.entity.*;
import com.tykj.workflowcore.workflow_editer.dao.FlowsInfoMapper; import com.tykj.workflowcore.workflow_editer.dao.FlowsInfoMapper;
import com.tykj.workflowcore.workflow_editer.entity.vo.*; import com.tykj.workflowcore.workflow_editer.entity.vo.*;
...@@ -20,32 +18,31 @@ import org.dom4j.Document; ...@@ -20,32 +18,31 @@ import org.dom4j.Document;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.flowable.bpmn.converter.BpmnXMLConverter;
import org.flowable.bpmn.model.*; import org.flowable.bpmn.model.*;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.engine.*; import org.flowable.engine.*;
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl; import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.Deployment;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance; import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery; import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.hibernate.engine.transaction.internal.TransactionImpl; import org.flowable.validation.ProcessValidator;
import org.flowable.validation.ValidationError;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.regex.Pattern;
/** /**
* ClassName: FlowableServiceImpl * ClassName: FlowableServiceImpl
...@@ -69,6 +66,8 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -69,6 +66,8 @@ public class WorkFlowServiceImpl implements WorkFlowService {
private final ProcessEngine processEngine; private final ProcessEngine processEngine;
private final VariableStorageService variableStorageService; private final VariableStorageService variableStorageService;
@Autowired
ProcessValidatorFactoryExt processValidatorFactoryExt;
final final
ClassLoader classLoader; ClassLoader classLoader;
...@@ -156,14 +155,15 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -156,14 +155,15 @@ public class WorkFlowServiceImpl implements WorkFlowService {
} }
@Override @Override
public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) { public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, FileNotFoundException {
String basePath = System.getProperty("user.dir") + "\\xml\\"; String basePath = System.getProperty("user.dir") + "\\xml\\";
Integer id = flowsInfoVo.getId(); Integer id = flowsInfoVo.getId();
String flowKey = flowsInfoVo.getFlowKey(); String flowKey = flowsInfoVo.getFlowKey();
String fileXml = flowsInfoVo.getFileXml(); String fileXml = flowsInfoVo.getFileXml();
//生成xml文件 //生成xml文件
FileUtil.createFileByString(basePath + flowKey + "bpmn20.xml", flowsInfoVo.getFileXml().replaceAll("\\[\\?\\?[^\\]]+\\?\\?\\]", "")); File file = FileUtil.createFileByString(basePath + flowKey + "bpmn20.xml",
flowsInfoVo.getFileXml().replaceAll("\\[\\?\\?[^\\]]+\\?\\?\\]", ""));
FileUtil.createFileByString(basePath + flowKey + "bpmnCustom20.xml", flowsInfoVo.getFileXml()); FileUtil.createFileByString(basePath + flowKey + "bpmnCustom20.xml", flowsInfoVo.getFileXml());
FlowsInfo flowsInfo = new FlowsInfo(); FlowsInfo flowsInfo = new FlowsInfo();
...@@ -174,8 +174,32 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -174,8 +174,32 @@ public class WorkFlowServiceImpl implements WorkFlowService {
flowsInfo.setId(id); flowsInfo.setId(id);
//更新并保存 //更新并保存
FlowsInfo save = flowsInfoMapper.save(flowsInfo); FlowsInfo save = flowsInfoMapper.save(flowsInfo);
//自动部署 //进行第一部的校验
deployXml(save); InputStream inputStream = new FileInputStream(file);//实例化FileInputStream
BpmnXMLConverter converter = new BpmnXMLConverter();
XMLInputFactory factory = XMLInputFactory.newInstance();
XMLStreamReader reader = factory.createXMLStreamReader(inputStream);//createXmlStreamReader
//将xml文件转换成BpmnModel
BpmnModel bpmnModel = converter.convertToBpmnModel(reader);
//做校验
ProcessValidator defaultProcessValidator = processValidatorFactoryExt.createDefaultProcessValidator();
List<ValidationError> validate = defaultProcessValidator.validate(bpmnModel);
StringBuffer message = new StringBuffer();
if (validate.size()!=0){
for (int i =0;i<validate.size();i++){
ValidationError validationError = validate.get(i);
String problem = validationError.getProblem();
message.append(i+1+problem);
message.append("\r\n");
}
throw new ApiException(null,message.toString());
}else {
//自动部署
deployXml(save);
}
} }
...@@ -346,7 +370,7 @@ public class WorkFlowServiceImpl implements WorkFlowService { ...@@ -346,7 +370,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
flowsInfoMapper.deleteById(id); flowsInfoMapper.deleteById(id);
} }
} else { } else {
throw new ApiException("流程不存在"); throw new ApiException(null,"流程不存在");
} }
} }
......
package com.tykj.workflowcore.workflow_editer.util;
import java.util.List;
/**
* ClassName: PageUtil
* Package: com.tykj.util
* Description:
* Datetime: 2021/3/2 20:39
*
* @Author: zsp
*/
public class PageUtil {
/**
* 开始分页
* @param list
* @param pageNum 页码
* @param pageSize 每页多少条数据
* @return
*/
public static List startPage(List list, Integer pageNum,
Integer pageSize) {
if (list == null) {
return null;
}
if (list.size() == 0) {
return null;
}
Integer count = list.size(); // 记录总数
Integer pageCount = 0; // 页数
if (count % pageSize == 0) {
pageCount = count / pageSize;
} else {
pageCount = count / pageSize + 1;
}
int fromIndex = 0; // 开始索引
int toIndex = 0; // 结束索引
if (pageNum > pageCount){
return null;
}
if (pageNum != pageCount) {
System.out.println("pageNum====>"+pageNum);
fromIndex = (pageNum - 1) * pageSize;
System.out.println("fromindex===>"+fromIndex);
toIndex = fromIndex + pageSize;
} else {
System.out.println("from====>"+fromIndex);
fromIndex = (pageNum - 1) * pageSize;
toIndex = count;
}
List pageList = list.subList(fromIndex, toIndex);
return pageList;
}
}
...@@ -251,4 +251,22 @@ class WorkflowCoreApplicationTests_workflow { ...@@ -251,4 +251,22 @@ class WorkflowCoreApplicationTests_workflow {
.andDo(print());//打印输出结果 .andDo(print());//打印输出结果
} }
@Test
void complteTask() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId","1");
jsonObject.put("handlingOpinion",0);
request = get("/workFlow/completeTask/")
.contentType(MediaType.APPLICATION_JSON)
.content(jsonObject.toJSONString())
// .param("taskId","2563cd2d-8c72-11eb-9463-005056c00001")//参数
// 设置返回值类型为utf-8,否则默认为ISO-8859-1
.accept(MediaType.APPLICATION_JSON_UTF8_VALUE);
mockMvc.perform(request).andExpect(status().isOk())
.andExpect(content().string(not(""))) //条件
// .andExpect(content().string(not("[]")))
.andDo(print());//打印输出结果
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论