<?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.unis.emergencySupportCenter.modular.planExecute.mapper.PlanExecuteMapper">
    <select id="pageList" parameterType="com.baomidou.mybatisplus.core.conditions.Wrapper" resultType="com.unis.emergencySupportCenter.modular.planExecute.entity.PlanExecute">
        SELECT
            pe.id,
            pf.plan_name planName,
	        pf.emergency_level emergencyLevel,
	        pf.disaster_level disasterLevel,
            CASE WHEN COUNT(ee.es_plan_execute_id)=0 THEN NULL END enterpriseCount,
            SUM(ee.quantity) grainCount,
            pe.create_time
        FROM
            biz_es_ep_plan_execute pe
        LEFT JOIN biz_es_ep_online_plan_formulation pf ON pe.es_online_plan_formulation_id = pf.id
        LEFT JOIN biz_es_ep_plan_execute_enterprise ee ON pe.id = ee.es_plan_execute_id
        ${ew.customSqlSegment}
    </select>
</mapper>