Commit c7f6ab98 authored by tianbo's avatar tianbo

隐患列表添加权限过滤

parent 1ff823de
package com.yeejoin.amos.boot.biz.common.service.impl; package com.yeejoin.amos.boot.biz.common.service.impl;
import java.text.ParseException; import com.alibaba.fastjson.JSONArray;
import java.text.SimpleDateFormat; import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.enums.WorkFlowEnum;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import com.alibaba.fastjson.JSONArray; import java.text.ParseException;
import com.alibaba.fastjson.JSONObject; import java.text.SimpleDateFormat;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import java.util.Date;
import com.yeejoin.amos.boot.biz.common.enums.WorkFlowEnum; import java.util.HashMap;
import com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService; import java.util.Map;
import com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService; import java.util.Random;
import java.util.Set;
@Service @Service
public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Autowired @Autowired
WorkflowFeignService workflowFeignService; WorkflowFeignService workflowFeignService;
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String newDate = sdf.format(new Date());
String result = "";
Random random = new Random();
for (int i = 0; i < 3; i++) {
result += random.nextInt(10);
}
return newDate + result;
}
@Transactional
@Override
public String startAndComplete(String key, String condition) throws Exception {
JSONObject body = new JSONObject();
String businessKey = buildOrderNo();
body.put(WorkFlowEnum.BUSINESSKEY.getCode(), businessKey);
body.put(WorkFlowEnum.processDefinitionKey.getCode(), key);
JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null || jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode()) == null) {
throw new RuntimeException("启动流程失败");
}
if (jsonObject != null) {
JSONObject instance = jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode());
if (!excuteTask(instance.getString(WorkFlowEnum.ID.getCode()), condition)) {
throw new RuntimeException("初始执行任务失败");
}
}
return jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode()).getString(WorkFlowEnum.ID.getCode());
}
@Transactional @Override
@Override public boolean checkTaskAuth(String processInstanceId, ReginParams userInfo) {
public String startAndComplete(String key, String condition) throws Exception { Map<String, Object> map = checkTaskAuthMap(processInstanceId, userInfo);
JSONObject body = new JSONObject(); return Boolean.parseBoolean(map.get(WorkFlowEnum.CHECKFLAG.getCode()).toString());
String businessKey = buildOrderNo(); }
body.put(WorkFlowEnum.BUSINESSKEY.getCode(), businessKey);
body.put(WorkFlowEnum.processDefinitionKey.getCode(), key);
JSONObject jsonObject = workflowFeignService.startByVariable(body);
if (jsonObject == null || jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode()) == null) {
throw new RuntimeException("启动流程失败");
}
if (jsonObject != null) {
JSONObject instance = jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode());
if (!excuteTask(instance.getString(WorkFlowEnum.ID.getCode()), condition)) {
throw new RuntimeException("初始执行任务失败");
}
}
return jsonObject.getJSONObject(WorkFlowEnum.DATA.getCode()).getString(WorkFlowEnum.ID.getCode());
}
@Override @Override
public boolean checkTaskAuth(String processInstanceId, ReginParams userInfo) { public Map<String, Object> checkTaskAuthMap(String processInstanceId, ReginParams userInfo) {
Map<String, Object> map = checkTaskAuthMap(processInstanceId, userInfo); // 获取当前登录用户的所有角色
return Boolean.parseBoolean(map.get(WorkFlowEnum.CHECKFLAG.getCode()).toString()); Set<String> roleNameSet = Sets.newHashSet();
} if (!ValidationUtil.isEmpty(userInfo.getUserModel().getOrgRoles())) {
userInfo.getUserModel().getOrgRoles().values().forEach(i -> {
i.forEach(e -> {
roleNameSet.add(e.getRoleName());
});
});
}
String currentLoginUserName = userInfo.getUserModel().getUserName();
Map<String, Object> map = new HashMap<String, Object>();
map.put(WorkFlowEnum.CHECKFLAG.getCode(), false);
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
if (ObjectUtils.isNotEmpty(teskObject.getJSONArray(WorkFlowEnum.DATA.getCode()))) {
JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode());
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
if (WorkFlowEnum.制定计划内容.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))
|| WorkFlowEnum.现场确认.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))) {
String groupName = getFristFlowDetail(processInstanceId);
if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
return map;
}
}
JSONObject taskGroupNameObject = workflowFeignService
.getTaskGroupName(detail.getString(WorkFlowEnum.ID.getCode()));
// 获取流程中原本设置的当前节点的执行权限
JSONArray taskGroupNameDetail = taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode());
// 如果拿不到当前任务的执行角色,再去获取当前任务有没有默认的执行人,如果都没有则返回校验失败
if (ObjectUtils.isEmpty(taskGroupNameDetail)) {
JSONObject taskAssignObject = workflowFeignService
.getTaskAssign(detail.getString(WorkFlowEnum.ID.getCode()));
String assignUser = taskAssignObject.getJSONObject(WorkFlowEnum.DATA.getCode())
.getString(WorkFlowEnum.ASSIGN.getCode());
if (StringUtils.isNotBlank(assignUser)) {
// 如果当前登录人与当前任务的设定人不一定,则直接返回权限校验失败
if (!assignUser.contains(currentLoginUserName)) {
return map;
}
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
map.put(WorkFlowEnum.ASSIGN.getCode(), assignUser);
return map;
}
continue;
}
String defaultExecutionRoleProcess = taskGroupNameDetail.getJSONObject(0)
.getString(WorkFlowEnum.GROUPID.getCode());
@Override if (StringUtils.isBlank(defaultExecutionRoleProcess)) {
public Map<String, Object> checkTaskAuthMap(String processInstanceId, ReginParams userInfo) { continue;
// 获取当前登录用户的角色 }
// String currentLoginUserRole = userInfo.getRole().getRoleName(); // 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出
Set<String> roleNameSet = Sets.newHashSet(); if (!roleNameSet.contains(defaultExecutionRoleProcess)) {
userInfo.getUserModel().getOrgRoles().values().forEach(i -> { continue;
i.forEach(e -> { }
roleNameSet.add(e.getRoleName()); map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
}); map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
}); map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
String currentLoginUserName = userInfo.getUserModel().getUserName(); map.put(WorkFlowEnum.GROUPNAME.getCode(), defaultExecutionRoleProcess);
Map<String, Object> map = new HashMap<String, Object>(); }
map.put(WorkFlowEnum.CHECKFLAG.getCode(), false); }
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId); return map;
if (ObjectUtils.isNotEmpty(teskObject.getJSONArray(WorkFlowEnum.DATA.getCode()))) { }
JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode());
for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
if (WorkFlowEnum.制定计划内容.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))
|| WorkFlowEnum.现场确认.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))) {
String groupName = getFristFlowDetail(processInstanceId);
if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
return map;
}
}
JSONObject taskGroupNameObject = workflowFeignService
.getTaskGroupName(detail.getString(WorkFlowEnum.ID.getCode()));
// 获取流程中原本设置的当前节点的执行权限
JSONArray taskGroupNameDetail = taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode());
// 如果拿不到当前任务的执行角色,再去获取当前任务有没有默认的执行人,如果都没有则返回校验失败
if (ObjectUtils.isEmpty(taskGroupNameDetail)) {
JSONObject taskAssignObject = workflowFeignService
.getTaskAssign(detail.getString(WorkFlowEnum.ID.getCode()));
String assignUser = taskAssignObject.getJSONObject(WorkFlowEnum.DATA.getCode())
.getString(WorkFlowEnum.ASSIGN.getCode());
if (StringUtils.isNotBlank(assignUser)) {
// 如果当前登录人与当前任务的设定人不一定,则直接返回权限校验失败
if (!assignUser.contains(currentLoginUserName)) {
return map;
}
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
map.put(WorkFlowEnum.ASSIGN.getCode(), assignUser);
return map;
}
continue;
}
String defaultExecutionRoleProcess = taskGroupNameDetail.getJSONObject(0)
.getString(WorkFlowEnum.GROUPID.getCode());
if(StringUtils.isBlank(defaultExecutionRoleProcess)) {
continue;
}
// 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出
if (!roleNameSet.contains(defaultExecutionRoleProcess)) {
continue;
}
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
map.put(WorkFlowEnum.GROUPNAME.getCode(), defaultExecutionRoleProcess);
}
}
return map;
}
@Override @Override
public boolean excuteTask(String procressId, String condition) throws Exception { public boolean excuteTask(String procressId, String condition) throws Exception {
HashMap<String, Object> conditionMap = new HashMap<String, Object>(); HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put(WorkFlowEnum.CONDITION.getCode(), condition); conditionMap.put(WorkFlowEnum.CONDITION.getCode(), condition);
JSONObject teskObject = workflowFeignService.getTaskList(procressId); JSONObject teskObject = workflowFeignService.getTaskList(procressId);
if (ObjectUtils.isNotEmpty(teskObject)) { if (ObjectUtils.isNotEmpty(teskObject)) {
JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode()); JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode());
for (Object obj : taskDetailArray) { for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj)); JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
workflowFeignService.pickupAndCompleteTask(detail.getString(WorkFlowEnum.ID.getCode()), conditionMap); workflowFeignService.pickupAndCompleteTask(detail.getString(WorkFlowEnum.ID.getCode()), conditionMap);
} }
} }
return true; return true;
} }
@Override @Override
public Object setTaskAssign(String processInstanceId, String userId) { public Object setTaskAssign(String processInstanceId, String userId) {
JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId); JSONObject teskObject = workflowFeignService.getTaskList(processInstanceId);
if (ObjectUtils.isEmpty(teskObject)) { if (ObjectUtils.isEmpty(teskObject)) {
throw new RuntimeException("设置任务执行人失败, 任务不存在,请检查processInstanceId" + processInstanceId + "是否正确"); throw new RuntimeException("设置任务执行人失败, 任务不存在,请检查processInstanceId" + processInstanceId + "是否正确");
} }
JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode()); JSONArray taskDetailArray = teskObject.getJSONArray(WorkFlowEnum.DATA.getCode());
for (Object obj : taskDetailArray) { for (Object obj : taskDetailArray) {
JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj)); JSONObject detail = JSONObject.parseObject(JSONObject.toJSONString(obj));
JSONObject taskGroupNameObject = workflowFeignService JSONObject taskGroupNameObject = workflowFeignService
.getTaskGroupName(detail.getString(WorkFlowEnum.ID.getCode())); .getTaskGroupName(detail.getString(WorkFlowEnum.ID.getCode()));
try { try {
if (taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode()) == null if (taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode()) == null
|| taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode()).size() < 1) { || taskGroupNameObject.getJSONArray(WorkFlowEnum.DATA.getCode()).size() < 1) {
workflowFeignService.setTaskUser(detail.getString(WorkFlowEnum.ID.getCode()), userId); workflowFeignService.setTaskUser(detail.getString(WorkFlowEnum.ID.getCode()), userId);
} }
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("设置任务执行人失败"); throw new RuntimeException("设置任务执行人失败");
} }
} }
return true; return true;
} }
@Override @Override
public boolean CompleteTask(String processInstanceId, String condition, ReginParams userInfo) { public boolean CompleteTask(String processInstanceId, String condition, ReginParams userInfo) {
Map<String, Object> map = checkTaskAuthMap(processInstanceId, userInfo); Map<String, Object> map = checkTaskAuthMap(processInstanceId, userInfo);
if (Boolean.parseBoolean(map.get(WorkFlowEnum.CHECKFLAG.getCode()).toString())) { if (Boolean.parseBoolean(map.get(WorkFlowEnum.CHECKFLAG.getCode()).toString())) {
HashMap<String, Object> conditionMap = new HashMap<String, Object>(); HashMap<String, Object> conditionMap = new HashMap<String, Object>();
conditionMap.put(WorkFlowEnum.CONDITION.getCode(), condition); conditionMap.put(WorkFlowEnum.CONDITION.getCode(), condition);
try { try {
workflowFeignService.pickupAndCompleteTask(map.get(WorkFlowEnum.TASKID.getCode()).toString(), workflowFeignService.pickupAndCompleteTask(map.get(WorkFlowEnum.TASKID.getCode()).toString(),
conditionMap); conditionMap);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("完成任务失败"); throw new RuntimeException("完成任务失败");
} }
} else { } else {
throw new RuntimeException("没有执行权限"); throw new RuntimeException("没有执行权限");
} }
return true; return true;
} }
public static String buildOrderNo() { /**
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); * 描述: 获取在流程启动时,直接完成的特定任务的执行角色信息。
String newDate = sdf.format(new Date()); * 作用:用来判断当前登录用户在任务回退到启动并完成的哪一步任务的执行权限,以及获取当前登录用户所属角色能够处理的当前任务的列表数据
String result = ""; *
Random random = new Random(); * @param processInstanceId
for (int i = 0; i < 3; i++) { * @return
result += random.nextInt(10); */
} public String getFristFlowDetail(String processInstanceId) {
return newDate + result; try {
}
/** JSONObject historyTaskJsonObject = workflowFeignService
* 描述: 获取在流程启动时,直接完成的特定任务的执行角色信息。 .getHistoricTaskForProcessInstanceId(processInstanceId);
* 作用:用来判断当前登录用户在任务回退到启动并完成的哪一步任务的执行权限,以及获取当前登录用户所属角色能够处理的当前任务的列表数据 if (ObjectUtils.isEmpty(historyTaskJsonObject.getJSONArray(WorkFlowEnum.DATA.getCode()))) {
* return null;
* @param processInstanceId }
* @return JSONObject historyTaskObject = historyTaskJsonObject.getJSONArray(WorkFlowEnum.DATA.getCode())
*/ .getJSONObject(0);
public String getFristFlowDetail(String processInstanceId) { JSONObject detail = workflowFeignService
try { .getHistoricIdentityLinksForTask(historyTaskObject.getString(WorkFlowEnum.ID.getCode()));
JSONArray resultArray = detail.getJSONArray(WorkFlowEnum.DATA.getCode());
if (ObjectUtils.isNotEmpty(resultArray)) {
for (int i = 0; i < resultArray.size(); i++) {
JSONObject result = resultArray.getJSONObject(i);
if (result.getBooleanValue(WorkFlowEnum.GROUP.getCode())) {
return result.getString(WorkFlowEnum.GROUPID.getCode());
}
}
}
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
JSONObject historyTaskJsonObject = workflowFeignService /**
.getHistoricTaskForProcessInstanceId(processInstanceId); * 获取当前登录用户所能执行的任务信息列表
if (ObjectUtils.isEmpty(historyTaskJsonObject.getJSONArray(WorkFlowEnum.DATA.getCode()))) { *
return null; * @param key
} * @param userInfo
JSONObject historyTaskObject = historyTaskJsonObject.getJSONArray(WorkFlowEnum.DATA.getCode()) * @return List<map < String, String>> eg: [{ "processInstanceId": "110d3af9-1f5a-11ec-a26e-b07b25133c48"}]
.getJSONObject(0); * @throws Exception
JSONObject detail = workflowFeignService */
.getHistoricIdentityLinksForTask(historyTaskObject.getString(WorkFlowEnum.ID.getCode())); @Override
JSONArray resultArray = detail.getJSONArray(WorkFlowEnum.DATA.getCode()); public Object getCurrentUserAllTaskList(String key, ReginParams userInfo) throws Exception {
if (ObjectUtils.isNotEmpty(resultArray)) { // 获取当前登录人的所有角色名
for (int i = 0; i < resultArray.size(); i++) { Set<String> roleNameSet = Sets.newHashSet();
JSONObject result = resultArray.getJSONObject(i); if (!ValidationUtil.isEmpty(userInfo.getUserModel().getOrgRoles())) {
if (result.getBooleanValue(WorkFlowEnum.GROUP.getCode())) { userInfo.getUserModel().getOrgRoles().values().forEach(i -> {
return result.getString(WorkFlowEnum.GROUPID.getCode()); i.forEach(e -> {
} roleNameSet.add(e.getRoleName());
} });
} });
} catch (ParseException e) { }
e.printStackTrace(); JSONObject CurrentUserAllTaskResult = null;
} try {
return null; //获取该登录用户已经分配到他名下和他对应的角色权限所能执行的任务组
} CurrentUserAllTaskResult = workflowFeignService.getCurrentUserAllTaskList(key);
/** } catch (Exception e) {
* 获取当前登录用户所能执行的任务信息列表 throw new RuntimeException("获取当前角色所能执行的任务失败");
* @param key }
* @param userInfo JSONArray allTaskResultList = CurrentUserAllTaskResult.getJSONArray(WorkFlowEnum.DATA.getCode());
* @return List<map<String,String>> eg: [{ "processInstanceId": "110d3af9-1f5a-11ec-a26e-b07b25133c48"}] //获取制定计划节点任务的所有可执行任务
* @throws Exception JSONObject SpecifyTask = workflowFeignService.getTaskListForTaskName(WorkFlowEnum.制定计划内容.getCode(), key);
*/ JSONArray SpecifyTaskArray = SpecifyTask.getJSONArray(WorkFlowEnum.DATA.getCode());
public Object getCurrentUserAllTaskList(String key, ReginParams userInfo) throws Exception { //判断该执行任务的历史执行节点的角色是否与当前登录用户的角色一致,如果一致就添加到根据用户角色ID和userID所属的任务列表中
Set<String> roleNameSet = Sets.newHashSet(); SpecifyTaskArray.stream().forEach(i -> {
userInfo.getUserModel().getOrgRoles().values().forEach(i -> { JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(i));
i.forEach(e -> { String groupName = getFristFlowDetail(json.getString(WorkFlowEnum.PROCESSINSTANCEID.getCode()));
roleNameSet.add(e.getRoleName()); if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
}); allTaskResultList.add(i);
}); }
// String currentLoginUserRole = userInfo.getRole().getRoleName(); });
JSONObject CurrentUserAllTaskResult = null; return allTaskResultList;
try { }
//获取该登录用户已经分配到他名下和他对应的角色权限所能执行的任务组
CurrentUserAllTaskResult = workflowFeignService.getCurrentUserAllTaskList(key);
} catch (Exception e) {
throw new RuntimeException("获取当前角色所能执行的任务失败");
}
JSONArray allTaskResultList = CurrentUserAllTaskResult.getJSONArray(WorkFlowEnum.DATA.getCode());
//获取制定计划节点任务的所有可执行任务
JSONObject SpecifyTask = workflowFeignService.getTaskListForTaskName(WorkFlowEnum.制定计划内容.getCode(), key);
JSONArray SpecifyTaskArray = SpecifyTask.getJSONArray(WorkFlowEnum.DATA.getCode());
//判断该执行任务的历史执行节点的角色是否与当前登录用户的角色一致,如果一致就添加到根据用户角色ID和userID所属的任务列表中
SpecifyTaskArray.stream().forEach(i -> {
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(i));
String groupName = getFristFlowDetail(json.getString(WorkFlowEnum.PROCESSINSTANCEID.getCode()));
if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
allTaskResultList.add(i);
}
});
return allTaskResultList;
}
} }
...@@ -240,6 +240,8 @@ public class LatentDangerController extends BaseController { ...@@ -240,6 +240,8 @@ public class LatentDangerController extends BaseController {
@PostMapping(value = "/page/list") @PostMapping(value = "/page/list")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel listDanger(@ApiParam(value = "查询条件", required = true) @RequestBody PageParam pageParam) throws Exception { public ResponseModel listDanger(@ApiParam(value = "查询条件", required = true) @RequestBody PageParam pageParam) throws Exception {
ReginParams reginParams = getSelectedOrgInfo();
pageParam.put("orgCode", reginParams.getCompany().getOrgCode());
IPage<LatentDanger> result = iLatentDangerService.pageListDanger(pageParam); IPage<LatentDanger> result = iLatentDangerService.pageListDanger(pageParam);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
...@@ -294,6 +296,8 @@ public class LatentDangerController extends BaseController { ...@@ -294,6 +296,8 @@ public class LatentDangerController extends BaseController {
@PostMapping(value = "/list/all") @PostMapping(value = "/list/all")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel<List<LatentDanger>> listAllDanger(@RequestBody LatentDangerListParam searchParam) { public ResponseModel<List<LatentDanger>> listAllDanger(@RequestBody LatentDangerListParam searchParam) {
ReginParams reginParams = getSelectedOrgInfo();
searchParam.setOrgCode(reginParams.getCompany().getOrgCode());
return ResponseHelper.buildResponse(iLatentDangerService.listAllDanger(searchParam)); return ResponseHelper.buildResponse(iLatentDangerService.listAllDanger(searchParam));
} }
...@@ -336,6 +340,8 @@ public class LatentDangerController extends BaseController { ...@@ -336,6 +340,8 @@ public class LatentDangerController extends BaseController {
@PostMapping(value = "/supervision/page/reviewList") @PostMapping(value = "/supervision/page/reviewList")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
public ResponseModel reviewListDanger(@ApiParam(value = "查询条件", required = true) @RequestBody PageParam pageParam) throws Exception { public ResponseModel reviewListDanger(@ApiParam(value = "查询条件", required = true) @RequestBody PageParam pageParam) throws Exception {
ReginParams reginParams = getSelectedOrgInfo();
pageParam.put("orgCode", reginParams.getCompany().getOrgCode());
IPage<LatentDanger> result = iLatentDangerService.reviewListDanger(pageParam); IPage<LatentDanger> result = iLatentDangerService.reviewListDanger(pageParam);
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
......
...@@ -39,4 +39,6 @@ public class LatentDangerListParam extends CommonPageable { ...@@ -39,4 +39,6 @@ public class LatentDangerListParam extends CommonPageable {
private String userId; private String userId;
private String dangerIds; private String dangerIds;
private String orgCode;
} }
...@@ -106,11 +106,22 @@ public class PageParam<K, V> extends HashMap<K, V> implements Pageable { ...@@ -106,11 +106,22 @@ public class PageParam<K, V> extends HashMap<K, V> implements Pageable {
return false; return false;
} }
public int getParamCurrent() { public int getParamPageCurrent() {
if (!ValidationUtil.isEmpty(this.get("current"))) { if (ValidationUtil.isEmpty(this.get("current"))) {
return current; return current;
} }
if (this.get("current") instanceof String && this.get("size") instanceof String) { if (this.get("current") instanceof String) {
return Integer.parseInt((String) this.get("current"));
} else {
return (Integer)(this.get("current"));
}
}
public int getParamPageSize() {
if (ValidationUtil.isEmpty(this.get("size"))) {
return size;
}
if (this.get("size") instanceof String) {
return Integer.parseInt((String) this.get("current")); return Integer.parseInt((String) this.get("current"));
} else { } else {
return (Integer)(this.get("current")); return (Integer)(this.get("current"));
......
...@@ -49,7 +49,20 @@ import com.yeejoin.amos.latentdanger.business.vo.DangerTimeAxisVo; ...@@ -49,7 +49,20 @@ import com.yeejoin.amos.latentdanger.business.vo.DangerTimeAxisVo;
import com.yeejoin.amos.latentdanger.business.vo.LatentDangerDetailRiskVo; import com.yeejoin.amos.latentdanger.business.vo.LatentDangerDetailRiskVo;
import com.yeejoin.amos.latentdanger.business.vo.LatentDangerDetailVo; import com.yeejoin.amos.latentdanger.business.vo.LatentDangerDetailVo;
import com.yeejoin.amos.latentdanger.business.vo.LatentDangerListVo; import com.yeejoin.amos.latentdanger.business.vo.LatentDangerListVo;
import com.yeejoin.amos.latentdanger.common.enums.*; import com.yeejoin.amos.latentdanger.common.enums.DangerHandleStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.DictTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.ExecuteStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.ExecuteTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerBizTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerExecuteTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerLevelEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerOvertimeStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerProcessStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerReformTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerState;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerStateEnum;
import com.yeejoin.amos.latentdanger.common.enums.LatentDangerTypeEnum;
import com.yeejoin.amos.latentdanger.common.enums.OwerEnum;
import com.yeejoin.amos.latentdanger.common.remote.RemoteSpcService; import com.yeejoin.amos.latentdanger.common.remote.RemoteSpcService;
import com.yeejoin.amos.latentdanger.common.remote.RemoteWebSocketServer; import com.yeejoin.amos.latentdanger.common.remote.RemoteWebSocketServer;
import com.yeejoin.amos.latentdanger.common.remote.RemoteWorkFlowService; import com.yeejoin.amos.latentdanger.common.remote.RemoteWorkFlowService;
...@@ -81,9 +94,17 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -81,9 +94,17 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo; import static com.yeejoin.amos.latentdanger.business.util.RandomUtil.buildOrderNo;
import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct; import static org.typroject.tyboot.core.foundation.context.RequestContext.getProduct;
...@@ -107,6 +128,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -107,6 +128,8 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
@Autowired @Autowired
SupervisionFeignClient supervisionFeignClient; SupervisionFeignClient supervisionFeignClient;
@Autowired @Autowired
JcsFeignClient jcsFeignClient;
@Autowired
private RemoteWorkFlowService remoteWorkFlowService; private RemoteWorkFlowService remoteWorkFlowService;
@Autowired @Autowired
private RemoteSecurityService remoteSecurityService; private RemoteSecurityService remoteSecurityService;
...@@ -120,7 +143,6 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -120,7 +143,6 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
private RemoteSpcService remoteSpcService; private RemoteSpcService remoteSpcService;
@Autowired @Autowired
private AsyncTask asyncTask; private AsyncTask asyncTask;
// @Autowired // @Autowired
// private Business business; // private Business business;
@Autowired @Autowired
...@@ -145,14 +167,10 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -145,14 +167,10 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
private WorkflowExcuteServiceImpl workflowExecuteService; private WorkflowExcuteServiceImpl workflowExecuteService;
@Autowired @Autowired
private WorkflowFeignService workflowFeignService; private WorkflowFeignService workflowFeignService;
// 有启动后执行现场确认的角色名称 // 有启动后执行现场确认的角色名称
@Value("${onSite.confirm.roleName}") @Value("${onSite.confirm.roleName}")
private String onSiteConfirmRole; private String onSiteConfirmRole;
@Autowired
JcsFeignClient jcsFeignClient;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public CommonResponse saveNormal(LatentDangerDto latentDangerDto, String userId, String userRealName, public CommonResponse saveNormal(LatentDangerDto latentDangerDto, String userId, String userRealName,
...@@ -1813,18 +1831,17 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1813,18 +1831,17 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (!ValidationUtil.isEmpty(dangerIdList)) { if (!ValidationUtil.isEmpty(dangerIdList)) {
pageParam.put("dangerIds", dangerIdList); pageParam.put("dangerIds", dangerIdList);
} }
Page page = new Page();
initPage(pageParam, page);
if (ValidationUtil.isEmpty(pageParam.get("order"))) { if (ValidationUtil.isEmpty(pageParam.get("order"))) {
pageParam.put("order", "1"); pageParam.put("order", "1");
} }
Page page = new Page(pageParam.getParamPageCurrent(), pageParam.getParamPageSize());
IPage<LatentDanger> iPage = this.baseMapper.selectPageByParam(page, (Map<String, Object>) pageParam); IPage<LatentDanger> iPage = this.baseMapper.selectPageByParam(page, (Map<String, Object>) pageParam);
if (iPage.getCurrent() != pageParam.getParamCurrent()) { if (iPage.getCurrent() != pageParam.getParamPageCurrent()) {
iPage.setRecords(Lists.newArrayList()); iPage.setRecords(Lists.newArrayList());
iPage.setTotal(0); iPage.setTotal(0);
iPage.setCurrent(pageParam.getParamCurrent()); iPage.setCurrent(pageParam.getParamPageCurrent());
return iPage; return iPage;
} }
Map<String, Object> buildingAbsolutePositionMap = new HashMap<>(); Map<String, Object> buildingAbsolutePositionMap = new HashMap<>();
...@@ -1865,18 +1882,6 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1865,18 +1882,6 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
return iPage; return iPage;
} }
public void initPage(PageParam pageParam, Page page) {
if (pageParam.get("current") instanceof String && pageParam.get("size") instanceof String) {
int current = Integer.valueOf((String) pageParam.get("current"));
int size = Integer.valueOf((String) pageParam.get("size"));
page.setCurrent(current);
page.setSize(size);
} else {
page.setCurrent((Integer)(pageParam.get("current")));
page.setSize((Integer)(pageParam.get("size")));
}
}
private List<Map<String, Object>> getAllNodes(List<Map<String, Object>> buildingTree) { private List<Map<String, Object>> getAllNodes(List<Map<String, Object>> buildingTree) {
List<Map<String, Object>> res = new LinkedList<>(); List<Map<String, Object>> res = new LinkedList<>();
if (buildingTree != null && !buildingTree.isEmpty()) { if (buildingTree != null && !buildingTree.isEmpty()) {
...@@ -1983,6 +1988,10 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD ...@@ -1983,6 +1988,10 @@ public class LatentDangerServiceImpl extends BaseService<LatentDangerBo, LatentD
if (!ValidationUtil.isEmpty(searchParam.getDangerIds())) { if (!ValidationUtil.isEmpty(searchParam.getDangerIds())) {
lambdaQueryWrapper.in(LatentDanger::getId, Lists.newArrayList(searchParam.getDangerIds().split(","))); lambdaQueryWrapper.in(LatentDanger::getId, Lists.newArrayList(searchParam.getDangerIds().split(",")));
} }
lambdaQueryWrapper.and(o ->
o.likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "*")
.or().likeRight(LatentDanger::getOrgCode, searchParam.getOrgCode() + "-")
.or().eq(LatentDanger::getOrgCode, searchParam.getOrgCode()));
List<LatentDanger> latentDangers = this.baseMapper.selectList(lambdaQueryWrapper); List<LatentDanger> latentDangers = this.baseMapper.selectList(lambdaQueryWrapper);
return latentDangers; return latentDangers;
......
...@@ -963,6 +963,10 @@ ...@@ -963,6 +963,10 @@
<where> <where>
deleted = 0 deleted = 0
<foreach collection="paramMap" index="key" item="value"> <foreach collection="paramMap" index="key" item="value">
<if test="key == 'orgCode' and value != null and value != ''">
and (a.org_code like concat(#{value}, "*%") or a.org_code like concat(#{value}, "-%") or
a.org_code = #{value})
</if>
<if test="key == 'bizType' and value != null and value != ''"> <if test="key == 'bizType' and value != null and value != ''">
and a.biz_type = #{value} and a.biz_type = #{value}
</if> </if>
......
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