diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/letter/sql/LetterMenu.sql b/yun-admin/src/main/java/net/lab1024/sa/admin/module/letter/sql/LetterMenu.sql deleted file mode 100644 index 80ec17a..0000000 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/letter/sql/LetterMenu.sql +++ /dev/null @@ -1,22 +0,0 @@ -# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下, -# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。 -# 如果你一切都是按照默认,那么下面的 SQL 基本不用改 - -INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id ) -VALUES ( '承诺书签订表', 2, 0, '/letter/list', '/business/letter/letter-list.vue', false, false, true, false, 1, 1 ); - -# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID -SET @parent_id = NULL; -SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = '承诺书签订表'; - -INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id ) -VALUES ( '查询', 3, @parent_id, false, false, true, false, 1, 'letter:query', 'letter:query', @parent_id, 1 ); - -INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id ) -VALUES ( '添加', 3, @parent_id, false, false, true, false, 1, 'letter:add', 'letter:add', @parent_id, 1 ); - -INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id ) -VALUES ( '更新', 3, @parent_id, false, false, true, false, 1, 'letter:update', 'letter:update', @parent_id, 1 ); - -INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id ) -VALUES ( '删除', 3, @parent_id, false, false, true, false, 1, 'letter:delete', 'letter:delete', @parent_id, 1 ); diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/controller/PenaltyApplyController.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/controller/PenaltyApplyController.java index 0c9501c..fa31175 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/controller/PenaltyApplyController.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/controller/PenaltyApplyController.java @@ -73,7 +73,7 @@ public class PenaltyApplyController { //审核 @Operation(summary = "审核 @author wzh") @PostMapping("/penaltyApply/review") - @SaCheckPermission("penaltyApply:review") + //@SaCheckPermission("penaltyApply:review") public ResponseDTO review(@RequestBody @Valid PenaltyApplyUpdateForm updateForm) { return penaltyApplyService.review(updateForm); } diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/entity/PenaltyApplyEntity.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/entity/PenaltyApplyEntity.java index 2cd1f45..25f76b2 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/entity/PenaltyApplyEntity.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/entity/PenaltyApplyEntity.java @@ -32,6 +32,11 @@ public class PenaltyApplyEntity { */ private Long userId; + /** + * 部门ID + */ + private Long departmentId; + /** * 申请日期 */ @@ -43,10 +48,15 @@ public class PenaltyApplyEntity { private String usePurpose; /** - * 状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) + * 律所审核状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) */ private Integer status; + /** + * 律协审核状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) + */ + private Integer auditStatus; + /** * 创建时间 */ diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyQueryForm.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyQueryForm.java index 1184adb..9af6504 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyQueryForm.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyQueryForm.java @@ -30,9 +30,23 @@ public class PenaltyApplyQueryForm extends PageParam { private String userName; /** - * 状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) + * 律所审核状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) */ private Integer status; + /** + * 律协审核状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回) + */ + private Integer auditStatus; + /** + * 部门ID + */ + private Long departmentId; + + /** + * 用户角色代码 + */ + private String userType; + private Long userId; } diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyUpdateForm.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyUpdateForm.java index 7686ce0..17e19e1 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyUpdateForm.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/form/PenaltyApplyUpdateForm.java @@ -19,7 +19,9 @@ public class PenaltyApplyUpdateForm { @NotNull(message = "申请ID 不能为空") private Long id; - @Schema(description = "状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回)") + @Schema(description = "律所审批状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回)") private Integer status; + @Schema(description = "律协审批状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回)") + private Integer auditStatus; } \ No newline at end of file diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/vo/PenaltyApplyVO.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/vo/PenaltyApplyVO.java index ec0b1d0..6f6ed14 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/vo/PenaltyApplyVO.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/domain/vo/PenaltyApplyVO.java @@ -23,6 +23,9 @@ public class PenaltyApplyVO { @Schema(description = "申请人ID") private Long userId; + @Schema(description = "部门ID") + private Long departmentId; + @Schema(description = "申请人名称") private String userName; @@ -35,6 +38,9 @@ public class PenaltyApplyVO { @Schema(description = "状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回)") private Integer status; + @Schema(description = "状态(0-未提交,1-已提交,2-审核中,3-已批准,5-已驳回)") + private Integer auditStatus; + @Schema(description = "创建时间") private LocalDateTime createTime; diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/service/PenaltyApplyService.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/service/PenaltyApplyService.java index 1d3bf28..97b63e4 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/service/PenaltyApplyService.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/penalty/service/PenaltyApplyService.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; import java.util.List; import net.lab1024.sa.admin.common.enums.ReviewEnum; +import net.lab1024.sa.admin.module.letter.service.LetterService; import net.lab1024.sa.admin.module.penalty.dao.PenaltyApplyDao; import net.lab1024.sa.admin.module.penalty.domain.entity.PenaltyApplyEntity; import net.lab1024.sa.admin.module.penalty.domain.form.PenaltyApplyAddForm; @@ -30,6 +31,8 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.validation.Valid; +import lombok.extern.slf4j.Slf4j; + /** * 无处罚证明申请主表 Service * @@ -39,6 +42,7 @@ import javax.validation.Valid; */ @Service +@Slf4j public class PenaltyApplyService { @Resource @@ -49,16 +53,25 @@ public class PenaltyApplyService { private EmployeeService employeeService; @Resource private RoleEmployeeService roleEmployeeService; + @Resource + private LetterService letterService; /** * 分页查询 */ public PageResult queryPage(PenaltyApplyQueryForm queryForm) { Page page = SmartPageUtil.convert2PageQuery(queryForm); RequestEmployee requestUser = AdminRequestUtil.getRequestUser(); - List roleIdList = roleEmployeeService.getRoleIdList(requestUser.getEmployeeId()); - if (!UserTypeEnum.CEO.getDesc().equals(roleIdList.get(0).getRoleCode())) { - queryForm.setUserId(requestUser.getEmployeeId()); + + // 安全获取角色代码,避免NPE + String roleCode = getUserRoleCode(requestUser); + if (roleCode.equals(UserTypeEnum.CEO.getDesc())) { + queryForm.setUserType(roleCode); + }else if(roleCode.equals(UserTypeEnum.CTO.getDesc())){ + queryForm.setDepartmentId(requestUser.getDepartmentId()); + }else { + queryForm.setUserId(requestUser.getUserId()); } + List list = penaltyApplyDao.queryPage(page, queryForm); return SmartPageUtil.convert2PageResult(page, list); } @@ -76,7 +89,15 @@ public class PenaltyApplyService { } PenaltyApplyEntity penaltyApplyEntity = SmartBeanUtil.copy(addForm, PenaltyApplyEntity.class); penaltyApplyEntity.setUserId(userId); - penaltyApplyEntity.setStatus(ReviewEnum.APPROVAL.getValue()); + String roleCode = letterService.getRoleCode(); + //判断类型 + if (roleCode.equals(UserTypeEnum.CTO.getDesc())){ + penaltyApplyEntity.setStatus(ReviewEnum.PASS.getValue()); + penaltyApplyEntity.setAuditStatus(ReviewEnum.APPROVAL.getValue()); + }else { + penaltyApplyEntity.setStatus(ReviewEnum.APPROVAL.getValue()); + } + penaltyApplyEntity.setDepartmentId(entity.getDepartmentId()); penaltyApplyEntity.setApplyDate(LocalDateTime.now()); penaltyApplyDao.insert(penaltyApplyEntity); return ResponseDTO.ok(); @@ -118,7 +139,17 @@ public class PenaltyApplyService { public ResponseDTO review(@Valid PenaltyApplyUpdateForm updateForm) { PenaltyApplyEntity penaltyApplyEntity = penaltyApplyDao.selectById(updateForm.getId()); - penaltyApplyEntity.setStatus(updateForm.getStatus()); + String roleCode = letterService.getRoleCode(); + //判断类型 + if (roleCode.equals(UserTypeEnum.CTO.getDesc())){ + //审核通过,则下一个为律协审核 + if (ReviewEnum.PASS.getValue().equals(updateForm.getAuditStatus())){ + penaltyApplyEntity.setAuditStatus(ReviewEnum.APPROVAL.getValue()); + } + penaltyApplyEntity.setStatus(updateForm.getAuditStatus()); + }else{ + penaltyApplyEntity.setAuditStatus(updateForm.getAuditStatus()); + } penaltyApplyDao.updateById(penaltyApplyEntity); return ResponseDTO.ok(); } @@ -126,4 +157,37 @@ public class PenaltyApplyService { public PenaltyApplyEntity selectOne(Integer id) { return penaltyApplyDao.selectById(id); } + + /** + * 安全获取用户角色代码,避免NPE + * @param requestUser 请求用户信息 + * @return 用户角色代码,如果获取失败则返回USER默认角色 + */ + private String getUserRoleCode(RequestEmployee requestUser) { + try { + if (requestUser == null) { + log.warn("请求用户信息为空,返回默认用户角色"); + return UserTypeEnum.USER.getDesc(); + } + + List roleIdList = roleEmployeeService.getRoleIdList(requestUser.getEmployeeId()); + if (roleIdList == null || roleIdList.isEmpty()) { + log.warn("用户ID {} 的角色列表为空,返回默认用户角色", requestUser.getEmployeeId()); + return UserTypeEnum.USER.getDesc(); + } + + RoleVO roleVO = roleIdList.get(0); + if (roleVO == null || roleVO.getRoleCode() == null) { + log.warn("角色信息为空或角色代码为空,返回默认用户角色"); + return UserTypeEnum.USER.getDesc(); + } + + String roleCode = roleVO.getRoleCode(); + log.debug("用户ID {} 的角色代码: {}", requestUser.getEmployeeId(), roleCode); + return roleCode; + } catch (Exception e) { + log.error("获取用户角色代码时发生异常", e); + return UserTypeEnum.USER.getDesc(); + } + } } diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/domain/form/ServiceApplicationsUpdateForm.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/domain/form/ServiceApplicationsUpdateForm.java index 38e2214..2e0e043 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/domain/form/ServiceApplicationsUpdateForm.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/domain/form/ServiceApplicationsUpdateForm.java @@ -75,7 +75,7 @@ public class ServiceApplicationsUpdateForm{ private Long associationAuditUser; @Schema(description = "协会审核意见") private String associationAuditOpinion; - + private Integer auditResult; /** * 职务id */ diff --git a/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/service/ServiceApplicationsService.java b/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/service/ServiceApplicationsService.java index f9ba99c..022afc2 100644 --- a/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/service/ServiceApplicationsService.java +++ b/yun-admin/src/main/java/net/lab1024/sa/admin/module/service/service/ServiceApplicationsService.java @@ -711,7 +711,7 @@ public class ServiceApplicationsService { // 根据不同角色执行不同的审核操作 if (UserTypeEnum.CEO.getDesc().equals(roleCode)) { // CEO角色:修改协会审核状态 - serviceApplicationsEntity.setAssociationAuditStatus(updateForm.getAssociationAuditStatus()); + serviceApplicationsEntity.setAssociationAuditStatus(updateForm.getFirmAuditStatus()); serviceApplicationsEntity.setAssociationAuditUser(requestUser.getEmployeeId()); serviceApplicationsEntity.setAssociationAuditTime(LocalDateTime.now()); serviceApplicationsEntity.setAssociationAuditOpinion(updateForm.getAssociationAuditOpinion()); @@ -878,10 +878,10 @@ public class ServiceApplicationsService { // 根据不同角色执行不同的审核操作 if (UserTypeEnum.CEO.getDesc().equals(roleCode)) { // CEO角色:修改协会审核状态 - serviceApplicationsDao.batchReviewAsAssociation(fileKeyList, ReviewEnum.PASS.getValue(), requestUser.getUserId(), reviewTime); + serviceApplicationsDao.batchReviewAsAssociation(fileKeyList, updateForm.getAuditResult(), requestUser.getUserId(), reviewTime); } else { // 其他角色(如律所管理员):修改律所审核状态 - serviceApplicationsDao.batchReviewAsFirm(fileKeyList, ReviewEnum.PASS.getValue(), requestUser.getUserId(), reviewTime); + serviceApplicationsDao.batchReviewAsFirm(fileKeyList, updateForm.getAuditResult(), requestUser.getUserId(), reviewTime); } return ResponseDTO.ok(); diff --git a/yun-admin/src/main/resources/mapper/penaltyapply/PenaltyApplyMapper.xml b/yun-admin/src/main/resources/mapper/penaltyapply/PenaltyApplyMapper.xml index de83d58..901b5f4 100644 --- a/yun-admin/src/main/resources/mapper/penaltyapply/PenaltyApplyMapper.xml +++ b/yun-admin/src/main/resources/mapper/penaltyapply/PenaltyApplyMapper.xml @@ -11,7 +11,9 @@ t_penalty_apply.status, t_penalty_apply.create_time, t_penalty_apply.update_time, - t_penalty_apply.deleted_flag + t_penalty_apply.deleted_flag, + t_penalty_apply.department_id, + t_penalty_apply.audit_status @@ -25,6 +27,8 @@ tp_apply.create_time as createTime, tp_apply.update_time as updateTime, tp_apply.deleted_flag as deletedFlag, + tp_apply.audit_status as auditStatus, + tp_apply.department_id as departmentId, te_employee.actual_name AS userName FROM t_penalty_apply tp_apply left join t_employee te_employee on tp_apply.user_id = te_employee.employee_id @@ -45,6 +49,12 @@ AND tp_apply.user_id = #{queryForm.userId} + + AND tp_apply.department_id = #{queryForm.departmentId} + + + AND tp_apply.audit_status > 0 + ORDER BY tp_apply.status, tp_apply.create_time DESC diff --git a/yun-admin/src/main/resources/mapper/service/ServiceApplicationsMapper.xml b/yun-admin/src/main/resources/mapper/service/ServiceApplicationsMapper.xml index 11d16b8..8b983bc 100644 --- a/yun-admin/src/main/resources/mapper/service/ServiceApplicationsMapper.xml +++ b/yun-admin/src/main/resources/mapper/service/ServiceApplicationsMapper.xml @@ -276,7 +276,7 @@ AND tsa.firm_id = #{queryForm.firmId} - GROUP BY tsa.user_id + GROUP BY tsa.user_id, tsa.certificate_number ORDER BY e.actual_name