From 57fed72081772d4e9bb8028ff5213280d82bf2f7 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Wed, 19 Feb 2025 09:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/home/HomeController.java | 8 +- .../admin/home/vo/HomeCountResVO.java | 6 +- .../admin/home/vo/HomeExecFinishVO.java | 13 +++ .../admin/home/vo/HomeGroupCountVO.java | 1 + .../controller/admin/home/vo/HomeListVO.java | 10 ++ .../admin/home/vo/HomeSelectVO.java | 11 +- .../dal/mysql/taskinfo/TaskInfoMapper.java | 9 ++ .../EnterpriseInspectionsServiceImpl.java | 4 +- .../system/service/home/HomeService.java | 5 +- .../system/service/home/HomeServiceImpl.java | 102 +++++++++--------- .../InspectionsLogServiceImpl.java | 2 - .../mapper/taskinfo/TaskInfoMapper.xml | 72 +++++++++++-- 12 files changed, 174 insertions(+), 69 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeExecFinishVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeListVO.java diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java index cfe6d56..7f131a2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.system.controller.admin.home; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import cn.iocoder.yudao.module.system.service.home.HomeService; @@ -14,6 +16,8 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - app首页统计") @@ -28,13 +32,15 @@ public class HomeController { @GetMapping("/appCount1") @Operation(summary = "app首页统计第一块") + @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 public CommonResult appCount1(HomeSelectVO homeSelectVO) { return success(homeService.appCount1(homeSelectVO)); } @GetMapping("/appCount2") @Operation(summary = "app首页统计第二块") - public CommonResult appCount2(HomeSelectVO homeSelectVO) { + @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 + public CommonResult> appCount2(HomeSelectVO homeSelectVO) { return success(homeService.appCount2(homeSelectVO)); } 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 ce64111..713d61d 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 @@ -8,7 +8,7 @@ import java.util.Map; @Data public class HomeCountResVO { //任务总数 - private Long taskCount; + private Integer taskCount; //执法总数 private Integer inspectionsCount; private Long enterpriseCount; @@ -16,9 +16,7 @@ public class HomeCountResVO { //总任务完成率 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/HomeExecFinishVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeExecFinishVO.java new file mode 100644 index 0000000..2e67e74 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeExecFinishVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.system.controller.admin.home.vo; + +import lombok.Data; + +@Data +public class HomeExecFinishVO { + //执法总数量 + private Integer execCount; + //完成总数量 + private Integer finishCount; + //任务总数量 + private Integer taskCount; +} 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 315c2ca..fcb96bc 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 @@ -8,4 +8,5 @@ public class HomeGroupCountVO { private String completionRate; private Integer execCount; private Integer finishCount; + 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/HomeListVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeListVO.java new file mode 100644 index 0000000..17f2228 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeListVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.system.controller.admin.home.vo; + +import lombok.Data; + +@Data +public class HomeListVO { + private String name; + private String pieValue; + private String value; +} 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 47d997b..490b348 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 @@ -1,20 +1,25 @@ package cn.iocoder.yudao.module.system.controller.admin.home.vo; import lombok.Data; + +import java.time.LocalDateTime; + /** 首页查询条件 **/ @Data public class HomeSelectVO { - //周期 取字典 private Integer selectWeek; - //部门 private Long deptId; - //类型 private Integer type; + //时间 + private LocalDateTime[] time; + //用户id + private Long userId; + } 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 b54ffa1..0de30ec 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 @@ -6,6 +6,7 @@ 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.HomeExecFinishVO; 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; @@ -68,9 +69,17 @@ public interface TaskInfoMapper extends BaseMapperX { //根据企业id查任务 IPage selectPageByEnterpriseId(Page page, @Param("reqVO") TaskInfoPageReqVO reqVO); + + //任务总数,执法总数, 完成总数 + List selectHomeExecFinish(HomeSelectVO homeSelectVO); + //分组统计 List selectHomeGroupCount(HomeSelectVO homeSelectVO); + //质检报告过期排序 List selectEnterpriseNum(HomeSelectVO homeSelectVO); + //整改次数排序 + List selectEnterpriseStatus(HomeSelectVO homeSelectVO); + } 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 fa0f290..01416e4 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 @@ -291,7 +291,9 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } final DeptDO dept = deptService.getDept(user.getDeptId()); - item.setDepartment(dept.getName()); + if (dept != null) { + item.setDepartment(dept.getName()); + } } else { //根据执法人员id 查询其所属部门 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java index 321d7f3..29f2938 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java @@ -1,10 +1,13 @@ package cn.iocoder.yudao.module.system.service.home; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; +import java.util.List; + public interface HomeService { HomeCountResVO appCount1(HomeSelectVO homeSelectVO); - HomeCountResVO appCount2(HomeSelectVO homeSelectVO); + List appCount2(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 308eb90..bb79033 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,10 +1,8 @@ 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.home.vo.*; 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; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; @@ -50,59 +48,35 @@ public class HomeServiceImpl implements HomeService{ //按时间查询 if (homeSelectVO.getSelectWeek() != null) { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime[] dateList = new LocalDateTime[2]; - - switch (homeSelectVO.getSelectWeek()) { - case 1: - dateList[0] = now.minusDays(3); // 三天前 - break; - case 2: - dateList[0] = now.minusWeeks(1); // 一周前 - break; - case 3: - dateList[0] = now.minusMonths(1); // 一月前 - break; - case 4: - dateList[0] = now.minusYears(1); // 一年前 - break; - } - dateList[1] = now; + final LocalDateTime[] weekDate = this.getWeekDate(homeSelectVO.getSelectWeek()); - enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, dateList[0], dateList[1]); + enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, weekDate[0], weekDate[1]); } - final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper); homeCountResVO.setEnterpriseCount(enterpriseCount); - TaskInfoPageReqVO taskInfoPageReqVO = new TaskInfoPageReqVO(); - if (homeSelectVO.getDeptId() != null) { - taskInfoPageReqVO.setDeptId(homeSelectVO.getDeptId()); - } + //查询任务和执法 - if (homeSelectVO.getSelectWeek() != null) { - taskInfoPageReqVO.setSelectWeek(homeSelectVO.getSelectWeek()); - } - - final PageResult taskInfoAppPage = taskInfoService.getTaskInfoAppPage(taskInfoPageReqVO); + final List homeExecFinishVOS = taskInfoMapper.selectHomeExecFinish(homeSelectVO); List taskExecList = new ArrayList<>(); List taskFinishList = new ArrayList<>(); - if (taskInfoAppPage != null && taskInfoAppPage.getList() != null && taskInfoAppPage.getList().size() > 0) { - taskInfoAppPage.getList().forEach(item->{ - taskExecList.add(item.getTaskExecNum()); - taskFinishList.add(item.getTaskFinishNum()); + if (homeExecFinishVOS != null && homeExecFinishVOS.size() > 0) { + homeExecFinishVOS.forEach(item->{ + taskExecList.add(item.getExecCount()); + taskFinishList.add(item.getFinishCount()); }); } + //任务总数 + homeCountResVO.setTaskCount(homeExecFinishVOS.size()); + //总数 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*100; homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); @@ -110,32 +84,62 @@ public class HomeServiceImpl implements HomeService{ homeCountResVO.setTaskCompletionRate("0.0"); } - homeCountResVO.setTaskCount(taskInfoAppPage.getTotal()); - //根据不同的身份查询 final List homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); - List homeGroupCountVOS1 = new ArrayList<>(); + List homeGroupCountVOS1 = new ArrayList<>(); if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { homeGroupCountVOS.forEach(item->{ - HomeGroupCountVO groupCountVO = new HomeGroupCountVO(); - groupCountVO.setName(item.getName()); + HomeListVO homeListVO = new HomeListVO(); + homeListVO.setName(item.getName()); + homeListVO.setValue(item.getCompletionRate()); double rate = (double) item.getFinishCount() /taskExec * 100; - groupCountVO.setCompletionRate(String.format("%.1f", rate)); - homeGroupCountVOS1.add(groupCountVO); + homeListVO.setPieValue(String.format("%.1f", rate)); + homeGroupCountVOS1.add(homeListVO); }); } - homeCountResVO.setCompletionRate(homeGroupCountVOS); - homeCountResVO.setTotalCompletionRate(homeGroupCountVOS1); + homeCountResVO.setCompletionRate(homeGroupCountVOS1); return homeCountResVO; } + public LocalDateTime[] getWeekDate(Integer selectWeek) { + //按时间查询 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime[] dateList = new LocalDateTime[2]; + + switch (selectWeek) { + case 1: + dateList[0] = now.minusDays(3); // 三天前 + break; + case 2: + dateList[0] = now.minusWeeks(1); // 一周前 + break; + case 3: + dateList[0] = now.minusMonths(1); // 一月前 + break; + case 4: + dateList[0] = now.minusYears(1); // 一年前 + break; + } + dateList[1] = now; + + return dateList; + + } + @Override - public HomeCountResVO appCount2(HomeSelectVO homeSelectVO) { + public List appCount2(HomeSelectVO homeSelectVO) { - return null; + if (homeSelectVO.getSelectWeek() != null) { + homeSelectVO.setTime(this.getWeekDate(homeSelectVO.getSelectWeek())); + } + if (homeSelectVO.getType() != null && homeSelectVO.getType() == 2) { + return taskInfoMapper.selectEnterpriseStatus(homeSelectVO); + } else { + return taskInfoMapper.selectEnterpriseNum(homeSelectVO); + } } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/inspectionslog/InspectionsLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/inspectionslog/InspectionsLogServiceImpl.java index 4313973..520deb1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/inspectionslog/InspectionsLogServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/inspectionslog/InspectionsLogServiceImpl.java @@ -185,8 +185,6 @@ public class InspectionsLogServiceImpl implements InspectionsLogService { inspectionsLogNew.setUserList(this.getInspectionsLogAppListVO(inspectionsLogNew.getId())); list.add(inspectionsLogNew); } - - } return list; 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 8bd21f5..7fa883f 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 @@ -12,7 +12,7 @@ + select - DATEDIFF(NOW(),expiry_date) AS overdueDays, - e.enterprises_name + DATEDIFF(NOW(),eq.expiry_date) AS count, + e.enterprises_name as name from enterprise_qualification eq LEFT JOIN enterprises e ON eq.enterprise_id = e.id WHERE e.deleted = 0 and eq.deleted = 0 AND expiry_date < NOW() - e.department_id = #{deptId} + and e.department_id = #{deptId} and eq.user_id = #{userId} - ORDER BY overdueDays DESC; + + and ei.create_time between + + #{i} + + + ORDER BY count DESC; + + + +