AccessPersonRecordMapper.xml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhgd.scs.mapper.AccessPersonRecordMapper">
  6. <resultMap id="BaseResultMap" type="com.zhgd.scs.domain.AccessPersonRecord">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="personId" column="person_id" jdbcType="BIGINT"/>
  9. <result property="projectId" column="project_id" jdbcType="BIGINT"/>
  10. <result property="idcard" column="idcard" jdbcType="VARCHAR"/>
  11. <result property="time" column="time" jdbcType="TIMESTAMP"/>
  12. <result property="flag" column="flag" jdbcType="INTEGER"/>
  13. <result property="personName" column="person_name" jdbcType="VARCHAR"/>
  14. </resultMap>
  15. <select id="pagelist" resultType="com.zhgd.scs.domain.vo.AccessPersonRecordVo">
  16. SELECT p.*,wt.name workerTypeName,u.abbr_name unitName
  17. FROM access_person_record p
  18. LEFT JOIN sys_worker_type wt ON wt.id = p.worker_type_id
  19. LEFT JOIN labor_unit u ON u.id = p.unit_id
  20. Where p.project_id = #{projectId}
  21. <if test="name!=null and name!= ''">
  22. AND p.person_name like concat('%',#{name},'%')
  23. </if>
  24. <if test="flag!=null">
  25. AND p.flag = #{flag}
  26. </if>
  27. <if test="unitId!=null ">
  28. AND p.unit_id = #{unitId}
  29. </if>
  30. <if test="workerTypeId!=null">
  31. AND p.worker_type_id = #{workerTypeId}
  32. </if>
  33. <if test="startTime!=null and endTime!=null">
  34. AND p.time BETWEEN #{startTime} AND #{endTime}
  35. </if>
  36. order by p.time desc
  37. </select>
  38. <select id="getAttendance" resultType="com.zhgd.scs.domain.vo.AttendanceVo">
  39. SELECT COUNT(*) total_count,
  40. IFNULL(i.in_count, 0) in_count,
  41. IFNULL(n.now_count, 0) now_count,
  42. i.unit_name,
  43. i.unit_id
  44. from labor_person p
  45. LEFT JOIN (
  46. SELECT count(DISTINCT idcard) in_count,
  47. da.unit_name,
  48. da.unit_id
  49. from access_date_attendance_data da
  50. where da.project_id=#{projectId}
  51. AND da.date= date(NOW())
  52. GROUP BY da.unit_id
  53. ) i on i.unit_id=p.unit_id
  54. LEFT JOIN (
  55. SELECT count(DISTINCT idcard) now_count,
  56. lr.unit_name,
  57. lr.unit_id
  58. from access_latest_record lr
  59. where lr.project_id=#{projectId}
  60. and date(lr.record_time)=date(NOW())
  61. and lr.record_type=0
  62. GROUP BY lr.unit_id
  63. ) n ON n.unit_id=p.unit_id
  64. WHERE p.project_id=#{projectId}
  65. GROUP BY p.unit_id
  66. </select>
  67. </mapper>