ConsumeDataServiceImpl.java
1.47 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.bsth.service.impl;
import com.bsth.data.history.entity.StationConsumeTime;
import com.bsth.service.ConsumeDataService;
import com.bsth.util.db_utils.DBUtils_InfoPublish;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ConsumeDataServiceImpl implements ConsumeDataService {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Override
public List<StationConsumeTime> search(String rq, String lineCode, String st, String et, String nbbm) {
List<StationConsumeTime> list = null;
try {
rq = rq.replaceAll("-", "");
st = st + "00";
et = et + "00";
String sql = "select * from bsth_h_consume_time where rq=" + rq + " and line_code='" + lineCode + "' and time_str>='" + st + "' and time_str<='" + et + "' ";
if (StringUtils.isNotBlank(nbbm))
sql += " and nbbm like '%" + nbbm + "%'";
sql += " order by time_str";
JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_InfoPublish.getDataSource());
list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(StationConsumeTime.class));
} catch (Exception e) {
logger.error("", e);
}
return list;
}
}