Нет описания

TSecContingencyPlanbMapper.xml 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.contingencyPlanB.mapper.TSecContingencyPlanbMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleSec.contingencyPlanB.entity.TSecContingencyPlanb">
  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="selectSecContingencyPlanbBySection"
  25. resultType="com.yt.zhylplat.moduleSec.contingencyPlanB.entity.TSecContingencyPlanb">
  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_Contingency_PlanB
  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
  59. ) b ON rsmc.section_id = b.section_id
  60. AND rsmc.maintenance_company_id = b.maintenance_company_id
  61. WHERE
  62. m.id IS NOT NULL
  63. <if test="sectionId != null">
  64. AND rsmc.section_id = #{sectionId}
  65. </if>
  66. <if test="maintenanceCompanyId != null">
  67. AND rsmc.maintenance_company_id = #{maintenanceCompanyId}
  68. </if>
  69. GROUP BY
  70. s.id,
  71. s.section_name,
  72. m.id,
  73. m.maintenance_company_name,
  74. b.sumCount
  75. ORDER BY
  76. s.id,
  77. m.id
  78. </select>
  79. <select id="selectSecContingencyPlanbSumCount"
  80. resultType="com.yt.zhylplat.moduleSec.contingencyPlanB.entity.TSecContingencyPlanb">
  81. select
  82. sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount
  83. from
  84. (<include refid="TSecContingencyPlanbSql"/>) temp
  85. </select>
  86. <sql id="TSecContingencyPlanbSql">
  87. SELECT
  88. section_id,
  89. section_name,
  90. maintenance_company_id,
  91. maintenance_company_name,
  92. COUNT(id) as sumCount
  93. FROM
  94. T_Sec_Contingency_PlanB
  95. WHERE
  96. del_flg = 0
  97. <if test="sectionId != null">
  98. AND section_id = #{sectionId}
  99. </if>
  100. <if test="maintenanceCompanyId != null">
  101. AND maintenance_company_id = #{maintenanceCompanyId}
  102. </if>
  103. <if test="uploadYear != null and uploadYear != ''">
  104. and DATE_FORMAT(create_date, '%Y') = #{uploadYear}
  105. </if>
  106. GROUP BY
  107. section_id,
  108. section_name,
  109. maintenance_company_id,
  110. maintenance_company_name
  111. order by
  112. section_id,
  113. maintenance_company_id
  114. </sql>
  115. </mapper>