Brak opisu

TLhzxFlowerChangePlanMapper.xml 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.flower.mapper.TLhzxFlowerChangePlanMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
  6. <id column="id" property="id" />
  7. <result column="plan_name" property="planName" />
  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="change_season" property="changeSeason" />
  13. <result column="change_type" property="changeType" />
  14. <result column="change_amount" property="changeAmount" />
  15. <result column="flower_source" property="flowerSource" />
  16. <result column="flower_variety" property="flowerVariety" />
  17. <result column="expected_date" property="expectedDate" />
  18. <result column="complete_state" property="completeState" />
  19. <result column="complete_rate" property="completeRate" />
  20. <result column="create_user_id" property="createUserId" />
  21. <result column="create_user_name" property="createUserName" />
  22. <result column="create_date" property="createDate" />
  23. <result column="update_user_id" property="updateUserId" />
  24. <result column="update_user_name" property="updateUserName" />
  25. <result column="update_date" property="updateDate" />
  26. <result column="del_flg" property="delFlg" />
  27. <result column="remark" property="remark" />
  28. </resultMap>
  29. <!-- 通用查询结果列 -->
  30. <sql id="Base_Column_List">
  31. id, plan_name, section_id, section_name, maintenance_company_id, maintenance_company_name, change_season, change_type, change_amount, flower_source, flower_variety, expected_date, complete_state, complete_rate, create_user_id, create_user_name, create_date, update_user_id, update_user_name, update_date, del_flg, remark
  32. </sql>
  33. <select id="selectFlowerChangePlanListBySeason"
  34. resultType="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
  35. select
  36. temp.*
  37. from
  38. (<include refid="flowerChangePlanListSql"/>) temp
  39. </select>
  40. <select id="selectFlowerChangePlanCountBySeason"
  41. resultType="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
  42. select
  43. sum(if(temp.change_amount is null, 0, temp.change_amount)) as change_amount,
  44. sum(if(temp.complete_amount is null, 0, temp.complete_amount)) as complete_amount,
  45. case
  46. when sum(if(temp.change_amount is null, 0, temp.change_amount)) = 0
  47. then 0
  48. when sum(if(temp.change_amount is null, 0, temp.change_amount)) != 0
  49. then sum(if(temp.complete_amount is null, 0, temp.complete_amount)) / sum(if(temp.change_amount is null, 0, temp.change_amount))
  50. end as completeRate
  51. from
  52. (<include refid="flowerChangePlanListSql"/>) temp
  53. </select>
  54. <sql id="flowerChangePlanListSql">
  55. select
  56. fcp.change_season,
  57. sum(if(fcp.change_amount is null, 0, fcp.change_amount)) as change_amount,
  58. sum(if(fcpi.complete_amount is null, 0, fcpi.complete_amount)) as complete_amount,
  59. case
  60. when sum(if(fcp.change_amount is null, 0, fcp.change_amount)) = 0
  61. then 0
  62. when sum(if(fcp.change_amount is null, 0, fcp.change_amount)) != 0
  63. then sum(if(fcpi.complete_amount is null, 0, fcpi.complete_amount)) / sum(if(fcp.change_amount is null, 0, fcp.change_amount))
  64. end as completeRate
  65. from
  66. T_Lhzx_Flower_Change_Plan fcp
  67. left join
  68. (
  69. select
  70. plan_id,
  71. sum(if(complete_amount is null, 0, complete_amount)) as complete_amount
  72. from
  73. T_Lhzx_Flower_Change_Plan_Item
  74. where
  75. del_flg = 0
  76. group by
  77. plan_id
  78. ) fcpi on fcp.id = fcpi.plan_id
  79. where
  80. fcp.del_flg = 0
  81. <if test="planYear != null and planYear != ''">
  82. and date_format(fcp.create_date, '%Y') = #{planYear}
  83. </if>
  84. <if test="changeSeason != null">
  85. and fcp.change_season = #{changeSeason}
  86. </if>
  87. <if test="changeType != null">
  88. and fcp.change_type = #{changeType}
  89. </if>
  90. group by
  91. fcp.change_season
  92. </sql>
  93. </mapper>