|
@@ -10,15 +10,14 @@ import com.qmth.distributed.print.business.bean.flow.link.FlowTaskLink;
|
|
import com.qmth.distributed.print.business.bean.flow.link.FlowTaskNode;
|
|
import com.qmth.distributed.print.business.bean.flow.link.FlowTaskNode;
|
|
import com.qmth.distributed.print.business.bean.result.*;
|
|
import com.qmth.distributed.print.business.bean.result.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
|
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowRejectResubmitTypeEnum;
|
|
|
|
-import com.qmth.distributed.print.business.enums.CustomFlowTypeEnum;
|
|
|
|
-import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.enums.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
import com.qmth.teachcloud.common.enums.*;
|
|
|
|
+import com.qmth.teachcloud.common.service.CommonCacheService;
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
import com.qmth.teachcloud.common.util.RedisUtil;
|
|
@@ -98,6 +97,9 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
@Resource
|
|
@Resource
|
|
TFCustomFlowEntityService tfCustomFlowEntityService;
|
|
TFCustomFlowEntityService tfCustomFlowEntityService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CommonCacheService commonCacheService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 启动流程
|
|
* 启动流程
|
|
*
|
|
*
|
|
@@ -202,8 +204,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
//流程审批
|
|
//流程审批
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), examTask.getSchoolId());
|
|
|
|
- TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
|
+ TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
if (Objects.isNull(tfFlowApprove)) {
|
|
if (Objects.isNull(tfFlowApprove)) {
|
|
tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId());
|
|
tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId());
|
|
} else {
|
|
} else {
|
|
@@ -252,7 +254,21 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
|
|
FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
|
|
|
|
|
|
String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? String.valueOf((Long) map.get(SystemConstant.APPROVE_ID)) : null;
|
|
String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? String.valueOf((Long) map.get(SystemConstant.APPROVE_ID)) : null;
|
|
- tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId()));
|
|
|
|
|
|
+
|
|
|
|
+ TFFlowApprove tfFlowApprove = null;
|
|
|
|
+ FlowJoinTypeEnum flowJoinTypeEnum = (FlowJoinTypeEnum) map.get(SystemConstant.FLOW_JOIN_TYPE);
|
|
|
|
+ if (Objects.nonNull(flowJoinTypeEnum) && flowJoinTypeEnum == FlowJoinTypeEnum.RESTART) {//重新提交
|
|
|
|
+ Long oldFlowId = (Long) map.get(SystemConstant.OLD_FLOW_ID);
|
|
|
|
+ tfFlowApprove = tfFlowApproveService.findByFlowId(oldFlowId);
|
|
|
|
+ tfFlowApprove.insertInfo(sysUser.getId());
|
|
|
|
+ tfFlowApprove.updateInfo(sysUser.getId());
|
|
|
|
+ tfFlowApprove.setFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
|
+ tfFlowApprove.setStatus(flowStatusEnum);
|
|
|
|
+ tfFlowApprove.setSetup(FlowApproveSetupEnum.SUBMIT.getSetup());
|
|
|
|
+ } else {
|
|
|
|
+ tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId());
|
|
|
|
+ }
|
|
|
|
+ tfFlowApproveService.save(tfFlowApprove);
|
|
|
|
|
|
Long objectId = (Long) map.get(SystemConstant.OBJECT_ID);
|
|
Long objectId = (Long) map.get(SystemConstant.OBJECT_ID);
|
|
tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), objectId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT, flowType.getTable()));
|
|
tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), objectId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT, flowType.getTable()));
|
|
@@ -286,7 +302,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
|
|
|
|
|
|
//流程审批
|
|
//流程审批
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, examTask.getSchoolId());
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
|
|
tfFlowApprove = Objects.isNull(tfFlowApprove) ? new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, sysUser.getId(), FlowStatusEnum.FINISH, sysUser.getId()) : tfFlowApprove;
|
|
tfFlowApprove = Objects.isNull(tfFlowApprove) ? new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, sysUser.getId(), FlowStatusEnum.FINISH, sysUser.getId()) : tfFlowApprove;
|
|
|
|
|
|
TFFlowLog tfFlowLog = null;
|
|
TFFlowLog tfFlowLog = null;
|
|
@@ -294,7 +310,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
|
|
TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
|
|
|
|
- TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(flowId);
|
|
|
|
|
|
+ TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(flowId);
|
|
|
|
|
|
String remark = null;
|
|
String remark = null;
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
|
|
@@ -730,13 +746,14 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
@Transactional
|
|
@Transactional
|
|
public boolean taskApproverExchange(String userId, String taskId) {
|
|
public boolean taskApproverExchange(String userId, String taskId) {
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
|
|
if (Objects.equals(String.valueOf(sysUser.getId()), userId)) {
|
|
if (Objects.equals(String.valueOf(sysUser.getId()), userId)) {
|
|
throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
throw ExceptionResultEnum.ERROR.exception("不能转给自己");
|
|
}
|
|
}
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
|
|
Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程任务为空或该流程已被他人审核,请刷新再试!"));
|
|
String flowId = task.getProcessInstanceId();
|
|
String flowId = task.getProcessInstanceId();
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), sysUser.getSchoolId());
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到流程状态记录"));
|
|
if (tfFlowApprove.getSetup() <= 0) {
|
|
if (tfFlowApprove.getSetup() <= 0) {
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
|
|
throw ExceptionResultEnum.ERROR.exception("流程已结束或已终止");
|
|
@@ -783,11 +800,14 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
|
|
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
SysUser exchangeUser = sysUserService.getById(userId);
|
|
SysUser exchangeUser = sysUserService.getById(userId);
|
|
|
|
+ SysOrg exchangeSysOrg = commonCacheService.orgCache(exchangeUser.getOrgId());
|
|
|
|
|
|
- TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
|
|
|
|
|
|
+ TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowId(SystemConstant.convertIdToLong(flowId));
|
|
|
|
|
|
|
|
+ String remark = Objects.nonNull(sysOrg) ? sysOrg.getName() : "无机构";
|
|
|
|
+ String exchangeRemark = Objects.nonNull(exchangeSysOrg) ? exchangeSysOrg.getName() : "无机构";
|
|
//流程流水日志
|
|
//流程流水日志
|
|
- TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
|
|
|
|
|
|
+ TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "(" + remark + ")转" + exchangeUser.getRealName() + "(" + exchangeRemark + ")审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
|
|
if (customFlowVarDto.getApproveIds().size() == 1) {
|
|
if (customFlowVarDto.getApproveIds().size() == 1) {
|
|
customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
|
|
customFlowVarDto.setApproveIds(new ArrayList<>(Arrays.asList(userId)));
|
|
@@ -1244,8 +1264,19 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), null, TFCustomTypeEnum.ELECTRON_FLOW);
|
|
TFCustomFlow tfCustomFlow = tfCustomFlowService.findMaxVersion(sysUser.getSchoolId(), null, TFCustomTypeEnum.ELECTRON_FLOW);
|
|
Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
|
|
Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到自定义流程数据"));
|
|
|
|
|
|
- TFCustomFlowEntity tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), sysUser.getId());
|
|
|
|
- Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
|
|
|
+ TFCustomFlowEntity tfCustomFlowEntity = null;
|
|
|
|
+ Map<String, Object> flowProcessVarMap = null;
|
|
|
|
+ FlowJoinTypeEnum flowJoinTypeEnum = (FlowJoinTypeEnum) map.get(SystemConstant.FLOW_JOIN_TYPE);
|
|
|
|
+ if (Objects.nonNull(flowJoinTypeEnum) && flowJoinTypeEnum == FlowJoinTypeEnum.RESTART) {//重新提交
|
|
|
|
+ Long oldFlowId = (Long) map.get(SystemConstant.OLD_FLOW_ID);
|
|
|
|
+ tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(oldFlowId);
|
|
|
|
+ tfCustomFlowEntity.insertInfo(sysUser.getId());
|
|
|
|
+ tfCustomFlowEntity.updateInfo(sysUser.getId());
|
|
|
|
+ flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
|
|
+ } else {//否则新增
|
|
|
|
+ tfCustomFlowEntity = new TFCustomFlowEntity(tfCustomFlow.getId(), sysUser.getId());
|
|
|
|
+ flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlow);
|
|
|
|
+ }
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
List<String> approveUserIds = new ArrayList(Arrays.asList(String.valueOf(approveId)));
|
|
List<String> approveUserIds = new ArrayList(Arrays.asList(String.valueOf(approveId)));
|
|
ApproveUserResult approveUserResult = sysUserService.findByIds(approveUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
|
|
ApproveUserResult approveUserResult = sysUserService.findByIds(approveUserIds.stream().map(x -> SystemConstant.convertIdToLong(x)).collect(Collectors.toList()));
|
|
@@ -1253,8 +1284,8 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
|
|
flowProcessVarMap.put(SystemConstant.AGGINESS_MAP, agginessMap);
|
|
|
|
|
|
map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());
|
|
map.computeIfAbsent(SystemConstant.ID, v -> tfCustomFlow.getFlowKey());
|
|
- map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
|
|
|
|
- map.computeIfAbsent(SystemConstant.FLOW_ENTITY_ID, v -> String.valueOf(tfCustomFlowEntity.getId()));
|
|
|
|
|
|
+ map.put(SystemConstant.FLOW_PROCESS_VAR_MAP, flowProcessVarMap);
|
|
|
|
+ map.put(SystemConstant.FLOW_ENTITY_ID, String.valueOf(tfCustomFlowEntity.getId()));
|
|
map.computeIfAbsent(SystemConstant.CUSTOM_FLOW_ID, v -> tfCustomFlow.getId());
|
|
map.computeIfAbsent(SystemConstant.CUSTOM_FLOW_ID, v -> tfCustomFlow.getId());
|
|
map.computeIfAbsent(SystemConstant.VERSION, v -> tfCustomFlow.getVersion());
|
|
map.computeIfAbsent(SystemConstant.VERSION, v -> tfCustomFlow.getVersion());
|
|
this.flowStart(map);
|
|
this.flowStart(map);
|
|
@@ -1295,7 +1326,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
FlowTaskResult currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
FlowTaskResult currFlowTaskResult = gson.fromJson(gson.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
|
|
|
|
|
|
//获取当前流程节点
|
|
//获取当前流程节点
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, sysUser.getSchoolId());
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
|
|
|
|
|
|
//获取流程待审批人
|
|
//获取流程待审批人
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
|
|
@@ -1338,7 +1369,7 @@ public class ActivitiServiceImpl implements ActivitiService {
|
|
Optional.ofNullable(tfFlowJoinList).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程数据为空"));
|
|
Optional.ofNullable(tfFlowJoinList).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程数据为空"));
|
|
|
|
|
|
//获取当前流程节点
|
|
//获取当前流程节点
|
|
- TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, sysUser.getSchoolId());
|
|
|
|
|
|
+ TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审核数据为空"));
|
|
Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程审核数据为空"));
|
|
|
|
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|
|
Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
|