| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?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.yt.zhylplat.moduleMain.flower.mapper.TLhzxFlowerChangePlanMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
- <id column="id" property="id" />
- <result column="plan_name" property="planName" />
- <result column="section_id" property="sectionId" />
- <result column="section_name" property="sectionName" />
- <result column="maintenance_company_id" property="maintenanceCompanyId" />
- <result column="maintenance_company_name" property="maintenanceCompanyName" />
- <result column="change_season" property="changeSeason" />
- <result column="change_type" property="changeType" />
- <result column="change_amount" property="changeAmount" />
- <result column="flower_source" property="flowerSource" />
- <result column="flower_variety" property="flowerVariety" />
- <result column="expected_date" property="expectedDate" />
- <result column="complete_state" property="completeState" />
- <result column="complete_rate" property="completeRate" />
- <result column="create_user_id" property="createUserId" />
- <result column="create_user_name" property="createUserName" />
- <result column="create_date" property="createDate" />
- <result column="update_user_id" property="updateUserId" />
- <result column="update_user_name" property="updateUserName" />
- <result column="update_date" property="updateDate" />
- <result column="del_flg" property="delFlg" />
- <result column="remark" property="remark" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <select id="selectFlowerChangePlanListBySeason"
- resultType="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
- select
- temp.*
- from
- (<include refid="flowerChangePlanListSql"/>) temp
- </select>
- <select id="selectFlowerChangePlanCountBySeason"
- resultType="com.yt.zhylplat.moduleMain.flower.entity.TLhzxFlowerChangePlan">
- select
- sum(if(temp.change_amount is null, 0, temp.change_amount)) as change_amount,
- sum(if(temp.complete_amount is null, 0, temp.complete_amount)) as complete_amount,
- case
- when sum(if(temp.change_amount is null, 0, temp.change_amount)) = 0
- then 0
- when sum(if(temp.change_amount is null, 0, temp.change_amount)) != 0
- then sum(if(temp.complete_amount is null, 0, temp.complete_amount)) / sum(if(temp.change_amount is null, 0, temp.change_amount))
- end as completeRate
- from
- (<include refid="flowerChangePlanListSql"/>) temp
- </select>
- <sql id="flowerChangePlanListSql">
- select
- fcp.change_season,
- sum(if(fcp.change_amount is null, 0, fcp.change_amount)) as change_amount,
- sum(if(fcpi.complete_amount is null, 0, fcpi.complete_amount)) as complete_amount,
- case
- when sum(if(fcp.change_amount is null, 0, fcp.change_amount)) = 0
- then 0
- when sum(if(fcp.change_amount is null, 0, fcp.change_amount)) != 0
- then sum(if(fcpi.complete_amount is null, 0, fcpi.complete_amount)) / sum(if(fcp.change_amount is null, 0, fcp.change_amount))
- end as completeRate
- from
- T_Lhzx_Flower_Change_Plan fcp
- left join
- (
- select
- plan_id,
- sum(if(complete_amount is null, 0, complete_amount)) as complete_amount
- from
- T_Lhzx_Flower_Change_Plan_Item
- where
- del_flg = 0
- group by
- plan_id
- ) fcpi on fcp.id = fcpi.plan_id
- where
- fcp.del_flg = 0
- <if test="planYear != null and planYear != ''">
- and date_format(fcp.create_date, '%Y') = #{planYear}
- </if>
- <if test="changeSeason != null">
- and fcp.change_season = #{changeSeason}
- </if>
- <if test="changeType != null">
- and fcp.change_type = #{changeType}
- </if>
- group by
- fcp.change_season
- </sql>
- </mapper>
|