工作流修改

This commit is contained in:
guoshengxiong 2025-03-26 15:43:23 +08:00
parent e790288bfc
commit 52c6b77450
4 changed files with 107 additions and 6 deletions

View File

@ -1,7 +1,10 @@
package com.wflow.controller;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wflow.bean.entity.WflowModelHistorys;
import com.wflow.bean.entity.WflowModels;
@ -143,4 +146,101 @@ public class CustomController {
}
return fields;
}
/**
* 工作流挪动并覆盖审批节点
*
* @return
*/
@PostMapping("/moveCoverApprover")
public Object moveCoverApprover(@RequestBody Map<String, Object> param) {
String fromName = MapUtil.getStr(param, "fromName");
String toName = MapUtil.getStr(param, "toName");
String process = JSON.toJSONString(param.get("process"));
checkNameUnique(fromName, process);
checkNameUnique(toName, process);
JSONObject processJo = JSON.parseObject(process);
JSONObject toObj = getToObj(null, fromName, processJo);
setToObj(null, toName, toObj, processJo);
return R.ok(JSON.toJSONString(processJo));
}
/**
* 检查名字唯一
*
* @param name
* @param process
*/
private void checkNameUnique(String name, String process) {
List<String> split = StrUtil.split(process, name);
if (split.size() == 1) {
throw new RuntimeException("不存在" + name);
}
if (split.size() != 2) {
throw new RuntimeException(name + "有很多个");
}
}
/**
* 获取替换的对象
*
* @param jo
* @param toName
* @param children
* @return
*/
private JSONObject getToObj(JSONObject jo, String toName, JSONObject children) {
if (children == null || children.getString("name") == null) {
return null;
}
if (Objects.equals(children.getString("name"), toName)) {
if (jo != null) {
jo.put("name", null);
}
return children;
}
String type = children.getString("type");
if (Objects.equals("CONDITIONS", type)) {
JSONArray array = children.getJSONArray("branchs");
for (int j = 0; j < array.size(); j++) {
JSONObject toObj = getToObj(children, toName, array.getJSONObject(j));
if (toObj != null) {
return toObj;
}
}
} else {
return getToObj(children, toName, children.getJSONObject("children"));
}
return null;
}
/**
* 设置对象
*
* @param jo
* @param fromName
* @param set
* @param children
*/
private void setToObj(JSONObject jo, String fromName, JSONObject set, JSONObject children) {
if (children == null) {
return;
}
if (Objects.equals(children.getString("name"), fromName)) {
if (jo != null) {
set.put("parentId", children.get("parentId"));
jo.put("children", set);
}
return;
}
String type = children.getString("type");
if (Objects.equals("CONDITIONS", type)) {
JSONArray array = children.getJSONArray("branchs");
for (int j = 0; j < array.size(); j++) {
setToObj(children, fromName, set, array.getJSONObject(j));
}
} else {
setToObj(children, fromName, set, children.getJSONObject("children"));
}
}
}

View File

@ -64,7 +64,7 @@ public class ProcessInstanceController {
* @param pageNo 页码
* @param code 表单流程ID流程定义KEY
* @param finished 流程是否已经结束
* @param customStatus 1待催办2已办结3审批进行中4审批被撤销5审批被驳回6审批通过
* @param customStatus 1待催办2已办结3审批进行中4审批被撤销5审批被驳回6审批通过7审批被驳回(发起人是自己)
* @return 列表数据
*/
@OperLog(operModul = "审批管理",operType = "获取系统待我处理的流程",operDesc = "获取系统待我处理的流程")

View File

@ -426,23 +426,24 @@ public class ProcessInstanceServiceImpl implements ProcessInstanceService {
@Override
public Page<ProcessInstanceVo> getUserSubmittedList(Integer pageSize, Integer pageNo, String startUser, String code,
Boolean finished, String[] startTimes, String keyword, String fieldId, String fieldVal, String key, Integer customStatus) {
Long userId = SecurityUtils.getUser().getUserId();
HistoricProcessInstanceQuery instanceQuery = historyService.createHistoricProcessInstanceQuery();
//TODO 多租户
instanceQuery.processInstanceTenantId(TenantContextHolder.getTenantId());
//(x=1 or x=2) and
if (Objects.equals(customStatus, 1)) {
instanceQuery.or().startedBy(userId + "").involvedUser(userId + "").endOr();
instanceQuery.or().startedBy(startUser + "").involvedUser(startUser + "").endOr();
} else if (Objects.equals(customStatus, 2)) {
instanceQuery.or().processInstanceBusinessStatusLike("PRE%").endOr();
}
Executor.builder()
//customStatus 1待催办2已办结3审批进行中4审批被撤销5审批被驳回6审批通过
//customStatus 1待催办2已办结3审批进行中4审批被撤销5审批被驳回6审批通过7审批被驳回(发起人是自己)
.ifTrueNext(Objects.equals(customStatus, 1), instanceQuery::unfinished)
.ifTrueNext(Objects.equals(customStatus, 3), instanceQuery::unfinished)
.ifNotBlankNext(Objects.equals(customStatus, 5) ? ProcessStatus.REFUSE.toString() : null, instanceQuery::processInstanceBusinessStatus)
.ifNotBlankNext(Objects.equals(customStatus, 6) ? ProcessStatus.PRE_PASS.toString() : null, instanceQuery::processInstanceBusinessStatus)
.ifNotBlankNext(startUser, instanceQuery::startedBy)
.ifNotBlankNext(Objects.equals(customStatus, 7) ? ProcessStatus.PRE_PASS.toString() : null, instanceQuery::processInstanceBusinessStatus)
.ifNotBlankNext(Objects.equals(customStatus, 7) ? SecurityUtils.getUser().getUserId() + "" : "", instanceQuery::startedBy)
.ifNotBlankNext(!Objects.equals(customStatus, 1) ? startUser : "", instanceQuery::startedBy)
.ifNotBlankNext(code, instanceQuery::processDefinitionKey)
.ifTrueNext(null != startTimes && startTimes.length > 1, () -> {
instanceQuery.startedAfter(DateUtil.parse(startTimes[0]));

View File

@ -642,7 +642,7 @@ public class ProcessTaskServiceImpl implements ProcessTaskService {
int firstSize = pageSize * pageNo;
Page<ProcessTaskVo> userTodoList = this.getUserTodoList(firstSize, 1, code, startTimes, startUser, key);
Page<ProcessInstanceVo> ccMeInstance = processService.getCcMeInstance(firstSize, 1, code, startTimes, startUser, null, key);
Page<ProcessInstanceVo> refuseListPage = processService.getUserSubmittedList(firstSize, 1, startUser, code, true, startTimes, null, null, null, key, 5);
Page<ProcessInstanceVo> refuseListPage = processService.getUserSubmittedList(firstSize, 1, startUser, code, true, startTimes, null, null, null, key, 7);
ccMeInstance.getRecords().forEach(o -> o.setIsCCme(true));
refuseListPage.getRecords().forEach(o -> {
o.setIsRefuse(true);