Commit 72acc6795a004839d8c36e9403b75cfa544acddc
1 parent
567fa3ec
update...
Showing
4 changed files
with
47 additions
and
13 deletions
src/main/java/com/bsth/server_rs/schedule/dto/ScheduleInOut.java
| ... | ... | @@ -29,9 +29,15 @@ public class ScheduleInOut implements Serializable { |
| 29 | 29 | return rs; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - /* public static ScheduleInOut getInstance(ScheduleRealInfo sch){ | |
| 33 | - //return JSONObject.parseObject(JSON.toJSONString(sch), ScheduleInOut.class); | |
| 34 | - }*/ | |
| 32 | + public static List<ScheduleInOut> getMultiInstance(List<ScheduleRealInfo> list){ | |
| 33 | + List<ScheduleInOut> rs = new ArrayList<>(); | |
| 34 | + | |
| 35 | + for(ScheduleRealInfo sch : list){ | |
| 36 | + rs.add(new ScheduleInOut(sch)); | |
| 37 | + } | |
| 38 | + return rs; | |
| 39 | + } | |
| 40 | + | |
| 35 | 41 | |
| 36 | 42 | ScheduleInOut(){} |
| 37 | 43 | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/SchRealInfoBuffer.java
| 1 | 1 | package com.bsth.server_rs.schedule.real; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.ScheduleRealInfo; |
| 4 | +import com.google.common.collect.ArrayListMultimap; | |
| 5 | +import org.apache.commons.lang3.StringUtils; | |
| 4 | 6 | import org.springframework.stereotype.Component; |
| 5 | 7 | |
| 6 | 8 | import java.util.List; |
| ... | ... | @@ -15,6 +17,27 @@ public class SchRealInfoBuffer { |
| 15 | 17 | /** |
| 16 | 18 | * 进出场班次数据,定时从调度系统获取。 对各场站输出 |
| 17 | 19 | */ |
| 18 | - public static List<ScheduleRealInfo> inOutList; | |
| 20 | + private static ArrayListMultimap<String, ScheduleRealInfo> inOutMap; | |
| 19 | 21 | |
| 22 | + public void putInOutData(List<ScheduleRealInfo> list){ | |
| 23 | + ArrayListMultimap<String, ScheduleRealInfo> inOutMapCopy = ArrayListMultimap.create(); | |
| 24 | + | |
| 25 | + String type; | |
| 26 | + for(ScheduleRealInfo sch : list){ | |
| 27 | + type = sch.getBcType(); | |
| 28 | + if(StringUtils.isEmpty(type)) | |
| 29 | + continue; | |
| 30 | + | |
| 31 | + if(type.equals("in")) | |
| 32 | + inOutMapCopy.put(sch.getZdzCode(), sch); | |
| 33 | + else if(type.equals("out")) | |
| 34 | + inOutMapCopy.put(sch.getQdzCode(), sch); | |
| 35 | + } | |
| 36 | + | |
| 37 | + inOutMap = inOutMapCopy; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public List<ScheduleRealInfo> findByParkCode(String parkCode){ | |
| 41 | + return inOutMap.get(parkCode); | |
| 42 | + } | |
| 20 | 43 | } | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/ScheduleRealService.java
| ... | ... | @@ -6,6 +6,8 @@ import com.bsth.server_rs.base_info.line.Line; |
| 6 | 6 | import com.bsth.server_rs.base_info.line.buffer.LineBufferData; |
| 7 | 7 | import com.bsth.server_rs.schedule.dto.ScheduleInOut; |
| 8 | 8 | import com.bsth.server_rs.schedule.dto.ScheduleRealInfoDTO_JK; |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 9 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 12 | import org.springframework.stereotype.Component; |
| 11 | 13 | |
| ... | ... | @@ -29,6 +31,11 @@ public class ScheduleRealService { |
| 29 | 31 | @Autowired |
| 30 | 32 | ScheduleRedisService redisService; |
| 31 | 33 | |
| 34 | + @Autowired | |
| 35 | + SchRealInfoBuffer schRealInfoBuffer; | |
| 36 | + | |
| 37 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 38 | + | |
| 32 | 39 | /** |
| 33 | 40 | * 获取当天指定停车场的进出场排班数据 |
| 34 | 41 | * |
| ... | ... | @@ -52,15 +59,10 @@ public class ScheduleRealService { |
| 52 | 59 | * @return |
| 53 | 60 | */ |
| 54 | 61 | @GET |
| 55 | - @Path("/in_out/{code}") | |
| 62 | + @Path("/in_out/pz_vip/{code}") | |
| 56 | 63 | public List<ScheduleInOut> findInOut_real(@PathParam("code") String code) { |
| 57 | - Set<String> lineArray = BasicData.lineDateMap.keySet(); | |
| 58 | - | |
| 59 | - List<ScheduleInOut> all = new ArrayList<>(); | |
| 60 | - for (String lineCode : lineArray) { | |
| 61 | - all.addAll(ScheduleInOut.getMultiInstance(redisService.read(BasicData.lineDateMap.get(lineCode), lineCode), code)); | |
| 62 | - } | |
| 63 | - return all; | |
| 64 | + logger.error("in_out -" + code); | |
| 65 | + return ScheduleInOut.getMultiInstance(schRealInfoBuffer.findByParkCode(code)); | |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | @GET | ... | ... |
src/main/java/com/bsth/server_rs/schedule/real/thread/SchInOutDataRefreshThread.java
| ... | ... | @@ -7,6 +7,7 @@ import com.bsth.util.ConfigUtil; |
| 7 | 7 | import com.bsth.util.HttpClientUtils; |
| 8 | 8 | import org.slf4j.Logger; |
| 9 | 9 | import org.slf4j.LoggerFactory; |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 10 | 11 | import org.springframework.stereotype.Component; |
| 11 | 12 | |
| 12 | 13 | import java.util.List; |
| ... | ... | @@ -21,6 +22,8 @@ public class SchInOutDataRefreshThread extends Thread { |
| 21 | 22 | static String url; |
| 22 | 23 | static String secretKey; |
| 23 | 24 | |
| 25 | + @Autowired | |
| 26 | + SchRealInfoBuffer schRealInfoBuffer; | |
| 24 | 27 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 25 | 28 | |
| 26 | 29 | static { |
| ... | ... | @@ -35,7 +38,7 @@ public class SchInOutDataRefreshThread extends Thread { |
| 35 | 38 | List<ScheduleRealInfo> list = JSON.parseArray(sb.toString(), ScheduleRealInfo.class); |
| 36 | 39 | |
| 37 | 40 | if(null != list && list.size() > 0){ |
| 38 | - SchRealInfoBuffer.inOutList = list; | |
| 41 | + schRealInfoBuffer.putInOutData(list); | |
| 39 | 42 | logger.info("从调度系统刷新进出场班次: " + list.size()); |
| 40 | 43 | } |
| 41 | 44 | } catch (Exception e) { | ... | ... |