12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zhgd.scs.mapper.AccessPersonRecordMapper">
- <resultMap id="BaseResultMap" type="com.zhgd.scs.domain.AccessPersonRecord">
- <id property="id" column="id" jdbcType="BIGINT"/>
- <result property="personId" column="person_id" jdbcType="BIGINT"/>
- <result property="projectId" column="project_id" jdbcType="BIGINT"/>
- <result property="idcard" column="idcard" jdbcType="VARCHAR"/>
- <result property="time" column="time" jdbcType="TIMESTAMP"/>
- <result property="flag" column="flag" jdbcType="INTEGER"/>
- <result property="personName" column="person_name" jdbcType="VARCHAR"/>
- </resultMap>
- <select id="pagelist" resultType="com.zhgd.scs.domain.vo.AccessPersonRecordVo">
- SELECT p.*,wt.name workerTypeName,u.abbr_name unitName
- FROM access_person_record p
- LEFT JOIN sys_worker_type wt ON wt.id = p.worker_type_id
- LEFT JOIN labor_unit u ON u.id = p.unit_id
- Where p.project_id = #{projectId}
- <if test="name!=null and name!= ''">
- AND p.person_name like concat('%',#{name},'%')
- </if>
- <if test="flag!=null">
- AND p.flag = #{flag}
- </if>
- <if test="unitId!=null ">
- AND p.unit_id = #{unitId}
- </if>
- <if test="workerTypeId!=null">
- AND p.worker_type_id = #{workerTypeId}
- </if>
- <if test="startTime!=null and endTime!=null">
- AND p.time BETWEEN #{startTime} AND #{endTime}
- </if>
- order by p.time desc
- </select>
- <select id="getAttendance" resultType="com.zhgd.scs.domain.vo.AttendanceVo">
- SELECT COUNT(*) total_count,
- IFNULL(i.in_count, 0) in_count,
- IFNULL(n.now_count, 0) now_count,
- i.unit_name,
- i.unit_id
- from labor_person p
- LEFT JOIN (
- SELECT count(DISTINCT idcard) in_count,
- da.unit_name,
- da.unit_id
- from access_date_attendance_data da
- where da.project_id=#{projectId}
- AND da.date= date(NOW())
- GROUP BY da.unit_id
- ) i on i.unit_id=p.unit_id
- LEFT JOIN (
- SELECT count(DISTINCT idcard) now_count,
- lr.unit_name,
- lr.unit_id
- from access_latest_record lr
- where lr.project_id=#{projectId}
- and date(lr.record_time)=date(NOW())
- and lr.record_type=0
- GROUP BY lr.unit_id
- ) n ON n.unit_id=p.unit_id
- WHERE p.project_id=#{projectId}
- GROUP BY p.unit_id
- </select>
- </mapper>
|