wuzeyu
2024-07-04 04a3aa29899d113b8ed8dabf674b054e2b0e8c31
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml
@@ -227,7 +227,8 @@
      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}]',
<!--      '[{"rtuAddr":"620201000029","isOnLine":true},{"rtuAddr":"4000004","isOnLine":true},{"rtuAddr":"dy20240325","isOnLine":false}]',-->
        #{onLineMap},
      '$[*]' COLUMNS(
      rtuAddr VARCHAR(20) PATH '$.rtuAddr',
      isOnLine BOOLEAN PATH '$.isOnLine'
@@ -245,4 +246,65 @@
      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.id,
      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>