<?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.njcn.mapper.user.TransFormerMapper">

<resultMap type="com.njcn.pojo.user.TransFormer" id="TransFormerMapperMap" autoMapping="true">
	<id property="tf_Index" column="TF_INDEX"/>
</resultMap>
<select id="selectAll" resultMap="TransFormerMapperMap">
select * from PQS_Transformer order by updatetime desc
</select>
<select id="selectRank" resultType="int">
select nvl(max(pqs_transformer.rank),0) from pqs_transformer order by updatetime desc
</select>
<select id="selectId" resultMap="TransFormerMapperMap">
select * from PQS_Transformer where tf_index=#{tfIndex} order by updatetime desc
</select>
<!--通过选择供电公司过滤-->
<select id="selectgd" resultMap="TransFormerMapperMap">
SELECT * FROM PQS_TRANSFORMER where sub_index in(select sub_index from PQ_SubStation where gd_index in(select gd_index from pq_gdinformation where name=#{name})) order by updatetime desc
</select>
<!--通过选择变电站过滤-->
<select id="selectsub" resultMap="TransFormerMapperMap">
SELECT * FROM PQS_TRANSFORMER where sub_index in(select sub_index from PQ_SubStation where name=#{name}) order by updatetime desc
</select>
<!-- 修改 -->
<update id="updateTrans">
update pqs_transformer tf set tf.tfname=#{tfName},tf.sub_index=#{subIndex},
 tf.wiring=#{wiring},tf.TF_DESCRIBE=#{description},tf.user_index=#{userIndex},
 tf.updatetime=#{updateTime} where tf.tf_index=#{tfIndex}
</update>
<!-- 查询除此之外的名称 -->
<select id="selectName" resultMap="TransFormerMapperMap">
select * from pqs_transformer  where tfname not in (select tfname from pqs_transformer where tf_index=#{tfIndex}) order by updatetime desc
</select>
<select id="selectOneName" resultMap="TransFormerMapperMap">
SELECT TF_INDEX,TFNAME,WIRING,TF_DESCRIBE,RANK,USER_INDEX,UPDATETIME FROM PQS_TRANSFORMER WHERE TFNAME =#{tfName} order by updatetime desc
</select>
<select id="selectNameAll" resultMap="TransFormerMapperMap">
SELECT * FROM PQS_TRANSFORMER WHERE TFNAME =#{tfName} order by updatetime desc
</select>
<!-- 根据id查询变压器名 -->
<select id="selectTwoName" resultMap="TransFormerMapperMap">
select * from pqs_transformer where tf_index=#{tfIndex} order by updatetime desc
</select>
</mapper>