DataCountDao.java 2.25 KB
package com.viontech.keliu.dao;

import com.viontech.keliu.entity.Person;
import com.viontech.keliu.vo.MallVo;
import com.viontech.keliu.vo.PersonVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: zhuhai
 * Date: 2022-10-31
 * Time: 20:59
 */
@Repository
public class DataCountDao {
    @Resource
    private JdbcTemplate jdbcTemplate;
    private static final Logger logger = LoggerFactory.getLogger(DataCountDao.class);
    private String SITE_SQL_PERSON_QUERY = "select person_unid,mall_id,person_type,min(counttime) as counttime,max(mood) as mood from d_face_recognition where countdate=? and direction=1 and account_id=? and gate_id in (select id from b_gate where is_mall_gate=1) \ngroup by mall_id,person_unid,person_type order by mall_id,counttime  ";
    private String SITE_SQL_MALL_QUERY = "select id,name from b_mall where account_id=? and status=1 order by id";

    private String SQL_QUERY_PERSON_BY_MALL_ID = "select person_unid as personUnid,mall_id as mallId,person_type as personType,min(counttime) as countTime,max(mood) as mood from d_face_recognition where countdate=? and direction=1 and mall_id=? and gate_id in (select id from b_gate where mall_id = ? and is_mall_gate=1) group by mall_id,person_unid,person_type order by mall_id,counttime";

    public List<PersonVo> get_person(Date countdate, Integer accountid) {
        return this.jdbcTemplate.query(this.SITE_SQL_PERSON_QUERY, new Object[]{countdate, accountid}, new BeanPropertyRowMapper(PersonVo.class));
    }

    public List<MallVo> get_malls(Integer accountid) {
        return this.jdbcTemplate.query(this.SITE_SQL_MALL_QUERY, new Object[]{accountid}, new BeanPropertyRowMapper(MallVo.class));
    }

    public List<Person> getPersonByMallId(Long mallId, Date countDate) {
        RowMapper<Person> rowMapper = new BeanPropertyRowMapper<>(Person.class);
        return jdbcTemplate.query(SQL_QUERY_PERSON_BY_MALL_ID, rowMapper, countDate, mallId, mallId);
    }
}