| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?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.streetTree.mapper.TLhzxStreetTreeSpecialPlanMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
- <id column="id" property="id" />
- <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="file_title" property="fileTitle" />
- <result column="file_name" property="fileName" />
- <result column="file_url" property="fileUrl" />
- <result column="type" property="type" />
- <result column="upload_year" property="uploadYear" />
- <result column="create_user_id" property="createUserId" />
- <result column="create_date" property="createDate" />
- <result column="update_user_id" property="updateUserId" />
- <result column="update_date" property="updateDate" />
- <result column="del_flg" property="delFlg" />
- <result column="remark" property="remark" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- 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
- </sql>
- <select id="selectStreetTreeSpecialPlanBySection"
- resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
- select
- temp.*
- from
- (<include refid="streetTreeSpecialPlanSql"/>) temp
- </select>
- <select id="selectStreetTreeSpecialPlanSumCount"
- resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeSpecialPlan">
- select
- sum(if(temp.sumCount is null, 0, temp.sumCount)) as sumCount,
- sum(if(temp.winterTrimCount is null, 0, temp.winterTrimCount)) as winterTrimCount,
- sum(if(temp.hairControlCount is null, 0, temp.hairControlCount)) as hairControlCount,
- sum(if(temp.camphorPruningCount is null, 0, temp.camphorPruningCount)) as camphorPruningCount,
- sum(if(temp.treePeelCount is null, 0, temp.treePeelCount)) as treePeelCount,
- sum(if(temp.helpTrimCount is null, 0, temp.helpTrimCount)) as helpTrimCount
- from
- (<include refid="streetTreeSpecialPlanSql"/>) temp
- </select>
- <sql id="streetTreeSpecialPlanSql">
- select distinct
- rsmc.section_id,
- s.section_name,
- rsmc.maintenance_company_id,
- mc.maintenance_company_name,
- if(stsp.sumCount is null, 0, stsp.sumCount) as sumCount,
- if(stsp.winterTrimCount is null, 0, stsp.winterTrimCount) as winterTrimCount,
- if(stsp.hairControlCount is null, 0, stsp.hairControlCount) as hairControlCount,
- if(stsp.camphorPruningCount is null, 0, stsp.camphorPruningCount) as camphorPruningCount,
- if(stsp.treePeelCount is null, 0, stsp.treePeelCount) as treePeelCount,
- if(stsp.helpTrimCount is null, 0, stsp.helpTrimCount) as helpTrimCount
- from
- T_Lhzx_Road_Section_Maintenance_Company rsmc
- left join
- T_Lhzx_Section s on rsmc.section_id = s.id
- left join
- T_Lhzx_Maintenance_Company mc on rsmc.maintenance_company_id = mc.id
- left join
- (
- select
- section_id,
- maintenance_company_id,
- count(1) as sumCount,
- sum(if(type = 1, 1, 0)) as winterTrimCount,
- sum(if(type = 2, 1, 0)) as hairControlCount,
- sum(if(type = 3, 1, 0)) as camphorPruningCount,
- sum(if(type = 4, 1, 0)) as treePeelCount,
- sum(if(type = 5, 1, 0)) as helpTrimCount
- from
- T_Lhzx_Street_Tree_Special_Plan
- where
- del_flg = 0
- <if test="uploadYear != null and uploadYear != ''">
- and upload_year = #{uploadYear}
- </if>
- group by
- section_id,
- section_name,
- maintenance_company_id,
- maintenance_company_name
- ) stsp on rsmc.section_id = stsp.section_id and rsmc.maintenance_company_id = stsp.maintenance_company_id
- <where>
- <if test="sectionId != null">
- and rsmc.section_id = #{sectionId}
- </if>
- <if test="maintenanceCompanyId != null">
- and rsmc.maintenance_company_id = #{maintenanceCompanyId}
- </if>
- </where>
- order by
- rsmc.section_id, rsmc.maintenance_company_id
- </sql>
- </mapper>
|