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 d2c95f1..e615b39 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 @@ -225,7 +225,7 @@ public class TaskInfoController { @GetMapping("/appPageByEnterpriseId") @Operation(summary = "获得任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。分页") - @PreAuthorize("@ss.hasPermission('system:task-info:query')") +// @PreAuthorize("@ss.hasPermission('system:task-info:query')") public CommonResult> appPageByEnterpriseId( TaskInfoPageReqVO pageReqVO) { PageResult pageResult = taskInfoService.appPageByEnterpriseId(pageReqVO); return success(BeanUtils.toBean(pageResult, TaskInfoRespVO.class)); 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 8bb13d7..093b83d 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 @@ -332,7 +332,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { if (insert < 0) { throw exception(INSERT_ERROR); } - user = userService.autoRegisterUser(authUser); + user = userService.autoRegisterUser(authUser, reqVO.getUserType()); //给用户付一个普通用户角色可以上传图片 UserRoleDO userRoleDO = new UserRoleDO(); @@ -354,7 +354,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { user.setIsBand(true); - } return user; 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 abcefd5..6cc6d07 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 @@ -79,9 +79,6 @@ public class HomeServiceImpl implements HomeService{ //完成数 final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); - log.info("taskFinish={}",taskFinish); - log.info("taskExec={}",taskExec); - if (taskFinish != null && taskFinish != 0) { double taskCompletionRate = (double) taskFinish/taskExec*100; homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); @@ -91,7 +88,6 @@ public class HomeServiceImpl implements HomeService{ //根据不同的身份查询 final List homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); - List homeGroupCountVOS1 = new ArrayList<>(); if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { @@ -99,19 +95,47 @@ public class HomeServiceImpl implements HomeService{ HomeListVO homeListVO = new HomeListVO(); homeListVO.setName(item.getName()); homeListVO.setValue(item.getCompletionRate()); - double rate = (double) item.getFinishCount() /taskExec * 100; - homeListVO.setPieValue(String.format("%.1f", rate)); +// double rate = (double) item.getFinishCount() /taskExec * 100; +// homeListVO.setPieValue(String.format("%.1f", rate)); homeGroupCountVOS1.add(homeListVO); }); + + //循环饼图占比数据 + + final List collect = homeGroupCountVOS1.stream().filter(i -> !i.getValue().equals("0.0")). + map(i -> Double.parseDouble(i.getValue())).collect(Collectors.toList()); + + double total = collect.stream() + .reduce(0.0, Double::sum); + + homeGroupCountVOS1.forEach(item->{ + if (item != null && item.getValue() != null) { + final double value = Double.parseDouble(item.getValue()); + if (total != 0 && value != 0) { + final double pieRate = value / total * 100; + // 如果 TaskCompletionRate 不为空,则乘以该值 + String taskCompletionRateStr = homeCountResVO.getTaskCompletionRate(); + double taskCompletionRate = "0.0".equals(taskCompletionRateStr) ? 0.0 : Double.parseDouble(taskCompletionRateStr); + final double pie = pieRate * taskCompletionRate / 100; + item.setPieValue(String.format("%.1f", pie)); + } else { + item.setPieValue(String.format("%.1f", 0.0)); + } + } else { + item.setPieValue(String.format("%.1f", 0.0)); + } + }); + + + } + //排序 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 623b9fc..b7f1c37 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 @@ -223,7 +223,7 @@ public interface AdminUserService { * @Author djx * @Date 2025-01-22 上午9:41 **/ - AdminUserDO autoRegisterUser(AuthUser authUser); + AdminUserDO autoRegisterUser(AuthUser authUser, Integer userType); void userAudit(UserAuditLogSaveReqVO auditLogSaveReqVO); 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 a4964ad..967e0ba 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 @@ -595,13 +595,14 @@ public class AdminUserServiceImpl implements AdminUserService { * @Date 2025-01-22 上午9:40 **/ @Override - public AdminUserDO autoRegisterUser(AuthUser authUser) { + public AdminUserDO autoRegisterUser(AuthUser authUser, Integer userType) { // 根据微信用户信息生成用户数据 AdminUserDO user = new AdminUserDO(); // openid.substring(openid.length() - 10) user.setUsername("wx_" + authUser.getUuid().substring(authUser.getUuid().length() - 5)); // 使用微信 openid 作为用户名 user.setNickname("wx_" + authUser.getUuid().substring(authUser.getUuid().length() - 5)); user.setAvatar(authUser.getAvatar()); + user.setUserType(userType); user.setStatus(CommonStatusEnum.ENABLE.getStatus()); user.setPassword(encodePassword(authUser.getUuid().substring(authUser.getUuid().length() - 10))); // 随机密码 userMapper.insert(user); 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 index 0071d79..521f0e7 100644 --- 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 @@ -36,5 +36,6 @@ #{item} + order by e.create_time desc 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 70a9606..3ca9bd0 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 @@ -121,7 +121,7 @@