AccessTaskTimeMapper.xml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.AccessTaskTimeMapper">
  6. <resultMap id="BaseResultMap" type="com.zhgd.scs.domain.AccessTaskTime">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="idcard" column="idcard" jdbcType="VARCHAR"/>
  9. <result property="inTime" column="in_time" jdbcType="TIMESTAMP"/>
  10. <result property="outTime" column="out_time" jdbcType="TIMESTAMP"/>
  11. <result property="workingHours" column="working_hours" jdbcType="DECIMAL"/>
  12. <result property="personId" column="person_id" jdbcType="BIGINT"/>
  13. <result property="projectId" column="project_id" jdbcType="BIGINT"/>
  14. </resultMap>
  15. <select id="pagelist" resultType="com.zhgd.scs.domain.vo.AccessTaskTimeVo">
  16. select p.*,
  17. tw.name workerTypeName,
  18. u.abbr_name unitName,
  19. a.total_hours
  20. from labor_person p
  21. LEFT JOIN sys_worker_type tw ON tw.id=p.worker_type_id
  22. LEFT JOIN labor_unit u ON u.id = p.unit_id
  23. LEFT JOIN (
  24. SELECT t.idcard, SUM(COALESCE(t.working_hours, 0)) total_hours FROM access_task_time t
  25. WHERE 1=1
  26. <if test="startDate != null and endDate != null">
  27. AND t.in_time >= #{startDate} and t.out_time &lt;= #{endDate}
  28. </if>
  29. GROUP BY t.idcard
  30. ) a ON p.id_card = a.idcard
  31. WHERE p.project_id=#{projectId}
  32. <if test="name!=null and name!= ''">
  33. AND p.name like concat('%',#{name},'%')
  34. </if>
  35. <if test="unitId!=null ">
  36. AND p.unit_id = #{unitId}
  37. </if>
  38. <if test="workerTypeId!=null">
  39. AND p.worker_type_id = #{workerTypeId}
  40. </if>
  41. ORDER BY
  42. a.total_hours DESC
  43. </select>
  44. </mapper>