Commit 5cc0a0c813bb102ccd05e6e56181cc80313fff59
1 parent
7d287e1b
fix: 删除dateFormat注解
Showing
5 changed files
with
29 additions
and
17 deletions
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
| @@ -102,12 +102,12 @@ public class DriverServiceImpl implements IDriverService { | @@ -102,12 +102,12 @@ public class DriverServiceImpl implements IDriverService { | ||
| 102 | 102 | ||
| 103 | @Override | 103 | @Override |
| 104 | public AjaxResult getDriverSchedulingInfo(String schedulingDate, String jobCode) { | 104 | public AjaxResult getDriverSchedulingInfo(String schedulingDate, String jobCode) { |
| 105 | -// String key = DRIVER_SCHEDULING_PRE + schedulingDate; | ||
| 106 | -// List<ResponseScheduling> cacheMapValue = redisCache.getCacheMapValue(key , jobCode); | ||
| 107 | -// // 优先从缓存中读取 | ||
| 108 | -// if (cacheMapValue != null && cacheMapValue.size() > 0) { | ||
| 109 | -// return AjaxResult.success(cacheMapValue); | ||
| 110 | -// } | 105 | + String key = DRIVER_SCHEDULING_PRE + schedulingDate; |
| 106 | + List<ResponseScheduling> cacheMapValue = redisCache.getCacheMapValue(key , jobCode); | ||
| 107 | + // 优先从缓存中读取 | ||
| 108 | + if (cacheMapValue != null && cacheMapValue.size() > 0) { | ||
| 109 | + return AjaxResult.success(cacheMapValue); | ||
| 110 | + } | ||
| 111 | // 数据库中读取所有接收到的排班信息 | 111 | // 数据库中读取所有接收到的排班信息 |
| 112 | List<ResponseScheduling> responseSchedulings = driverMapper.getDriverSchedulingList(schedulingDate, jobCode); | 112 | List<ResponseScheduling> responseSchedulings = driverMapper.getDriverSchedulingList(schedulingDate, jobCode); |
| 113 | // 缓存中读取当天的排班信息 | 113 | // 缓存中读取当天的排班信息 |
| @@ -125,7 +125,8 @@ public class DriverServiceImpl implements IDriverService { | @@ -125,7 +125,8 @@ public class DriverServiceImpl implements IDriverService { | ||
| 125 | 125 | ||
| 126 | @Override | 126 | @Override |
| 127 | public AjaxResult getDriverSchedulingAll() { | 127 | public AjaxResult getDriverSchedulingAll() { |
| 128 | - Set yyyyMMdd = redisCache.redisTemplate.opsForHash().keys(DateUtils.getDate("yyyyMMdd")); | ||
| 129 | - return AjaxResult.success(yyyyMMdd); | 128 | +// Set yyyyMMdd = redisCache.redisTemplate.opsForHash().keys(DateUtils.getDate("yyyyMMdd")); |
| 129 | +// return AjaxResult.success(yyyyMMdd); | ||
| 130 | + return AjaxResult.success(); | ||
| 130 | } | 131 | } |
| 131 | } | 132 | } |
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
| @@ -5,6 +5,7 @@ import com.ruoyi.common.utils.DateUtils; | @@ -5,6 +5,7 @@ import com.ruoyi.common.utils.DateUtils; | ||
| 5 | import com.ruoyi.driver.domain.Driver; | 5 | import com.ruoyi.driver.domain.Driver; |
| 6 | import com.ruoyi.driver.service.IDriverService; | 6 | import com.ruoyi.driver.service.IDriverService; |
| 7 | import com.ruoyi.pojo.response.ResponseScheduling; | 7 | import com.ruoyi.pojo.response.ResponseScheduling; |
| 8 | +import com.ruoyi.utils.ConstDateUtil; | ||
| 8 | import com.ruoyi.utils.ListUtils; | 9 | import com.ruoyi.utils.ListUtils; |
| 9 | import org.apache.commons.math3.distribution.RealDistribution; | 10 | import org.apache.commons.math3.distribution.RealDistribution; |
| 10 | import org.springframework.beans.factory.InitializingBean; | 11 | import org.springframework.beans.factory.InitializingBean; |
| @@ -73,7 +74,7 @@ public class DriverJob implements InitializingBean { | @@ -73,7 +74,7 @@ public class DriverJob implements InitializingBean { | ||
| 73 | // 获取驾驶员信息 | 74 | // 获取驾驶员信息 |
| 74 | List<Driver> drivers = getDrivers(getDriverInfoUrl, String.valueOf(timestamp)); | 75 | List<Driver> drivers = getDrivers(getDriverInfoUrl, String.valueOf(timestamp)); |
| 75 | // 格式化请求 | 76 | // 格式化请求 |
| 76 | - String getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", DateUtils.getDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); | 77 | + String getSchedulingInfoUrl = String.format(GET_SCHEDULING_INFO_URL, "99", ConstDateUtil.formatDate("yyyyMMdd"), timestamp, NONCE, PASSWORD, getSHA1(getStringStringMap(String.valueOf(timestamp)))); |
| 77 | // 获取排班信息并存入redis | 78 | // 获取排班信息并存入redis |
| 78 | saveSchedulingToRedis(getSchedulingInfoUrl, drivers); | 79 | saveSchedulingToRedis(getSchedulingInfoUrl, drivers); |
| 79 | // 分片插入 | 80 | // 分片插入 |
| @@ -115,7 +116,7 @@ public class DriverJob implements InitializingBean { | @@ -115,7 +116,7 @@ public class DriverJob implements InitializingBean { | ||
| 115 | // 存入数据库 | 116 | // 存入数据库 |
| 116 | DRIVER_SERVICE.saveDriverScheduling(driverSchedulingMap); | 117 | DRIVER_SERVICE.saveDriverScheduling(driverSchedulingMap); |
| 117 | // 存入redis | 118 | // 存入redis |
| 118 | - REDIS_CACHE.setCacheMap(DRIVER_SCHEDULING_PRE + DateUtils.getDate("yyyyMMdd"), driverSchedulingMap, 1, TimeUnit.DAYS); | 119 | + REDIS_CACHE.setCacheMap(DRIVER_SCHEDULING_PRE + ConstDateUtil.formatDate("yyyyMMdd"), driverSchedulingMap, 1, TimeUnit.DAYS); |
| 119 | } | 120 | } |
| 120 | 121 | ||
| 121 | private static List<Driver> getDrivers(String format, String timestamp) throws Exception { | 122 | private static List<Driver> getDrivers(String format, String timestamp) throws Exception { |
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ResponseScheduling.java
| 1 | package com.ruoyi.pojo.response; | 1 | package com.ruoyi.pojo.response; |
| 2 | 2 | ||
| 3 | -import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | import lombok.Data; | 3 | import lombok.Data; |
| 5 | import org.springframework.format.annotation.DateTimeFormat; | 4 | import org.springframework.format.annotation.DateTimeFormat; |
| 6 | 5 | ||
| @@ -17,8 +16,7 @@ import java.util.List; | @@ -17,8 +16,7 @@ import java.util.List; | ||
| 17 | public class ResponseScheduling { | 16 | public class ResponseScheduling { |
| 18 | 17 | ||
| 19 | private Long id; | 18 | private Long id; |
| 20 | - @DateTimeFormat(pattern = "yyyy-MM-dd hh:mm:ss") | ||
| 21 | - @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss",timezone = "GMT+8") | 19 | + @DateTimeFormat(pattern = "yyyy-MM-dd") |
| 22 | private Date scheduleDate; | 20 | private Date scheduleDate; |
| 23 | private String lineName; | 21 | private String lineName; |
| 24 | private String lineCode; | 22 | private String lineCode; |
ruoyi-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
0 → 100644
| 1 | +package com.ruoyi.utils; | ||
| 2 | + | ||
| 3 | +import java.text.SimpleDateFormat; | ||
| 4 | +import java.util.Date; | ||
| 5 | + | ||
| 6 | +public class ConstDateUtil { | ||
| 7 | + public static String formatDate(String str){ | ||
| 8 | + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str); | ||
| 9 | + return simpleDateFormat.format(new Date()); | ||
| 10 | + } | ||
| 11 | + | ||
| 12 | + public static void main(String[] args) { | ||
| 13 | + String formatDate = formatDate("yyyyMMdd"); | ||
| 14 | + System.out.println(formatDate); | ||
| 15 | + } | ||
| 16 | +} |
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
| @@ -53,10 +53,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils | @@ -53,10 +53,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils | ||
| 53 | return dateTimeNow(YYYY_MM_DD); | 53 | return dateTimeNow(YYYY_MM_DD); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | - public static String getDate(String format) | ||
| 57 | - { | ||
| 58 | - return dateTimeNow(format); | ||
| 59 | - } | ||
| 60 | 56 | ||
| 61 | public static final String getTime() | 57 | public static final String getTime() |
| 62 | { | 58 | { |