添加冷却时间等概念
This commit is contained in:
@@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="workStatus" column="work_status"/>
|
||||
<result property="idleTime" column="idle_time"/>
|
||||
<result property="maintainReason" column="maintain_reason"/>
|
||||
<result property="cooldownUntil" column="cooldown_until"/>
|
||||
<result property="lastHeartbeatTime" column="last_heartbeat_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
@@ -25,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<sql id="selectAfDeviceVo">
|
||||
select id, user_name, device_code, online_status, task_status, current_task_id,
|
||||
dispatch_enabled, work_status, idle_time, maintain_reason, last_heartbeat_time,
|
||||
dispatch_enabled, work_status, idle_time, maintain_reason, cooldown_until, last_heartbeat_time,
|
||||
create_by, create_time, update_by, update_time, remark
|
||||
from af_device
|
||||
</sql>
|
||||
@@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and dispatch_enabled = 'Y'
|
||||
and work_status = 'READY'
|
||||
and (maintain_reason is null or maintain_reason = '')
|
||||
and (cooldown_until is null or cooldown_until <= now())
|
||||
order by idle_time asc, last_heartbeat_time desc, id asc
|
||||
limit 1
|
||||
for update
|
||||
@@ -99,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and dispatch_enabled = 'Y'
|
||||
and work_status = 'READY'
|
||||
and (maintain_reason is null or maintain_reason = '')
|
||||
and (cooldown_until is null or cooldown_until <= now())
|
||||
for update
|
||||
</select>
|
||||
|
||||
@@ -125,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="workStatus != null and workStatus != ''">work_status = #{workStatus},</if>
|
||||
<if test="idleTime != null">idle_time = #{idleTime},</if>
|
||||
<if test="maintainReason != null">maintain_reason = #{maintainReason},</if>
|
||||
<if test="cooldownUntil != null">cooldown_until = #{cooldownUntil},</if>
|
||||
<if test="lastHeartbeatTime != null">last_heartbeat_time = #{lastHeartbeatTime},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
@@ -138,6 +142,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set task_status = 'HAS_TASK',
|
||||
current_task_id = #{currentTaskId},
|
||||
idle_time = null,
|
||||
cooldown_until = null,
|
||||
update_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where id = #{id}
|
||||
@@ -152,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set task_status = 'IDLE',
|
||||
current_task_id = null,
|
||||
idle_time = sysdate(),
|
||||
cooldown_until = null,
|
||||
update_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where id = #{id}
|
||||
@@ -163,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
set task_status = 'IDLE',
|
||||
current_task_id = null,
|
||||
idle_time = sysdate(),
|
||||
cooldown_until = null,
|
||||
update_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where id = #{id}
|
||||
@@ -170,6 +177,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and current_task_id = #{currentTaskId}
|
||||
</update>
|
||||
|
||||
<update id="updateDeviceAfterTaskFinish">
|
||||
update af_device
|
||||
set task_status = 'IDLE',
|
||||
current_task_id = null,
|
||||
idle_time = sysdate(),
|
||||
cooldown_until = date_add(now(), interval #{cooldownSeconds} second),
|
||||
update_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where id = #{id}
|
||||
and current_task_id = #{currentTaskId}
|
||||
</update>
|
||||
|
||||
<update id="enableDeviceDispatch">
|
||||
update af_device
|
||||
set dispatch_enabled = 'Y',
|
||||
|
||||
Reference in New Issue
Block a user