标准征求意见流程-流程图、流程历史改造。

This commit is contained in:
wangzhijiang
2024-01-26 17:57:36 +08:00
parent 70d45f56bf
commit dab9d57c13
8 changed files with 245 additions and 20 deletions
@@ -27,6 +27,7 @@ import com.ydw.bat.wkflow.business_oa.webService.service.impl.WebServiceOAServic
import com.ydw.bat.wkflow.business_wkflow.form.dto.FormSubmitDto;
import com.ydw.bat.wkflow.business_wkflow.form.service.FormValsService;
import com.ydw.bat.wkflow.util.enums.FlowTypeEnum;
import com.ydw.bat.wkflow.util.enums.TaskStatusEnum;
import org.activiti.engine.*;
import org.activiti.engine.history.*;
import org.activiti.engine.repository.ProcessDefinition;
@@ -903,6 +904,11 @@ public class TodoTaskController extends BaseAction {
updateWrapper.in(BusProcessNew::getTaskId,taskIdList);
updateWrapper.set(BusProcessNew::getReceiveStatus,"已接收");
iBusProcessNewService.update(updateWrapper);
LambdaUpdateWrapper<BusProcessHistory> bphUpdateWrapper = new LambdaUpdateWrapper<>();
bphUpdateWrapper.in(BusProcessHistory::getTaskId,taskIdList);
bphUpdateWrapper.set(BusProcessHistory::getTaskStatus, TaskStatusEnum.RECEIVED.getValue());
this.busProcessHistoryService.update(bphUpdateWrapper);
return processNew;
}
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/datas/bus-process-history")
@@ -17,11 +18,31 @@ public class BusProcessHistoryController {
@Autowired
private IBusProcessHistoryService busProcessHistoryService;
@GetMapping("/queryByList")
public List<BusProcessHistory> queryByList(String actiProcInstId) {
/**
* 查询流程历史列表
* @param actiProcInstId
* @param flowType
* @return
*/
@GetMapping("/queryFlowHistoryList")
public List<BusProcessHistory> queryFlowHistoryList(String actiProcInstId,String flowType) {
BusProcessHistory busProcessHistory = new BusProcessHistory();
busProcessHistory.setActiProcInstId(actiProcInstId);
return this.busProcessHistoryService.queryByList(busProcessHistory);
busProcessHistory.setFlowType(flowType);
return this.busProcessHistoryService.queryFlowHistoryList(busProcessHistory);
}
/**
* 查询流程图数据
* @param actiProcInstId
* @return
*/
@GetMapping("/getImgDataList")
public List<Map<String,Object>> getImgDataList(String actiProcInstId, String flowType) {
BusProcessHistory busProcessHistory = new BusProcessHistory();
busProcessHistory.setActiProcInstId(actiProcInstId);
busProcessHistory.setFlowType(flowType);
return this.busProcessHistoryService.getImgDataList(busProcessHistory);
}
}
@@ -86,5 +86,13 @@ public class BusProcessHistory {
// 子流程数据数组
@TableField(exist = false)
private List<BusProcessHistory> childList;
private List<BusProcessHistory> children;
@TableField(exist = false)
private String userName;
@TableField(exist = false)
private String taskStatusShow;
@TableField(exist = false)
private String taskKeyShow;
}
@@ -6,9 +6,12 @@ import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessHistory;
import org.activiti.engine.delegate.DelegateTask;
import java.util.List;
import java.util.Map;
public interface IBusProcessHistoryService extends IService<BusProcessHistory> {
List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory);
List<BusProcessHistory> queryByList(BusProcessHistory busProcessHistory);
void insertBatch(List<BusProcessHistory> busProcessHistoryList);
@@ -25,4 +28,6 @@ public interface IBusProcessHistoryService extends IService<BusProcessHistory> {
// 更新排序号
void updateOrderNum(String actiProcInstId, int orderNum,int dataNum);
List<Map<String,Object>> getImgDataList(BusProcessHistory busProcessHistory);
}
@@ -2,26 +2,81 @@ package com.ydw.bat.wkflow.business_main.datas.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ydw.bat.wkflow.business_main.datas.entity.BusMes;
import com.ydw.bat.wkflow.business_main.datas.entity.BusProcessHistory;
import com.ydw.bat.wkflow.business_auth.LawsUserInfoService;
import com.ydw.bat.wkflow.business_main.datas.entity.*;
import com.ydw.bat.wkflow.business_main.datas.mapper.BusProcessHistoryMapper;
import com.ydw.bat.wkflow.business_main.datas.service.IBusProcessHistoryService;
import com.ydw.bat.wkflow.util.enums.FlowTypeEnum;
import com.ydw.bat.wkflow.util.enums.StandardCommentNewProcessNodeKeyEnum;
import com.ydw.bat.wkflow.util.enums.TaskStatusEnum;
import org.activiti.engine.delegate.DelegateTask;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistoryMapper, BusProcessHistory> implements IBusProcessHistoryService {
@Autowired
LawsUserInfoService lawsUserInfoService;
@Override
public List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory) {
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(busProcessHistory, bphQueryWrap);
bphQueryWrap.orderByAsc("order_num","create_time");
bphQueryWrap.lambda().and(
query -> query.isNull(BusProcessHistory::getTaskId).eq(BusProcessHistory::getIsMany,"1").or().isNotNull(BusProcessHistory::getTaskId)
);
// bphQueryWrap.isNotNull("task_id");
List<BusProcessHistory> bphList = this.list(bphQueryWrap);
this.disposeData(bphList);
List<BusProcessHistory> firstBphList = bphList.stream().filter(bph -> StringUtils.isEmpty(bph.getManyPId())).distinct().collect(Collectors.toList());
for (BusProcessHistory processHistory : firstBphList) {
if (StringUtils.equals(processHistory.getIsMany(),"1")) {
List<BusProcessHistory> childList = bphList.stream().filter(bph -> StringUtils.equals(processHistory.getId(), bph.getManyPId())).distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(childList)) {
String taskStatus = TaskStatusEnum.DONE.getValue();
for (BusProcessHistory history : childList) {
if (StringUtils.equals(history.getTaskStatus(),TaskStatusEnum.TODO.getValue()) || StringUtils.equals(history.getTaskStatus(),TaskStatusEnum.RECEIVED.getValue())) {
taskStatus = TaskStatusEnum.TODO.getValue();
break;
}
}
Date endTime = null;
if (StringUtils.equals(taskStatus,TaskStatusEnum.DONE.getValue())) {
Collections.sort(childList,new Comparator<BusProcessHistory>(){
@Override
public int compare(BusProcessHistory o1, BusProcessHistory o2) {
return o2.getEndTime().compareTo(o1.getEndTime());
}
});
endTime = childList.get(0).getEndTime();
}
String userNames = childList.stream().map(BusProcessHistory::getUserName).distinct().collect(Collectors.joining(","));
processHistory.setUserName(userNames);
processHistory.setCreateTime(childList.get(0).getCreateTime());
processHistory.setEndTime(endTime);
processHistory.setTaskStatus(taskStatus);
processHistory.setTaskStatusShow(TaskStatusEnum.getLabelByValue(taskStatus));
processHistory.setChildren(childList);
}
}
}
return firstBphList;
}
@Override
public List<BusProcessHistory> queryByList(BusProcessHistory busProcessHistory) {
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
@@ -67,14 +122,26 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
private List<BusProcessHistory> disposeData(List<BusProcessHistory> datas) {
List<BusProcessHistory> results = new ArrayList<>();
if (CollectionUtils.isNotEmpty(datas)) {
results = datas.stream().filter(data -> StringUtils.isEmpty(data.getPId())).distinct().collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(results)) {
List<BusProcessHistory> childList = datas.stream().filter(data -> StringUtils.isNotEmpty(data.getPId())).distinct().collect(Collectors.toList());
for (BusProcessHistory data : results) {
if (StringUtils.equals(data.getIsSub(), "1")) {
data.setChildList(childList.stream().filter(child -> StringUtils.equals(child.getPId(), data.getId())).distinct().collect(Collectors.toList()));
for (BusProcessHistory data : datas) {
ResponseMessage<UserVO> assignee = lawsUserInfoService.getByIdFeignClientWithDisabled(data.getUserId());
String userName = "";
if(assignee.getData()!=null){
if (assignee.getData().getDisableFlag() == 1) {
userName = assignee.getData().getUname() + "("+ assignee.getData().getUsid() +")" + "(已禁用)";
} else {
userName = assignee.getData().getUname() + "(" + assignee.getData().getUsid() + ")";
}
} else {
userName = data.getUserId();
}
data.setUserName(userName);
data.setTaskStatusShow(TaskStatusEnum.getLabelByValue(data.getTaskStatus()));
String taskKeyShow = "";
if (StringUtils.equals(data.getFlowType(),FlowTypeEnum.BZZQYJLC.getValue())) {
taskKeyShow = StandardCommentNewProcessNodeKeyEnum.getLableByValue(data.getTaskKey());
}
data.setTaskKeyShow(taskKeyShow);
}
}
return results;
@@ -106,7 +173,10 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
bph.setActiProcInstId(delegateTask.getProcessInstanceId());
bph.setTaskKey(delegateTask.getTaskDefinitionKey());
bph.setUserId(delegateTask.getAssignee());
List<BusProcessHistory> bphList = this.queryByList(bph);
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(bph, bphQueryWrap);
bphQueryWrap.isNull("task_id");
List<BusProcessHistory> bphList = this.list(bphQueryWrap);
if (CollectionUtils.isNotEmpty(bphList)) {
BusProcessHistory busProcessHistory = bphList.get(0);
busProcessHistory.setTaskId(delegateTask.getId());
@@ -165,4 +235,80 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
this.updateBatch(list);
}
}
@Override
public List<Map<String,Object>> getImgDataList(BusProcessHistory busProcessHistory) {
List<Map<String, Object>> result = new ArrayList<>();
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(busProcessHistory, bphQueryWrap);
bphQueryWrap.orderByAsc("order_num", "create_time");
List<BusProcessHistory> bphList = this.list(bphQueryWrap);
this.disposeData(bphList);
FlowTypeEnum flowTypeEnum = FlowTypeEnum.getFlowTypeEnumByValue(busProcessHistory.getFlowType());
switch (flowTypeEnum) {
case BZZQYJLC:
result = this.getBzzqyjlcImgDataList(bphList);
break;
default:
break;
}
return result;
}
/**
* 获取标准征求意见流程图数据
* @param bphList
* @return
*/
private List<Map<String, Object>> getBzzqyjlcImgDataList(List<BusProcessHistory> bphList) {
List<Map<String, Object>> result = new ArrayList<>();
for (StandardCommentNewProcessNodeKeyEnum nodeKeyEnum : StandardCommentNewProcessNodeKeyEnum.values()) {
Map<String, Object> tasksMap = this.getTasksMap(
bphList,
nodeKeyEnum.getValue(),
nodeKeyEnum.getLable()
);
if (ObjectUtils.isNotEmpty(tasksMap)) {
result.add(tasksMap);
}
}
return result;
}
private Map<String, Object> getTasksMap(List<BusProcessHistory> bphList,String taskKey,String taskKeyName) {
Map<String, Object> tasksMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(bphList)) {
List<BusProcessHistory> bphListByTaskKey = bphList.stream().filter(bph -> {
boolean flag = false;
if (StringUtils.equals(bph.getTaskKey(), taskKey)) {
flag = true;
}
return flag;
}).distinct().collect(Collectors.toList());
String taskStatus = "";
String userNames = "";
if (CollectionUtils.isNotEmpty(bphListByTaskKey)) {
userNames = bphListByTaskKey.stream().map(BusProcessHistory::getUserName).distinct().collect(Collectors.joining(","));
taskStatus = TaskStatusEnum.DONE.getValue();
for (BusProcessHistory busProcessHistory : bphListByTaskKey) {
if (StringUtils.isEmpty(busProcessHistory.getTaskId())
|| StringUtils.equals(busProcessHistory.getTaskStatus(), TaskStatusEnum.TODO.getValue())
|| StringUtils.equals(busProcessHistory.getTaskStatus(), TaskStatusEnum.RECEIVED.getValue())) {
taskStatus = TaskStatusEnum.TODO.getValue();
break;
}
}
}
tasksMap.put("taskKey", taskKey);
tasksMap.put("taskKeyName", taskKeyName);
tasksMap.put("userNames", userNames);
// 任务状态
tasksMap.put("taskStatus", taskStatus);
tasksMap.put("taskList", bphListByTaskKey);
}
return tasksMap;
}
}
@@ -1,5 +1,7 @@
package com.ydw.bat.wkflow.util.enums;
import org.apache.commons.lang.StringUtils;
/**
* 流程类型枚举类
*/
@@ -28,4 +30,15 @@ public enum FlowTypeEnum {
public String getRoute() {
return route;
}
public static FlowTypeEnum getFlowTypeEnumByValue(String value){
FlowTypeEnum result = null;
for (FlowTypeEnum flowTypeEnum : FlowTypeEnum.values()) {
if (StringUtils.equals(flowTypeEnum.getValue(),value)) {
result = flowTypeEnum;
break;
}
}
return result;
}
}
@@ -1,11 +1,13 @@
package com.ydw.bat.wkflow.util.enums;
import org.apache.commons.lang.StringUtils;
/**
* 标准征求意见流程-任务节点定义key
*/
public enum StandardCommentNewProcessNodeKeyEnum {
STAND_ASK_FOR_OPINION1("StandAskForOpinion1","起草",0),
SUB_PROCESS("subProcess","子流程",1),
// SUB_PROCESS("subProcess","子流程",1),
STAND_ASK_FOR_OPINION2("StandAskForOpinion2","任务分发",2),
STAND_ASK_FOR_OPINION3("StandAskForOpinion3","意见反馈",3),
STAND_ASK_FOR_OPINION4("StandAskForOpinion4","意见汇总审批",4),
@@ -36,4 +38,15 @@ public enum StandardCommentNewProcessNodeKeyEnum {
public Integer getOrderNum() {
return orderNum;
}
public static String getLableByValue(String value){
String result = "";
for (StandardCommentNewProcessNodeKeyEnum nodeKeyEnum : StandardCommentNewProcessNodeKeyEnum.values()) {
if (StringUtils.equals(nodeKeyEnum.getValue(),value)) {
result = nodeKeyEnum.getLable();
break;
}
}
return result;
}
}
@@ -1,12 +1,15 @@
package com.ydw.bat.wkflow.util.enums;
import org.apache.commons.lang.StringUtils;
/**
* 任务状态枚举类
*/
public enum TaskStatusEnum {
TODO("待办","todo"),
DONE("","done"),
TODO("未完成","todo"), // 待办
RECEIVED("接收","received"), // 已接收
DONE("已完成","done"), // 已办
;
TaskStatusEnum(String label, String value) {
@@ -33,4 +36,14 @@ public enum TaskStatusEnum {
this.value = value;
}
public static String getLabelByValue(String value) {
String result = "";
for (TaskStatusEnum taskStatusEnum : TaskStatusEnum.values()) {
if (StringUtils.equals(taskStatusEnum.getValue(), value)) {
result = taskStatusEnum.getLabel();
break;
}
}
return result;
}
}