优化pile_msg_record插入数据

This commit is contained in:
jsowell
2026-07-01 16:30:38 +08:00
parent 06aab00627
commit aa7a9a10d9
5 changed files with 153 additions and 1 deletions

View File

@@ -16,7 +16,7 @@
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, pile_sn, frame_type, connector_code, pile_connector_code, original_msg, json_msg, create_time
id, pile_sn, transaction_code, frame_type, connector_code, pile_connector_code, original_msg, json_msg, create_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
<!--@mbg.generated-->
@@ -154,6 +154,19 @@
</select>
<select id="queryPileFeedList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from pile_msg_record
where pile_sn = #{pileSn,jdbcType=VARCHAR}
<if test="frameType != null and frameType != ''">
and frame_type = #{frameType,jdbcType=VARCHAR}
</if>
<if test="transactionCode != null and transactionCode != ''" >
and transaction_code = #{transactionCode,jdbcType=VARCHAR}
</if>
</select>
<select id="queryPileFeedListByJsonTransactionCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from pile_msg_record
@@ -165,4 +178,23 @@
and json_msg->>'$.transactionCode' LIKE CONCAT('%', #{transactionCode}, '%')
</if>
</select>
<select id="selectRetentionCutoffId" resultType="java.lang.Long">
select id
from pile_msg_record
where pile_sn = #{pileSn,jdbcType=VARCHAR}
and frame_type = #{frameType,jdbcType=VARCHAR}
and frame_type != '0x3B'
order by id desc
limit #{offset}, 1
</select>
<delete id="deleteOldRecordsBeforeId">
delete from pile_msg_record
where pile_sn = #{pileSn,jdbcType=VARCHAR}
and frame_type = #{frameType,jdbcType=VARCHAR}
and frame_type != '0x3B'
and id &lt; #{cutoffId,jdbcType=BIGINT}
limit #{limit}
</delete>
</mapper>