<?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.huimv.admin.mapper.ProtDataMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.huimv.admin.entity.ProtData">
        <id column="id" property="id" />
        <result column="loction_type" property="loctionType" />
        <result column="ph" property="ph" />
        <result column="cod" property="cod" />
        <result column="NH3N" property="Nh3n" />
        <result column="TP" property="tp" />
        <result column="TN" property="tn" />
        <result column="FLOW" property="flow" />
        <result column="original_data" property="originalData" />
        <result column="farm_id" property="farmId" />
        <result column="other1" property="other1" />
        <result column="other2" property="other2" />
        <result column="other3" property="other3" />
        <result column="create_date" property="createDate" />
    </resultMap>
    <select id="listPh" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(ph),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listPhYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(ph),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>
    <select id="listCod" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(cod),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listCodYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(cod),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>
    <select id="listNh3n" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(NH3N),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listNh3nYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(NH3N),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>
    <select id="listTp" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(TP),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listTpYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(TP),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>
    <select id="listTn" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(TN),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listTnYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(TN),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>

    <select id="listFlow" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(FLOW),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m-%d')
        ORDER BY create_date ASC
    </select>
    <select id="listFlowYear" resultType="com.huimv.admin.entity.vo.ProCountVo">
        select Convert((IFNULL(AVG(FLOW),'0')),DECIMAL(10,2)) 'value',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y-%m')
        ORDER BY create_date ASC
    </select>


    <!--大屏-->
    <select id="flowCount" resultType="com.huimv.admin.entity.ProtData">
        select Convert((IFNULL(sum(FLOW),'0')),DECIMAL(10,2)) 'flow',create_date,loction_type from prot_data
        ${ew.customSqlSegment}
        group BY DATE_FORMAT(create_date,'%Y')
    </select>
    <select id="listAllScreen" resultType="com.huimv.admin.entity.ProtData"></select>
</mapper>
