Commit 3b394d445b09597a22c3c0f74fe07e63ae6b7393
1 parent
480095ac
update...
Showing
3 changed files
with
10 additions
and
4 deletions
src/main/java/com/bsth/redis/OilRedisService.java
| 1 | package com.bsth.redis; | 1 | package com.bsth.redis; |
| 2 | 2 | ||
| 3 | +import com.bsth.Application; | ||
| 3 | import com.bsth.entity.OilInfo; | 4 | import com.bsth.entity.OilInfo; |
| 4 | import com.bsth.redis.util.RedisUtils; | 5 | import com.bsth.redis.util.RedisUtils; |
| 5 | import com.bsth.repository.OilInfoRepository; | 6 | import com.bsth.repository.OilInfoRepository; |
| @@ -18,6 +19,7 @@ import org.springframework.stereotype.Component; | @@ -18,6 +19,7 @@ import org.springframework.stereotype.Component; | ||
| 18 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 19 | 20 | ||
| 20 | import java.util.*; | 21 | import java.util.*; |
| 22 | +import java.util.concurrent.TimeUnit; | ||
| 21 | 23 | ||
| 22 | /** | 24 | /** |
| 23 | * 油量数据Redis缓存 | 25 | * 油量数据Redis缓存 |
| @@ -122,7 +124,7 @@ public class OilRedisService implements CommandLineRunner { | @@ -122,7 +124,7 @@ public class OilRedisService implements CommandLineRunner { | ||
| 122 | @Override | 124 | @Override |
| 123 | public void run(String... strings) throws Exception { | 125 | public void run(String... strings) throws Exception { |
| 124 | //定时刷新油耗信息 | 126 | //定时刷新油耗信息 |
| 125 | - //Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 40, 60 * 40, TimeUnit.SECONDS); | 127 | + Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 40, 60 * 40, TimeUnit.SECONDS); |
| 126 | } | 128 | } |
| 127 | 129 | ||
| 128 | /** | 130 | /** |
src/main/java/com/bsth/redis/PlanScheduleRedisService.java
| 1 | package com.bsth.redis; | 1 | package com.bsth.redis; |
| 2 | 2 | ||
| 3 | +import com.bsth.Application; | ||
| 3 | import com.bsth.entity.SchedulePlanInfo; | 4 | import com.bsth.entity.SchedulePlanInfo; |
| 5 | +import com.bsth.redis.util.DateUtils; | ||
| 4 | import com.bsth.redis.util.RedisUtils; | 6 | import com.bsth.redis.util.RedisUtils; |
| 5 | import com.bsth.repository.SchedulePlanInfoRepository; | 7 | import com.bsth.repository.SchedulePlanInfoRepository; |
| 6 | import com.bsth.server_rs.base_info.line.Line; | 8 | import com.bsth.server_rs.base_info.line.Line; |
| @@ -16,6 +18,7 @@ import org.springframework.boot.CommandLineRunner; | @@ -16,6 +18,7 @@ import org.springframework.boot.CommandLineRunner; | ||
| 16 | import org.springframework.core.annotation.Order; | 18 | import org.springframework.core.annotation.Order; |
| 17 | import org.springframework.data.redis.core.ListOperations; | 19 | import org.springframework.data.redis.core.ListOperations; |
| 18 | import org.springframework.data.redis.core.RedisTemplate; | 20 | import org.springframework.data.redis.core.RedisTemplate; |
| 21 | +import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
| 19 | import org.springframework.stereotype.Component; | 22 | import org.springframework.stereotype.Component; |
| 20 | import org.springframework.stereotype.Service; | 23 | import org.springframework.stereotype.Service; |
| 21 | 24 | ||
| @@ -23,6 +26,7 @@ import java.util.ArrayList; | @@ -23,6 +26,7 @@ import java.util.ArrayList; | ||
| 23 | import java.util.Date; | 26 | import java.util.Date; |
| 24 | import java.util.Iterator; | 27 | import java.util.Iterator; |
| 25 | import java.util.List; | 28 | import java.util.List; |
| 29 | +import java.util.concurrent.TimeUnit; | ||
| 26 | 30 | ||
| 27 | /** | 31 | /** |
| 28 | * 计调的 计划排班redis缓存 | 32 | * 计调的 计划排班redis缓存 |
| @@ -120,7 +124,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | @@ -120,7 +124,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | ||
| 120 | 124 | ||
| 121 | @Override | 125 | @Override |
| 122 | public void run(String... strings) throws Exception { | 126 | public void run(String... strings) throws Exception { |
| 123 | - /*int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | 127 | + int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); |
| 124 | //设置key 序列化器 | 128 | //设置key 序列化器 |
| 125 | redisTemplate.setKeySerializer(new StringRedisSerializer()); | 129 | redisTemplate.setKeySerializer(new StringRedisSerializer()); |
| 126 | 130 | ||
| @@ -135,7 +139,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | @@ -135,7 +139,7 @@ public class PlanScheduleRedisService implements CommandLineRunner { | ||
| 135 | long diff = (DateUtils.getTimestamp() + 1000 * 60 * 5) - System.currentTimeMillis(); | 139 | long diff = (DateUtils.getTimestamp() + 1000 * 60 * 5) - System.currentTimeMillis(); |
| 136 | if (diff < 0) | 140 | if (diff < 0) |
| 137 | diff += (1000 * 60 * 60 * 24); | 141 | diff += (1000 * 60 * 60 * 24); |
| 138 | - Application.mainServices.scheduleAtFixedRate(planClearThread, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS);*/ | 142 | + Application.mainServices.scheduleAtFixedRate(planClearThread, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); |
| 139 | } | 143 | } |
| 140 | 144 | ||
| 141 | public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { | 145 | public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { |
src/main/resources/application.properties
| @@ -15,4 +15,4 @@ server.compression.enabled=true | @@ -15,4 +15,4 @@ server.compression.enabled=true | ||
| 15 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript | 15 | server.compression.mime-types=application/json,application/xml,text/html,text/xml,text/plain,text/javascript,text/css,application/javascript |
| 16 | 16 | ||
| 17 | #redis »º´æ¶àÉÙÌìµÄÊý¾Ý | 17 | #redis »º´æ¶àÉÙÌìµÄÊý¾Ý |
| 18 | -cache.days=40 | 18 | +cache.days=32 |