Нет описания

TLhzxMaintenanceCompletionTreeRecordMapper.xml 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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.completion.mapper.TLhzxMaintenanceCompletionTreeRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  6. <id column="id" property="id" />
  7. <result column="completion_record_id" property="completionRecordId" />
  8. <result column="road_id" property="roadId" />
  9. <result column="road_name" property="roadName" />
  10. <result column="road_start_spot" property="roadStartSpot" />
  11. <result column="road_end_spot" property="roadEndSpot" />
  12. <result column="replant" property="replant" />
  13. <result column="fruit_hair_control" property="fruitHairControl" />
  14. <result column="wrap_adjustment" property="wrapAdjustment" />
  15. <result column="apply_fertilizer" property="applyFertilizer" />
  16. <result column="green_trim_count" property="greenTrimCount" />
  17. <result column="tree_hole_replant" property="treeHoleReplant" />
  18. <result column="tree_hole_repair" property="treeHoleRepair" />
  19. <result column="peeling_bud" property="peelingBud" />
  20. <result column="cover_repair" property="coverRepair" />
  21. <result column="righting" property="righting" />
  22. <result column="other" property="other" />
  23. <result column="create_user_id" property="createUserId" />
  24. <result column="create_date" property="createDate" />
  25. <result column="update_user_id" property="updateUserId" />
  26. <result column="update_date" property="updateDate" />
  27. <result column="del_flg" property="delFlg" />
  28. <result column="remark" property="remark" />
  29. </resultMap>
  30. <!-- 通用查询结果列 -->
  31. <sql id="Base_Column_List">
  32. id, completion_record_id, road_id, road_name, road_start_spot, road_end_spot, replant, fruit_hair_control, wrap_adjustment, apply_fertilizer, green_trim_count, tree_hole_replant, tree_hole_repair, peeling_bud, cover_repair, righting, other, create_user_id, create_date, update_user_id, update_date, del_flg, remark
  33. </sql>
  34. <select id="selectCompletionTreeRecordPage"
  35. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  36. select
  37. temp.*
  38. from
  39. (<include refid="selectCompletionTreeRecordPageSql"/>) temp
  40. </select>
  41. <select id="selectStreetTreeWorkPlanItemPage"
  42. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  43. select
  44. temp.*
  45. from
  46. (<include refid="selectStreetTreeWorkPlanItemPageSql"/>) temp
  47. </select>
  48. <select id="selectCompletionTreeRecordListBySectionType"
  49. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  50. select
  51. temp.section_type,
  52. sum(if(temp.replant is null, 0, temp.replant)) as replant,
  53. sum(if(temp.fruit_hair_control is null, 0, temp.fruit_hair_control)) as fruit_hair_control,
  54. sum(if(temp.wrap_adjustment is null, 0, temp.wrap_adjustment)) as wrap_adjustment,
  55. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  56. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  57. sum(if(temp.tree_hole_replant is null, 0, temp.tree_hole_replant)) as tree_hole_replant,
  58. sum(if(temp.tree_hole_repair is null, 0, temp.tree_hole_repair)) as tree_hole_repair,
  59. sum(if(temp.peeling_bud is null, 0, temp.peeling_bud)) as peeling_bud,
  60. sum(if(temp.cover_repair is null, 0, temp.cover_repair)) as cover_repair,
  61. sum(if(temp.righting is null, 0, temp.righting)) as righting
  62. from
  63. (<include refid="selectCompletionTreeRecordPageSql"/>) temp
  64. group by
  65. temp.section_type
  66. </select>
  67. <select id="getCompletionTreeRecordSumCount"
  68. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  69. select
  70. sum(if(temp.replant is null, 0, temp.replant)) as replant,
  71. sum(if(temp.fruit_hair_control is null, 0, temp.fruit_hair_control)) as fruit_hair_control,
  72. sum(if(temp.wrap_adjustment is null, 0, temp.wrap_adjustment)) as wrap_adjustment,
  73. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  74. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  75. sum(if(temp.tree_hole_replant is null, 0, temp.tree_hole_replant)) as tree_hole_replant,
  76. sum(if(temp.tree_hole_repair is null, 0, temp.tree_hole_repair)) as tree_hole_repair,
  77. sum(if(temp.peeling_bud is null, 0, temp.peeling_bud)) as peeling_bud,
  78. sum(if(temp.cover_repair is null, 0, temp.cover_repair)) as cover_repair,
  79. sum(if(temp.righting is null, 0, temp.righting)) as righting
  80. from
  81. (<include refid="selectCompletionTreeRecordPageSql"/>) temp
  82. </select>
  83. <select id="selectStreetTreeWorkPlanItemListBySectionType"
  84. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  85. select
  86. temp.section_type,
  87. sum(if(temp.replant is null, 0, temp.replant)) as replant,
  88. sum(if(temp.fruit_hair_control is null, 0, temp.fruit_hair_control)) as fruit_hair_control,
  89. sum(if(temp.wrap_adjustment is null, 0, temp.wrap_adjustment)) as wrap_adjustment,
  90. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  91. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  92. sum(if(temp.tree_hole_replant is null, 0, temp.tree_hole_replant)) as tree_hole_replant,
  93. sum(if(temp.tree_hole_repair is null, 0, temp.tree_hole_repair)) as tree_hole_repair,
  94. sum(if(temp.peeling_bud is null, 0, temp.peeling_bud)) as peeling_bud,
  95. sum(if(temp.cover_repair is null, 0, temp.cover_repair)) as cover_repair,
  96. sum(if(temp.righting is null, 0, temp.righting)) as righting
  97. from
  98. (<include refid="selectStreetTreeWorkPlanItemPageSql"/>) temp
  99. group by
  100. temp.section_type
  101. </select>
  102. <select id="getStreetTreeWorkPlanItemSumCount"
  103. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionTreeRecord">
  104. select
  105. sum(if(temp.replant is null, 0, temp.replant)) as replant,
  106. sum(if(temp.fruit_hair_control is null, 0, temp.fruit_hair_control)) as fruit_hair_control,
  107. sum(if(temp.wrap_adjustment is null, 0, temp.wrap_adjustment)) as wrap_adjustment,
  108. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  109. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  110. sum(if(temp.tree_hole_replant is null, 0, temp.tree_hole_replant)) as tree_hole_replant,
  111. sum(if(temp.tree_hole_repair is null, 0, temp.tree_hole_repair)) as tree_hole_repair,
  112. sum(if(temp.peeling_bud is null, 0, temp.peeling_bud)) as peeling_bud,
  113. sum(if(temp.cover_repair is null, 0, temp.cover_repair)) as cover_repair,
  114. sum(if(temp.righting is null, 0, temp.righting)) as righting
  115. from
  116. (<include refid="selectStreetTreeWorkPlanItemPageSql"/>) temp
  117. </select>
  118. <sql id="selectCompletionTreeRecordPageSql">
  119. select
  120. s.section_type,
  121. rsmc.section_id,
  122. s.section_name,
  123. rsmc.maintenance_company_id,
  124. mc.maintenance_company_name,
  125. if(ctr.replant is null, 0, ctr.replant) as replant,
  126. if(ctr.fruit_hair_control is null, 0, ctr.fruit_hair_control) as fruit_hair_control,
  127. if(ctr.wrap_adjustment is null, 0, ctr.wrap_adjustment) as wrap_adjustment,
  128. if(ctr.apply_fertilizer is null, 0, ctr.apply_fertilizer) as apply_fertilizer,
  129. if(ctr.green_trim_count is null, 0, ctr.green_trim_count) as green_trim_count,
  130. if(ctr.tree_hole_replant is null, 0, ctr.tree_hole_replant) as tree_hole_replant,
  131. if(ctr.tree_hole_repair is null, 0, ctr.tree_hole_repair) as tree_hole_repair,
  132. if(ctr.peeling_bud is null, 0, ctr.peeling_bud) as peeling_bud,
  133. if(ctr.cover_repair is null, 0, ctr.cover_repair) as cover_repair,
  134. if(ctr.righting is null, 0, ctr.righting) as righting,
  135. ctr.other
  136. from (
  137. select distinct
  138. section_id,
  139. maintenance_company_id
  140. from
  141. T_Lhzx_Road_Section_Maintenance_Company
  142. where
  143. del_flg = 0
  144. ) rsmc
  145. left join
  146. (<include refid="completionTreeRecordSql"/>) ctr on rsmc.section_id = ctr.section_id and rsmc.maintenance_company_id = ctr.maintenance_company_id
  147. left join
  148. T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
  149. left join
  150. T_Lhzx_Section s on rsmc.section_id = s.id
  151. <where>
  152. <if test="maintenanceCompletionTreeRecord.sectionId">
  153. and rsmc.section_id = #{maintenanceCompletionTreeRecord.sectionId}
  154. </if>
  155. <if test="maintenanceCompletionTreeRecord.sectionType">
  156. and s.section_type = #{maintenanceCompletionTreeRecord.sectionType}
  157. </if>
  158. <if test="maintenanceCompletionTreeRecord.maintenanceCompanyId">
  159. and rsmc.maintenance_company_id = #{maintenanceCompletionTreeRecord.maintenanceCompanyId}
  160. </if>
  161. </where>
  162. order by
  163. rsmc.section_id,
  164. rsmc.maintenance_company_id
  165. </sql>
  166. <sql id="selectStreetTreeWorkPlanItemPageSql">
  167. select
  168. s.section_type,
  169. rsmc.section_id,
  170. s.section_name,
  171. rsmc.maintenance_company_id,
  172. mc.maintenance_company_name,
  173. if(ctr.replant is null, 0, ctr.replant) as replant,
  174. if(ctr.fruit_hair_control is null, 0, ctr.fruit_hair_control) as fruit_hair_control,
  175. if(ctr.wrap_adjustment is null, 0, ctr.wrap_adjustment) as wrap_adjustment,
  176. if(ctr.apply_fertilizer is null, 0, ctr.apply_fertilizer) as apply_fertilizer,
  177. if(ctr.green_trim_count is null, 0, ctr.green_trim_count) as green_trim_count,
  178. if(ctr.tree_hole_replant is null, 0, ctr.tree_hole_replant) as tree_hole_replant,
  179. if(ctr.tree_hole_repair is null, 0, ctr.tree_hole_repair) as tree_hole_repair,
  180. if(ctr.peeling_bud is null, 0, ctr.peeling_bud) as peeling_bud,
  181. if(ctr.cover_repair is null, 0, ctr.cover_repair) as cover_repair,
  182. if(ctr.righting is null, 0, ctr.righting) as righting,
  183. ctr.other
  184. from (
  185. select distinct
  186. section_id,
  187. maintenance_company_id
  188. from
  189. T_Lhzx_Road_Section_Maintenance_Company
  190. where
  191. del_flg = 0
  192. ) rsmc
  193. left join
  194. (<include refid="selectStreetTreeWorkPlanItemSql"/>) ctr on rsmc.section_id = ctr.section_id and rsmc.maintenance_company_id = ctr.maintenance_company_id
  195. left join
  196. T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
  197. left join
  198. T_Lhzx_Section s on rsmc.section_id = s.id
  199. <where>
  200. <if test="maintenanceCompletionTreeRecord.sectionId">
  201. and rsmc.section_id = #{maintenanceCompletionTreeRecord.sectionId}
  202. </if>
  203. <if test="maintenanceCompletionTreeRecord.maintenanceCompanyId">
  204. and rsmc.maintenance_company_id = #{maintenanceCompletionTreeRecord.maintenanceCompanyId}
  205. </if>
  206. </where>
  207. order by
  208. rsmc.section_id,
  209. rsmc.maintenance_company_id
  210. </sql>
  211. <sql id="completionTreeRecordSql">
  212. select
  213. mcr.section_id,
  214. mcr.section_name,
  215. mcr.maintenance_company_id,
  216. mcr.maintenance_company_name,
  217. sum(if(mctr.replant is null, 0, mctr.replant)) as replant,
  218. sum(if(mctr.fruit_hair_control is null, 0, mctr.fruit_hair_control)) as fruit_hair_control,
  219. sum(if(mctr.wrap_adjustment is null, 0, mctr.wrap_adjustment)) as wrap_adjustment,
  220. sum(if(mctr.apply_fertilizer is null, 0, mctr.apply_fertilizer)) as apply_fertilizer,
  221. sum(if(mctr.green_trim_count is null, 0, mctr.green_trim_count)) as green_trim_count,
  222. sum(if(mctr.tree_hole_replant is null, 0, mctr.tree_hole_replant)) as tree_hole_replant,
  223. sum(if(mctr.tree_hole_repair is null, 0, mctr.tree_hole_repair)) as tree_hole_repair,
  224. sum(if(mctr.peeling_bud is null, 0, mctr.peeling_bud)) as peeling_bud,
  225. sum(if(mctr.cover_repair is null, 0, mctr.cover_repair)) as cover_repair,
  226. sum(if(mctr.righting is null, 0, mctr.righting)) as righting,
  227. group_concat(mctr.other separator ';') as other
  228. from
  229. T_Lhzx_Maintenance_Completion_Tree_Record mctr
  230. left join
  231. T_Lhzx_Maintenance_Completion_Record mcr on mctr.completion_record_id = mcr.id
  232. <where>
  233. and mcr.del_flg = 0
  234. <if test="maintenanceCompletionTreeRecord.queryStartTime != null and maintenanceCompletionTreeRecord.queryStartTime != ''">
  235. and DATE_FORMAT(mcr.complete_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{maintenanceCompletionTreeRecord.queryStartTime}
  236. </if>
  237. <if test="maintenanceCompletionTreeRecord.queryEndTime != null and maintenanceCompletionTreeRecord.queryEndTime != ''">
  238. and DATE_FORMAT(mcr.complete_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{maintenanceCompletionTreeRecord.queryEndTime}
  239. </if>
  240. <if test="maintenanceCompletionTreeRecord.planMonth != null and maintenanceCompletionTreeRecord.planMonth != ''">
  241. and DATE_FORMAT(mcr.complete_date, '%Y-%m') = #{maintenanceCompletionTreeRecord.planMonth}
  242. </if>
  243. </where>
  244. group by
  245. mcr.section_id,
  246. mcr.section_name,
  247. mcr.maintenance_company_id,
  248. mcr.maintenance_company_name
  249. </sql>
  250. <sql id="selectStreetTreeWorkPlanItemSql">
  251. select
  252. stwp.section_id,
  253. stwp.section_name,
  254. stwp.maintenance_company_id,
  255. stwp.maintenance_company_name,
  256. sum(if(stwpdi.replant is null, 0, stwpdi.replant)) as replant,
  257. sum(if(stwpdi.fruit_hair_control is null, 0, stwpdi.fruit_hair_control)) as fruit_hair_control,
  258. sum(if(stwpdi.wrap_adjustment is null, 0, stwpdi.wrap_adjustment)) as wrap_adjustment,
  259. sum(if(stwpdi.apply_fertilizer is null, 0, stwpdi.apply_fertilizer)) as apply_fertilizer,
  260. sum(if(stwpdi.green_trim_count is null, 0, stwpdi.green_trim_count)) as green_trim_count,
  261. sum(if(stwpdi.tree_hole_replant is null, 0, stwpdi.tree_hole_replant)) as tree_hole_replant,
  262. sum(if(stwpdi.tree_hole_repair is null, 0, stwpdi.tree_hole_repair)) as tree_hole_repair,
  263. sum(if(stwpdi.peeling_bud is null, 0, stwpdi.peeling_bud)) as peeling_bud,
  264. sum(if(stwpdi.cover_repair is null, 0, stwpdi.cover_repair)) as cover_repair,
  265. sum(if(stwpdi.righting is null, 0, stwpdi.righting)) as righting,
  266. group_concat(stwpdi.other separator ';') as other
  267. from
  268. T_Lhzx_Street_Tree_Work_Plan_Detail_Item stwpdi
  269. left join
  270. T_Lhzx_Street_Tree_Work_Plan stwp on stwp.id = stwpdi.plan_id
  271. where
  272. stwpdi.del_flg = 0
  273. <if test="maintenanceCompletionTreeRecord.planMonth != null and maintenanceCompletionTreeRecord.planMonth != ''">
  274. and DATE_FORMAT(stwp.start_time, '%Y-%m') = #{maintenanceCompletionTreeRecord.planMonth}
  275. </if>
  276. group by
  277. stwp.section_id,
  278. stwp.section_name,
  279. stwp.maintenance_company_id,
  280. stwp.maintenance_company_name
  281. </sql>
  282. </mapper>