<?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.TransformerEvaluateMapper">
<select id="findEvaluateStatus" parameterType="java.lang.String" resultType="com.huatek.busi.entity.TransformerEvaluateStatus">
	SELECT
		t.site_id as siteId,
		t.main_equipment_id as mainEquipmentId,
		t.transformer_name as transformerName,
		e.evaluate_date as evaluateDate,
		e.health_index as healthIndex,
		e.score as score,
		t.`status`
	FROM busi_offline_transformer_brand t
	LEFT JOIN transformer_evaluation_results e on t.main_equipment_id = e.main_tree_id
	GROUP BY t.main_equipment_id
</select>


	<select id="findEquipmentEvaluateStatus" resultType="com.huatek.busi.entity.EquipmentEvaluateStatus">
		SELECT
				t.site_id as siteId,
				t.main_equipment_id as mainEquipmentId,
				e.evaluate_date as evaluateDate,
				e.health_index as healthIndex,
				e.score as score,
				t.`status`
			FROM busi_offline_transformer_brand t
			LEFT JOIN transformer_evaluation_results e on t.main_equipment_id = e.main_tree_id
			GROUP BY t.main_equipment_id
		UNION
		SELECT
			t.site_id as siteId,
			t.main_equipment_id as mainEquipmentId,
			e.assess_time as assessTime,
			e.health_level as healthLevel,
			e.health_score as healthScore,
			t.`status`
		FROM busi_offline_gis_brand t
		LEFT JOIN gis_assessment_result e on t.main_equipment_id = e.main_tree_id
		GROUP BY t.main_equipment_id
	</select>
</mapper>