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