Нет описания

TLhzxStreetTreeSpecialPlanMapper.xml 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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.TLhzxStreetTreeSpecialPlanMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
  6. <id column="id" property="id" />
  7. <result column="section_id" property="sectionId" />
  8. <result column="section_name" property="sectionName" />
  9. <result column="maintenance_company_id" property="maintenanceCompanyId" />
  10. <result column="maintenance_company_name" property="maintenanceCompanyName" />
  11. <result column="file_title" property="fileTitle" />
  12. <result column="file_name" property="fileName" />
  13. <result column="file_url" property="fileUrl" />
  14. <result column="type" property="type" />
  15. <result column="upload_year" property="uploadYear" />
  16. <result column="create_user_id" property="createUserId" />
  17. <result column="create_date" property="createDate" />
  18. <result column="update_user_id" property="updateUserId" />
  19. <result column="update_date" property="updateDate" />
  20. <result column="del_flg" property="delFlg" />
  21. <result column="remark" property="remark" />
  22. </resultMap>
  23. <!-- 通用查询结果列 -->
  24. <sql id="Base_Column_List">
  25. id, section_id, section_name, maintenance_company_id, maintenance_company_name, file_title, file_name, file_url, type, upload_year, create_user_id, create_date, update_user_id, update_date, del_flg, remark
  26. </sql>
  27. <select id="selectStreetTreeSpecialPlanBySection"
  28. resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
  29. select
  30. temp.*
  31. from
  32. (<include refid="streetTreeSpecialPlanSql"/>) temp
  33. </select>
  34. <select id="selectStreetTreeSpecialPlanSumCount"
  35. resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
  36. select
  37. sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount,
  38. sum(if(temp.winterTrimCount is null, 0, temp.winterTrimCount)) as winterTrimCount,
  39. sum(if(temp.hairControlCount is null, 0, temp.hairControlCount)) as hairControlCount,
  40. sum(if(temp.camphorPruningCount is null, 0, temp.camphorPruningCount)) as camphorPruningCount,
  41. sum(if(temp.treePeelCount is null, 0, temp.treePeelCount)) as treePeelCount,
  42. sum(if(temp.helpTrimCount is null, 0, temp.helpTrimCount)) as helpTrimCount
  43. from
  44. (<include refid="streetTreeSpecialPlanSql"/>) temp
  45. </select>
  46. <sql id="streetTreeSpecialPlanSql">
  47. select distinct
  48. rsmc.section_id,
  49. s.section_name,
  50. rsmc.maintenance_company_id,
  51. mc.maintenance_company_name,
  52. if(stsp.sumCount is null, 0, stsp.sumCount) as sumCount,
  53. if(stsp.winterTrimCount is null, 0, stsp.winterTrimCount) as winterTrimCount,
  54. if(stsp.hairControlCount is null, 0, stsp.hairControlCount) as hairControlCount,
  55. if(stsp.camphorPruningCount is null, 0, stsp.camphorPruningCount) as camphorPruningCount,
  56. if(stsp.treePeelCount is null, 0, stsp.treePeelCount) as treePeelCount,
  57. if(stsp.helpTrimCount is null, 0, stsp.helpTrimCount) as helpTrimCount
  58. from
  59. T_Lhzx_Road_Section_Maintenance_Company rsmc
  60. left join
  61. T_Lhzx_Section s on rsmc.section_id = s.id
  62. left join
  63. T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
  64. left join
  65. (
  66. select
  67. section_id,
  68. maintenance_company_id,
  69. count(1) as sumCount,
  70. sum(if(type = 1, 1, 0)) as winterTrimCount,
  71. sum(if(type = 2, 1, 0)) as hairControlCount,
  72. sum(if(type = 3, 1, 0)) as camphorPruningCount,
  73. sum(if(type = 4, 1, 0)) as treePeelCount,
  74. sum(if(type = 5, 1, 0)) as helpTrimCount
  75. from
  76. T_Lhzx_Street_Tree_Special_Plan
  77. where
  78. del_flg = 0
  79. <if test="uploadYear != null and uploadYear != ''">
  80. and upload_year = #{uploadYear}
  81. </if>
  82. group by
  83. section_id,
  84. section_name,
  85. maintenance_company_id,
  86. maintenance_company_name
  87. ) stsp on rsmc.section_id = stsp.section_id and rsmc.maintenance_company_id = stsp.maintenance_company_id
  88. <where>
  89. <if test="sectionId != null">
  90. and rsmc.section_id = #{sectionId}
  91. </if>
  92. <if test="maintenanceCompanyId != null">
  93. and rsmc.maintenance_company_id = #{maintenanceCompanyId}
  94. </if>
  95. </where>
  96. order by
  97. rsmc.section_id, rsmc.maintenance_company_id
  98. </sql>
  99. </mapper>