|
@@ -37,6 +37,8 @@ import java.lang.reflect.Method;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -122,11 +124,9 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
}
|
|
}
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.HAVE_PASSED);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -163,11 +163,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
endExampleDetail.setFlowExampleId(flowId);
|
|
endExampleDetail.setFlowExampleId(flowId);
|
|
endExampleDetail.setFlowDefinitionNodeId(nextUserNode.getId());
|
|
endExampleDetail.setFlowDefinitionNodeId(nextUserNode.getId());
|
|
endExampleDetail.setFlowDefinitionNodeType(nextUserNode.getNodeType());
|
|
endExampleDetail.setFlowDefinitionNodeType(nextUserNode.getNodeType());
|
|
- endExampleDetail.setHandleType(HandleTypeEnum.OVER.getKey());
|
|
+ endExampleDetail.setHandleType(HandleTypeEnum.NEXT.getKey());
|
|
flowExampleDetailList.add(endExampleDetail);
|
|
flowExampleDetailList.add(endExampleDetail);
|
|
}
|
|
}
|
|
|
|
|
|
- flowExample.setTitle(StrUtil.format(flowDefinition.getTitleTemplate(), templateMap, true));
|
|
+ flowExample.setTitle(templateParse(flowDefinition.getTitleTemplate(), templateMap));
|
|
flowExample.setFlowKey(dto.getFlowKey());
|
|
flowExample.setFlowKey(dto.getFlowKey());
|
|
flowExample.setDefinitionId(flowDefinition.getId());
|
|
flowExample.setDefinitionId(flowDefinition.getId());
|
|
flowExample.setDefinitionNodeId(nextUserNode.getId());
|
|
flowExample.setDefinitionNodeId(nextUserNode.getId());
|
|
@@ -234,6 +234,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
FlowDefinitionNode nextUserNode = null;
|
|
FlowDefinitionNode nextUserNode = null;
|
|
switch (handleTypeEnum) {
|
|
switch (handleTypeEnum) {
|
|
|
|
+
|
|
|
|
+
|
|
case NEXT:
|
|
case NEXT:
|
|
|
|
|
|
|
|
|
|
@@ -246,7 +248,6 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
if (NodeTypeEnum.END.equals(NodeTypeEnum.getEnum(nextUserNode.getNodeType()))) {
|
|
if (NodeTypeEnum.END.equals(NodeTypeEnum.getEnum(nextUserNode.getNodeType()))) {
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.HAVE_PASSED);
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
FlowResult handleUser = getHandleUser(nextUserNode, dto.getHandleUserId());
|
|
FlowResult handleUser = getHandleUser(nextUserNode, dto.getHandleUserId());
|
|
@@ -263,10 +264,15 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ case REJECT:
|
|
|
|
+ flowExample.setStatus(FlowStatusEnum.REJECTED.getKey());
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+
|
|
case PREVIOUS:
|
|
case PREVIOUS:
|
|
|
|
|
|
|
|
|
|
@@ -281,17 +287,23 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
if (NodeTypeEnum.START.getKey().equals(lastOneFlowExampleDetail.getFlowDefinitionNodeType())) {
|
|
if (NodeTypeEnum.START.getKey().equals(lastOneFlowExampleDetail.getFlowDefinitionNodeType())) {
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.UNINITIATED.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.UNINITIATED.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.UNINITIATED);
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
|
|
- case OVER:
|
|
+
|
|
- flowExample.setStatus(FlowStatusEnum.REJECTED.getKey());
|
|
+ case RETURN_TO_SPONSOR:
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.REJECTED);
|
|
+
|
|
|
|
+
|
|
|
|
+ FlowExampleDetail exampleDetail = flowExampleDetailService.getOne(q -> q
|
|
|
|
+ .eq(FlowExampleDetail::getFlowExampleId, flowId));
|
|
|
|
+
|
|
|
|
+ flowExample.setHandleUserId(exampleDetail.getCreateUser());
|
|
|
|
+ flowExample.setDefinitionNodeId(exampleDetail.getFlowDefinitionNodeId());
|
|
|
|
+ flowExample.setStatus(FlowStatusEnum.UNINITIATED.getKey());
|
|
|
|
+ FlowThreadLocalUtil.setNextHandleUserId(exampleDetail.getCreateUser());
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -332,7 +344,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
endExampleDetail.setFlowExampleId(flowId);
|
|
endExampleDetail.setFlowExampleId(flowId);
|
|
endExampleDetail.setFlowDefinitionNodeId(nextUserNode.getId());
|
|
endExampleDetail.setFlowDefinitionNodeId(nextUserNode.getId());
|
|
endExampleDetail.setFlowDefinitionNodeType(nextUserNode.getNodeType());
|
|
endExampleDetail.setFlowDefinitionNodeType(nextUserNode.getNodeType());
|
|
- endExampleDetail.setHandleType(HandleTypeEnum.OVER.getKey());
|
|
+ endExampleDetail.setHandleType(HandleTypeEnum.NEXT.getKey());
|
|
flowExampleDetailList.add(endExampleDetail);
|
|
flowExampleDetailList.add(endExampleDetail);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -474,10 +486,12 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
HandleObjectTypeEnum handleObjectTypeEnum = HandleObjectTypeEnum.getEnum(handleObjectType);
|
|
HandleObjectTypeEnum handleObjectTypeEnum = HandleObjectTypeEnum.getEnum(handleObjectType);
|
|
|
|
|
|
switch (handleObjectTypeEnum) {
|
|
switch (handleObjectTypeEnum) {
|
|
|
|
+
|
|
case USER:
|
|
case USER:
|
|
flowResult.setSuccess(true);
|
|
flowResult.setSuccess(true);
|
|
flowResult.setUserId(handleObjectId);
|
|
flowResult.setUserId(handleObjectId);
|
|
return flowResult;
|
|
return flowResult;
|
|
|
|
+
|
|
case DETP_LEADER:
|
|
case DETP_LEADER:
|
|
case DEPT_DIRECTOR:
|
|
case DEPT_DIRECTOR:
|
|
SysDept sysDept = sysDeptService.getById(handleObjectId);
|
|
SysDept sysDept = sysDeptService.getById(handleObjectId);
|
|
@@ -499,19 +513,35 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
}
|
|
}
|
|
flowResult.setSuccess(true);
|
|
flowResult.setSuccess(true);
|
|
return flowResult;
|
|
return flowResult;
|
|
|
|
+
|
|
case POST:
|
|
case POST:
|
|
- List<SysUser> userList = sysUserService.getListByPostId(handleObjectId);
|
|
+ List<SysUser> postUserList = sysUserService.getListByPostId(handleObjectId);
|
|
- if (userList.size() == 0) {
|
|
+ if (postUserList.size() == 0) {
|
|
throw new ServiceException("岗位无用户");
|
|
throw new ServiceException("岗位无用户");
|
|
}
|
|
}
|
|
- if (userList.size() == 1) {
|
|
+ if (postUserList.size() == 1) {
|
|
|
|
+ flowResult.setSuccess(true);
|
|
|
|
+ flowResult.setUserId(postUserList.get(0).getUserId());
|
|
|
|
+ return flowResult;
|
|
|
|
+ }
|
|
|
|
+ flowResult.setSuccess(false);
|
|
|
|
+ flowResult.setUserList(postUserList);
|
|
|
|
+ return flowResult;
|
|
|
|
+
|
|
|
|
+ case ROLE:
|
|
|
|
+ List<SysUser> roleUserList = sysUserService.getListByRoleId(handleObjectId);
|
|
|
|
+ if (roleUserList.size() == 0) {
|
|
|
|
+ throw new ServiceException("角色无用户");
|
|
|
|
+ }
|
|
|
|
+ if (roleUserList.size() == 1) {
|
|
flowResult.setSuccess(true);
|
|
flowResult.setSuccess(true);
|
|
- flowResult.setUserId(userList.get(0).getUserId());
|
|
+ flowResult.setUserId(roleUserList.get(0).getUserId());
|
|
return flowResult;
|
|
return flowResult;
|
|
}
|
|
}
|
|
flowResult.setSuccess(false);
|
|
flowResult.setSuccess(false);
|
|
- flowResult.setUserList(userList);
|
|
+ flowResult.setUserList(roleUserList);
|
|
return flowResult;
|
|
return flowResult;
|
|
|
|
+
|
|
default:
|
|
default:
|
|
throw new ServiceException("未知用户处理类型:" + handleObjectType);
|
|
throw new ServiceException("未知用户处理类型:" + handleObjectType);
|
|
}
|
|
}
|
|
@@ -532,4 +562,31 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * 模板替换
|
|
|
|
+ *
|
|
|
|
+ * <p>
|
|
|
|
+ * templateStr: ${Integer.parseInt(a)+1}; ${a+1}; ${b.tt}; ${b.vv}; ${b.vv[0]};
|
|
|
|
+ * map: {a: "1", b: {tt: "t", vv: ["aa", "bb", "cc"] }}
|
|
|
|
+ * result: 2; 11; t; ["aa","bb","cc"]; aa;
|
|
|
|
+ *
|
|
|
|
+ * @param templateStr 模板字符串
|
|
|
|
+ * @param map 替换参数
|
|
|
|
+ * @return 替换后的字符串
|
|
|
|
+ */
|
|
|
|
+ private static String templateParse(String templateStr, Map<String, Object> map) {
|
|
|
|
+ Pattern pattern = Pattern.compile("\\$\\{(.*?)}");
|
|
|
|
+ Matcher matcher = pattern.matcher(templateStr);
|
|
|
|
+ StringBuffer sr = new StringBuffer();
|
|
|
|
+ while (matcher.find()) {
|
|
|
|
+ String group = matcher.group().replace("$", "");
|
|
|
|
+ Object execute = AviatorEvaluator.compile(group).execute(map);
|
|
|
|
+ if (execute != null) {
|
|
|
|
+ matcher.appendReplacement(sr, execute.toString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ matcher.appendTail(sr);
|
|
|
|
+ return sr.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|