标注任务接口
This commit is contained in:
parent
75dab1689b
commit
5609ffe2bd
|
|
@ -3,15 +3,18 @@ package com.bonus.ai.controller.dataset;
|
|||
import com.bonus.ai.client.AnnotationParam;
|
||||
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
|
||||
import com.bonus.ai.domain.dataset.AnnotationTaskEntity;
|
||||
import com.bonus.ai.domain.dataset.DataSetEntity;
|
||||
import com.bonus.ai.service.DataSetBasicFileService;
|
||||
import com.bonus.ai.service.dataset.AnnotationTaskService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bonus
|
||||
|
|
@ -58,12 +61,13 @@ public class AnnotationTaskController extends BaseController {
|
|||
/**
|
||||
* 查看由我创建的任务列表和我参与的或全部任务列表
|
||||
* 统一获取文件列表
|
||||
* @param type 参数类型:myCreated - 由我创建的任务列表, myParticipated - 分配给我的标注任务表, all - 用户创建和公共文件
|
||||
* @return 返回满足条件的任务列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public AjaxResult list(@RequestParam String type) {
|
||||
return AjaxResult.success();
|
||||
public TableDataInfo list(AnnotationTaskEntity task) {
|
||||
startPage();
|
||||
List<AnnotationTaskEntity> taskList = annotationTaskService.getTaskList(task);
|
||||
return getDataTable(taskList);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,4 +51,8 @@ public class AnnotationTaskEntity extends BaseEntity {
|
|||
/**分配后子任务,一个标注文件对应一个子任务*/
|
||||
private List<AnnotationSubTaskEntity> subAnnotationTasks;
|
||||
|
||||
/**用于查询目的*/
|
||||
private Long annotatorId= 0L;
|
||||
private Long reviewerId = 0L;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,14 @@ public interface AnnotationTaskMapper
|
|||
*/
|
||||
List<AnnotationTaskEntity> selectAnnotationTaskList(AnnotationTaskEntity annotationTask);
|
||||
|
||||
/**
|
||||
* 查询由我创建的 和 我参与的标注任务列表
|
||||
* @param annotationTask 查询条件
|
||||
* @return 标注任务列表
|
||||
*/
|
||||
List<AnnotationTaskEntity> selectMyAnnotationTaskList(AnnotationTaskEntity annotationTask);
|
||||
|
||||
|
||||
int insertAnnotTaskannotator(AnnotationTaskAnnotatorEntity annotationTaskAnnotatorEntities);
|
||||
|
||||
int deleteTaskById(Long taskId);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ import com.bonus.ai.mapper.DatasetFileMapper;
|
|||
import com.bonus.ai.service.dataset.AnnotationTaskService;
|
||||
import com.bonus.ai.utils.AverageUtil;
|
||||
import com.bonus.common.core.utils.SpringUtils;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
|
@ -33,7 +36,6 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
|
||||
@Resource
|
||||
OnlineAnnotationServiceOkHttp onlineAnnotationService;
|
||||
// OnlineAnnotationService onlineAnnotationService;
|
||||
|
||||
@Resource
|
||||
private OnlineAnnotateConfig onlineAnnotateConfig;
|
||||
|
|
@ -57,6 +59,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
|
||||
int status =0;
|
||||
//1.调用label studio 接口创建project,将projectid 关联到标注任务里
|
||||
/*
|
||||
ProjectInputParam lSProject= new ProjectInputParam();
|
||||
lSProject.setTitle(task.getTaskName());
|
||||
lSProject.setDescription(task.getTaskDesc());
|
||||
|
|
@ -74,7 +77,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
//2.插入标注任务表
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
task.setTaskUuid(uuid);
|
||||
|
|
@ -83,11 +86,10 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
AnnotationTaskEntity tempTask = new AnnotationTaskEntity();
|
||||
tempTask.setTaskUuid(uuid);
|
||||
List<AnnotationTaskEntity> tempTasks = annotationTaskMapper.selectAnnotationTaskList(task);
|
||||
Long annotationTaskid;
|
||||
|
||||
Long annotationTaskid = 0L;
|
||||
if (!tempTasks.isEmpty()){
|
||||
annotationTaskid = tempTasks.get(0).getTaskId();
|
||||
} else {
|
||||
annotationTaskid = 0L;
|
||||
}
|
||||
|
||||
//3. 根据标注任务创建标注人等信息,对任务里的文件进行分配
|
||||
|
|
@ -100,6 +102,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
//每个文件都需要创建label studio的 task id 与之唯一对应
|
||||
entity.setTaskId(annotationTaskid);
|
||||
}
|
||||
/*
|
||||
// 使用 CountDownLatch 来确保所有任务完成后才执行下一步操作
|
||||
CountDownLatch latch = new CountDownLatch(annotationTaskAnnotatorEntities.size());
|
||||
|
||||
|
|
@ -138,6 +141,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
Thread.currentThread().interrupt();
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
// 5. 将文件和标注人等信息 插入文件和标注人关联表
|
||||
if(status == 1){
|
||||
|
|
@ -158,8 +162,16 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
* 获取任务列表,分配给我的标注任务,我创建的标注任务
|
||||
*/
|
||||
@Override
|
||||
public DataSetEntity getTaskList(String type) {
|
||||
return null;
|
||||
public List<AnnotationTaskEntity> getTaskList(AnnotationTaskEntity task){
|
||||
try {
|
||||
//这样设置不合适,设置后会改变真实用户的意图
|
||||
// String userId = SecurityUtils.getUserId().toString();
|
||||
// task.setCreateBy(userId);
|
||||
return annotationTaskMapper.selectMyAnnotationTaskList(task);
|
||||
} catch (Exception e) {
|
||||
log.error("获取数据集列表失败", e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -172,12 +184,15 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
*/
|
||||
@Override
|
||||
public int updateTask(AnnotationTaskEntity task){
|
||||
|
||||
int result = annotationTaskMapper.updateAnnotationTaskById(task);
|
||||
if (result != 1){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
try {
|
||||
result = annotationTaskMapper.updateAnnotationTaskById(task);
|
||||
}catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
/*
|
||||
//防止labels信息发生变化,信息也同步更新到label studio studio 对应的project
|
||||
AnnotationTaskEntity newTask = new AnnotationTaskEntity();
|
||||
newTask.setTaskId(task.getTaskId());
|
||||
|
|
@ -198,10 +213,8 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//删除对应的标注任务文件关联关系表信息
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -212,6 +225,19 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteTaskById(Long taskId) {
|
||||
//删除任务需要删除两个个表 对应两个个表删除状态修改成1
|
||||
int status = 0;
|
||||
try{
|
||||
//删除主表任务信息
|
||||
status = annotationTaskMapper.deleteTaskById(taskId);
|
||||
//删除团队成员表信息
|
||||
status = annotationTaskMapper.deleteAnnotator(taskId);
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return status;
|
||||
/*
|
||||
//删除任务需要删除两个个表 对应两个个表删除状态修改成1
|
||||
AnnotationTaskEntity task = new AnnotationTaskEntity();
|
||||
task.setTaskId(taskId);
|
||||
|
|
@ -232,7 +258,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return status;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package com.bonus.ai.service.dataset;
|
|||
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
|
||||
import com.bonus.ai.domain.dataset.AnnotationTaskEntity;
|
||||
import com.bonus.ai.domain.dataset.DataSetEntity;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface AnnotationTaskService {
|
||||
/**创建标注任务*/
|
||||
|
|
@ -26,7 +28,7 @@ public interface AnnotationTaskService {
|
|||
void aiAnnotate(AnnotationSubTaskEntity subTask);
|
||||
|
||||
/**根据类型获取标注任务列表*/
|
||||
DataSetEntity getTaskList(String type);
|
||||
List<AnnotationTaskEntity> getTaskList(AnnotationTaskEntity task);
|
||||
|
||||
/**检查标注任务名唯一性*/
|
||||
boolean checkTaskNameUnique(AnnotationTaskEntity task);
|
||||
|
|
|
|||
|
|
@ -72,6 +72,59 @@
|
|||
AND annotation_status = #{annotateTaskStatus}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 我参与的任务 和我创建的 或所有的-->
|
||||
<select id="selectMyAnnotationTaskList" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity" resultMap="BaseResultMap">
|
||||
SELECT distinct at.task_id , at.dataset_id , at.task_name , at.task_uuid, at.description, at.annotation_scene, at.annotation_type ,
|
||||
at.labels, at.is_annotation_team AS isStartTeam, at.annotation_status,
|
||||
at.label_studio_project_id, at.del_flag, at.create_by , at.create_time,
|
||||
at.update_by , at.update_time
|
||||
FROM ai_annotation_task at
|
||||
left join ai_annotation_task_annotator_map ap on at.task_id = ap.task_id
|
||||
WHERE at.del_flag = '0'
|
||||
<choose>
|
||||
<when test="annotatorId != null and annotatorId != 0 and reviewerId != null and reviewerId != 0 and createBy != null and createBy != 0">
|
||||
AND (ap.annotator_id = #{annotatorId} or ap.reviewer_id = #{reviewerId} or at.create_by = #{createBy})
|
||||
</when>
|
||||
<when test="annotatorId != null and annotatorId != 0 and reviewerId != null and reviewerId != 0 ">
|
||||
AND (ap.annotator_id = #{annotatorId} or ap.reviewer_id = #{reviewerId})
|
||||
</when>
|
||||
<when test="reviewerId != null and reviewerId != 0 and createBy != null and createBy != 0">
|
||||
AND (ap.reviewer_id = #{reviewerId} or at.create_by = #{createBy})
|
||||
</when>
|
||||
<when test="annotatorId != null and annotatorId != 0 and createBy != null and createBy != 0">
|
||||
AND (ap.annotatorId = #{annotatorId} or at.create_by = #{createBy})
|
||||
</when>
|
||||
<when test="createBy != null and createBy != 0">
|
||||
AND (at.create_by = #{createBy} or at.create_by = #{createBy})
|
||||
</when>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <select id="getDatasetList" parameterType="com.bonus.ai.domain.dataset.DataSetEntity" resultMap="DatasetResult">-->
|
||||
<!-- <include refid="selectDatasetVo"/>-->
|
||||
<!-- <where>-->
|
||||
<!-- and ad.del_flag = '0'-->
|
||||
<!-- <if test="datasetName != null and datasetName != ''">-->
|
||||
<!-- AND ad.dataset_name like concat('%', #{datasetName}, '%')-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="dataType != null and dataType != ''">-->
|
||||
<!-- AND ad.data_type = #{dataType}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationStatus != null and annotationStatus != ''">-->
|
||||
<!-- AND ad.annotation_status = #{annotationStatus}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="isPublic != null and isPublic != ''">-->
|
||||
<!-- AND ad.is_public = #{isPublic}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="createBy != null and createBy != ''">-->
|
||||
<!-- AND ad.create_by = #{createBy}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- order by create_time desc-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <select id="selectAnnotationTaskListUUID" resultType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">-->
|
||||
<!-- SELECT label_studio_project_id, task_id, task_uuid FROM ai_annotation_task where del_flag = 0-->
|
||||
<!-- </select>-->
|
||||
|
|
@ -185,70 +238,6 @@
|
|||
<!-- </foreach>-->
|
||||
</insert>
|
||||
|
||||
<!-- <insert id="insertAnnotTaskannotator" parameterType="java.util.List">-->
|
||||
<!-- INSERT INTO ai_annotation_task_annotator_map-->
|
||||
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
|
||||
<!-- task_id-->
|
||||
<!-- <if test="fileId != null">-->
|
||||
<!-- , file_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="fileUrl != null">-->
|
||||
<!-- , file_url-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="labelStudioTaskId != null">-->
|
||||
<!-- , label_studio_task_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotatorId != null">-->
|
||||
<!-- , annotator_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="reviewerId != null">-->
|
||||
<!-- , reviewer_id-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="description != null and description != ''">-->
|
||||
<!-- , description-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationStatus != null">-->
|
||||
<!-- , annotation_status-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationResult != null">-->
|
||||
<!-- , annotation_result-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationResource != null">-->
|
||||
<!-- , annotation_resource-->
|
||||
<!-- </if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- <trim prefix="VALUES (" suffix=")" suffixOverrides=",">-->
|
||||
<!-- #{taskId}-->
|
||||
<!-- <if test="fileId != null">-->
|
||||
<!-- , #{fileId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="fileUrl != null">-->
|
||||
<!-- , #{fileUrl}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="labelStudioTaskId != null">-->
|
||||
<!-- , #{labelStudioTaskId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotatorId != null">-->
|
||||
<!-- , #{annotatorId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="reviewerId != null">-->
|
||||
<!-- , #{reviewerId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="description != null and description != ''">-->
|
||||
<!-- , #{description}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationStatus != null">-->
|
||||
<!-- , #{annotationStatus}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationResult != null">-->
|
||||
<!-- , #{annotationResult}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="annotationResource != null">-->
|
||||
<!-- , #{annotationResource}-->
|
||||
<!-- </if>-->
|
||||
<!-- </trim>-->
|
||||
<!-- </insert>-->
|
||||
|
||||
|
||||
<!-- 根据任务ID更新标注任务 -->
|
||||
<update id="updateAnnotationTaskById" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
|
||||
|
|
|
|||
Loading…
Reference in New Issue