123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruoyi.powerdistribution.mapper.PdmReportPlanWeekMapper">
- <resultMap type="PdmReportPlanWeek" id="PdmReportPlanWeekResult">
- <result property="id" column="id" />
- <result property="company" column="company" />
- <result property="reportDate" column="report_date" />
- <result property="reportEndDate" column="report_end_date" />
- <result property="total" column="total" />
- <result property="weekSum" column="week_sum" />
- <result property="weekCancelSum" column="week_cancel_sum" />
- <result property="weekRatio" column="week_ratio" />
- <result property="temporarySum" column="temporary_sum" />
- <result property="temporaryCancelSum" column="temporary_cancel_sum" />
- <result property="temporaryRatio" column="temporary_ratio" />
- <result property="temporaryPlanRatio" column="temporary_plan_ratio" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <sql id="selectPdmReportPlanWeekVo">
- 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
- </sql>
- <select id="selectPdmReportPlanWeekList" parameterType="PdmReportPlanWeek" resultMap="PdmReportPlanWeekResult">
- select * from (
- <include refid="selectPdmReportPlanWeekVo"/>
- <where>
- <if test="company != null and company != ''"> and company = #{company}</if>
- <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
- <if test="reportEndDate != null and reportEndDate != ''"> and report_end_date = #{reportEndDate}</if>
- <if test="total != null "> and total = #{total}</if>
- <if test="weekSum != null "> and week_sum = #{weekSum}</if>
- <if test="weekCancelSum != null "> and week_cancel_sum = #{weekCancelSum}</if>
- <if test="weekRatio != null and weekRatio != ''"> and week_ratio = #{weekRatio}</if>
- <if test="temporarySum != null "> and temporary_sum = #{temporarySum}</if>
- <if test="temporaryCancelSum != null "> and temporary_cancel_sum = #{temporaryCancelSum}</if>
- <if test="temporaryRatio != null and temporaryRatio != ''"> and temporary_ratio = #{temporaryRatio}</if>
- <if test="temporaryPlanRatio != null and temporaryPlanRatio != ''"> and temporary_plan_ratio = #{temporaryPlanRatio}</if>
- </where>
- UNION
- SELECT
- sum(id) as id,
- '总计' as company,
- report_date,
- report_end_date,
- sum(ifnull(total,0)) total,
- sum(ifnull(week_sum,0)) week_sum,
- sum(ifnull(week_cancel_sum,0)) week_cancel_sum,
- CONCAT(round((sum(ifnull(week_sum,0))-sum(ifnull(week_cancel_sum,0)))/sum(ifnull(week_sum,0))*100,2),'%') week_ratio,
- sum(ifnull(temporary_sum,0)) temporary_sum,
- sum(ifnull(temporary_cancel_sum,0)) temporary_cancel_sum,
- CONCAT(round((sum(ifnull(temporary_sum,0))-sum(ifnull(temporary_cancel_sum,0)))/sum(ifnull(temporary_sum,0))*100,2),'%') temporary_ratio,
- CONCAT(round(sum(ifnull(temporary_sum,0))/(sum(ifnull(week_sum,0))+sum(ifnull(temporary_sum,0)))*100,2),'%') temporary_plan_ratio,
- null create_by ,
- null create_time,
- null update_by,
- null update_time FROM
- pdm_report_plan_week
- <where>
- <if test="company != null and company != ''"> and company = #{company}</if>
- <if test="reportDate != null and reportDate != ''"> and report_date = #{reportDate}</if>
- <if test="reportEndDate != null and reportEndDate != ''"> and report_end_date = #{reportEndDate}</if>
- <if test="total != null "> and total = #{total}</if>
- <if test="weekSum != null "> and week_sum = #{weekSum}</if>
- <if test="weekCancelSum != null "> and week_cancel_sum = #{weekCancelSum}</if>
- <if test="weekRatio != null and weekRatio != ''"> and week_ratio = #{weekRatio}</if>
- <if test="temporarySum != null "> and temporary_sum = #{temporarySum}</if>
- <if test="temporaryCancelSum != null "> and temporary_cancel_sum = #{temporaryCancelSum}</if>
- <if test="temporaryRatio != null and temporaryRatio != ''"> and temporary_ratio = #{temporaryRatio}</if>
- <if test="temporaryPlanRatio != null and temporaryPlanRatio != ''"> and temporary_plan_ratio = #{temporaryPlanRatio}</if>
- </where>
- GROUP BY report_date) a order by id asc
- </select>
- <select id="selectPdmReportPlanWeekById" parameterType="Long" resultMap="PdmReportPlanWeekResult">
- <include refid="selectPdmReportPlanWeekVo"/>
- where id = #{id}
- </select>
- <insert id="insertPdmReportPlanWeek" parameterType="PdmReportPlanWeek" useGeneratedKeys="true" keyProperty="id">
- insert into pdm_report_plan_week
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="company != null">company,</if>
- <if test="reportDate != null">report_date,</if>
- <if test="reportEndDate != null">report_end_date,</if>
- <if test="total != null">total,</if>
- <if test="weekSum != null">week_sum,</if>
- <if test="weekCancelSum != null">week_cancel_sum,</if>
- <if test="weekRatio != null">week_ratio,</if>
- <if test="temporarySum != null">temporary_sum,</if>
- <if test="temporaryCancelSum != null">temporary_cancel_sum,</if>
- <if test="temporaryRatio != null">temporary_ratio,</if>
- <if test="temporaryPlanRatio != null">temporary_plan_ratio,</if>
- <if test="createBy != null">create_by,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateBy != null">update_by,</if>
- <if test="updateTime != null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="company != null">#{company},</if>
- <if test="reportDate != null">#{reportDate},</if>
- <if test="reportEndDate != null">#{reportEndDate},</if>
- <if test="total != null">#{total},</if>
- <if test="weekSum != null">#{weekSum},</if>
- <if test="weekCancelSum != null">#{weekCancelSum},</if>
- <if test="weekRatio != null">#{weekRatio},</if>
- <if test="temporarySum != null">#{temporarySum},</if>
- <if test="temporaryCancelSum != null">#{temporaryCancelSum},</if>
- <if test="temporaryRatio != null">#{temporaryRatio},</if>
- <if test="temporaryPlanRatio != null">#{temporaryPlanRatio},</if>
- <if test="createBy != null">#{createBy},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateBy != null">#{updateBy},</if>
- <if test="updateTime != null">#{updateTime},</if>
- </trim>
- </insert>
- <update id="updatePdmReportPlanWeek" parameterType="PdmReportPlanWeek">
- update pdm_report_plan_week
- <trim prefix="SET" suffixOverrides=",">
- <if test="company != null">company = #{company},</if>
- <if test="reportDate != null">report_date = #{reportDate},</if>
- <if test="reportEndDate != null">report_end_date = #{reportEndDate},</if>
- <if test="total != null">total = #{total},</if>
- <if test="weekSum != null">week_sum = #{weekSum},</if>
- <if test="weekCancelSum != null">week_cancel_sum = #{weekCancelSum},</if>
- <if test="weekRatio != null">week_ratio = #{weekRatio},</if>
- <if test="temporarySum != null">temporary_sum = #{temporarySum},</if>
- <if test="temporaryCancelSum != null">temporary_cancel_sum = #{temporaryCancelSum},</if>
- <if test="temporaryRatio != null">temporary_ratio = #{temporaryRatio},</if>
- <if test="temporaryPlanRatio != null">temporary_plan_ratio = #{temporaryPlanRatio},</if>
- <if test="createBy != null">create_by = #{createBy},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateBy != null">update_by = #{updateBy},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deletePdmReportPlanWeekById" parameterType="Long">
- delete from pdm_report_plan_week where id = #{id}
- </delete>
- <delete id="deletePdmReportPlanWeekByIds" parameterType="String">
- delete from pdm_report_plan_week where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- </mapper>
|