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

import com.viontech.keliu.entity.FaceDataContent;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
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.List;

@Repository
public class DFaceRecognitionDao {
    @Resource
    private NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    public final static String INSERT_FACE_RECOGNITION_SQL = "INSERT INTO d_face_recognition (device_id, channel_id, gate_id, person_unid,person_type, device_serialnum, channel_serialnum, face_pic, body_pic, mood, age, gender, direction, counttime, countdate, mall_id, account_id,status,track_info,track_time,happy_conf,unid,history_arrival_count,face_score,face_type,face_pic_num,body_pic_num ,face_feature_type ,body_feature_type,body_type,intersect_x,intersect_y,intersect_time,age_group,duration,event_image,event_coordinate,event_video,body_score,channel_product_id,focus,is_across,product_id,today_arrival_count) VALUES "
            + "(:deviceId, :channelId, :gateId, :personUnid, :personType ,:deviceSerialnum, :channelSerialnum, :facePic, :bodyPic, :mood, :age, :gender, :direction, :counttime, :countdate, :mallId, :accountId,:status,:trackInfo,:trackTime,:happyConf,:unid,:historyArrivalCount,:faceScore,:faceType,:facePicNum,:bodyPicNum,:faceFeatureType,:bodyFeatureType,:bodyType,:intersectX,:intersectY,:intersectTime,:ageGroup,:duration,:eventImage,:eventCoordinate,:eventVideo,:bodyScore,:channelProductId,:focus,:isAcross,:productId,:todayArrivalCount);";

    public void insert(FaceDataContent faceDataContent) {
        SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(faceDataContent);
        namedParameterJdbcTemplate.update(INSERT_FACE_RECOGNITION_SQL, parameterSource);
    }

    public void batchInsert(List<FaceDataContent> faceDataContents) {
        SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(faceDataContents.toArray());
        namedParameterJdbcTemplate.batchUpdate(INSERT_FACE_RECOGNITION_SQL, batch);
    }
}