From d8fdb9b4a9ad749e217a628e463fe426ebe8f062 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Tue, 18 Feb 2025 11:36:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => admin}/home/HomeController.java | 19 ++++--- .../admin/home/vo/HomeCountResVO.java | 22 ++++++++ .../admin/home/vo/HomeGroupCountVO.java | 9 ++++ .../{ => admin}/home/vo/HomeSelectVO.java | 3 +- .../controller/home/vo/HomeCountResVO.java | 13 ----- .../dal/mysql/taskinfo/TaskInfoMapper.java | 5 +- .../system/job/TaskSendStartMessageJob.java | 21 +++++++- .../system/service/home/HomeService.java | 9 ++-- .../system/service/home/HomeServiceImpl.java | 53 ++++++++++++++++--- .../service/taskinfo/TaskInfoService.java | 2 +- .../service/taskinfo/TaskInfoServiceImpl.java | 14 ++--- .../mapper/taskinfo/TaskInfoMapper.xml | 30 +++++++++++ 12 files changed, 156 insertions(+), 44 deletions(-) rename yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/{ => admin}/home/HomeController.java (61%) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java rename yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/{ => admin}/home/vo/HomeSelectVO.java (72%) delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/HomeController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java similarity index 61% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/HomeController.java rename to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java index 8b2273c..cfe6d56 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/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,9 +1,8 @@ -package cn.iocoder.yudao.module.system.controller.home; +package cn.iocoder.yudao.module.system.controller.admin.home; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO; +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; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -14,11 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping; 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 = "管理后台 - 检查结果日志") +@Tag(name = "管理后台 - app首页统计") @RestController @RequestMapping("/system/home") @Validated @@ -30,9 +28,14 @@ public class HomeController { @GetMapping("/appCount1") @Operation(summary = "app首页统计第一块") -// @PreAuthorize("@ss.hasPermission('system:inspections-log:create')") - public CommonResult signInList(HomeSelectVO homeSelectVO) { + public CommonResult appCount1(HomeSelectVO homeSelectVO) { return success(homeService.appCount1(homeSelectVO)); } + @GetMapping("/appCount2") + @Operation(summary = "app首页统计第二块") + 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 new file mode 100644 index 0000000..1770dda --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.system.controller.admin.home.vo; + +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Data +public class HomeCountResVO { + //任务总数 + private Long taskCount; + //执法总数 + private Integer inspectionsCount; + private Long enterpriseCount; + + //总任务完成率 + private Double taskCompletionRate; + //各部门或个人任务完成率 + private List> completionRate; + + +} 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 new file mode 100644 index 0000000..d28a3c9 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.system.controller.admin.home.vo; + +import lombok.Data; + +@Data +public class HomeGroupCountVO { + private String groupName; + private Long count; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/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 similarity index 72% rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeSelectVO.java rename to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java index 4e147b7..66a7776 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/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,4 +1,4 @@ -package cn.iocoder.yudao.module.system.controller.home.vo; +package cn.iocoder.yudao.module.system.controller.admin.home.vo; import lombok.Data; /** @@ -13,4 +13,5 @@ public class HomeSelectVO { //部门 private Long deptId; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java deleted file mode 100644 index baf803b..0000000 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.yudao.module.system.controller.home.vo; - -import lombok.Data; - -@Data -public class HomeCountResVO { - //任务总数 - private Long taskCount; - //执法总数 - private Long inspectionsCount; - private Long enterpriseCount; - -} 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 fd36949..bb5ab36 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,8 @@ 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.HomeGroupCountVO; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; 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; @@ -65,6 +67,7 @@ public interface TaskInfoMapper extends BaseMapperX { //根据企业id查任务 IPage selectPageByEnterpriseId(Page page, @Param("reqVO") TaskInfoPageReqVO reqVO); - + //分组统计 + List selectHomeGroupCount(HomeSelectVO homeSelectVO); } 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 01ea879..d947615 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 @@ -6,7 +6,11 @@ import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoRespVO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; +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.service.taskinfo.TaskInfoService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; import org.redisson.executor.TasksService; import org.springframework.stereotype.Component; @@ -25,6 +29,8 @@ public class TaskSendStartMessageJob implements JobHandler { @Resource SocialClientApi socialClientApi; + @Resource + EnterpriseInspectionsMapper enterpriseInspectionsMapper; @Override public String execute(String param) throws Exception { @@ -51,8 +57,21 @@ public class TaskSendStartMessageJob implements JobHandler { catch (Exception e){ log.error("任务发送通知错误:",e.toString()); } - } + //执法任务更改状态 + if (beforeTaskInfoList != null && beforeTaskInfoList.size() > 0) { + beforeTaskInfoList.forEach(item->{ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, item.getId()); + List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); + if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size()>0){ + for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { + enterpriseInspectionsDO.setStatus(2); + } + } + enterpriseInspectionsMapper.updateBatch(enterpriseInspectionsDOList); + }); + } }); 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 4596bf9..321d7f3 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,11 +1,10 @@ package cn.iocoder.yudao.module.system.service.home; -import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO; - -import java.util.List; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; public interface HomeService { HomeCountResVO appCount1(HomeSelectVO homeSelectVO); + + HomeCountResVO 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 de66709..bd00ed2 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,24 +1,27 @@ package cn.iocoder.yudao.module.system.service.home; -import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.EnterprisePageReqVO; -import cn.iocoder.yudao.module.system.controller.admin.inspectionslog.vo.InspectionsLogAppListVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeCountResVO; -import cn.iocoder.yudao.module.system.controller.home.vo.HomeSelectVO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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; import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; import cn.iocoder.yudao.module.system.service.dept.DeptService; -import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; +@Slf4j @Service public class HomeServiceImpl implements HomeService{ @@ -73,12 +76,48 @@ public class HomeServiceImpl implements HomeService{ 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); + + 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()); + }); + } + //总数 + 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); + } else { + homeCountResVO.setTaskCompletionRate(0.0); + } -// taskInfoService.getTaskInfoAppPage() + homeCountResVO.setTaskCount(taskInfoAppPage.getTotal()); //根据不同的身份查询 + return homeCountResVO; + } + + @Override + public HomeCountResVO appCount2(HomeSelectVO homeSelectVO) { + return null; -// return List.of(); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java index 6d0cd1b..f10ecd3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java @@ -60,7 +60,7 @@ public interface TaskInfoService { //定时执行任务 void sendTask(Long taskId); - PageResult getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO); + PageResult getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO); PageResult appPageByEnterpriseId(TaskInfoPageReqVO pageReqVO); } 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 dd3f248..9f63fbe 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 @@ -115,7 +115,7 @@ public class TaskInfoServiceImpl implements TaskInfoService { inspection.setEnterpriseId(item); if (enterpriseDO.getUserId() != null) { - inspection.setCreator(enterpriseDO.getUserId().toString()); + inspection.setUserId(enterpriseDO.getUserId()); } list.add(inspection); @@ -321,12 +321,12 @@ public class TaskInfoServiceImpl implements TaskInfoService { }); } - //筛选出 TaskExecNum 为0的 - if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) { - final List collect = taskInfoDOPageResult.getList().stream().filter(res -> res.getTaskExecNum() > 0).collect(Collectors.toList()); - taskInfoDOPageResult.setList(collect); - taskInfoDOPageResult.setTotal(Long.valueOf(collect.size())); - } +// //筛选出 TaskExecNum 为0的 +// if (taskInfoDOPageResult.getList() != null && taskInfoDOPageResult.getList().size() > 0) { +// final List collect = taskInfoDOPageResult.getList().stream().filter(res -> res.getTaskExecNum() > 0).collect(Collectors.toList()); +// taskInfoDOPageResult.setList(collect); +// taskInfoDOPageResult.setTotal(Long.valueOf(collect.size())); +// } return taskInfoDOPageResult; } 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 3015678..ac1b19a 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,4 +56,34 @@ GROUP BY t.id ORDER BY t.create_time DESC + +