Commit 7d503500 by 朱海

[chg]发送数据增加数量过滤

1 parent 3ed5f823
...@@ -24,15 +24,18 @@ import java.io.BufferedReader; ...@@ -24,15 +24,18 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
/** /**
* . * .
...@@ -79,8 +82,15 @@ public class KeliuController { ...@@ -79,8 +82,15 @@ public class KeliuController {
try { try {
AtomicLong count = new AtomicLong(); AtomicLong count = new AtomicLong();
List<FaceRecognition> faceRecognitions = keliuRepository.getFaceRecognitionsByDateAndMallId(date, mallId, direction, deviceSerialNum, personType, channelSerialNum, startTime, endTime); List<FaceRecognition> faceRecognitions = keliuRepository.getFaceRecognitionsByDateAndMallId(date, mallId, direction, deviceSerialNum, personType, channelSerialNum, startTime, endTime);
log.info("上传数据量:" + faceRecognitions.size()); Map<String, List<FaceRecognition>> faceRecognitionMap = faceRecognitions.stream().collect(Collectors.groupingBy(FaceRecognition::getPersonUnid));
for (FaceRecognition faceRecognition : faceRecognitions) { List<FaceRecognition> faceRecognitionList = new ArrayList<>();
faceRecognitionMap.forEach((k, v) -> {
if (v.size() >= 8) {
faceRecognitionList.addAll(v);
}
});
log.info("上传数据量:" + faceRecognitionList.size());
for (FaceRecognition faceRecognition : faceRecognitionList) {
Future<JsonMessageUtil.JsonMessage> submit = threadPoolExecutor.submit(() -> { Future<JsonMessageUtil.JsonMessage> submit = threadPoolExecutor.submit(() -> {
try { try {
byte[] bodyPic = fileService.getFile(faceRecognition.getBodyPath()); byte[] bodyPic = fileService.getFile(faceRecognition.getBodyPath());
...@@ -88,7 +98,7 @@ public class KeliuController { ...@@ -88,7 +98,7 @@ public class KeliuController {
HttpEntity<MultiValueMap<String, Object>> requestEntity = getRequestEntity(faceRecognition, bodyPic, bodyFeature, packId, taskId); HttpEntity<MultiValueMap<String, Object>> requestEntity = getRequestEntity(faceRecognition, bodyPic, bodyFeature, packId, taskId);
ResponseEntity<JsonMessageUtil.JsonMessage> exchange = restTemplate.exchange(vionConfig.getTargetUrl(), HttpMethod.POST, requestEntity, JsonMessageUtil.JsonMessage.class); ResponseEntity<JsonMessageUtil.JsonMessage> exchange = restTemplate.exchange(vionConfig.getTargetUrl(), HttpMethod.POST, requestEntity, JsonMessageUtil.JsonMessage.class);
JsonMessageUtil.JsonMessage body = exchange.getBody(); JsonMessageUtil.JsonMessage body = exchange.getBody();
log.info("unid:{},msg:{},count:{}/{}", faceRecognition.getUnid(), body.getMsg(), count.incrementAndGet(), faceRecognitions.size()); log.info("unid:{},msg:{},count:{}/{}", faceRecognition.getUnid(), body.getMsg(), count.incrementAndGet(), faceRecognitionList.size());
return body; return body;
} catch (Exception e) { } catch (Exception e) {
log.info("", e); log.info("", e);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!