Commit 809b6dfb authored by kongfm's avatar kongfm

Merge remote-tracking branch 'origin/developer' into developer

parents 08d32ce5 cdc7dcc7
package com.yeejoin.amos.boot.biz.common.service;
import java.util.Map;
public interface IWorkflowExcuteService{
/**
* 启动流程,并执行完成任务
* @param key 流程定义的key
* @param condition 执行控制条件
*/
void startAndComplete(String key,String condition)throws Exception;
/**
* 检查当前登录人有没有流程操作权限
* @param processInstanceId 流程定义的ID
* @return true 可以执行,false 无执行权限
*/
boolean checkTaskAuth(String processInstanceId);
/**
* 检查当前登录人有没有流程操作权限
* @param processInstanceId 流程定义的ID
* @return 包含是否执行的角色权限flag,以及当前任务的id
*/
Map<String, Object> checkTaskAuthMap(String processInstanceId);
/**
* 设置当前任务的执行人,只支持当前节点流程拥有单个可执行任务的情况,不支持并行网关产生的多条任务设置人的任务情况
* @param processInstanceId
* @return
*/
Object setTaskAssign(String processInstanceId,String userId);
/**
* 完成task节点任务
* @param processInstanceId
* @param condition
* @param userInfo
* @return
*/
boolean CompleteTask(String processInstanceId,String condition);
}
package com.yeejoin.amos.boot.biz.common.service.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
@Service
public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Autowired
WorkflowFeignService workflowFeignService;
@Transactional
@Override
public void startAndComplete(String key, String condition) throws Exception {
JSONObject body = new JSONObject();
body.put("processDefinitionKey", key);
JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null || jsonObject.getJSONObject("data") == null) {
throw new RuntimeException("启动流程失败");
}
if (jsonObject != null) {
JSONObject instance = jsonObject.getJSONObject("data");
if (!excuteTask(instance.getString("id"), condition)) {
throw new RuntimeException("初始执行任务失败");
}
}
}
@Override
public boolean checkTaskAuth(String processInstanceId) {
Map<String, Object> map = checkTaskAuthMap(processInstanceId);
return Boolean.parseBoolean(map.get("checkFlag").toString());
}
@Override
public Map<String, Object> checkTaskAuthMap(String processInstanceId) {
// 获取当前登录用户的角色
Map<String, Object> map = new HashMap<String, Object>();
map.put("checkFlag", false);
JSONObject teskObject = workflowFeignService.getTask(processInstanceId);
if (ObjectUtils.isNotEmpty(teskObject)) {
map.put("taskId", teskObject.getString("id"));
map.put("checkFlag", true);
map.put("name", teskObject.getString("name"));
}
/*
* JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
* if (ObjectUtils.isNotEmpty(teskObject)) { JSONArray taskDetailArray =
* teskObject.getJSONArray("data"); for (Object obj : taskDetailArray) {
* JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
* JSONObject taskGroupNameObject =
* workflowFeignService.getTaskGroupName(detail.getString("id")); //
* 获取流程中原本设置的当前节点的执行权限 JSONArray taskGroupNameDetail =
* taskGroupNameObject.getJSONArray("data"); //
* 如果拿不到当前任务的执行角色,再去获取当前任务有没有默认的执行人,如果都没有则返回校验失败 if
* (ObjectUtils.isEmpty(taskGroupNameDetail)) { JSONObject taskAssignObject =
* workflowFeignService.getTaskAssign(detail.getString("id")); String assignUser
* = taskAssignObject.getJSONObject("data").getString("assignee"); if
* (StringUtils.isNotBlank(assignUser)) { // 如果当前登录人与当前任务的设定人不一定,则直接返回权限校验失败 if
* (!currentLoginUserId.equals(assignUser)) { return map; } else {
* map.put("taskId", detail.getString("id")); map.put("checkFlag", true);
* map.put("name", detail.getString("name")); map.put("assign", assignUser);
* return map; } } continue; } String defaultExecutionRoleProcess =
* taskGroupNameDetail.getJSONObject(0).getString("groupId"); //
* 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出 if
* (!defaultExecutionRoleProcess.equals(currentLoginUserRole)) { continue; }
* map.put("taskId", detail.getString("id")); map.put("checkFlag", true);
* map.put("name", detail.getString("name"));
* map.put("groupName",currentLoginUserRole); } }
*/
return map;
}
public boolean excuteTask(String procressId, String condition) throws Exception {
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", condition);
JSONObject teskObject = workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
workflowFeignService.pickupAndCompleteTask(detail.getString("id"), conditionMap);
}
}
return true;
}
@Override
public Object setTaskAssign(String processInstanceId, String userId) {
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray("data");
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
try {
workflowFeignService.setTaskUser(detail.getString("id"), userId);
} catch (Exception e) {
throw new RuntimeException("设置任务执行人失败");
}
}
}
return true;
}
@Override
public boolean CompleteTask(String processInstanceId, String condition) {
Map<String, Object> map = checkTaskAuthMap(processInstanceId);
if (Boolean.parseBoolean(map.get("checkFlag").toString())) {
HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put("condition", condition);
try {
workflowFeignService.completeNoExecuteFromInstanceAdd(map.get("taskId").toString(), conditionMap);
} catch (Exception e) {
throw new RuntimeException("完成任务失败");
}
} else {
throw new RuntimeException("没有执行权限");
}
return true;
}
}
......@@ -25,7 +25,7 @@ public interface WorkflowFeignService {
JSONObject startByVariable(@RequestBody Object params);
/**
* 完成任务
* 以当前登录人作为任务完成人的完成任务操作
*
* @param taskID
* @param variable
......@@ -55,65 +55,115 @@ public interface WorkflowFeignService {
JSONObject getTaskGroupName(@PathVariable("taskId") String taskId);
/**
* 我的待办
* 查询当前登录人可执行的任务集合,-------我的待办
*
* @param processDefinitionKey
* @param userId
* @return
*/
@RequestMapping(value = "/task/all-list", method = RequestMethod.GET)
JSONObject getTasksNoAuth(@RequestParam(value="processDefinitionKey", required=false) String processDefinitionKey,
@RequestParam(value="userId", required=false) String userId) ;
JSONObject getTasksNoAuth(
@RequestParam(value = "processDefinitionKey", required = false) String processDefinitionKey,
@RequestParam(value = "userId", required = false) String userId);
/**
* 流程信息
* 查询历史流程信息
*
* @param processDefinitionKey
* @param userId
* @return
*/
@RequestMapping(value = "/activitiHistory/processes/historytasks/list/{processInstanceId}", method = RequestMethod.GET)
JSONObject queryHistoryTaskListByProcessId(@PathVariable("processInstanceId") String processInstanceId);
JSONObject queryHistoryTaskListByProcessId(@PathVariable("processInstanceId") String processInstanceId);
/**
* 查询当前流程已经执行的任务
*
* @param processInstanceId
* @return
*/
@RequestMapping(value = "/activitiHistory/historyTask/{processInstanceId}", method = RequestMethod.GET)
JSONObject queryHistoryTasksByProcessInstanceId(@PathVariable("processInstanceId") String processInstanceId);
/**
* 拾取任务
*
* @param taskID
* @return
*/
@RequestMapping(value = "/task/pickuptask/{taskID}", method = RequestMethod.PUT)
JSONObject pickuptask(@PathVariable("taskID") String taskID) ;
JSONObject pickuptask(@PathVariable("taskID") String taskID);
/**
* 直接完成任务
*
* @param taskId
* @param variable
* @return
*/
@RequestMapping(value = "/task/complete/{taskId}", method = RequestMethod.POST)
JSONObject completeByVariable(@PathVariable("taskId") String taskId, @RequestBody HashMap<String, Object> variable);
/**
* 获取当前任务的设定执行人
*
* @param taskId
* @return
*/
@RequestMapping(value = "/task/getTaskAssign/{taskId}", method = RequestMethod.GET)
JSONObject getTaskAssign(@PathVariable("taskId") String taskId) ;
JSONObject getTaskAssign(@PathVariable("taskId") String taskId);
/**
* 不操作FormInstance直接完成任务
*
* @param taskID
* @param variable
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/completeTask/noFromInstanceAdd/{taskID}", method = RequestMethod.POST)
JSONObject completeNoExecuteFromInstanceAdd(@PathVariable("taskID") String taskID, @RequestBody(required = false) HashMap<String, Object> variable) throws Exception;
JSONObject completeNoExecuteFromInstanceAdd(@PathVariable("taskID") String taskID,
@RequestBody(required = false) HashMap<String, Object> variable) throws Exception;
/**
* 流程图高亮
* */
/**
* 流程图高亮
*/
@RequestMapping(value = "/activitiHistory/gethighLineImg/{processInstanceId}", method = RequestMethod.GET)
Response thighLineImg(@PathVariable("processInstanceId") String processInstanceId) ;
/**
* 流程图高亮图片
* */
@RequestMapping(value = "/activitiHistory/gethighLine",method = RequestMethod.GET)
Response thighLineImg(@PathVariable("processInstanceId") String processInstanceId);
/**
* 流程图高亮图片
*/
@RequestMapping(value = "/activitiHistory/gethighLine", method = RequestMethod.GET)
Response thighLine(@RequestParam("instanceId") String instanceId);
/**
* 设置当前任务的执行组
*
* @param taskId
* @param groupName
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/setTaskGroupName/{taskId}/{groupName}", method = RequestMethod.GET)
JSONObject setTaskGroupName(@PathVariable("taskId") String taskId, @PathVariable("groupName") String groupName)
throws Exception;
/**
* 设置当前任务的执行人
*
* @param taskId
* @param userId
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/setTaskAssignUser/{taskId}/{userId}", method = RequestMethod.GET)
JSONObject setTaskUser(@PathVariable("taskId") String taskId, @PathVariable("userId") String userId) throws Exception;
/**
* 查询当前登录人所属角色或者id 所能执行的单个任务
* @param processInstanceId
* @return
*/
@RequestMapping(value = "/task/")
JSONObject getTask(@RequestParam(value="processInstanceId") String processInstanceId);
}
......@@ -92,7 +92,9 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
Map<Long, OrgMenuDto> map = new HashMap<>(menuList.size());
menuList.forEach(e -> map.put(e.getKey(), e));
Set<? extends Map.Entry<Long, ? extends OrgMenuDto>> entries = map.entrySet();
entries.parallelStream().forEach(entry -> {
//此处多线程,会value 出现null 的情况
//entries.parallelStream().forEach(entry -> {
entries.stream().forEach(entry -> {
OrgMenuDto value = entry.getValue();
if (value != null) {
OrgMenuDto treeDto = map.get(value.getParentId());
......@@ -102,6 +104,7 @@ public class OrgUsrServiceImpl extends BaseService<OrgUsrDto, OrgUsr, OrgUsrMapp
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
result.add(value);
......
......@@ -1145,4 +1145,18 @@
</sql>
</changeSet>
<changeSet author="tw" id="2021-09-22-0002">
<preConditions onFail="MARK_RAN">
<tableExists tableName="cb_firefighters"/>
</preConditions>
<comment>增加amos账号关联字段</comment>
<sql>
ALTER TABLE `cb_firefighters` add amos_name varchar(255) COMMENT 'amos账户名称';
ALTER TABLE `cb_firefighters` add amos_user_id varchar(255) COMMENT 'amos账户id';
</sql>
</changeSet>
</databaseChangeLog>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment