<?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.projectManagement.modular.analysisInfo.mapper.AnalysisMapper">
    <select id="getCount" resultType="com.unis.projectManagement.modular.analysisInfo.entity.AnalysisCountParam">
        SELECT
            t1.planFundIn,
            t2.specialFund,
            t3.planFundOut,
            t4.centralFund,
            t5.provincialFund,
            t6.cityFund,
            t7.bankLoans
        FROM
            (
                SELECT
                    COUNT(1) planFundIn
                FROM
                    biz_pm_application
                WHERE
                    project_type = 1
                AND `status` = 3
            ) t1,
            (
                SELECT
                    COUNT(1) specialFund
                FROM
                    biz_pm_application
                WHERE
                    project_type = 2
                AND `status` = 3
            ) t2,
            (
                SELECT
                    COUNT(1) planFundOut
                FROM
                    biz_pm_application
                WHERE
                    project_type = 3
                AND `status` = 3
            ) t3,
            (
                SELECT
                    COUNT(1) centralFund
                FROM
                    biz_pm_application
                WHERE
                    `status` = 3
            ) t4,
            (
                SELECT
                    COUNT(1) provincialFund
                FROM
                    biz_pm_application
                WHERE
                    `status` = 3
            ) t5,
            (
                SELECT
                    COUNT(1) cityFund
                FROM
                    biz_pm_application
                WHERE
                    `status` = 3
            ) t6,
            (
                SELECT
                    COUNT(1) bankLoans
                FROM
                    biz_pm_application
                WHERE
                    `status` = 3
            ) t7
    </select>
    <select id="getPage" parameterType="com.baomidou.mybatisplus.core.conditions.Wrapper" resultType="com.unis.projectManagement.modular.analysisInfo.entity.AnalysisPageListParam">
        SELECT
            bpa.project_name projectName,
            bpa.project_code projectCode,
            bpa.declaration_date declarationTime,
            bpb.leading_department leadingDepartment,
            bpb.applicant applicant,
            bpb.reviewer reviewer,
            bpb.construction_period constructionPeriod,
            bpb.funds_scale fundsScale,
            bpb.performance_standard performanceStandard,
            bpa.project_type projectType,
            bpa.project_legal_unit projectLegalUnit,
            bpb.funds_source fundsSource,
            bpa.planned_start_time plannedStartTime,
            bpa.planned_completion_time plannedCompletionTime,
            bpa.total_investment totalInvestment,
            bpb.pm_application_id pmApplicationId
        FROM
            biz_pm_budget bpb
        LEFT JOIN biz_pm_application bpa ON bpa.id = bpb.pm_application_id
        ${ ew.customSqlSegment }
    </select>
</mapper>