Browse Source

首页统计, 任务修改

master
DX 1 month ago
parent
commit
a06ae5545e
  1. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsSaveReqVO.java
  2. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/EnterpriseNumVO.java
  3. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java
  4. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java
  5. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java
  6. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java
  7. 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java
  8. 26
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java
  9. 48
      yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

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

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

6
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<Map<String, String>> completionRate;
private List<HomeGroupCountVO> completionRate;
//各部门或个人任务完成率 占总数的百分百
private List<HomeGroupCountVO> totalCompletionRate;
}

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

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

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

3
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<TaskInfoDO> {
//分组统计
List<HomeGroupCountVO> selectHomeGroupCount(HomeSelectVO homeSelectVO);
List<EnterpriseNumVO> selectEnterpriseNum(HomeSelectVO homeSelectVO);
}

26
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<HomeGroupCountVO> homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO);
List<HomeGroupCountVO> 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;
}

48
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>
<select id="selectHomeGroupCount"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO">
<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>
<if test="deptId != null and deptId != ''">
su.`real_name` as name,
</if>
<if test="deptId == null">
sd.`name` as name,
</if>
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
<if test="deptId != null and deptId != ''">
left Join system_users su on su.id = ei.user_id
</if>
<if test="deptId == null">
left Join system_dept sd on sd.id = e.department_id
</if>
WHERE
ei.deleted = 0 AND e.deleted = 0
<if test="deptId != null and deptId != ''">
@ -85,5 +95,23 @@
</if>
</select>
<select id="selectEnterpriseNum"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO">
select
DATEDIFF(NOW(),expiry_date) AS overdueDays,
e.enterprises_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 &lt; NOW()
<if test="deptId != null and deptId != ''">
e.department_id = #{deptId}
</if>
<if test="userId != null and userId != ''">
and eq.user_id = #{userId}
</if>
ORDER BY overdueDays DESC;
</select>
</mapper>

Loading…
Cancel
Save