Browse Source

首页信息

master
DX 1 month ago
parent
commit
d8fdb9b4a9
  1. 19
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java
  2. 22
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java
  3. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java
  4. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java
  5. 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java
  6. 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java
  7. 21
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java
  8. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java
  9. 53
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java
  10. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java
  11. 14
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java
  12. 30
      yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

19
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/HomeController.java → 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<HomeCountResVO> signInList(HomeSelectVO homeSelectVO) {
public CommonResult<HomeCountResVO> appCount1(HomeSelectVO homeSelectVO) {
return success(homeService.appCount1(homeSelectVO));
}
@GetMapping("/appCount2")
@Operation(summary = "app首页统计第二块")
public CommonResult<HomeCountResVO> appCount2(HomeSelectVO homeSelectVO) {
return success(homeService.appCount2(homeSelectVO));
}
}

22
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<Map<String, String>> completionRate;
}

9
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;
}

3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeSelectVO.java → 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;
}

13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/home/vo/HomeCountResVO.java

@ -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;
}

5
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<TaskInfoDO> {
//根据企业id查任务
IPage<TaskInfoDO> selectPageByEnterpriseId(Page<TaskInfoDO> page, @Param("reqVO") TaskInfoPageReqVO reqVO);
//分组统计
List<HomeGroupCountVO> selectHomeGroupCount(HomeSelectVO homeSelectVO);
}

21
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<EnterpriseInspectionsDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EnterpriseInspectionsDO::getTaskId, item.getId());
List<EnterpriseInspectionsDO> enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper);
if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size()>0){
for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) {
enterpriseInspectionsDO.setStatus(2);
}
}
enterpriseInspectionsMapper.updateBatch(enterpriseInspectionsDOList);
});
}
});

9
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);
}

53
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<TaskInfoDO> taskInfoAppPage = taskInfoService.getTaskInfoAppPage(taskInfoPageReqVO);
List<Integer> taskExecList = new ArrayList<>();
List<Integer> 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();
}
}

2
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<TaskInfoDO> getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO);
PageResult<TaskInfoDO> getTaskInfoAppPage(TaskInfoPageReqVO pageReqVO);
PageResult<TaskInfoDO> appPageByEnterpriseId(TaskInfoPageReqVO pageReqVO);
}

14
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<TaskInfoDO> 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<TaskInfoDO> collect = taskInfoDOPageResult.getList().stream().filter(res -> res.getTaskExecNum() > 0).collect(Collectors.toList());
// taskInfoDOPageResult.setList(collect);
// taskInfoDOPageResult.setTotal(Long.valueOf(collect.size()));
// }
return taskInfoDOPageResult;
}

30
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
</select>
<select id="selectHomeGroupCount"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO">
SELECT
<if test="deptId != null and deptId != ''">
ei.user_id,
COUNT(ei.user_id) AS total_count
</if>
<if test="deptId == null">
e.department_id,
COUNT(e.department_id) AS total_count
</if>
FROM
enterprise_inspections ei
LEFT JOIN
enterprises e ON e.id = ei.enterprise_id
WHERE
ei.deleted = 0 AND e.deleted = 0
<if test="deptId != null and deptId != ''">
and e.department_id = #{deptId}
</if>
GROUP BY
<if test="deptId != null and deptId != ''">
ei.user_id
</if>
<if test="deptId == null">
e.department_id
</if>
</select>
</mapper>

Loading…
Cancel
Save