FaceRecognitionDao.java
3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.viontech.keliu.dao;
import com.viontech.keliu.entity.DateTimeParam;
import com.viontech.keliu.entity.Person;
import com.viontech.keliu.service.DateTimeParamService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.boot.autoconfigure.batch.BatchProperties;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* Created with IntelliJ IDEA.
*
* @author: zhuhai
* Date: 2023-12-21
* Time: 16:54
*/
@Repository
public class FaceRecognitionDao {
@Resource
private JdbcTemplate jdbcTemplate;
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Resource
private BGateDao bGateDao;
@Resource
private DateTimeParamService dateTimeParamService;
public List<Person> queryGateFaceRecognitionList(Long mallId, Date countDate) {
List<Long> gateIds = bGateDao.getMallInsideGateIds(mallId);
if (CollectionUtils.isEmpty(gateIds)) {
return null;
}
DateTimeParam dateTimeParam = dateTimeParamService.getDateTimeParam(mallId, countDate);
String sql = "select account_id,mall_id,gate_id,person_unid,direction,countdate as countDate," +
"counttime as countTime from d_face_recognition " +
"where mall_id = :mallId and countdate between :startDate and :endDate and counttime >= :startTime and counttime < :endTime and gate_id in(:gateIds) " +
"and person_type = 0 and direction in(-1,1,6) order by person_unid asc,counttime asc;";
Map<String, Object> queryMap = new HashMap<>();
queryMap.put("mallId", mallId);
queryMap.put("startDate", dateTimeParam.getStartDate());
queryMap.put("endDate", dateTimeParam.getEndDate());
queryMap.put("startTime", dateTimeParam.getStartDateTime());
queryMap.put("endTime", dateTimeParam.getEndDateTime());
queryMap.put("gateIds", gateIds);
return namedParameterJdbcTemplate.query(sql, queryMap, new BeanPropertyRowMapper<>(Person.class));
}
public List<Person> queryFaceRecognitionList(Long mallId, Date countDate) {
DateTimeParam dateTimeParam = dateTimeParamService.getDateTimeParam(mallId, countDate);
String sql = "select account_id,mall_id,gate_id,person_unid,direction,track_time,countdate as countDate,person_type,age,gender," +
"counttime as countTime from d_face_recognition where mall_id = :mallId and countdate between :startDate and :endDate and counttime >= :startTime and counttime < :endTime " +
"and direction in(-1,1,6) and person_type = 0 order by person_unid asc, counttime asc;";
Map<String, Object> queryMap = new HashMap<>();
queryMap.put("mallId", mallId);
queryMap.put("startDate", dateTimeParam.getStartDate());
queryMap.put("endDate", dateTimeParam.getEndDate());
queryMap.put("startTime", dateTimeParam.getStartDateTime());
queryMap.put("endTime", dateTimeParam.getEndDateTime());
return namedParameterJdbcTemplate.query(sql, queryMap, new BeanPropertyRowMapper<>(Person.class));
}
}