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/controller/admin/taskinfo/vo/TaskInfoPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoPageReqVO.java index 1e358c7..a80110b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoPageReqVO.java @@ -80,7 +80,7 @@ public class TaskInfoPageReqVO extends PageParam { */ @Schema(description = "任务标签集合", example = "1") - private List tagList; + private String tagList; @Schema(description = "按时间查询", example = "1") private Integer selectWeek; 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..d0cbd5f 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,6 +20,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; @@ -79,9 +80,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 +89,6 @@ public class HomeServiceImpl implements HomeService{ //根据不同的身份查询 final List homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); - List homeGroupCountVOS1 = new ArrayList<>(); if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { @@ -99,20 +96,63 @@ 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 sortCollect = homeGroupCountVOS1.stream(). - sorted(Comparator.comparing(HomeListVO::getValue).reversed()). - collect(Collectors.toList()); + //循环饼图占比数据 + + 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)); + } + }); - log.info("sortCollect:{}", sortCollect); - homeCountResVO.setCompletionRate(sortCollect); + + } + + + //排序 + final List sortedList = homeGroupCountVOS1.stream() + .filter(item -> item.getValue() != null && !item.getValue().isEmpty()) // 过滤掉 null 或空字符串 + .sorted(Comparator.comparing( + item -> { + try { + return Double.parseDouble(item.getValue()); // 将字符串转为 double + } catch (NumberFormatException e) { + return Double.MIN_VALUE; // 如果解析失败,视为最小值 + } + } + )) // 升序排序 + .collect(Collectors.toList()); + + if (sortedList != null && sortedList.size() > 0) { + List reversedList = new ArrayList<>(); + for (int i = sortedList.size() - 1; i >= 0; i--) { + reversedList.add(sortedList.get(i)); + } + homeCountResVO.setCompletionRate(reversedList); + } return homeCountResVO; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java index e54ca73..8694599 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java @@ -271,6 +271,15 @@ public class TaskInfoServiceImpl implements TaskInfoService { if (tagLibraryDOS1 != null && tagLibraryDOS1.size() > 0) { item.setTagList(tagLibraryDOS1.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList())); } + + //发布的部门 + if (item.getCreator() != null) { + final Long value = Long.valueOf(item.getCreator()); + final DeptDO deptDO = deptService.getByUserId(value); + item.setDeptName(deptDO.getName()); + } + + }); } 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..1d8ddee 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 @@ -18,8 +18,7 @@ left join enterprise_inspections ei on t.id = ei.task_id left join inspections_log il on ei.id = il.inspections_id left join enterprises e on e.id = ei.enterprise_id - left join task_tag tt on t.id = tt.task_id - left join tag_library tl on tl.id = tt.tag_id + left join tag_library tl on tl.id = t.task_type WHERE t.deleted = 0 and ei.deleted = 0 and ei.status = 2 @@ -38,10 +37,7 @@ AND t.end_date between #{params.startTime} and #{params.endTime} - AND tl.id in - - #{tagId} - + AND t.task_type = #{params.tagList} GROUP BY t.id ORDER BY t.create_time DESC @@ -121,7 +117,7 @@