Compare commits

...

2 Commits

Author SHA1 Message Date
weiweiw b570de32a6 增加满足条件的任务列表和任务报表数据 2024-11-26 19:03:55 +08:00
weiweiw fb4353ca7a 增加获取审核驳回原因的接口 2024-11-26 17:10:43 +08:00
9 changed files with 140 additions and 63 deletions

View File

@ -3,6 +3,7 @@ package com.bonus.ai.controller.dataset;
import com.bonus.ai.client.AnnotationParam;
import com.bonus.ai.domain.DataSetBasicFileEntity;
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskAnnotatorEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskEntity;
import com.bonus.ai.domain.dataset.DataSetEntity;
import com.bonus.ai.service.DataSetBasicFileService;
@ -115,14 +116,34 @@ public class AnnotationTaskController extends BaseController {
}
/**
* * 根据任务id返回由我审核任务的所有文件列表
* @return 返回数据集详情
*/
@GetMapping(value = "/getAuditFailReasonByTaskId/{taskId}/{fileId}")
public AjaxResult getAuditFailReasonByFileId(@PathVariable Long taskId, @PathVariable Long fileId) {
try {
String failReason = annotationTaskService.getAuditFailReasonByFileId(taskId, fileId);
if (failReason.isEmpty())
{
failReason= "";
}
return AjaxResult.success(failReason);
}catch (Exception e){
return AjaxResult.error("获取文件列表失败");
}
}
/**手工标注或审核
* @param subTask 标注文件的信息
* @return 返回影响的行数或错误信
*/
@PostMapping("/manualAnnotate")
public AjaxResult manualAnnotate(@Validated @RequestBody AnnotationSubTaskEntity subTask) {
return AjaxResult.success();
public AjaxResult manualAnnotate(@Validated @RequestBody AnnotationTaskAnnotatorEntity subTask) {
annotationTaskService.manualAnnotate(subTask);
return AjaxResult.success("手工标注保存成功");
}
/**智能标注,预留接口
@ -130,8 +151,9 @@ public class AnnotationTaskController extends BaseController {
* @return 返回影响的行数或错误信
*/
@PostMapping("/aiAnnotate")
public AjaxResult aiAnnotate(@Validated @RequestBody AnnotationSubTaskEntity subTask) {
public AjaxResult aiAnnotate(@Validated @RequestBody AnnotationTaskAnnotatorEntity subTask) {
annotationTaskService.aiAnnotate(subTask);
return AjaxResult.success();
}

View File

@ -0,0 +1,8 @@
package com.bonus.ai.domain.dataset;
public class AnnotationFileStatusCount {
private String annotationStatus;
private Long recordCount;
// Getters and Setters
}

View File

@ -13,9 +13,9 @@ public class AnnotationTaskAnnotatorEntity {
private Long taskId; // 任务ID
private Long fileId; // 文件ID
private String fileUrl; // 文件URL
private Long labelStudioTaskId; //label studio 里对应的任务id
private String description; // 描述
private String annotationStatus; // 标注状态
private Long labelStudioTaskId = 0L; //label studio 里对应的任务id
private String description = ""; // 描述
private String annotationStatus = "0"; // 标注状态
private String annotationResult; // 标注结果 (JSON串)
private String annotationResource; // 标注资源类型
private String delFlag; // 删除标记

View File

@ -52,8 +52,21 @@ public class AnnotationTaskEntity extends BaseEntity {
private List<AnnotationSubTaskEntity> subAnnotationTasks;
/**用于查询目的*/
/**根据任务id标注人id或审核人id 和文件标注状态返回满足条件的文件列表*/
private Long annotatorId= 0L;
private Long reviewerId = 0L;
private String fileAnnotationStatus;
/**根据任务id 和文件id 返回审核驳回的原因*/
private Long fileId = 0L;
/**任务查询数据*/
private String datasetName;
private String ownerName;
private int status0Count;
private int status1Count;
private int status2Count;
private int status3Count;
private int totalCount;
}

View File

@ -35,13 +35,6 @@ public interface AnnotationTaskMapper
*/
int deleteAnnotationTaskById(Long taskId);
/**
* 根据任务ID查询标注任务
* @param taskId 任务ID
* @return 标注任务实体
*/
// AnnotationTaskEntity selectAnnotationTaskById(Long taskId);
/**
* 查询标注任务列表
* @param annotationTask 查询条件
@ -64,6 +57,7 @@ public interface AnnotationTaskMapper
int deleteAnnotator(Long taskId);
List<DataSetBasicFileEntity>getTaskBasicFile(AnnotationTaskEntity annotationTask);
String getAuditFailReasonByFileId(Long taskId, Long fileId);
//这个接口不需要可以扩展selectAnnotationTaskList
// AnnotationTaskEntity selectAnnotationTaskListUUID(Long taskId);
}

View File

@ -156,28 +156,6 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
e.printStackTrace();
}
return status;
/*
//删除任务需要删除两个个表 对应两个个表删除状态修改成1
AnnotationTaskEntity task = new AnnotationTaskEntity();
task.setTaskId(taskId);
int status = 0;
try{
// //删除主表任务信息
// status = annotationTaskMapper.deleteTaskById(taskId);
// //删除团队成员表信息
// status = annotationTaskMapper.deleteAnnotator(taskId);
// //查询对应的label studio project id , 删除这个标注任务对应的label studio project
List<AnnotationTaskEntity> resultTask = annotationTaskMapper.selectAnnotationTaskList(task);
if (!resultTask.isEmpty()){
Long project = resultTask.get(0).getLabelStudioProjectId();
//删除对应的标注任务文件关联关系表信息
onlineAnnotationService.deleteProjectById(String.valueOf(project));
}
}catch (Exception e){
e.printStackTrace();
}
*/
}
/**
@ -188,19 +166,15 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
@Override
public AnnotationTaskEntity getTaskInfo(Long taskId) {
AnnotationTaskEntity task = new AnnotationTaskEntity();
task.setTaskId(taskId);
try {
AnnotationTaskEntity task = new AnnotationTaskEntity();
task.setTaskId(taskId);
//查询对应的label studio project id , 从label studio这个标注任务对应的label studio project
List<AnnotationTaskEntity> resultTasks = annotationTaskMapper.selectAnnotationTaskList(task);
if (!resultTasks.isEmpty()) {
Long project = resultTasks.get(0).getLabelStudioProjectId();
//删除对应的标注任务文件关联关系表信息
ProjectParam projectParam = onlineAnnotationService.getProjectById(String.valueOf(project));
AnnotationTaskEntity resultTask = resultTasks.get(0);
resultTask.setProjectParam(projectParam);
if (!resultTasks.isEmpty()) {
return resultTasks.get(0);
}
} catch (Exception e){
e.printStackTrace();
}
@ -209,18 +183,23 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
@Override
public List<DataSetBasicFileEntity> getMyAnnotaionTaskBasicFile(Long taskId, String annotationStatus){
Long userId = SecurityUtils.getUserId();
AnnotationTaskEntity task = new AnnotationTaskEntity();
task.setTaskId(taskId);
task.setAnnotatorId(userId);
Long intAnnotationStatus = Long.valueOf(annotationStatus);
if (intAnnotationStatus < 4 && intAnnotationStatus >= 0) {
try {
Long userId = SecurityUtils.getUserId();
AnnotationTaskEntity task = new AnnotationTaskEntity();
task.setTaskId(taskId);
task.setAnnotatorId(userId);
Long intAnnotationStatus = Long.valueOf(annotationStatus);
if (intAnnotationStatus < 4 && intAnnotationStatus >= 0) {
task.setFileAnnotationStatus(annotationStatus);
} else {
task.setFileAnnotationStatus("5");
}
task.setFileAnnotationStatus(annotationStatus);
} else {
task.setFileAnnotationStatus("5");
return annotationTaskMapper.getTaskBasicFile(task);
}catch(Exception e){
e.printStackTrace();
return new ArrayList<>();
}
task.setFileAnnotationStatus(annotationStatus);
return annotationTaskMapper.getTaskBasicFile(task);
}
@Override
@ -238,6 +217,18 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
}
return annotationTaskMapper.getTaskBasicFile(task);
}
@Override
public String getAuditFailReasonByFileId(Long taskId, Long fileId){
try {
return annotationTaskMapper.getAuditFailReasonByFileId(taskId, fileId);
}catch(Exception e){
e.printStackTrace();
return "";
}
}
/**
* 检查任务名称是否重复
* @param task
@ -253,7 +244,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
* 手工标注
*/
@Override
public void manualAnnotate(AnnotationSubTaskEntity subTask) {
public void manualAnnotate(AnnotationTaskAnnotatorEntity subTask) {
}
@ -261,7 +252,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
* AI标注
*/
@Override
public void aiAnnotate(AnnotationSubTaskEntity subTask) {
public void aiAnnotate(AnnotationTaskAnnotatorEntity subTask) {
}

View File

@ -2,6 +2,7 @@ package com.bonus.ai.service.dataset;
import com.bonus.ai.domain.DataSetBasicFileEntity;
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskAnnotatorEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskEntity;
import com.bonus.ai.domain.dataset.DataSetEntity;
import com.bonus.common.core.web.page.TableDataInfo;
@ -23,10 +24,10 @@ public interface AnnotationTaskService {
AnnotationTaskEntity getTaskInfo(Long taskId);
/**手工标注*/
void manualAnnotate(AnnotationSubTaskEntity subTask);
void manualAnnotate(AnnotationTaskAnnotatorEntity subTask);
/**AI自动标注*/
void aiAnnotate(AnnotationSubTaskEntity subTask);
void aiAnnotate(AnnotationTaskAnnotatorEntity subTask);
/**根据类型获取标注任务列表*/
List<AnnotationTaskEntity> getTaskList(AnnotationTaskEntity task);
@ -37,5 +38,7 @@ public interface AnnotationTaskService {
List<DataSetBasicFileEntity> getMyAnnotaionTaskBasicFile(Long taskId,String annotationStatus);
List<DataSetBasicFileEntity> getMyAuditTaskBasicFile(Long taskId,String annotationStatus);
String getAuditFailReasonByFileId(Long taskId, Long fileId);
;
}

View File

@ -75,13 +75,20 @@
<!-- 我参与的任务 和我创建的 或所有的-->
<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 ,
SELECT ap.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
at.update_by , at.update_time, ad.dataset_name AS datasetName, su.user_name AS ownerName,
SUM(CASE WHEN ap.annotation_status = '0' THEN 1 ELSE 0 END) AS status0Count,
SUM(CASE WHEN ap.annotation_status = '1' THEN 1 ELSE 0 END) AS status1Count,
SUM(CASE WHEN ap.annotation_status = '2' THEN 1 ELSE 0 END) AS status2Count,
SUM(CASE WHEN ap.annotation_status = '3' THEN 1 ELSE 0 END) AS status3Count,
COUNT(*) AS totalCount
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'
LEFT join ai_dataset ad on ad.dataset_id = at.dataset_id
LEFT join sys_user su on su.user_id = at.create_by
WHERE at.del_flag = '0' and ap.annotation_status IN ('0', '1', '2','3')
<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})
@ -99,6 +106,7 @@
AND (at.create_by = #{createBy} or at.create_by = #{createBy})
</when>
</choose>
GROUP BY ap.task_id
</select>
@ -294,6 +302,44 @@
</if>
</select>
<select id="getAuditFailReasonByFileId" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskEntity" resultType="String">
SELECT
atap.audit_failed_reason
FROM ai_basic_file abf
LEFT JOIN ai_dataset_file_map adfm ON abf.file_id = adfm.file_id
LEFT JOIN ai_annotation_task aat ON aat.dataset_id= adfm.dataset_id
LEFT JOIN ai_annotation_task_annotator_map atap on atap.task_id = aat.task_id
where abf.del_flag = '0' and aat.del_flag = '0' and aat.task_id = #{taskId} and adfm.file_id = #{fileId}
</select>
<!-- 根据任务ID更新标注任务 -->
<update id="updateAnnotationInfo" parameterType="com.bonus.ai.domain.dataset.AnnotationTaskAnnotatorEntity">
UPDATE ai_annotation_task_annotator_map
<set>
<if test="annotation_result != null">annotation_result = #{annotationResult},</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="labelStudioProjectId != null">label_studio_project_id = #{labelStudioProjectId},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</set>
WHERE task_id = #{taskId}
</update>
<!-- resultMap="statusCountResultMap"-->
<select id="countStatusByTaskId" resultType="com.bonus.ai.domain.dataset.AnnotationFileStatusCount">
SELECT annotation_status, COUNT(*) AS record_count
FROM ai_annotation_task_annotator_map
WHERE task_id = #{taskId}
AND annotation_status IN ('0', '1', '2')
GROUP BY annotation_status
</select>
</mapper>

View File

@ -36,7 +36,7 @@ create table ai_annotation_task_annotator_map
file_url varchar(200) default '' comment '文件网络路径',
label_studio_task_id bigint(20) comment "label studio 对应的taskId"
description varchar(500) default '' comment '描述',
annotation_status char(1) comment '0未标注1已标注2已审核4 审核驳回',
annotation_status char(1) comment '0未标注1已标注2已审核3 审核驳回',
annotation_result text comment '标注结果(json串)',
annotation_resource char(1) comment '0人工标注1智能标注',
del_flag char(1) default '0' comment '是否删除(0代表存在,1代表删除)',