Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
95b6942b31
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.ai.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OnlineAnnotateUtil {
|
||||
/**
|
||||
* 替换 View 中的 Label 标签内容
|
||||
* @param template 原始字符串模板
|
||||
* @param labels 要替换的 labels 列表
|
||||
* @return 替换后的字符串
|
||||
*/
|
||||
public static String rectangleImageLabels(String template, List<String> labels) {
|
||||
if (labels == null || labels.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
// 构建新的 Label 标签内容
|
||||
StringBuilder labelBuilder = new StringBuilder();
|
||||
String[] colors = {"#FFA39E", "#D4380D", "#36CFC9", "#FF85C0", "#FFD666"}; // 颜色数组
|
||||
int colorIndex = 0;
|
||||
|
||||
for (String label : labels) {
|
||||
// 循环使用颜色
|
||||
String color = colors[colorIndex % colors.length];
|
||||
labelBuilder.append(" <Label value=\"")
|
||||
.append(label)
|
||||
.append("\" background=\"")
|
||||
.append(color)
|
||||
.append("\"/>\n");
|
||||
colorIndex++;
|
||||
}
|
||||
|
||||
// 替换模板中的内容
|
||||
return template.replaceAll(
|
||||
"<RectangleLabels name=\"label\" toName=\"image\">.*?</RectangleLabels>",
|
||||
"<RectangleLabels name=\"label\" toName=\"image\">\n" + labelBuilder + " </RectangleLabels>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class AnnotationTaskController extends BaseController {
|
|||
/**
|
||||
* 查看由我创建的任务列表和我参与的或全部任务列表
|
||||
* 统一获取文件列表
|
||||
* @param type 参数类型:myCreated - 由我创建的任务列表, myParticipated - 由我参与的任务列表, all - 用户创建和公共文件
|
||||
* @param type 参数类型:myCreated - 由我创建的任务列表, myParticipated - 分配给我的标注任务表, all - 用户创建和公共文件
|
||||
* @return 返回满足条件的任务列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
|
|
@ -61,6 +61,7 @@ public class AnnotationTaskController extends BaseController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据任务编号获取任务详情,如果是标注人员获取分配的文件列表,如果是审核人员获取所有分配的文件列表,如果是管理员获取所有文件列表
|
||||
* @param taskId 任务编号
|
||||
|
|
@ -92,4 +93,6 @@ public class AnnotationTaskController extends BaseController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; // 创建时间
|
||||
}
|
||||
|
|
@ -16,6 +16,8 @@ public class AnnotationTaskEntity extends BaseEntity {
|
|||
private Long datasetId;
|
||||
/**标注团队id,为0表示未启用标注团队,1启用标注团队*/
|
||||
private String isStartTeam;
|
||||
|
||||
private String taskUuid;
|
||||
/**任务名称*/
|
||||
private String taskName;
|
||||
/**任务描述*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.bonus.ai.service.Impl.dataset;
|
||||
|
||||
import com.bonus.ai.client.OnlineAnnotateUtil;
|
||||
import com.bonus.ai.client.OnlineAnnotationService;
|
||||
import com.bonus.ai.client.ProjectParam;
|
||||
import com.bonus.ai.client.TaskParam;
|
||||
import com.bonus.ai.config.MinioConfig;
|
||||
import com.bonus.ai.config.OnlineAnnotateConfig;
|
||||
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
|
||||
|
|
@ -28,6 +31,15 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
*/
|
||||
@Override
|
||||
public int createTask(AnnotationTaskEntity task) {
|
||||
// TODO 调用label studio 接口获取其project id
|
||||
ProjectParam lSProject = new ProjectParam();
|
||||
lSProject.setTitle(task.getTaskName());
|
||||
lSProject.setDescription(task.getTaskDesc());
|
||||
//需要将标签转换为json格式
|
||||
lSProject.setLabelConfig(task.getLabels());
|
||||
onlineAnnotationService.createProject(lSProject, onlineAnnotateConfig.getApikey());
|
||||
//TODO 根据标注任务file list 和标注人信息自动分配
|
||||
// 获取project id以后调用AnnotationTaskMapper 和AnnotationTaskAnnotatorMapper 插入数据集
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 '标注团队id(0未启用,1启用团队)',
|
||||
is_annotation_team char(1) comment '标注团队id(0未启用,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 '创建者',
|
||||
|
|
|
|||
Loading…
Reference in New Issue