INSERT INTO task_execution ( task_id, task_name, trigger_type, execution_plan, current_index, status, version, started_at, expected_finish_at, last_heartbeat_at, tenant_id, created_at ) VALUES ( #{taskId}, #{taskName}, #{triggerType}, #{executionPlan,typeHandler=cn.sciento.farm.automationv2.infra.typehandler.ExecutionPlanTypeHandler}, #{currentIndex}, #{status}, #{version}, #{startedAt}, #{expectedFinishAt}, #{lastHeartbeatAt}, #{tenantId}, NOW() ) UPDATE task_execution execution_plan = #{executionPlan,typeHandler=cn.sciento.farm.automationv2.infra.typehandler.ExecutionPlanTypeHandler}, current_index = #{currentIndex}, status = #{status}, started_at = #{startedAt}, finished_at = #{finishedAt}, expected_finish_at = #{expectedFinishAt}, last_heartbeat_at = #{lastHeartbeatAt}, fail_reason = #{failReason}, safe_close_status = #{safeCloseStatus}, safe_close_details = #{safeCloseDetails}, updated_at = NOW() WHERE id = #{id} UPDATE task_execution execution_plan = #{executionPlan,typeHandler=cn.sciento.farm.automationv2.infra.typehandler.ExecutionPlanTypeHandler}, current_index = #{currentIndex}, status = #{status}, started_at = #{startedAt}, finished_at = #{finishedAt}, expected_finish_at = #{expectedFinishAt}, fail_reason = #{failReason}, safe_close_status = #{safeCloseStatus}, version = version + 1, updated_at = NOW() WHERE id = #{id} AND version = #{version} UPDATE task_execution SET current_index = #{currentIndex}, version = version + 1, updated_at = NOW() WHERE id = #{id} AND version = #{version} UPDATE task_execution SET execution_plan = #{executionPlan,typeHandler=cn.sciento.farm.automationv2.infra.typehandler.ExecutionPlanTypeHandler}, version = version + 1, updated_at = NOW() WHERE id = #{id} AND version = #{version} UPDATE task_execution SET last_heartbeat_at = NOW() WHERE id = #{id} DELETE FROM task_execution WHERE id = #{id}