<?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.RptDataMapper'>
    <select id="selectMaxRDIndex" resultType="String">
			select max(rd_index) from pqs_rptdata where  State = 1
	</select>

    <select id="getMaxDesc" resultType="int">
		select  nvl(max(sort),0) from pqs_rptdata where  State = 1
	</select>

    <select id="testName" resultType="RptData">
		select * from PQS_RptData where  State = 1 and RD_Name = #{name} and RD_Index != #{rdIndex}
	</select>

    <select id="getDatasByPloy" resultType="RptData">
		select * from PQS_RPTDATA t2 where T2.RD_INDEX in(
			select T1.RD_INDEX from PQS_RPTASS t1 where T1.RP_INDEX = #{rpIndex}
		)
	</select>

    <update id="deleteData">
		update pqs_rptdata set state = 0,updatetime = #{updateTime} where rd_index = #{rdIndex} or parentguid = #{rdIndex}
	</update>

    <update id="updateData">
		update pqs_rptdata set rd_name = #{shortName},describe = #{fullName},updatetime = #{updateTime} where rd_index = #{rdIndex}
	</update>

    <select id="getNodeData" resultType="RptData">
		select 
			*
		from PQS_RptData 
		where parentnode=#{parent} and datatype=#{dataType} and State = 1 and parentguid is null
	    order by Sort
	</select>

    <select id="getTreeState" resultType="java.lang.String">
		select rd_index from pqs_rptass where rp_index = #{rpIndex}
    </select>
</mapper>