<?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.configuration.ConstantValueMapper'>
    <resultMap type="ConstantValue" id="ConstantValueMap" autoMapping="true">
        <id column="PV_INDEX" property="pvIndex"/>
    </resultMap>
    <!--查询外部定值-->
    <select id="quarryOutValueBase" resultMap="ConstantValueMap">
       select a.*from PQS_PROTECTVALUE a where  a.cpu_no=#{lineIndex} and a.type like '%80%'  order by a.sort
	</select>
    <!--查询内部定值-->
    <select id="quarryInValueBase" resultMap="ConstantValueMap">
       select a.*from PQS_PROTECTVALUE a where a.cpu_no=#{devIndex} and a.type like '%90%'  order by a.sort
	</select>
    <!--统计次数-->
    <select id="quarryOutCount" resultType="int">
	select count(*) from PQS_PROTECTVALUE where devtype=#{devtype} and cpu_no=#{lineIndex} and type like '%80%'
    </select>
    <delete id="deleteWord">
		delete from PQS_PROTECTCONTROLWORD c where c.PV_INDEX in(select b.PV_INDEX from PQS_PROTECTCONTROLWORD b
		where b.PV_INDEX in(select a.PV_INDEX from PQS_PROTECTVALUE a where a.devtype=#{devtype} and a.type like
		'%90%'))
	</delete>
    <delete id="deleteValue">
		delete from PQS_PROTECTVALUE a where a.cpu_no=#{devtype} and a.type like #{type}
    </delete>
    <delete id="deleteOutValue">
		delete from PQS_PROTECTVALUE a where a.cpu_no=#{lineIndex} and a.type like #{type}
    </delete>
    <update id="updateOut">
        update PQS_PROTECTVALUE a set a.value =#{value} where a.sort=#{sort} and a.cpu_no=#{cpuNo} and a.type
         like #{type}
    </update>
    <update id="updateIn">
        update PQS_PROTECTVALUE a set a.value =#{value} where a.sort=#{sort} and a.cpu_no=#{cpuNo} and a.type
         like #{type}
    </update>
    <select id="getConvId" resultMap="ConstantValueMap">
        select * from PQS_PROTECTVALUE a where a.cpu_no=#{cpuNo} and a.sort=#{sort} and a.type like #{type}
    </select>
</mapper>