|  |  | 
 |  |  |   <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     <!--@Table rm_command_history--> | 
 |  |  |     <id column="id" jdbcType="BIGINT" property="id" /> | 
 |  |  |     <id column="com_id" jdbcType="BIGINT" property="comId" /> | 
 |  |  |     <result column="command_code" jdbcType="VARCHAR" property="commandCode" /> | 
 |  |  |     <result column="command_name" jdbcType="VARCHAR" property="commandName" /> | 
 |  |  |     <result column="rtuAddr" jdbcType="VARCHAR" property="rtuaddr" /> | 
 |  |  |     <result column="intake_id" jdbcType="BIGINT" property="intakeId" /> | 
 |  |  |     <result column="rtu_addr" jdbcType="VARCHAR" property="rtuAddr" /> | 
 |  |  |     <result column="protocol" jdbcType="VARCHAR" property="protocol" /> | 
 |  |  |     <result column="param" property="param" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" /> | 
 |  |  |     <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" /> | 
 |  |  |     <result column="operator" jdbcType="BIGINT" property="operator" /> | 
 |  |  |     <result column="result" jdbcType="TINYINT" property="result" /> | 
 |  |  |     <result column="result_time" jdbcType="TIMESTAMP" property="resultTime" /> | 
 |  |  |     <result column="result_text" property="resultText" jdbcType="JAVA_OBJECT" typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler" /> | 
 |  |  |     <result column="result_text" jdbcType="LONGVARCHAR" property="resultText" /> | 
 |  |  |   </resultMap> | 
 |  |  |   <sql id="Base_Column_List"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     id, command_code, command_name, rtuAddr, protocol, param, send_time, `operator`,  | 
 |  |  |     `result`, result_time, result_text | 
 |  |  |     com_id, command_code, command_name, intake_id, rtu_addr, protocol, param, send_time,  | 
 |  |  |     `operator`, `result`, result_time, result_text | 
 |  |  |   </sql> | 
 |  |  |   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     select  | 
 |  |  |     <include refid="Base_Column_List" /> | 
 |  |  |     from rm_command_history | 
 |  |  |     where id = #{id,jdbcType=BIGINT} | 
 |  |  |     where com_id = #{comId,jdbcType=BIGINT} | 
 |  |  |   </select> | 
 |  |  |   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     delete from rm_command_history | 
 |  |  |     where id = #{id,jdbcType=BIGINT} | 
 |  |  |     where com_id = #{comId,jdbcType=BIGINT} | 
 |  |  |   </delete> | 
 |  |  |   <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     insert into rm_command_history (id, command_code, command_name,  | 
 |  |  |       rtuAddr, protocol, param,  | 
 |  |  |       send_time, `operator`, `result`,  | 
 |  |  |       result_time, result_text) | 
 |  |  |     values (#{id,jdbcType=BIGINT}, #{commandCode,jdbcType=VARCHAR}, #{commandName,jdbcType=VARCHAR},  | 
 |  |  |       #{rtuaddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
 |  |  |       #{sendTime,jdbcType=TIMESTAMP}, #{operator,jdbcType=BIGINT}, #{result,jdbcType=TINYINT},  | 
 |  |  |       #{resultTime,jdbcType=TIMESTAMP}, #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}) | 
 |  |  |     insert into rm_command_history (com_id, command_code, command_name,  | 
 |  |  |       intake_id, rtu_addr, protocol,  | 
 |  |  |       param, send_time, `operator`,  | 
 |  |  |       `result`, result_time, result_text | 
 |  |  |       ) | 
 |  |  |     values (#{comId,jdbcType=BIGINT}, #{commandCode,jdbcType=VARCHAR}, #{commandName,jdbcType=VARCHAR},  | 
 |  |  |       #{intakeId,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, | 
 |  |  |       #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, #{sendTime,jdbcType=TIMESTAMP}, #{operator,jdbcType=BIGINT}, | 
 |  |  |       #{result,jdbcType=TINYINT}, #{resultTime,jdbcType=TIMESTAMP}, #{resultText,jdbcType=LONGVARCHAR} | 
 |  |  |       ) | 
 |  |  |   </insert> | 
 |  |  |   <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     insert into rm_command_history | 
 |  |  |     <trim prefix="(" suffix=")" suffixOverrides=","> | 
 |  |  |       <if test="id != null"> | 
 |  |  |         id, | 
 |  |  |       <if test="comId != null"> | 
 |  |  |         com_id, | 
 |  |  |       </if> | 
 |  |  |       <if test="commandCode != null"> | 
 |  |  |         command_code, | 
 |  |  | 
 |  |  |       <if test="commandName != null"> | 
 |  |  |         command_name, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuaddr != null"> | 
 |  |  |         rtuAddr, | 
 |  |  |       <if test="intakeId != null"> | 
 |  |  |         intake_id, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuAddr != null"> | 
 |  |  |         rtu_addr, | 
 |  |  |       </if> | 
 |  |  |       <if test="protocol != null"> | 
 |  |  |         protocol, | 
 |  |  | 
 |  |  |       </if> | 
 |  |  |     </trim> | 
 |  |  |     <trim prefix="values (" suffix=")" suffixOverrides=","> | 
 |  |  |       <if test="id != null"> | 
 |  |  |         #{id,jdbcType=BIGINT}, | 
 |  |  |       <if test="comId != null"> | 
 |  |  |         #{comId,jdbcType=BIGINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="commandCode != null"> | 
 |  |  |         #{commandCode,jdbcType=VARCHAR}, | 
 |  |  | 
 |  |  |       <if test="commandName != null"> | 
 |  |  |         #{commandName,jdbcType=VARCHAR}, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuaddr != null"> | 
 |  |  |         #{rtuaddr,jdbcType=VARCHAR}, | 
 |  |  |       <if test="intakeId != null"> | 
 |  |  |         #{intakeId,jdbcType=BIGINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuAddr != null"> | 
 |  |  |         #{rtuAddr,jdbcType=VARCHAR}, | 
 |  |  |       </if> | 
 |  |  |       <if test="protocol != null"> | 
 |  |  |         #{protocol,jdbcType=VARCHAR}, | 
 |  |  | 
 |  |  |         #{resultTime,jdbcType=TIMESTAMP}, | 
 |  |  |       </if> | 
 |  |  |       <if test="resultText != null"> | 
 |  |  |         #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
 |  |  |         #{resultText,jdbcType=LONGVARCHAR}, | 
 |  |  |       </if> | 
 |  |  |     </trim> | 
 |  |  |   </insert> | 
 |  |  | 
 |  |  |       <if test="commandName != null"> | 
 |  |  |         command_name = #{commandName,jdbcType=VARCHAR}, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuaddr != null"> | 
 |  |  |         rtuAddr = #{rtuaddr,jdbcType=VARCHAR}, | 
 |  |  |       <if test="intakeId != null"> | 
 |  |  |         intake_id = #{intakeId,jdbcType=BIGINT}, | 
 |  |  |       </if> | 
 |  |  |       <if test="rtuAddr != null"> | 
 |  |  |         rtu_addr = #{rtuAddr,jdbcType=VARCHAR}, | 
 |  |  |       </if> | 
 |  |  |       <if test="protocol != null"> | 
 |  |  |         protocol = #{protocol,jdbcType=VARCHAR}, | 
 |  |  | 
 |  |  |         result_time = #{resultTime,jdbcType=TIMESTAMP}, | 
 |  |  |       </if> | 
 |  |  |       <if test="resultText != null"> | 
 |  |  |         result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
 |  |  |         result_text = #{resultText,jdbcType=LONGVARCHAR}, | 
 |  |  |       </if> | 
 |  |  |     </set> | 
 |  |  |     where id = #{id,jdbcType=BIGINT} | 
 |  |  |     where com_id = #{comId,jdbcType=BIGINT} | 
 |  |  |   </update> | 
 |  |  |   <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> | 
 |  |  |     <!--@mbg.generated--> | 
 |  |  |     update rm_command_history | 
 |  |  |     set command_code = #{commandCode,jdbcType=VARCHAR}, | 
 |  |  |       command_name = #{commandName,jdbcType=VARCHAR}, | 
 |  |  |       rtuAddr = #{rtuaddr,jdbcType=VARCHAR}, | 
 |  |  |       intake_id = #{intakeId,jdbcType=BIGINT}, | 
 |  |  |       rtu_addr = #{rtuAddr,jdbcType=VARCHAR}, | 
 |  |  |       protocol = #{protocol,jdbcType=VARCHAR}, | 
 |  |  |       param = #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, | 
 |  |  |       send_time = #{sendTime,jdbcType=TIMESTAMP}, | 
 |  |  |       `operator` = #{operator,jdbcType=BIGINT}, | 
 |  |  |       `result` = #{result,jdbcType=TINYINT}, | 
 |  |  |       result_time = #{resultTime,jdbcType=TIMESTAMP}, | 
 |  |  |       result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} | 
 |  |  |     where id = #{id,jdbcType=BIGINT} | 
 |  |  |       result_text = #{resultText,jdbcType=LONGVARCHAR} | 
 |  |  |     where com_id = #{comId,jdbcType=BIGINT} | 
 |  |  |   </update> | 
 |  |  |  | 
 |  |  |   <!--根据操作员ID获取未关阀记录(包含在线情况)--> | 
 |  |  |   <select id="getUnclosedValves" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedValve"> | 
 |  |  |     SELECT | 
 |  |  |         com.command_code AS commandCode, | 
 |  |  |         inta.name AS intakeNum, | 
 |  |  |         rtus.isOnLine, | 
 |  |  |         com.rtuAddr, | 
 |  |  |         com.param ->>'$.orderNo' AS orderNo, | 
 |  |  |         com.rtu_addr AS rtuAddr, | 
 |  |  |         com.param ->>'$.icCardNo' AS vcNum, | 
 |  |  |         com.send_time AS openTime | 
 |  |  |         (SELECT param ->>'$.orderNo' AS orderNo FROM rm_command_history WHERE rtu_addr = com.rtu_addr ORDER BY send_time desc LIMIT 0,1) AS orderNo | 
 |  |  |     FROM rm_command_history com | 
 |  |  |         INNER JOIN pr_controller con ON com.rtuAddr = con.rtuAddr | 
 |  |  |         INNER JOIN pr_controller con ON com.rtu_addr = con.rtuAddr | 
 |  |  |         INNER JOIN pr_intake inta ON con.intakeId = inta.id | 
 |  |  |         INNER JOIN JSON_TABLE( | 
 |  |  |             <!--'[{"rtuAddr":"37142501020100215","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> | 
 |  |  | 
 |  |  |                 rtuAddr VARCHAR(20) PATH '$.rtuAddr', | 
 |  |  |                 isOnLine BOOLEAN PATH '$.isOnLine' | 
 |  |  |             ) | 
 |  |  |         ) rtus ON com.rtuAddr = rtus.rtuAddr | 
 |  |  |     WHERE (com.command_code = '92' OR com.command_code = 'A2') AND com.operator = #{operator} | 
 |  |  |     AND NOT EXISTS (SELECT * FROM rm_command_history WHERE (command_code = '93' OR command_code = 'A3') AND param ->>'$.orderNo' = com.param ->>'$.orderNo') | 
 |  |  |         ) rtus ON com.rtu_addr = rtus.rtuAddr | 
 |  |  |     <where> | 
 |  |  |       AND (com.command_code = '92' OR com.command_code = 'A2' OR com.command_code = '97') | 
 |  |  |       AND com.operator = #{operator} | 
 |  |  |       AND NOT EXISTS ( | 
 |  |  |         SELECT * | 
 |  |  |         FROM rm_command_history | 
 |  |  |         WHERE (result IS NULL OR result = 1 ) | 
 |  |  |             AND (command_code = '93' OR command_code = 'A3' OR command_code = '98') | 
 |  |  |             AND param ->>'$.orderNo' = com.param ->>'$.orderNo' | 
 |  |  |       ) | 
 |  |  |     </where> | 
 |  |  |     GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->>'$.icCardNo' | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据取水口ID获取该取水口未关阀参数--> | 
 |  |  |   <select id="getUncloseParam" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedParam"> | 
 |  |  |     SELECT | 
 |  |  |         com.rtu_addr AS rtuAddr, | 
 |  |  |         com.param ->>'$.orderNo' AS orderNo, | 
 |  |  |         com.param ->>'$.icCardNo' AS vcNum | 
 |  |  |     FROM rm_command_history com | 
 |  |  |         INNER JOIN pr_controller con ON com.rtu_addr = con.rtuAddr | 
 |  |  |         INNER JOIN pr_intake inta ON con.intakeId = inta.id | 
 |  |  |         INNER JOIN JSON_TABLE( | 
 |  |  |             <!--      '[{"rtuAddr":"620201000029","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',--> | 
 |  |  |             #{onLineMap}, | 
 |  |  |             '$[*]' COLUMNS( | 
 |  |  |                 rtuAddr VARCHAR(20) PATH '$.rtuAddr', | 
 |  |  |                 isOnLine BOOLEAN PATH '$.isOnLine' | 
 |  |  |             ) | 
 |  |  |         ) rtus ON com.rtu_addr = rtus.rtuAddr | 
 |  |  |     WHERE (com.command_code = '92' OR com.command_code = 'A2' OR com.command_code = '97') AND con.intakeId = #{intakeId} | 
 |  |  |     AND NOT EXISTS ( | 
 |  |  |         SELECT * | 
 |  |  |         FROM rm_command_history | 
 |  |  |         WHERE (result IS NULL OR result = 1 ) | 
 |  |  |             AND (command_code = '93' OR command_code = 'A3' OR command_code = '98') | 
 |  |  |             AND param ->>'$.orderNo' = com.param ->>'$.orderNo' | 
 |  |  |     ) | 
 |  |  |     ORDER BY com.send_time DESC | 
 |  |  |     LIMIT 0,1 | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据指定条件获取命令日志历史记录总数--> | 
 |  |  |   <select id="getCommandHistoriesCount" resultType="java.lang.Long"> | 
 |  |  |     SELECT | 
 |  |  |         COUNT(*) AS recordCount | 
 |  |  |     FROM rm_command_history his | 
 |  |  |       INNER JOIN pr_intake inta ON inta.id = his.intake_id | 
 |  |  |       LEFT JOIN se_client cli ON cli.id = his.operator | 
 |  |  |       LEFT JOIN ba_user  user ON user.id = his.operator | 
 |  |  |     <where> | 
 |  |  |       <if test = "commandName != null and commandName !=''"> | 
 |  |  |         AND his.command_name LIKE CONCAT('%',#{commandName},'%') | 
 |  |  |       </if> | 
 |  |  |       <if test = "result != null"> | 
 |  |  |         AND his.result = #{result} | 
 |  |  |       </if> | 
 |  |  |       <if test = "timeStart != null and timeStop != null"> | 
 |  |  |         AND his.send_time BETWEEN #{timeStart} AND #{timeStop} | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |   </select> | 
 |  |  |  | 
 |  |  |   <!--根据指定条件获取命令日志历史记录--> | 
 |  |  |   <select id="getCommandHistories" resultType="com.dy.pipIrrGlobal.voRm.VoCommand"> | 
 |  |  |     SELECT | 
 |  |  |         his.com_id AS comId, | 
 |  |  |         his.command_name AS commandName, | 
 |  |  |         inta.name AS intakeName, | 
 |  |  |         his.rtu_addr AS rtuAddr, | 
 |  |  |         his.protocol, | 
 |  |  |         his.send_time AS sendTime, | 
 |  |  |         his.result_time AS resultTime, | 
 |  |  |         (CASE | 
 |  |  |         WHEN his.result = 1 THEN "成功" | 
 |  |  |         ELSE "失败" | 
 |  |  |         END) AS result, | 
 |  |  |         his.result_text, | 
 |  |  |         IFNULL(cli.name, user.name) AS userName | 
 |  |  |     FROM rm_command_history his | 
 |  |  |         INNER JOIN pr_intake inta ON inta.id = his.intake_id | 
 |  |  |         LEFT JOIN se_client cli ON cli.id = his.operator | 
 |  |  |         LEFT JOIN ba_user  user ON user.id = his.operator | 
 |  |  |     <where> | 
 |  |  |       <if test = "commandName != null and commandName !=''"> | 
 |  |  |         AND his.command_name LIKE CONCAT('%',#{commandName},'%') | 
 |  |  |       </if> | 
 |  |  |       <if test = "result != null"> | 
 |  |  |         AND his.result = #{result} | 
 |  |  |       </if> | 
 |  |  |  | 
 |  |  |       <if test = "timeStart != null and timeStop != null"> | 
 |  |  |         AND his.send_time BETWEEN #{timeStart} AND #{timeStop} | 
 |  |  |       </if> | 
 |  |  |     </where> | 
 |  |  |     ORDER BY his.send_time DESC | 
 |  |  |     <trim prefix="limit " > | 
 |  |  |       <if test="start != null and count != null"> | 
 |  |  |         #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
 |  |  |       </if> | 
 |  |  |     </trim> | 
 |  |  |   </select> | 
 |  |  | </mapper> |