Commit 4f89d8ce4f5caf58fca8eedbd940abc85d93d0ce
1 parent
8ed700ee
给电科的油电接口,添加有加油无路单的车辆。
Showing
3 changed files
with
1023 additions
and
915 deletions
src/main/java/com/bsth/entity/ElecInfo.java
| ... | ... | @@ -23,6 +23,18 @@ public class ElecInfo implements Serializable { |
| 23 | 23 | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| 24 | 24 | private Date rq; |
| 25 | 25 | /** |
| 26 | + * 线路编码 | |
| 27 | + */ | |
| 28 | + private String xlbm; | |
| 29 | + /** | |
| 30 | + * 所属公司代码 | |
| 31 | + */ | |
| 32 | + private String ssgsdm; | |
| 33 | + /** | |
| 34 | + * 分公司代码 | |
| 35 | + */ | |
| 36 | + private String fgsdm; | |
| 37 | + /** | |
| 26 | 38 | * 内部编码 |
| 27 | 39 | */ |
| 28 | 40 | private String nbbm; |
| ... | ... | @@ -70,6 +82,30 @@ public class ElecInfo implements Serializable { |
| 70 | 82 | this.rq = rq; |
| 71 | 83 | } |
| 72 | 84 | |
| 85 | + public String getXlbm() { | |
| 86 | + return xlbm; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setXlbm(String xlbm) { | |
| 90 | + this.xlbm = xlbm; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getSsgsdm() { | |
| 94 | + return ssgsdm; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setSsgsdm(String ssgsdm) { | |
| 98 | + this.ssgsdm = ssgsdm; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getFgsdm() { | |
| 102 | + return fgsdm; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setFgsdm(String fgsdm) { | |
| 106 | + this.fgsdm = fgsdm; | |
| 107 | + } | |
| 108 | + | |
| 73 | 109 | public String getNbbm() { |
| 74 | 110 | return nbbm; |
| 75 | 111 | } | ... | ... |
src/main/java/com/bsth/redis/OilRedisService.java
| 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.joda.time.format.DateTimeFormat; | |
| 12 | -import org.slf4j.Logger; | |
| 13 | -import org.slf4j.LoggerFactory; | |
| 14 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | -import org.springframework.boot.CommandLineRunner; | |
| 16 | -import org.springframework.core.annotation.Order; | |
| 17 | -import org.springframework.data.redis.core.RedisTemplate; | |
| 18 | -import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 19 | -import org.springframework.stereotype.Component; | |
| 20 | -import org.springframework.stereotype.Service; | |
| 21 | - | |
| 22 | -import java.util.*; | |
| 23 | -import java.util.concurrent.TimeUnit; | |
| 24 | - | |
| 25 | -/** | |
| 26 | - * 油量数据Redis缓存 | |
| 27 | - * Created by panzhao on 2017/3/19. | |
| 28 | - */ | |
| 29 | -@Service | |
| 30 | -@Order(3) | |
| 31 | -public class OilRedisService implements CommandLineRunner { | |
| 32 | - | |
| 33 | - @Autowired | |
| 34 | - private RedisTemplate redisTemplate; | |
| 35 | - | |
| 36 | - @Autowired | |
| 37 | - OilInfoRepository oilInfoRepository; | |
| 38 | - | |
| 39 | - @Autowired | |
| 40 | - RedisUtils redisUtils; | |
| 41 | - | |
| 42 | - static Logger logger = LoggerFactory.getLogger(OilRedisService.class); | |
| 43 | - | |
| 44 | - private final static String REDIS_KEY_PREFIX = "oil:"; | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * 将油量数据写入redis | |
| 48 | - * | |
| 49 | - * @param list | |
| 50 | - */ | |
| 51 | - public void wirte(List<OilInfo> list) { | |
| 52 | - ArrayListMultimap<String, OilInfo> multimap; | |
| 53 | - try { | |
| 54 | - if (list.size() == 0) | |
| 55 | - return; | |
| 56 | - //按日期和线路分组数据 | |
| 57 | - Class clazz = OilInfo.class; | |
| 58 | - multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("rq")); | |
| 59 | - | |
| 60 | - //写入redis | |
| 61 | - Iterator<String> iterator = multimap.keySet().iterator(); | |
| 62 | - String key; | |
| 63 | - while (iterator.hasNext()) { | |
| 64 | - key = iterator.next(); | |
| 65 | - mergeData(key, multimap.get(key)); | |
| 66 | - } | |
| 67 | - } catch (Exception e) { | |
| 68 | - logger.error("", e); | |
| 69 | - } | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 74 | - * | |
| 75 | - * @param nbbmArray | |
| 76 | - * @param rq | |
| 77 | - * @return | |
| 78 | - */ | |
| 79 | - public ArrayListMultimap<String, OilInfo> findByNbbmGroup(Iterable<String> nbbmArray, String rq) { | |
| 80 | - ArrayListMultimap<String, OilInfo> rs = ArrayListMultimap.create(); | |
| 81 | - | |
| 82 | - rq = rq.replaceAll("-", ""); | |
| 83 | - try { | |
| 84 | - List<OilInfo> list = new ArrayList<>(); | |
| 85 | - Set<String> nbbms = new HashSet<>(); | |
| 86 | - for (String nbbm : nbbmArray) { | |
| 87 | - nbbm = nbbm.split("_")[1]; | |
| 88 | - if (!nbbms.contains(nbbm)) { | |
| 89 | - nbbms.add(nbbm); | |
| 90 | - list.addAll(read(nbbm, rq)); | |
| 91 | - } | |
| 92 | - } | |
| 93 | - Class clazz = OilInfo.class; | |
| 94 | - rs = new ConvertUtil().groupMultiList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 95 | - } catch (Exception e) { | |
| 96 | - logger.error("", e); | |
| 97 | - } | |
| 98 | - return rs; | |
| 99 | - } | |
| 100 | - | |
| 101 | - /** | |
| 102 | - * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 103 | - * | |
| 104 | - * @param nbbmArray | |
| 105 | - * @param rq | |
| 106 | - * @return | |
| 107 | - */ | |
| 108 | - public Map<String, OilInfo> findByNbbmGroupRaw(Iterable<String> nbbmArray, String rq) { | |
| 109 | - Map<String, OilInfo> rs = new HashMap<>(); | |
| 110 | - | |
| 111 | - rq = rq.replaceAll("-", ""); | |
| 112 | - try { | |
| 113 | - List<OilInfo> list = new ArrayList<>(); | |
| 114 | - for (String nbbm : nbbmArray) { | |
| 115 | - nbbm = nbbm.split("_")[1]; | |
| 116 | - list.addAll(read(nbbm, rq)); | |
| 117 | - } | |
| 118 | - Class clazz = OilInfo.class; | |
| 119 | - rs = new ConvertUtil().groupList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 120 | - } catch (Exception e) { | |
| 121 | - logger.error("", e); | |
| 122 | - } | |
| 123 | - return rs; | |
| 124 | - } | |
| 125 | - | |
| 126 | - /** | |
| 127 | - * 根据车辆和日期获取油耗数据,以 车辆 为key | |
| 128 | - * | |
| 129 | - * @param nbbmArray | |
| 130 | - * @param rq | |
| 131 | - * @return | |
| 132 | - */ | |
| 133 | - public ArrayListMultimap<String, OilInfo> findByNbbmGroup1(Iterable<String> nbbmArray, String rq) { | |
| 134 | - ArrayListMultimap<String, OilInfo> rs = ArrayListMultimap.create(); | |
| 135 | - | |
| 136 | - DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 137 | - try { | |
| 138 | - List<OilInfo> list = oilInfoRepository.findByDate(dateTime.toDate()); | |
| 139 | - Class clazz = OilInfo.class; | |
| 140 | - rs = new ConvertUtil().groupMultiList(list, "_", clazz.getDeclaredField("nbbm")); | |
| 141 | - } catch (Exception e) { | |
| 142 | - logger.error("", e); | |
| 143 | - } | |
| 144 | - return rs; | |
| 145 | - } | |
| 146 | - | |
| 147 | - public List<OilInfo> read(String nbbm, String rq) { | |
| 148 | - return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + nbbm + ":" + rq, 0, -1); | |
| 149 | - } | |
| 150 | - | |
| 151 | - /** | |
| 152 | - * 将 list 与redis里的数据合并 | |
| 153 | - * | |
| 154 | - * @param key | |
| 155 | - * @param list | |
| 156 | - */ | |
| 157 | - public void mergeData(String key, List<OilInfo> list) { | |
| 158 | - key = REDIS_KEY_PREFIX + key; | |
| 159 | - | |
| 160 | - //更新 直接覆盖更新 | |
| 161 | - redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 162 | - } | |
| 163 | - | |
| 164 | - @Autowired | |
| 165 | - OilRefreshThread oilRefreshThread; | |
| 166 | - | |
| 167 | - @Override | |
| 168 | - public void run(String... strings) throws Exception { | |
| 169 | - Application.mainServices.schedule(new Runnable() { | |
| 170 | - @Override | |
| 171 | - public void run() { | |
| 172 | - //启动加载油耗缓存 | |
| 173 | - synchData(null); | |
| 174 | - } | |
| 175 | - }, 30, TimeUnit.SECONDS); | |
| 176 | - | |
| 177 | - | |
| 178 | - //定时刷新油耗信息 | |
| 179 | - Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 60 * 40, 60 * 40, TimeUnit.SECONDS); | |
| 180 | - } | |
| 181 | - | |
| 182 | - /** | |
| 183 | - * 和数据库同步数据 | |
| 184 | - */ | |
| 185 | - public void synchData(Integer days) { | |
| 186 | - int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 187 | - if (null != days && days < cacheDays) | |
| 188 | - cacheDays = days; | |
| 189 | - //设置key 序列化器 | |
| 190 | - redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 191 | - | |
| 192 | - DateTime dt = new DateTime(); | |
| 193 | - dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | |
| 194 | - List<OilInfo> list = oilInfoRepository.findByDateLT(dt.toDate()); | |
| 195 | - //写入redis | |
| 196 | - wirte(list); | |
| 197 | - logger.info("刷新油耗数据, days: " + cacheDays + " -size: " + list.size() + " -LT: " + dt.toString("yyyy-MM-dd")); | |
| 198 | - } | |
| 199 | - | |
| 200 | - @Component | |
| 201 | - public static class OilRefreshThread extends Thread { | |
| 202 | - | |
| 203 | - @Autowired | |
| 204 | - OilRedisService oilRedisService; | |
| 205 | - | |
| 206 | - @Override | |
| 207 | - public void run() { | |
| 208 | - try { | |
| 209 | - oilRedisService.synchData(5); | |
| 210 | - } catch (Exception e) { | |
| 211 | - logger.error("", e); | |
| 212 | - } | |
| 213 | - } | |
| 214 | - } | |
| 215 | -} | |
| 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.joda.time.format.DateTimeFormat; | |
| 12 | +import org.slf4j.Logger; | |
| 13 | +import org.slf4j.LoggerFactory; | |
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 15 | +import org.springframework.boot.CommandLineRunner; | |
| 16 | +import org.springframework.core.annotation.Order; | |
| 17 | +import org.springframework.data.redis.core.RedisTemplate; | |
| 18 | +import org.springframework.data.redis.serializer.StringRedisSerializer; | |
| 19 | +import org.springframework.stereotype.Component; | |
| 20 | +import org.springframework.stereotype.Service; | |
| 21 | + | |
| 22 | +import java.util.*; | |
| 23 | +import java.util.concurrent.TimeUnit; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * 油量数据Redis缓存 | |
| 27 | + * Created by panzhao on 2017/3/19. | |
| 28 | + */ | |
| 29 | +@Service | |
| 30 | +@Order(3) | |
| 31 | +public class OilRedisService implements CommandLineRunner { | |
| 32 | + | |
| 33 | + @Autowired | |
| 34 | + private RedisTemplate redisTemplate; | |
| 35 | + | |
| 36 | + @Autowired | |
| 37 | + OilInfoRepository oilInfoRepository; | |
| 38 | + | |
| 39 | + @Autowired | |
| 40 | + RedisUtils redisUtils; | |
| 41 | + | |
| 42 | + static Logger logger = LoggerFactory.getLogger(OilRedisService.class); | |
| 43 | + | |
| 44 | + private final static String REDIS_KEY_PREFIX = "oil:"; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 将油量数据写入redis | |
| 48 | + * | |
| 49 | + * @param list | |
| 50 | + */ | |
| 51 | + public void wirte(List<OilInfo> list) { | |
| 52 | + ArrayListMultimap<String, OilInfo> multimap; | |
| 53 | + try { | |
| 54 | + if (list.size() == 0) | |
| 55 | + return; | |
| 56 | + //按日期和线路分组数据 | |
| 57 | + Class clazz = OilInfo.class; | |
| 58 | + multimap = new ConvertUtil().groupMultiList(list, ":", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("rq")); | |
| 59 | + | |
| 60 | + //写入redis | |
| 61 | + Iterator<String> iterator = multimap.keySet().iterator(); | |
| 62 | + String key; | |
| 63 | + while (iterator.hasNext()) { | |
| 64 | + key = iterator.next(); | |
| 65 | + mergeData(key, multimap.get(key)); | |
| 66 | + } | |
| 67 | + } catch (Exception e) { | |
| 68 | + logger.error("", e); | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 74 | + * | |
| 75 | + * @param nbbmArray | |
| 76 | + * @param rq | |
| 77 | + * @return | |
| 78 | + */ | |
| 79 | + public ArrayListMultimap<String, OilInfo> findByNbbmGroup(Iterable<String> nbbmArray, String rq) { | |
| 80 | + ArrayListMultimap<String, OilInfo> rs = ArrayListMultimap.create(); | |
| 81 | + | |
| 82 | + rq = rq.replaceAll("-", ""); | |
| 83 | + try { | |
| 84 | + List<OilInfo> list = new ArrayList<>(); | |
| 85 | + Set<String> nbbms = new HashSet<>(); | |
| 86 | + for (String nbbm : nbbmArray) { | |
| 87 | + nbbm = nbbm.split("_")[1]; | |
| 88 | + if (!nbbms.contains(nbbm)) { | |
| 89 | + nbbms.add(nbbm); | |
| 90 | + list.addAll(read(nbbm, rq)); | |
| 91 | + } | |
| 92 | + } | |
| 93 | + Class clazz = OilInfo.class; | |
| 94 | + rs = new ConvertUtil().groupMultiList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 95 | + } catch (Exception e) { | |
| 96 | + logger.error("", e); | |
| 97 | + } | |
| 98 | + return rs; | |
| 99 | + } | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 根据车辆和日期获取油耗数据,以 车辆_驾驶员 为key | |
| 103 | + * | |
| 104 | + * @param nbbmArray | |
| 105 | + * @param rq | |
| 106 | + * @return | |
| 107 | + */ | |
| 108 | + public Map<String, OilInfo> findByNbbmGroupRaw(Iterable<String> nbbmArray, String rq) { | |
| 109 | + Map<String, OilInfo> rs = new HashMap<>(); | |
| 110 | + | |
| 111 | + rq = rq.replaceAll("-", ""); | |
| 112 | + try { | |
| 113 | + List<OilInfo> list = new ArrayList<>(); | |
| 114 | + for (String nbbm : nbbmArray) { | |
| 115 | + nbbm = nbbm.split("_")[1]; | |
| 116 | + list.addAll(read(nbbm, rq)); | |
| 117 | + } | |
| 118 | + Class clazz = OilInfo.class; | |
| 119 | + rs = new ConvertUtil().groupList(list, "_", clazz.getDeclaredField("nbbm"), clazz.getDeclaredField("jsy")); | |
| 120 | + } catch (Exception e) { | |
| 121 | + logger.error("", e); | |
| 122 | + } | |
| 123 | + return rs; | |
| 124 | + } | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 根据车辆和日期获取油耗数据,以 车辆 为key | |
| 128 | + * | |
| 129 | + * @param nbbmArray | |
| 130 | + * @param rq | |
| 131 | + * @return | |
| 132 | + */ | |
| 133 | + public ArrayListMultimap<String, OilInfo> findByNbbmGroup1(Iterable<String> nbbmArray, String rq) { | |
| 134 | + ArrayListMultimap<String, OilInfo> rs = ArrayListMultimap.create(); | |
| 135 | + | |
| 136 | + DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 137 | + try { | |
| 138 | + List<OilInfo> list = oilInfoRepository.findByDate(dateTime.toDate()); | |
| 139 | + Class clazz = OilInfo.class; | |
| 140 | + rs = new ConvertUtil().groupMultiList(list, "_", clazz.getDeclaredField("nbbm")); | |
| 141 | + } catch (Exception e) { | |
| 142 | + logger.error("", e); | |
| 143 | + } | |
| 144 | + return rs; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public List<OilInfo> read(String nbbm, String rq) { | |
| 148 | + return redisTemplate.opsForList().range(REDIS_KEY_PREFIX + nbbm + ":" + rq, 0, -1); | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * 将 list 与redis里的数据合并 | |
| 153 | + * | |
| 154 | + * @param key | |
| 155 | + * @param list | |
| 156 | + */ | |
| 157 | + public void mergeData(String key, List<OilInfo> list) { | |
| 158 | + key = REDIS_KEY_PREFIX + key; | |
| 159 | + | |
| 160 | + //更新 直接覆盖更新 | |
| 161 | + redisTemplate.execute(redisUtils.getUpdateCallback(key, list)); | |
| 162 | + } | |
| 163 | + | |
| 164 | + @Autowired | |
| 165 | + OilRefreshThread oilRefreshThread; | |
| 166 | + | |
| 167 | + @Override | |
| 168 | + public void run(String... strings) throws Exception { | |
| 169 | + Application.mainServices.schedule(new Runnable() { | |
| 170 | + @Override | |
| 171 | + public void run() { | |
| 172 | + //启动加载油耗缓存 | |
| 173 | + synchData(null); | |
| 174 | + } | |
| 175 | + }, 30, TimeUnit.SECONDS); | |
| 176 | + | |
| 177 | + | |
| 178 | + //定时刷新油耗信息 | |
| 179 | + Application.mainServices.scheduleWithFixedDelay(oilRefreshThread, 60 * 40, 60 * 40, TimeUnit.SECONDS); | |
| 180 | + } | |
| 181 | + | |
| 182 | + /** | |
| 183 | + * 和数据库同步数据 | |
| 184 | + */ | |
| 185 | + public void synchData(Integer days) { | |
| 186 | + int cacheDays = Integer.parseInt(ConfigUtil.get("cache.days")); | |
| 187 | + if (null != days && days < cacheDays) | |
| 188 | + cacheDays = days; | |
| 189 | + //设置key 序列化器 | |
| 190 | + redisTemplate.setKeySerializer(new StringRedisSerializer()); | |
| 191 | + | |
| 192 | + DateTime dt = new DateTime(); | |
| 193 | + dt = dt.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).minusDays(cacheDays); | |
| 194 | + List<OilInfo> list = oilInfoRepository.findByDateLT(dt.toDate()); | |
| 195 | + //写入redis | |
| 196 | + wirte(list); | |
| 197 | + logger.info("刷新油耗数据, days: " + cacheDays + " -size: " + list.size() + " -LT: " + dt.toString("yyyy-MM-dd")); | |
| 198 | + } | |
| 199 | + | |
| 200 | + @Component | |
| 201 | + public static class OilRefreshThread extends Thread { | |
| 202 | + | |
| 203 | + @Autowired | |
| 204 | + OilRedisService oilRedisService; | |
| 205 | + | |
| 206 | + @Override | |
| 207 | + public void run() { | |
| 208 | + try { | |
| 209 | + oilRedisService.synchData(5); | |
| 210 | + } catch (Exception e) { | |
| 211 | + logger.error("", e); | |
| 212 | + } | |
| 213 | + } | |
| 214 | + } | |
| 215 | +} | ... | ... |
src/main/java/com/bsth/server_rs/dks/DksRestService.java
| 1 | -package com.bsth.server_rs.dks; | |
| 2 | - | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | -import com.bsth.entity.ElecInfo; | |
| 5 | -import com.bsth.entity.OilInfo; | |
| 6 | -import com.bsth.entity.SchedulePlanInfo; | |
| 7 | -import com.bsth.entity.ScheduleRealInfo; | |
| 8 | -import com.bsth.redis.ElecRedisService; | |
| 9 | -import com.bsth.redis.OilRedisService; | |
| 10 | -import com.bsth.redis.ScheduleRedisService; | |
| 11 | -import com.bsth.repository.SchedulePlanInfoRepository; | |
| 12 | -import com.bsth.repository.ScheduleRealInfoRepository; | |
| 13 | -import com.bsth.server_rs.base_info.line.Line; | |
| 14 | -import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 15 | -import com.bsth.server_ws.util.ScheduleCalculator; | |
| 16 | -import com.bsth.util.Arith; | |
| 17 | -import com.google.common.collect.ArrayListMultimap; | |
| 18 | -import org.joda.time.DateTime; | |
| 19 | -import org.joda.time.format.DateTimeFormat; | |
| 20 | -import org.slf4j.Logger; | |
| 21 | -import org.slf4j.LoggerFactory; | |
| 22 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 23 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 24 | -import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 25 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 26 | -import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 27 | -import org.springframework.scheduling.annotation.EnableScheduling; | |
| 28 | -import org.springframework.scheduling.annotation.Scheduled; | |
| 29 | -import org.springframework.stereotype.Component; | |
| 30 | -import org.springframework.transaction.TransactionDefinition; | |
| 31 | -import org.springframework.transaction.TransactionStatus; | |
| 32 | -import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 33 | -import org.springframework.util.StringUtils; | |
| 34 | - | |
| 35 | -import javax.ws.rs.*; | |
| 36 | -import javax.ws.rs.core.MediaType; | |
| 37 | -import java.sql.PreparedStatement; | |
| 38 | -import java.sql.SQLException; | |
| 39 | -import java.util.*; | |
| 40 | - | |
| 41 | -/** | |
| 42 | - * @author Hill | |
| 43 | - * @date 2021-09 | |
| 44 | - */ | |
| 45 | -@Component | |
| 46 | -@EnableScheduling | |
| 47 | -@Path("/dks") | |
| 48 | -@Produces({MediaType.APPLICATION_JSON}) | |
| 49 | -public class DksRestService { | |
| 50 | - | |
| 51 | - private final static Logger log = LoggerFactory.getLogger(DksRestService.class); | |
| 52 | - | |
| 53 | - @Autowired | |
| 54 | - private JdbcTemplate jdbcTemplate; | |
| 55 | - | |
| 56 | - @Autowired | |
| 57 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 58 | - | |
| 59 | - @Autowired | |
| 60 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 61 | - | |
| 62 | - @Autowired | |
| 63 | - private ScheduleRedisService scheduleRedisService; | |
| 64 | - | |
| 65 | - @Autowired | |
| 66 | - private OilRedisService oilRedisService; | |
| 67 | - | |
| 68 | - @Autowired | |
| 69 | - private ElecRedisService elecRedisService; | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * 根据日期统计数据重新计算 | |
| 73 | - * @param rq | |
| 74 | - */ | |
| 75 | - @GET | |
| 76 | - @Path("/reCompute/{rq}") | |
| 77 | - public void reStatisticalComputation(@PathParam("rq") String rq) { | |
| 78 | - DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 79 | - planComputation(dateTime); | |
| 80 | - realComputation(dateTime); | |
| 81 | - carMileageComputation(dateTime); | |
| 82 | - } | |
| 83 | - | |
| 84 | - /** | |
| 85 | - * | |
| 86 | - */ | |
| 87 | - private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) { | |
| 88 | - List<LineServiceConfigVo> result = new ArrayList<>(); | |
| 89 | - String oldLineCode = ""; | |
| 90 | - LineServiceConfigVo vo = null; | |
| 91 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 92 | - LineServiceConfig config = configs.get(i); | |
| 93 | - if (i == 0) { | |
| 94 | - oldLineCode = config.getLineCode(); | |
| 95 | - vo = new LineServiceConfigVo(); | |
| 96 | - vo.setLineName(config.getLineName()); | |
| 97 | - vo.setMonth(month); | |
| 98 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 99 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 100 | - } else if (i == len - 1) { | |
| 101 | - result.add(vo); | |
| 102 | - } else { | |
| 103 | - if (!oldLineCode.equals(config.getLineCode())) { | |
| 104 | - oldLineCode = config.getLineCode(); | |
| 105 | - result.add(vo); | |
| 106 | - vo = new LineServiceConfigVo(); | |
| 107 | - vo.setLineName(config.getLineName()); | |
| 108 | - vo.setMonth(month); | |
| 109 | - vo.setConductorFirstCount(config.getConductorCount()); | |
| 110 | - vo.setDriverFirstCount(config.getDriverCount()); | |
| 111 | - } | |
| 112 | - } | |
| 113 | - vo.setConductorLastCount(config.getConductorCount()); | |
| 114 | - vo.setDriverLastCount(config.getDriverCount()); | |
| 115 | - } | |
| 116 | - | |
| 117 | - return result; | |
| 118 | - } | |
| 119 | - | |
| 120 | - /** | |
| 121 | - * 计划司售配档数 | |
| 122 | - * @param month | |
| 123 | - */ | |
| 124 | - @GET | |
| 125 | - @Path("/plan/{month}") | |
| 126 | - public List<LineServiceConfigVo> plan(@PathParam("month") String month) { | |
| 127 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 128 | - return reGroup(configs, month); | |
| 129 | - } | |
| 130 | - | |
| 131 | - /** | |
| 132 | - * 实际司售配档数 | |
| 133 | - * @param month | |
| 134 | - */ | |
| 135 | - @GET | |
| 136 | - @Path("/actual/{month}") | |
| 137 | - public List<LineServiceConfigVo> actual(@PathParam("month") String month) { | |
| 138 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 139 | - return reGroup(configs, month); | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * 计划配车数 | |
| 144 | - * @param month | |
| 145 | - */ | |
| 146 | - @GET | |
| 147 | - @Path("/bus/plan/{month}") | |
| 148 | - public List<BusVo> busPlan(@PathParam("month") String month) { | |
| 149 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 150 | - List<BusVo> result = new ArrayList<>(); | |
| 151 | - String oldLineCode = ""; | |
| 152 | - BusVo vo = null; | |
| 153 | - int max = 0; | |
| 154 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 155 | - LineServiceConfig config = configs.get(i); | |
| 156 | - if (i == 0) { | |
| 157 | - oldLineCode = config.getLineCode(); | |
| 158 | - vo = new BusVo(); | |
| 159 | - vo.setLineName(config.getLineName()); | |
| 160 | - vo.setMonth(month); | |
| 161 | - vo.setBusFirstCount(config.getCarCount()); | |
| 162 | - } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 163 | - oldLineCode = config.getLineCode(); | |
| 164 | - vo.setBusMaxCount(max); | |
| 165 | - result.add(vo); | |
| 166 | - max = 0; | |
| 167 | - vo = new BusVo(); | |
| 168 | - vo.setLineName(config.getLineName()); | |
| 169 | - vo.setMonth(month); | |
| 170 | - vo.setBusFirstCount(config.getCarCount()); | |
| 171 | - } | |
| 172 | - max = Math.max(max, config.getCarCount()); | |
| 173 | - if (i == len - 1) { | |
| 174 | - vo.setBusMaxCount(max); | |
| 175 | - result.add(vo); | |
| 176 | - } | |
| 177 | - vo.setBusLastCount(config.getCarCount()); | |
| 178 | - } | |
| 179 | - | |
| 180 | - return result; | |
| 181 | - } | |
| 182 | - | |
| 183 | - /** | |
| 184 | - * 实际配车数 | |
| 185 | - * @param month | |
| 186 | - */ | |
| 187 | - @GET | |
| 188 | - @Path("/bus/{month}") | |
| 189 | - public List<BusVo> bus(@PathParam("month") String month) { | |
| 190 | - List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 191 | - List<BusVo> result = new ArrayList<>(); | |
| 192 | - String oldLineCode = ""; | |
| 193 | - BusVo vo = null; | |
| 194 | - int max = 0; | |
| 195 | - for (int i = 0, len = configs.size();i < len;i++) { | |
| 196 | - LineServiceConfig config = configs.get(i); | |
| 197 | - if (i == 0) { | |
| 198 | - oldLineCode = config.getLineCode(); | |
| 199 | - vo = new BusVo(); | |
| 200 | - vo.setLineName(config.getLineName()); | |
| 201 | - vo.setMonth(month); | |
| 202 | - vo.setBusFirstCount(config.getCarCount()); | |
| 203 | - } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 204 | - oldLineCode = config.getLineCode(); | |
| 205 | - vo.setBusMaxCount(max); | |
| 206 | - result.add(vo); | |
| 207 | - max = 0; | |
| 208 | - vo = new BusVo(); | |
| 209 | - vo.setLineName(config.getLineName()); | |
| 210 | - vo.setMonth(month); | |
| 211 | - vo.setBusFirstCount(config.getCarCount()); | |
| 212 | - } | |
| 213 | - max = Math.max(max, config.getCarCount()); | |
| 214 | - if (i == len - 1) { | |
| 215 | - vo.setBusMaxCount(max); | |
| 216 | - result.add(vo); | |
| 217 | - } | |
| 218 | - vo.setBusLastCount(config.getCarCount()); | |
| 219 | - } | |
| 220 | - | |
| 221 | - return result; | |
| 222 | - } | |
| 223 | - | |
| 224 | - /** | |
| 225 | - * 车辆公里、油耗数据 | |
| 226 | - * @param month | |
| 227 | - */ | |
| 228 | - @GET | |
| 229 | - @Path("/mileage/{month}") | |
| 230 | - public List<BusMileageVo> mileage(@PathParam("month") String month) { | |
| 231 | - List<BusMileage> mileages = jdbcTemplate.query("select company, company_code, nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by company, company_code, nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class)); | |
| 232 | - List<BusMileageVo> result = new ArrayList<>(); | |
| 233 | - for (BusMileage mileage : mileages) { | |
| 234 | - BusMileageVo vo = new BusMileageVo(); | |
| 235 | - vo.setMonth(mileage.getScheduleDate()); | |
| 236 | - vo.setInsideCode(mileage.getNbbm()); | |
| 237 | - vo.setTotalMileage(mileage.getZlc()); | |
| 238 | - vo.setOilConsume(mileage.getYh()); | |
| 239 | - vo.setElectricConsume(mileage.getDh()); | |
| 240 | - vo.setCompany(mileage.getCompany()); | |
| 241 | - vo.setCompanyCode(mileage.getCompanyCode()); | |
| 242 | - | |
| 243 | - result.add(vo); | |
| 244 | - } | |
| 245 | - | |
| 246 | - return result; | |
| 247 | - } | |
| 248 | - | |
| 249 | - @Scheduled(cron = "0 0/25 23 * * ?") | |
| 250 | - public void statisticalComputation() { | |
| 251 | - log.info("执行电科所接口数据统计计算"); | |
| 252 | - DateTime dateTime = DateTime.now().plusDays(1); | |
| 253 | - try { | |
| 254 | - for (int i = 0;i < 3;i++) { | |
| 255 | - dateTime = dateTime.minusDays(1); | |
| 256 | - planComputation(dateTime); | |
| 257 | - realComputation(dateTime); | |
| 258 | - carMileageComputation(dateTime); | |
| 259 | - } | |
| 260 | - } catch (Exception e) { | |
| 261 | - e.printStackTrace(); | |
| 262 | - } | |
| 263 | - } | |
| 264 | - | |
| 265 | - /** | |
| 266 | - * 计划排班中的线路司售配档数 | |
| 267 | - */ | |
| 268 | - private void planComputation(DateTime dateTime) { | |
| 269 | - // 记录实际线路司售配档情况 | |
| 270 | - List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); | |
| 271 | - Set<String> lineCodes = new HashSet<>(); | |
| 272 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 273 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 274 | - for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | |
| 275 | - String lineCode = schedulePlanInfo.getXlBm(); | |
| 276 | - lineCodes.add(lineCode); | |
| 277 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 278 | - if (conductors == null) { | |
| 279 | - conductors = new HashSet<>(); | |
| 280 | - line2conductors.put(lineCode, conductors); | |
| 281 | - } | |
| 282 | - if (drivers == null) { | |
| 283 | - drivers = new HashSet<>(); | |
| 284 | - line2drivers.put(lineCode, drivers); | |
| 285 | - } | |
| 286 | - if (cars == null) { | |
| 287 | - cars = new HashSet<>(); | |
| 288 | - line2cars.put(lineCode, cars); | |
| 289 | - } | |
| 290 | - if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { | |
| 291 | - conductors.add(schedulePlanInfo.getsGh()); | |
| 292 | - } | |
| 293 | - drivers.add(schedulePlanInfo.getjGh()); | |
| 294 | - cars.add(schedulePlanInfo.getClZbh()); | |
| 295 | - } | |
| 296 | - for (String lineCode : lineCodes) { | |
| 297 | - LineServiceConfig object = new LineServiceConfig(); | |
| 298 | - Line line = LineBufferData.findOne(lineCode); | |
| 299 | - object.setLineCode(lineCode); | |
| 300 | - object.setLineName(line == null ? "" : line.getName()); | |
| 301 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 302 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 303 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 304 | - object.setCarCount(line2cars.get(lineCode).size()); | |
| 305 | - | |
| 306 | - objects.add(object); | |
| 307 | - } | |
| 308 | - | |
| 309 | - //编程式事务 | |
| 310 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 311 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 312 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 313 | - TransactionStatus status = tran.getTransaction(def); | |
| 314 | - | |
| 315 | - try { | |
| 316 | - jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 317 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 318 | - @Override | |
| 319 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 320 | - LineServiceConfig object = objects.get(i); | |
| 321 | - ps.setString(1, object.getLineCode()); | |
| 322 | - ps.setString(2, object.getLineName()); | |
| 323 | - ps.setString(3, object.getScheduleDate()); | |
| 324 | - ps.setInt(4, object.getConductorCount()); | |
| 325 | - ps.setInt(5, object.getDriverCount()); | |
| 326 | - ps.setInt(6, object.getCarCount()); | |
| 327 | - } | |
| 328 | - | |
| 329 | - @Override | |
| 330 | - public int getBatchSize() { | |
| 331 | - return objects.size(); | |
| 332 | - } | |
| 333 | - }); | |
| 334 | - tran.commit(status); | |
| 335 | - } catch (Exception e) { | |
| 336 | - tran.rollback(status); | |
| 337 | - } | |
| 338 | - } | |
| 339 | - | |
| 340 | - /** | |
| 341 | - * 实际排班中的线路司售配档数 | |
| 342 | - */ | |
| 343 | - private void realComputation(DateTime dateTime) { | |
| 344 | - // 记录实际线路司售配档情况 | |
| 345 | - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd")); | |
| 346 | - Set<String> lineCodes = new HashSet<>(); | |
| 347 | - Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 348 | - final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 349 | - for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 350 | - // 烂班班次不计入配档数 | |
| 351 | - if (scheduleRealInfo.getStatus() == -1) { continue; } | |
| 352 | - String lineCode = scheduleRealInfo.getXlBm(); | |
| 353 | - lineCodes.add(lineCode); | |
| 354 | - Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 355 | - if (conductors == null) { | |
| 356 | - conductors = new HashSet<>(); | |
| 357 | - line2conductors.put(lineCode, conductors); | |
| 358 | - } | |
| 359 | - if (drivers == null) { | |
| 360 | - drivers = new HashSet<>(); | |
| 361 | - line2drivers.put(lineCode, drivers); | |
| 362 | - } | |
| 363 | - if (cars == null) { | |
| 364 | - cars = new HashSet<>(); | |
| 365 | - line2cars.put(lineCode, cars); | |
| 366 | - } | |
| 367 | - if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) { | |
| 368 | - conductors.add(scheduleRealInfo.getsGh()); | |
| 369 | - } | |
| 370 | - drivers.add(scheduleRealInfo.getjGh()); | |
| 371 | - cars.add(scheduleRealInfo.getClZbh()); | |
| 372 | - } | |
| 373 | - for (String lineCode : lineCodes) { | |
| 374 | - LineServiceConfig object = new LineServiceConfig(); | |
| 375 | - Line line = LineBufferData.findOne(lineCode); | |
| 376 | - object.setLineCode(lineCode); | |
| 377 | - object.setLineName(line == null ? "" : line.getName()); | |
| 378 | - object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 379 | - object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 380 | - object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 381 | - object.setCarCount(line2cars.get(lineCode).size()); | |
| 382 | - | |
| 383 | - objects.add(object); | |
| 384 | - } | |
| 385 | - | |
| 386 | - //编程式事务 | |
| 387 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 388 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 389 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 390 | - TransactionStatus status = tran.getTransaction(def); | |
| 391 | - try { | |
| 392 | - jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 393 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 394 | - @Override | |
| 395 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 396 | - LineServiceConfig object = objects.get(i); | |
| 397 | - ps.setString(1, object.getLineCode()); | |
| 398 | - ps.setString(2, object.getLineName()); | |
| 399 | - ps.setString(3, object.getScheduleDate()); | |
| 400 | - ps.setInt(4, object.getConductorCount()); | |
| 401 | - ps.setInt(5, object.getDriverCount()); | |
| 402 | - ps.setInt(6, object.getCarCount()); | |
| 403 | - } | |
| 404 | - | |
| 405 | - @Override | |
| 406 | - public int getBatchSize() { | |
| 407 | - return objects.size(); | |
| 408 | - } | |
| 409 | - }); | |
| 410 | - tran.commit(status); | |
| 411 | - } catch (Exception e) { | |
| 412 | - tran.rollback(status); | |
| 413 | - } | |
| 414 | - } | |
| 415 | - | |
| 416 | - private void carMileageComputation(final DateTime dateTime) { | |
| 417 | - String rq = dateTime.toString("yyyy-MM-dd"); | |
| 418 | - // 实际排班信息 | |
| 419 | - ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq); | |
| 420 | - // 油耗信息 | |
| 421 | - ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 422 | - //电耗信息 | |
| 423 | - ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 424 | - Set<String> nbbms = nbbm2schedules.keySet(); | |
| 425 | - final List<BusMileage> busMileages = new ArrayList<>(); | |
| 426 | - for (String nbbm : nbbms) { | |
| 427 | - List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 428 | - if (scheduleRealInfos.size() == 0) { | |
| 429 | - continue; | |
| 430 | - } | |
| 431 | - ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(0); | |
| 432 | - BusMileage busMileage = new BusMileage(); | |
| 433 | - busMileage.setScheduleDate(rq); | |
| 434 | - busMileage.setNbbm(nbbm); | |
| 435 | - busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos)); | |
| 436 | - busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos)); | |
| 437 | - busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos)); | |
| 438 | - busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos)); | |
| 439 | - busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos)); | |
| 440 | - busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos)); | |
| 441 | - busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos)); | |
| 442 | - busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos)); | |
| 443 | - busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos)); | |
| 444 | - busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos)); | |
| 445 | - List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 446 | - List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 447 | - Double yh = 0.0, dh = 0.0; | |
| 448 | - for (OilInfo oilInfo : oilInfos) { | |
| 449 | - yh = Arith.add(yh, oilInfo.getYh()); | |
| 450 | - } | |
| 451 | - for (ElecInfo elecInfo : elecInfos) { | |
| 452 | - dh = Arith.add(yh, elecInfo.getHd()); | |
| 453 | - } | |
| 454 | - busMileage.setYh(yh); | |
| 455 | - busMileage.setDh(dh); | |
| 456 | - busMileage.setCompany(scheduleRealInfo.getGsName()); | |
| 457 | - busMileage.setCompanyCode(scheduleRealInfo.getGsBm()); | |
| 458 | - | |
| 459 | - busMileages.add(busMileage); | |
| 460 | - } | |
| 461 | - | |
| 462 | - //编程式事务 | |
| 463 | - DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 464 | - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 465 | - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 466 | - TransactionStatus status = tran.getTransaction(def); | |
| 467 | - try { | |
| 468 | - jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 469 | - jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month,company,company_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 470 | - @Override | |
| 471 | - public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 472 | - BusMileage busMileage = busMileages.get(i); | |
| 473 | - ps.setString(1, busMileage.getScheduleDate()); | |
| 474 | - ps.setString(2, busMileage.getNbbm()); | |
| 475 | - ps.setDouble(3, busMileage.getJhlc()); | |
| 476 | - ps.setDouble(4, busMileage.getSjjhlc()); | |
| 477 | - ps.setDouble(5, busMileage.getSjcclc()); | |
| 478 | - ps.setDouble(6, busMileage.getSjjclc()); | |
| 479 | - ps.setDouble(7, busMileage.getYylc()); | |
| 480 | - ps.setDouble(8, busMileage.getKslc()); | |
| 481 | - ps.setDouble(9, busMileage.getCjlc()); | |
| 482 | - ps.setDouble(10, busMileage.getLblc()); | |
| 483 | - ps.setDouble(11, busMileage.getZjlc()); | |
| 484 | - ps.setDouble(12, busMileage.getZlc()); | |
| 485 | - ps.setDouble(13, busMileage.getYh()); | |
| 486 | - ps.setDouble(14, busMileage.getDh()); | |
| 487 | - ps.setString(15, dateTime.toString("yyyy-MM")); | |
| 488 | - ps.setString(16, busMileage.getCompany()); | |
| 489 | - ps.setString(17, busMileage.getCompanyCode()); | |
| 490 | - } | |
| 491 | - | |
| 492 | - @Override | |
| 493 | - public int getBatchSize() { | |
| 494 | - return busMileages.size(); | |
| 495 | - } | |
| 496 | - }); | |
| 497 | - tran.commit(status); | |
| 498 | - } catch (Exception e) { | |
| 499 | - tran.rollback(status); | |
| 500 | - } | |
| 501 | - } | |
| 502 | - | |
| 503 | - /** | |
| 504 | - * 线路司售配档对象 | |
| 505 | - */ | |
| 506 | - private final static class LineServiceConfigVo { | |
| 507 | - | |
| 508 | - private String lineName; | |
| 509 | - | |
| 510 | - private String month; | |
| 511 | - | |
| 512 | - private Integer driverFirstCount; | |
| 513 | - | |
| 514 | - private Integer driverLastCount; | |
| 515 | - | |
| 516 | - private Integer conductorFirstCount; | |
| 517 | - | |
| 518 | - private Integer conductorLastCount; | |
| 519 | - | |
| 520 | - public String getLineName() { | |
| 521 | - return lineName; | |
| 522 | - } | |
| 523 | - | |
| 524 | - public void setLineName(String lineName) { | |
| 525 | - this.lineName = lineName; | |
| 526 | - } | |
| 527 | - | |
| 528 | - public String getMonth() { | |
| 529 | - return month; | |
| 530 | - } | |
| 531 | - | |
| 532 | - public void setMonth(String month) { | |
| 533 | - this.month = month; | |
| 534 | - } | |
| 535 | - | |
| 536 | - public Integer getDriverFirstCount() { | |
| 537 | - return driverFirstCount; | |
| 538 | - } | |
| 539 | - | |
| 540 | - public void setDriverFirstCount(Integer driverFirstCount) { | |
| 541 | - this.driverFirstCount = driverFirstCount; | |
| 542 | - } | |
| 543 | - | |
| 544 | - public Integer getDriverLastCount() { | |
| 545 | - return driverLastCount; | |
| 546 | - } | |
| 547 | - | |
| 548 | - public void setDriverLastCount(Integer driverLastCount) { | |
| 549 | - this.driverLastCount = driverLastCount; | |
| 550 | - } | |
| 551 | - | |
| 552 | - public Integer getConductorFirstCount() { | |
| 553 | - return conductorFirstCount; | |
| 554 | - } | |
| 555 | - | |
| 556 | - public void setConductorFirstCount(Integer conductorFirstCount) { | |
| 557 | - this.conductorFirstCount = conductorFirstCount; | |
| 558 | - } | |
| 559 | - | |
| 560 | - public Integer getConductorLastCount() { | |
| 561 | - return conductorLastCount; | |
| 562 | - } | |
| 563 | - | |
| 564 | - public void setConductorLastCount(Integer conductorLastCount) { | |
| 565 | - this.conductorLastCount = conductorLastCount; | |
| 566 | - } | |
| 567 | - } | |
| 568 | - | |
| 569 | - /** | |
| 570 | - * 车辆配档对象 | |
| 571 | - */ | |
| 572 | - private final static class BusVo { | |
| 573 | - | |
| 574 | - private String lineName; | |
| 575 | - | |
| 576 | - private String month; | |
| 577 | - | |
| 578 | - private Integer busFirstCount; | |
| 579 | - | |
| 580 | - private Integer busLastCount; | |
| 581 | - | |
| 582 | - private Integer busMaxCount; | |
| 583 | - | |
| 584 | - public String getLineName() { | |
| 585 | - return lineName; | |
| 586 | - } | |
| 587 | - | |
| 588 | - public void setLineName(String lineName) { | |
| 589 | - this.lineName = lineName; | |
| 590 | - } | |
| 591 | - | |
| 592 | - public String getMonth() { | |
| 593 | - return month; | |
| 594 | - } | |
| 595 | - | |
| 596 | - public void setMonth(String month) { | |
| 597 | - this.month = month; | |
| 598 | - } | |
| 599 | - | |
| 600 | - public Integer getBusFirstCount() { | |
| 601 | - return busFirstCount; | |
| 602 | - } | |
| 603 | - | |
| 604 | - public void setBusFirstCount(Integer busFirstCount) { | |
| 605 | - this.busFirstCount = busFirstCount; | |
| 606 | - } | |
| 607 | - | |
| 608 | - public Integer getBusLastCount() { | |
| 609 | - return busLastCount; | |
| 610 | - } | |
| 611 | - | |
| 612 | - public void setBusLastCount(Integer busLastCount) { | |
| 613 | - this.busLastCount = busLastCount; | |
| 614 | - } | |
| 615 | - | |
| 616 | - public Integer getBusMaxCount() { | |
| 617 | - return busMaxCount; | |
| 618 | - } | |
| 619 | - | |
| 620 | - public void setBusMaxCount(Integer busMaxCount) { | |
| 621 | - this.busMaxCount = busMaxCount; | |
| 622 | - } | |
| 623 | - } | |
| 624 | - | |
| 625 | - /** | |
| 626 | - * 车辆公里、油耗对象 | |
| 627 | - */ | |
| 628 | - private final static class BusMileageVo { | |
| 629 | - | |
| 630 | - private String insideCode; | |
| 631 | - | |
| 632 | - private String month; | |
| 633 | - | |
| 634 | - private Double totalMileage; | |
| 635 | - | |
| 636 | - private Double oilConsume; | |
| 637 | - | |
| 638 | - private Double electricConsume; | |
| 639 | - | |
| 640 | - private String company; | |
| 641 | - | |
| 642 | - private String companyCode; | |
| 643 | - | |
| 644 | - public String getInsideCode() { | |
| 645 | - return insideCode; | |
| 646 | - } | |
| 647 | - | |
| 648 | - public void setInsideCode(String insideCode) { | |
| 649 | - this.insideCode = insideCode; | |
| 650 | - } | |
| 651 | - | |
| 652 | - public String getMonth() { | |
| 653 | - return month; | |
| 654 | - } | |
| 655 | - | |
| 656 | - public void setMonth(String month) { | |
| 657 | - this.month = month; | |
| 658 | - } | |
| 659 | - | |
| 660 | - public Double getTotalMileage() { | |
| 661 | - return totalMileage; | |
| 662 | - } | |
| 663 | - | |
| 664 | - public void setTotalMileage(Double totalMileage) { | |
| 665 | - this.totalMileage = totalMileage; | |
| 666 | - } | |
| 667 | - | |
| 668 | - public Double getOilConsume() { | |
| 669 | - return oilConsume; | |
| 670 | - } | |
| 671 | - | |
| 672 | - public void setOilConsume(Double oilConsume) { | |
| 673 | - this.oilConsume = oilConsume; | |
| 674 | - } | |
| 675 | - | |
| 676 | - public Double getElectricConsume() { | |
| 677 | - return electricConsume; | |
| 678 | - } | |
| 679 | - | |
| 680 | - public void setElectricConsume(Double electricConsume) { | |
| 681 | - this.electricConsume = electricConsume; | |
| 682 | - } | |
| 683 | - | |
| 684 | - public String getCompany() { | |
| 685 | - return company; | |
| 686 | - } | |
| 687 | - | |
| 688 | - public void setCompany(String company) { | |
| 689 | - this.company = company; | |
| 690 | - } | |
| 691 | - | |
| 692 | - public String getCompanyCode() { | |
| 693 | - return companyCode; | |
| 694 | - } | |
| 695 | - | |
| 696 | - public void setCompanyCode(String companyCode) { | |
| 697 | - this.companyCode = companyCode; | |
| 698 | - } | |
| 699 | - } | |
| 700 | -} | |
| 1 | +package com.bsth.server_rs.dks; | |
| 2 | + | |
| 3 | +import com.alibaba.fastjson.JSON; | |
| 4 | +import com.bsth.common.BusinessCodeData; | |
| 5 | +import com.bsth.entity.ElecInfo; | |
| 6 | +import com.bsth.entity.OilInfo; | |
| 7 | +import com.bsth.entity.SchedulePlanInfo; | |
| 8 | +import com.bsth.entity.ScheduleRealInfo; | |
| 9 | +import com.bsth.redis.ElecRedisService; | |
| 10 | +import com.bsth.redis.OilRedisService; | |
| 11 | +import com.bsth.redis.ScheduleRedisService; | |
| 12 | +import com.bsth.repository.SchedulePlanInfoRepository; | |
| 13 | +import com.bsth.repository.ScheduleRealInfoRepository; | |
| 14 | +import com.bsth.server_rs.base_info.line.Line; | |
| 15 | +import com.bsth.server_rs.base_info.line.buffer.LineBufferData; | |
| 16 | +import com.bsth.server_ws.util.ScheduleCalculator; | |
| 17 | +import com.bsth.util.Arith; | |
| 18 | +import com.google.common.collect.ArrayListMultimap; | |
| 19 | +import org.joda.time.DateTime; | |
| 20 | +import org.joda.time.format.DateTimeFormat; | |
| 21 | +import org.slf4j.Logger; | |
| 22 | +import org.slf4j.LoggerFactory; | |
| 23 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 24 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 25 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | |
| 26 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 27 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 28 | +import org.springframework.scheduling.annotation.EnableScheduling; | |
| 29 | +import org.springframework.scheduling.annotation.Scheduled; | |
| 30 | +import org.springframework.stereotype.Component; | |
| 31 | +import org.springframework.transaction.TransactionDefinition; | |
| 32 | +import org.springframework.transaction.TransactionStatus; | |
| 33 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | |
| 34 | +import org.springframework.util.StringUtils; | |
| 35 | + | |
| 36 | +import javax.ws.rs.*; | |
| 37 | +import javax.ws.rs.core.MediaType; | |
| 38 | +import java.sql.PreparedStatement; | |
| 39 | +import java.sql.SQLException; | |
| 40 | +import java.util.*; | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * @author Hill | |
| 44 | + * @date 2021-09 | |
| 45 | + */ | |
| 46 | +@Component | |
| 47 | +@EnableScheduling | |
| 48 | +@Path("/dks") | |
| 49 | +@Produces({MediaType.APPLICATION_JSON}) | |
| 50 | +public class DksRestService { | |
| 51 | + | |
| 52 | + private final static Logger log = LoggerFactory.getLogger(DksRestService.class); | |
| 53 | + | |
| 54 | + @Autowired | |
| 55 | + private JdbcTemplate jdbcTemplate; | |
| 56 | + | |
| 57 | + @Autowired | |
| 58 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 59 | + | |
| 60 | + @Autowired | |
| 61 | + private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 62 | + | |
| 63 | + @Autowired | |
| 64 | + private ScheduleRedisService scheduleRedisService; | |
| 65 | + | |
| 66 | + @Autowired | |
| 67 | + private OilRedisService oilRedisService; | |
| 68 | + | |
| 69 | + @Autowired | |
| 70 | + private ElecRedisService elecRedisService; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * 根据日期统计数据重新计算 | |
| 74 | + * @param rq | |
| 75 | + */ | |
| 76 | + @GET | |
| 77 | + @Path("/reCompute/{rq}") | |
| 78 | + public void reStatisticalComputation(@PathParam("rq") String rq) { | |
| 79 | + DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(rq); | |
| 80 | + planComputation(dateTime); | |
| 81 | + realComputation(dateTime); | |
| 82 | + carMileageComputation(dateTime); | |
| 83 | + } | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * | |
| 87 | + */ | |
| 88 | + private List<LineServiceConfigVo> reGroup(List<LineServiceConfig> configs, String month) { | |
| 89 | + List<LineServiceConfigVo> result = new ArrayList<>(); | |
| 90 | + String oldLineCode = ""; | |
| 91 | + LineServiceConfigVo vo = null; | |
| 92 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 93 | + LineServiceConfig config = configs.get(i); | |
| 94 | + if (i == 0) { | |
| 95 | + oldLineCode = config.getLineCode(); | |
| 96 | + vo = new LineServiceConfigVo(); | |
| 97 | + vo.setLineName(config.getLineName()); | |
| 98 | + vo.setMonth(month); | |
| 99 | + vo.setConductorFirstCount(config.getConductorCount()); | |
| 100 | + vo.setDriverFirstCount(config.getDriverCount()); | |
| 101 | + } else if (i == len - 1) { | |
| 102 | + result.add(vo); | |
| 103 | + } else { | |
| 104 | + if (!oldLineCode.equals(config.getLineCode())) { | |
| 105 | + oldLineCode = config.getLineCode(); | |
| 106 | + result.add(vo); | |
| 107 | + vo = new LineServiceConfigVo(); | |
| 108 | + vo.setLineName(config.getLineName()); | |
| 109 | + vo.setMonth(month); | |
| 110 | + vo.setConductorFirstCount(config.getConductorCount()); | |
| 111 | + vo.setDriverFirstCount(config.getDriverCount()); | |
| 112 | + } | |
| 113 | + } | |
| 114 | + vo.setConductorLastCount(config.getConductorCount()); | |
| 115 | + vo.setDriverLastCount(config.getDriverCount()); | |
| 116 | + } | |
| 117 | + | |
| 118 | + return result; | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** | |
| 122 | + * 计划司售配档数 | |
| 123 | + * @param month | |
| 124 | + */ | |
| 125 | + @GET | |
| 126 | + @Path("/plan/{month}") | |
| 127 | + public List<LineServiceConfigVo> plan(@PathParam("month") String month) { | |
| 128 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 129 | + return reGroup(configs, month); | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * 实际司售配档数 | |
| 134 | + * @param month | |
| 135 | + */ | |
| 136 | + @GET | |
| 137 | + @Path("/actual/{month}") | |
| 138 | + public List<LineServiceConfigVo> actual(@PathParam("month") String month) { | |
| 139 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 140 | + return reGroup(configs, month); | |
| 141 | + } | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * 计划配车数 | |
| 145 | + * @param month | |
| 146 | + */ | |
| 147 | + @GET | |
| 148 | + @Path("/bus/plan/{month}") | |
| 149 | + public List<BusVo> busPlan(@PathParam("month") String month) { | |
| 150 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_plan where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 151 | + List<BusVo> result = new ArrayList<>(); | |
| 152 | + String oldLineCode = ""; | |
| 153 | + BusVo vo = null; | |
| 154 | + int max = 0; | |
| 155 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 156 | + LineServiceConfig config = configs.get(i); | |
| 157 | + if (i == 0) { | |
| 158 | + oldLineCode = config.getLineCode(); | |
| 159 | + vo = new BusVo(); | |
| 160 | + vo.setLineName(config.getLineName()); | |
| 161 | + vo.setMonth(month); | |
| 162 | + vo.setBusFirstCount(config.getCarCount()); | |
| 163 | + } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 164 | + oldLineCode = config.getLineCode(); | |
| 165 | + vo.setBusMaxCount(max); | |
| 166 | + result.add(vo); | |
| 167 | + max = 0; | |
| 168 | + vo = new BusVo(); | |
| 169 | + vo.setLineName(config.getLineName()); | |
| 170 | + vo.setMonth(month); | |
| 171 | + vo.setBusFirstCount(config.getCarCount()); | |
| 172 | + } | |
| 173 | + max = Math.max(max, config.getCarCount()); | |
| 174 | + if (i == len - 1) { | |
| 175 | + vo.setBusMaxCount(max); | |
| 176 | + result.add(vo); | |
| 177 | + } | |
| 178 | + vo.setBusLastCount(config.getCarCount()); | |
| 179 | + } | |
| 180 | + | |
| 181 | + return result; | |
| 182 | + } | |
| 183 | + | |
| 184 | + /** | |
| 185 | + * 实际配车数 | |
| 186 | + * @param month | |
| 187 | + */ | |
| 188 | + @GET | |
| 189 | + @Path("/bus/{month}") | |
| 190 | + public List<BusVo> bus(@PathParam("month") String month) { | |
| 191 | + List<LineServiceConfig> configs = jdbcTemplate.query("select * from control_interface.bsth_t_real where schedule_date like CONCAT(?, '%') order by line_code, schedule_date", new Object[]{ month }, BeanPropertyRowMapper.newInstance(LineServiceConfig.class)); | |
| 192 | + List<BusVo> result = new ArrayList<>(); | |
| 193 | + String oldLineCode = ""; | |
| 194 | + BusVo vo = null; | |
| 195 | + int max = 0; | |
| 196 | + for (int i = 0, len = configs.size();i < len;i++) { | |
| 197 | + LineServiceConfig config = configs.get(i); | |
| 198 | + if (i == 0) { | |
| 199 | + oldLineCode = config.getLineCode(); | |
| 200 | + vo = new BusVo(); | |
| 201 | + vo.setLineName(config.getLineName()); | |
| 202 | + vo.setMonth(month); | |
| 203 | + vo.setBusFirstCount(config.getCarCount()); | |
| 204 | + } else if (!oldLineCode.equals(config.getLineCode())) { | |
| 205 | + oldLineCode = config.getLineCode(); | |
| 206 | + vo.setBusMaxCount(max); | |
| 207 | + result.add(vo); | |
| 208 | + max = 0; | |
| 209 | + vo = new BusVo(); | |
| 210 | + vo.setLineName(config.getLineName()); | |
| 211 | + vo.setMonth(month); | |
| 212 | + vo.setBusFirstCount(config.getCarCount()); | |
| 213 | + } | |
| 214 | + max = Math.max(max, config.getCarCount()); | |
| 215 | + if (i == len - 1) { | |
| 216 | + vo.setBusMaxCount(max); | |
| 217 | + result.add(vo); | |
| 218 | + } | |
| 219 | + vo.setBusLastCount(config.getCarCount()); | |
| 220 | + } | |
| 221 | + | |
| 222 | + return result; | |
| 223 | + } | |
| 224 | + | |
| 225 | + /** | |
| 226 | + * 车辆公里、油耗数据 | |
| 227 | + * @param month | |
| 228 | + */ | |
| 229 | + @GET | |
| 230 | + @Path("/mileage/{month}") | |
| 231 | + public List<BusMileageVo> mileage(@PathParam("month") String month) { | |
| 232 | + List<BusMileage> mileages = jdbcTemplate.query("select company, company_code, nbbm, schedule_month schedule_date, sum(zlc) zlc, sum(yh) yh, sum(dh) dh from control_interface.bsth_t_mileage where schedule_month = ? group by company, company_code, nbbm, schedule_month", new Object[]{ month }, BeanPropertyRowMapper.newInstance(BusMileage.class)); | |
| 233 | + List<BusMileageVo> result = new ArrayList<>(); | |
| 234 | + for (BusMileage mileage : mileages) { | |
| 235 | + BusMileageVo vo = new BusMileageVo(); | |
| 236 | + vo.setMonth(mileage.getScheduleDate()); | |
| 237 | + vo.setInsideCode(mileage.getNbbm()); | |
| 238 | + vo.setTotalMileage(mileage.getZlc()); | |
| 239 | + vo.setOilConsume(mileage.getYh()); | |
| 240 | + vo.setElectricConsume(mileage.getDh()); | |
| 241 | + vo.setCompany(mileage.getCompany()); | |
| 242 | + vo.setCompanyCode(mileage.getCompanyCode()); | |
| 243 | + | |
| 244 | + result.add(vo); | |
| 245 | + } | |
| 246 | + | |
| 247 | + return result; | |
| 248 | + } | |
| 249 | + | |
| 250 | + @Scheduled(cron = "0 0/25 23 * * ?") | |
| 251 | + public void statisticalComputation() { | |
| 252 | + log.info("执行电科所接口数据统计计算"); | |
| 253 | + DateTime dateTime = DateTime.now().plusDays(1); | |
| 254 | + try { | |
| 255 | + for (int i = 0;i < 3;i++) { | |
| 256 | + dateTime = dateTime.minusDays(1); | |
| 257 | + planComputation(dateTime); | |
| 258 | + realComputation(dateTime); | |
| 259 | + carMileageComputation(dateTime); | |
| 260 | + } | |
| 261 | + } catch (Exception e) { | |
| 262 | + e.printStackTrace(); | |
| 263 | + } | |
| 264 | + } | |
| 265 | + | |
| 266 | + /** | |
| 267 | + * 计划排班中的线路司售配档数 | |
| 268 | + */ | |
| 269 | + private void planComputation(DateTime dateTime) { | |
| 270 | + // 记录实际线路司售配档情况 | |
| 271 | + List<SchedulePlanInfo> schedulePlanInfos = schedulePlanInfoRepository.findByDate(DateTimeFormat.forPattern("yyyy-MM-dd").parseDateTime(dateTime.toString("yyyy-MM-dd")).toDate()); | |
| 272 | + Set<String> lineCodes = new HashSet<>(); | |
| 273 | + Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 274 | + final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 275 | + for (SchedulePlanInfo schedulePlanInfo : schedulePlanInfos) { | |
| 276 | + String lineCode = schedulePlanInfo.getXlBm(); | |
| 277 | + lineCodes.add(lineCode); | |
| 278 | + Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 279 | + if (conductors == null) { | |
| 280 | + conductors = new HashSet<>(); | |
| 281 | + line2conductors.put(lineCode, conductors); | |
| 282 | + } | |
| 283 | + if (drivers == null) { | |
| 284 | + drivers = new HashSet<>(); | |
| 285 | + line2drivers.put(lineCode, drivers); | |
| 286 | + } | |
| 287 | + if (cars == null) { | |
| 288 | + cars = new HashSet<>(); | |
| 289 | + line2cars.put(lineCode, cars); | |
| 290 | + } | |
| 291 | + if (!StringUtils.isEmpty(schedulePlanInfo.getsGh())) { | |
| 292 | + conductors.add(schedulePlanInfo.getsGh()); | |
| 293 | + } | |
| 294 | + drivers.add(schedulePlanInfo.getjGh()); | |
| 295 | + cars.add(schedulePlanInfo.getClZbh()); | |
| 296 | + } | |
| 297 | + for (String lineCode : lineCodes) { | |
| 298 | + LineServiceConfig object = new LineServiceConfig(); | |
| 299 | + Line line = LineBufferData.findOne(lineCode); | |
| 300 | + object.setLineCode(lineCode); | |
| 301 | + object.setLineName(line == null ? "" : line.getName()); | |
| 302 | + object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 303 | + object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 304 | + object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 305 | + object.setCarCount(line2cars.get(lineCode).size()); | |
| 306 | + | |
| 307 | + objects.add(object); | |
| 308 | + } | |
| 309 | + | |
| 310 | + //编程式事务 | |
| 311 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 312 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 313 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 314 | + TransactionStatus status = tran.getTransaction(def); | |
| 315 | + | |
| 316 | + try { | |
| 317 | + jdbcTemplate.update("delete from control_interface.bsth_t_plan where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 318 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_plan (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 319 | + @Override | |
| 320 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 321 | + LineServiceConfig object = objects.get(i); | |
| 322 | + ps.setString(1, object.getLineCode()); | |
| 323 | + ps.setString(2, object.getLineName()); | |
| 324 | + ps.setString(3, object.getScheduleDate()); | |
| 325 | + ps.setInt(4, object.getConductorCount()); | |
| 326 | + ps.setInt(5, object.getDriverCount()); | |
| 327 | + ps.setInt(6, object.getCarCount()); | |
| 328 | + } | |
| 329 | + | |
| 330 | + @Override | |
| 331 | + public int getBatchSize() { | |
| 332 | + return objects.size(); | |
| 333 | + } | |
| 334 | + }); | |
| 335 | + tran.commit(status); | |
| 336 | + } catch (Exception e) { | |
| 337 | + tran.rollback(status); | |
| 338 | + } | |
| 339 | + } | |
| 340 | + | |
| 341 | + /** | |
| 342 | + * 实际排班中的线路司售配档数 | |
| 343 | + */ | |
| 344 | + private void realComputation(DateTime dateTime) { | |
| 345 | + // 记录实际线路司售配档情况 | |
| 346 | + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.findAll(dateTime.toString("yyyy-MM-dd")); | |
| 347 | + Set<String> lineCodes = new HashSet<>(); | |
| 348 | + Map<String, Set<String>> line2conductors = new HashMap<>(), line2drivers = new HashMap<>(), line2cars = new HashMap<>(); | |
| 349 | + final List<LineServiceConfig> objects = new ArrayList<>(); | |
| 350 | + for (ScheduleRealInfo scheduleRealInfo : scheduleRealInfos) { | |
| 351 | + // 烂班班次不计入配档数 | |
| 352 | + if (scheduleRealInfo.getStatus() == -1) { continue; } | |
| 353 | + String lineCode = scheduleRealInfo.getXlBm(); | |
| 354 | + lineCodes.add(lineCode); | |
| 355 | + Set<String> conductors = line2conductors.get(lineCode), drivers = line2drivers.get(lineCode), cars = line2cars.get(lineCode); | |
| 356 | + if (conductors == null) { | |
| 357 | + conductors = new HashSet<>(); | |
| 358 | + line2conductors.put(lineCode, conductors); | |
| 359 | + } | |
| 360 | + if (drivers == null) { | |
| 361 | + drivers = new HashSet<>(); | |
| 362 | + line2drivers.put(lineCode, drivers); | |
| 363 | + } | |
| 364 | + if (cars == null) { | |
| 365 | + cars = new HashSet<>(); | |
| 366 | + line2cars.put(lineCode, cars); | |
| 367 | + } | |
| 368 | + if (!StringUtils.isEmpty(scheduleRealInfo.getsGh())) { | |
| 369 | + conductors.add(scheduleRealInfo.getsGh()); | |
| 370 | + } | |
| 371 | + drivers.add(scheduleRealInfo.getjGh()); | |
| 372 | + cars.add(scheduleRealInfo.getClZbh()); | |
| 373 | + } | |
| 374 | + for (String lineCode : lineCodes) { | |
| 375 | + LineServiceConfig object = new LineServiceConfig(); | |
| 376 | + Line line = LineBufferData.findOne(lineCode); | |
| 377 | + object.setLineCode(lineCode); | |
| 378 | + object.setLineName(line == null ? "" : line.getName()); | |
| 379 | + object.setScheduleDate(dateTime.toString("yyyy-MM-dd")); | |
| 380 | + object.setConductorCount(line2conductors.get(lineCode).size()); | |
| 381 | + object.setDriverCount(line2drivers.get(lineCode).size()); | |
| 382 | + object.setCarCount(line2cars.get(lineCode).size()); | |
| 383 | + | |
| 384 | + objects.add(object); | |
| 385 | + } | |
| 386 | + | |
| 387 | + //编程式事务 | |
| 388 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 389 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 390 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 391 | + TransactionStatus status = tran.getTransaction(def); | |
| 392 | + try { | |
| 393 | + jdbcTemplate.update("delete from control_interface.bsth_t_real where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 394 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_real (line_code, line_name, schedule_date, conductor_count, driver_count, car_count) values (?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 395 | + @Override | |
| 396 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 397 | + LineServiceConfig object = objects.get(i); | |
| 398 | + ps.setString(1, object.getLineCode()); | |
| 399 | + ps.setString(2, object.getLineName()); | |
| 400 | + ps.setString(3, object.getScheduleDate()); | |
| 401 | + ps.setInt(4, object.getConductorCount()); | |
| 402 | + ps.setInt(5, object.getDriverCount()); | |
| 403 | + ps.setInt(6, object.getCarCount()); | |
| 404 | + } | |
| 405 | + | |
| 406 | + @Override | |
| 407 | + public int getBatchSize() { | |
| 408 | + return objects.size(); | |
| 409 | + } | |
| 410 | + }); | |
| 411 | + tran.commit(status); | |
| 412 | + } catch (Exception e) { | |
| 413 | + tran.rollback(status); | |
| 414 | + } | |
| 415 | + } | |
| 416 | + | |
| 417 | + private void carMileageComputation(final DateTime dateTime) { | |
| 418 | + String rq = dateTime.toString("yyyy-MM-dd"); | |
| 419 | + // 实际排班信息 | |
| 420 | + ArrayListMultimap<String, ScheduleRealInfo> nbbm2schedules = scheduleRedisService.findByDate(rq); | |
| 421 | + // 油耗信息 | |
| 422 | + ArrayListMultimap<String, OilInfo> oilInfoMap = oilRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 423 | + //电耗信息 | |
| 424 | + ArrayListMultimap<String, ElecInfo> elecInfoMap = elecRedisService.findByNbbmGroup1(nbbm2schedules.keySet(), rq); | |
| 425 | + Set<String> nbbms = nbbm2schedules.keySet(); | |
| 426 | + final List<BusMileage> busMileages = new ArrayList<>(); | |
| 427 | + for (String nbbm : nbbms) { | |
| 428 | + List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 429 | + if (scheduleRealInfos.size() == 0) { | |
| 430 | + continue; | |
| 431 | + } | |
| 432 | + ScheduleRealInfo scheduleRealInfo = scheduleRealInfos.get(0); | |
| 433 | + BusMileage busMileage = new BusMileage(); | |
| 434 | + busMileage.setScheduleDate(rq); | |
| 435 | + busMileage.setNbbm(nbbm); | |
| 436 | + busMileage.setJhlc(ScheduleCalculator.calcJHLC(scheduleRealInfos)); | |
| 437 | + busMileage.setSjjhlc(ScheduleCalculator.calcSJLC(scheduleRealInfos)); | |
| 438 | + busMileage.setSjcclc(ScheduleCalculator.calcCCLC(scheduleRealInfos)); | |
| 439 | + busMileage.setSjjclc(ScheduleCalculator.calcJCLC(scheduleRealInfos)); | |
| 440 | + busMileage.setYylc(ScheduleCalculator.calcYYLC(scheduleRealInfos)); | |
| 441 | + busMileage.setKslc(ScheduleCalculator.calcKSLC(scheduleRealInfos)); | |
| 442 | + busMileage.setCjlc(ScheduleCalculator.calcCJLC(scheduleRealInfos)); | |
| 443 | + busMileage.setLblc(ScheduleCalculator.calcLBLC(scheduleRealInfos)); | |
| 444 | + busMileage.setZjlc(ScheduleCalculator.calcZJLC(scheduleRealInfos)); | |
| 445 | + busMileage.setZlc(ScheduleCalculator.calcZLC(scheduleRealInfos)); | |
| 446 | + List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 447 | + List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 448 | + Double yh = 0.0, dh = 0.0; | |
| 449 | + for (OilInfo oilInfo : oilInfos) { | |
| 450 | + yh = Arith.add(yh, oilInfo.getYh()); | |
| 451 | + } | |
| 452 | + for (ElecInfo elecInfo : elecInfos) { | |
| 453 | + dh = Arith.add(dh, elecInfo.getHd()); | |
| 454 | + } | |
| 455 | + busMileage.setYh(yh); | |
| 456 | + busMileage.setDh(dh); | |
| 457 | + busMileage.setCompany(scheduleRealInfo.getGsName()); | |
| 458 | + busMileage.setCompanyCode(scheduleRealInfo.getGsBm()); | |
| 459 | + | |
| 460 | + busMileages.add(busMileage); | |
| 461 | + } | |
| 462 | + for(String nbbm : oilInfoMap.keys()){ //有加油没路单的车。 | |
| 463 | + if(nbbms.contains(nbbm)){ | |
| 464 | + List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 465 | + if (scheduleRealInfos.size() > 0) { | |
| 466 | + continue; | |
| 467 | + } | |
| 468 | + } | |
| 469 | + BusMileage busMileage = new BusMileage(); | |
| 470 | + busMileage.setScheduleDate(rq); | |
| 471 | + busMileage.setNbbm(nbbm); | |
| 472 | + busMileage.setJhlc(0d); | |
| 473 | + busMileage.setSjjhlc(0d); | |
| 474 | + busMileage.setSjcclc(0d); | |
| 475 | + busMileage.setSjjclc(0d); | |
| 476 | + busMileage.setYylc(0d); | |
| 477 | + busMileage.setKslc(0d); | |
| 478 | + busMileage.setCjlc(0d); | |
| 479 | + busMileage.setLblc(0d); | |
| 480 | + busMileage.setZjlc(0d); | |
| 481 | + busMileage.setZlc(0d); | |
| 482 | + List<OilInfo> oilInfos = oilInfoMap.get(nbbm); | |
| 483 | + List<ElecInfo> elecInfos = elecInfoMap.containsKey(nbbm)?elecInfoMap.get(nbbm):new ArrayList<ElecInfo>(); | |
| 484 | + Double yh = 0.0, dh = 0.0; | |
| 485 | + for (OilInfo oilInfo : oilInfos) { | |
| 486 | + yh = Arith.add(yh, oilInfo.getYh()); | |
| 487 | + busMileage.setCompany(BusinessCodeData.code2Name.get(oilInfo.getSsgsdm())); | |
| 488 | + busMileage.setCompanyCode(oilInfo.getSsgsdm()); | |
| 489 | + } | |
| 490 | + for (ElecInfo elecInfo : elecInfos) { | |
| 491 | + dh = Arith.add(dh, elecInfo.getHd()); | |
| 492 | + } | |
| 493 | + busMileage.setYh(yh); | |
| 494 | + busMileage.setDh(dh); | |
| 495 | + | |
| 496 | + busMileages.add(busMileage); | |
| 497 | + } | |
| 498 | + for(String nbbm : elecInfoMap.keys()){ //有加电没路单的车。 | |
| 499 | + if(nbbms.contains(nbbm)){ | |
| 500 | + List<ScheduleRealInfo> scheduleRealInfos = nbbm2schedules.get(nbbm); | |
| 501 | + if (scheduleRealInfos.size() > 0) { | |
| 502 | + continue; | |
| 503 | + } | |
| 504 | + } | |
| 505 | + if(oilInfoMap.keys().contains(nbbm)){ | |
| 506 | + continue; | |
| 507 | + } | |
| 508 | + BusMileage busMileage = new BusMileage(); | |
| 509 | + busMileage.setScheduleDate(rq); | |
| 510 | + busMileage.setNbbm(nbbm); | |
| 511 | + busMileage.setJhlc(0d); | |
| 512 | + busMileage.setSjjhlc(0d); | |
| 513 | + busMileage.setSjcclc(0d); | |
| 514 | + busMileage.setSjjclc(0d); | |
| 515 | + busMileage.setYylc(0d); | |
| 516 | + busMileage.setKslc(0d); | |
| 517 | + busMileage.setCjlc(0d); | |
| 518 | + busMileage.setLblc(0d); | |
| 519 | + busMileage.setZjlc(0d); | |
| 520 | + busMileage.setZlc(0d); | |
| 521 | + List<ElecInfo> elecInfos = elecInfoMap.get(nbbm); | |
| 522 | + Double yh = 0.0, dh = 0.0; | |
| 523 | + for (ElecInfo elecInfo : elecInfos) { | |
| 524 | + dh = Arith.add(dh, elecInfo.getHd()); | |
| 525 | + busMileage.setCompany(BusinessCodeData.code2Name.get(elecInfo.getSsgsdm())); | |
| 526 | + busMileage.setCompanyCode(elecInfo.getSsgsdm()); | |
| 527 | + } | |
| 528 | + busMileage.setYh(yh); | |
| 529 | + busMileage.setDh(dh); | |
| 530 | + | |
| 531 | + busMileages.add(busMileage); | |
| 532 | + } | |
| 533 | + | |
| 534 | + //编程式事务 | |
| 535 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | |
| 536 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | |
| 537 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | |
| 538 | + TransactionStatus status = tran.getTransaction(def); | |
| 539 | + try { | |
| 540 | + jdbcTemplate.update("delete from control_interface.bsth_t_mileage where schedule_date = ?", new Object[]{ dateTime.toString("yyyy-MM-dd") }); | |
| 541 | + jdbcTemplate.batchUpdate("insert into control_interface.bsth_t_mileage (schedule_date,nbbm,jhlc,sjjhlc,sjcclc,sjjclc,yylc,kslc,cjlc,lblc,zjlc,zlc,yh,dh,schedule_month,company,company_code) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 542 | + @Override | |
| 543 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | |
| 544 | + BusMileage busMileage = busMileages.get(i); | |
| 545 | + ps.setString(1, busMileage.getScheduleDate()); | |
| 546 | + ps.setString(2, busMileage.getNbbm()); | |
| 547 | + ps.setDouble(3, busMileage.getJhlc()); | |
| 548 | + ps.setDouble(4, busMileage.getSjjhlc()); | |
| 549 | + ps.setDouble(5, busMileage.getSjcclc()); | |
| 550 | + ps.setDouble(6, busMileage.getSjjclc()); | |
| 551 | + ps.setDouble(7, busMileage.getYylc()); | |
| 552 | + ps.setDouble(8, busMileage.getKslc()); | |
| 553 | + ps.setDouble(9, busMileage.getCjlc()); | |
| 554 | + ps.setDouble(10, busMileage.getLblc()); | |
| 555 | + ps.setDouble(11, busMileage.getZjlc()); | |
| 556 | + ps.setDouble(12, busMileage.getZlc()); | |
| 557 | + ps.setDouble(13, busMileage.getYh()); | |
| 558 | + ps.setDouble(14, busMileage.getDh()); | |
| 559 | + ps.setString(15, dateTime.toString("yyyy-MM")); | |
| 560 | + ps.setString(16, busMileage.getCompany()); | |
| 561 | + ps.setString(17, busMileage.getCompanyCode()); | |
| 562 | + } | |
| 563 | + | |
| 564 | + @Override | |
| 565 | + public int getBatchSize() { | |
| 566 | + return busMileages.size(); | |
| 567 | + } | |
| 568 | + }); | |
| 569 | + tran.commit(status); | |
| 570 | + } catch (Exception e) { | |
| 571 | + tran.rollback(status); | |
| 572 | + } | |
| 573 | + } | |
| 574 | + | |
| 575 | + /** | |
| 576 | + * 线路司售配档对象 | |
| 577 | + */ | |
| 578 | + private final static class LineServiceConfigVo { | |
| 579 | + | |
| 580 | + private String lineName; | |
| 581 | + | |
| 582 | + private String month; | |
| 583 | + | |
| 584 | + private Integer driverFirstCount; | |
| 585 | + | |
| 586 | + private Integer driverLastCount; | |
| 587 | + | |
| 588 | + private Integer conductorFirstCount; | |
| 589 | + | |
| 590 | + private Integer conductorLastCount; | |
| 591 | + | |
| 592 | + public String getLineName() { | |
| 593 | + return lineName; | |
| 594 | + } | |
| 595 | + | |
| 596 | + public void setLineName(String lineName) { | |
| 597 | + this.lineName = lineName; | |
| 598 | + } | |
| 599 | + | |
| 600 | + public String getMonth() { | |
| 601 | + return month; | |
| 602 | + } | |
| 603 | + | |
| 604 | + public void setMonth(String month) { | |
| 605 | + this.month = month; | |
| 606 | + } | |
| 607 | + | |
| 608 | + public Integer getDriverFirstCount() { | |
| 609 | + return driverFirstCount; | |
| 610 | + } | |
| 611 | + | |
| 612 | + public void setDriverFirstCount(Integer driverFirstCount) { | |
| 613 | + this.driverFirstCount = driverFirstCount; | |
| 614 | + } | |
| 615 | + | |
| 616 | + public Integer getDriverLastCount() { | |
| 617 | + return driverLastCount; | |
| 618 | + } | |
| 619 | + | |
| 620 | + public void setDriverLastCount(Integer driverLastCount) { | |
| 621 | + this.driverLastCount = driverLastCount; | |
| 622 | + } | |
| 623 | + | |
| 624 | + public Integer getConductorFirstCount() { | |
| 625 | + return conductorFirstCount; | |
| 626 | + } | |
| 627 | + | |
| 628 | + public void setConductorFirstCount(Integer conductorFirstCount) { | |
| 629 | + this.conductorFirstCount = conductorFirstCount; | |
| 630 | + } | |
| 631 | + | |
| 632 | + public Integer getConductorLastCount() { | |
| 633 | + return conductorLastCount; | |
| 634 | + } | |
| 635 | + | |
| 636 | + public void setConductorLastCount(Integer conductorLastCount) { | |
| 637 | + this.conductorLastCount = conductorLastCount; | |
| 638 | + } | |
| 639 | + } | |
| 640 | + | |
| 641 | + /** | |
| 642 | + * 车辆配档对象 | |
| 643 | + */ | |
| 644 | + private final static class BusVo { | |
| 645 | + | |
| 646 | + private String lineName; | |
| 647 | + | |
| 648 | + private String month; | |
| 649 | + | |
| 650 | + private Integer busFirstCount; | |
| 651 | + | |
| 652 | + private Integer busLastCount; | |
| 653 | + | |
| 654 | + private Integer busMaxCount; | |
| 655 | + | |
| 656 | + public String getLineName() { | |
| 657 | + return lineName; | |
| 658 | + } | |
| 659 | + | |
| 660 | + public void setLineName(String lineName) { | |
| 661 | + this.lineName = lineName; | |
| 662 | + } | |
| 663 | + | |
| 664 | + public String getMonth() { | |
| 665 | + return month; | |
| 666 | + } | |
| 667 | + | |
| 668 | + public void setMonth(String month) { | |
| 669 | + this.month = month; | |
| 670 | + } | |
| 671 | + | |
| 672 | + public Integer getBusFirstCount() { | |
| 673 | + return busFirstCount; | |
| 674 | + } | |
| 675 | + | |
| 676 | + public void setBusFirstCount(Integer busFirstCount) { | |
| 677 | + this.busFirstCount = busFirstCount; | |
| 678 | + } | |
| 679 | + | |
| 680 | + public Integer getBusLastCount() { | |
| 681 | + return busLastCount; | |
| 682 | + } | |
| 683 | + | |
| 684 | + public void setBusLastCount(Integer busLastCount) { | |
| 685 | + this.busLastCount = busLastCount; | |
| 686 | + } | |
| 687 | + | |
| 688 | + public Integer getBusMaxCount() { | |
| 689 | + return busMaxCount; | |
| 690 | + } | |
| 691 | + | |
| 692 | + public void setBusMaxCount(Integer busMaxCount) { | |
| 693 | + this.busMaxCount = busMaxCount; | |
| 694 | + } | |
| 695 | + } | |
| 696 | + | |
| 697 | + /** | |
| 698 | + * 车辆公里、油耗对象 | |
| 699 | + */ | |
| 700 | + private final static class BusMileageVo { | |
| 701 | + | |
| 702 | + private String insideCode; | |
| 703 | + | |
| 704 | + private String month; | |
| 705 | + | |
| 706 | + private Double totalMileage; | |
| 707 | + | |
| 708 | + private Double oilConsume; | |
| 709 | + | |
| 710 | + private Double electricConsume; | |
| 711 | + | |
| 712 | + private String company; | |
| 713 | + | |
| 714 | + private String companyCode; | |
| 715 | + | |
| 716 | + public String getInsideCode() { | |
| 717 | + return insideCode; | |
| 718 | + } | |
| 719 | + | |
| 720 | + public void setInsideCode(String insideCode) { | |
| 721 | + this.insideCode = insideCode; | |
| 722 | + } | |
| 723 | + | |
| 724 | + public String getMonth() { | |
| 725 | + return month; | |
| 726 | + } | |
| 727 | + | |
| 728 | + public void setMonth(String month) { | |
| 729 | + this.month = month; | |
| 730 | + } | |
| 731 | + | |
| 732 | + public Double getTotalMileage() { | |
| 733 | + return totalMileage; | |
| 734 | + } | |
| 735 | + | |
| 736 | + public void setTotalMileage(Double totalMileage) { | |
| 737 | + this.totalMileage = totalMileage; | |
| 738 | + } | |
| 739 | + | |
| 740 | + public Double getOilConsume() { | |
| 741 | + return oilConsume; | |
| 742 | + } | |
| 743 | + | |
| 744 | + public void setOilConsume(Double oilConsume) { | |
| 745 | + this.oilConsume = oilConsume; | |
| 746 | + } | |
| 747 | + | |
| 748 | + public Double getElectricConsume() { | |
| 749 | + return electricConsume; | |
| 750 | + } | |
| 751 | + | |
| 752 | + public void setElectricConsume(Double electricConsume) { | |
| 753 | + this.electricConsume = electricConsume; | |
| 754 | + } | |
| 755 | + | |
| 756 | + public String getCompany() { | |
| 757 | + return company; | |
| 758 | + } | |
| 759 | + | |
| 760 | + public void setCompany(String company) { | |
| 761 | + this.company = company; | |
| 762 | + } | |
| 763 | + | |
| 764 | + public String getCompanyCode() { | |
| 765 | + return companyCode; | |
| 766 | + } | |
| 767 | + | |
| 768 | + public void setCompanyCode(String companyCode) { | |
| 769 | + this.companyCode = companyCode; | |
| 770 | + } | |
| 771 | + } | |
| 772 | +} | ... | ... |