Merge remote-tracking branch 'origin/DEV_20240422_LCLS' into test_20240409_for39

This commit is contained in:
wxyclub
2024-04-29 10:05:44 +08:00
11 changed files with 171 additions and 35 deletions
@@ -25,11 +25,11 @@ public class BusProcessHistoryController {
* @return
*/
@GetMapping("/queryFlowHistoryList")
public List<BusProcessHistory> queryFlowHistoryList(String actiProcInstId,String flowType) {
public List<BusProcessHistory> queryFlowHistoryList(String actiProcInstId,String flowType,String userId) {
BusProcessHistory busProcessHistory = new BusProcessHistory();
busProcessHistory.setActiProcInstId(actiProcInstId);
busProcessHistory.setFlowType(flowType);
return this.busProcessHistoryService.queryFlowHistoryList(busProcessHistory);
return this.busProcessHistoryService.queryFlowHistoryList(busProcessHistory,userId);
}
/**
@@ -10,7 +10,7 @@ import java.util.Map;
public interface IBusProcessHistoryService extends IService<BusProcessHistory> {
List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory);
List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory,String userId);
List<BusProcessHistory> queryByList(BusProcessHistory busProcessHistory);
@@ -39,13 +39,37 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
private IBusProcessEntrustService iBusProcessEntrustService;
@Override
public List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory) {
public List<BusProcessHistory> queryFlowHistoryList(BusProcessHistory busProcessHistory,String userId) {
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(busProcessHistory, bphQueryWrap);
bphQueryWrap.orderByAsc("order_num","create_time");
bphQueryWrap.lambda().and(
query -> query.isNull(BusProcessHistory::getTaskId).isNull(BusProcessHistory::getUserId).eq(BusProcessHistory::getIsMany,"1").or().isNotNull(BusProcessHistory::getTaskId)
);
// 验证当前操作用户,是否只是该流程中子流程中参与的人员(用户参与了外面的节点,也参与了子流程节点,这种情况不属于子流程用户)
// 如果是,查询出非子流程节点所有数据,和他自己参与过的子流程数据,如果不是,查询所有的数据。
boolean isChildProcess = this.checkUserIsChildProcess(busProcessHistory,userId);
if (isChildProcess) {
// 查询出,当前登录用户,所在的子流程数据id
QueryWrapper<BusProcessHistory> childBphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(busProcessHistory, childBphQueryWrap);
childBphQueryWrap.lambda().eq(BusProcessHistory::getUserId,userId);
List<BusProcessHistory> childBpnList = this.list(childBphQueryWrap);
List<String> manyPidList = childBpnList.stream().map(BusProcessHistory::getManyPId)
.distinct().filter(manyPid -> StringUtils.isNotEmpty(manyPid)).collect(Collectors.toList());
bphQueryWrap.lambda().and(
query -> query.isNull(BusProcessHistory::getTaskId).isNull(BusProcessHistory::getUserId)
.eq(BusProcessHistory::getIsMany,"1")
.notLike(BusProcessHistory::getTaskKey,StandardCommentNewProcessNodeKeyEnum.SUB_PROCESS.getLable())
.or().in(BusProcessHistory::getId,manyPidList)
.or().isNotNull(BusProcessHistory::getTaskId)
);
} else {
bphQueryWrap.lambda().and(
query -> query.isNull(BusProcessHistory::getTaskId)
.isNull(BusProcessHistory::getUserId)
.eq(BusProcessHistory::getIsMany,"1")
.or().isNotNull(BusProcessHistory::getTaskId)
);
}
// bphQueryWrap.isNotNull("task_id");
List<BusProcessHistory> bphList = this.list(bphQueryWrap);
this.disposeData(bphList,busProcessHistory.getActiProcInstId());
@@ -97,6 +121,38 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
return results;
}
/**
* 验证用户是否只是参与子流程的。
* @param bph
* @param userId
* @return
*/
public boolean checkUserIsChildProcess(BusProcessHistory bph,String userId){
boolean result = false;
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
this.setQueryCondition(bph, bphQueryWrap);
bphQueryWrap.lambda().eq(BusProcessHistory::getUserId,userId);
List<BusProcessHistory> busProcessHistoryList = this.list(bphQueryWrap);
if (CollectionUtils.isNotEmpty(busProcessHistoryList)) {
for (BusProcessHistory busProcessHistory : busProcessHistoryList) {
if (StringUtils.isNotEmpty(busProcessHistory.getManyPId())) {
BusProcessHistory byId = this.getById(busProcessHistory.getManyPId());
if (StringUtils.contains(byId.getTaskKey(),StandardCommentNewProcessNodeKeyEnum.SUB_PROCESS.getLable())) {
result = true;
continue;
} else {
result = false;
break;
}
} else {
result = false;
break;
}
}
}
return result;
}
@Override
public List<BusProcessHistory> queryByList(BusProcessHistory busProcessHistory) {
QueryWrapper<BusProcessHistory> bphQueryWrap = new QueryWrapper<>();
@@ -210,7 +266,9 @@ public class IBusProcessHistoryServiceImpl extends ServiceImpl<BusProcessHistory
}
busProcessHistory.setImgShowColor(imgShowColor);
busProcessHistory.setImgShowFlag("1");
busProcessHistory.setCreateTime(new Date());
if (null == busProcessHistory.getCreateTime()) {
busProcessHistory.setCreateTime(new Date());
}
}
this.saveBatch(busProcessHistoryList);
}
@@ -102,6 +102,11 @@ public class StartSurveyAfter implements TaskListener {
int i=0;
for(String nextUser : nextUserList){
object.put("onlyKey", i);
// 定义一个子流程id,子流程id,就是子流程的发起人id + - + 流程实例id
String subProcessKey = nextUser + "-" + delegateTask.getProcessInstanceId();
String subProcessId = UUID.randomUUID().toString();
delegateTask.setVariable(subProcessKey,subProcessId);
object.put("subProcessId",subProcessId);
BusProcessNew busProcessNewNext = new BusProcessNew();
busProcessNewNext.setMsgType("clause");
busProcessNewNext.setPId(delegateTask.getProcessInstanceId());
@@ -210,8 +215,24 @@ public class StartSurveyAfter implements TaskListener {
}
if (CollectionUtils.isNotEmpty(zrUserIdList)) {
int subProcessIndex = 1;
for (String zrUserId : zrUserIdList) {
// 任务分发
// 获取在上面设置的子流程主键id
String subProcessKey = zrUserId + "-" + delegateTask.getProcessInstanceId();
String subProcessId = (String) delegateTask.getVariable(subProcessKey);
BusProcessHistory rwffBphP = new BusProcessHistory();
rwffBphP.setId(subProcessId);
rwffBphP.setActiProcInstId(delegateTask.getProcessInstanceId());
rwffBphP.setTaskKey(StandardCommentNewProcessNodeKeyEnum.SUB_PROCESS.getLable() + subProcessIndex);
rwffBphP.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
rwffBphP.setOrderNum(StandardCommentNewProcessNodeKeyEnum.SUB_PROCESS.getOrderNum());
rwffBphP.setIsSub("1");
rwffBphP.setIsMany("1");
rwffBphP.setCreateTime(new Date());
bphList.add(rwffBphP);
BusProcessHistory rwffBph = new BusProcessHistory();
rwffBph.setActiProcInstId(delegateTask.getProcessInstanceId());
rwffBph.setUserId(zrUserId);
@@ -220,8 +241,18 @@ public class StartSurveyAfter implements TaskListener {
rwffBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION2.getOrderNum());
rwffBph.setIsSub("2");
rwffBph.setIsMany("2");
rwffBph.setManyPId(subProcessId);
rwffBph.setCreateTime(new Date());
bphList.add(rwffBph);
// 停1秒钟,确保流程历史中的子流程没问题。
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
subProcessIndex ++;
// // 意见汇总审批
// BusProcessHistory yjhzspBph = new BusProcessHistory();
// yjhzspBph.setActiProcInstId(delegateTask.getProcessInstanceId());
@@ -138,35 +138,54 @@ public class Step1After implements TaskListener {
List<String> yjfkUserIdList = Arrays.asList(json.getString("responUserList").split(","));
// 意见反馈
if (CollectionUtils.isNotEmpty(yjfkUserIdList)) {
String yjfkPBphId = (String) delegateTask.getVariable("yjfkPBphId");
if (StringUtils.isEmpty(yjfkPBphId)) {
BusProcessHistory yjfkPBph = new BusProcessHistory();
yjfkPBphId = UUID.randomUUID().toString();
yjfkPBph.setId(yjfkPBphId);
yjfkPBph.setActiProcInstId(delegateTask.getProcessInstanceId());
yjfkPBph.setTaskKey(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getValue());
yjfkPBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
yjfkPBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getOrderNum());
yjfkPBph.setIsSub("2");
yjfkPBph.setIsMany("1");
bphList.add(yjfkPBph);
String subProcessId = json.getString("subProcessId");
if (StringUtils.isNotEmpty(subProcessId)) {
for (String yjfkUserId : yjfkUserIdList) {
BusProcessHistory yjfkBph = new BusProcessHistory();
yjfkBph.setActiProcInstId(delegateTask.getProcessInstanceId());
yjfkBph.setUserId(yjfkUserId);
yjfkBph.setTaskKey(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getValue());
yjfkBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
yjfkBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getOrderNum());
yjfkBph.setIsSub("2");
yjfkBph.setIsMany("1");
yjfkBph.setManyPId(subProcessId);
yjfkBph.setParentUserId(delegateTask.getAssignee());
bphList.add(yjfkBph);
}
} else {
String yjfkPBphId = (String) delegateTask.getVariable("yjfkPBphId");
if (StringUtils.isEmpty(yjfkPBphId)) {
BusProcessHistory yjfkPBph = new BusProcessHistory();
yjfkPBphId = UUID.randomUUID().toString();
yjfkPBph.setId(yjfkPBphId);
yjfkPBph.setActiProcInstId(delegateTask.getProcessInstanceId());
yjfkPBph.setTaskKey(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getValue());
yjfkPBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
yjfkPBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getOrderNum());
yjfkPBph.setIsSub("2");
yjfkPBph.setIsMany("1");
bphList.add(yjfkPBph);
}
for (String yjfkUserId : yjfkUserIdList) {
BusProcessHistory yjfkBph = new BusProcessHistory();
yjfkBph.setActiProcInstId(delegateTask.getProcessInstanceId());
yjfkBph.setUserId(yjfkUserId);
yjfkBph.setTaskKey(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getValue());
yjfkBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
yjfkBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getOrderNum());
yjfkBph.setIsSub("2");
yjfkBph.setIsMany("1");
yjfkBph.setManyPId(yjfkPBphId);
yjfkBph.setParentUserId(delegateTask.getAssignee());
bphList.add(yjfkBph);
}
delegateTask.setVariable("yjfkPBphId",yjfkPBphId);
}
for (String yjfkUserId : yjfkUserIdList) {
BusProcessHistory yjfkBph = new BusProcessHistory();
yjfkBph.setActiProcInstId(delegateTask.getProcessInstanceId());
yjfkBph.setUserId(yjfkUserId);
yjfkBph.setTaskKey(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getValue());
yjfkBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
yjfkBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION3.getOrderNum());
yjfkBph.setIsSub("2");
yjfkBph.setIsMany("1");
yjfkBph.setManyPId(yjfkPBphId);
yjfkBph.setParentUserId(delegateTask.getAssignee());
bphList.add(yjfkBph);
}
delegateTask.setVariable("yjfkPBphId",yjfkPBphId);
}
bphService.insertBatch(bphList);
@@ -19,6 +19,7 @@ import com.ydw.bat.wkflow.util.enums.TaskStatusEnum;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.apache.commons.lang.StringUtils;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -141,6 +142,7 @@ public class Step2After implements TaskListener {
if (count == 0) {
List<BusProcessHistory> bphList = new ArrayList<>();
String subProcessId = json.getString("subProcessId");
// 意见汇总审批
BusProcessHistory yjhzspBph = new BusProcessHistory();
yjhzspBph.setActiProcInstId(delegateTask.getProcessInstanceId());
@@ -150,6 +152,9 @@ public class Step2After implements TaskListener {
yjhzspBph.setOrderNum(StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION4.getOrderNum());
yjhzspBph.setIsSub("2");
yjhzspBph.setIsMany("2");
if (StringUtils.isNotEmpty(subProcessId)) {
yjhzspBph.setManyPId(subProcessId);
}
bphList.add(yjhzspBph);
bphService.insertBatch(bphList);
@@ -17,6 +17,7 @@ import com.ydw.bat.wkflow.util.enums.StandardCommentNewProcessNodeKeyEnum;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -117,6 +118,10 @@ public class Step3After implements TaskListener {
pzBph.setFlowType(FlowTypeEnum.BZZQYJLC.getValue());
pzBph.setIsSub("2");
pzBph.setIsMany("2");
String subProcessId = json.getString("subProcessId");
if (StringUtils.isNotEmpty(subProcessId)) {
pzBph.setManyPId(subProcessId);
}
int orderNum = bphService.getMaxOrderNum(delegateTask.getProcessInstanceId(),StandardCommentNewProcessNodeKeyEnum.STAND_ASK_FOR_OPINION4.getValue());
pzBph.setOrderNum(orderNum + 1);
@@ -113,6 +113,7 @@ public class Step4After implements TaskListener {
String spFlag = json.getString("spFlag");
List<BusProcessHistory> bphList = new ArrayList<>();
String subProcessId = json.getString("subProcessId");
// 如果是驳回,流程走向意见处理节点,否则流程结束
if (!StringUtils.equals(spFlag,"0")) {
String zrUserId = json.getString("SKS");
@@ -126,6 +127,9 @@ public class Step4After implements TaskListener {
yjhzspBph.setOrderNum(orderNum + 1);
yjhzspBph.setIsSub("2");
yjhzspBph.setIsMany("2");
if (StringUtils.isNotEmpty(subProcessId)) {
yjhzspBph.setManyPId(subProcessId);
}
bphList.add(yjhzspBph);
bphService.updateOrderNum(delegateTask.getProcessInstanceId(),orderNum + 1,bphList.size());
@@ -155,6 +159,9 @@ public class Step4After implements TaskListener {
glyBph.setOrderNum(orderNum + 1);
glyBph.setIsSub("2");
glyBph.setIsMany("2");
if (StringUtils.isNotEmpty(subProcessId)) {
glyBph.setManyPId(subProcessId);
}
glyBph.setParentUserId(delegateTask.getAssignee());
bphList.add(glyBph);
bphService.updateOrderNum(delegateTask.getProcessInstanceId(),orderNum + 1,bphList.size());
@@ -141,6 +141,8 @@ public class Step5After implements TaskListener {
if (!StringUtils.equals(bzFlag,"0")) {
String zrUserId = json.getString("SKS");
List<BusProcessHistory> bphList = new ArrayList<>();
String subProcessId = json.getString("subProcessId");
// 意见汇总审批
BusProcessHistory yjhzspBph = new BusProcessHistory();
yjhzspBph.setActiProcInstId(delegateTask.getProcessInstanceId());
@@ -151,6 +153,9 @@ public class Step5After implements TaskListener {
yjhzspBph.setOrderNum(orderNum + 1);
yjhzspBph.setIsSub("2");
yjhzspBph.setIsMany("2");
if (StringUtils.isNotEmpty(subProcessId)) {
yjhzspBph.setManyPId(subProcessId);
}
bphList.add(yjhzspBph);
bphService.insertBatch(bphList);
bphService.updateOrderNum(delegateTask.getProcessInstanceId(),orderNum + 1,bphList.size());
@@ -58,6 +58,9 @@ public enum BussLibraryNodeKeyEnum {
break;
}
}
if (StringUtils.isEmpty(result)) {
result = value;
}
return result;
}
@@ -11,7 +11,7 @@ import java.util.List;
*/
public enum StandardCommentNewProcessNodeKeyEnum {
STAND_ASK_FOR_OPINION1("StandAskForOpinion1","起草",0,true),
// SUB_PROCESS("subProcess","子流程",1),
SUB_PROCESS("subProcess","子流程",1,false),
STAND_ASK_FOR_OPINION2("StandAskForOpinion2","任务分发",2,true),
STAND_ASK_FOR_OPINION3("StandAskForOpinion3","意见反馈",3,true),
STAND_ASK_FOR_OPINION4("StandAskForOpinion4","意见汇总审批",4,true),
@@ -53,6 +53,9 @@ public enum StandardCommentNewProcessNodeKeyEnum {
break;
}
}
if (StringUtils.isEmpty(result)) {
result = value;
}
return result;
}