| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?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.TLhzxStreetTreeWorkPlanMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
- <id column="id" property="id" />
- <result column="plan_no" property="planNo" />
- <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="phone" property="phone" />
- <result column="user_id" property="userId" />
- <result column="user_code" property="userCode" />
- <result column="user_name" property="userName" />
- <result column="start_time" property="startTime" />
- <result column="end_time" property="endTime" />
- <result column="plan_type" property="planType" />
- <result column="state" property="state" />
- <result column="effect_date" property="effectDate" />
- <result column="remark" property="remark" />
- <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" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, plan_no, section_id, section_name, maintenance_company_id, maintenance_company_name, phone, user_id, user_code, user_name, start_time, end_time, plan_type, state, effect_date, remark, create_user_id, create_date, update_user_id, update_date, del_flg
- </sql>
- <select id="selectStreetTreeWorkPlanBySection"
- resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
- select
- temp.*
- from
- (<include refid="selectStreetTreeWorkPlanSql"/>) temp
- </select>
- <select id="selectStreetTreeWorkPlanBySectionType"
- resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
- select
- temp.section_type,
- sum(if(temp.planCount is null, 0, temp.planCount)) as planCount,
- sum(if(temp.completeCount is null, 0, temp.completeCount)) as completeCount,
- if(
- sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount)) <![CDATA[ < ]]> 0,
- 0,
- sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount))
- ) as noCompleteCount
- from
- (<include refid="selectStreetTreeWorkPlanSql"/>) temp
- group by
- temp.section_type
- </select>
- <select id="selectStreetTreeWorkPlanSumCount"
- resultType="com.yt.zhylplat.moduleMain.streetTree.entity.TLhzxStreetTreeWorkPlan">
- select
- sum(if(temp.planCount is null, 0, temp.planCount)) as planCount,
- sum(if(temp.completeCount is null, 0, temp.completeCount)) as completeCount,
- if(
- sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount)) <![CDATA[ < ]]> 0,
- 0,
- sum(if(temp.planCount is null, 0, temp.planCount)) - sum(if(temp.completeCount is null, 0, temp.completeCount))
- ) as noCompleteCount
- from
- (<include refid="selectStreetTreeWorkPlanSql"/>) temp
- </select>
- <sql id="selectStreetTreeWorkPlanSql">
- select distinct
- rsmc.section_id as sectionId,
- s.section_name as sectionName,
- rsmc.maintenance_company_id as maintenanceCompanyId,
- mc.maintenance_company_name as maintenanceCompanyName,
- s.section_type,
- if(plan_count.planCount is null, 0, plan_count.planCount) as planCount,
- if(complete_count.completeCount is null, 0, complete_count.completeCount) as completeCount,
- if(
- if(plan_count.planCount is null, 0, plan_count.planCount) - if(complete_count.completeCount is null, 0, complete_count.completeCount) <![CDATA[ < ]]> 0,
- 0,
- if(plan_count.planCount is null, 0, plan_count.planCount) - if(complete_count.completeCount is null, 0, complete_count.completeCount)
- ) as noCompleteCount
- from
- T_Lhzx_Road_Section_Maintenance_Company rsmc
- left join
- T_Lhzx_Section s on s.id = rsmc.section_id
- left join
- T_Lhzx_Maintenance_Company mc on mc.id = rsmc.maintenance_company_id
- left join (
- select
- section_id,
- maintenance_company_id,
- count(id) as planCount
- from
- T_Lhzx_Street_Tree_Work_Plan
- where
- plan_type = 1
- and
- del_flg = 0
- <if test="tLhzxStreetTreeWorkPlan.uploadType != null">
- and upload_type = #{tLhzxStreetTreeWorkPlan.uploadType}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.planMonth != null and tLhzxStreetTreeWorkPlan.planMonth != ''">
- and date_format(start_time, '%Y-%m') = #{tLhzxStreetTreeWorkPlan.planMonth}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.planYear != null and tLhzxStreetTreeWorkPlan.planYear != ''">
- and date_format(start_time, '%Y') = #{tLhzxStreetTreeWorkPlan.planYear}
- </if>
- group by
- section_id,
- maintenance_company_id
- ) plan_count on plan_count.section_id = rsmc.section_id and plan_count.maintenance_company_id = rsmc.maintenance_company_id
- left join (
- select
- section_id,
- maintenance_company_id,
- count(id) as completeCount
- from
- T_Lhzx_Street_Tree_Work_Plan
- where
- plan_type = 2
- and
- del_flg = 0
- <if test="tLhzxStreetTreeWorkPlan.uploadType != null">
- and upload_type = #{tLhzxStreetTreeWorkPlan.uploadType}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.planMonth != null and tLhzxStreetTreeWorkPlan.planMonth != ''">
- and date_format(start_time, '%Y-%m') = #{tLhzxStreetTreeWorkPlan.planMonth}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.planYear != null and tLhzxStreetTreeWorkPlan.planYear != ''">
- and date_format(start_time, '%Y') = #{tLhzxStreetTreeWorkPlan.planYear}
- </if>
- group by
- section_id,
- maintenance_company_id
- ) complete_count on complete_count.section_id = rsmc.section_id and complete_count.maintenance_company_id = rsmc.maintenance_company_id
- where
- rsmc.del_flg = 0
- <if test="tLhzxStreetTreeWorkPlan.sectionId != null">
- and rsmc.section_id = #{tLhzxStreetTreeWorkPlan.sectionId}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.maintenanceCompanyId != null">
- and rsmc.maintenance_company_id = #{tLhzxStreetTreeWorkPlan.maintenanceCompanyId}
- </if>
- <if test="tLhzxStreetTreeWorkPlan.sectionType != null">
- and s.section_type = #{tLhzxStreetTreeWorkPlan.sectionType}
- </if>
- order by
- rsmc.section_id,
- rsmc.maintenance_company_id
- </sql>
- </mapper>
|