审核权限

new
chenqp 1 year ago
parent d8db345e08
commit d0beb88bd2

@ -1,6 +1,7 @@
package cn.iocoder.yudao.framework.tenant.core.db; package cn.iocoder.yudao.framework.tenant.core.db;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -17,5 +18,9 @@ public abstract class TenantBaseDO extends BaseDO {
* *
*/ */
private Long tenantId; private Long tenantId;
/**
* 使
*/
@TableField(exist = false)
private Boolean isAuthorised = false;
} }

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService; import cn.iocoder.yudao.module.bpm.service.expenseapplytrip.ExpenseApplyTripService;
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.*; import cn.iocoder.yudao.module.bs.controller.admin.expenseapply.vo.*;
import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert; import cn.iocoder.yudao.module.bs.convert.expenseapply.ExpenseApplyConvert;
import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO; import cn.iocoder.yudao.module.bs.dal.dataobject.expenseapply.ExpenseApplyDO;
@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.bs.enums.BillTypeEnum;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -43,6 +45,9 @@ public class ExpenseApplyController {
private ExpenseApplyService expenseApplyService; private ExpenseApplyService expenseApplyService;
@Resource @Resource
private ExpenseApplyTripService expenseApplyTripService; private ExpenseApplyTripService expenseApplyTripService;
@Resource
@Lazy // 解决循环依赖
private BpmTaskService taskService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建申请单") @Operation(summary = "创建申请单")
@PreAuthorize("@ss.hasPermission('bs:expense-apply:create')") @PreAuthorize("@ss.hasPermission('bs:expense-apply:create')")
@ -74,6 +79,7 @@ public class ExpenseApplyController {
expenseApplyService.setNickNameField(CollUtil.toList(expenseApply)); expenseApplyService.setNickNameField(CollUtil.toList(expenseApply));
expenseApplyService.setDeptNameField(CollUtil.toList(expenseApply)); expenseApplyService.setDeptNameField(CollUtil.toList(expenseApply));
} }
taskService.handleApprovalAuthority(CollUtil.toList(expenseApply));
return success(expenseApply); return success(expenseApply);
} }
@ -93,7 +99,6 @@ public class ExpenseApplyController {
PageResult<ExpenseApplyDO> pageResult = expenseApplyService.getExpenseApplyPage(pageVO); PageResult<ExpenseApplyDO> pageResult = expenseApplyService.getExpenseApplyPage(pageVO);
List<ExpenseApplyDO> list = pageResult.getList(); List<ExpenseApplyDO> list = pageResult.getList();
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
//cqptodo 待设置用户名称
expenseApplyService.setNickNameField(list); expenseApplyService.setNickNameField(list);
List<Long> applids = list.stream().map(ExpenseApplyDO::getId).collect(Collectors.toList()); List<Long> applids = list.stream().map(ExpenseApplyDO::getId).collect(Collectors.toList());
LambdaQueryWrapperX<ExpenseApplyTripDO> queryWrapper = new LambdaQueryWrapperX<>(); LambdaQueryWrapperX<ExpenseApplyTripDO> queryWrapper = new LambdaQueryWrapperX<>();
@ -107,6 +112,8 @@ public class ExpenseApplyController {
} }
apply.getExpenseApplyTrips().add(tripDO); apply.getExpenseApplyTrips().add(tripDO);
} }
taskService.handleApprovalAuthority(list);
} }
return success(pageResult); return success(pageResult);
} }

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.service.task;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
@ -128,4 +129,5 @@ public interface BpmTaskService {
*/ */
void updateTaskExtAssign(Task task); void updateTaskExtAssign(Task task);
<T extends TenantBaseDO> List<T> handleApprovalAuthority(List<T> list);
} }

@ -1,14 +1,18 @@
package cn.iocoder.yudao.module.bpm.service.task; package cn.iocoder.yudao.module.bpm.service.task;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils; import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.framework.common.util.object.PageUtils; import cn.iocoder.yudao.framework.common.util.object.PageUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
@ -38,6 +42,7 @@ import javax.annotation.Resource;
import javax.validation.Valid; import javax.validation.Valid;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
@ -316,5 +321,34 @@ public class BpmTaskServiceImpl implements BpmTaskService {
private HistoricTaskInstance getHistoricTask(String id) { private HistoricTaskInstance getHistoricTask(String id) {
return historyService.createHistoricTaskInstanceQuery().taskId(id).taskTenantId(TenantContextHolder.getTenantId().toString()).singleResult(); return historyService.createHistoricTaskInstanceQuery().taskId(id).taskTenantId(TenantContextHolder.getTenantId().toString()).singleResult();
} }
@Override
public <T extends TenantBaseDO> List<T> handleApprovalAuthority(List<T> list) {
if (CollUtil.isNotEmpty(list)) {
for (T t : list) {
Object processInstanceId = ReflectUtil.getFieldValue(t, "processInstanceId");
if (processInstanceId != null) {
List<HistoricTaskInstance> taskList = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(Convert.toStr(processInstanceId))
.taskTenantId(TenantContextHolder.getTenantId().toString())
.list();
if (CollUtil.isNotEmpty(taskList)) {
//endtime为null表示未结束的task
List<String> taskIdS = taskList.stream().filter(tk -> tk.getEndTime() == null).map(HistoricTaskInstance::getId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(taskIdS)) {
LambdaQueryWrapperX<BpmTaskExtDO> wrapperX = new LambdaQueryWrapperX<>();
wrapperX.in(BpmTaskExtDO::getTaskId, taskIdS);
wrapperX.in(BpmTaskExtDO::getAssigneeUserId, SecurityFrameworkUtils.getLoginUserId());
boolean exists = taskExtMapper.exists(wrapperX);
if (exists) {
t.setIsAuthorised(true);
} else {
t.setIsAuthorised(false);
}
}
}
}
}
}
return list;
}
} }

Loading…
Cancel
Save