增加根据taskid 返回已审核的标注结果和增加导出接口
This commit is contained in:
parent
52a2527f6b
commit
34fee494f6
|
|
@ -0,0 +1,59 @@
|
|||
package com.bonus.ai.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.bonus.ai.domain.DataSetBasicFileEntity;
|
||||
import com.bonus.ai.service.dataset.AnnotationTaskService;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/annotations")
|
||||
public class AnnotationExportController {
|
||||
|
||||
@Resource
|
||||
private AnnotationTaskService annotationTaskService;
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
@RequiresPermissions("dataCenter:task:annotation:export")
|
||||
@PostMapping("/export/{taskId}")
|
||||
public void exportAuditedAnnotations(HttpServletResponse response, HttpServletRequest request, @PathVariable Long taskId) {
|
||||
try {
|
||||
// Step 1: 获取标注结果
|
||||
List<DataSetBasicFileEntity> annotations = annotationTaskService.geAllAuditAnnotationByTaskId(taskId);
|
||||
|
||||
// Step 2: 按文件生成 JSON
|
||||
List<File> jsonFiles = new ArrayList<>();
|
||||
for (DataSetBasicFileEntity annotation : annotations) {
|
||||
String fileName = annotation.getFileName() + ".json";
|
||||
File jsonFile = createJsonFile(fileName, annotation);
|
||||
jsonFiles.add(jsonFile);
|
||||
}
|
||||
|
||||
// Step 3: 压缩为 ZIP
|
||||
|
||||
// Step 4: 设置响应头,提供文件下载
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public File createJsonFile(String fileName, Object data) throws IOException {
|
||||
File jsonFile = new File(fileName);
|
||||
objectMapper.writerWithDefaultPrettyPrinter().writeValue(jsonFile, data);
|
||||
return jsonFile;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package com.bonus.ai.domain.dataset;
|
||||
|
||||
public class AnnotationFileStatusCount {
|
||||
private String annotationStatus;
|
||||
private Long recordCount;
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
|
@ -334,5 +334,17 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
return annotationTaskMapper.getMyNoAuditTask(reviewerId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DataSetBasicFileEntity> geAllAuditAnnotationByTaskId(Long taskId){
|
||||
try {
|
||||
AnnotationTaskEntity task = new AnnotationTaskEntity();
|
||||
task.setTaskId(taskId);
|
||||
task.setFileAnnotationStatus("2");
|
||||
return annotationTaskMapper.getTaskBasicFile(task);
|
||||
}catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,5 +58,8 @@ public interface AnnotationTaskService {
|
|||
List<AnnotationTaskEntity> getMyNoAnnotationTask();
|
||||
/**获取由我审核的未完成审核的任务列表*/
|
||||
List<AnnotationTaskEntity> getMyNoAuditTask();
|
||||
|
||||
/**根据taskid获取所有已经审核的标注结果*/
|
||||
List<DataSetBasicFileEntity> geAllAuditAnnotationByTaskId(Long taskId);
|
||||
;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,13 +313,13 @@
|
|||
WHERE task_id = #{taskId} and file_id = #{fileId}
|
||||
</update>
|
||||
|
||||
<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>
|
||||
<!-- <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>-->
|
||||
|
||||
<select id="getMyNoAnnotationTask" parameterType="Long" resultType="com.bonus.ai.domain.dataset.AnnotationTaskEntity">
|
||||
SELECT distinct at.task_id AS taskId, at.task_name AS taskName, at.labels as labels
|
||||
|
|
|
|||
Loading…
Reference in New Issue