Commit 5636ab80 by 朱海

[chg]增加筛选指定设备的数据

1 parent 24d95cf3
...@@ -56,7 +56,10 @@ public class KeliuController { ...@@ -56,7 +56,10 @@ public class KeliuController {
@GetMapping("/sendData") @GetMapping("/sendData")
public Object sendData(@RequestParam Date date, @RequestParam Long mallId, @RequestParam Long packId, @RequestParam(required = false) Long taskId, @RequestParam(required = false, defaultValue = "1") Integer needOutSide) { public Object sendData(@RequestParam Date date, @RequestParam Long mallId, @RequestParam Long packId, @RequestParam(required = false) Long taskId,
@RequestParam(required = false, defaultValue = "1") Integer needOutSide,
@RequestParam(required = false,value = "deviceSerialNum") String deviceSerialNum
) {
List<Future<JsonMessageUtil.JsonMessage>> responses = new LinkedList<>(); List<Future<JsonMessageUtil.JsonMessage>> responses = new LinkedList<>();
if (SEND_DATA) { if (SEND_DATA) {
return JsonMessageUtil.getErrorJsonMsg("有数据传输任务正在进行"); return JsonMessageUtil.getErrorJsonMsg("有数据传输任务正在进行");
...@@ -65,7 +68,7 @@ public class KeliuController { ...@@ -65,7 +68,7 @@ public class KeliuController {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(20, 20, 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>(10000), new ThreadPoolExecutor.CallerRunsPolicy()); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(20, 20, 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>(10000), new ThreadPoolExecutor.CallerRunsPolicy());
try { try {
AtomicLong count = new AtomicLong(); AtomicLong count = new AtomicLong();
List<FaceRecognition> faceRecognitions = keliuRepository.getFaceRecognitionsByDateAndMallId(date, mallId, needOutSide); List<FaceRecognition> faceRecognitions = keliuRepository.getFaceRecognitionsByDateAndMallId(date, mallId, needOutSide, deviceSerialNum);
System.out.println("上传数据量:" + faceRecognitions.size()); System.out.println("上传数据量:" + faceRecognitions.size());
for (FaceRecognition faceRecognition : faceRecognitions) { for (FaceRecognition faceRecognition : faceRecognitions) {
Future<JsonMessageUtil.JsonMessage> submit = threadPoolExecutor.submit(() -> { Future<JsonMessageUtil.JsonMessage> submit = threadPoolExecutor.submit(() -> {
......
package com.viontech.label.tool.keliu.repository; package com.viontech.label.tool.keliu.repository;
import com.viontech.label.tool.keliu.model.FaceRecognition; import com.viontech.label.tool.keliu.model.FaceRecognition;
import org.apache.commons.lang3.StringUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -23,13 +24,26 @@ public class KeliuRepository { ...@@ -23,13 +24,26 @@ public class KeliuRepository {
@Resource @Resource
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
public List<FaceRecognition> getFaceRecognitionsByDateAndMallId(Date date, Long mallId, Integer needOutSide) { public List<FaceRecognition> getFaceRecognitionsByDateAndMallId(Date date, Long mallId, Integer needOutSide, String deviceSerialNum) {
String sql = "select unid,person_unid,channel_serialnum,body_pic,countdate,counttime,direction,gate_id from d_face_recognition where countdate=? and mall_id=?";
//不需要横穿数据 //不需要横穿数据
if (needOutSide == 0) { if (needOutSide == 0) {
return jdbcTemplate.query("select unid,person_unid,channel_serialnum,body_pic,countdate,counttime,direction,gate_id from d_face_recognition where countdate=? and mall_id=? and direction != 0", new BeanPropertyRowMapper<>(FaceRecognition.class), date, mallId); sql = sql + " and direction != 0";
} else {
return jdbcTemplate.query("select unid,person_unid,channel_serialnum,body_pic,countdate,counttime,direction,gate_id from d_face_recognition where countdate=? and mall_id=?", new BeanPropertyRowMapper<>(FaceRecognition.class), date, mallId);
} }
if (StringUtils.isNotBlank(deviceSerialNum)) {
String[] devices = deviceSerialNum.split(",");
StringBuilder sb = new StringBuilder();
for (String device : devices) {
if (sb.length() > 0) {
sb.append(",");
}
sb.append("'");
sb.append(device);
sb.append("'");
}
sql = sql + " and device_serialnum in (" + sb.toString() + ")";
}
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FaceRecognition.class), date, mallId);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!