在线标注底层api接口

This commit is contained in:
weiweiw 2024-11-24 11:03:01 +08:00
parent d8a873995b
commit 3d33a8ce96
4 changed files with 127 additions and 51 deletions

View File

@ -0,0 +1,25 @@
package com.bonus.ai.domain.dataset;
import lombok.Data;
import java.util.Date;
@Data
public class AnnotationTaskAnnotatorMap {
private Long annotatorId; // 标注人员
private Long reviewerId; // 审核人员
private Long taskId; // 任务ID
private Long fileId; // 文件ID
private String description; // 描述
private String annotationStatus; // 标注状态
private String annotationResult; // 标注结果 (JSON串)
private String annotationResource; // 标注资源类型
private String delFlag; // 删除标记
private Date annotationTime; // 标注时间
private Date reviewTime; // 审核时间
private String auditFailedReason; // 审核驳回原因
private String createBy; // 创建者
private String updateBy; // 更新者
private Date updateTime; // 更新时间
private Date createTime; // 创建时间
}

View File

@ -16,6 +16,8 @@ public class AnnotationTaskEntity extends BaseEntity {
private Long datasetId;
/**标注团队id,为0表示未启用标注团队,1启用标注团队*/
private String isStartTeam;
private String taskUuid;
/**任务名称*/
private String taskName;
/**任务描述*/

View File

@ -4,62 +4,41 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.ai.mapper.AnnotationTaskMapper">
<!-- 插入标注任务 -->
<insert id="insertAnnotationTask" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
INSERT INTO ai_annotation_task (dataset_id, task_name, task_uuid, description,
annotation_scene, annotation_type, labels, is_annotation,
annotation_status, project_id, del_flag, create_by, create_time, update_by, update_time)
VALUES (#{datasetId}, #{taskName}, #{taskUuid}, #{taskDesc},
#{annotateScene}, #{annotateType}, #{labels}, #{isStartTeam},
#{annotateTaskStatus}, #{projectId}, #{delFlag}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime})
</insert>
<!-- ResultMap映射 -->
<resultMap id="BaseResultMap" type="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
<id column="task_id" property="taskId" jdbcType="BIGINT"/>
<result column="dataset_id" property="datasetId" jdbcType="BIGINT"/>
<result column="task_name" property="taskName" jdbcType="VARCHAR"/>
<result column="task_uuid" property="taskUuid" jdbcType="VARCHAR"/>
<result column="description" property="taskDesc" jdbcType="VARCHAR"/>
<result column="annotation_scene" property="annotateScene" jdbcType="CHAR"/>
<result column="annotation_type" property="annotateType" jdbcType="CHAR"/>
<result column="labels" property="labels" jdbcType="VARCHAR"/>
<result column="is_annotation_team" property="isStartTeam" jdbcType="CHAR"/>
<result column="annotation_status" property="annotateTaskStatus" jdbcType="CHAR"/>
<result column="del_flag" property="delFlag" jdbcType="CHAR"/>
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- 根据任务ID更新标注任务 -->
<update id="updateAnnotationTaskById" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
UPDATE ai_annotation_task
SET dataset_id = #{datasetId},
task_name = #{taskName},
task_uuid = #{taskUuid},
description = #{taskDesc},
annotation_scene = #{annotateScene},
annotation_type = #{annotateType},
labels = #{labels},
is_annotation = #{isStartTeam},
annotation_status = #{annotateTaskStatus},
project_id = #{projectId},
del_flag = #{delFlag},
create_by = #{createBy},
create_time = #{createTime},
update_by = #{updateBy},
update_time = #{updateTime}
WHERE task_id = #{taskId}
</update>
<sql id="selectTaskDetailVo">
select distinct t.task_id, t.task_uuid, t.task_name, t.description, t.annotation_scene, t.annotation_type,
FROM ai_annotation_task t
left join ai_annotation_task_annotator_map a on t.task_id = a.task_id
</sql>
<!-- 根据任务ID删除标注任务 (逻辑删除) -->
<update id="deleteAnnotationTaskById" parameterType="long">
UPDATE ai_annotation_task
SET del_flag = '1'
WHERE task_id = #{taskId}
</update>
<!-- TODO 根据标注人id查询所有标注文件列表-->
<!-- 根据任务ID查询标注任务 -->
<select id="selectAnnotationTaskById" parameterType="long" resultType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
SELECT task_id AS taskId, dataset_id AS datasetId, task_name AS taskName, task_uuid AS taskUuid,
description AS taskDesc, annotation_scene AS annotateScene, annotation_type AS annotateType,
labels, is_annotation AS isStartTeam, annotation_status AS annotateTaskStatus,
project_id AS projectId, del_flag AS delFlag, create_by AS createBy, create_time AS createTime,
update_by AS updateBy, update_time AS updateTime
FROM ai_annotation_task
WHERE task_id = #{taskId} AND del_flag = '0'
</select>
<!-- TODO 根据审核人id查询所有需要审核文件列表-->
<!-- 查询标注任务列表 -->
<select id="selectAnnotationTaskList" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity" resultType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
SELECT task_id AS taskId, dataset_id AS datasetId, task_name AS taskName, task_uuid AS taskUuid,
description AS taskDesc, annotation_scene AS annotateScene, annotation_type AS annotateType,
labels, is_annotation AS isStartTeam, annotation_status AS annotateTaskStatus,
project_id AS projectId, del_flag AS delFlag, create_by AS createBy, create_time AS createTime,
update_by AS updateBy, update_time AS updateTime
SELECT task_id , dataset_id , task_name , task_uuidd, description, annotation_scene, annotation_type ,
labels, is_annotation_team AS isStartTeam, annotation_status,
project_id, del_flag, create_by , create_time,
update_by , update_time
FROM ai_annotation_task
WHERE del_flag = '0'
<if test="datasetId != null">
@ -79,4 +58,74 @@
</if>
</select>
<!-- 插入标注任务 -->
<insert id="insertAnnotationTask" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
INSERT INTO ai_annotation_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="datasetId != null">dataset_id,</if>
<if test="taskName != null">task_name,</if>
<if test="taskUuid != null">task_uuid,</if>
<if test="taskDesc != null">description,</if>
<if test="annotateScene != null">annotation_scene,</if>
<if test="annotateType != null">annotation_type,</if>
<if test="labels != null">labels,</if>
<if test="isStartTeam != null">is_annotation_team,</if>
<if test="annotateTaskStatus != null">annotation_status,</if>
<if test="projectId != null">project_id,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if>
create_time,
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="datasetId != null">#{datasetId},</if>
<if test="taskName != null">#{taskName},</if>
<if test="taskUuid != null">#{taskUuid},</if>
<if test="taskDesc != null">#{taskDesc},</if>
<if test="annotateScene != null">#{annotateScene},</if>
<if test="annotateType != null">#{annotateType},</if>
<if test="labels != null">#{labels},</if>
<if test="isStartTeam != null">#{isStartTeam},</if>
<if test="annotateTaskStatus != null">#{annotateTaskStatus},</if>
<if test="projectId != null">#{projectId},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
sysdate(),
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<!-- 根据任务ID更新标注任务 -->
<update id="updateAnnotationTaskById" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
UPDATE ai_annotation_task
<set>
<if test="datasetId != null">dataset_id = #{datasetId},</if>
<if test="taskName != null">task_name = #{taskName},</if>
<if test="taskUuid != null">task_uuid = #{taskUuid},</if>
<if test="taskDesc != null">description = #{taskDesc},</if>
<if test="annotateScene != null">annotation_scene = #{annotateScene},</if>
<if test="annotateType != null">annotation_type = #{annotateType},</if>
<if test="labels != null">labels = #{labels},</if>
<if test="isStartTeam != null">is_annotation_team = #{isStartTeam},</if>
<if test="annotateTaskStatus != null">annotation_status = #{annotateTaskStatus},</if>
<if test="projectId != null">project_id = #{projectId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate(),
</set>
WHERE task_id = #{taskId}
</update>
<!-- 根据任务ID删除标注任务 (逻辑删除) -->
<update id="deleteAnnotationTaskById" parameterType="long">
UPDATE ai_annotation_task
SET del_flag = '1'
WHERE task_id = #{taskId}
</update>
</mapper>

View File

@ -12,7 +12,7 @@ create table ai_annotation_task
annotation_scene char(1) comment '标注场景(对应数据集的数据类型)',
annotation_type char(2) comment '标注类型(不同数据类型有不同的标注类型,如图片:图像分类,物体检测等)',
labels varchar(200) comment '允许的标签集',
is_annotation char(1) comment '标注团队id0未启用,1启用团队',
is_annotation_team char(1) comment '标注团队id0未启用,1启用团队',
annotation_status char(1) default '0' comment '0未标注1正在标注2已标注3正在审核4已审核',
del_flag char(1) default '0' comment '是否删除(0代表存在,1代表删除)',
create_by varchar(64) default '' comment '创建者',