DPersonTrackDetailDao.java 1.53 KB
package com.viontech.keliu.dao;

import com.viontech.keliu.entity.DPersonTrackDetail;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Repository;

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

/**
 * Created with IntelliJ IDEA.
 *
 * @author: zhuhai
 * Date: 2023-12-22
 * Time: 9:28
 */
@Repository
public class DPersonTrackDetailDao {

    @Resource
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Resource
    private JdbcTemplate jdbcTemplate;


    public void createDPersonTrackDetailBatch(List<DPersonTrackDetail> personTrackDetailList) {
        SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(personTrackDetailList.toArray());
        String sql = "insert into d_person_track_detail (mall_id,account_id,gate_id,count_date,person_unid,group_unid,arrive_time, leave_time, visit_duration, is_engage)" +
                " values(:mallId,:accountId,:gateId,:countDate,:personUnid,:groupUnid,:arriveTime,:leaveTime,:visitDuration,:isEngage)";
        namedParameterJdbcTemplate.batchUpdate(sql, batch);

    }

    public void deleteData(Long mallId, Date countDate) {
        String sql = "delete from d_person_track_detail where mall_id = ? and count_date = ?";
        jdbcTemplate.update(sql, mallId, countDate);
    }
}