Commit c909ea4f by xmh

<fix> 修复结果排序改为分数降序

<feature> 添加分配图包到任务的接口
<fix> 调整阿里云数据库地址
1 parent 67b0423e
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>com.viontech.keliu</groupId> <groupId>com.viontech.keliu</groupId>
<artifactId>keliu-util</artifactId> <artifactId>keliu-util</artifactId>
<version>6.0.10-SNAPSHOT</version> <version>6.0.10</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -3,6 +3,7 @@ package com.viontech.label.platform.controller.web; ...@@ -3,6 +3,7 @@ package com.viontech.label.platform.controller.web;
import com.viontech.keliu.util.JsonMessageUtil; import com.viontech.keliu.util.JsonMessageUtil;
import com.viontech.label.platform.base.BaseExample; import com.viontech.label.platform.base.BaseExample;
import com.viontech.label.platform.controller.base.PackBaseController; import com.viontech.label.platform.controller.base.PackBaseController;
import com.viontech.label.platform.model.Pack;
import com.viontech.label.platform.model.PackExample; import com.viontech.label.platform.model.PackExample;
import com.viontech.label.platform.model.User; import com.viontech.label.platform.model.User;
import com.viontech.label.platform.model.entity.PackInfo; import com.viontech.label.platform.model.entity.PackInfo;
...@@ -11,9 +12,11 @@ import com.viontech.label.platform.vo.PackVo; ...@@ -11,9 +12,11 @@ import com.viontech.label.platform.vo.PackVo;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Controller @Controller
...@@ -45,4 +48,24 @@ public class PackController extends PackBaseController { ...@@ -45,4 +48,24 @@ public class PackController extends PackBaseController {
return JsonMessageUtil.getSuccessJsonMsg(info); return JsonMessageUtil.getSuccessJsonMsg(info);
} }
@GetMapping("/assignTo")
@ResponseBody
public JsonMessageUtil.JsonMessage assignTo(@RequestParam Long[] packIds, @RequestParam(required = false) Long taskId) {
PackExample packExample = new PackExample();
packExample.createCriteria().andIdIn(Arrays.asList(packIds));
if (taskId == null) {
// todo 取消分配
List<Pack> packs = packService.selectByExample(packExample);
for (Pack pack : packs) {
pack.setTaskId(null);
packService.updateByPrimaryKey(pack);
}
} else {
Pack pack = new Pack();
pack.setTaskId(taskId);
packService.updateByExampleSelective(pack, packExample);
}
return JsonMessageUtil.getSuccessJsonMsg();
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -483,7 +483,7 @@ public class ReidService { ...@@ -483,7 +483,7 @@ public class ReidService {
final Set<String> matchFilter = currentPerson == null ? Collections.emptySet() : getMatchFilter(currentPerson, packId); final Set<String> matchFilter = currentPerson == null ? Collections.emptySet() : getMatchFilter(currentPerson, packId);
Map<String, List<SubTask>> collect = subTasks.stream().sorted( Map<String, List<SubTask>> collect = subTasks.stream().sorted(
(o1, o2) -> { (o2, o1) -> {
String o1P = o1.getPersonUnid(); String o1P = o1.getPersonUnid();
String o2P = o2.getPersonUnid(); String o2P = o2.getPersonUnid();
Float o1s = personScoreMap.get(o1P); Float o1s = personScoreMap.get(o1P);
......
...@@ -3,9 +3,9 @@ server.port=12100 ...@@ -3,9 +3,9 @@ server.port=12100
#spring.datasource.url=jdbc:postgresql://36.112.68.214:5432/vion_label #spring.datasource.url=jdbc:postgresql://36.112.68.214:5432/vion_label
#spring.datasource.username=postgres #spring.datasource.username=postgres
#spring.datasource.password=vion #spring.datasource.password=vion
spring.datasource.url=jdbc:postgresql://pgm-2ze197c18ro6p1r1fo.pg.rds.aliyuncs.com:3433/vion-label spring.datasource.url=jdbc:postgresql://pgm-2ze3cjpyjgjw0bl5uo.pg.rds.aliyuncs.com:1921/vion-label
spring.datasource.username=vion spring.datasource.username=vion
spring.datasource.password=cdmqYwBq9uAdvLJb spring.datasource.password=jkou72j32m4K5d8k
# redis # redis
spring.redis.host=47.94.47.137 spring.redis.host=47.94.47.137
spring.redis.port=6379 spring.redis.port=6379
...@@ -16,5 +16,5 @@ logging.level.com.viontech.label.platform.mapper=error ...@@ -16,5 +16,5 @@ logging.level.com.viontech.label.platform.mapper=error
debug=false debug=false
# vion # vion
#vion.match-url=http://36.112.68.214:12000/alg #vion.match-url=http://36.112.68.214:12000/alg
#vion.match-url=http://101.201.36.180:12001/alg
vion.match-url=http://127.0.0.1:12000/alg
\ No newline at end of file \ No newline at end of file
vion.match-url=http://101.201.36.180:12001/alg
#vion.match-url=http://127.0.0.1:12000/alg
\ No newline at end of file \ No newline at end of file
package com.viontech.label.platform; package com.viontech.label.platform;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.viontech.keliu.model.*; import com.viontech.keliu.model.*;
import com.viontech.keliu.util.DateUtil; import com.viontech.keliu.util.DateUtil;
import com.viontech.keliu.websocket.AlgApiClient; import com.viontech.keliu.websocket.AlgApiClient;
import com.viontech.label.core.constant.Constants; import com.viontech.label.core.constant.Constants;
import com.viontech.label.core.constant.SubTaskStatus; import com.viontech.label.core.constant.SubTaskStatus;
import com.viontech.label.platform.model.Pic;
import com.viontech.label.platform.model.PicExample;
import com.viontech.label.platform.model.SubTask; import com.viontech.label.platform.model.SubTask;
import com.viontech.label.platform.model.SubTaskExample; import com.viontech.label.platform.model.SubTaskExample;
import com.viontech.label.platform.service.adapter.PicService; import com.viontech.label.platform.service.adapter.PicService;
...@@ -45,8 +44,8 @@ class LabelApplicationTests { ...@@ -45,8 +44,8 @@ class LabelApplicationTests {
@Test @Test
void contextLoads() throws Exception { void contextLoads() throws Exception {
Long[] picIdArr = new Long[]{2911L,2924L,3085L}; Long[] subTaskIds = new Long[]{634L};
Long packId = 1L; Long packId = 2L;
long size = 10L; long size = 10L;
Integer timeInterval = 60; Integer timeInterval = 60;
...@@ -56,8 +55,8 @@ class LabelApplicationTests { ...@@ -56,8 +55,8 @@ class LabelApplicationTests {
Date countTimeGTE = null; Date countTimeGTE = null;
Date countTimeLTE = null; Date countTimeLTE = null;
for (Long picId : picIdArr) { for (Long subtaskId : subTaskIds) {
SubTask subTask = subTaskService.selectByPrimaryKey(picId); SubTask subTask = subTaskService.selectByPrimaryKey(subtaskId);
PicVo pic = storageUtils.getPic(subTask.getPicId()); PicVo pic = storageUtils.getPic(subTask.getPicId());
if (pic == null) { if (pic == null) {
continue; continue;
...@@ -71,7 +70,7 @@ class LabelApplicationTests { ...@@ -71,7 +70,7 @@ class LabelApplicationTests {
countTimeLTE = countTimeLTE == null ? max : max.compareTo(countTimeLTE) > 0 ? max : countTimeLTE; countTimeLTE = countTimeLTE == null ? max : max.compareTo(countTimeLTE) > 0 ? max : countTimeLTE;
countTimeGTE = countTimeGTE == null ? min : min.compareTo(countTimeGTE) < 0 ? min : countTimeGTE; countTimeGTE = countTimeGTE == null ? min : min.compareTo(countTimeGTE) < 0 ? min : countTimeGTE;
} }
BodyFeature feature = getBodyFeature(pic.getId()); BodyFeature feature = getBodyFeature(subtaskId);
if (feature == null) { if (feature == null) {
continue; continue;
} }
...@@ -88,41 +87,72 @@ class LabelApplicationTests { ...@@ -88,41 +87,72 @@ class LabelApplicationTests {
Person person = new Person().setBodyFeatures(bodyFeatures).setCounttimeGTE(countTimeGTE).setCounttimeLTE(countTimeLTE); Person person = new Person().setBodyFeatures(bodyFeatures).setCounttimeGTE(countTimeGTE).setCounttimeLTE(countTimeLTE);
try { try {
HashMap<String, Object> options = new HashMap<>(2); HashMap<String, Object> options = new HashMap<>(2);
options.put("size", size + picIdArr.length); options.put("size", size + 1);
options.put("agg", true); options.put("agg", true);
CompletableFuture<AlgResult> future = matchClient.matchPerson(2, person, reidPoolName, Collections.emptyList(), options); CompletableFuture<AlgResult> future = matchClient.matchPerson(2, person, reidPoolName, Collections.emptyList(), options);
AlgResult result = future.get(); AlgResult result = future.get();
List<String> personUnidList = new ArrayList<>();
Map<String, Float> personScoreMap = new HashMap<>();
List<Person> matchBodies = result.getMatchBodies(); List<Person> matchBodies = result.getMatchBodies();
List<String> personUnidList = matchBodies.stream().filter(x -> x.getScore() > 60F).map(Person::getPersonId).filter(x -> !personUnidSet.contains(x)).collect(Collectors.toList()); for (Person match : matchBodies) {
String personId = match.getPersonId();
if (match.getScore() < 60F || personUnidSet.contains(personId)) {
continue;
}
personScoreMap.put(personId, match.getScore());
personUnidList.add(personId);
}
if (personUnidList.size() == 0) { if (personUnidList.size() == 0) {
System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); System.out.println("0000000000000000");
return;
} }
SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPersonUnidIn(personUnidList);
List<SubTask> subtasks = subTaskService.selectByExample(subTaskExample); SubTaskExample subTaskExample = new SubTaskExample();
subTaskExample.createCriteria().andPersonUnidIn(personUnidList).andPackIdEqualTo(packId);
List<SubTask> subTasks = subTaskService.selectByExample(subTaskExample);
Map<String, List<SubTask>> collect = subTasks.stream().sorted(
(o2,o1 ) -> {
String o1P = o1.getPersonUnid();
String o2P = o2.getPersonUnid();
Float o1s = personScoreMap.get(o1P);
Float o2s = personScoreMap.get(o2P);
if (o2s == null) {
return 1;
} else if (o1s != null) {
return o1s > o2s ? 1 : o1s.equals(o2s) ? 0 : -1;
} else {
return -1;
}
}
).collect(Collectors.groupingBy(SubTask::getPersonUnid, LinkedHashMap::new, Collectors.toList()));
HashMap<String, Map<String, List<SubTask>>> ret = new HashMap<>();
Map<String, List<SubTask>> hideMap = new LinkedHashMap<>();
Map<String, List<SubTask>> displayMap = new LinkedHashMap<>();
ret.put("hide", hideMap);
ret.put("display", displayMap);
Map<String, List<SubTask>> collect = subtasks.stream().collect(Collectors.groupingBy(SubTask::getPersonUnid, Collectors.toList()));
for (Map.Entry<String, List<SubTask>> entry : collect.entrySet()) { for (Map.Entry<String, List<SubTask>> entry : collect.entrySet()) {
SubTask pic = entry.getValue().get(0); SubTask pic = entry.getValue().get(0);
if (pic.getStatus() == SubTaskStatus.FINISH_LABELING.val && entry.getValue().size() > 3) { if (pic.getStatus() == SubTaskStatus.FINISH_LABELING.val && entry.getValue().size() > 3) {
entry.setValue(entry.getValue().subList(0, 3)); entry.setValue(entry.getValue().subList(0, 3));
} }
displayMap.put(entry.getKey(), entry.getValue());
} }
System.out.println(JSON.toJSONString(ret));
System.out.println(collect);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private BodyFeature getBodyFeature(Long picId) throws IOException { private BodyFeature getBodyFeature(Long subTaskId) throws IOException {
byte[] bytes = FileUtils.readFileToByteArray(new File("C:\\Users\\vion\\Desktop\\" + subTaskId + ".feature"));
byte[] bytes = FileUtils.readFileToByteArray(new File("C:\\Users\\vion\\Desktop\\" + picId + ".feature"));
Feature featureByPic = objectMapper.readValue(bytes, Feature.class); Feature featureByPic = objectMapper.readValue(bytes, Feature.class);
Pic pic = picService.selectByPrimaryKey(picId);
List<Data> datas = featureByPic.getDatas(); List<Data> datas = featureByPic.getDatas();
if (datas == null || datas.size() == 0) { if (datas == null || datas.size() == 0) {
return null; return null;
...@@ -132,7 +162,7 @@ class LabelApplicationTests { ...@@ -132,7 +162,7 @@ class LabelApplicationTests {
return null; return null;
} }
Double[] featureData = data.getData(); Double[] featureData = data.getData();
return new BodyFeature().setFeature(featureData).setBid(featureByPic.getFilename()).setCounttime(pic.getCreateTime()); return new BodyFeature().setFeature(featureData).setBid(featureByPic.getFilename());
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!