diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java index e37a2f3..bb4d7ee 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java @@ -101,4 +101,5 @@ public class EnterprisePageReqVO extends PageParam { @Schema(description = "排除企业id") private Long excludeEnterpriseId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index 451ae55..b558b99 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -189,7 +189,10 @@ public class TaskInfoController { pageResult.getList().forEach(item->{ item.setPublishDep(dep.getName()); - item.setCreateName(adminUserService.getUser(Long.valueOf(item.getCreator())).getRealName()); + final AdminUserDO user1 = adminUserService.getUser(Long.valueOf(item.getCreator())); + if (user1 != null) { + item.setCreateName(user1.getRealName()); + } enterpriseInspectionsPageReqVO.setTaskId(item.getId()); List enterpriseInspectionsides=enterpriseInspectionsService.getEnterpriseInspectionsList(enterpriseInspectionsPageReqVO); EnterprisePageReqVO enterprisePageReqVO=new EnterprisePageReqVO(); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java index f14ac09..68ec662 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java @@ -77,6 +77,15 @@ public class UserController { return success(true); } + @DeleteMapping("/test_delete") + @Operation(summary = "测试时,删除用户所有信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:user:delete')") + public CommonResult testDeleteUser(@RequestParam("id") Long id) { + userService.testDeleteUser(id); + return success(true); + } + @PutMapping("/update-password") @Operation(summary = "重置用户密码") @PreAuthorize("@ss.hasPermission('system:user:update-password')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java index 727c02e..dc94601 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java @@ -6,8 +6,12 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.*; +import org.apache.ibatis.annotations.Param; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; @@ -72,4 +76,7 @@ public interface EnterpriseMapper extends BaseMapperX { .inIfPresent(EnterpriseDO::getId,reqVO.getIds()) .orderByDesc(EnterpriseDO::getId)); } + + IPage getAppPage(Page page, @Param("params") EnterprisePageReqVO pageReqVO); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index bd4dcd1..950a1a8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; @@ -50,4 +51,9 @@ public interface AdminUserMapper extends BaseMapperX { return selectList(AdminUserDO::getDeptId, deptIds); } + @Delete("delete from system_oauth2_access_token where user_id = #{userId}") + Long deleteOauth2AccessAuth(Long userId); + + @Delete("delete from system_oauth2_refresh_token where user_id = #{userId}") + Long deleteOauth2RefreshAuth(Long userId); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java index c350bf0..2f1c69f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java @@ -76,9 +76,9 @@ public class TaskSendStartMessageJob implements JobHandler { //执法任务更改状态 LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getId()); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getTaskId()); List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); - if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0){ + if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { List list = new ArrayList<>(); for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { //站内信发送通知 @@ -88,16 +88,17 @@ public class TaskSendStartMessageJob implements JobHandler { Map templateParams = new HashMap<>(); templateParams.put("title", beforeTaskInfo.getTitle()); templateParams.put("startTime", beforeTaskInfo.getStartDate()); + templateParams.put("endTime", beforeTaskInfo.getEndDate()); + templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); + notifyMessage.setTemplateParams(templateParams); - notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); + notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); enterpriseInspectionsDO.setStatus(2); list.add(enterpriseInspectionsDO); } enterpriseInspectionsMapper.updateBatch(list); } - - } }); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index bdfe6c1..97dbbaa 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -459,47 +459,31 @@ public class AdminAuthServiceImpl implements AdminAuthService { AdminUserDO user = userService.getUser(loginUserId); RoleNameAndSelectTypeVO roleNameAndSelectTypeVO = new RoleNameAndSelectTypeVO(); if (user != null) { - if (user.getPostIds() != null) { - if (user.getPostIds().contains(1L) || user.getPostIds().contains(2L)) { - // 全部权限,不需要设置任何条件 - roleNameAndSelectTypeVO.setRoleName("director"); - } else if (user.getPostIds().contains(4L)) { - // 本部门权限 - roleNameAndSelectTypeVO.setRoleName("queue"); - roleNameAndSelectTypeVO.setValue(user.getDeptId()); - } else { - // 仅自己权限 - roleNameAndSelectTypeVO.setRoleName("self"); - roleNameAndSelectTypeVO.setValue(loginUserId); - roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); - } - } else { - //如果岗位不存在查询角色 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserRoleDO::getUserId, loginUserId); - List userRoleDO = userRoleMapper.selectList(wrapper); - - if (userRoleDO == null) { - throw exception(ROLE_ERROR); - } - - List collect = userRoleDO.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); - if (collect.contains(164l) || collect.contains(1l)) { - // 全部权限,不需要设置任何条件 - roleNameAndSelectTypeVO.setRoleName("director"); - } else if (collect.contains(163L)) { - // 本部门权限 - roleNameAndSelectTypeVO.setRoleName("queue"); - roleNameAndSelectTypeVO.setValue(user.getDeptId()); - } else { - // 仅自己权限 - roleNameAndSelectTypeVO.setRoleName("self"); - roleNameAndSelectTypeVO.setValue(loginUserId); - roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); - - } + //如果岗位不存在查询角色 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserRoleDO::getUserId, loginUserId); + List userRoleDO = userRoleMapper.selectList(wrapper); + + if (userRoleDO == null) { + throw exception(ROLE_ERROR); + } + + List collect = userRoleDO.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); + if (collect.contains(164l) || collect.contains(1l)) { + // 全部权限,不需要设置任何条件 + roleNameAndSelectTypeVO.setRoleName("director"); + } else if (collect.contains(163L)) { + // 本部门权限 + roleNameAndSelectTypeVO.setRoleName("queue"); + roleNameAndSelectTypeVO.setValue(user.getDeptId()); + } else { + // 仅自己权限 + roleNameAndSelectTypeVO.setRoleName("self"); + roleNameAndSelectTypeVO.setValue(loginUserId); + roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); } + } else { throw exception(USER_NOT_EXISTS); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java index c5680b1..a4b7ba4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java @@ -29,6 +29,8 @@ import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificat import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.tomcat.jni.FileInfo; import org.checkerframework.checker.units.qual.A; import org.springframework.stereotype.Service; @@ -279,27 +281,12 @@ public class EnterpriseServiceImpl implements EnterpriseService { pageReqVO.setDepartmentId(typeVO.getValue()); } - final PageResult enterpriseDOPageResult = enterpriseMapper.selectPage(pageReqVO); + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + final IPage appPage = enterpriseMapper.getAppPage(page, pageReqVO); + + return new PageResult<>(appPage.getRecords(), appPage.getTotal()); - if (pageReqVO.getTagList() != null && pageReqVO.getTagList().size() > 0) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(EnterpriseTagDO::getTagId, pageReqVO.getTagList()); - List enterpriseTagDOList = enterpriseTagMapper.selectList(wrapper); - //根据enterpriseTagDOList 筛选 - List enterpriseDOList = new ArrayList<>(); - for (EnterpriseDO enterpriseDO : enterpriseDOPageResult.getList()) { - for (EnterpriseTagDO enterpriseTagDO : enterpriseTagDOList) { - if (enterpriseTagDO.getEnterpriseId().equals(enterpriseDO.getId())) { - enterpriseDOList.add(enterpriseDO); - break; - } - } - } - enterpriseDOPageResult.setList(enterpriseDOList); - enterpriseDOPageResult.setTotal(Long.valueOf(enterpriseDOList.size())); - } - return enterpriseDOPageResult; } //审核状态 @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java index 78b7293..e16f018 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java @@ -193,15 +193,6 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } } -// if ("queue".equals(typeVO.getRoleName())) { -// pageReqVO.setDepartmentId(typeVO.getValue()); -// final List adminUserDOS = adminUserMapper.selectList(new QueryWrapper().eq("dept_id", typeVO.getValue())); -// if (adminUserDOS != null || adminUserDOS.size() > 0) { -// final List collect = adminUserDOS.stream().map(item -> item.getId()).collect(Collectors.toList()); -// pageReqVO.setUserIds(collect); -// } -// } - //按照部门查询 if (pageReqVO.getDepartmentId() != null) { final List adminUserDOS = adminUserMapper.selectList(new QueryWrapper().eq("dept_id", pageReqVO.getDepartmentId())); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java index a6c8e53..63f07dd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java @@ -20,7 +20,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; @Slf4j @Service @@ -98,7 +100,14 @@ public class HomeServiceImpl implements HomeService{ }); } - homeCountResVO.setCompletionRate(homeGroupCountVOS1); + //排序 + final List sortCollect = homeGroupCountVOS1.stream(). + sorted(Comparator.comparing(HomeListVO::getValue).reversed()). + collect(Collectors.toList()); + + log.info("sortCollect:{}", sortCollect); + + homeCountResVO.setCompletionRate(sortCollect); return homeCountResVO; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java index 89dad96..1b53fb7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java @@ -230,4 +230,6 @@ public interface AdminUserService { List getSimpleUserZGList(); List getSimpleEnterpriseUserList(Integer type); + + void testDeleteUser(Long id); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 5383bc0..5c78025 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -23,12 +23,19 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; import cn.iocoder.yudao.module.system.controller.admin.userAuditlog.vo.UserAuditLogSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; +import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.userAuditlog.UserAuditLogDO; import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; +import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; +import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper; import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; +import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper; +import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.userAuditlog.UserAuditLogMapper; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; @@ -38,6 +45,7 @@ import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.tenant.TenantService; import cn.iocoder.yudao.module.system.service.userAuditlog.UserAuditLogService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.service.impl.DiffParseFunction; @@ -100,6 +108,15 @@ public class AdminUserServiceImpl implements AdminUserService { private AdminUserMapper adminUserMapper; @Resource private UserRoleMapper userRoleMapper; + @Resource + private SocialUserBindMapper socialUserBindMapper; + @Resource + private SocialUserMapper socialUserMapper; + @Resource + private EnterpriseMapper enterpriseMapper; + @Resource + private EnterpriseInspectionsMapper enterpriseInspectionsMapper; + @Override @Transactional(rollbackFor = Exception.class) @@ -288,6 +305,23 @@ public class AdminUserServiceImpl implements AdminUserService { permissionService.processUserDeleted(id); // 2.2 删除用户岗位 userPostMapper.deleteByUserId(id); + // 2.3 删除社交用户 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", id); + final SocialUserBindDO socialUserBindDO = socialUserBindMapper.selectById(wrapper); + socialUserMapper.deleteById(socialUserBindDO.getSocialUserId()); + socialUserBindMapper.deleteById(socialUserBindDO.getId()); + //2.4 删除 token 数据 + adminUserMapper.deleteOauth2AccessAuth(id); + adminUserMapper.deleteOauth2RefreshAuth(id); + //2.5 删除 企业 + QueryWrapper enterpriseDOQueryWrapper = new QueryWrapper<>(); + enterpriseDOQueryWrapper.eq("user_id", id); + enterpriseMapper.delete(enterpriseDOQueryWrapper); + //2.6 执法 + QueryWrapper inspectionsDOQueryWrapper = new QueryWrapper<>(); + inspectionsDOQueryWrapper.eq("user_id", id); + enterpriseInspectionsMapper.delete(inspectionsDOQueryWrapper); // 3. 记录操作日志上下文 LogRecordContext.putVariable("user", user); @@ -622,6 +656,37 @@ public class AdminUserServiceImpl implements AdminUserService { return adminUserMapper.selectList(wrapper); } + @Override + public void testDeleteUser(Long id) { + // 1. 校验用户存在 + AdminUserDO user = validateUserExists(id); + // 2.1 删除用户 + userMapper.deleteById(id); + // 2.2 删除用户关联数据 + permissionService.processUserDeleted(id); + // 2.2 删除用户岗位 + userPostMapper.deleteByUserId(id); + // 2.3 删除社交用户 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("user_id", id); + final SocialUserBindDO socialUserBindDO = socialUserBindMapper.selectOne(wrapper); + socialUserMapper.deleteById(socialUserBindDO.getSocialUserId()); + socialUserBindMapper.deleteById(socialUserBindDO.getId()); + //2.4 删除 token 数据 + adminUserMapper.deleteOauth2AccessAuth(id); + adminUserMapper.deleteOauth2RefreshAuth(id); + //2.5 删除 企业 + QueryWrapper enterpriseDOQueryWrapper = new QueryWrapper<>(); + enterpriseDOQueryWrapper.eq("user_id", id); + enterpriseMapper.delete(enterpriseDOQueryWrapper); + //2.6 执法 + QueryWrapper inspectionsDOQueryWrapper = new QueryWrapper<>(); + inspectionsDOQueryWrapper.eq("user_id", id); + enterpriseInspectionsMapper.delete(inspectionsDOQueryWrapper); + // 3. 记录操作日志上下文 + LogRecordContext.putVariable("user", user); + } + public void bindSocialUser(Long userId, AuthUser authUser) { // SocialUserDO socialUser = new SocialUserDO(); // socialUser.setUserId(userId); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml new file mode 100644 index 0000000..433e850 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml index 8b72d43..28271b1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml @@ -68,7 +68,6 @@ SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) as finishCount, COUNT(DISTINCT ei.id) as execCount, - COUNT(DISTINCT ei.id) AS totalCount , -- 计算每个 user_id 的总数 round( SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) /COUNT(DISTINCT ei.id) * 100,1) as completionRate FROM enterprise_inspections ei @@ -85,7 +84,7 @@ WHERE ei.deleted = 0 AND e.deleted = 0 and ei.status = 2 - and e.department_id = #{deptId} and su.real_name is not null + and e.department_id = #{deptId} and e.department_id != 100 @@ -97,7 +96,7 @@ e.department_id - + order by finishCount