PdmReportPlanWeekMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.powerdistribution.mapper.PdmReportPlanWeekMapper">
  6. <resultMap type="PdmReportPlanWeek" id="PdmReportPlanWeekResult">
  7. <result property="id" column="id" />
  8. <result property="company" column="company" />
  9. <result property="reportDate" column="report_date" />
  10. <result property="reportEndDate" column="report_end_date" />
  11. <result property="total" column="total" />
  12. <result property="weekSum" column="week_sum" />
  13. <result property="weekCancelSum" column="week_cancel_sum" />
  14. <result property="weekRatio" column="week_ratio" />
  15. <result property="temporarySum" column="temporary_sum" />
  16. <result property="temporaryCancelSum" column="temporary_cancel_sum" />
  17. <result property="temporaryRatio" column="temporary_ratio" />
  18. <result property="temporaryPlanRatio" column="temporary_plan_ratio" />
  19. <result property="createBy" column="create_by" />
  20. <result property="createTime" column="create_time" />
  21. <result property="updateBy" column="update_by" />
  22. <result property="updateTime" column="update_time" />
  23. </resultMap>
  24. <sql id="selectPdmReportPlanWeekVo">
  25. select id, company, report_date, report_end_date, total, week_sum, week_cancel_sum, week_ratio, temporary_sum, temporary_cancel_sum, temporary_ratio, temporary_plan_ratio, create_by, create_time, update_by, update_time from pdm_report_plan_week
  26. </sql>
  27. <select id="selectPdmReportPlanWeekList" parameterType="PdmReportPlanWeek" resultMap="PdmReportPlanWeekResult">
  28. select * from (
  29. <include refid="selectPdmReportPlanWeekVo"/>
  30. <where>
  31. <if test="company != null and company != ''"> and company = #{company}</if>
  32. <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
  33. <if test="reportEndDate != null and reportEndDate != ''"> and report_end_date = #{reportEndDate}</if>
  34. <if test="total != null "> and total = #{total}</if>
  35. <if test="weekSum != null "> and week_sum = #{weekSum}</if>
  36. <if test="weekCancelSum != null "> and week_cancel_sum = #{weekCancelSum}</if>
  37. <if test="weekRatio != null and weekRatio != ''"> and week_ratio = #{weekRatio}</if>
  38. <if test="temporarySum != null "> and temporary_sum = #{temporarySum}</if>
  39. <if test="temporaryCancelSum != null "> and temporary_cancel_sum = #{temporaryCancelSum}</if>
  40. <if test="temporaryRatio != null and temporaryRatio != ''"> and temporary_ratio = #{temporaryRatio}</if>
  41. <if test="temporaryPlanRatio != null and temporaryPlanRatio != ''"> and temporary_plan_ratio = #{temporaryPlanRatio}</if>
  42. </where>
  43. UNION
  44. SELECT
  45. sum(id) as id,
  46. '总计' as company,
  47. report_date,
  48. report_end_date,
  49. sum(ifnull(total,0)) total,
  50. sum(ifnull(week_sum,0)) week_sum,
  51. sum(ifnull(week_cancel_sum,0)) week_cancel_sum,
  52. CONCAT(round((sum(ifnull(week_sum,0))-sum(ifnull(week_cancel_sum,0)))/sum(ifnull(week_sum,0))*100,2),'%') week_ratio,
  53. sum(ifnull(temporary_sum,0)) temporary_sum,
  54. sum(ifnull(temporary_cancel_sum,0)) temporary_cancel_sum,
  55. CONCAT(round((sum(ifnull(temporary_sum,0))-sum(ifnull(temporary_cancel_sum,0)))/sum(ifnull(temporary_sum,0))*100,2),'%') temporary_ratio,
  56. CONCAT(round(sum(ifnull(temporary_sum,0))/(sum(ifnull(week_sum,0))+sum(ifnull(temporary_sum,0)))*100,2),'%') temporary_plan_ratio,
  57. null create_by ,
  58. null create_time,
  59. null update_by,
  60. null update_time FROM
  61. pdm_report_plan_week
  62. <where>
  63. <if test="company != null and company != ''"> and company = #{company}</if>
  64. <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
  65. <if test="reportEndDate != null and reportEndDate != ''"> and report_end_date = #{reportEndDate}</if>
  66. <if test="total != null "> and total = #{total}</if>
  67. <if test="weekSum != null "> and week_sum = #{weekSum}</if>
  68. <if test="weekCancelSum != null "> and week_cancel_sum = #{weekCancelSum}</if>
  69. <if test="weekRatio != null and weekRatio != ''"> and week_ratio = #{weekRatio}</if>
  70. <if test="temporarySum != null "> and temporary_sum = #{temporarySum}</if>
  71. <if test="temporaryCancelSum != null "> and temporary_cancel_sum = #{temporaryCancelSum}</if>
  72. <if test="temporaryRatio != null and temporaryRatio != ''"> and temporary_ratio = #{temporaryRatio}</if>
  73. <if test="temporaryPlanRatio != null and temporaryPlanRatio != ''"> and temporary_plan_ratio = #{temporaryPlanRatio}</if>
  74. </where>
  75. GROUP BY report_date) a order by id asc
  76. </select>
  77. <select id="selectPdmReportPlanWeekById" parameterType="Long" resultMap="PdmReportPlanWeekResult">
  78. <include refid="selectPdmReportPlanWeekVo"/>
  79. where id = #{id}
  80. </select>
  81. <insert id="insertPdmReportPlanWeek" parameterType="PdmReportPlanWeek" useGeneratedKeys="true" keyProperty="id">
  82. insert into pdm_report_plan_week
  83. <trim prefix="(" suffix=")" suffixOverrides=",">
  84. <if test="company != null">company,</if>
  85. <if test="reportDate != null">report_date,</if>
  86. <if test="reportEndDate != null">report_end_date,</if>
  87. <if test="total != null">total,</if>
  88. <if test="weekSum != null">week_sum,</if>
  89. <if test="weekCancelSum != null">week_cancel_sum,</if>
  90. <if test="weekRatio != null">week_ratio,</if>
  91. <if test="temporarySum != null">temporary_sum,</if>
  92. <if test="temporaryCancelSum != null">temporary_cancel_sum,</if>
  93. <if test="temporaryRatio != null">temporary_ratio,</if>
  94. <if test="temporaryPlanRatio != null">temporary_plan_ratio,</if>
  95. <if test="createBy != null">create_by,</if>
  96. <if test="createTime != null">create_time,</if>
  97. <if test="updateBy != null">update_by,</if>
  98. <if test="updateTime != null">update_time,</if>
  99. </trim>
  100. <trim prefix="values (" suffix=")" suffixOverrides=",">
  101. <if test="company != null">#{company},</if>
  102. <if test="reportDate != null">#{reportDate},</if>
  103. <if test="reportEndDate != null">#{reportEndDate},</if>
  104. <if test="total != null">#{total},</if>
  105. <if test="weekSum != null">#{weekSum},</if>
  106. <if test="weekCancelSum != null">#{weekCancelSum},</if>
  107. <if test="weekRatio != null">#{weekRatio},</if>
  108. <if test="temporarySum != null">#{temporarySum},</if>
  109. <if test="temporaryCancelSum != null">#{temporaryCancelSum},</if>
  110. <if test="temporaryRatio != null">#{temporaryRatio},</if>
  111. <if test="temporaryPlanRatio != null">#{temporaryPlanRatio},</if>
  112. <if test="createBy != null">#{createBy},</if>
  113. <if test="createTime != null">#{createTime},</if>
  114. <if test="updateBy != null">#{updateBy},</if>
  115. <if test="updateTime != null">#{updateTime},</if>
  116. </trim>
  117. </insert>
  118. <update id="updatePdmReportPlanWeek" parameterType="PdmReportPlanWeek">
  119. update pdm_report_plan_week
  120. <trim prefix="SET" suffixOverrides=",">
  121. <if test="company != null">company = #{company},</if>
  122. <if test="reportDate != null">report_date = #{reportDate},</if>
  123. <if test="reportEndDate != null">report_end_date = #{reportEndDate},</if>
  124. <if test="total != null">total = #{total},</if>
  125. <if test="weekSum != null">week_sum = #{weekSum},</if>
  126. <if test="weekCancelSum != null">week_cancel_sum = #{weekCancelSum},</if>
  127. <if test="weekRatio != null">week_ratio = #{weekRatio},</if>
  128. <if test="temporarySum != null">temporary_sum = #{temporarySum},</if>
  129. <if test="temporaryCancelSum != null">temporary_cancel_sum = #{temporaryCancelSum},</if>
  130. <if test="temporaryRatio != null">temporary_ratio = #{temporaryRatio},</if>
  131. <if test="temporaryPlanRatio != null">temporary_plan_ratio = #{temporaryPlanRatio},</if>
  132. <if test="createBy != null">create_by = #{createBy},</if>
  133. <if test="createTime != null">create_time = #{createTime},</if>
  134. <if test="updateBy != null">update_by = #{updateBy},</if>
  135. <if test="updateTime != null">update_time = #{updateTime},</if>
  136. </trim>
  137. where id = #{id}
  138. </update>
  139. <delete id="deletePdmReportPlanWeekById" parameterType="Long">
  140. delete from pdm_report_plan_week where id = #{id}
  141. </delete>
  142. <delete id="deletePdmReportPlanWeekByIds" parameterType="String">
  143. delete from pdm_report_plan_week where id in
  144. <foreach item="id" collection="array" open="(" separator="," close=")">
  145. #{id}
  146. </foreach>
  147. </delete>
  148. </mapper>