Commit 3dfe88b1 by xmh

重构初步完成

1 parent c26a8dbc
......@@ -14,7 +14,7 @@ public enum SubTaskStatus {
/** 完成标注 */
FINISH_LABELING(3),
/** 已回收 */
recycled(4);
recycled(-1);
public int val;
SubTaskStatus(int val) {
......
......@@ -147,7 +147,7 @@ public class ReidController {
*/
@GetMapping("/setPure")
public Object setPackPure(@RequestParam String personUnid, @RequestParam Long packId) {
reidService.setPackPure(personUnid, packId);
reidService.finishLabeling(personUnid, packId);
return JsonMessageUtil.getSuccessJsonMsg("success");
}
......@@ -199,6 +199,12 @@ public class ReidController {
return JsonMessageUtil.getSuccessJsonMsg("success");
}
@GetMapping("recovery")
public Object recovery(@RequestParam String personUnid, @RequestParam Long packId) throws Exception {
reidService.recovery(personUnid, packId);
return JsonMessageUtil.getSuccessJsonMsg("success");
}
@GetMapping("downloadLabeledPicAsZip")
public void downloadLabeledPicAsZip(@RequestParam Long packId, HttpServletResponse response) throws Exception {
File file = reidService.downloadLabeledPicAsZip(packId);
......
......@@ -56,16 +56,22 @@ public interface SubTaskMapper extends BaseMapper {
@Select("<script>" +
"select id,unid,create_time as createTime,pack_id as packId,pic_id as picId,task_id as taskId,person_unid as personUnid,status from d_sub_task where pack_id=#{packId} and person_unid in " +
"(select person_unid from d_sub_task where pack_id=#{packId}" +
" <if test = 'status != null'> and status=#{status}</if> group by person_unid " +
" <if test = 'status != null'> and status=#{status}</if> " +
" <if test = 'status == null'> and status != -1</if> " +
"group by person_unid " +
// " having count(*) > 1 " +
" order by person_unid <if test='offset != null'> offset #{offset} limit #{limit}</if>) " +
" order by person_unid </script>")
" order by person_unid " +
"<if test='offset != null'> offset #{offset} limit #{limit}</if>) " +
" order by person_unid " +
"</script>")
List<SubTask> getPeople(Long packId, Integer status, Long offset, Long limit);
@Select("<script>" +
"select count(*) from " +
"(select person_unid from d_sub_task where pack_id=#{packId}" +
" <if test = 'status != null'> and status=#{status}</if> group by person_unid " +
" <if test = 'status != null'> and status=#{status}</if> " +
" <if test = 'status == null'> and status != -1</if> " +
" group by person_unid " +
// " having count(*) > 1 " +
") as t " +
"</script>")
......@@ -73,7 +79,10 @@ public interface SubTaskMapper extends BaseMapper {
@Select("<script>" +
"select id,unid,create_time as createTime,pack_id as packId,pic_id as picId,task_id as taskId,person_unid as personUnid,status from d_sub_task where pack_id=#{packId} and person_unid=" +
"(select person_unid from d_sub_task where pack_id=#{packId} <if test = 'status != null'> and status=#{status}</if> and person_unid ${type} #{personUnid} group by person_unid " +
"(select person_unid from d_sub_task where pack_id=#{packId} " +
"<if test = 'status != null'> and status=#{status}</if>" +
" <if test = 'status == null'> and status != -1</if> " +
" and person_unid ${type} #{personUnid} group by person_unid " +
// " having count(*) > 1 " +
" order by person_unid ${sort} limit 1) order by id" +
"</script>")
......
......@@ -4,6 +4,7 @@ import cn.dev33.satoken.stp.StpUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.viontech.keliu.exception.ParameterExceptin;
import com.viontech.keliu.model.*;
import com.viontech.keliu.util.DateUtil;
import com.viontech.keliu.websocket.AlgApiClient;
......@@ -12,7 +13,10 @@ import com.viontech.label.core.constant.LogOperateType;
import com.viontech.label.core.constant.SubTaskStatus;
import com.viontech.label.platform.mapper.SubTaskMapper;
import com.viontech.label.platform.model.*;
import com.viontech.label.platform.service.adapter.*;
import com.viontech.label.platform.service.adapter.LogService;
import com.viontech.label.platform.service.adapter.PicService;
import com.viontech.label.platform.service.adapter.SubTaskService;
import com.viontech.label.platform.service.adapter.UserService;
import com.viontech.label.platform.utils.StorageUtils;
import com.viontech.label.platform.vo.PicVo;
import com.viontech.label.platform.vo.ReidUploadData;
......@@ -27,8 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.websocket.DeploymentException;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
......@@ -161,6 +167,8 @@ public class ReidService {
subTask.setPersonUnid(newPersonUnid);
if (!Objects.equals(newPersonUnid, currentPerson)) {
subTask.setStatus(SubTaskStatus.TO_BE_LABELED.val);
} else {
subTask.setStatus(SubTaskStatus.LABELING.val);
}
subTaskService.updateByExampleSelective(subTask, subTaskExample);
// 删除和更新特征池
......@@ -308,18 +316,26 @@ public class ReidService {
/**
* 标记人为纯净的(修改人对应的所有的图片状态)
*/
public void setPackPure(String personUnid, Long packId) {
public void finishLabeling(String personUnid, Long packId) {
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPersonUnidEqualTo(personUnid);
List<SubTask> subTasks = subTaskService.selectByExample(subTaskExample);
if (subTasks.size() > 0 && subTasks.get(0).getStatus().equals(SubTaskStatus.FINISH_LABELING.val)) {
throw new RuntimeException("已经是完成状态了!");
if (subTasks.size() == 0) {
return;
}
Set<Integer> status = subTasks.stream().map(SubTask::getStatus).collect(Collectors.toSet());
SubTask subTask = new SubTask();
subTask.setStatus(SubTaskStatus.FINISH_LABELING.val);
if (status.contains(SubTaskStatus.FINISH_LABELING.val)) {
if (status.size() == 1) {
throw new RuntimeException("已经是完成状态了!");
} else {
subTaskService.updateByExampleSelective(subTask, subTaskExample);
return;
}
}
subTask.setAnnotatorId(StpUtil.getLoginIdAsLong());
subTask.setAnnotateTime(new Date());
subTaskService.updateByExampleSelective(subTask, subTaskExample);
......@@ -485,6 +501,31 @@ public class ReidService {
return true;
}
/**
* 回收人员
*/
@Transactional(rollbackFor = Throwable.class)
public synchronized void recovery(String personUnid, Long packId) throws Exception {
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPackIdEqualTo(packId).andStatusEqualTo(SubTaskStatus.recycled.val);
List<SubTask> subTasks = subTaskService.selectByExample(subTaskExample);
SubTask subTask = new SubTask();
subTask.setStatus(SubTaskStatus.recycled.val);
if (subTasks.size() > 0) {
subTask.setPersonUnid(subTasks.get(0).getPersonUnid());
}
subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPersonUnidEqualTo(personUnid).andPackIdEqualTo(packId);
subTaskService.updateByExampleSelective(subTask, subTaskExample);
String poolName = Constants.getReidPoolName(packId);
matchClient.EASY_PERSON_API.deletePerson(poolName, Collections.singletonList(personUnid));
}
public void exitLabeling(String personUnid, Long packId) {
// 数据库更新状态
......@@ -494,7 +535,7 @@ public class ReidService {
subTaskExample.createCriteria().andPersonUnidEqualTo(personUnid).andPackIdEqualTo(packId);
List<SubTask> subTasks = subTaskService.selectByExample(subTaskExample);
if (subTasks.size() > 0 && subTasks.get(0).getStatus() == (SubTaskStatus.FINISH_LABELING.val)) {
if (subTasks.size() > 0 && subTasks.get(0).getStatus() != SubTaskStatus.LABELING.val) {
return;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!