Commit 72cea6fa by xmh

完善

1 parent 73c4f50b
package com.xmh.es.match.controller; package com.xmh.es.match.controller;
import com.xmh.es.match.entity.MatchResult;
import com.xmh.es.match.entity.vo.RequestData; import com.xmh.es.match.entity.vo.RequestData;
import com.xmh.es.match.repository.FaceRecognitionRepository;
import com.xmh.es.match.service.MatchService; import com.xmh.es.match.service.MatchService;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* . * .
...@@ -13,15 +18,20 @@ import javax.annotation.Resource; ...@@ -13,15 +18,20 @@ import javax.annotation.Resource;
* @author 谢明辉 * @author 谢明辉
* @date 2020/11/23 * @date 2020/11/23
*/ */
@RestController("/alg") @RestController
@RequestMapping("/alg")
public class MainController { public class MainController {
@Resource @Resource
private MatchService matchService; private MatchService matchService;
@Resource
private FaceRecognitionRepository faceRecognitionRepository;
@PostMapping("/match") @PostMapping("/match")
public Object match(RequestData requestData) throws Exception { public Object match(RequestData requestData) throws Exception {
return matchService.match(requestData); List<MatchResult> match = matchService.match(requestData);
List<String> collect = match.stream().map(MatchResult::getPersonId).collect(Collectors.toList());
return faceRecognitionRepository.queryFaceRecognitionByUnids(collect);
} }
} }
...@@ -62,6 +62,10 @@ public class FaceRecognition extends BaseModel { ...@@ -62,6 +62,10 @@ public class FaceRecognition extends BaseModel {
private Integer trackTime; private Integer trackTime;
private String facePath;
private String trackPath;
private Short happyConf; private Short happyConf;
/** 历史到店次数 */ /** 历史到店次数 */
private Short historyArrivalCount; private Short historyArrivalCount;
...@@ -348,4 +352,36 @@ public class FaceRecognition extends BaseModel { ...@@ -348,4 +352,36 @@ public class FaceRecognition extends BaseModel {
public void setBodyFeatureType(Short bodyFeatureType) { public void setBodyFeatureType(Short bodyFeatureType) {
this.bodyFeatureType = bodyFeatureType; this.bodyFeatureType = bodyFeatureType;
} }
private String getRootPath(String pathType) {
Date countdate = this.getCountdate();
if (countdate == null) {
return "获取轨迹根路径失败。【日期字段无法获取】";
}
String yyyyMMdd = DateUtil.format("yyyyMMdd", countdate);
String channelSerialnum = this.getChannelSerialnum();
if (channelSerialnum == null) {
return "获取轨迹根路径失败。【通道序列号字段无法获取】";
}
return pathType + "/" + yyyyMMdd + "/" + channelSerialnum + "/";
}
public String getFacePath() {
facePath = getRootPath("face");
return facePath;
}
public String getTrackPath() {
trackPath = getRootPath("track");
return trackPath;
}
public void setFacePath(String facePath) {
this.facePath = facePath;
}
public void setTrackPath(String trackPath) {
this.trackPath = trackPath;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -3,11 +3,14 @@ package com.xmh.es.match.repository; ...@@ -3,11 +3,14 @@ package com.xmh.es.match.repository;
import com.xmh.es.match.entity.FaceRecognition; import com.xmh.es.match.entity.FaceRecognition;
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.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* . * .
...@@ -18,14 +21,24 @@ import java.util.List; ...@@ -18,14 +21,24 @@ import java.util.List;
@Repository @Repository
public class FaceRecognitionRepository { public class FaceRecognitionRepository {
private static final BeanPropertyRowMapper<FaceRecognition> FACE_RECOGNITION_ROW_MAPPER = new BeanPropertyRowMapper<>(FaceRecognition.class);
private static final String QUERY_FACE = "select * from d_face_recognition where countdate=? and mall_id=? and direction=1 and gender>-1 and face_score>0.7"; private static final String QUERY_FACE = "select * from d_face_recognition where countdate=? and mall_id=? and direction=1 and gender>-1 and face_score>0.7";
private static final String QUERY_FACE_BY_UNID = "select face_pic,id,channel_serialnum,device_serialnum,person_unid,unid,id,countdate,counttime,age,gender,direction,mall_id,account_id,gate_id,face_score,person_type from d_face_recognition where unid in (:unids)";
@Resource @Resource
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
public List<FaceRecognition> queryFaceRecognitions(Date date, Long mallId) { public List<FaceRecognition> queryFaceRecognitions(Date date, Long mallId) {
return jdbcTemplate.query(QUERY_FACE, new BeanPropertyRowMapper<>(FaceRecognition.class), date, mallId); return jdbcTemplate.query(QUERY_FACE, FACE_RECOGNITION_ROW_MAPPER, date, mallId);
} }
public List<FaceRecognition> queryFaceRecognitionByUnids(List<String> unidList) {
Map<String, List<String>> param = Collections.singletonMap("unids", unidList);
return namedParameterJdbcTemplate.query(QUERY_FACE_BY_UNID, param, FACE_RECOGNITION_ROW_MAPPER);
}
} }
...@@ -9,4 +9,6 @@ oss.config.accessKeyId=LTAI9WfUr3GDne4c ...@@ -9,4 +9,6 @@ oss.config.accessKeyId=LTAI9WfUr3GDne4c
oss.config.accessKeySecret=SDzMs26kNyiDIIRJIY2qUBxBOeUEZ8 oss.config.accessKeySecret=SDzMs26kNyiDIIRJIY2qUBxBOeUEZ8
oss.config.bucket=vion-retail oss.config.bucket=vion-retail
# ws # ws
ws.featureUrl=http://101.200.130.13:10000
\ No newline at end of file \ No newline at end of file
ws.featureUrl=http://101.200.130.13:10000
# other
server.port=12000
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!