Newer
Older
huludao / src / main / resources / mapper / project / ProjectMapper.xml
<?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.xf.huludao.project.dao.ProjectMapper">

    <resultMap id="projectMap" type="com.xf.huludao.project.entity.Project">
        <id column="project_no" property="projectNo"/>
        <result column="serial" property="serial"/>
        <result column="project_name" property="projectName"/>
        <result column="project_type" property="projectType"/>
        <result column="project_type_name" property="projectTypeName"/>
        <result column="project_order" property="projectOrder"/>
        <result column="create_time" property="createTime"/>
        <result column="position" property="position"/>
        <result column="duty_dept"  property="dutyDept"/>
        <result column="duty_person"  property="dutyPerson"/>
        <result column="principal_phone"  property="principalPhone"/>
        <association property="projectAdditionalInfo" javaType="com.xf.huludao.project.entity.ProjectAdditionalInfo">
            <id column="project_no" property="projectNo"/>
            <result column="info_serial"  property="infoSerial"/>
            <result column="city_no"  property="cityNo"/>
            <result column="town_name"  property="townName"/>
            <result column="province_no"  property="provinceNo"/>
            <result column="province_name"  property="provinceName"/>
            <result column="project_name"  property="projectName"/>
            <result column="build_type"  property="buildType"/>
            <result column="build_type_name"  property="buildTypeName"/>
            <result column="project_drainage_zoning"  property="projectDrainageZoning"/>
            <result column="project_drainage_zoning_name"  property="projectDrainageZoningName"/>
            <result column="commence_date"  property="commenceDate"/>
            <result column="completion_date"  property="completionDate"/>
            <result column="planning_conditions"  property="planningConditions"/>
            <result column="design_parameters"  property="designParameters"/>
            <result column="projec_quantities"  property="projecQuantities"/>
            <result column="build_state_no"  property="buildStateNo"/>
            <result column="build_state_name"  property="buildStateName"/>
            <result column="project_schedule" property="projectSchedule"/>
            <result column="design_company"  property="designCompany"/>
            <result column="construction_company" property="constructionCompany"/>
            <result column="devops_company"  property="devopsCompany"/>
            <result column="project_text"  property="projectText"/>
            <result column="project_invest"  property="projectInvest"/>
            <result column="approval_documents" property="approvalDocuments"/>
            <result column="project_total_money" property="projectTotalMoney"/>
            <result column="project_government_money" property="projectGovernmentMoney"/>
            <result column="project_society_money" property="projectSocietyMoney"/>
            <result column="project_operation_mode" property="projectOperationMode"/>
            <result column="project_sponge_money" property="projectSpongeMoney"/>
        </association>
    </resultMap>


    <resultMap id="newProjectPatrolVoMap" type="com.xf.huludao.vo.NewProjectPatrolVo">
        <result column="project_name" property="name"/>
        <result column="project_no" property="projectNo"/>
        <result column="real_name" property="realName"/>
        <result column="principal_phone" property="phone"/>
        <result column="patrol_count" property="patrolCount"/>
        <association property="projectPatrol" javaType="com.xf.huludao.project.entity.ProjectPatrol">
            <id property="patrolId" column="patrol_id"/>
            <result property="projectNo" column="project_no"/>
            <result property="patrolTime" column="patrol_time"/>
            <result property="problems" column="problems"/>
            <result property="filePaths" column="file_paths"/>
            <collection property="labels" ofType="com.xf.huludao.project.entity.PatrolLabel">
                <id column="id" property="id"/>
                <result column="label_name" property="labelName"/>
            </collection>
        </association>
    </resultMap>
    <resultMap  id="projectInfoListMap"  type="com.xf.huludao.project.entity.ProjectInfo">
        <result  column="project_no"   property="projectNo" />
        <result  column="project_name"   property="projectName" />
    </resultMap>

    <resultMap id="projectStatisticsVo" type="com.xf.huludao.vo.ProjectStatisticsVo">
        <result property="projectCount" column="projectCount"/>
        <result property="doneCount" column="doneCount"/>
        <result property="projectMoney" column="projectMoney"/>
        <result property="projectArea" column="projectArea"/>
    </resultMap>
    <resultMap id="projectNameStatisticsMap" type="com.xf.huludao.project.entity.ProjectNameStatistics">
        <result property="name" column="name"/>
        <result property="num" column="num"/>
    </resultMap>
<!--    <select id="queryListByProjectName" resultMap="projectMap">-->
<!--        SELECT-->
<!--        *-->
<!--        FROM-->
<!--        project p-->
<!--        LEFT JOIN-->
<!--        project_additional_info pai-->
<!--        ON-->
<!--        p.project_no = pai.projectNo-->
<!--        WHERE 1 = 1-->
<!--        <if test="projectName != null and projectName != ''">-->
<!--            AND p.project_name like concat('%',#{projectName},'%')-->
<!--        </if>-->
<!--        <if test="projectNo != null and projectNo != ''">-->
<!--            AND p.project_no = #{projectNo}-->
<!--        </if>-->
<!--        order by p.create_time desc limit #{current},#{size}-->
<!--    </select>-->


<!--    <select id="selectNotPicList" resultMap="projectMap">-->
<!--        SELECT *-->
<!--        FROM project-->
<!--        WHERE project_no NOT IN (-->
<!--            SELECT DISTINCT project_no-->
<!--            FROM project_pic-->
<!--        )-->
<!--    </select>-->

<!--    <select id="queryListMap" resultMap="projectMap">-->
<!--        select-->
<!--        p.*-->
<!--        from project p-->
<!--        LEFT JOIN project_user pus-->
<!--        ON p.project_no = pus.project_no-->
<!--        where pus.user_no = #{userNo}-->
<!--        <if test="projectName != null and projectName != ''">-->
<!--            and p.projectName like concat('%',#{projectName},'%')-->
<!--        </if>-->
<!--    </select>-->

    <select id="queryList" resultMap="projectMap">
        select
        p.*,pai.*
        from project p
        LEFT JOIN project_additional_info pai
        ON p.project_no = pai.project_no
        WHERE 1=1
        <if test="project.projectName != null and project.projectName != ''">
            and p.project_name like concat('%',#{project.projectName},'%')
        </if>
        <if test="project.buildStateNo != null and project.buildStateNo != ''">
            and pai.build_state_no = #{project.buildStateNo}
        </if>
        <if test="project.projectType != null and project.projectType != ''">
            and p.project_type = #{project.projectType}
        </if>
        order by create_time desc
    </select>

    <select id="queryListCount" resultType="long">
        select
        count(p.project_no)
        from project p
        LEFT JOIN project_additional_info pai
        ON p.project_no = pai.project_no
        <if test="project.projectName != null and project.projectName != ''">
            and project_name like concat('%',#{project.projectName},'%')
        </if>
    </select>

        <select id="selectByProjectNo" resultMap="projectMap">
        SELECT *
        FROM project p
                 LEFT JOIN
             project_additional_info pai
             on p.project_no = pai.project_no
        where p.project_no = #{projectNo}
    </select>


<!--    <select id="selectProjectStatisticsVo" resultMap="projectStatisticsVo">-->
<!--        select count(project_no)                                                               as projectCount,-->
<!--               (select count(project_no) as doneCount from project where project_state = 3)    as doneCount,-->
<!--               (select sum(pa.money) as projectMoney-->
<!--                from project p-->
<!--                         left join project_additional_info pa on p.project_no = pa.project_no) as projectMoney,-->
<!--               (select sum(area) from project)                                                 as projectArea-->
<!--        from project-->
<!--    </select>-->


<!--    <select id="selectAllProjectInfo" resultMap="projectMap">-->
<!--        select p.*,-->
<!--               pai.*-->
<!--        from project p-->
<!--                 left JOIN-->
<!--             project_additional_info pai-->
<!--             ON p.project_no = pai.project_no-->

<!--    </select>-->

    <select id="queryPageListNew" resultMap="newProjectPatrolVoMap">

        select
        p.project_name,p.patrol_id,p.project_no,p.patrol_time,p.problems,p.file_paths,pl.id,pl.label_name,ppu.real_name,ppu.principal_phone,ppppp.patrol_count
        from
        (
        select p.project_name,p.project_no,pp.patrol_id,max(pp.patrol_time) as patrol_time,pp.problems,pp.file_paths
        from
        (
        select
        pj.*,pain.build_type,pain.build_state_no
        from project pj
        left join
        project_additional_info pain
        on pj.project_no = pain.project_no
        where
        pj.project_no in (select project_no from project_patrol group by project_no)
        <if test="buildType != null">
            and `build_type` = #{buildType}
        </if>
        <if test="buildStateNo != null">
            and build_stateNo = #{buildStateNo}
        </if>
        <if test="projectName != null and projectName != ''">
            and project_name like concat('%',#{projectName},'%')
        </if>
        LIMIT #{current},#{size}
        )
        p left join (select t.* from project_patrol t where patrol_time = (select max(patrol_time) from project_patrol
        where project_no = t.project_no) group by t.project_no) pp
        on p.project_no = pp.project_no
        GROUP BY pp.project_no
        )
        p left join project_patrol_label ppl

        on p.patrol_id = ppl.protrol_no

        left JOIN patrol_label pl

        on ppl.label_id = pl.id
        left join project_principal_user ppu
        on p.project_no = ppu.project_no
        left JOIN (select project_no,count(patrol_id) as patrol_count from project_patrol GROUP BY project_no) ppppp
        on p.project_no = ppppp.project_no
        order by p.patrol_time desc
    </select>

    <select id="queryPageListNewCount" resultType="int">
        select
        count(project_no)
        from project
        where
        project_no in (select project_no from project_patrol group by project_no)
        <if test="buildType != null">
            and `build_type` = #{buildType}
        </if>
        <if test="buildStateNo != null">
            and build_stateNo = #{buildStateNo}
        </if>
        <if test="projectName != null and projectName != ''">
            and project_name like concat('%',#{projectName},'%')
        </if>
    </select>
    <select id="selectProjectList" resultMap="projectInfoListMap">
        select
            p.project_name,p.project_no
        from project p
    </select>
    <select id="selectProjectListByCondition" resultMap="projectMap">
        select
            p.*,pai.project_schedule
        from project p
                 LEFT JOIN
             project_additional_info pai
             on p.project_no = pai.project_no
    </select>

    <select id="selectProjectCountForEchart" resultType="com.xf.huludao.project.dto.ProjectCountDto">
        SELECT p.project_no,p.project_name,p.project_type,p.project_type_name,pai.build_state_no,
        pai.build_state_name,pai.project_schedule
        FROM `project` p
        inner join project_additional_info pai on p.project_no=pai.project_no
        where 1=1
        <choose>
            <when test="type != null and type != 0">
                and `build_state_no` = "not_yet_approved"
            </when>
            <otherwise>
                and `build_state_no` != "not_yet_approved"
            </otherwise>
        </choose>
    </select>

    <select id="selectInfoByNo" resultType="com.xf.huludao.project.entity.ProjectDto">
        select p.project_no,p.project_name,pai.project_drainage_zoning,pai.project_drainage_zoning_name,
        p.project_type,p.project_type_name,pai.build_type,pai.build_type_name,pai.construction_company,
        pai.design_company,pai.devops_company,pai.build_state_name
        from project_additional_info pai
        left join project p on pai.project_no = p.project_no
        where p.project_no = #{projectNo}
    </select>

    <select id="getTotal" resultType="com.xf.huludao.project.dto.ProjectTotalDto">
       select p.project_type,p.project_type_name,pai.build_state_no,pai.build_state_name,pai.project_total_money,pai.project_sponge_money
        from  project p
        left join project_additional_info pai on pai.project_no = p.project_no
    </select>
</mapper>