From 5f50bd7bf3a0c039e2e45e336978287b81c8efb0 Mon Sep 17 00:00:00 2001 From: wuzeyu <1223318623@qq.com> Date: 星期二, 24 九月 2024 14:47:00 +0800 Subject: [PATCH] 优化代码 条件获取流浪控制器接口结果排序优化 --- pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerTrampMapper.xml | 80 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 73 insertions(+), 7 deletions(-) diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerTrampMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerTrampMapper.xml index f3830e0..d1ee14b 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerTrampMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/PrControllerTrampMapper.xml @@ -8,20 +8,21 @@ <result column="rtuAddr" jdbcType="VARCHAR" property="rtuAddr" /> <result column="protocol" jdbcType="VARCHAR" property="protocol" /> <result column="findDt" jdbcType="TIMESTAMP" property="findDt" /> + <result column="orgTag" jdbcType="VARCHAR" property="orgTag" /> </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> - id, rtuAddr, protocol, findDt + id, rtuAddr, protocol, findDt, orgTag </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <!--@mbg.generated--> - select + select <include refid="Base_Column_List" /> from pr_controller_tramp where id = #{id,jdbcType=BIGINT} </select> - <select id="selectPrControllerTrampByRtuAddr" parameterType="java.lang.String" resultMap="BaseResultMap"> + <select id="getPrControllerTrampByRtuAddr" parameterType="java.lang.String" resultMap="BaseResultMap"> <!--@mbg.generated--> select <include refid="Base_Column_List" /> @@ -36,10 +37,10 @@ </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoPr.PrControllerTramp"> <!--@mbg.generated--> - insert into pr_controller_tramp (id, rtuAddr, protocol, - findDt) + insert into pr_controller_tramp (id, rtuAddr, protocol, + findDt, orgTag) values (#{id,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, - #{findDt,jdbcType=TIMESTAMP}) + #{findDt,jdbcType=TIMESTAMP},#{orgTag,jdbcType=VARCHAR}) </insert> <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoPr.PrControllerTramp"> <!--@mbg.generated--> @@ -57,6 +58,9 @@ <if test="findDt != null"> findDt, </if> + <if test="orgTag != null"> + orgTag, + </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="id != null"> @@ -70,6 +74,9 @@ </if> <if test="findDt != null"> #{findDt,jdbcType=TIMESTAMP}, + </if> + <if test="orgTag != null"> + #{orgTag,jdbcType=VARCHAR}, </if> </trim> </insert> @@ -86,6 +93,9 @@ <if test="findDt != null"> findDt = #{findDt,jdbcType=TIMESTAMP}, </if> + <if test="orgTag != null"> + orgTag = #{orgTag,jdbcType=VARCHAR}, + </if> </set> where id = #{id,jdbcType=BIGINT} </update> @@ -94,7 +104,63 @@ update pr_controller_tramp set rtuAddr = #{rtuAddr,jdbcType=VARCHAR}, protocol = #{protocol,jdbcType=VARCHAR}, - findDt = #{findDt,jdbcType=TIMESTAMP} + findDt = #{findDt,jdbcType=TIMESTAMP}, + orgTag = #{orgTag,jdbcType=VARCHAR} where id = #{id,jdbcType=BIGINT} </update> + + <!--鏍规嵁鎺у埗鍣ㄧ紪鍙疯幏鍙栨祦娴帶鍒跺櫒鍦板潃--> +<!-- <select id="getTrampRtuAddr" resultType="java.lang.String">--> +<!-- SELECT rtuAddr FROM pr_controller_tramp WHERE id = ${controllerId}--> +<!-- </select>--> + + <!--鏍规嵁鎺у埗鍣ㄧ紪鍙疯幏鍙栨祦娴帶鍒跺櫒淇℃伅--> + <select id="getTrampControllerInfo" resultMap="BaseResultMap"> + SELECT rtuAddr, protocol, findDt, orgTag FROM pr_controller_tramp WHERE id = #{controllerId} + </select> + + <!-- 鏍规嵁鏉′欢鑾峰彇娴佹氮鎺у埗鍣ㄤ俊鎭�--> + <select id="getTrampControllers" resultMap="BaseResultMap"> + select CAST(id AS char)AS id, + rtuAddr, + protocol, + findDt, + orgTag + FROM pr_controller_tramp + <where> + <if test="id != null and id !=''"> + id = #{id,jdbcType=VARCHAR} + </if> + <if test="rtuAddr != null and rtuAddr != ''"> + AND rtuAddr = #{rtuAddr,jdbcType=VARCHAR} + </if> + <if test="protocol != null and protocol != ''"> + AND protocol = #{protocol,jdbcType=VARCHAR} + </if> + </where> + <trim prefix="limit " > + <if test="start != null and count != null"> + #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} + </if> + </trim> + order by rtuAddr desc + </select> + <!-- 鏍规嵁鏉′欢鑾峰彇娴佹氮鎺у埗鍣ㄦ暟閲�--> + <select id="getTrampControllersCount" resultType="java.lang.Long"> + select + COUNT(*) AS recordCount + FROM pr_controller_tramp + <where> + <if test="id != null and id !=''"> + id = #{id,jdbcType=VARCHAR} + </if> + <if test="rtuAddr != null and rtuAddr != ''"> + AND rtuAddr = #{rtuAddr,jdbcType=VARCHAR} + </if> + <if test="protocol != null and protocol != ''"> + AND protocol = #{protocol,jdbcType=VARCHAR} + </if> + + </where> + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0