From a06ae5545eb93546d9b26aaf289e7dcb585b7460 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 18 Feb 2025 15:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1,=20?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/EnterpriseInspectionsSaveReqVO.java | 3 ++ .../admin/home/vo/EnterpriseNumVO.java | 9 ++++ .../admin/home/vo/HomeCountResVO.java | 6 ++- .../admin/home/vo/HomeGroupCountVO.java | 6 ++- .../admin/home/vo/HomeSelectVO.java | 3 ++ .../admin/taskinfo/TaskInfoController.java | 6 +++ .../dal/mysql/taskinfo/TaskInfoMapper.java | 3 ++ .../system/service/home/HomeServiceImpl.java | 26 ++++++++-- .../mapper/taskinfo/TaskInfoMapper.xml | 48 +++++++++++++++---- 9 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/EnterpriseNumVO.java diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java index 88375d5..ab40e8d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java @@ -17,4 +17,7 @@ public class EnterpriseInspectionsSaveReqVO { @Schema(description = "企业ID", example = "27002") private Long enterpriseId; + @Schema(description = "用户ID", example = "27002") + private Long userId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/EnterpriseNumVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/EnterpriseNumVO.java new file mode 100644 index 0000000..12e4ec8 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/EnterpriseNumVO.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.system.controller.admin.home.vo; + +import lombok.Data; + +@Data +public class EnterpriseNumVO { + private String name; + private Integer count; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java index 1770dda..ce64111 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java @@ -14,9 +14,11 @@ public class HomeCountResVO { private Long enterpriseCount; //总任务完成率 - private Double taskCompletionRate; + private String taskCompletionRate; //各部门或个人任务完成率 - private List> completionRate; + private List completionRate; + //各部门或个人任务完成率 占总数的百分百 + private List totalCompletionRate; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java index d28a3c9..315c2ca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java @@ -4,6 +4,8 @@ import lombok.Data; @Data public class HomeGroupCountVO { - private String groupName; - private Long count; + private String name; + private String completionRate; + private Integer execCount; + private Integer finishCount; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java index 66a7776..47d997b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java @@ -14,4 +14,7 @@ public class HomeSelectVO { //部门 private Long deptId; + //类型 + private Integer type; + } 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 c4e6c7e..21fc787 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 @@ -97,6 +97,12 @@ public class TaskInfoController { for(Long enterprise:eid) { enterpriseInspectionsSaveReqVO.setTaskId(updateReqVO.getId()); enterpriseInspectionsSaveReqVO.setEnterpriseId(enterprise); + + final EnterpriseDO enterprise1 = enterpriseService.getEnterprise(enterprise); + if (enterprise1 != null) { + enterpriseInspectionsSaveReqVO.setUserId(enterprise1.getUserId()); + } + if(del>0){ enterpriseInspectionsService.createEnterpriseInspections(enterpriseInspectionsSaveReqVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java index bb5ab36..b54ffa1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java @@ -5,6 +5,7 @@ import java.util.*; 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.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; @@ -70,4 +71,6 @@ public interface TaskInfoMapper extends BaseMapperX { //分组统计 List selectHomeGroupCount(HomeSelectVO homeSelectVO); + List selectEnterpriseNum(HomeSelectVO homeSelectVO); + } 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 bd00ed2..308eb90 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.service.home; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO; import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; @@ -30,7 +31,6 @@ public class HomeServiceImpl implements HomeService{ @Resource private TaskInfoService taskInfoService; - @Resource private TaskInfoMapper taskInfoMapper; @Resource @@ -95,22 +95,40 @@ public class HomeServiceImpl implements HomeService{ taskFinishList.add(item.getTaskFinishNum()); }); } + //总数 final Integer taskExec = taskExecList.stream().reduce(Integer::sum).orElse(0); homeCountResVO.setInspectionsCount(taskExec); //完成数 final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); + if (taskFinish != null && taskFinish != 0) { - double taskCompletionRate = (double) taskFinish/taskExec; - homeCountResVO.setTaskCompletionRate(taskCompletionRate); + double taskCompletionRate = (double) taskFinish/taskExec*100; + homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); } else { - homeCountResVO.setTaskCompletionRate(0.0); + homeCountResVO.setTaskCompletionRate("0.0"); } homeCountResVO.setTaskCount(taskInfoAppPage.getTotal()); //根据不同的身份查询 + final List homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); + + List homeGroupCountVOS1 = new ArrayList<>(); + + if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { + homeGroupCountVOS.forEach(item->{ + HomeGroupCountVO groupCountVO = new HomeGroupCountVO(); + groupCountVO.setName(item.getName()); + double rate = (double) item.getFinishCount() /taskExec * 100; + groupCountVO.setCompletionRate(String.format("%.1f", rate)); + homeGroupCountVOS1.add(groupCountVO); + }); + } + + homeCountResVO.setCompletionRate(homeGroupCountVOS); + homeCountResVO.setTotalCompletionRate(homeGroupCountVOS1); return homeCountResVO; } 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 ac1b19a..8bd21f5 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 @@ -56,21 +56,31 @@ GROUP BY t.id ORDER BY t.create_time DESC - SELECT - - ei.user_id, - COUNT(ei.user_id) AS total_count - - - e.department_id, - COUNT(e.department_id) AS total_count - + + su.`real_name` as name, + + + sd.`name` as name, + + SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) as finishCount, + COUNT(DISTINCT ei.id) as execCount, + COUNT(DISTINCT ei.id) AS total_count , -- 计算每个 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 LEFT JOIN enterprises e ON e.id = ei.enterprise_id + LEFT JOIN + inspections_log il ON ei.id = il.inspections_id + + left Join system_users su on su.id = ei.user_id + + + left Join system_dept sd on sd.id = e.department_id + WHERE ei.deleted = 0 AND e.deleted = 0 @@ -85,5 +95,23 @@ +