Brak opisu

TSecEmergencyPlayMapper.xml 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yt.zhylplat.moduleSec.emergencyPlay.mapper.TSecEmergencyPlayMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleSec.emergencyPlay.entity.TSecEmergencyPlay">
  6. <id column="id" property="id" />
  7. <result column="create_user_id" property="createUserId" />
  8. <result column="create_date" property="createDate" />
  9. <result column="update_user_id" property="updateUserId" />
  10. <result column="maintenance_company_id" property="maintenanceCompanyId" />
  11. <result column="maintenance_company_name" property="maintenanceCompanyName" />
  12. <result column="section_id" property="sectionId" />
  13. <result column="section_name" property="sectionName" />
  14. <result column="file_name" property="fileName" />
  15. <result column="file_url" property="fileUrl" />
  16. <result column="update_date" property="updateDate" />
  17. <result column="del_flg" property="delFlg" />
  18. <result column="remark" property="remark" />
  19. </resultMap>
  20. <!-- 通用查询结果列 -->
  21. <sql id="Base_Column_List">
  22. id, create_user_id, create_date, update_user_id, maintenance_company_id, maintenance_company_name, section_id, section_name, file_name, file_url, update_date, del_flg, remark
  23. </sql>
  24. <select id="selectTSecEmergencyPlayBySection"
  25. resultType="com.yt.zhylplat.moduleSec.emergencyPlay.entity.TSecEmergencyPlay">
  26. select
  27. s.id as sectionId,
  28. s.section_name as sectionName,
  29. m.id as maintenanceCompanyId,
  30. m.maintenance_company_name as maintenanceCompanyName,
  31. IFNULL
  32. (b.sumCount,0) AS sumCount
  33. FROM
  34. T_Lhzx_Section s
  35. LEFT JOIN T_Lhzx_Road_Section_Maintenance_Company rsmc ON s.id = rsmc.section_id
  36. LEFT JOIN T_Lhzx_Maintenance_Company m ON m.id = rsmc.maintenance_company_id
  37. LEFT JOIN (
  38. SELECT
  39. section_id,
  40. section_name,
  41. maintenance_company_id,
  42. maintenance_company_name,
  43. COUNT(id) as sumCount
  44. FROM
  45. T_Sec_Emergency_Play
  46. WHERE
  47. del_flg = 0
  48. <if test="uploadYear != null and uploadYear != ''">
  49. and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
  50. </if>
  51. GROUP BY
  52. section_id,
  53. section_name,
  54. maintenance_company_id,
  55. maintenance_company_name
  56. order by
  57. section_id,
  58. maintenance_company_id) b ON rsmc.section_id = b.section_id
  59. AND rsmc.maintenance_company_id = b.maintenance_company_id
  60. WHERE
  61. m.id IS NOT NULL
  62. <if test="sectionId != null">
  63. AND rsmc.section_id = #{sectionId}
  64. </if>
  65. <if test="maintenanceCompanyId != null">
  66. AND rsmc.maintenance_company_id = #{maintenanceCompanyId}
  67. </if>
  68. GROUP BY
  69. s.id,
  70. s.section_name,
  71. m.id,
  72. m.maintenance_company_name,
  73. b.sumCount
  74. ORDER BY
  75. s.id,
  76. m.id
  77. </select>
  78. <select id="selectTSecEmergencyPlaySumCount"
  79. resultType="com.yt.zhylplat.moduleSec.emergencyPlay.entity.TSecEmergencyPlay">
  80. select
  81. sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount
  82. from
  83. (<include refid="TSecEmergencyPlaySql"/>) temp
  84. </select>
  85. <sql id="TSecEmergencyPlaySql">
  86. SELECT
  87. section_id,
  88. section_name,
  89. maintenance_company_id,
  90. maintenance_company_name,
  91. COUNT(id) as sumCount
  92. FROM
  93. T_Sec_Emergency_Play
  94. WHERE
  95. del_flg = 0
  96. <if test="sectionId != null">
  97. AND section_id = #{sectionId}
  98. </if>
  99. <if test="maintenanceCompanyId != null">
  100. AND maintenance_company_id = #{maintenanceCompanyId}
  101. </if>
  102. <if test="uploadYear != null and uploadYear != ''">
  103. and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
  104. </if>
  105. GROUP BY
  106. section_id,
  107. section_name,
  108. maintenance_company_id,
  109. maintenance_company_name
  110. order by
  111. section_id,
  112. maintenance_company_id
  113. </sql>
  114. </mapper>