DGateMinuteCountDataDao.java
2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.viontech.keliu.dao;
import com.viontech.keliu.entity.GateCountData;
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 DGateMinuteCountDataDao {
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
public final static String INSERT_SQL = "INSERT INTO d_gate_minute_count_data(mall_id, account_id, gate_id, innum, outnum, outside_innum, outside_outnum, countdate, counttime, hour) VALUES (:mallId, :accountId, :gateId, :innum, :outnum, :outsideInnum, :outsideOutnum, :countdate, :counttime, :hour);";
public final static String UPDATE_SQL = "UPDATE d_gate_minute_count_data SET modify_time=now(),innum=:innum,outnum=:outnum,outside_innum=:outsideInnum,outside_outnum=:outsideOutnum where mall_id=:mallId and countdate=:countdate and gate_id=:gateId and counttime = :counttime;";
public void insert(GateCountData data) {
SqlParameterSource parameterSource = new BeanPropertySqlParameterSource(data);
namedParameterJdbcTemplate.update(INSERT_SQL, parameterSource);
}
public void batchInsert(List<GateCountData> dataList) {
SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(dataList.toArray());
namedParameterJdbcTemplate.batchUpdate(INSERT_SQL, batch);
}
public void update(GateCountData data) {
SqlParameterSource sqlParameterSource = new BeanPropertySqlParameterSource(data);
namedParameterJdbcTemplate.update(UPDATE_SQL, sqlParameterSource);
}
public void batchUpdate(List<GateCountData> dataList) {
SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(dataList.toArray());
namedParameterJdbcTemplate.batchUpdate(UPDATE_SQL, batch);
}
}