Нет описания

TLhzxMaintenanceCompletionGreenRecordMapper.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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.TLhzxMaintenanceCompletionGreenRecordMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  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="seedling_adjustment_m" property="seedlingAdjustmentM" />
  13. <result column="seedling_adjustment_z" property="seedlingAdjustmentZ" />
  14. <result column="remove_stump" property="removeStump" />
  15. <result column="green_weed" property="greenWeed" />
  16. <result column="facility_maintenance" property="facilityMaintenance" />
  17. <result column="green_trim_count" property="greenTrimCount" />
  18. <result column="green_trim" property="greenTrim" />
  19. <result column="apply_fertilizer" property="applyFertilizer" />
  20. <result column="trimming" property="trimming" />
  21. <result column="green_space_clean" property="greenSpaceClean" />
  22. <result column="righting_seedling" property="rightingSeedling" />
  23. <result column="watering" property="watering" />
  24. <result column="turn_soil" property="turnSoil" />
  25. <result column="underpin" property="underpin" />
  26. <result column="underpin_start_spot" property="underpinStartSpot" />
  27. <result column="underpin_end_spot" property="underpinEndSpot" />
  28. <result column="other" property="other" />
  29. <result column="create_user_id" property="createUserId" />
  30. <result column="create_date" property="createDate" />
  31. <result column="update_user_id" property="updateUserId" />
  32. <result column="update_date" property="updateDate" />
  33. <result column="del_flg" property="delFlg" />
  34. <result column="remark" property="remark" />
  35. </resultMap>
  36. <!-- 通用查询结果列 -->
  37. <sql id="Base_Column_List">
  38. id, completion_record_id, road_id, road_name, road_start_spot, road_end_spot, seedling_adjustment_m, seedling_adjustment_z, remove_stump, green_weed, facility_maintenance, green_trim_count, green_trim, apply_fertilizer, trimming, green_space_clean, righting_seedling, watering, turn_soil, underpin, underpin_start_spot, underpin_end_spot, other, create_user_id, create_date, update_user_id, update_date, del_flg, remark
  39. </sql>
  40. <select id="selectCompletionGreenRecordPage"
  41. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  42. select
  43. temp.*
  44. from
  45. (<include refid="selectCompletionGreenRecordPageSql"/>) temp
  46. </select>
  47. <select id="selectGreenWorkPlanItemPage"
  48. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  49. select
  50. temp.*
  51. from
  52. (<include refid="selectGreenWorkPlanItemPageSql"/>) temp
  53. </select>
  54. <select id="selectCompletionGreenRecordListBySectionType"
  55. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  56. select
  57. temp.section_type,
  58. sum(if(temp.seedling_adjustment_m is null, 0, temp.seedling_adjustment_m)) as seedling_adjustment_m,
  59. sum(if(temp.seedling_adjustment_z is null, 0, temp.seedling_adjustment_z)) as seedling_adjustment_z,
  60. sum(if(temp.remove_stump is null, 0, temp.remove_stump)) as remove_stump,
  61. sum(if(temp.green_weed is null, 0, temp.green_weed)) as green_weed,
  62. sum(if(temp.facility_maintenance is null, 0, temp.facility_maintenance)) as facility_maintenance,
  63. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  64. sum(if(temp.green_trim is null, 0, temp.green_trim)) as green_trim,
  65. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  66. sum(if(temp.trimming is null, 0, temp.trimming)) as trimming,
  67. sum(if(temp.green_space_clean is null, 0, temp.green_space_clean)) as green_space_clean,
  68. sum(if(temp.righting_seedling is null, 0, temp.righting_seedling)) as righting_seedling,
  69. sum(if(temp.watering is null, 0, temp.watering)) as watering,
  70. sum(if(temp.turn_soil is null, 0, temp.turn_soil)) as turn_soil
  71. from
  72. (<include refid="selectCompletionGreenRecordPageSql"/>) temp
  73. group by
  74. temp.section_type
  75. </select>
  76. <select id="getCompletionGreenRecordSumCount"
  77. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  78. select
  79. sum(if(temp.seedling_adjustment_m is null, 0, temp.seedling_adjustment_m)) as seedling_adjustment_m,
  80. sum(if(temp.seedling_adjustment_z is null, 0, temp.seedling_adjustment_z)) as seedling_adjustment_z,
  81. sum(if(temp.remove_stump is null, 0, temp.remove_stump)) as remove_stump,
  82. sum(if(temp.green_weed is null, 0, temp.green_weed)) as green_weed,
  83. sum(if(temp.facility_maintenance is null, 0, temp.facility_maintenance)) as facility_maintenance,
  84. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  85. sum(if(temp.green_trim is null, 0, temp.green_trim)) as green_trim,
  86. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  87. sum(if(temp.trimming is null, 0, temp.trimming)) as trimming,
  88. sum(if(temp.green_space_clean is null, 0, temp.green_space_clean)) as green_space_clean,
  89. sum(if(temp.righting_seedling is null, 0, temp.righting_seedling)) as righting_seedling,
  90. sum(if(temp.watering is null, 0, temp.watering)) as watering,
  91. sum(if(temp.turn_soil is null, 0, temp.turn_soil)) as turn_soil
  92. from
  93. (<include refid="selectCompletionGreenRecordPageSql"/>) temp
  94. </select>
  95. <select id="selectGreenWorkPlanItemListBySectionType"
  96. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  97. select
  98. temp.section_type,
  99. sum(if(temp.seedling_adjustment_m is null, 0, temp.seedling_adjustment_m)) as seedling_adjustment_m,
  100. sum(if(temp.seedling_adjustment_z is null, 0, temp.seedling_adjustment_z)) as seedling_adjustment_z,
  101. sum(if(temp.remove_stump is null, 0, temp.remove_stump)) as remove_stump,
  102. sum(if(temp.green_weed is null, 0, temp.green_weed)) as green_weed,
  103. sum(if(temp.facility_maintenance is null, 0, temp.facility_maintenance)) as facility_maintenance,
  104. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  105. sum(if(temp.green_trim is null, 0, temp.green_trim)) as green_trim,
  106. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  107. sum(if(temp.trimming is null, 0, temp.trimming)) as trimming,
  108. sum(if(temp.green_space_clean is null, 0, temp.green_space_clean)) as green_space_clean,
  109. sum(if(temp.righting_seedling is null, 0, temp.righting_seedling)) as righting_seedling,
  110. sum(if(temp.watering is null, 0, temp.watering)) as watering,
  111. sum(if(temp.turn_soil is null, 0, temp.turn_soil)) as turn_soil
  112. from
  113. (<include refid="selectGreenWorkPlanItemPageSql"/>) temp
  114. group by
  115. temp.section_type
  116. </select>
  117. <select id="getGreenWorkPlanItemSumCount"
  118. resultType="com.yt.zhylplat.moduleMain.completion.entity.TLhzxMaintenanceCompletionGreenRecord">
  119. select
  120. sum(if(temp.seedling_adjustment_m is null, 0, temp.seedling_adjustment_m)) as seedling_adjustment_m,
  121. sum(if(temp.seedling_adjustment_z is null, 0, temp.seedling_adjustment_z)) as seedling_adjustment_z,
  122. sum(if(temp.remove_stump is null, 0, temp.remove_stump)) as remove_stump,
  123. sum(if(temp.green_weed is null, 0, temp.green_weed)) as green_weed,
  124. sum(if(temp.facility_maintenance is null, 0, temp.facility_maintenance)) as facility_maintenance,
  125. sum(if(temp.green_trim_count is null, 0, temp.green_trim_count)) as green_trim_count,
  126. sum(if(temp.green_trim is null, 0, temp.green_trim)) as green_trim,
  127. sum(if(temp.apply_fertilizer is null, 0, temp.apply_fertilizer)) as apply_fertilizer,
  128. sum(if(temp.trimming is null, 0, temp.trimming)) as trimming,
  129. sum(if(temp.green_space_clean is null, 0, temp.green_space_clean)) as green_space_clean,
  130. sum(if(temp.righting_seedling is null, 0, temp.righting_seedling)) as righting_seedling,
  131. sum(if(temp.watering is null, 0, temp.watering)) as watering,
  132. sum(if(temp.turn_soil is null, 0, temp.turn_soil)) as turn_soil
  133. from
  134. (<include refid="selectGreenWorkPlanItemPageSql"/>) temp
  135. </select>
  136. <sql id="selectCompletionGreenRecordPageSql">
  137. select
  138. s.section_type,
  139. rsmc.section_id,
  140. s.section_name,
  141. rsmc.maintenance_company_id,
  142. mc.maintenance_company_name,
  143. if(cgr.seedling_adjustment_m is null, 0, cgr.seedling_adjustment_m) as seedling_adjustment_m,
  144. if(cgr.seedling_adjustment_z is null, 0, cgr.seedling_adjustment_z) as seedling_adjustment_z,
  145. if(cgr.remove_stump is null, 0, cgr.remove_stump) as remove_stump,
  146. if(cgr.green_weed is null, 0, cgr.green_weed) as green_weed,
  147. if(cgr.facility_maintenance is null, 0, cgr.facility_maintenance) as facility_maintenance,
  148. if(cgr.green_trim_count is null, 0, cgr.green_trim_count) as green_trim_count,
  149. if(cgr.green_trim is null, 0, cgr.green_trim) as green_trim,
  150. if(cgr.apply_fertilizer is null, 0, cgr.apply_fertilizer) as apply_fertilizer,
  151. if(cgr.trimming is null, 0, cgr.trimming) as trimming,
  152. if(cgr.green_space_clean is null, 0, cgr.green_space_clean) as green_space_clean,
  153. if(cgr.righting_seedling is null, 0, cgr.righting_seedling) as righting_seedling,
  154. if(cgr.watering is null, 0, cgr.watering) as watering,
  155. if(cgr.turn_soil is null, 0, cgr.turn_soil) as turn_soil,
  156. cgr.other
  157. from (
  158. select distinct
  159. section_id,
  160. maintenance_company_id
  161. from
  162. T_Lhzx_Road_Section_Maintenance_Company
  163. where
  164. del_flg = 0
  165. ) rsmc
  166. left join
  167. (<include refid="completionGreenRecordSql"/>) cgr on rsmc.section_id = cgr.section_id and rsmc.maintenance_company_id = cgr.maintenance_company_id
  168. left join
  169. T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
  170. left join
  171. T_Lhzx_Section s on rsmc.section_id = s.id
  172. <where>
  173. <if test="maintenanceCompletionGreenRecord.sectionId">
  174. and rsmc.section_id = #{maintenanceCompletionGreenRecord.sectionId}
  175. </if>
  176. <if test="maintenanceCompletionGreenRecord.maintenanceCompanyId">
  177. and rsmc.maintenance_company_id = #{maintenanceCompletionGreenRecord.maintenanceCompanyId}
  178. </if>
  179. </where>
  180. order by
  181. rsmc.section_id,
  182. rsmc.maintenance_company_id
  183. </sql>
  184. <sql id="selectGreenWorkPlanItemPageSql">
  185. select
  186. s.section_type,
  187. rsmc.section_id,
  188. s.section_name,
  189. rsmc.maintenance_company_id,
  190. mc.maintenance_company_name,
  191. if(cgr.seedling_adjustment_m is null, 0, cgr.seedling_adjustment_m) as seedling_adjustment_m,
  192. if(cgr.seedling_adjustment_z is null, 0, cgr.seedling_adjustment_z) as seedling_adjustment_z,
  193. if(cgr.green_weed is null, 0, cgr.green_weed) as green_weed,
  194. if(cgr.facility_maintenance is null, 0, cgr.facility_maintenance) as facility_maintenance,
  195. if(cgr.green_trim_count is null, 0, cgr.green_trim_count) as green_trim_count,
  196. if(cgr.green_trim is null, 0, cgr.green_trim) as green_trim,
  197. if(cgr.apply_fertilizer is null, 0, cgr.apply_fertilizer) as apply_fertilizer,
  198. if(cgr.trimming is null, 0, cgr.trimming) as trimming,
  199. if(cgr.watering is null, 0, cgr.watering) as watering,
  200. if(cgr.turn_soil is null, 0, cgr.turn_soil) as turn_soil,
  201. cgr.other
  202. from (
  203. select distinct
  204. section_id,
  205. maintenance_company_id
  206. from
  207. T_Lhzx_Road_Section_Maintenance_Company
  208. where
  209. del_flg = 0
  210. ) rsmc
  211. left join
  212. (<include refid="greenWorkPlanItemSql"/>) cgr on rsmc.section_id = cgr.section_id and rsmc.maintenance_company_id = cgr.maintenance_company_id
  213. left join
  214. T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
  215. left join
  216. T_Lhzx_Section s on rsmc.section_id = s.id
  217. <where>
  218. <if test="maintenanceCompletionGreenRecord.sectionId">
  219. and rsmc.section_id = #{maintenanceCompletionGreenRecord.sectionId}
  220. </if>
  221. <if test="maintenanceCompletionGreenRecord.sectionType">
  222. and s.section_type = #{maintenanceCompletionGreenRecord.sectionType}
  223. </if>
  224. <if test="maintenanceCompletionGreenRecord.maintenanceCompanyId">
  225. and rsmc.maintenance_company_id = #{maintenanceCompletionGreenRecord.maintenanceCompanyId}
  226. </if>
  227. </where>
  228. order by
  229. rsmc.section_id,
  230. rsmc.maintenance_company_id
  231. </sql>
  232. <sql id="completionGreenRecordSql">
  233. select
  234. mcr.section_id,
  235. mcr.section_name,
  236. mcr.maintenance_company_id,
  237. mcr.maintenance_company_name,
  238. sum(if(mcgr.seedling_adjustment_m is null, 0, mcgr.seedling_adjustment_m)) as seedling_adjustment_m,
  239. sum(if(mcgr.seedling_adjustment_z is null, 0, mcgr.seedling_adjustment_z)) as seedling_adjustment_z,
  240. sum(if(mcgr.remove_stump is null, 0, mcgr.remove_stump)) as remove_stump,
  241. sum(if(mcgr.green_weed is null, 0, mcgr.green_weed)) as green_weed,
  242. sum(if(mcgr.facility_maintenance is null, 0, mcgr.facility_maintenance)) as facility_maintenance,
  243. sum(if(mcgr.green_trim_count is null, 0, mcgr.green_trim_count)) as green_trim_count,
  244. sum(if(mcgr.green_trim is null, 0, mcgr.green_trim)) as green_trim,
  245. sum(if(mcgr.apply_fertilizer is null, 0, mcgr.apply_fertilizer)) as apply_fertilizer,
  246. sum(if(mcgr.trimming is null, 0, mcgr.trimming)) as trimming,
  247. sum(if(mcgr.green_space_clean is null, 0, mcgr.green_space_clean)) as green_space_clean,
  248. sum(if(mcgr.righting_seedling is null, 0, mcgr.righting_seedling)) as righting_seedling,
  249. sum(if(mcgr.watering is null, 0, mcgr.watering)) as watering,
  250. sum(if(mcgr.turn_soil is null, 0, mcgr.turn_soil)) as turn_soil,
  251. group_concat(mcgr.other separator ';') as other
  252. from
  253. T_Lhzx_Maintenance_Completion_Green_Record mcgr
  254. left join
  255. T_Lhzx_Maintenance_Completion_Record mcr on mcgr.completion_record_id = mcr.id
  256. <where>
  257. and mcr.del_flg = 0
  258. <if test="maintenanceCompletionGreenRecord.queryStartTime != null and maintenanceCompletionGreenRecord.queryStartTime != ''">
  259. and DATE_FORMAT(mcr.complete_date, '%Y-%m-%d') <![CDATA[ >= ]]> #{maintenanceCompletionGreenRecord.queryStartTime}
  260. </if>
  261. <if test="maintenanceCompletionGreenRecord.queryEndTime != null and maintenanceCompletionGreenRecord.queryEndTime != ''">
  262. and DATE_FORMAT(mcr.complete_date, '%Y-%m-%d') <![CDATA[ <= ]]> #{maintenanceCompletionGreenRecord.queryEndTime}
  263. </if>
  264. <if test="maintenanceCompletionGreenRecord.planMonth != null and maintenanceCompletionGreenRecord.planMonth != ''">
  265. and DATE_FORMAT(mcr.complete_date, '%Y-%m') = #{maintenanceCompletionGreenRecord.planMonth}
  266. </if>
  267. </where>
  268. group by
  269. mcr.section_id,
  270. mcr.section_name,
  271. mcr.maintenance_company_id,
  272. mcr.maintenance_company_name
  273. </sql>
  274. <sql id="greenWorkPlanItemSql">
  275. select
  276. gwp.section_id,
  277. gwp.object_id as maintenance_company_id,
  278. sum(if(gwpdi.seedling_adjustment_m is null, 0, gwpdi.seedling_adjustment_m)) as seedling_adjustment_m,
  279. sum(if(gwpdi.seedling_adjustment_z is null, 0, gwpdi.seedling_adjustment_z)) as seedling_adjustment_z,
  280. sum(if(gwpdi.green_weed is null, 0, gwpdi.green_weed)) as green_weed,
  281. sum(if(gwpdi.facility_maintenance is null, 0, gwpdi.facility_maintenance)) as facility_maintenance,
  282. sum(if(gwpdi.green_trim_count is null, 0, gwpdi.green_trim_count)) as green_trim_count,
  283. sum(if(gwpdi.green_trim is null, 0, gwpdi.green_trim)) as green_trim,
  284. sum(if(gwpdi.apply_fertilizer is null, 0, gwpdi.apply_fertilizer)) as apply_fertilizer,
  285. sum(if(gwpdi.trimming is null, 0, gwpdi.trimming)) as trimming,
  286. sum(if(gwpdi.watering is null, 0, gwpdi.watering)) as watering,
  287. sum(if(gwpdi.turn_soil is null, 0, gwpdi.turn_soil)) as turn_soil,
  288. group_concat(gwpdi.facility_maintenance separator ';') as other
  289. from
  290. T_Lhgy_Green_Work_Plan_Detail_Item gwpdi
  291. left join
  292. T_Lhgy_Green_Work_Plan gwp on gwpdi.plan_id = gwp.id
  293. <where>
  294. and gwpdi.delete_flag = 0
  295. <if test="maintenanceCompletionGreenRecord.planMonth != null and maintenanceCompletionGreenRecord.planMonth != ''">
  296. and DATE_FORMAT(gwp.start_time, '%Y-%m') = #{maintenanceCompletionGreenRecord.planMonth}
  297. </if>
  298. </where>
  299. group by
  300. gwp.section_id,
  301. gwp.object_id
  302. </sql>
  303. </mapper>