Browse Source

提交:部门下分组

mine
袁强 5 months ago
parent
commit
d1cff7e7ca
  1. 10
      yq-admin/src/main/java/yq/web/controller/mine/MineWarningController.java
  2. 6
      yq-system/src/main/java/yq/system/domain/MineFace.java
  3. 2
      yq-system/src/main/java/yq/system/domain/MineGroup.java
  4. 5
      yq-system/src/main/java/yq/system/domain/MineHealth.java
  5. 9
      yq-system/src/main/java/yq/system/domain/MineWarning.java
  6. 28
      yq-system/src/main/java/yq/system/domain/vo/NormalCountVo.java
  7. 2
      yq-system/src/main/java/yq/system/domain/vo/StatisticVo.java
  8. 3
      yq-system/src/main/java/yq/system/mapper/MineWarningMapper.java
  9. 2
      yq-system/src/main/java/yq/system/service/IMineWarningService.java
  10. 5
      yq-system/src/main/java/yq/system/service/impl/MineWarningServiceImpl.java
  11. 21
      yq-system/src/main/resources/mapper/system/MineFaceMapper.xml
  12. 1
      yq-system/src/main/resources/mapper/system/MineGroupMapper.xml
  13. 13
      yq-system/src/main/resources/mapper/system/MineHealthMapper.xml
  14. 78
      yq-system/src/main/resources/mapper/system/MineWarningMapper.xml

10
yq-admin/src/main/java/yq/web/controller/mine/MineWarningController.java

@ -20,6 +20,7 @@ import yq.common.enums.BusinessType;
import yq.system.domain.MineWarning; import yq.system.domain.MineWarning;
import yq.system.domain.vo.NormalCountVo;
import yq.system.domain.vo.StatisticVo; import yq.system.domain.vo.StatisticVo;
import yq.system.service.IMineWarningService; import yq.system.service.IMineWarningService;
import yq.common.utils.poi.ExcelUtil; import yq.common.utils.poi.ExcelUtil;
@ -83,7 +84,16 @@ public class MineWarningController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
/**
* 异常正常所占比
*/
@PreAuthorize("@ss.hasPermi('earlywarning:druid:list')")
@GetMapping("/normal/list")
public TableDataInfo normalList(MineWarning mineWarning){
List<NormalCountVo> list = mineWarningService.selectMineWarningNormalList(mineWarning);
return getDataTable(list);
}
/** /**

6
yq-system/src/main/java/yq/system/domain/MineFace.java

@ -31,8 +31,6 @@ public class MineFace
@Excel(name = "姓名") @Excel(name = "姓名")
private String faceName; private String faceName;
@Excel(name = "组名")
private String mineGroupName;
@Excel(name = "年龄") @Excel(name = "年龄")
private Long age; private Long age;
@ -70,8 +68,10 @@ public class MineFace
@NotNull(message = "未选择部门") @NotNull(message = "未选择部门")
private Long deptId; private Long deptId;
private String deptIdStr;
/** 组名 */ /** 组名 */
@Excel(name = "部门名称") @Excel(name = "所属部门")
private String deptName; private String deptName;
} }

2
yq-system/src/main/java/yq/system/domain/MineGroup.java

@ -39,7 +39,7 @@ public class MineGroup {
private Long deptId; private Long deptId;
/** 组名 */ /** 组名 */
@Excel(name = "部门名称") @Excel(name = "所属部门")
private String deptName; private String deptName;
} }

5
yq-system/src/main/java/yq/system/domain/MineHealth.java

@ -31,8 +31,7 @@ public class MineHealth {
private String facePhone; private String facePhone;
@Excel(name = "组名")
private String mineGroupName;
@Excel(name = "高压") @Excel(name = "高压")
private Integer bpHigh; private Integer bpHigh;
@ -62,7 +61,7 @@ public class MineHealth {
private Long deptId; private Long deptId;
/** 组名 */ /** 组名 */
@Excel(name = "部门名称") @Excel(name = "所属部门")
private String deptName; private String deptName;

9
yq-system/src/main/java/yq/system/domain/MineWarning.java

@ -74,11 +74,12 @@ public class MineWarning {
@Excel(name = "手机号") @Excel(name = "手机号")
private String facePhone; private String facePhone;
@NotNull(message = "未选择分组")
private Long groupId;
@Excel(name = "组名") private Long deptId;
private String mineGroupName;
/** 组名 */
@Excel(name = "所属部门")
private String deptName;
private String deptIdStr; private String deptIdStr;
private Long userId; private Long userId;

28
yq-system/src/main/java/yq/system/domain/vo/NormalCountVo.java

@ -0,0 +1,28 @@
package yq.system.domain.vo;
import lombok.Data;
/**
* @auther yq
* @data 2025/1/10
*/
@Data
public class NormalCountVo {
//部门名称
private String deptName;
//正常人数(打卡次数为1
private Integer normalCount;
// 异常人数(打卡次数不为1
private Integer abnormalCount;
//小组总人数
private Integer totalCount;
//正常人数占比
private double normalPercentage;
//异常人数占
private double abnormalPercentage ;
//异常名单
private String abnormalNmaes;
}

2
yq-system/src/main/java/yq/system/domain/vo/StatisticVo.java

@ -12,7 +12,7 @@ public class StatisticVo {
private String mineGroupName; private String deptName;
private Integer clock; private Integer clock;
private Integer unClock; private Integer unClock;
private String unClockNames; private String unClockNames;

3
yq-system/src/main/java/yq/system/mapper/MineWarningMapper.java

@ -3,6 +3,7 @@ package yq.system.mapper;
import java.util.List; import java.util.List;
import yq.system.domain.MineWarning; import yq.system.domain.MineWarning;
import yq.system.domain.vo.MineWarningVo; import yq.system.domain.vo.MineWarningVo;
import yq.system.domain.vo.NormalCountVo;
import yq.system.domain.vo.StatisticVo; import yq.system.domain.vo.StatisticVo;
/** /**
@ -35,7 +36,7 @@ public interface MineWarningMapper
public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning); public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning);
public List<NormalCountVo> selectMineWarningNormalList(MineWarning mineWarning);
public List<MineWarning> selectMineWarningListOne(MineWarning mineWarning); public List<MineWarning> selectMineWarningListOne(MineWarning mineWarning);
/** /**

2
yq-system/src/main/java/yq/system/service/IMineWarningService.java

@ -3,6 +3,7 @@ package yq.system.service;
import java.util.List; import java.util.List;
import yq.system.domain.MineWarning; import yq.system.domain.MineWarning;
import yq.system.domain.vo.MineWarningVo; import yq.system.domain.vo.MineWarningVo;
import yq.system.domain.vo.NormalCountVo;
import yq.system.domain.vo.StatisticVo; import yq.system.domain.vo.StatisticVo;
/** /**
@ -47,6 +48,7 @@ public interface IMineWarningService
*/ */
public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning); public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning);
public List<NormalCountVo> selectMineWarningNormalList(MineWarning mineWarning);
/** /**

5
yq-system/src/main/java/yq/system/service/impl/MineWarningServiceImpl.java

@ -14,6 +14,7 @@ import yq.common.utils.SecurityUtils;
import yq.system.domain.MineFace; import yq.system.domain.MineFace;
import yq.system.domain.MineWarning; import yq.system.domain.MineWarning;
import yq.system.domain.vo.MineWarningVo; import yq.system.domain.vo.MineWarningVo;
import yq.system.domain.vo.NormalCountVo;
import yq.system.domain.vo.StatisticVo; import yq.system.domain.vo.StatisticVo;
import yq.system.mapper.MineFaceMapper; import yq.system.mapper.MineFaceMapper;
import yq.system.mapper.MineWarningMapper; import yq.system.mapper.MineWarningMapper;
@ -77,6 +78,10 @@ public class MineWarningServiceImpl implements IMineWarningService
public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning) { public List<StatisticVo> selectMineWarningStatisticList(MineWarning mineWarning) {
return mineWarningMapper.selectMineWarningStatisticList(mineWarning); return mineWarningMapper.selectMineWarningStatisticList(mineWarning);
} }
@Override
public List<NormalCountVo> selectMineWarningNormalList(MineWarning mineWarning) {
return mineWarningMapper.selectMineWarningNormalList(mineWarning);
}
/** /**
* 新增请填写功能名称 * 新增请填写功能名称

21
yq-system/src/main/resources/mapper/system/MineFaceMapper.xml

@ -15,17 +15,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="isWork" column="is_work" /> <result property="isWork" column="is_work" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="groupId" column="group_id" />
<result property="mineGroupName" column="mine_group_name" />
<result property="useTime" column="use_time" /> <result property="useTime" column="use_time" />
<result property="faceByte" column="face_byte" /> <result property="faceByte" column="face_byte" />
</resultMap> </resultMap>
<sql id="selectMineFaceVo"> <sql id="selectMineFaceVo">
select mf.id, mf.face_name,mg.dept_id,d.dept_name, mf.age, mf.face_phone, mf.face_url, mf.is_work, mf.remark, mf.create_time,mf.use_time, mf.group_id ,mg.mine_group_name select mf.id, mf.face_name, mf.age, mf.face_phone, mf.face_url,
mf.is_work, mf.remark, mf.create_time,mf.use_time,mf.dept_id,d.dept_name
from mine_face mf from mine_face mf
inner join mine_group mg on mg.id =mf.group_id inner join sys_dept d on mf.dept_id = d.dept_id
inner join sys_dept d on mg.dept_id = d.dept_id
</sql> </sql>
<select id="selectMineFaceList" parameterType="MineFace" resultMap="MineFaceResult"> <select id="selectMineFaceList" parameterType="MineFace" resultMap="MineFaceResult">
@ -37,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="facePhone != null and facePhone != ''"> and mf.face_phone = #{facePhone}</if> <if test="facePhone != null and facePhone != ''"> and mf.face_phone = #{facePhone}</if>
<if test="faceUrl != null and faceUrl != ''"> and mf.face_url = #{faceUrl}</if> <if test="faceUrl != null and faceUrl != ''"> and mf.face_url = #{faceUrl}</if>
<if test="isWork != null "> and mf.is_work = #{isWork}</if> <if test="isWork != null "> and mf.is_work = #{isWork}</if>
<if test="groupId != null "> and mf.group_id = #{groupId}</if> <if test="deptIdStr != null "> and d.dept_id in (#{deptIdStr})</if>
</where> </where>
order by mf.face_name order by mf.face_name
</select> </select>
@ -55,11 +53,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mf.face_url, mf.face_url,
mf.face_phone, mf.face_phone,
mf.remark, mf.remark,
mf.group_id, d.dept_id,d.dept_name
mg.mine_group_name
FROM FROM
mine_face mf mine_face mf
LEFT JOIN mine_group mg ON mg.id = mf.group_id inner join sys_dept d on mg.dept_id = d.dept_id
WHERE mf.face_byte is not null WHERE mf.face_byte is not null
</select> </select>
@ -76,7 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="useTime != null">use_time,</if> <if test="useTime != null">use_time,</if>
<if test="faceByte != null">face_byte,</if> <if test="faceByte != null">face_byte,</if>
<if test="groupId != null">group_id,</if> <if test="deptId != null">dept_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if> <if test="id != null">#{id},</if>
@ -89,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="useTime != null">#{useTime},</if> <if test="useTime != null">#{useTime},</if>
<if test="faceByte != null">#{faceByte},</if> <if test="faceByte != null">#{faceByte},</if>
<if test="groupId != null">#{groupId},</if> <if test="deptId != null">#{deptId},</if>
</trim> </trim>
</insert> </insert>
@ -103,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isWork != null">is_work = #{isWork},</if> <if test="isWork != null">is_work = #{isWork},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="groupId != null">group_id = #{groupId},</if> <if test="deptId != null">dept_id = #{deptId},</if>
<if test="useTime != null">use_time=#{useTime},</if> <if test="useTime != null">use_time=#{useTime},</if>
<if test="faceByte != null">face_byte = #{faceByte},</if> <if test="faceByte != null">face_byte = #{faceByte},</if>
</trim> </trim>

1
yq-system/src/main/resources/mapper/system/MineGroupMapper.xml

@ -6,7 +6,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="MineGroup" id="MineGroupResult"> <resultMap type="MineGroup" id="MineGroupResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="mineGroupName" column="mine_group_name" />
<result property="deptId" column="dept_id" /> <result property="deptId" column="dept_id" />
<result property="deptName" column="dept_name" /> <result property="deptName" column="dept_name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />

13
yq-system/src/main/resources/mapper/system/MineHealthMapper.xml

@ -14,7 +14,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="temperature" column="temperature" /> <result property="temperature" column="temperature" />
<result property="isWork" column="is_work" /> <result property="isWork" column="is_work" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="mineGroupName" column="mine_group_name" />
<result property="faceName" column="face_name" /> <result property="faceName" column="face_name" />
<result property="facePhone" column="face_phone" /> <result property="facePhone" column="face_phone" />
<result property="deptId" column="dept_id" /> <result property="deptId" column="dept_id" />
@ -42,22 +41,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mf.face_name, mf.face_name,
mf.face_phone , mf.face_phone ,
mf.age , mf.age ,
mg.dept_id, mf.dept_id,
d.dept_name, d.dept_name
mg.mine_group_name
FROM FROM
mine_health mh mine_health mh
INNER JOIN mine_face mf INNER JOIN mine_face mf
on mf.id =mh.face_id on mf.id =mh.face_id
INNER JOIN mine_group mg
on mg.id =mf.group_id
inner join sys_dept d inner join sys_dept d
on d.dept_id =mg.dept_id on d.dept_id =mf.dept_id
</sql> </sql>
<select id="selectMineHealthList" parameterType="mineHealthVo" resultMap="MineHealthResult"> <select id="selectMineHealthList" parameterType="mineHealthVo" resultMap="MineHealthResult">
<include refid="selectMineHealthVo"/> <include refid="selectMineHealthVo"/>
<where> <where>
<if test="mineGroupName != null and mineGroupName != ''"> and mg.mine_group_name like concat('%', #{mineGroupName}, '%')</if> <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
<if test="deptId != null "> and d.dept_id = #{deptId}</if>
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if> <if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
<if test="bpHigh != null "> and mh.bp_high = #{bpHigh}</if> <if test="bpHigh != null "> and mh.bp_high = #{bpHigh}</if>
<if test="bpLow != null "> and mh.bp_low = #{bpLow}</if> <if test="bpLow != null "> and mh.bp_low = #{bpLow}</if>

78
yq-system/src/main/resources/mapper/system/MineWarningMapper.xml

@ -15,11 +15,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="temperature" column="temperature" /> <result property="temperature" column="temperature" />
<result property="isWork" column="is_work" /> <result property="isWork" column="is_work" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="mineGroupName" column="mine_group_name" />
<result property="faceName" column="face_name" /> <result property="faceName" column="face_name" />
<result property="facePhone" column="face_phone" /> <result property="facePhone" column="face_phone" />
<result property="age" column="age" /> <result property="age" column="age" />
<result property="groupId" column="group_id" />
</resultMap> </resultMap>
<resultMap type="MineWarning" id="MineWarningUnResult"> <resultMap type="MineWarning" id="MineWarningUnResult">
@ -33,11 +31,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="temperature" column="temperature" /> <result property="temperature" column="temperature" />
<result property="isWork" column="is_work" /> <result property="isWork" column="is_work" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="mineGroupName" column="mine_group_name" />
<result property="faceName" column="face_name" /> <result property="faceName" column="face_name" />
<result property="facePhone" column="face_phone" /> <result property="facePhone" column="face_phone" />
<result property="age" column="age" /> <result property="age" column="age" />
<result property="groupId" column="group_id" />
</resultMap> </resultMap>
@ -57,14 +54,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mf.face_name, mf.face_name,
mf.age, mf.age,
mf.face_phone, mf.face_phone,
mf.group_id, mf.dept_id,
mg.mine_group_name d.dept_name
FROM FROM
mine_warning mw mine_warning mw
INNER JOIN mine_face mf INNER JOIN mine_face mf
on mf.id =mw.face_id on mf.id =mw.face_id
INNER JOIN mine_group mg inner join sys_dept d on mf.dept_id = d.dept_id
on mg.id =mf.group_id
</sql> </sql>
<sql id="selectMineWarningMedicalVo"> <sql id="selectMineWarningMedicalVo">
SELECT SELECT
@ -79,13 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mf.is_work, mf.is_work,
mw.create_time, mw.create_time,
mf.face_name, mf.face_name,
mg.mine_group_name d.dept_name
FROM FROM
mine_warning mw mine_warning mw
INNER JOIN mine_face mf INNER JOIN mine_face mf
on mf.id =mw.face_id on mf.id =mw.face_id
INNER JOIN mine_group mg inner join sys_dept d on mf.dept_id = d.dept_id
on mg.id =mf.group_id
</sql> </sql>
<sql id="selectMineWarningList"> <sql id="selectMineWarningList">
SELECT SELECT
@ -107,12 +102,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMineWarningList" parameterType="MineWarning" resultMap="MineWarningResult"> <select id="selectMineWarningList" parameterType="MineWarning" resultMap="MineWarningResult">
<include refid="selectMineWarningVo"/> <include refid="selectMineWarningVo"/>
<where> <where>
<if test="mineGroupName != null and mineGroupName != ''"> and mg.mine_group_name like concat('%', #{mineGroupName}, '%')</if> <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if> <if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
<if test="groupId != null "> and mf.group_id =#{groupId}</if>
<if test="bpHigh != null "> and mw.bp_high = #{bpHigh}</if> <if test="bpHigh != null "> and mw.bp_high = #{bpHigh}</if>
<if test="bpLow != null "> and mw.bp_low = #{bpLow}</if> <if test="bpLow != null "> and mw.bp_low = #{bpLow}</if>
<if test="groupId != null "> and mg.id = #{groupId}</if> <if test="deptId != null "> and d.dept_id = #{deptId}</if>
<if test="br != null "> and mw.br = #{br}</if> <if test="br != null "> and mw.br = #{br}</if>
<if test="hr != null "> and mw.hr = #{hr}</if> <if test="hr != null "> and mw.hr = #{hr}</if>
<if test="hrv != null "> and mw.hrv = #{hrv}</if> <if test="hrv != null "> and mw.hrv = #{hrv}</if>
@ -160,18 +154,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mf.is_work, mf.is_work,
mw.create_time, mw.create_time,
mf.face_name, mf.face_name,
mg.mine_group_name, d.dept_name,
ROW_NUMBER() OVER (PARTITION BY mf.face_name ORDER BY mw.create_time DESC) AS rn ROW_NUMBER() OVER (PARTITION BY mf.face_name ORDER BY mw.create_time DESC) AS rn
FROM FROM
mine_warning mw mine_warning mw
INNER JOIN mine_face mf ON mf.id = mw.face_id INNER JOIN mine_face mf ON mf.id = mw.face_id
INNER JOIN mine_group mg ON mg.id = mf.group_id inner join sys_dept d on mf.dept_id = d.dept_id
<where> <where>
<if test="mineGroupName != null and mineGroupName != ''"> and mg.mine_group_name like concat('%', #{mineGroupName}, '%')</if> <if test="deptName != null and deptName != ''"> and d.dept_name like concat('%', #{deptName}, '%')</if>
<if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if> <if test="faceName != null and faceName != ''"> and mf.face_name like concat('%', #{faceName}, '%')</if>
<if test="bpHigh != null "> and mw.bp_high = #{bpHigh}</if> <if test="bpHigh != null "> and mw.bp_high = #{bpHigh}</if>
<if test="bpLow != null "> and mw.bp_low = #{bpLow}</if> <if test="bpLow != null "> and mw.bp_low = #{bpLow}</if>
<if test="groupId != null "> and mg.id = #{groupId}</if> <if test="deptId != null "> and d.dept_id = #{deptId}</if>
<if test="br != null "> and mw.br = #{br}</if> <if test="br != null "> and mw.br = #{br}</if>
<if test="hr != null "> and mw.hr = #{hr}</if> <if test="hr != null "> and mw.hr = #{hr}</if>
<if test="hrv != null "> and mw.hrv = #{hrv}</if> <if test="hrv != null "> and mw.hrv = #{hrv}</if>
@ -197,7 +191,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
is_work as isWork, is_work as isWork,
create_time as createTime, create_time as createTime,
face_name as faceName, face_name as faceName,
mine_group_name as mineGroupName dept_name as deptName
FROM FROM
RankedWarnings RankedWarnings
WHERE WHERE
@ -206,20 +200,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectMineWarningStatisticList" resultType="yq.system.domain.vo.StatisticVo"> <select id="selectMineWarningStatisticList" resultType="yq.system.domain.vo.StatisticVo">
SELECT SELECT
mg.mine_group_name AS mineGroupName, d.dept_name AS deptName,
COUNT(DISTINCT CASE WHEN mw.create_time IS NOT NULL THEN mf.id END) AS clock, -- 统计已打卡的人数 COUNT(DISTINCT CASE WHEN mw.create_time IS NOT NULL THEN mf.id END) AS clock, -- 统计已打卡的人数
COUNT(DISTINCT CASE WHEN mw.create_time IS NULL THEN mf.id END) AS unClock , -- 统计未打卡的人数 COUNT(DISTINCT CASE WHEN mw.create_time IS NULL THEN mf.id END) AS unClock , -- 统计未打卡的人数
GROUP_CONCAT(CASE WHEN mw.create_time IS NULL THEN mf.face_name END) AS unClockNames -- 统计未打卡的人员名称 GROUP_CONCAT(CASE WHEN mw.create_time IS NULL THEN mf.face_name END) AS unClockNames -- 统计未打卡的人员名称
FROM FROM
mine_group mg sys_dept d
LEFT JOIN mine_face mf ON mg.id = mf.group_id inner JOIN mine_face mf ON d.dept_id = mf.dept_id
LEFT JOIN mine_warning mw ON mw.face_id = mf.id LEFT JOIN mine_warning mw ON mw.face_id = mf.id
<if test="search == '今日' "> AND DATE(mw.create_time) = CURDATE() </if> <if test="search == '今日' "> AND DATE(mw.create_time) = CURDATE() </if>
<if test="search == '7天' "> AND mw.create_time >= CURDATE() - INTERVAL 7 DAY -- 过去7天内的打卡记录 </if> <if test="search == '7天' "> AND mw.create_time >= CURDATE() - INTERVAL 7 DAY -- 过去7天内的打卡记录 </if>
<if test="search == '30天' "> AND DATE(mw.create_time) = CURDATE() - INTERVAL 1 MONTH </if> <if test="search == '30天' "> AND DATE(mw.create_time) = CURDATE() - INTERVAL 1 MONTH </if>
GROUP BY GROUP BY
mg.dept_id, mg.id; d.dept_id
order by d.dept_name
</select> </select>
<select id="selectMineWarningUnMedicalList" resultMap="MineWarningResult"> <select id="selectMineWarningUnMedicalList" resultMap="MineWarningResult">
select mw.id, select mw.id,
@ -233,11 +228,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mw.is_work, mw.is_work,
mw.create_time, mw.create_time,
mf.face_name, mf.face_name,
mg.mine_group_name d.dept_name
from mine_warning mw from mine_warning mw
INNER join mine_health mh on mw.id =mh.warning_id INNER join mine_health mh on mw.id =mh.warning_id
INNER JOIN mine_face mf ON mf.id = mw.face_id INNER JOIN mine_face mf ON mf.id = mw.face_id
INNER JOIN mine_group mg ON mg.id = mf.group_id inner join sys_dept d on mf.dept_id = d.dept_id
</select>
<select id="selectMineWarningNormalList" resultType="yq.system.domain.vo.NormalCountVo">
SELECT
d.dept_name AS deptName, -- 部门名称
COUNT(DISTINCT CASE WHEN valid_count = total_count THEN mf.id END) AS normalCount, -- 正常人数(is_word = 0 的次数 = 总打卡次数)
COUNT(DISTINCT CASE WHEN valid_count != total_count THEN mf.id END) AS abnormalCount, -- 异常人数(is_word = 0 的次数 != 总打卡次数)
COUNT(DISTINCT mf.id) AS totalCount, -- 小组总人数
ROUND(COUNT(DISTINCT CASE WHEN valid_count = total_count THEN mf.id END) * 100.0 / COUNT(DISTINCT mf.id), 2) AS normalPercentage, -- 正常人数占比
ROUND(COUNT(DISTINCT CASE WHEN valid_count != total_count THEN mf.id END) * 100.0 / COUNT(DISTINCT mf.id), 2) AS abnormalPercentage, -- 异常人数占比
GROUP_CONCAT(DISTINCT CASE WHEN valid_count != total_count THEN mf.face_name END) AS abnormalNmaes -- 显示异常人员的姓名(假设是mf.name字段)
FROM
sys_dept d
INNER JOIN
mine_face mf ON d.dept_id = mf.dept_id -- 连接部门和员工
LEFT JOIN (
SELECT
mw.face_id,
COUNT(mw.id) AS total_count, -- 计算每个员工的打卡总次数
SUM(CASE WHEN mw.is_work = 1 THEN 1 ELSE 0 END) AS valid_count -- 计算is_word = 0的次数(正常打卡次数)
FROM
mine_warning mw
<where>
<if test="search == '今日' "> AND DATE(mw.create_time) = CURDATE() </if>
<if test="search == '7天' "> AND mw.create_time >= CURDATE() - INTERVAL 7 DAY -- 过去7天内的打卡记录 </if>
<if test="search == '30天' "> AND DATE(mw.create_time) = CURDATE() - INTERVAL 1 MONTH </if>
</where>
GROUP BY
mw.face_id -- 按员工分组,统计每个员工的打卡次数
) AS card_info ON card_info.face_id = mf.id -- 连接打卡信息
GROUP BY
d.dept_id -- 按部门分组
ORDER BY
d.dept_name;
</select> </select>
<insert id="insertMineWarning" parameterType="MineWarning" useGeneratedKeys="true" keyProperty="id"> <insert id="insertMineWarning" parameterType="MineWarning" useGeneratedKeys="true" keyProperty="id">

Loading…
Cancel
Save