代码小优化
parent
26c326162d
commit
dc1ab4cfe8
|
@ -8,10 +8,19 @@ import java.util.Date;
|
||||||
public class ActModel {
|
public class ActModel {
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 模型(流程)名称
|
||||||
|
*/
|
||||||
private String modelName;
|
private String modelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 版本号
|
||||||
|
*/
|
||||||
private int rev;
|
private int rev;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程定义key
|
||||||
|
*/
|
||||||
private String procDefKey;
|
private String procDefKey;
|
||||||
|
|
||||||
private Date createdTime;
|
private Date createdTime;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ActModelService {
|
||||||
String select = "a.ID_ as id,a.REV_ as rev,a.NAME_ as modelName,a.KEY_ as procDefKey,a.CREATE_TIME_ as createdTime,a.LAST_UPDATE_TIME_ as lastUpdatedTime";
|
String select = "a.ID_ as id,a.REV_ as rev,a.NAME_ as modelName,a.KEY_ as procDefKey,a.CREATE_TIME_ as createdTime,a.LAST_UPDATE_TIME_ as lastUpdatedTime";
|
||||||
QueryHelper queryHelper = new QueryHelper(select, " act_re_model a");
|
QueryHelper queryHelper = new QueryHelper(select, " act_re_model a");
|
||||||
String name = searchInfo.get("name");
|
String name = searchInfo.get("name");
|
||||||
queryHelper.addCondition(StringUtils.isNotEmpty(name), "a.NAME_=? or a.KEY_=?", name, name);
|
queryHelper.addCondition(StringUtils.isNotEmpty(name), "(a.NAME_=? or a.KEY_=?)", name, name);
|
||||||
queryHelper.addOrderProperty("a.LAST_UPDATE_TIME_", false);
|
queryHelper.addOrderProperty("a.LAST_UPDATE_TIME_", false);
|
||||||
return pagination.paginate(queryHelper.getSql(), ActModel.class, pageNumber, pageSize);
|
return pagination.paginate(queryHelper.getSql(), ActModel.class, pageNumber, pageSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package cn.palmte.work.service;
|
||||||
|
|
||||||
import cn.palmte.work.model.ActTaskDefRepository;
|
import cn.palmte.work.model.ActTaskDefRepository;
|
||||||
import cn.palmte.work.pojo.ActProcDef;
|
import cn.palmte.work.pojo.ActProcDef;
|
||||||
import org.activiti.bpmn.model.*;
|
import org.activiti.bpmn.model.BpmnModel;
|
||||||
import org.activiti.engine.ProcessEngine;
|
import org.activiti.engine.ProcessEngine;
|
||||||
import org.activiti.engine.RepositoryService;
|
import org.activiti.engine.RepositoryService;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
|
@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import top.jfunc.common.db.QueryHelper;
|
import top.jfunc.common.db.QueryHelper;
|
||||||
import top.jfunc.common.db.bean.Page;
|
import top.jfunc.common.db.bean.Page;
|
||||||
import top.jfunc.common.db.utils.Pagination;
|
import top.jfunc.common.db.utils.Pagination;
|
||||||
|
import top.jfunc.common.utils.IoUtil;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -47,7 +48,7 @@ public class ActProcDefService {
|
||||||
" p.DGRM_RESOURCE_NAME_ as dgrmResourceName,p.SUSPENSION_STATE_ as suspensionState, d.DEPLOY_TIME_ as deployTime ";
|
" p.DGRM_RESOURCE_NAME_ as dgrmResourceName,p.SUSPENSION_STATE_ as suspensionState, d.DEPLOY_TIME_ as deployTime ";
|
||||||
QueryHelper queryHelper = new QueryHelper(select, " act_re_procdef p LEFT JOIN act_re_deployment d on p.DEPLOYMENT_ID_ = d.ID_");
|
QueryHelper queryHelper = new QueryHelper(select, " act_re_procdef p LEFT JOIN act_re_deployment d on p.DEPLOYMENT_ID_ = d.ID_");
|
||||||
String name = searchInfo.get("name");
|
String name = searchInfo.get("name");
|
||||||
queryHelper.addCondition(StringUtils.isNotEmpty(name), "p.NAME_=? or p.KEY_=?", name, name);
|
queryHelper.addCondition(StringUtils.isNotEmpty(name), "(p.NAME_=? or p.KEY_=?)", name, name);
|
||||||
queryHelper.addOrderProperty("p.KEY_,p.VERSION_", false);
|
queryHelper.addOrderProperty("p.KEY_,p.VERSION_", false);
|
||||||
return pagination.paginate(queryHelper.getSql(), ActProcDef.class, pageNumber, pageSize);
|
return pagination.paginate(queryHelper.getSql(), ActProcDef.class, pageNumber, pageSize);
|
||||||
}
|
}
|
||||||
|
@ -91,26 +92,10 @@ public class ActProcDefService {
|
||||||
*/
|
*/
|
||||||
public void createProcDefPng(HttpServletResponse response, String deploymentId) throws IOException {
|
public void createProcDefPng(HttpServletResponse response, String deploymentId) throws IOException {
|
||||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
|
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
|
||||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); // 获取bpmnModel
|
// 获取bpmnModel
|
||||||
InputStream inputStream = generateDiagramInputStream(bpmnModel, new ArrayList<>(), new ArrayList<>());
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||||
responsePng(response, inputStream);
|
try (InputStream inputStream = generateDiagramInputStream(bpmnModel, new ArrayList<>(), new ArrayList<>())){
|
||||||
}
|
IoUtil.copy(inputStream, response.getOutputStream());
|
||||||
|
|
||||||
public void responsePng(HttpServletResponse response, InputStream inputStream) throws IOException {
|
|
||||||
InputStream pic = null;
|
|
||||||
try {
|
|
||||||
pic = inputStream;
|
|
||||||
byte[] b = new byte[1024];
|
|
||||||
int len = -1;
|
|
||||||
while ((len = pic.read(b, 0, 1024)) != -1) {
|
|
||||||
response.getOutputStream().write(b, 0, len);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("an exception happens in try catch statement", e);
|
|
||||||
} finally {
|
|
||||||
if (pic != null) {
|
|
||||||
pic.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import top.jfunc.common.db.QueryHelper;
|
||||||
import top.jfunc.common.db.bean.Page;
|
import top.jfunc.common.db.bean.Page;
|
||||||
import top.jfunc.common.db.bean.Record;
|
import top.jfunc.common.db.bean.Record;
|
||||||
import top.jfunc.common.db.utils.Pagination;
|
import top.jfunc.common.db.utils.Pagination;
|
||||||
|
import top.jfunc.common.utils.IoUtil;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -183,8 +184,9 @@ public class ActProcInsService {
|
||||||
}
|
}
|
||||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(historicProcessInstance.getProcessDefinitionId()); // 获取bpmnModel
|
BpmnModel bpmnModel = repositoryService.getBpmnModel(historicProcessInstance.getProcessDefinitionId()); // 获取bpmnModel
|
||||||
List<String> flowIds = this.getExecutedFlows(bpmnModel, newHisTaskInstanceList); // 获取流程已发生流转的线ID集合
|
List<String> flowIds = this.getExecutedFlows(bpmnModel, newHisTaskInstanceList); // 获取流程已发生流转的线ID集合
|
||||||
InputStream inputStream = actProcDefService.generateDiagramInputStream(bpmnModel, executedActivityIdList, flowIds);
|
try (InputStream inputStream = actProcDefService.generateDiagramInputStream(bpmnModel, executedActivityIdList, flowIds)){
|
||||||
actProcDefService.responsePng(response, inputStream);
|
IoUtil.copy(inputStream, response.getOutputStream());
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("an exception happens in try catch statement", e);
|
logger.error("an exception happens in try catch statement", e);
|
||||||
|
|
|
@ -2,7 +2,7 @@ spring.application.name=fourcal
|
||||||
server.port=8282
|
server.port=8282
|
||||||
server.context-path=/fourcal
|
server.context-path=/fourcal
|
||||||
app.version=0.0.1
|
app.version=0.0.1
|
||||||
spring.profiles.active=local
|
spring.profiles.active=dev
|
||||||
|
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|
Loading…
Reference in New Issue