2026-09-28 10:55:48 +08:00
|
|
|
<?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.ruoyi.warehouse.mapper.AiCommandMapper">
|
|
|
|
|
<resultMap id="AiCommandResult" type="com.ruoyi.warehouse.domain.AiCommand">
|
|
|
|
|
<id property="id" column="id"/>
|
|
|
|
|
<result property="userId" column="user_id"/>
|
|
|
|
|
<result property="username" column="username"/>
|
|
|
|
|
<result property="action" column="action"/>
|
|
|
|
|
<result property="requiredPermission" column="required_permission"/>
|
|
|
|
|
<result property="requestText" column="request_text"/>
|
|
|
|
|
<result property="planJson" column="plan_json"/>
|
|
|
|
|
<result property="resultJson" column="result_json"/>
|
|
|
|
|
<result property="commandStatus" column="command_status"/>
|
|
|
|
|
<result property="expiresAt" column="expires_at"/>
|
|
|
|
|
<result property="confirmedAt" column="confirmed_at"/>
|
|
|
|
|
<result property="executedAt" column="executed_at"/>
|
|
|
|
|
<result property="errorMessage" column="error_message"/>
|
|
|
|
|
<result property="createTime" column="create_time"/>
|
|
|
|
|
<result property="updateTime" column="update_time"/>
|
|
|
|
|
</resultMap>
|
|
|
|
|
|
|
|
|
|
<insert id="insertAiCommand" parameterType="com.ruoyi.warehouse.domain.AiCommand" useGeneratedKeys="true" keyProperty="id">
|
|
|
|
|
insert into ai_command(user_id, username, action, required_permission, request_text, plan_json,
|
|
|
|
|
command_status, expires_at, create_time)
|
|
|
|
|
values(#{userId}, #{username}, #{action}, #{requiredPermission}, #{requestText}, cast(#{planJson} as json),
|
|
|
|
|
#{commandStatus}, #{expiresAt}, sysdate())
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<select id="selectAiCommandForUpdate" resultMap="AiCommandResult">
|
|
|
|
|
select * from ai_command where id = #{id} and user_id = #{userId} for update
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="markExecuting">
|
|
|
|
|
update ai_command set command_status = 'EXECUTING', confirmed_at = sysdate(), update_time = sysdate()
|
|
|
|
|
where id = #{id} and user_id = #{userId} and command_status = 'WAIT_CONFIRM' and expires_at > sysdate()
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="markSucceeded">
|
|
|
|
|
update ai_command set command_status = 'SUCCEEDED', result_json = cast(#{resultJson} as json),
|
|
|
|
|
executed_at = sysdate(), update_time = sysdate()
|
|
|
|
|
where id = #{id} and command_status = 'EXECUTING'
|
|
|
|
|
</update>
|
2026-10-16 15:30:10 +08:00
|
|
|
|
|
|
|
|
<select id="selectAssistantCommand" resultMap="AiCommandResult">
|
|
|
|
|
select * from ai_command where id = #{id} and user_id = #{userId}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<update id="updateAssistantCommand" parameterType="com.ruoyi.warehouse.domain.AiCommand">
|
|
|
|
|
update ai_command set plan_json = cast(#{planJson} as json),
|
|
|
|
|
result_json = cast(#{resultJson} as json), command_status = #{commandStatus},
|
|
|
|
|
confirmed_at = #{confirmedAt}, executed_at = #{executedAt},
|
|
|
|
|
error_message = #{errorMessage}, expires_at = #{expiresAt}, update_time = sysdate()
|
|
|
|
|
where id = #{id} and user_id = #{userId}
|
|
|
|
|
</update>
|
2026-09-28 10:55:48 +08:00
|
|
|
</mapper>
|