Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import cn.cordys.crm.approval.annotation.HitApproval;
import cn.cordys.crm.approval.constants.ApprovalStatus;
import cn.cordys.crm.approval.constants.ExecuteTimingEnum;
import cn.cordys.crm.approval.domain.ApprovalFlowVersion;
import cn.cordys.crm.approval.domain.ApprovalFlow;
import cn.cordys.crm.approval.service.ApprovalFlowService;
import cn.cordys.crm.approval.service.ApprovalResourceService;
import jakarta.annotation.Resource;
Expand Down Expand Up @@ -161,7 +161,7 @@ private String resolveResourceIdFromArgs(Method method, Object[] args, String ex
private boolean checkHitApprovalFlow(FormKey formKey, ExecuteTimingEnum executeTiming, String organizationId) {
try {
// 查询当前组织表单审批流配置
ApprovalFlowVersion flow = approvalFlowService.getEnabledFlow(formKey.getKey(), organizationId);
ApprovalFlow flow = approvalFlowService.getEnabledFlow(formKey.getKey(), organizationId);

if (flow == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package cn.cordys.crm.approval.controller;

import cn.cordys.aspectj.annotation.OperationLog;
import cn.cordys.aspectj.constants.LogModule;
import cn.cordys.aspectj.constants.LogType;
import cn.cordys.common.constants.PermissionConstants;
import cn.cordys.common.pager.Pager;
import cn.cordys.context.OrganizationContext;
import cn.cordys.crm.approval.dto.request.ApprovalFlowAddRequest;
import cn.cordys.crm.approval.dto.request.ApprovalFlowPageRequest;
import cn.cordys.crm.approval.dto.request.ApprovalFlowUpdateRequest;
import cn.cordys.crm.approval.dto.response.ApprovalFlowByFormTypeResponse;
import cn.cordys.crm.approval.dto.response.ApprovalFlowDetailResponse;
import cn.cordys.crm.approval.dto.response.ApprovalFlowListResponse;
import cn.cordys.crm.approval.dto.response.StatusPermissionSettingResponse;
import cn.cordys.crm.approval.dto.request.ApprovalFlowAddRequest;
import cn.cordys.crm.approval.dto.request.ApprovalFlowPageRequest;
import cn.cordys.crm.approval.dto.request.ApprovalFlowUpdateRequest;
import cn.cordys.crm.approval.domain.ApprovalFlow;
import cn.cordys.crm.approval.service.ApprovalFlowService;
import cn.cordys.security.SessionUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
Expand All @@ -45,23 +41,20 @@ public Pager<List<ApprovalFlowListResponse>> list(@Validated @RequestBody Approv

@PostMapping("/add")
@RequiresPermissions(PermissionConstants.APPROVAL_FLOW_ADD)
@OperationLog(module = LogModule.APPROVAL_FLOW, type = LogType.ADD)
@Operation(summary = "新建审批流")
public ApprovalFlowDetailResponse add(@Validated @RequestBody ApprovalFlowAddRequest request) {
return approvalFlowService.add(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
}

@PostMapping("/update")
@RequiresPermissions(PermissionConstants.APPROVAL_FLOW_UPDATE)
@OperationLog(module = LogModule.APPROVAL_FLOW, type = LogType.UPDATE)
@Operation(summary = "更新审批流")
public ApprovalFlowDetailResponse update(@Validated @RequestBody ApprovalFlowUpdateRequest request) {
return approvalFlowService.update(request, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
}

@GetMapping("/delete/{id}")
@RequiresPermissions(PermissionConstants.APPROVAL_FLOW_DELETE)
@OperationLog(module = LogModule.APPROVAL_FLOW, type = LogType.DELETE)
@Operation(summary = "删除审批流")
public void delete(@PathVariable("id") String id) {
approvalFlowService.delete(id, OrganizationContext.getOrganizationId());
Expand All @@ -76,7 +69,6 @@ public ApprovalFlowDetailResponse get(@PathVariable("id") String id) {

@GetMapping("/enable/{id}")
@RequiresPermissions(PermissionConstants.APPROVAL_FLOW_UPDATE)
@OperationLog(module = LogModule.APPROVAL_FLOW, type = LogType.UPDATE)
@Operation(summary = "启用/禁用审批流")
public void updateEnable(@PathVariable("id") String id, @RequestParam("enable") Boolean enable) {
approvalFlowService.updateEnable(id, enable, SessionUtils.getUserId(), OrganizationContext.getOrganizationId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,39 @@ public class ApprovalFlow extends BaseModel {
@Schema(description = "表单类型:quotation/contract/invoice/order")
private String formType;

@Schema(description = "新建时执行")
private Boolean createExecute;

@Schema(description = "编辑时执行")
private Boolean updateExecute;

@Schema(description = "允许提交人撤销")
private Boolean submitterCanRevoke;

@Schema(description = "允许批量处理")
private Boolean allowBatchProcess;

@Schema(description = "允许撤回")
private Boolean allowWithdraw;

@Schema(description = "允许加签")
private Boolean allowAddSign;

@Schema(description = "重复审批人规则:FIRST_ONLY/SEQUENTIAL_ALL/EACH")
private String duplicateApproverRule;

@Schema(description = "是否必须填写审批意见")
private Boolean requireComment;

@Schema(description = "启用状态")
private Boolean enable;

@Schema(description = "流程描述")
private String description;

@Schema(description = "状态权限配置(JSON格式)")
private String statusPermissions;

@Schema(description = "组织id")
private String organizationId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,9 @@ public class ApprovalFlowVersion implements Serializable {
@Schema(description = "审批流ID")
private String flowId;

@Schema(description = "新建时执行")
private Boolean createExecute;

@Schema(description = "编辑时执行")
private Boolean updateExecute;

@Schema(description = "允许提交人撤销")
private Boolean submitterCanRevoke;

@Schema(description = "允许批量处理")
private Boolean allowBatchProcess;

@Schema(description = "允许撤回")
private Boolean allowWithdraw;

@Schema(description = "允许加签")
private Boolean allowAddSign;

@Schema(description = "重复审批人规则:FIRST_ONLY/SEQUENTIAL_ALL/EACH")
private String duplicateApproverRule;

@Schema(description = "是否必须填写审批意见")
private Boolean requireComment;

@Schema(description = "组织id")
private String organizationId;

@Schema(description = "状态权限配置(JSON格式)")
private String statusPermissions;

@Schema(description = "创建人")
private String createUser;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ public interface ExtApprovalFlowMapper {
List<ApprovalFlowListResponse> list(
@Param("request") ApprovalFlowPageRequest request,
@Param("organizationId") String organizationId);

/**
* 批量禁用同类型审批流
*/
int disableByFormType(
@Param("formType") String formType,
@Param("organizationId") String organizationId,
@Param("excludeId") String excludeId,
@Param("updateUser") String updateUser,
@Param("updateTime") Long updateTime);
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,4 @@
</otherwise>
</choose>
</sql>

<update id="disableByFormType">
UPDATE approval_flow
SET enable = 0,
update_user = #{updateUser},
update_time = #{updateTime}
WHERE form_type = #{formType}
AND organization_id = #{organizationId}
AND enable = 1
<if test="excludeId != null">
AND id != #{excludeId}
</if>
</update>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public class ApprovalActionService {
@Resource
private ApprovalInstanceService approvalInstanceService;
@Resource
private BaseMapper<ApprovalFlowVersion> approvalFlowVersionMapper;
@Resource
private BaseMapper<ApprovalInstance> approvalInstanceMapper;
@Resource
private BaseMapper<ApprovalTask> approvalTaskMapper;
Expand Down Expand Up @@ -87,12 +85,14 @@ public class ApprovalActionService {
* @param orgId 当前组织
*/
public void sign(ApprovalAddSignRequest request, String userId, String orgId) {
ApprovalInstance instance = approvalInstanceMapper.selectByPrimaryKey(request.getInstanceId());

// 审批流是否允许加签
ApprovalFlowVersion flowVersion = getFlowVersionOfInstanceId(request.getInstanceId());
if (flowVersion == null || !flowVersion.getAllowAddSign()) {
ApprovalFlow approvalFlow = approvalFlowService.selectApprovalFlowByFormType(instance.getType(), orgId);
if (approvalFlow == null || !approvalFlow.getAllowAddSign()) {
throw new GenericException(Translator.get("no.operation.permission"));
}
ApprovalInstance instance = approvalInstanceMapper.selectByPrimaryKey(request.getInstanceId());

// 刷新被加签任务状态 && 插入审批记录
ApprovalTask currentTask = saveActionTask(request, ApprovalAction.SIGN, userId, orgId, ApprovalAddSignType.valueOf(request.getType()));
// 加签操作的待办任务
Expand Down Expand Up @@ -134,12 +134,12 @@ public void back(ApprovalReturnBackRequest request, String userId, String orgId)
*/
public void revoke(ApprovalRevokeRequest request, String currentUserId, String orgId) {
ApprovalTask currentTask = getTaskById(request.getId());
ApprovalInstance instance = approvalInstanceMapper.selectByPrimaryKey(currentTask.getInstanceId());
// 审批流是否允许撤回
ApprovalFlowVersion flowVersion = getFlowVersionOfInstanceId(currentTask.getInstanceId());
if (flowVersion == null || !flowVersion.getAllowWithdraw()) {
ApprovalFlow approvalFlow = approvalFlowService.selectApprovalFlowByFormType(currentTask.getType(), orgId);
if (approvalFlow == null || !approvalFlow.getAllowWithdraw()) {
throw new GenericException(Translator.get("no.operation.permission"));
}
ApprovalInstance instance = approvalInstanceMapper.selectByPrimaryKey(currentTask.getInstanceId());
revokeProcess(currentTask, instance, orgId);
refreshRevokeTask(currentTask, instance, currentUserId);
}
Expand Down Expand Up @@ -168,17 +168,6 @@ public void reject(ApprovalActionRequest request, String currentUserId, String c
rejectProcess(currentTask, currentUserId, currentOrgId);
}

/**
* 获取流程配置相关权限
*
* @param id 审批实例ID
* @return 审批流
*/
private ApprovalFlowVersion getFlowVersionOfInstanceId(String id) {
ApprovalInstance approvalInstance = approvalInstanceMapper.selectByPrimaryKey(id);
return approvalFlowVersionMapper.selectByPrimaryKey(approvalInstance.getFlowVersionId());
}

/**
* 保存加签任务的信息
*
Expand Down
Loading
Loading