Browse Source

首页统计

master
DX 1 month ago
parent
commit
57fed72081
  1. 8
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java
  2. 6
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java
  3. 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeExecFinishVO.java
  4. 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeGroupCountVO.java
  5. 10
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeListVO.java
  6. 11
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java
  7. 9
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java
  8. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java
  9. 5
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java
  10. 102
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java
  11. 2
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/inspectionslog/InspectionsLogServiceImpl.java
  12. 72
      yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

8
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; package cn.iocoder.yudao.module.system.controller.admin.home;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.HomeCountResVO;
import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO;
import cn.iocoder.yudao.module.system.service.home.HomeService; 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 javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - app首页统计") @Tag(name = "管理后台 - app首页统计")
@ -28,13 +32,15 @@ public class HomeController {
@GetMapping("/appCount1") @GetMapping("/appCount1")
@Operation(summary = "app首页统计第一块") @Operation(summary = "app首页统计第一块")
@DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。
public CommonResult<HomeCountResVO> appCount1(HomeSelectVO homeSelectVO) { public CommonResult<HomeCountResVO> appCount1(HomeSelectVO homeSelectVO) {
return success(homeService.appCount1(homeSelectVO)); return success(homeService.appCount1(homeSelectVO));
} }
@GetMapping("/appCount2") @GetMapping("/appCount2")
@Operation(summary = "app首页统计第二块") @Operation(summary = "app首页统计第二块")
public CommonResult<HomeCountResVO> appCount2(HomeSelectVO homeSelectVO) { @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。
public CommonResult<List<EnterpriseNumVO>> appCount2(HomeSelectVO homeSelectVO) {
return success(homeService.appCount2(homeSelectVO)); return success(homeService.appCount2(homeSelectVO));
} }

6
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 @Data
public class HomeCountResVO { public class HomeCountResVO {
//任务总数 //任务总数
private Long taskCount; private Integer taskCount;
//执法总数 //执法总数
private Integer inspectionsCount; private Integer inspectionsCount;
private Long enterpriseCount; private Long enterpriseCount;
@ -16,9 +16,7 @@ public class HomeCountResVO {
//总任务完成率 //总任务完成率
private String taskCompletionRate; private String taskCompletionRate;
//各部门或个人任务完成率 //各部门或个人任务完成率
private List<HomeGroupCountVO> completionRate; private List<HomeListVO> completionRate;
//各部门或个人任务完成率 占总数的百分百
private List<HomeGroupCountVO> totalCompletionRate;
} }

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

1
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 String completionRate;
private Integer execCount; private Integer execCount;
private Integer finishCount; private Integer finishCount;
private Long userId;
} }

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

11
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; package cn.iocoder.yudao.module.system.controller.admin.home.vo;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
/** /**
首页查询条件 首页查询条件
**/ **/
@Data @Data
public class HomeSelectVO { public class HomeSelectVO {
//周期 取字典 //周期 取字典
private Integer selectWeek; private Integer selectWeek;
//部门 //部门
private Long deptId; private Long deptId;
//类型 //类型
private Integer type; private Integer type;
//时间
private LocalDateTime[] time;
//用户id
private Long userId;
} }

9
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.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.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.HomeGroupCountVO;
import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO;
import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO;
@ -68,9 +69,17 @@ public interface TaskInfoMapper extends BaseMapperX<TaskInfoDO> {
//根据企业id查任务 //根据企业id查任务
IPage<TaskInfoDO> selectPageByEnterpriseId(Page<TaskInfoDO> page, @Param("reqVO") TaskInfoPageReqVO reqVO); IPage<TaskInfoDO> selectPageByEnterpriseId(Page<TaskInfoDO> page, @Param("reqVO") TaskInfoPageReqVO reqVO);
//任务总数,执法总数, 完成总数
List<HomeExecFinishVO> selectHomeExecFinish(HomeSelectVO homeSelectVO);
//分组统计 //分组统计
List<HomeGroupCountVO> selectHomeGroupCount(HomeSelectVO homeSelectVO); List<HomeGroupCountVO> selectHomeGroupCount(HomeSelectVO homeSelectVO);
//质检报告过期排序
List<EnterpriseNumVO> selectEnterpriseNum(HomeSelectVO homeSelectVO); List<EnterpriseNumVO> selectEnterpriseNum(HomeSelectVO homeSelectVO);
//整改次数排序
List<EnterpriseNumVO> selectEnterpriseStatus(HomeSelectVO homeSelectVO);
} }

4
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()); final DeptDO dept = deptService.getDept(user.getDeptId());
item.setDepartment(dept.getName()); if (dept != null) {
item.setDepartment(dept.getName());
}
} else { } else {
//根据执法人员id 查询其所属部门 //根据执法人员id 查询其所属部门

5
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; 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.HomeCountResVO;
import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO;
import java.util.List;
public interface HomeService { public interface HomeService {
HomeCountResVO appCount1(HomeSelectVO homeSelectVO); HomeCountResVO appCount1(HomeSelectVO homeSelectVO);
HomeCountResVO appCount2(HomeSelectVO homeSelectVO); List<EnterpriseNumVO> appCount2(HomeSelectVO homeSelectVO);
} }

102
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; package cn.iocoder.yudao.module.system.service.home;
import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.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.enterprise.EnterpriseDO;
import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; 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.enterprise.EnterpriseMapper;
@ -50,59 +48,35 @@ public class HomeServiceImpl implements HomeService{
//按时间查询 //按时间查询
if (homeSelectVO.getSelectWeek() != null) { if (homeSelectVO.getSelectWeek() != null) {
LocalDateTime now = LocalDateTime.now(); final LocalDateTime[] weekDate = this.getWeekDate(homeSelectVO.getSelectWeek());
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;
enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, dateList[0], dateList[1]); enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, weekDate[0], weekDate[1]);
} }
final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper); final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper);
homeCountResVO.setEnterpriseCount(enterpriseCount); homeCountResVO.setEnterpriseCount(enterpriseCount);
TaskInfoPageReqVO taskInfoPageReqVO = new TaskInfoPageReqVO(); //查询任务和执法
if (homeSelectVO.getDeptId() != null) {
taskInfoPageReqVO.setDeptId(homeSelectVO.getDeptId());
}
if (homeSelectVO.getSelectWeek() != null) { final List<HomeExecFinishVO> homeExecFinishVOS = taskInfoMapper.selectHomeExecFinish(homeSelectVO);
taskInfoPageReqVO.setSelectWeek(homeSelectVO.getSelectWeek());
}
final PageResult<TaskInfoDO> taskInfoAppPage = taskInfoService.getTaskInfoAppPage(taskInfoPageReqVO);
List<Integer> taskExecList = new ArrayList<>(); List<Integer> taskExecList = new ArrayList<>();
List<Integer> taskFinishList = new ArrayList<>(); List<Integer> taskFinishList = new ArrayList<>();
if (taskInfoAppPage != null && taskInfoAppPage.getList() != null && taskInfoAppPage.getList().size() > 0) { if (homeExecFinishVOS != null && homeExecFinishVOS.size() > 0) {
taskInfoAppPage.getList().forEach(item->{ homeExecFinishVOS.forEach(item->{
taskExecList.add(item.getTaskExecNum()); taskExecList.add(item.getExecCount());
taskFinishList.add(item.getTaskFinishNum()); taskFinishList.add(item.getFinishCount());
}); });
} }
//任务总数
homeCountResVO.setTaskCount(homeExecFinishVOS.size());
//总数 //总数
final Integer taskExec = taskExecList.stream().reduce(Integer::sum).orElse(0); final Integer taskExec = taskExecList.stream().reduce(Integer::sum).orElse(0);
homeCountResVO.setInspectionsCount(taskExec); homeCountResVO.setInspectionsCount(taskExec);
//完成数 //完成数
final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0);
if (taskFinish != null && taskFinish != 0) { if (taskFinish != null && taskFinish != 0) {
double taskCompletionRate = (double) taskFinish/taskExec*100; double taskCompletionRate = (double) taskFinish/taskExec*100;
homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate));
@ -110,32 +84,62 @@ public class HomeServiceImpl implements HomeService{
homeCountResVO.setTaskCompletionRate("0.0"); homeCountResVO.setTaskCompletionRate("0.0");
} }
homeCountResVO.setTaskCount(taskInfoAppPage.getTotal());
//根据不同的身份查询 //根据不同的身份查询
final List<HomeGroupCountVO> homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); final List<HomeGroupCountVO> homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO);
List<HomeGroupCountVO> homeGroupCountVOS1 = new ArrayList<>(); List<HomeListVO> homeGroupCountVOS1 = new ArrayList<>();
if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) {
homeGroupCountVOS.forEach(item->{ homeGroupCountVOS.forEach(item->{
HomeGroupCountVO groupCountVO = new HomeGroupCountVO(); HomeListVO homeListVO = new HomeListVO();
groupCountVO.setName(item.getName()); homeListVO.setName(item.getName());
homeListVO.setValue(item.getCompletionRate());
double rate = (double) item.getFinishCount() /taskExec * 100; double rate = (double) item.getFinishCount() /taskExec * 100;
groupCountVO.setCompletionRate(String.format("%.1f", rate)); homeListVO.setPieValue(String.format("%.1f", rate));
homeGroupCountVOS1.add(groupCountVO); homeGroupCountVOS1.add(homeListVO);
}); });
} }
homeCountResVO.setCompletionRate(homeGroupCountVOS); homeCountResVO.setCompletionRate(homeGroupCountVOS1);
homeCountResVO.setTotalCompletionRate(homeGroupCountVOS1);
return homeCountResVO; 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 @Override
public HomeCountResVO appCount2(HomeSelectVO homeSelectVO) { public List<EnterpriseNumVO> 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);
}
} }
} }

2
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())); inspectionsLogNew.setUserList(this.getInspectionsLogAppListVO(inspectionsLogNew.getId()));
list.add(inspectionsLogNew); list.add(inspectionsLogNew);
} }
} }
return list; return list;

72
yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml

@ -12,7 +12,7 @@
<select id="selectMyPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO"> <select id="selectMyPage" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO">
SELECT SELECT
t.*, t.*,
count(ei.task_id) as taskExecNum, count(DISTINCT ei.id) as taskExecNum,
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS taskFinishNum SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS taskFinishNum
FROM task_info t FROM task_info t
left join enterprise_inspections ei on t.id = ei.task_id left join enterprise_inspections ei on t.id = ei.task_id
@ -21,7 +21,7 @@
left join task_tag tt on t.id = tt.task_id left join task_tag tt on t.id = tt.task_id
left join tag_library tl on tl.id = tt.tag_id left join tag_library tl on tl.id = tt.tag_id
WHERE WHERE
t.deleted = 0 and ei.deleted = 0 and t.status = 2 t.deleted = 0 and ei.deleted = 0 and ei.status = 2
<if test="params.userId != null and params.userId != ''"> <if test="params.userId != null and params.userId != ''">
AND ei.user_id = #{params.userId} AND ei.user_id = #{params.userId}
</if> </if>
@ -43,9 +43,10 @@
#{tagId} #{tagId}
</foreach> </foreach>
</if> </if>
GROUP BY t.id GROUP BY t.id ORDER BY t.create_time DESC
</select> </select>
<select id="selectPageByEnterpriseId" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO"> <select id="selectPageByEnterpriseId" resultType="cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO">
SELECT SELECT
t.* t.*
@ -82,7 +83,7 @@
left Join system_dept sd on sd.id = e.department_id left Join system_dept sd on sd.id = e.department_id
</if> </if>
WHERE WHERE
ei.deleted = 0 AND e.deleted = 0 ei.deleted = 0 AND e.deleted = 0 and ei.status = 2
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">
and e.department_id = #{deptId} and e.department_id = #{deptId}
</if> </if>
@ -98,20 +99,75 @@
<select id="selectEnterpriseNum" <select id="selectEnterpriseNum"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO"> resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO">
select select
DATEDIFF(NOW(),expiry_date) AS overdueDays, DATEDIFF(NOW(),eq.expiry_date) AS count,
e.enterprises_name e.enterprises_name as name
from from
enterprise_qualification eq enterprise_qualification eq
LEFT JOIN enterprises e ON eq.enterprise_id = e.id LEFT JOIN enterprises e ON eq.enterprise_id = e.id
WHERE WHERE
e.deleted = 0 and eq.deleted = 0 AND expiry_date &lt; NOW() e.deleted = 0 and eq.deleted = 0 AND expiry_date &lt; NOW()
<if test="deptId != null and deptId != ''"> <if test="deptId != null and deptId != ''">
e.department_id = #{deptId} and e.department_id = #{deptId}
</if> </if>
<if test="userId != null and userId != ''"> <if test="userId != null and userId != ''">
and eq.user_id = #{userId} and eq.user_id = #{userId}
</if> </if>
ORDER BY overdueDays DESC; <if test="time != null and time != ''">
and ei.create_time between
<foreach collection="time" item="i" open="" separator="and" close="">
#{i}
</foreach>
</if>
ORDER BY count DESC;
</select>
<select id="selectEnterpriseStatus"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO">
SELECT
DISTINCT e.enterprises_name as name,
sum(CASE WHEN il.status=3 THEN 1 ELSE 0 END) as count
FROM
enterprise_inspections ei
LEFT JOIN inspections_log il on il.inspections_id = ei.id
LEFT JOIN enterprises e ON e.id = ei.enterprise_id
<where>
ei.deleted = 0 and il.status = 3
<if test="deptId != null and deptId != ''">
and e.department_id = #{deptId}
</if>
<if test="time != null and time != ''">
and ei.create_time between
<foreach collection="time" item="i" open="" separator="and" close="">
#{i}
</foreach>
</if>
</where>
GROUP BY ei.id order by count desc;
</select>
<select id="selectHomeExecFinish"
resultType="cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeExecFinishVO">
SELECT
count( DISTINCT ei.id) as execCount,
SUM(CASE WHEN il.status = 2 THEN 1 ELSE 0 END) AS finishCount
FROM task_info t
left join enterprise_inspections ei on t.id = ei.task_id
left join inspections_log il on ei.id = il.inspections_id
left join enterprises e on e.id = ei.enterprise_id
left join task_tag tt on t.id = tt.task_id
left join tag_library tl on tl.id = tt.tag_id
WHERE
t.deleted = 0 and ei.deleted = 0 and ei.status = 2
<if test="deptId != null and deptId != ''">
and e.department_id = #{deptId}
</if>
<if test="time != null and time != ''">
and t.end_date between
<foreach collection="time" item="i" open="" separator="and" close="">
#{i}
</foreach>
</if>
GROUP By t.id
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save