Commit 648549147ac6116dc4691b5ff1dd52b1c932a40d

Authored by 潘钊
1 parent b72e7f53

修正跨24点查询的bug

src/main/java/com/bsth/server_rs/gps/dao/HistoryGpsDao.java
... ... @@ -5,6 +5,8 @@ import com.bsth.server_rs.base_info.car.Car;
5 5 import com.bsth.server_rs.base_info.car.buffer.CarBufferData;
6 6 import com.bsth.server_rs.gps.entity.HistoryGpsEntity;
7 7 import com.bsth.util.DBUtils_MS;
  8 +import org.joda.time.format.DateTimeFormat;
  9 +import org.joda.time.format.DateTimeFormatter;
8 10 import org.springframework.jdbc.core.BeanPropertyRowMapper;
9 11 import org.springframework.jdbc.core.JdbcTemplate;
10 12 import org.springframework.stereotype.Component;
... ... @@ -53,6 +55,7 @@ public class HistoryGpsDao {
53 55 return list;
54 56 }
55 57  
  58 + private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd");
56 59 private List<HistoryGpsEntity> query(String deviceId, Calendar sCal, Calendar eCal) {
57 60 int sDayOfYear = sCal.get(Calendar.DAY_OF_YEAR);
58 61 int eDayOfYear = eCal.get(Calendar.DAY_OF_YEAR);
... ... @@ -65,17 +68,17 @@ public class HistoryGpsDao {
65 68 list = query(sDayOfYear, st, et, deviceId);
66 69 } else {
67 70 // 跨天
68   - Long tempSt = 0L, tempEt = 0L;
  71 + Long tempSt, tempEt;
69 72 for (int i = sDayOfYear; i <= eDayOfYear; i++) {
70 73  
71 74 if (i == sDayOfYear) {
72 75 tempSt = st;
73   - tempEt = DateUtils.getTimesnight(sCal);
  76 + tempEt = fmtyyyyMMdd.parseMillis(fmtyyyyMMdd.print(tempSt)) + 1000 * 60 * 60 * 24;
74 77 } else if (i == eDayOfYear) {
75   - tempSt = DateUtils.getTimesmorning(sCal);
  78 + tempSt = fmtyyyyMMdd.parseMillis(fmtyyyyMMdd.print(et));
76 79 tempEt = et;
77 80 } else {
78   - tempSt = DateUtils.getTimesmorning(sCal);
  81 + tempSt = DateUtils.getTimesmorning(sCal) * 1000;
79 82 tempEt = DateUtils.getTimesnight(sCal);
80 83 }
81 84  
... ...