Нет описания

TLhzxStreetTreeWorkPlanMapper.xml 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.moduleMain.streetTree.mapper.TLhzxStreetTreeWorkPlanMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
  6. <id column="id" property="id" />
  7. <result column="plan_no" property="planNo" />
  8. <result column="section_id" property="sectionId" />
  9. <result column="section_name" property="sectionName" />
  10. <result column="maintenance_company_id" property="maintenanceCompanyId" />
  11. <result column="maintenance_company_name" property="maintenanceCompanyName" />
  12. <result column="phone" property="phone" />
  13. <result column="user_id" property="userId" />
  14. <result column="user_code" property="userCode" />
  15. <result column="user_name" property="userName" />
  16. <result column="start_time" property="startTime" />
  17. <result column="end_time" property="endTime" />
  18. <result column="plan_type" property="planType" />
  19. <result column="state" property="state" />
  20. <result column="effect_date" property="effectDate" />
  21. <result column="remark" property="remark" />
  22. <result column="create_user_id" property="createUserId" />
  23. <result column="create_date" property="createDate" />
  24. <result column="update_user_id" property="updateUserId" />
  25. <result column="update_date" property="updateDate" />
  26. <result column="del_flg" property="delFlg" />
  27. </resultMap>
  28. <!-- 通用查询结果列 -->
  29. <sql id="Base_Column_List">
  30. id, plan_no, section_id, section_name, maintenance_company_id, maintenance_company_name, phone, user_id, user_code, user_name, start_time, end_time, plan_type, state, effect_date, remark, create_user_id, create_date, update_user_id, update_date, del_flg
  31. </sql>
  32. <select id="selectStreetTreeWorkPlanBySection"
  33. resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
  34. select
  35. temp.*
  36. from
  37. (<include refid="selectStreetTreeWorkPlanSql"/>) temp
  38. </select>
  39. <select id="selectStreetTreeWorkPlanBySectionType"
  40. resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
  41. select
  42. temp.section_type,
  43. sum(if(temp.planCount is null, 0, temp.planCount)) as planCount,
  44. sum(if(temp.completeCount is null, 0, temp.completeCount)) as completeCount,
  45. if(
  46. sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount)) <![CDATA[ < ]]> 0,
  47. 0,
  48. sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount))
  49. ) as noCompleteCount
  50. from
  51. (<include refid="selectStreetTreeWorkPlanSql"/>) temp
  52. group by
  53. temp.section_type
  54. </select>
  55. <select id="selectStreetTreeWorkPlanSumCount"
  56. resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
  57. select
  58. sum(if(temp.planCount is null, 0, temp.planCount)) as planCount,
  59. sum(if(temp.completeCount is null, 0, temp.completeCount)) as completeCount,
  60. if(
  61. sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount)) <![CDATA[ < ]]> 0,
  62. 0,
  63. sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount))
  64. ) as noCompleteCount
  65. from
  66. (<include refid="selectStreetTreeWorkPlanSql"/>) temp
  67. </select>
  68. <sql id="selectStreetTreeWorkPlanSql">
  69. select distinct
  70. rsmc.section_id as sectionId,
  71. s.section_name as sectionName,
  72. rsmc.maintenance_company_id as maintenanceCompanyId,
  73. mc.maintenance_company_name as maintenanceCompanyName,
  74. s.section_type,
  75. if(plan_count.planCount is null, 0, plan_count.planCount) as planCount,
  76. if(complete_count.completeCount is null, 0, complete_count.completeCount) as completeCount,
  77. if(
  78. if(plan_count.planCount is null, 0, plan_count.planCount) - if(complete_count.completeCount is null, 0, complete_count.completeCount) <![CDATA[ < ]]> 0,
  79. 0,
  80. if(plan_count.planCount is null, 0, plan_count.planCount) - if(complete_count.completeCount is null, 0, complete_count.completeCount)
  81. ) as noCompleteCount
  82. from
  83. T_Lhzx_Road_Section_Maintenance_Company rsmc
  84. left join
  85. T_Lhzx_Section s on s.id = rsmc.section_id
  86. left join
  87. T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
  88. left join (
  89. select
  90. section_id,
  91. maintenance_company_id,
  92. count(id) as planCount
  93. from
  94. T_Lhzx_Street_Tree_Work_Plan
  95. where
  96. plan_type = 1
  97. and
  98. del_flg = 0
  99. <if test="tLhzxStreetTreeWorkPlan.uploadType != null">
  100. and upload_type = #{tLhzxStreetTreeWorkPlan.uploadType}
  101. </if>
  102. <if test="tLhzxStreetTreeWorkPlan.planMonth != null and tLhzxStreetTreeWorkPlan.planMonth != ''">
  103. and date_format(start_time, '%Y-%m') = #{tLhzxStreetTreeWorkPlan.planMonth}
  104. </if>
  105. <if test="tLhzxStreetTreeWorkPlan.planYear != null and tLhzxStreetTreeWorkPlan.planYear != ''">
  106. and date_format(start_time, '%Y') = #{tLhzxStreetTreeWorkPlan.planYear}
  107. </if>
  108. group by
  109. section_id,
  110. maintenance_company_id
  111. ) plan_count on plan_count.section_id = rsmc.section_id and plan_count.maintenance_company_id = rsmc.maintenance_company_id
  112. left join (
  113. select
  114. section_id,
  115. maintenance_company_id,
  116. count(id) as completeCount
  117. from
  118. T_Lhzx_Street_Tree_Work_Plan
  119. where
  120. plan_type = 2
  121. and
  122. del_flg = 0
  123. <if test="tLhzxStreetTreeWorkPlan.uploadType != null">
  124. and upload_type = #{tLhzxStreetTreeWorkPlan.uploadType}
  125. </if>
  126. <if test="tLhzxStreetTreeWorkPlan.planMonth != null and tLhzxStreetTreeWorkPlan.planMonth != ''">
  127. and date_format(start_time, '%Y-%m') = #{tLhzxStreetTreeWorkPlan.planMonth}
  128. </if>
  129. <if test="tLhzxStreetTreeWorkPlan.planYear != null and tLhzxStreetTreeWorkPlan.planYear != ''">
  130. and date_format(start_time, '%Y') = #{tLhzxStreetTreeWorkPlan.planYear}
  131. </if>
  132. group by
  133. section_id,
  134. maintenance_company_id
  135. ) complete_count on complete_count.section_id = rsmc.section_id and complete_count.maintenance_company_id = rsmc.maintenance_company_id
  136. where
  137. rsmc.del_flg = 0
  138. <if test="tLhzxStreetTreeWorkPlan.sectionId != null">
  139. and rsmc.section_id = #{tLhzxStreetTreeWorkPlan.sectionId}
  140. </if>
  141. <if test="tLhzxStreetTreeWorkPlan.maintenanceCompanyId != null">
  142. and rsmc.maintenance_company_id = #{tLhzxStreetTreeWorkPlan.maintenanceCompanyId}
  143. </if>
  144. <if test="tLhzxStreetTreeWorkPlan.sectionType != null">
  145. and s.section_type = #{tLhzxStreetTreeWorkPlan.sectionType}
  146. </if>
  147. order by
  148. rsmc.section_id,
  149. rsmc.maintenance_company_id
  150. </sql>
  151. </mapper>