<?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.securitycontrol.screen.mapper.XcIndexMapper">

    <select id="getProDetails" resultType="com.securitycontrol.entity.system.base.vo.ProVo">
            select pro_brief  AS proBrief,pro_id AS proId,plan_start_time planStartTime,plan_end_time planEndTime,pro_cost AS proCost
                from tb_project
                    where bid_code=#{bidCode}
    </select>
    <!--查询环境检测数据-->
    <select id="getProJcData" resultType="com.securitycontrol.entity.screen.vo.DeviceValueVo">
            select bdd.device_name deviceName,tdd.mode_name modelName,
                    tdv.val,tdv.is_warn isWarn,tdv.create_time createTime,sd.dict_name deviceType
                from tb_pro_bd bd
                INNER join tb_bd_device bdd on bdd.bd_id=bd.id and bdd.del_flage=0
                LEFT JOIN sys_dict sd on sd.dict_code=bdd.devic_type
                left join tb_device_detail tdd on tdd.device_id=bdd.device_id and tdd.del_flag=0
                left join tb_device_value tdv on tdd.id=tdv.attribute_id
                where    tdd.mode_name is not null and  sd.dict_code=#{typeCode}
                and bd.bid_code=#{bidCode}
    </select>
    <select id="getWeekRiskNum" resultType="java.lang.Integer">
        select count(1) num
            from jj_week_plan jwp
            where    #{startTime}   BETWEEN jwp.start_date AND jwp.end_date
            AND jwp.bid_no=#{bidCode}
    </select>
    <select id="getWarnNum" resultType="java.lang.Integer">
            select count(1) num
             from tb_warn
               where  DATE_FORMAT(warn_time, '%Y-%m-%d')=#{startTime}
    </select>

    <!--项目进度-->
    <select id="getProBasicInfo" resultType="java.util.Map">
        SELECT tp.bid_code AS bidCode,
               tp.pro_name AS proName,
               tp.plan_start_time AS planStartTime,
               tp.plan_end_time AS planEndTime,
               tgp.plan_id AS planId,
               tgp.gx_weight AS gxWeight,
               tgp.plan_progress AS planProgress
        FROM tb_project tp
        LEFT JOIN tb_gx_plan tgp ON tp.bid_code = tgp.bid_code AND tgp.del_flag = 0
        WHERE tp.del_flag = 0 AND tp.bid_code = #{bidCode}
    </select>
    <!--工程成本记录-->
    <select id="getProCost" resultType="java.lang.String">
            SELECT SUM(cost)
                FROM tb_project_cost
                where curry_day like concat('%',#{time},'%')
                and bid_code=#{bidCode}

    </select>
</mapper>