修改:项目与流程审批对接起来
This commit is contained in:
parent
6583cc5032
commit
558d99834d
@ -17,6 +17,8 @@ import net.ferrum.workflow.service.IWfCopyService;
|
||||
import net.ferrum.workflow.service.IWfProcessService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -38,6 +40,7 @@ public class WfProcessController extends BaseController {
|
||||
|
||||
private final IWfProcessService processService;
|
||||
private final IWfCopyService copyService;
|
||||
private final RuntimeService runtimeService;
|
||||
|
||||
/**
|
||||
* 查询可发起流程列表
|
||||
@ -227,7 +230,8 @@ public class WfProcessController extends BaseController {
|
||||
*/
|
||||
@SaCheckPermission("workflow:process:start")
|
||||
@PostMapping("/start/{processDefId}")
|
||||
public R<Void> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody Map<String, Object> variables) {
|
||||
public R<Void> start(@PathVariable(value = "processDefId") String processDefId, @RequestBody (required = false) Map<String, Object> variables) {
|
||||
|
||||
processService.startProcessByDefId(processDefId, variables);
|
||||
|
||||
// 获取所有流程变量
|
||||
|
||||
@ -93,4 +93,19 @@ public class ProcessConstants {
|
||||
*/
|
||||
public static final String PROCESS_BUSYNESSKEY_ConnString = "---";
|
||||
|
||||
/**
|
||||
* 项目ID,作为Busynesskey
|
||||
*/
|
||||
public static final String PROCESS_BUSYNESSKEY_PROJECT_ID = "projectId";
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
public static final String PROCESS_BUSYNESSKEY_PROJECT_NAME = "projectName";
|
||||
|
||||
/**
|
||||
* 批次
|
||||
*/
|
||||
public static final String PROCESS_BUSYNESSKEY_BATCH_NAME = "batchName";
|
||||
|
||||
}
|
||||
|
||||
@ -43,10 +43,10 @@ public class ProcessQuery {
|
||||
/**
|
||||
* 批次名称
|
||||
*/
|
||||
private String specBatch;
|
||||
private String batchName;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
* 项目名称
|
||||
*/
|
||||
private String specName;
|
||||
private String projectName;
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import org.flowable.common.engine.api.query.Query;
|
||||
import org.flowable.common.engine.impl.db.SuspensionState;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||
import org.flowable.task.api.TaskInfoQuery;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
import org.flowable.variable.api.history.HistoricVariableInstanceQuery;
|
||||
@ -80,32 +81,33 @@ public class ProcessUtils {
|
||||
query.taskCreatedBefore(DateUtils.parseDate(params.get("endTime")));
|
||||
}
|
||||
|
||||
String sKey = getBusynessKey(process);
|
||||
if(sKey != null) {
|
||||
query.processInstanceBusinessKeyLike(sKey);
|
||||
}
|
||||
|
||||
// String sKey = getBusynessKey(process);
|
||||
// if(sKey != null) {
|
||||
// query.processInstanceBusinessKeyLike(sKey);
|
||||
// }
|
||||
|
||||
BuildTaskBusynessQueryCond(query, process);
|
||||
|
||||
}
|
||||
|
||||
//已经没有用处了,但不是放在这里
|
||||
private static String getBusynessKey(ProcessQuery process){
|
||||
String sKey = null;
|
||||
|
||||
if (StringUtils.isNotBlank(process.getSpecBatch()) || StringUtils.isNotBlank(process.getSpecName())) {
|
||||
if (StringUtils.isNotBlank(process.getBatchName()) || StringUtils.isNotBlank(process.getProjectName())) {
|
||||
//批次
|
||||
if (StringUtils.isNotBlank(process.getSpecBatch())){
|
||||
sKey = "%" + process.getSpecBatch();
|
||||
if (StringUtils.isNotBlank(process.getBatchName())){
|
||||
sKey = "%" + process.getBatchName();
|
||||
//规格名称
|
||||
if (StringUtils.isNotBlank(process.getSpecName())) {
|
||||
sKey += "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getSpecName() + "%";
|
||||
if (StringUtils.isNotBlank(process.getProjectName())) {
|
||||
sKey += "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getProjectName() + "%";
|
||||
}else{
|
||||
sKey += "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%";
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (StringUtils.isNotBlank(process.getSpecName())) {
|
||||
sKey = "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getSpecName() + "%";
|
||||
if (StringUtils.isNotBlank(process.getProjectName())) {
|
||||
sKey = "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%" + process.getProjectName() + "%";
|
||||
}else{
|
||||
sKey = "%" + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + "%";
|
||||
}
|
||||
@ -115,6 +117,31 @@ public class ProcessUtils {
|
||||
return sKey;
|
||||
}
|
||||
|
||||
private static void BuildTaskBusynessQueryCond(TaskInfoQuery query, ProcessQuery process){
|
||||
//批次
|
||||
if (StringUtils.isNotBlank(process.getBatchName())){
|
||||
query.processVariableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_BATCH_NAME ,"%" +process.getBatchName()+ "%");
|
||||
}
|
||||
//项目名称
|
||||
if (StringUtils.isNotBlank(process.getProjectName())){
|
||||
query.processVariableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_PROJECT_NAME ,"%" +process.getProjectName()+ "%");
|
||||
}
|
||||
}
|
||||
|
||||
private static void BuildProcessBusynessQueryCond(HistoricProcessInstanceQuery query, ProcessQuery process){
|
||||
//批次
|
||||
if (StringUtils.isNotBlank(process.getBatchName())){
|
||||
query.variableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_BATCH_NAME ,"%" +process.getBatchName()+ "%");
|
||||
}
|
||||
//项目名称
|
||||
if (StringUtils.isNotBlank(process.getProjectName())){
|
||||
query.variableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_PROJECT_NAME ,"%" +process.getProjectName()+ "%");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void buildHistoricTaskInstanceSearch(HistoricTaskInstanceQuery query, ProcessQuery process) {
|
||||
Map<String, Object> params = process.getParams();
|
||||
if (StringUtils.isNotBlank(process.getProcessKey())) {
|
||||
@ -127,10 +154,11 @@ public class ProcessUtils {
|
||||
query.taskCompletedAfter(DateUtils.parseDate(params.get("beginTime")));
|
||||
query.taskCompletedBefore(DateUtils.parseDate(params.get("endTime")));
|
||||
}
|
||||
String sKey = getBusynessKey(process);
|
||||
if(sKey != null) {
|
||||
query.processInstanceBusinessKeyLike(sKey);
|
||||
}
|
||||
// String sKey = getBusynessKey(process);
|
||||
// if(sKey != null) {
|
||||
// query.processInstanceBusinessKeyLike(sKey);
|
||||
// }
|
||||
BuildTaskBusynessQueryCond(query, process);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,10 +178,12 @@ public class ProcessUtils {
|
||||
}
|
||||
|
||||
*/
|
||||
String sKey = getBusynessKey(process);
|
||||
if(sKey != null) {
|
||||
query.processInstanceBusinessKeyLike(sKey);
|
||||
}
|
||||
// String sKey = getBusynessKey(process);
|
||||
// if(sKey != null) {
|
||||
// query.processInstanceBusinessKeyLike(sKey);
|
||||
// }
|
||||
|
||||
BuildProcessBusynessQueryCond(query, process);
|
||||
|
||||
// 流程类别
|
||||
if (StringUtils.isNotBlank(process.getCategory())) {
|
||||
@ -167,13 +197,22 @@ public class ProcessUtils {
|
||||
|
||||
|
||||
public static void buildHistoricVariableInstanceSearch(HistoricVariableInstanceQuery query, ProcessQuery process) {
|
||||
// 规格批次
|
||||
if (StringUtils.isNotBlank(process.getSpecBatch())) {
|
||||
query.variableValueLike("lbl_Batch","%" + process.getSpecBatch() + "%");
|
||||
// // 规格批次
|
||||
// if (StringUtils.isNotBlank(process.getBatchName())) {
|
||||
// query.variableValueLike("lbl_Batch","%" + process.getBatchName() + "%");
|
||||
// }
|
||||
// // 规格名称
|
||||
// if (StringUtils.isNotBlank(process.getProjectName())) {
|
||||
// query.variableValueLike("lbl_name","%" + process.getBatchName() + "%");
|
||||
// }
|
||||
|
||||
//批次
|
||||
if (StringUtils.isNotBlank(process.getBatchName())){
|
||||
query.variableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_BATCH_NAME ,process.getBatchName());
|
||||
}
|
||||
// 规格名称
|
||||
if (StringUtils.isNotBlank(process.getSpecName())) {
|
||||
query.variableValueLike("lbl_name","%" + process.getSpecBatch() + "%");
|
||||
//项目名称
|
||||
if (StringUtils.isNotBlank(process.getProcessName())){
|
||||
query.variableValueLike(ProcessConstants.PROCESS_BUSYNESSKEY_PROJECT_NAME ,process.getProcessName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package net.ferrum.business.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import net.ferrum.business.domain.QsSpecAttributeTypes;
|
||||
import net.ferrum.common.utils.DateUtils;
|
||||
import net.ferrum.common.utils.StringUtils;
|
||||
import net.ferrum.common.core.page.TableDataInfo;
|
||||
import net.ferrum.common.core.domain.PageQuery;
|
||||
@ -10,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.ferrum.system.service.ISysConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import net.ferrum.business.domain.bo.QsBatchBo;
|
||||
import net.ferrum.business.domain.vo.QsBatchVo;
|
||||
@ -17,6 +19,7 @@ import net.ferrum.business.domain.QsBatch;
|
||||
import net.ferrum.business.mapper.QsBatchMapper;
|
||||
import net.ferrum.business.service.IQsBatchService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@ -32,6 +35,7 @@ import java.util.Collection;
|
||||
public class QsBatchServiceImpl implements IQsBatchService {
|
||||
|
||||
private final QsBatchMapper baseMapper;
|
||||
private final ISysConfigService configService;
|
||||
|
||||
/**
|
||||
* 查询批次管理
|
||||
@ -125,9 +129,19 @@ public class QsBatchServiceImpl implements IQsBatchService {
|
||||
@Override
|
||||
public List<QsBatch> selectBatchList(QsBatch entity) {
|
||||
LambdaQueryWrapper<QsBatch> lqw = new LambdaQueryWrapper<>();
|
||||
Map<String, Object> params = entity.getParams();
|
||||
lqw.eq(QsBatch::getDelFlag, "0")
|
||||
.eq(ObjectUtil.isNotNull(entity.getBatchId()), QsBatch::getBatchId, entity.getBatchId())
|
||||
.like(StringUtils.isNotBlank(entity.getBatchName()), QsBatch::getBatchName, entity.getBatchName() );
|
||||
|
||||
if(params.get("CurrentDate") != null){
|
||||
String sysConfig = configService.selectConfigByKey("work.create.queryBatchStartDateRange");
|
||||
Integer month = -1 * Integer.parseInt(sysConfig);
|
||||
Date d = DateUtils.parseDate(params.get("CurrentDate"));
|
||||
Date d1 = DateUtils.addMonths(d,month);
|
||||
lqw.between(ObjectUtil.isNotNull(entity.getBatchStartDate()), QsBatch::getBatchStartDate ,d1, d);
|
||||
}
|
||||
|
||||
return baseMapper.selectBatchList(lqw);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import net.ferrum.flowable.core.FormConf;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程详情视图对象
|
||||
@ -44,4 +45,9 @@ public class WfDetailVo {
|
||||
public Boolean isExistTaskForm() {
|
||||
return ObjectUtil.isNotEmpty(this.taskFormData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 流程中的变量
|
||||
*/
|
||||
Map<String, Object> variablesMap;
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import org.flowable.engine.task.Comment;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 工作流任务视图对象
|
||||
@ -138,4 +139,9 @@ public class WfTaskVo implements Serializable {
|
||||
* 规格名称
|
||||
*/
|
||||
private String specName;
|
||||
|
||||
/**
|
||||
* 流程中的变量
|
||||
*/
|
||||
Map<String, Object> variablesMap;
|
||||
}
|
||||
|
||||
@ -201,6 +201,8 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
Object var3Value = variablesMap.get(ProcessConstants.PROCESS_SPEC_NAME); // 规格名称
|
||||
String specName = Convert.toStr(var3Value);
|
||||
taskVo.setSpecName(specName);
|
||||
|
||||
taskVo.setVariablesMap(variablesMap);
|
||||
}
|
||||
private List<WfTaskVo> getHistProcessList(List<HistoricProcessInstance> historicProcessInstances,ProcessQuery processQuery){
|
||||
List<WfTaskVo> taskVoList = new ArrayList<>();
|
||||
@ -567,10 +569,10 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
*/
|
||||
|
||||
String getBusynessKey(Map<String, Object> variables){
|
||||
String batch = Convert.toStr(variables.get(ProcessConstants.PROCESS_BATCH));
|
||||
String name = Convert.toStr(variables.get(ProcessConstants.PROCESS_SPEC_NAME));
|
||||
String procBusynessKey = batch + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + name;
|
||||
|
||||
// String batch = Convert.toStr(variables.get(ProcessConstants.PROCESS_BATCH));
|
||||
// String name = Convert.toStr(variables.get(ProcessConstants.PROCESS_SPEC_NAME));
|
||||
// String procBusynessKey = batch + ProcessConstants.PROCESS_BUSYNESSKEY_ConnString + name;
|
||||
String procBusynessKey = Convert.toStr(variables.get(ProcessConstants.PROCESS_BUSYNESSKEY_PROJECT_ID));
|
||||
return procBusynessKey;
|
||||
}
|
||||
@Override
|
||||
@ -636,6 +638,11 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
detailVo.setHistoryProcNodeList(historyProcNodeList(historicProcIns));
|
||||
detailVo.setProcessFormList(processFormList(bpmnModel, historicProcIns));
|
||||
detailVo.setFlowViewer(getFlowViewer(bpmnModel, procInsId));
|
||||
|
||||
//获得流程中的变量
|
||||
Map<String, Object> variablesMap = getHistProcessvariablesMap(historicProcIns);
|
||||
detailVo.setVariablesMap(variablesMap);
|
||||
|
||||
return detailVo;
|
||||
}
|
||||
|
||||
@ -976,7 +983,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
.desc();
|
||||
|
||||
// 构建搜索条件
|
||||
//processQuery.setSpecBatch("4");
|
||||
//processQuery.setBatchName("4");
|
||||
|
||||
ProcessUtils.buildProcessSearch(historicVariableInstanceQuery, processQuery);
|
||||
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
|
||||
@ -1028,8 +1035,8 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
|
||||
// String spec[] = new String[2];
|
||||
// getHistSpecInfo(hisIns.getId(),spec);
|
||||
// taskVo.setSpecBatch(spec[0]);
|
||||
// taskVo.setSpecName(spec[1]);
|
||||
// taskVo.setBatchName(spec[0]);
|
||||
// taskVo.setProjectName(spec[1]);
|
||||
|
||||
|
||||
// 计算耗时
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user