FaceRecognitionDao.java 2.28 KB
package com.viontech.keliu.dao;

import com.viontech.keliu.entity.Person;
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;


    public List<Person> queryGateFaceRecognitionList(Long mallId, Date countDate) {
        List<Long> gateIds = bGateDao.getMallInsideGateIds(mallId);
        if (CollectionUtils.isEmpty(gateIds)) {
            return null;
        }
        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 = :countDate 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("countDate", countDate);
        queryMap.put("gateIds", gateIds);
        return namedParameterJdbcTemplate.query(sql, queryMap, new BeanPropertyRowMapper<>(Person.class));
    }

    public List<Person> queryFaceRecognitionList(Long mallId, Date countDate) {
        String sql = "select account_id,mall_id,gate_id,person_unid,direction,countdate as countDate,person_type,age,gender," +
                "counttime as countTime from d_face_recognition where mall_id = ? and countdate = ? " +
                "and direction in(-1,1,6) order by person_unid asc, counttime asc;";

        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Person.class), mallId, countDate);
    }

}