<?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.huatek.busi.mapper.GisAssessmentResultDataMapper">

 <resultMap id="BaseResultMap" type="com.huatek.busi.entity.GisAssessmentResultData">
    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="evaluation_id" jdbcType="VARCHAR" property="evaluationId" />
    <result column="gis_id" jdbcType="VARCHAR" property="gisId" />
    <result column="gis_name" jdbcType="VARCHAR" property="gisName" />
    <result column="assess_time" jdbcType="TIMESTAMP" property="assessTime" />
    <result column="health_score" jdbcType="VARCHAR" property="healthScore" />
    <result column="health_level" jdbcType="VARCHAR" property="healthLevel" />
    <result column="dkcses" jdbcType="VARCHAR" property="dkcses" />
    <result column="future_failure_rate" jdbcType="VARCHAR" property="futureFailureRate" />
    <result column="contact_wear_rate" jdbcType="VARCHAR" property="contactWearRate" />
    <result column="contact_wear_rate" jdbcType="VARCHAR" property="contactWearRate" />
    <result column="expected_usage_count" jdbcType="VARCHAR" property="expectedUsageCount" />
    <result column="remaining_usage_count" jdbcType="VARCHAR" property="remainingUsageCount" />
	<result column="overhaul_suggest" jdbcType="VARCHAR" property="overhaulSuggest" />
	<result column="breaking_wear" jdbcType="VARCHAR" property="breakingWear" />
	<result column="operational_data" jdbcType="VARCHAR" property="operationalData" />
	<result column="operation_parameters" jdbcType="VARCHAR" property="operationParameters" />
	<result column="insulating_medium" jdbcType="VARCHAR" property="insulatingMedium" />
	<result column="breaking_wear_details" jdbcType="VARCHAR" property="breakingWearDetails" />
	<result column="operational_data_details" jdbcType="VARCHAR" property="operationalDataDetails" />
	<result column="operation_parameters_details" jdbcType="VARCHAR" property="operationParametersDetails" />
	<result column="insulating_medium_details" jdbcType="VARCHAR" property="insulatingMediumDetails" />    
  </resultMap>
  
  <sql id="Base_Column_List">
   		id as id,
		evaluation_id as evaluationId,
		gis_id as gisId,
		gis_name as gisName,
		assess_time as assessTime,
		health_score as healthScore,
		health_level as healthLevel,
		dkcses as dkcses,
		future_failure_rate as futureFailureRate,
		contact_wear_rate as contactWearRate,
		expected_usage_count as expectedUsageCount,
		remaining_usage_count as remainingUsageCount,
		overhaul_suggest as overhaulSuggest,
		breaking_wear as breakingWear,
		operational_data as operationalData,
		operation_parameters as operationParameters,
		insulating_medium as insulatingMedium,
		breaking_wear_details as breakingWearDetails,
		operational_data_details as operationalDataDetails,
		operation_parameters_details as operationParametersDetails,
		insulating_medium_details as insulatingMediumDetails 
  </sql>
  <select id="findGisAssessmentByMainTreeId" parameterType="java.lang.String" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from gis_assessment_result t
    where 
    t.site_id = #{siteId} 
    and t.main_tree_id = #{mainTreeId} 
    ORDER BY t.assess_time DESC 
  </select>
  
  
  <select id="findGisAssessmentResultDataByGisId" parameterType="java.lang.String" resultType="com.huatek.busi.entity.GisAssessmentResultData">
    select 
    <include refid="Base_Column_List" />
    from gis_assessment_result_data t
    where 
    t.gis_id = #{gisId} 
    ORDER BY t.`assess_time` DESC LIMIT 1
  </select>
  
  
  
</mapper>