WProjectLibraryInventoryMapper.xml 11.5 KB
<?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.hotent.chkpower.dao.WProjectLibraryInventoryDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hotent.chkpower.model.WProjectLibraryInventory">
        <id column="ID_" property="id"/>
        <result column="REF_ID_" property="refId"/>
        <result column="F_org_name" property="fOrgName"/>
        <result column="F_warehouse_entry_date" property="fWarehouseEntryDate"/>
        <result column="F_project_name" property="fProjectName"/>
        <result column="F_project_category" property="fProjectCategory"/>
        <result column="F_business_scenarios" property="fBusinessScenarios"/>
        <result column="F_smart_heating" property="fSmartHeating"/>
        <result column="F_energy_efficiency" property="fEnergyEfficiency"/>
        <result column="F_photovoltaic" property="fPhotovoltaic"/>
        <result column="F_energy_storage" property="fEnergyStorage"/>
        <result column="F_project_nature" property="fProjectNature"/>
        <result column="F_business_model" property="fBusinessModel"/>
        <result column="F_investment_scale" property="fInvestmentScale"/>
        <result column="F_project_rating" property="fProjectRating"/>
        <result column="F_static_payback_period" property="fStaticPaybackPeriod"/>
        <result column="F_calculate_IRR" property="fCalculateIrr"/>
        <result column="F_annual_income_forecast" property="fAnnualIncomeForecast"/>
        <result column="F_annual_net_profit_forecast" property="fAnnualNetProfitForecast"/>
        <result column="F_team_leader" property="fTeamLeader"/>
        <result column="F_team_leader_id" property="fTeamLeaderId"/>
        <result column="F_team_collaboration_per" property="fTeamCollaborationPer"/>
        <result column="F_team_collaboration_per_id" property="fTeamCollaborationPerId"/>
        <result column="F_expected_signing_date" property="fExpectedSigningDate"/>
        <result column="F_expected_scheduled_date" property="fExpectedScheduledDate"/>
        <result column="F_strategic_value" property="fStrategicValue"/>
        <result column="F_project_source" property="fProjectSource"/>
        <result column="F_customer_contact" property="fCustomerContact"/>
        <result column="F_project_overview" property="fProjectOverview"/>
        <result column="F_project_debriefing" property="fProjectDebriefing"/>
        <result column="F_deviation_analysis" property="fDeviationAnalysis"/>
        <result column="F_project_state" property="fProjectState"/>
        <result column="F_create_by" property="fCreateBy"/>
        <result column="F_create_by_id" property="fCreateById"/>
        <result column="F_create_time" property="fCreateTime"/>
        <result column="F_update_by" property="fUpdateBy"/>
        <result column="F_update_by_id" property="fUpdateById"/>
        <result column="F_update_time" property="fUpdateTime"/>
        <result column="F_form_data_rev_" property="fFormDataRev"/>
        <result column="F_project_no" property="fProjectNo"/>
        <result column="F_org_id" property="fOrgId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID_, REF_ID_, F_org_name, F_warehouse_entry_date, F_project_name, F_project_category, F_business_scenarios, F_smart_heating, F_energy_efficiency, F_photovoltaic, F_energy_storage, F_project_nature, F_business_model, F_investment_scale, F_project_rating, F_static_payback_period, F_calculate_IRR, F_annual_income_forecast, F_annual_net_profit_forecast, F_team_leader, F_team_leader_id, F_team_collaboration_per, F_team_collaboration_per_id, F_expected_signing_date, F_expected_scheduled_date, F_strategic_value, F_project_source, F_customer_contact, F_project_overview, F_project_debriefing, F_deviation_analysis, F_project_state, F_create_by, F_create_by_id, F_create_time, F_update_by, F_update_by_id, F_update_time, F_form_data_rev_, F_project_no, F_org_id
    </sql>

    <select id="selectPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_project_library_inventory
        ${ew.customSqlSegment}
    </select>

    <select id="selectList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_project_library_inventory
        ${ew.customSqlSegment}
    </select>

    <select id="selectById" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from
        w_project_library_inventory
        where
        ID_ = #{id}
    </select>



    <select id="basicsStatistics" resultType="java.util.HashMap">
        SELECT
            SUM(CASE WHEN F_PROJECT_CATEGORY = '已通过投评项目' THEN 1 ELSE 0 END ) AS YTGTPXMS, -- 已通过投评项目
            SUM(CASE WHEN F_PROJECT_CATEGORY = '已签约项目' THEN 1 ELSE 0 END ) AS YQYXMS, -- 已签约项目
            ROUND(SUM(F_ANNUAL_INCOME_FORECAST/10000),2) AS YJZNSR,	-- 预计总年收入(亿元)
            ROUND(SUM(F_ANNUAL_NET_PROFIT_FORECAST/10000),2) AS YJZNLR, -- 预计总年利润(亿元)


            COUNT(*) AS XMZS, -- 项目总数
            SUM(CASE WHEN F_PROJECT_CATEGORY = '暂缓项目' THEN 1 ELSE 0 END ) AS ZHXMS, -- 暂缓项目
            SUM(CASE WHEN F_PROJECT_CATEGORY = '出库项目' THEN 1 ELSE 0 END ) AS CKXMS, -- 出库项目数
            SUM(CASE WHEN F_PROJECT_CATEGORY = '本月重点推进项目' THEN 1 ELSE 0 END ) AS BYZDTJXMS, -- 本月重点推进项目
            ROUND(SUM(F_INVESTMENT_SCALE/10000),2) AS YJZTZ, -- 预计总投资(亿元)


            SUM(F_SMART_HEATING) AS ZHGR, -- 智慧供热
            ROUND(SUM(F_ENERGY_EFFICIENCY/10000),2) AS ZHNX, -- 综合能效
            SUM(F_PHOTOVOLTAIC) AS GF, -- 光伏
            SUM(F_ENERGY_STORAGE) AS CN -- 储能

        FROM
            W_PROJECT_LIBRARY_INVENTORY
            WHERE
            F_PROJECT_STATE != '已作废'
            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
                AND F_create_time BETWEEN #{startDate} AND #{endDate}
            </if>
            <if test="list != null and list.size() > 0">
                AND F_org_id IN
                <foreach collection="list" separator="," item="orgId" close=")" open="(">
                    #{orgId}
                </foreach>
            </if>
    </select>

    <select id="projectRatingStatistics" resultType="java.util.HashMap">
        SELECT
        temp1.project_rating AS xmzl,
        count(W_PROJECT_LIBRARY_INVENTORY.F_project_rating)AS sl
        FROM (
        <foreach collection="xmpjList" item="xmpj" separator="UNION ALL">
            SELECT #{xmpj} AS project_rating
        </foreach>
        ) temp1
        LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_project_rating = temp1.project_rating AND
        W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废'
        <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
            AND W_PROJECT_LIBRARY_INVENTORY.F_create_time BETWEEN #{startDate} AND #{endDate}
        </if>
        <if test="list != null and list.size() > 0">
            AND W_PROJECT_LIBRARY_INVENTORY.F_org_id IN
            <foreach collection="list" separator="," item="orgId" close=")" open="(">
                #{orgId}
            </foreach>
        </if>
        GROUP BY temp1.project_rating
    </select>

    <select id="investmentScaleStatistics" resultType="java.util.HashMap">
        SELECT
        SUM(CASE WHEN F_investment_scale &lt;= 500 THEN 1 ELSE 0 END) AS '≤500万',
        SUM(CASE WHEN F_investment_scale > 500 AND F_investment_scale &lt;= 1000 THEN 1 ELSE 0 END)  AS '500-1000万',
        SUM(CASE WHEN F_investment_scale > 1000 AND F_investment_scale &lt;= 3000 THEN 1 ELSE 0 END)  AS '1000-3000万',
        SUM(CASE WHEN F_investment_scale > 3000 THEN 1 ELSE 0 END)  AS '>3000万'
        FROM
        W_PROJECT_LIBRARY_INVENTORY
        WHERE
            F_PROJECT_STATE != '已作废'
            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
                AND F_create_time BETWEEN #{startDate} AND #{endDate}
            </if>
            <if test="list != null and list.size() > 0">
                AND F_org_id IN
                <foreach collection="list" separator="," item="orgId" close=")" open="(">
                    #{orgId}
                </foreach>
            </if>
    </select>

    <select id="orgNameProjectStatistics" resultType="java.util.HashMap">
        SELECT
            F_org_name AS xmzt,
            count( F_org_id ) AS sl
        FROM
            W_PROJECT_LIBRARY_INVENTORY
        WHERE
            F_PROJECT_STATE != '已作废'
            <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
                AND F_create_time BETWEEN #{startDate} AND #{endDate}
            </if>
            <if test="list != null and list.size() > 0">
                AND F_org_id IN
                <foreach collection="list" separator="," item="orgId" close=")" open="(">
                    #{orgId}
                </foreach>
            </if>
        GROUP BY
            F_org_id
    </select>

    <select id="listDictByKey" resultType="java.lang.String">
        SELECT
            NAME_
        FROM
            portal_sys_dic
        WHERE
            PARENT_ID_ = ( SELECT id_ FROM portal_sys_dic WHERE KEY_ = #{ywcj} )
        ORDER BY
            SN_
    </select>

    <select id="businessScenariosScaleStatistics" resultType="java.util.HashMap">
        SELECT
        temp1.business_scenarios AS ywcj,
        count(W_PROJECT_LIBRARY_INVENTORY.F_business_scenarios)AS sl
        FROM (
        <foreach collection="ywcjList" item="ywcj" separator="UNION ALL">
            SELECT #{ywcj} AS business_scenarios
        </foreach>
        ) temp1
        LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_business_scenarios =
        temp1.business_scenarios AND W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废'
        <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
            AND F_create_time BETWEEN #{startDate} AND #{endDate}
        </if>
        <if test="list != null and list.size() > 0">
            AND F_org_id IN
            <foreach collection="list" separator="," item="orgId" close=")" open="(">
                #{orgId}
            </foreach>
        </if>
        GROUP BY temp1.business_scenarios
    </select>

    <select id="businessModelStatistics" resultType="java.util.HashMap">
        SELECT
        temp1.business_model AS swms,
        count(W_PROJECT_LIBRARY_INVENTORY.F_business_model)AS sl
        FROM (
        <foreach collection="swmsList" item="swms" separator="UNION ALL">
            SELECT #{swms} AS business_model
        </foreach>
        ) temp1
        LEFT JOIN W_PROJECT_LIBRARY_INVENTORY ON W_PROJECT_LIBRARY_INVENTORY.F_business_model = temp1.business_model
        AND W_PROJECT_LIBRARY_INVENTORY.F_PROJECT_STATE != '已作废'
        <if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
            AND F_create_time BETWEEN #{startDate} AND #{endDate}
        </if>
        <if test="list != null and list.size() > 0">
            AND F_org_id IN
            <foreach collection="list" separator="," item="orgId" close=")" open="(">
                #{orgId}
            </foreach>
        </if>
        GROUP BY temp1.business_model
    </select>
</mapper>