Commit e8f4c1c56aa2f2b434ce3d4a8905f64968928c43
1 parent
042807b1
1.凯道生产环境配置,去除多余接口
Showing
14 changed files
with
57 additions
and
1509 deletions
src/main/java/com/bsth/CXFConfig.java
| ... | ... | @@ -3,7 +3,6 @@ package com.bsth; |
| 3 | 3 | import com.bsth.server_rs.AuthorizeInterceptor_IN; |
| 4 | 4 | import com.bsth.server_rs.base_info.car.CarRestService; |
| 5 | 5 | import com.bsth.server_rs.base_info.line.LineRestService; |
| 6 | -import com.bsth.server_rs.base_info.person.PersonRestService; | |
| 7 | 6 | import com.bsth.server_rs.base_info.section.LD_RoadSpeedRestService; |
| 8 | 7 | import com.bsth.server_rs.base_info.section.LD_SectionRestService; |
| 9 | 8 | import com.bsth.server_rs.base_info.station.StationRestService; |
| ... | ... | @@ -48,7 +47,6 @@ public class CXFConfig { |
| 48 | 47 | endpoint.setServiceBeans(Arrays.<Object>asList( |
| 49 | 48 | new LineRestService(), |
| 50 | 49 | new CarRestService(), |
| 51 | - new PersonRestService(), | |
| 52 | 50 | stationRestService, |
| 53 | 51 | ldSectionRestService, |
| 54 | 52 | ld_roadSpeedRestService)); | ... | ... |
src/main/java/com/bsth/redis/ElecRedisService.java deleted
100644 → 0
| 1 | -package com.bsth.redis; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.entity.ElecInfo; | |
| 5 | -import com.bsth.redis.util.RedisUtils; | |
| 6 | -import com.bsth.repository.ElecInfoRepository; | |
| 7 | -import com.bsth.util.ConfigUtil; | |
| 8 | -import com.bsth.util.ConvertUtil; | |
| 9 | -import com.google.common.collect.ArrayListMultimap; | |
| 10 | -import org.joda.time.DateTime; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | -import org.springframework.boot.CommandLineRunner; | |
| 15 | -import org.springframework.core.annotation.Order; | |
| 16 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 17 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 18 | -import org.springframework.stereotype.Component; | |
| 19 | -import org.springframework.stereotype.Service; | |
| 20 | - | |
| 21 | -import java.util.*; | |
| 22 | -import java.util.concurrent.TimeUnit; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - * 油量数据Redis缓存 | |
| 26 | - * Created by panzhao on 2017/3/19. | |
| 27 | - */ | |
| 28 | -@Service | |
| 29 | -@Order(3) | |
| 30 | -public class ElecRedisService implements CommandLineRunner { | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - private RedisTemplate redisTemplate; | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - ElecInfoRepository elecInfoRepository; | |
| 37 | - | |
| 38 | - @Autowired | |
| 39 | - RedisUtils redisUtils; | |
| 40 | - | |
| 41 | - static Logger logger = LoggerFactory.getLogger(ElecRedisService.class); | |
| 42 | - | |
| 43 | - private final static String REDIS_KEY_PREFIX = "elec:"; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 将油量数据写入redis | |
| 47 | - * | |
| 48 | - * @param list | |
| 49 | - */ | |
| 50 | - public void wirte(List<ElecInfo> list) { | |
| 51 | - ArrayListMultimap<String, ElecInfo> multimap; | |
| 52 | - try { | |
| 53 | - if (list.size() == 0) | |
| 54 | - return; | |
| 55 | - //按日期和线路分组数据 | |
| 56 | - Class clazz = ElecInfo.class; | |
| 57 | - multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("rq")); | |
| 58 | - | |
| 59 | - //写入redis | |
| 60 | - Iterator<String> iterator = multimap.keySet().iterator(); | |
| 61 | - String key; | |
| 62 | - while (iterator.hasNext()) { | |
| 63 | - key = iterator.next(); | |
| 64 | - mergeData(key, multimap.get(key)); | |
| 65 | - } | |
| 66 | - } catch (Exception e) { | |
| 67 | - logger.error("", e); | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 73 | - * | |
| 74 | - * @param nbbmArray | |
| 75 | - * @param rq | |
| 76 | - * @return | |
| 77 | - */ | |
| 78 | - public Map<String, ElecInfo> findByNbbmGroup(Iterable<String> nbbmArray, String rq) { | |
| 79 | - Map<String, ElecInfo> rs = new HashMap<>(); | |
| 80 | - | |
| 81 | - rq = rq.replaceAll("-", ""); | |
| 82 | - try { | |
| 83 | - List<ElecInfo> list = new ArrayList<>(); | |
| 84 | - for (String nbbm : nbbmArray) { | |
| 85 | - nbbm = nbbm.split("_")[1]; | |
| 86 | - list.addAll(read(nbbm, rq)); | |
| 87 | - } | |
| 88 | - Class clazz = ElecInfo.class; | |
| 89 | - rs = new ConvertUtil().groupList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 90 | - } catch (Exception e) { | |
| 91 | - logger.error("", e); | |
| 92 | - } | |
| 93 | - return rs; | |
| 94 | - } | |
| 95 | - | |
| 96 | - public List<ElecInfo> read(String nbbm, String rq) { | |
| 97 | - return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + nbbm + ":" + rq, 0, -1); | |
| 98 | - } | |
| 99 | - | |
| 100 | - /** | |
| 101 | - * 将 list 与redis里的数据合并 | |
| 102 | - * | |
| 103 | - * @param key | |
| 104 | - * @param list | |
| 105 | - */ | |
| 106 | - public void mergeData(String key, List<ElecInfo> list) { | |
| 107 | - key = REDIS_KEY_PREFIX + key; | |
| 108 | - | |
| 109 | - //更新 直接覆盖更新 | |
| 110 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 111 | - } | |
| 112 | - | |
| 113 | - @Autowired | |
| 114 | - ElecRefreshThread elecRefreshThread; | |
| 115 | - | |
| 116 | - @Override | |
| 117 | - public void run(String... strings) throws Exception { | |
| 118 | - Application.mainServices.schedule(new Runnable() { | |
| 119 | - @Override | |
| 120 | - public void run() { | |
| 121 | - //启动加载油耗缓存 | |
| 122 | - synchData(null); | |
| 123 | - } | |
| 124 | - }, 30, TimeUnit.SECONDS); | |
| 125 | - | |
| 126 | - | |
| 127 | - //定时刷新油耗信息 | |
| 128 | - Application.mainServices.scheduleWithFixedDelay(elecRefreshThread, 60 * 40, 60 * 40, TimeUnit.SECONDS); | |
| 129 | - } | |
| 130 | - | |
| 131 | - /** | |
| 132 | - * 和数据库同步数据 | |
| 133 | - */ | |
| 134 | - public void synchData(Integer days) { | |
| 135 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 136 | - if (null != days && days < cacheDays) | |
| 137 | - cacheDays = days; | |
| 138 | - //设置key 序列化器 | |
| 139 | - redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 140 | - | |
| 141 | - DateTime dt = new DateTime(); | |
| 142 | - dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | |
| 143 | - List<ElecInfo> list = elecInfoRepository.findByDateLT(dt.toDate()); | |
| 144 | - //写入redis | |
| 145 | - wirte(list); | |
| 146 | - logger.info("刷新电耗数据, days: " + cacheDays + " -size: " + list.size() + " -LT: " + dt.toString("yyyy-MM-dd")); | |
| 147 | - } | |
| 148 | - | |
| 149 | - @Component | |
| 150 | - public static class ElecRefreshThread extends Thread { | |
| 151 | - | |
| 152 | - @Autowired | |
| 153 | - ElecRedisService elecRedisService; | |
| 154 | - | |
| 155 | - @Override | |
| 156 | - public void run() { | |
| 157 | - try { | |
| 158 | - elecRedisService.synchData(5); | |
| 159 | - } catch (Exception e) { | |
| 160 | - logger.error("", e); | |
| 161 | - } | |
| 162 | - } | |
| 163 | - } | |
| 164 | -} |
src/main/java/com/bsth/redis/OilRedisService.java deleted
100644 → 0
| 1 | -package com.bsth.redis; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.entity.OilInfo; | |
| 5 | -import com.bsth.redis.util.RedisUtils; | |
| 6 | -import com.bsth.repository.OilInfoRepository; | |
| 7 | -import com.bsth.util.ConfigUtil; | |
| 8 | -import com.bsth.util.ConvertUtil; | |
| 9 | -import com.google.common.collect.ArrayListMultimap; | |
| 10 | -import org.joda.time.DateTime; | |
| 11 | -import org.slf4j.Logger; | |
| 12 | -import org.slf4j.LoggerFactory; | |
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 14 | -import org.springframework.boot.CommandLineRunner; | |
| 15 | -import org.springframework.core.annotation.Order; | |
| 16 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 17 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 18 | -import org.springframework.stereotype.Component; | |
| 19 | -import org.springframework.stereotype.Service; | |
| 20 | - | |
| 21 | -import java.util.*; | |
| 22 | -import java.util.concurrent.TimeUnit; | |
| 23 | - | |
| 24 | -/** | |
| 25 | - * 油量数据Redis缓存 | |
| 26 | - * Created by panzhao on 2017/3/19. | |
| 27 | - */ | |
| 28 | -@Service | |
| 29 | -@Order(3) | |
| 30 | -public class OilRedisService implements CommandLineRunner { | |
| 31 | - | |
| 32 | - @Autowired | |
| 33 | - private RedisTemplate redisTemplate; | |
| 34 | - | |
| 35 | - @Autowired | |
| 36 | - OilInfoRepository oilInfoRepository; | |
| 37 | - | |
| 38 | - @Autowired | |
| 39 | - RedisUtils redisUtils; | |
| 40 | - | |
| 41 | - static Logger logger = LoggerFactory.getLogger(OilRedisService.class); | |
| 42 | - | |
| 43 | - private final static String REDIS_KEY_PREFIX = "oil:"; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * 将油量数据写入redis | |
| 47 | - * | |
| 48 | - * @param list | |
| 49 | - */ | |
| 50 | - public void wirte(List<OilInfo> list) { | |
| 51 | - ArrayListMultimap<String, OilInfo> multimap; | |
| 52 | - try { | |
| 53 | - if (list.size() == 0) | |
| 54 | - return; | |
| 55 | - //按日期和线路分组数据 | |
| 56 | - Class clazz = OilInfo.class; | |
| 57 | - multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("rq")); | |
| 58 | - | |
| 59 | - //写入redis | |
| 60 | - Iterator<String> iterator = multimap.keySet().iterator(); | |
| 61 | - String key; | |
| 62 | - while (iterator.hasNext()) { | |
| 63 | - key = iterator.next(); | |
| 64 | - mergeData(key, multimap.get(key)); | |
| 65 | - } | |
| 66 | - } catch (Exception e) { | |
| 67 | - logger.error("", e); | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 73 | - * | |
| 74 | - * @param nbbmArray | |
| 75 | - * @param rq | |
| 76 | - * @return | |
| 77 | - */ | |
| 78 | - public Map<String, OilInfo> findByNbbmGroup(Iterable<String> nbbmArray, String rq) { | |
| 79 | - Map<String, OilInfo> rs = new HashMap<>(); | |
| 80 | - | |
| 81 | - rq = rq.replaceAll("-", ""); | |
| 82 | - try { | |
| 83 | - List<OilInfo> list = new ArrayList<>(); | |
| 84 | - for (String nbbm : nbbmArray) { | |
| 85 | - nbbm = nbbm.split("_")[1]; | |
| 86 | - list.addAll(read(nbbm, rq)); | |
| 87 | - } | |
| 88 | - Class clazz = OilInfo.class; | |
| 89 | - rs = new ConvertUtil().groupList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 90 | - } catch (Exception e) { | |
| 91 | - logger.error("", e); | |
| 92 | - } | |
| 93 | - return rs; | |
| 94 | - } | |
| 95 | - | |
| 96 | - public List<OilInfo> read(String nbbm, String rq) { | |
| 97 | - return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + nbbm + ":" + rq, 0, -1); | |
| 98 | - } | |
| 99 | - | |
| 100 | - /** | |
| 101 | - * 将 list 与redis里的数据合并 | |
| 102 | - * | |
| 103 | - * @param key | |
| 104 | - * @param list | |
| 105 | - */ | |
| 106 | - public void mergeData(String key, List<OilInfo> list) { | |
| 107 | - key = REDIS_KEY_PREFIX + key; | |
| 108 | - | |
| 109 | - //更新 直接覆盖更新 | |
| 110 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 111 | - } | |
| 112 | - | |
| 113 | - @Autowired | |
| 114 | - OilRefreshThread oilRefreshThread; | |
| 115 | - | |
| 116 | - @Override | |
| 117 | - public void run(String... strings) throws Exception { | |
| 118 | - Application.mainServices.schedule(new Runnable() { | |
| 119 | - @Override | |
| 120 | - public void run() { | |
| 121 | - //启动加载油耗缓存 | |
| 122 | - synchData(null); | |
| 123 | - } | |
| 124 | - }, 30, TimeUnit.SECONDS); | |
| 125 | - | |
| 126 | - | |
| 127 | - //定时刷新油耗信息 | |
| 128 | - Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 60 * 40, 60 * 40, TimeUnit.SECONDS); | |
| 129 | - } | |
| 130 | - | |
| 131 | - /** | |
| 132 | - * 和数据库同步数据 | |
| 133 | - */ | |
| 134 | - public void synchData(Integer days) { | |
| 135 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 136 | - if (null != days && days < cacheDays) | |
| 137 | - cacheDays = days; | |
| 138 | - //设置key 序列化器 | |
| 139 | - redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 140 | - | |
| 141 | - DateTime dt = new DateTime(); | |
| 142 | - dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | |
| 143 | - List<OilInfo> list = oilInfoRepository.findByDateLT(dt.toDate()); | |
| 144 | - //写入redis | |
| 145 | - wirte(list); | |
| 146 | - logger.info("刷新油耗数据, days: " + cacheDays + " -size: " + list.size() + " -LT: " + dt.toString("yyyy-MM-dd")); | |
| 147 | - } | |
| 148 | - | |
| 149 | - @Component | |
| 150 | - public static class OilRefreshThread extends Thread { | |
| 151 | - | |
| 152 | - @Autowired | |
| 153 | - OilRedisService oilRedisService; | |
| 154 | - | |
| 155 | - @Override | |
| 156 | - public void run() { | |
| 157 | - try { | |
| 158 | - oilRedisService.synchData(5); | |
| 159 | - } catch (Exception e) { | |
| 160 | - logger.error("", e); | |
| 161 | - } | |
| 162 | - } | |
| 163 | - } | |
| 164 | -} |
src/main/java/com/bsth/redis/PlanScheduleRedisService.java deleted
100644 → 0
| 1 | -package com.bsth.redis; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.entity.SchedulePlanInfo; | |
| 5 | -import com.bsth.redis.util.DateUtils; | |
| 6 | -import com.bsth.redis.util.RedisUtils; | |
| 7 | -import com.bsth.repository.SchedulePlanInfoRepository; | |
| 8 | -import com.bsth.server_rs.base_info.line.Line; | |
| 9 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 10 | -import com.bsth.util.ConfigUtil; | |
| 11 | -import com.bsth.util.ConvertUtil; | |
| 12 | -import com.google.common.collect.ArrayListMultimap; | |
| 13 | -import org.joda.time.DateTime; | |
| 14 | -import org.slf4j.Logger; | |
| 15 | -import org.slf4j.LoggerFactory; | |
| 16 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | -import org.springframework.boot.CommandLineRunner; | |
| 18 | -import org.springframework.core.annotation.Order; | |
| 19 | -import org.springframework.data.redis.core.ListOperations; | |
| 20 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 21 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 22 | -import org.springframework.stereotype.Component; | |
| 23 | -import org.springframework.stereotype.Service; | |
| 24 | - | |
| 25 | -import java.util.ArrayList; | |
| 26 | -import java.util.Date; | |
| 27 | -import java.util.Iterator; | |
| 28 | -import java.util.List; | |
| 29 | -import java.util.concurrent.TimeUnit; | |
| 30 | - | |
| 31 | -/** | |
| 32 | - * 计调的 计划排班redis缓存 | |
| 33 | - * Created by panzhao on 2017/3/27. | |
| 34 | - */ | |
| 35 | -@Service | |
| 36 | -@Order(6) | |
| 37 | -public class PlanScheduleRedisService implements CommandLineRunner { | |
| 38 | - | |
| 39 | - @Autowired | |
| 40 | - private RedisTemplate redisTemplate; | |
| 41 | - | |
| 42 | - @Autowired | |
| 43 | - SchedulePlanInfoRepository planInfoRepository; | |
| 44 | - | |
| 45 | - @Autowired | |
| 46 | - RedisUtils redisUtils; | |
| 47 | - | |
| 48 | - static Logger logger = LoggerFactory.getLogger(PlanScheduleRedisService.class); | |
| 49 | - | |
| 50 | - private final static String REDIS_KEY_PREFIX = "plan:"; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * 将一批计划写入redis | |
| 54 | - * | |
| 55 | - * @param list | |
| 56 | - */ | |
| 57 | - public void wirte(List<SchedulePlanInfo> list) { | |
| 58 | - ArrayListMultimap<String, SchedulePlanInfo> multimap; | |
| 59 | - try { | |
| 60 | - if (list.size() == 0) | |
| 61 | - return; | |
| 62 | - //按日期和线路分组数据 | |
| 63 | - Class clazz = SchedulePlanInfo.class; | |
| 64 | - multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("xlBm"), clazz.getDeclaredField("scheduleDate")); | |
| 65 | - | |
| 66 | - //写入redis | |
| 67 | - Iterator<String> iterator = multimap.keySet().iterator(); | |
| 68 | - String key; | |
| 69 | - while (iterator.hasNext()) { | |
| 70 | - key = iterator.next(); | |
| 71 | - replace(key, multimap.get(key)); | |
| 72 | - } | |
| 73 | - } catch (Exception e) { | |
| 74 | - logger.error("", e); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * 将 list 与redis里的数据合并 | |
| 80 | - * | |
| 81 | - * @param key | |
| 82 | - * @param list | |
| 83 | - */ | |
| 84 | - public void mergeData(String key, List<SchedulePlanInfo> list) { | |
| 85 | - key = REDIS_KEY_PREFIX + key.replaceAll("-", ""); | |
| 86 | - | |
| 87 | - ListOperations<String, SchedulePlanInfo> ops = redisTemplate.opsForList(); | |
| 88 | - List<SchedulePlanInfo> cacheList = ops.range(key, 0, -1); | |
| 89 | - | |
| 90 | - for (SchedulePlanInfo plan : cacheList) { | |
| 91 | - if (!list.contains(plan)) | |
| 92 | - list.add(plan); | |
| 93 | - } | |
| 94 | - | |
| 95 | - //更新 | |
| 96 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 97 | - } | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * 覆盖数据 | |
| 101 | - * | |
| 102 | - * @param key | |
| 103 | - * @param list | |
| 104 | - */ | |
| 105 | - public void replace(String key, List<SchedulePlanInfo> list) { | |
| 106 | - key = REDIS_KEY_PREFIX + key.replaceAll("-", ""); | |
| 107 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 108 | - } | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * 根据日期和线路编码从redis获取计划 | |
| 112 | - * | |
| 113 | - * @param dateStr | |
| 114 | - * @param lineCode | |
| 115 | - * @return | |
| 116 | - */ | |
| 117 | - public List<SchedulePlanInfo> read(String dateStr, String lineCode) { | |
| 118 | - return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + lineCode + ":" + dateStr, 0, -1); | |
| 119 | - } | |
| 120 | - | |
| 121 | - | |
| 122 | - @Autowired | |
| 123 | - PlanClearThread planClearThread; | |
| 124 | - | |
| 125 | - @Override | |
| 126 | - public void run(String... strings) throws Exception { | |
| 127 | - Application.mainServices.schedule(new Runnable() { | |
| 128 | - @Override | |
| 129 | - public void run() { | |
| 130 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 131 | - //设置key 序列化器 | |
| 132 | - redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 133 | - | |
| 134 | - DateTime dt = new DateTime(); | |
| 135 | - dt = dt.minusDays(cacheDays); | |
| 136 | - dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | |
| 137 | - List<SchedulePlanInfo> list = planInfoRepository.findByDateRange(dt.toDate(), new Date()); | |
| 138 | - //写入redis | |
| 139 | - wirte(list); | |
| 140 | - } | |
| 141 | - }, 60 * 5, TimeUnit.SECONDS); | |
| 142 | - | |
| 143 | - | |
| 144 | - //定时 00:05 分清理计划,并加载当天的计划 | |
| 145 | - long diff = (DateUtils.getTimestamp() + 1000 * 60 * 5) - System.currentTimeMillis(); | |
| 146 | - if (diff < 0) | |
| 147 | - diff += (1000 * 60 * 60 * 24); | |
| 148 | - Application.mainServices.scheduleAtFixedRate(planClearThread, diff / 1000, 60 * 60 * 24, TimeUnit.SECONDS); | |
| 149 | - } | |
| 150 | - | |
| 151 | - public List<SchedulePlanInfo> findByMultiLine(List<String> lineArray, String rq) { | |
| 152 | - rq = rq.replaceAll("-", ""); | |
| 153 | - List<SchedulePlanInfo> rs = new ArrayList<>(); | |
| 154 | - for (String lineCode : lineArray) { | |
| 155 | - rs.addAll(read(rq, lineCode)); | |
| 156 | - } | |
| 157 | - return rs; | |
| 158 | - } | |
| 159 | - | |
| 160 | - @Component | |
| 161 | - public static class PlanClearThread extends Thread { | |
| 162 | - | |
| 163 | - @Autowired | |
| 164 | - PlanScheduleRedisService planRedisService; | |
| 165 | - @Autowired | |
| 166 | - SchedulePlanInfoRepository planInfoRepository; | |
| 167 | - | |
| 168 | - @Override | |
| 169 | - public void run() { | |
| 170 | - try { | |
| 171 | - logger.info("redis -清理计划排班"); | |
| 172 | - | |
| 173 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 174 | - DateTime dt = new DateTime(); | |
| 175 | - dt = dt.minusDays(cacheDays); | |
| 176 | - String rq = dt.toString("yyyy-MM-dd"); | |
| 177 | - | |
| 178 | - List<Line> lines = LineBufferData.findAll(); | |
| 179 | - for (Line line : lines) { | |
| 180 | - planRedisService.delete(line.getLineCode(), rq); | |
| 181 | - } | |
| 182 | - | |
| 183 | - //加载当天的计划 | |
| 184 | - Date d = new Date(); | |
| 185 | - Date s = new Date(d.getTime() - 1000 * 60 * 60 * 24); | |
| 186 | - List<SchedulePlanInfo> list = planInfoRepository.findByDateRange(s, d); | |
| 187 | - //写入redis | |
| 188 | - planRedisService.wirte(list); | |
| 189 | - } catch (Exception e) { | |
| 190 | - logger.error("", e); | |
| 191 | - } | |
| 192 | - } | |
| 193 | - } | |
| 194 | - | |
| 195 | - private void delete(String lineCode, String rq) { | |
| 196 | - String key = REDIS_KEY_PREFIX + (lineCode + ":" + rq).replaceAll("-", ""); | |
| 197 | - redisTemplate.delete(key); | |
| 198 | - } | |
| 199 | -} |
src/main/java/com/bsth/redis/ScheduleRedisService.java deleted
100644 → 0
| 1 | -package com.bsth.redis; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.common.BasicData; | |
| 5 | -import com.bsth.entity.ScheduleRealInfo; | |
| 6 | -import com.bsth.redis.util.RedisUtils; | |
| 7 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 8 | -import com.bsth.server_rs.base_info.line.Line; | |
| 9 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 10 | -import com.bsth.util.ConfigUtil; | |
| 11 | -import com.bsth.util.ConvertUtil; | |
| 12 | -import com.google.common.collect.ArrayListMultimap; | |
| 13 | -import org.apache.commons.lang3.StringUtils; | |
| 14 | -import org.joda.time.DateTime; | |
| 15 | -import org.joda.time.format.DateTimeFormat; | |
| 16 | -import org.joda.time.format.DateTimeFormatter; | |
| 17 | -import org.slf4j.Logger; | |
| 18 | -import org.slf4j.LoggerFactory; | |
| 19 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 20 | -import org.springframework.boot.CommandLineRunner; | |
| 21 | -import org.springframework.core.annotation.Order; | |
| 22 | -import org.springframework.data.redis.core.ListOperations; | |
| 23 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 24 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 25 | -import org.springframework.stereotype.Component; | |
| 26 | -import org.springframework.stereotype.Service; | |
| 27 | - | |
| 28 | -import java.util.ArrayList; | |
| 29 | -import java.util.Iterator; | |
| 30 | -import java.util.List; | |
| 31 | -import java.util.concurrent.TimeUnit; | |
| 32 | - | |
| 33 | -/** | |
| 34 | - * 班次 redis 缓存管理 | |
| 35 | - * Created by panzhao on 2017/3/13. | |
| 36 | - */ | |
| 37 | -@Service | |
| 38 | -@Order(2) | |
| 39 | -public class ScheduleRedisService implements CommandLineRunner { | |
| 40 | - | |
| 41 | - @Autowired | |
| 42 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 43 | - | |
| 44 | - private final static String REDIS_KEY_PREFIX = "schedule:"; | |
| 45 | - | |
| 46 | - @Autowired | |
| 47 | - private RedisTemplate redisTemplate; | |
| 48 | - | |
| 49 | - @Autowired | |
| 50 | - RedisUtils redisUtils; | |
| 51 | - | |
| 52 | - static Logger logger = LoggerFactory.getLogger(ScheduleRedisService.class); | |
| 53 | - | |
| 54 | - private final static long DAY_TIME = 1000 * 60 * 60 * 24L; | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * 将一批班次写入redis | |
| 58 | - * | |
| 59 | - * @param list | |
| 60 | - */ | |
| 61 | - public void wirte(List<ScheduleRealInfo> list) { | |
| 62 | - ArrayListMultimap<String, ScheduleRealInfo> multimap; | |
| 63 | - try { | |
| 64 | - if (list.size() == 0) | |
| 65 | - return; | |
| 66 | - //按日期和线路分组数据 | |
| 67 | - Class clazz = ScheduleRealInfo.class; | |
| 68 | - multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("xlBm"), clazz.getDeclaredField("scheduleDateStr")); | |
| 69 | - | |
| 70 | - //写入redis | |
| 71 | - Iterator<String> iterator = multimap.keySet().iterator(); | |
| 72 | - String key; | |
| 73 | - while (iterator.hasNext()) { | |
| 74 | - key = iterator.next(); | |
| 75 | - replace(key, multimap.get(key)); | |
| 76 | - } | |
| 77 | - } catch (Exception e) { | |
| 78 | - logger.error("", e); | |
| 79 | - } | |
| 80 | - } | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * 将 list 与redis里的数据合并 | |
| 84 | - * | |
| 85 | - * @param key | |
| 86 | - * @param list | |
| 87 | - */ | |
| 88 | - public void mergeData(String key, List<ScheduleRealInfo> list) { | |
| 89 | - key = REDIS_KEY_PREFIX + key.replaceAll("-", ""); | |
| 90 | - | |
| 91 | - ListOperations<String, ScheduleRealInfo> ops = redisTemplate.opsForList(); | |
| 92 | - List<ScheduleRealInfo> cacheList = ops.range(key, 0, -1); | |
| 93 | - | |
| 94 | - for (ScheduleRealInfo sch : cacheList) { | |
| 95 | - if (!list.contains(sch)) | |
| 96 | - list.add(sch); | |
| 97 | - } | |
| 98 | - | |
| 99 | - //更新 | |
| 100 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 101 | - } | |
| 102 | - | |
| 103 | - /** | |
| 104 | - * 覆盖数据 | |
| 105 | - * | |
| 106 | - * @param key | |
| 107 | - * @param list | |
| 108 | - */ | |
| 109 | - public void replace(String key, List<ScheduleRealInfo> list) { | |
| 110 | - key = REDIS_KEY_PREFIX + key.replaceAll("-", ""); | |
| 111 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 112 | - } | |
| 113 | - | |
| 114 | - /** | |
| 115 | - * 删除数据 | |
| 116 | - * | |
| 117 | - * @param key | |
| 118 | - */ | |
| 119 | - public void delete(String lineCode, String rq) { | |
| 120 | - String key = REDIS_KEY_PREFIX + (lineCode + ":" + rq).replaceAll("-", ""); | |
| 121 | - redisTemplate.delete(key); | |
| 122 | - } | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * 根据日期和线路编码从redis获取班次 | |
| 126 | - * | |
| 127 | - * @param dateStr | |
| 128 | - * @param lineCode | |
| 129 | - * @return | |
| 130 | - */ | |
| 131 | - public List<ScheduleRealInfo> read(String dateStr, String lineCode) { | |
| 132 | - return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + lineCode + ":" + dateStr, 0, -1); | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * 返回指定日期,公司的实际排班,并按线路_车辆分组 | |
| 137 | - * | |
| 138 | - * @param rq | |
| 139 | - * @param companyId | |
| 140 | - * @return | |
| 141 | - */ | |
| 142 | - public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByNbbm(String rq, String companyId) { | |
| 143 | - List<String> lineArray = LineBufferData.findCodesByCompany(companyId); | |
| 144 | - ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create(); | |
| 145 | - | |
| 146 | - rq = rq.replaceAll("-", ""); | |
| 147 | - List<ScheduleRealInfo> list; | |
| 148 | - for (String lineCode : lineArray) { | |
| 149 | - | |
| 150 | - list = read(rq, lineCode); | |
| 151 | - | |
| 152 | - for (ScheduleRealInfo sch : list) { | |
| 153 | - rs.put(sch.getXlBm() + "_" + sch.getClZbh(), sch); | |
| 154 | - } | |
| 155 | - } | |
| 156 | - return rs; | |
| 157 | - } | |
| 158 | - | |
| 159 | - /** | |
| 160 | - * 返回指定日期,公司的实际排班,并按线路分组 | |
| 161 | - * | |
| 162 | - * @param rq | |
| 163 | - * @param companyId | |
| 164 | - * @return | |
| 165 | - */ | |
| 166 | - public ArrayListMultimap<String, ScheduleRealInfo> findByDateAndGroupByLine(String rq, String companyId) { | |
| 167 | - | |
| 168 | - List<String> lineArray = LineBufferData.findCodesByCompany(companyId); | |
| 169 | - ArrayListMultimap<String, ScheduleRealInfo> rs = ArrayListMultimap.create(); | |
| 170 | - | |
| 171 | - rq = rq.replaceAll("-", ""); | |
| 172 | - List<ScheduleRealInfo> list; | |
| 173 | - for (String lineCode : lineArray) { | |
| 174 | - | |
| 175 | - list = read(rq, lineCode); | |
| 176 | - | |
| 177 | - for (ScheduleRealInfo sch : list) { | |
| 178 | - rs.put(sch.getXlBm(), sch); | |
| 179 | - } | |
| 180 | - } | |
| 181 | - return rs; | |
| 182 | - } | |
| 183 | - | |
| 184 | - @Autowired | |
| 185 | - ScheduleRefreshThread scheduleRefreshThread; | |
| 186 | - @Autowired | |
| 187 | - ScheduleClearThread scheduleClearThread; | |
| 188 | - | |
| 189 | - @Override | |
| 190 | - public void run(String... strings) throws Exception { | |
| 191 | - //用子线程去加载,,不要阻塞 | |
| 192 | - Application.mainServices.schedule(new Runnable() { | |
| 193 | - @Override | |
| 194 | - public void run() { | |
| 195 | - try { | |
| 196 | - logger.info("redis 实际排班 start..."); | |
| 197 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 198 | - //设置key 序列化器 | |
| 199 | - redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 200 | - | |
| 201 | - DateTime dt = new DateTime(); | |
| 202 | - dt = dt.minusDays(cacheDays); | |
| 203 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDateLT(dt.toString("yyyy-MM-dd")); | |
| 204 | - calcTime(list); | |
| 205 | - //写入redis | |
| 206 | - wirte(list); | |
| 207 | - logger.info("redis 实际排班 over..."); | |
| 208 | - } catch (Exception e) { | |
| 209 | - logger.info("redis 实际排班 异常", e); | |
| 210 | - } | |
| 211 | - } | |
| 212 | - }, 5, TimeUnit.SECONDS); | |
| 213 | - | |
| 214 | - //定时刷新一次当日实际排班 | |
| 215 | - int minute = 10; | |
| 216 | - Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, minute + 4, minute, TimeUnit.MINUTES); | |
| 217 | - //24小时清理一次实际排班数据 | |
| 218 | - Application.mainServices.scheduleWithFixedDelay(scheduleClearThread, 24, 24, TimeUnit.HOURS); | |
| 219 | - } | |
| 220 | - | |
| 221 | - public List<ScheduleRealInfo> findByMultiLine(List<String> lineArray, String rq) { | |
| 222 | - rq = rq.replaceAll("-", ""); | |
| 223 | - List<ScheduleRealInfo> rs = new ArrayList<>(); | |
| 224 | - for (String lineCode : lineArray) { | |
| 225 | - rs.addAll(read(rq, lineCode)); | |
| 226 | - } | |
| 227 | - return rs; | |
| 228 | - } | |
| 229 | - | |
| 230 | - @Component | |
| 231 | - public static class ScheduleRefreshThread extends Thread { | |
| 232 | - | |
| 233 | - @Autowired | |
| 234 | - ScheduleRealInfoRepository realInfoRepository; | |
| 235 | - | |
| 236 | - @Autowired | |
| 237 | - ScheduleRedisService scheduleRedisService; | |
| 238 | - | |
| 239 | - @Override | |
| 240 | - public void run() { | |
| 241 | - try { | |
| 242 | - DateTime dt = new DateTime(); | |
| 243 | - DateTime yesterday = dt.minusDays(2); | |
| 244 | - | |
| 245 | - String rq = yesterday.toString("yyyy-MM-dd"); | |
| 246 | - logger.info("refresh lt yesterday ..." + rq + " -start"); | |
| 247 | - List<ScheduleRealInfo> list = realInfoRepository.findByDateLT(rq); | |
| 248 | - | |
| 249 | - //计算时间戳 | |
| 250 | - scheduleRedisService.calcTime(list); | |
| 251 | - scheduleRedisService.wirte(list); | |
| 252 | - | |
| 253 | - logger.info("refresh lt yesterday ..." + rq + " -end### size: " + list.size()); | |
| 254 | - } catch (Exception e) { | |
| 255 | - logger.error("", e); | |
| 256 | - } | |
| 257 | - } | |
| 258 | - } | |
| 259 | - | |
| 260 | - @Component | |
| 261 | - public static class ScheduleClearThread extends Thread { | |
| 262 | - | |
| 263 | - @Autowired | |
| 264 | - ScheduleRedisService scheduleRedisService; | |
| 265 | - | |
| 266 | - @Override | |
| 267 | - public void run() { | |
| 268 | - try { | |
| 269 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 270 | - DateTime dt = new DateTime(); | |
| 271 | - dt = dt.minusDays(cacheDays); | |
| 272 | - String rq = dt.toString("yyyy-MM-dd"); | |
| 273 | - | |
| 274 | - List<Line> lines = LineBufferData.findAll(); | |
| 275 | - for (Line line : lines) { | |
| 276 | - scheduleRedisService.delete(line.getLineCode(), rq); | |
| 277 | - } | |
| 278 | - } catch (Exception e) { | |
| 279 | - logger.error("", e); | |
| 280 | - } | |
| 281 | - } | |
| 282 | - } | |
| 283 | - | |
| 284 | - /** | |
| 285 | - * ############ 时间戳计算 ########## | |
| 286 | - */ | |
| 287 | - private static DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"), | |
| 288 | - fmtHHmm = DateTimeFormat.forPattern("HH:mm"); | |
| 289 | - | |
| 290 | - private void calcTime(List<ScheduleRealInfo> list) { | |
| 291 | - if (list.size() == 0) | |
| 292 | - return; | |
| 293 | - | |
| 294 | - //计算真实执行日期 和 时间戳 | |
| 295 | - for (ScheduleRealInfo sch : list) { | |
| 296 | - calcRealDate(BasicData.lineStartTimeMap.get(sch.getXlBm()), sch); | |
| 297 | - } | |
| 298 | - } | |
| 299 | - | |
| 300 | - /** | |
| 301 | - * @Title: calcRealDate | |
| 302 | - * @Description: TODO(计算班次的真实执行日期) | |
| 303 | - */ | |
| 304 | - public void calcRealDate(String startTime, ScheduleRealInfo sch) { | |
| 305 | - try { | |
| 306 | - if (null == startTime) | |
| 307 | - return; | |
| 308 | - | |
| 309 | - if (null == sch.getBcsj()) | |
| 310 | - sch.setBcsj(0); | |
| 311 | - | |
| 312 | - String rq = sch.getScheduleDateStr(); | |
| 313 | - //计发时间 | |
| 314 | - sch.setFcsjT(parseTime(rq, sch.getFcsj(), startTime)); | |
| 315 | - //待发时间 | |
| 316 | - sch.setDfsjT(parseTime(rq, sch.getDfsj(), startTime)); | |
| 317 | - //计划终点时间 | |
| 318 | - if (StringUtils.isEmpty(sch.getZdsj())) { | |
| 319 | - sch.setZdsjT(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | |
| 320 | - sch.setZdsj(fmtHHmm.print(sch.getZdsjT())); | |
| 321 | - } else | |
| 322 | - sch.setZdsjT(sch.getDfsjT() + (sch.getBcsj() * 60 * 1000)); | |
| 323 | - //实发时间 | |
| 324 | - if (StringUtils.isNotEmpty(sch.getFcsjActual())) | |
| 325 | - sch.setFcsjActualAll(parseTime(rq, sch.getFcsjActual(), startTime)); | |
| 326 | - | |
| 327 | - //实达时间 | |
| 328 | - if (StringUtils.isNotEmpty(sch.getZdsjActual())) | |
| 329 | - sch.setZdsjActualAll(parseTime(rq, sch.getZdsjActual(), startTime)); | |
| 330 | - } catch (Exception e) { | |
| 331 | - logger.error("", e); | |
| 332 | - } | |
| 333 | - } | |
| 334 | - | |
| 335 | - private long parseTime(String rq, String sj, String startTime) { | |
| 336 | - long t = fmtyyyyMMddHHmm.parseMillis(rq + sj); | |
| 337 | - if (sj.compareTo(startTime) < 0) { | |
| 338 | - t += DAY_TIME; | |
| 339 | - } | |
| 340 | - return t; | |
| 341 | - } | |
| 342 | -} |
src/main/java/com/bsth/redis/util/DateUtils.java deleted
100644 → 0
| 1 | -package com.bsth.redis.util; | |
| 2 | - | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.Calendar; | |
| 6 | -import java.util.Date; | |
| 7 | - | |
| 8 | -public class DateUtils { | |
| 9 | - | |
| 10 | - // 获得当天0点时间 | |
| 11 | - public static int getTimesmorning() { | |
| 12 | - Calendar cal = Calendar.getInstance(); | |
| 13 | - cal.set(Calendar.HOUR_OF_DAY, 0); | |
| 14 | - cal.set(Calendar.SECOND, 0); | |
| 15 | - cal.set(Calendar.MINUTE, 0); | |
| 16 | - cal.set(Calendar.MILLISECOND, 0); | |
| 17 | - return (int) (cal.getTimeInMillis() / 1000); | |
| 18 | - } | |
| 19 | - | |
| 20 | - // 获得当天0点毫秒时间戳 | |
| 21 | - public static long getTimestamp() { | |
| 22 | - Calendar cal = Calendar.getInstance(); | |
| 23 | - cal.set(Calendar.HOUR_OF_DAY, 0); | |
| 24 | - cal.set(Calendar.SECOND, 0); | |
| 25 | - cal.set(Calendar.MINUTE, 0); | |
| 26 | - cal.set(Calendar.MILLISECOND, 0); | |
| 27 | - return cal.getTimeInMillis(); | |
| 28 | - } | |
| 29 | - | |
| 30 | - public static Long getTimesmorning(Calendar cal) { | |
| 31 | - cal.set(Calendar.HOUR_OF_DAY, 0); | |
| 32 | - cal.set(Calendar.SECOND, 0); | |
| 33 | - cal.set(Calendar.MINUTE, 0); | |
| 34 | - cal.set(Calendar.MILLISECOND, 0); | |
| 35 | - return cal.getTimeInMillis() / 1000; | |
| 36 | - } | |
| 37 | - | |
| 38 | - // 获得当天24点时间 | |
| 39 | - public static int getTimesnight() { | |
| 40 | - Calendar cal = Calendar.getInstance(); | |
| 41 | - cal.set(Calendar.HOUR_OF_DAY, 24); | |
| 42 | - cal.set(Calendar.SECOND, 0); | |
| 43 | - cal.set(Calendar.MINUTE, 0); | |
| 44 | - cal.set(Calendar.MILLISECOND, 0); | |
| 45 | - return (int) (cal.getTimeInMillis() / 1000); | |
| 46 | - } | |
| 47 | - | |
| 48 | - // 获得当天24点时间 毫秒 | |
| 49 | - public static Long getTimesnight2() { | |
| 50 | - Calendar cal = Calendar.getInstance(); | |
| 51 | - cal.set(Calendar.HOUR_OF_DAY, 24); | |
| 52 | - cal.set(Calendar.SECOND, 0); | |
| 53 | - cal.set(Calendar.MINUTE, 0); | |
| 54 | - cal.set(Calendar.MILLISECOND, 0); | |
| 55 | - return cal.getTimeInMillis(); | |
| 56 | - } | |
| 57 | - | |
| 58 | - public static Long getTimesnight(Calendar cal) { | |
| 59 | - cal.set(Calendar.HOUR_OF_DAY, 24); | |
| 60 | - cal.set(Calendar.SECOND, 0); | |
| 61 | - cal.set(Calendar.MINUTE, 0); | |
| 62 | - cal.set(Calendar.MILLISECOND, 0); | |
| 63 | - return cal.getTimeInMillis(); | |
| 64 | - } | |
| 65 | - | |
| 66 | - // 获得本周一0点时间 | |
| 67 | - public static int getTimesWeekmorning() { | |
| 68 | - Calendar cal = Calendar.getInstance(); | |
| 69 | - cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); | |
| 70 | - cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); | |
| 71 | - return (int) (cal.getTimeInMillis() / 1000); | |
| 72 | - } | |
| 73 | - | |
| 74 | - // 获得本周日24点时间 | |
| 75 | - public static int getTimesWeeknight() { | |
| 76 | - Calendar cal = Calendar.getInstance(); | |
| 77 | - cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); | |
| 78 | - cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); | |
| 79 | - return (int) ((cal.getTime().getTime() + (7 * 24 * 60 * 60 * 1000)) / 1000); | |
| 80 | - } | |
| 81 | - | |
| 82 | - // 获得本月第一天0点时间 | |
| 83 | - public static int getTimesMonthmorning() { | |
| 84 | - Calendar cal = Calendar.getInstance(); | |
| 85 | - cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); | |
| 86 | - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH)); | |
| 87 | - return (int) (cal.getTimeInMillis() / 1000); | |
| 88 | - } | |
| 89 | - | |
| 90 | - // 获得本月最后一天24点时间 | |
| 91 | - public static int getTimesMonthnight() { | |
| 92 | - Calendar cal = Calendar.getInstance(); | |
| 93 | - cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONDAY), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0); | |
| 94 | - cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); | |
| 95 | - cal.set(Calendar.HOUR_OF_DAY, 24); | |
| 96 | - return (int) (cal.getTimeInMillis() / 1000); | |
| 97 | - } | |
| 98 | - | |
| 99 | - private static SimpleDateFormat sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm") | |
| 100 | - ,sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd") | |
| 101 | - ,sdfHHmm = new SimpleDateFormat("HH:mm"); | |
| 102 | - public static long getTimesByHHmm(String str) throws ParseException{ | |
| 103 | - Date d = sdfyyyyMMddHHmm.parse(sdfyyyyMMdd.format(new Date()) + str); | |
| 104 | - return d.getTime(); | |
| 105 | - } | |
| 106 | - | |
| 107 | - public static String plusDay(String old, int day){ | |
| 108 | - Calendar cal = null; | |
| 109 | - try { | |
| 110 | - Date date = sdfyyyyMMdd.parse(old); | |
| 111 | - cal = Calendar.getInstance(); | |
| 112 | - cal.setTime(date); | |
| 113 | - cal.add(Calendar.DATE, day); | |
| 114 | - } catch (ParseException e) { | |
| 115 | - e.printStackTrace(); | |
| 116 | - } | |
| 117 | - return sdfyyyyMMdd.format(cal.getTime()); | |
| 118 | - } | |
| 119 | - | |
| 120 | - public static String subtractDay(String old, int day){ | |
| 121 | - Calendar cal = null; | |
| 122 | - try { | |
| 123 | - Date date = sdfyyyyMMdd.parse(old); | |
| 124 | - cal = Calendar.getInstance(); | |
| 125 | - cal.setTime(date); | |
| 126 | - cal.set(Calendar.DATE, cal.get(Calendar.DATE) - day); | |
| 127 | - } catch (ParseException e) { | |
| 128 | - e.printStackTrace(); | |
| 129 | - } | |
| 130 | - return sdfyyyyMMdd.format(cal.getTime()); | |
| 131 | - } | |
| 132 | - | |
| 133 | - public static int calcHHmmDiff(String fcsj, String zdsj) throws ParseException { | |
| 134 | - return (int) (sdfHHmm.parse(zdsj).getTime() - sdfHHmm.parse(fcsj).getTime()); | |
| 135 | - } | |
| 136 | -} |
src/main/java/com/bsth/redis/util/RedisUtils.java deleted
100644 → 0
| 1 | -package com.bsth.redis.util; | |
| 2 | - | |
| 3 | -import org.springframework.dao.DataAccessException; | |
| 4 | -import org.springframework.data.redis.core.RedisOperations; | |
| 5 | -import org.springframework.data.redis.core.SessionCallback; | |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | - | |
| 8 | -import java.util.List; | |
| 9 | - | |
| 10 | -/** | |
| 11 | - * Created by panzhao on 2017/3/30. | |
| 12 | - */ | |
| 13 | -@Component | |
| 14 | -public class RedisUtils<T> { | |
| 15 | - | |
| 16 | - public SessionCallback getUpdateCallback(final String key, final List<T> list){ | |
| 17 | - | |
| 18 | - SessionCallback<Object> sessionCallback = new SessionCallback<Object>() { | |
| 19 | - | |
| 20 | - @Override | |
| 21 | - public Object execute(RedisOperations redisOperations) throws DataAccessException { | |
| 22 | - redisOperations.multi(); | |
| 23 | - redisOperations.delete(key); | |
| 24 | - redisOperations.opsForList().leftPushAll(key, list); | |
| 25 | - return redisOperations.exec(); | |
| 26 | - } | |
| 27 | - }; | |
| 28 | - | |
| 29 | - return sessionCallback; | |
| 30 | - } | |
| 31 | -} |
src/main/java/com/bsth/server_rs/base_info/person/PersonRestService.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.base_info.person; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.alibaba.fastjson.TypeReference; | |
| 5 | -import com.bsth.server_rs.base_info.dto.PersonCardDto; | |
| 6 | -import com.bsth.server_rs.base_info.person.buffer.PersonBufferData; | |
| 7 | -import org.apache.commons.lang3.StringEscapeUtils; | |
| 8 | - | |
| 9 | -import javax.ws.rs.*; | |
| 10 | -import javax.ws.rs.core.MediaType; | |
| 11 | -import java.util.List; | |
| 12 | -import java.util.Map; | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * Created by panzhao on 2017/3/28. | |
| 16 | - */ | |
| 17 | -@Path("/person") | |
| 18 | -@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) | |
| 19 | -public class PersonRestService { | |
| 20 | - | |
| 21 | - @GET | |
| 22 | - @Path("/all") | |
| 23 | - public List<Personnel> findAll(){ | |
| 24 | - return PersonBufferData.findAll(); | |
| 25 | - } | |
| 26 | - | |
| 27 | - @GET | |
| 28 | - @Path("/company/{companyId}") | |
| 29 | - public List<Personnel> findByCompany(@PathParam("companyId") String companyId) { | |
| 30 | - return companyId.equals("-9999") ? PersonBufferData.findAll() : PersonBufferData.findByCompany(companyId); | |
| 31 | - } | |
| 32 | - | |
| 33 | - @GET | |
| 34 | - @Path("/{workId}") | |
| 35 | - public Personnel findOne(@PathParam("workId") String workId) { | |
| 36 | - return PersonBufferData.findOne(workId); | |
| 37 | - } | |
| 38 | - | |
| 39 | - @POST | |
| 40 | - @Path("/setCards") | |
| 41 | - public Map<String, Object> multiPostCards(String bodyStr){ | |
| 42 | - bodyStr = StringEscapeUtils.unescapeHtml4(bodyStr); | |
| 43 | - List<PersonCardDto> list = JSON.parseObject(bodyStr, new TypeReference<List<PersonCardDto>>() {}); | |
| 44 | - return PersonBufferData.multiSaveCards(list); | |
| 45 | - } | |
| 46 | -} |
src/main/java/com/bsth/server_rs/base_info/person/Personnel.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.base_info.person; | |
| 2 | - | |
| 3 | -import javax.xml.bind.annotation.XmlRootElement; | |
| 4 | -import java.io.Serializable; | |
| 5 | - | |
| 6 | -/** | |
| 7 | - * @ClassName : Personnel(人员实体类) | |
| 8 | - * @Author : bsth@lq | |
| 9 | - * @Description : TODO(人员) | |
| 10 | - * @Data :2016-04-27 | |
| 11 | - * @Version 公交调度系统BS版 0.1 | |
| 12 | - */ | |
| 13 | -@XmlRootElement | |
| 14 | -public class Personnel implements Serializable { | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * 公司编码 | |
| 18 | - */ | |
| 19 | - private String companyCode; | |
| 20 | - /** | |
| 21 | - * 分公司编码 | |
| 22 | - */ | |
| 23 | - private String brancheCompanyCode; | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 工号 | |
| 27 | - */ | |
| 28 | - private String jobCode; | |
| 29 | - /** | |
| 30 | - * 姓名 | |
| 31 | - */ | |
| 32 | - private String personnelName; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 运营服务证书号 | |
| 36 | - */ | |
| 37 | - private String papersCode; | |
| 38 | - /** | |
| 39 | - * 一卡通工作卡号 | |
| 40 | - */ | |
| 41 | - private String icCardCode; | |
| 42 | - /** | |
| 43 | - * 性别(字典类型sexType) | |
| 44 | - */ | |
| 45 | - private String personnelType; | |
| 46 | - /** | |
| 47 | - * 所属岗位/工种(字典类型gzType) | |
| 48 | - */ | |
| 49 | - private String posts; | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * 身份证 | |
| 53 | - */ | |
| 54 | - private String card; | |
| 55 | - | |
| 56 | - public String getCard() { | |
| 57 | - return card; | |
| 58 | - } | |
| 59 | - | |
| 60 | - public void setCard(String card) { | |
| 61 | - this.card = card; | |
| 62 | - } | |
| 63 | - | |
| 64 | - /** | |
| 65 | - * 联系电话(TODO:在原系统里没有,这里暂时留着) | |
| 66 | - */ | |
| 67 | - private String telphone; | |
| 68 | - | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * RFID 人卡IC号 | |
| 72 | - */ | |
| 73 | - private String icRfid; | |
| 74 | - | |
| 75 | - /** | |
| 76 | - * RFID 人卡ID号 | |
| 77 | - */ | |
| 78 | - private String idRfid; | |
| 79 | - | |
| 80 | - /** | |
| 81 | - * RFID 标签号 | |
| 82 | - */ | |
| 83 | - private String tagRfid; | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * 备注 | |
| 87 | - */ | |
| 88 | - private String remark; | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * 线路名称 | |
| 92 | - */ | |
| 93 | - private String lineName; | |
| 94 | - | |
| 95 | - /** | |
| 96 | - * 线路编码 | |
| 97 | - */ | |
| 98 | - private String lineCode; | |
| 99 | - | |
| 100 | - public String getCompanyCode() { | |
| 101 | - return companyCode; | |
| 102 | - } | |
| 103 | - | |
| 104 | - public void setCompanyCode(String companyCode) { | |
| 105 | - this.companyCode = companyCode; | |
| 106 | - } | |
| 107 | - | |
| 108 | - public String getBrancheCompanyCode() { | |
| 109 | - return brancheCompanyCode; | |
| 110 | - } | |
| 111 | - | |
| 112 | - public void setBrancheCompanyCode(String brancheCompanyCode) { | |
| 113 | - this.brancheCompanyCode = brancheCompanyCode; | |
| 114 | - } | |
| 115 | - | |
| 116 | - public String getJobCode() { | |
| 117 | - return jobCode; | |
| 118 | - } | |
| 119 | - | |
| 120 | - public void setJobCode(String jobCode) { | |
| 121 | - this.jobCode = jobCode; | |
| 122 | - } | |
| 123 | - | |
| 124 | - public String getPersonnelName() { | |
| 125 | - return personnelName; | |
| 126 | - } | |
| 127 | - | |
| 128 | - public void setPersonnelName(String personnelName) { | |
| 129 | - this.personnelName = personnelName; | |
| 130 | - } | |
| 131 | - | |
| 132 | - public String getPapersCode() { | |
| 133 | - return papersCode; | |
| 134 | - } | |
| 135 | - | |
| 136 | - public void setPapersCode(String papersCode) { | |
| 137 | - this.papersCode = papersCode; | |
| 138 | - } | |
| 139 | - | |
| 140 | - public String getIcCardCode() { | |
| 141 | - return icCardCode; | |
| 142 | - } | |
| 143 | - | |
| 144 | - public void setIcCardCode(String icCardCode) { | |
| 145 | - this.icCardCode = icCardCode; | |
| 146 | - } | |
| 147 | - | |
| 148 | - public String getPersonnelType() { | |
| 149 | - return personnelType; | |
| 150 | - } | |
| 151 | - | |
| 152 | - public void setPersonnelType(String personnelType) { | |
| 153 | - this.personnelType = personnelType; | |
| 154 | - } | |
| 155 | - | |
| 156 | - public String getPosts() { | |
| 157 | - return posts; | |
| 158 | - } | |
| 159 | - | |
| 160 | - public void setPosts(String posts) { | |
| 161 | - this.posts = posts; | |
| 162 | - } | |
| 163 | - | |
| 164 | - public String getTelphone() { | |
| 165 | - return telphone; | |
| 166 | - } | |
| 167 | - | |
| 168 | - public void setTelphone(String telphone) { | |
| 169 | - this.telphone = telphone; | |
| 170 | - } | |
| 171 | - | |
| 172 | - public String getIcRfid() { | |
| 173 | - return icRfid; | |
| 174 | - } | |
| 175 | - | |
| 176 | - public void setIcRfid(String icRfid) { | |
| 177 | - this.icRfid = icRfid; | |
| 178 | - } | |
| 179 | - | |
| 180 | - public String getIdRfid() { | |
| 181 | - return idRfid; | |
| 182 | - } | |
| 183 | - | |
| 184 | - public void setIdRfid(String idRfid) { | |
| 185 | - this.idRfid = idRfid; | |
| 186 | - } | |
| 187 | - | |
| 188 | - public String getTagRfid() { | |
| 189 | - return tagRfid; | |
| 190 | - } | |
| 191 | - | |
| 192 | - public void setTagRfid(String tagRfid) { | |
| 193 | - this.tagRfid = tagRfid; | |
| 194 | - } | |
| 195 | - | |
| 196 | - public String getLineName() { | |
| 197 | - return lineName; | |
| 198 | - } | |
| 199 | - | |
| 200 | - public void setLineName(String lineName) { | |
| 201 | - this.lineName = lineName; | |
| 202 | - } | |
| 203 | - | |
| 204 | - public String getLineCode() { | |
| 205 | - return lineCode; | |
| 206 | - } | |
| 207 | - | |
| 208 | - public void setLineCode(String lineCode) { | |
| 209 | - this.lineCode = lineCode; | |
| 210 | - } | |
| 211 | - | |
| 212 | - public String getRemark() { | |
| 213 | - return remark; | |
| 214 | - } | |
| 215 | - | |
| 216 | - public void setRemark(String remark) { | |
| 217 | - this.remark = remark; | |
| 218 | - } | |
| 219 | -} |
src/main/java/com/bsth/server_rs/base_info/person/buffer/PersonBufferData.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.base_info.person.buffer; | |
| 2 | - | |
| 3 | -import com.bsth.Application; | |
| 4 | -import com.bsth.server_rs.base_info.dto.PersonCardDto; | |
| 5 | -import com.bsth.server_rs.base_info.person.Personnel; | |
| 6 | -import com.google.common.collect.ArrayListMultimap; | |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | -import org.springframework.boot.CommandLineRunner; | |
| 9 | -import org.springframework.core.annotation.Order; | |
| 10 | -import org.springframework.stereotype.Component; | |
| 11 | - | |
| 12 | -import java.util.*; | |
| 13 | -import java.util.concurrent.TimeUnit; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * Created by panzhao on 2017/3/30. | |
| 17 | - */ | |
| 18 | -@Component | |
| 19 | -@Order(7) | |
| 20 | -public class PersonBufferData implements CommandLineRunner { | |
| 21 | - | |
| 22 | - @Autowired | |
| 23 | - PersonRefreshThread personRefreshThread; | |
| 24 | - | |
| 25 | - private static List<Personnel> data; | |
| 26 | - private static Map<String, Personnel> idMap; | |
| 27 | - private static ArrayListMultimap<String, Personnel> companyListMap; | |
| 28 | - | |
| 29 | - /** | |
| 30 | - * 待入库的personnel | |
| 31 | - */ | |
| 32 | - public static LinkedList<Personnel> pstList = new LinkedList<>(); | |
| 33 | - public static List<Personnel> findAll() { | |
| 34 | - return data; | |
| 35 | - } | |
| 36 | - | |
| 37 | - public static Personnel findOne(String workId) { | |
| 38 | - return idMap.get(workId); | |
| 39 | - } | |
| 40 | - | |
| 41 | - public static List<Personnel> findByCompany(String company) { | |
| 42 | - return companyListMap.get(company); | |
| 43 | - } | |
| 44 | - | |
| 45 | - public static void replaceAll(List<Personnel> newData) { | |
| 46 | - data = newData; | |
| 47 | - Map<String, Personnel> idMapCopy = new HashMap<>(); | |
| 48 | - ArrayListMultimap<String, Personnel> listMap = ArrayListMultimap.create(); | |
| 49 | - | |
| 50 | - for (Personnel p : data) { | |
| 51 | - idMapCopy.put(p.getJobCode(), p); | |
| 52 | - listMap.put(p.getCompanyCode(), p); | |
| 53 | - } | |
| 54 | - idMap = idMapCopy; | |
| 55 | - | |
| 56 | - companyListMap = listMap; | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * 批量设置人卡数据 | |
| 61 | - * @param list | |
| 62 | - * @return | |
| 63 | - */ | |
| 64 | - public static Map<String, Object> multiSaveCards(List<PersonCardDto> list){ | |
| 65 | - int success=0,error=0; | |
| 66 | - | |
| 67 | - Personnel p; | |
| 68 | - for(PersonCardDto pcd : list){ | |
| 69 | - p = idMap.get(pcd.getCompany() + "-" + pcd.getJobCode()); | |
| 70 | - if(p == null) | |
| 71 | - error ++; | |
| 72 | - else{ | |
| 73 | - p.setIdRfid(pcd.getIdCard()); | |
| 74 | - p.setTagRfid(pcd.getTagCard()); | |
| 75 | - p.setRemark(pcd.getRemark()); | |
| 76 | - success ++; | |
| 77 | - | |
| 78 | - pstList.add(p); | |
| 79 | - } | |
| 80 | - } | |
| 81 | - | |
| 82 | - Map<String, Object> rs = new HashMap<>(); | |
| 83 | - rs.put("success", success); | |
| 84 | - rs.put("error", error); | |
| 85 | - return rs; | |
| 86 | - } | |
| 87 | - | |
| 88 | - @Override | |
| 89 | - public void run(String... strings) throws Exception { | |
| 90 | - Application.mainServices.scheduleWithFixedDelay(personRefreshThread, 10, 60 * 30, TimeUnit.SECONDS); | |
| 91 | - } | |
| 92 | -} |
src/main/java/com/bsth/server_rs/base_info/person/buffer/PersonRefreshThread.java deleted
100644 → 0
| 1 | -package com.bsth.server_rs.base_info.person.buffer; | |
| 2 | - | |
| 3 | -import com.bsth.server_rs.base_info.person.Personnel; | |
| 4 | -import org.slf4j.Logger; | |
| 5 | -import org.slf4j.LoggerFactory; | |
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 8 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 9 | -import org.springframework.stereotype.Component; | |
| 10 | - | |
| 11 | -import java.util.ArrayList; | |
| 12 | -import java.util.HashMap; | |
| 13 | -import java.util.List; | |
| 14 | -import java.util.Map; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * Created by panzhao on 2017/3/27. | |
| 18 | - */ | |
| 19 | -@Component | |
| 20 | -public class PersonRefreshThread extends Thread{ | |
| 21 | - | |
| 22 | - @Autowired | |
| 23 | - JdbcTemplate jdbcTemplate; | |
| 24 | - | |
| 25 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 26 | - | |
| 27 | - @Override | |
| 28 | - public void run() { | |
| 29 | - | |
| 30 | - try { | |
| 31 | - List<Personnel> list = jdbcTemplate.query("select DISTINCT t1.*,t2.name as line_name,t2.line_code from (SELECT company_code,branche_company_code,job_code,personnel_name,papers_code,ic_card_code,personnel_type,posts,card,telphone,ic_rfid,id_rfid,tag_rfid,e.xl FROM bsth_c_personnel p left JOIN bsth_c_s_ecinfo e on p.id=e.jsy) t1 LEFT JOIN bsth_c_line t2 on t1.xl=t2.id " | |
| 32 | - ,BeanPropertyRowMapper.newInstance(Personnel.class)); | |
| 33 | - | |
| 34 | - Map<String, Personnel> map = new HashMap<>(); | |
| 35 | - //过滤数据,多条线路配人的保留一条 | |
| 36 | - for(Personnel p : list){ | |
| 37 | - map.put(p.getJobCode(), p); | |
| 38 | - } | |
| 39 | - | |
| 40 | - if(list != null && list.size() > 0) | |
| 41 | - PersonBufferData.replaceAll(new ArrayList(map.values())); | |
| 42 | - }catch (Exception e){ | |
| 43 | - logger.error("", e); | |
| 44 | - } | |
| 45 | - } | |
| 46 | -} |
src/main/resources/application-prod.properties
| ... | ... | @@ -8,7 +8,7 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy |
| 8 | 8 | spring.jpa.database= MYSQL |
| 9 | 9 | spring.jpa.show-sql= false |
| 10 | 10 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 11 | -spring.datasource.url= jdbc:mysql://172.50.127.252:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 11 | +spring.datasource.url= jdbc:mysql://127.0.0.1:3306/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 12 | 12 | spring.datasource.username= root |
| 13 | 13 | spring.datasource.password= root |
| 14 | 14 | #DATASOURCE |
| ... | ... | @@ -21,15 +21,4 @@ spring.datasource.test-on-borrow=true |
| 21 | 21 | spring.datasource.test-on-connect=true |
| 22 | 22 | spring.datasource.test-on-return=true |
| 23 | 23 | spring.datasource.test-while-idle=true |
| 24 | -spring.datasource.validation-query=select 1 | |
| 25 | - | |
| 26 | -#REDIS | |
| 27 | -spring.redis.database=0 | |
| 28 | -spring.redis.host=10.10.150.24 | |
| 29 | -spring.redis.password=bsth_control_001 | |
| 30 | -spring.redis.port=28008 | |
| 31 | - | |
| 32 | -http.control.service_data_url= http://10.10.200.121:49088/companyService | |
| 33 | -http.control.secret.key= dVPHJkWUt5FhMT7jrM2dLV7QvlHAmZFd42rs1P0usBx8A7HZki | |
| 34 | - | |
| 35 | -http.gps.real.url= http://10.10.200.79:8080/transport_server/rtgps/ | |
| 36 | 24 | \ No newline at end of file |
| 25 | +spring.datasource.validation-query=select 1 | |
| 37 | 26 | \ No newline at end of file | ... | ... |
src/main/resources/logback.xml
| 1 | -<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | -<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"> --> | |
| 3 | -<configuration> | |
| 4 | - | |
| 5 | - <!-- <property resource="application.properties" /> --> | |
| 6 | - <property name="LOG_BASE" value="E:/control_interface_logs" /> | |
| 7 | - <!-- 控制台输出 --> | |
| 8 | - <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| 9 | - | |
| 10 | - <layout class="ch.qos.logback.classic.PatternLayout"> | |
| 11 | - <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 12 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] | |
| 13 | - %-5level-%msg%n | |
| 14 | - </pattern> | |
| 15 | - </layout> | |
| 16 | - </appender> | |
| 17 | - | |
| 18 | - <!-- 主日志文件 --> | |
| 19 | - <appender name="FILE" | |
| 20 | - class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 21 | - <file>${LOG_BASE}/main/main.log</file> | |
| 22 | - <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
| 23 | - <fileNamePattern>${LOG_BASE}/main/main-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 24 | - <timeBasedFileNamingAndTriggeringPolicy | |
| 25 | - class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |
| 26 | - <maxFileSize>100MB</maxFileSize> | |
| 27 | - </timeBasedFileNamingAndTriggeringPolicy> | |
| 28 | - </rollingPolicy> | |
| 29 | - <encoder> | |
| 30 | - <pattern>%msg%n</pattern> | |
| 31 | - </encoder> | |
| 32 | - | |
| 33 | - <layout class="ch.qos.logback.classic.PatternLayout"> | |
| 34 | - <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 35 | - <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] | |
| 36 | - %-5level-%msg%n | |
| 37 | - </pattern> | |
| 38 | - </layout> | |
| 39 | - </appender> | |
| 40 | - | |
| 41 | - | |
| 42 | - <!-- 日志输出级别 --> | |
| 43 | - <root level="info"> | |
| 44 | - <appender-ref ref="STDOUT" /> | |
| 45 | - <appender-ref ref="FILE" /> | |
| 46 | - </root> | |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"> --> | |
| 3 | +<configuration> | |
| 4 | + | |
| 5 | + <!-- <property resource="application.properties" /> --> | |
| 6 | + <property name="LOG_BASE" value="D:/control_interface_logs" /> | |
| 7 | + <!-- 控制台输出 --> | |
| 8 | + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
| 9 | + | |
| 10 | + <layout class="ch.qos.logback.classic.PatternLayout"> | |
| 11 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 12 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] | |
| 13 | + %-5level-%msg%n | |
| 14 | + </pattern> | |
| 15 | + </layout> | |
| 16 | + </appender> | |
| 17 | + | |
| 18 | + <!-- 主日志文件 --> | |
| 19 | + <appender name="FILE" | |
| 20 | + class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
| 21 | + <file>${LOG_BASE}/main/main.log</file> | |
| 22 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
| 23 | + <fileNamePattern>${LOG_BASE}/main/main-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |
| 24 | + <timeBasedFileNamingAndTriggeringPolicy | |
| 25 | + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |
| 26 | + <maxFileSize>100MB</maxFileSize> | |
| 27 | + </timeBasedFileNamingAndTriggeringPolicy> | |
| 28 | + </rollingPolicy> | |
| 29 | + <encoder> | |
| 30 | + <pattern>%msg%n</pattern> | |
| 31 | + </encoder> | |
| 32 | + | |
| 33 | + <layout class="ch.qos.logback.classic.PatternLayout"> | |
| 34 | + <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 --> | |
| 35 | + <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%file:%line] | |
| 36 | + %-5level-%msg%n | |
| 37 | + </pattern> | |
| 38 | + </layout> | |
| 39 | + </appender> | |
| 40 | + | |
| 41 | + | |
| 42 | + <!-- 日志输出级别 --> | |
| 43 | + <root level="info"> | |
| 44 | + <appender-ref ref="STDOUT" /> | |
| 45 | + <appender-ref ref="FILE" /> | |
| 46 | + </root> | |
| 47 | 47 | </configuration> |
| 48 | 48 | \ No newline at end of file | ... | ... |
src/main/resources/ms-jdbc.properties
| 1 | -#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 2 | -#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 3 | -#ms.mysql.username= root | |
| 4 | -#ms.mysql.password= panzhao | |
| 5 | - | |
| 6 | -ms.mysql.driver= com.mysql.jdbc.Driver | |
| 7 | -ms.mysql.url= jdbc:mysql://10.10.200.226:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 8 | -ms.mysql.username= root | |
| 9 | -ms.mysql.password= root2jsp | |
| 10 | 1 | \ No newline at end of file |
| 2 | +#ms.mysql.driver= com.mysql.jdbc.Driver | |
| 3 | +#ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 4 | +#ms.mysql.username= root | |
| 5 | +#ms.mysql.password= panzhao | |
| 6 | + | |
| 7 | +ms.mysql.driver= com.mysql.jdbc.Driver | |
| 8 | +ms.mysql.url= jdbc:mysql://127.0.0.1:3306/ms?useUnicode=true&characterEncoding=utf-8 | |
| 9 | +ms.mysql.username= root | |
| 10 | +ms.mysql.password= root | |
| 11 | 11 | \ No newline at end of file | ... | ... |