Newer
Older
huludao / src / main / resources / mapper / WaterQuality / WaterQualityDataDao.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.newfiber.api.pc.dao.WaterQuality.WaterQualityDataDao">


    <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.WaterQuality.WaterQualityData">
        <id column="Serial" property="serial" jdbcType="BIGINT"/>
        <result column="Data_No" property="dataNo" jdbcType="VARCHAR"/>
        <result column="Field_Name_ZN" property="fieldNameZn" jdbcType="NVARCHAR"/>
        <result column="Field_Name" property="fieldName" jdbcType="VARCHAR"/>
        <result column="Field_Type" property="fieldType" jdbcType="VARCHAR"/>
        <result column="Field_Value" property="fieldValue" jdbcType="VARCHAR"/>
        <result column="SampPoint_Type" property="sampPointType" jdbcType="INTEGER"/>
        <result column="SampPoint_ID" property="sampPointID" jdbcType="NVARCHAR"/>
        <result column="Sampling_Date" property="samplingDate" jdbcType="TIMESTAMP"/>
        <result column="Create_User_No" property="createUserNo" jdbcType="VARCHAR"/>
        <result column="Create_Time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="Update_Time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="Update_User_No" property="updateUserNo" jdbcType="VARCHAR"/>
        <result column="ProjectType" property="projectType" jdbcType="INTEGER"/>

    </resultMap>

    <select id="getProBySiteNO" parameterType="string" resultType="string">
        SELECT DISTINCT Field_Name FROM (
        SELECT  CASE WHEN Field_Name = 'ORP' THEN -1 when  Field_Name = 'SS' then -2  ELSE 1 END AS o ,Field_Name
        from water_quality_data WHERE SampPoint_ID = #{siteNO} AND Field_Type != '--' AND (Field_Value != '/' AND  Field_Value != '-')
         ) f ORDER BY f.o desc

    </select>


    <select id="selectBySamPointId" parameterType="string" resultMap="BaseResultMap">
        SELECT
        Serial, Data_No, Field_Name_ZN, Field_Name, Field_Type, Field_Value, SampPoint_Type, SampPoint_ID,
        Sampling_Date,Create_User_No, Create_Time, Update_Time, Update_User_No
        FROM water_quality_data
        WHERE SampPoint_ID = #{siteNO}
        order by Sampling_Date asc
    </select>

    <select id="selectLatestData" parameterType="String" resultMap="BaseResultMap">

        SELECT
  Serial,
  Data_No,
  Field_Name_ZN,
  Field_Name,
  Field_Type,
  Field_Value,
  SampPoint_Type,
  SampPoint_ID,
  Create_User_No,
  Create_Time,
  Update_Time,
  Update_User_No,Sampling_Date
FROM water_quality_data
WHERE SampPoint_ID = #{siteNO} AND
      Sampling_Date = (SELECT max(Sampling_Date) FROM  water_quality_data WHERE SampPoint_ID = #{siteNO}
      )
AND Field_Type !='--' AND Field_Value != '/' AND Field_Value !='-'




    </select>


</mapper>