Commit 9aaade0dec39ee3fa456a9ef85c616acabac0dad

Authored by 潘钊
1 parent ccac49b8

update...

Too many changes to show.

To preserve performance only 16 of 23 files are displayed.

src/main/java/com/bsth/controller/directive/DirectiveController.java
... ... @@ -63,7 +63,7 @@ public class DirectiveController {
63 63 * @throws
64 64 */
65 65 @RequestMapping(value = "/lineChnage", method = RequestMethod.POST)
66   - public int lineChange(@RequestParam String nbbm, @RequestParam Integer lineId){
  66 + public int lineChange(@RequestParam String nbbm, @RequestParam String lineId){
67 67 SysUser user = SecurityUtils.getCurrentUser();
68 68 return directiveService.lineChange(nbbm, lineId, user.getUserName());
69 69 }
... ...
src/main/java/com/bsth/controller/sys/UserController.java
... ... @@ -40,7 +40,8 @@ public class UserController extends BaseController<SysUser, Integer> {
40 40  
41 41 @RequestMapping(value = "/login", method = RequestMethod.POST)
42 42 public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName,
43   - @RequestParam String password) {
  43 + @RequestParam String password, String captcha) {
  44 +
44 45 Map<String, Object> rs = new HashMap<>();
45 46 rs.put("status", ResponseCode.ERROR);
46 47 try {
... ... @@ -51,29 +52,20 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt; {
51 52 //校验验证码
52 53 String verCode = (String) session
53 54 .getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
54   - String captcha = request.getParameter("captcha");
55 55  
56   - if(StringUtils.isBlank(captcha)){
57   - rs.put("msg", "请输入验证码");
58   - return rs;
59   - }
  56 + if(StringUtils.isBlank(captcha))
  57 + return put(rs, "msg", "请输入验证码");
60 58  
61   - if(!verCode.equals(captcha)){
62   - rs.put("msg", "验证码有误,请刷新后重新输入");
63   - return rs;
64   - }
  59 + if(!verCode.equals(captcha))
  60 + return put(rs, "msg", "验证码有误,请刷新后重新输入");
65 61 }
66 62  
67 63 SysUser user = sysUserService.findByUserName(userName);
68   - if (null == user) {
69   - rs.put("msg", "不存在的用户");
70   - return rs;
71   - }
  64 + if (null == user)
  65 + return put(rs, "msg", "不存在的用户");
72 66  
73   - if (!user.isEnabled()) {
74   - rs.put("msg", "该用户已被锁定,请联系管理员");
75   - return rs;
76   - }
  67 + if (!user.isEnabled())
  68 + return put(rs, "msg", "该用户已被锁定,请联系管理员");
77 69  
78 70 // 校验密码
79 71 password = fourDecodeBase64(password);
... ... @@ -109,6 +101,11 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt; {
109 101 Integer size = captchaMap.get(userName);
110 102 return size == null?0:size;
111 103 }
  104 +
  105 + public Map<String, Object> put(Map<String, Object> rs, String key, Object val){
  106 + rs.put(key, val);
  107 + return rs;
  108 + }
112 109  
113 110 private String fourDecodeBase64(String t) {
114 111 return new String(Base64.decodeBase64(Base64.decodeBase64(Base64.decodeBase64(Base64.decodeBase64(t)))));
... ...
src/main/java/com/bsth/controller/sys/util/jCryption.java 0 → 100644
  1 +package com.bsth.controller.sys.util;
  2 +
  3 +import java.io.UnsupportedEncodingException;
  4 +import java.net.URLDecoder;
  5 +import java.security.GeneralSecurityException;
  6 +import java.security.KeyPair;
  7 +import java.security.KeyPairGenerator;
  8 +import java.security.NoSuchAlgorithmException;
  9 +import java.security.interfaces.RSAPublicKey;
  10 +import java.util.HashMap;
  11 +import java.util.Map;
  12 +
  13 +import javax.crypto.Cipher;
  14 +
  15 +public class jCryption {
  16 +
  17 + public KeyPair generateKeypair(int keyLength) {
  18 + try {
  19 + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
  20 + kpg.initialize(keyLength);
  21 + return kpg.generateKeyPair();
  22 + } catch (NoSuchAlgorithmException e) {
  23 + throw new RuntimeException("RSA algorithm not supported",e);
  24 + }
  25 + }
  26 +
  27 + public String decrypt( String encrypted, KeyPair keys ) {
  28 + Cipher dec;
  29 + try {
  30 + dec = Cipher.getInstance("RSA/NONE/NoPadding");
  31 + dec.init(Cipher.DECRYPT_MODE, keys.getPrivate());
  32 + } catch (GeneralSecurityException e) {
  33 + throw new RuntimeException("RSA algorithm not supported",e);
  34 + }
  35 + String[] blocks = encrypted.split("\\s");
  36 + StringBuffer result = new StringBuffer();
  37 + try {
  38 + for ( int i = blocks.length-1; i >= 0; i-- ) {
  39 + byte[] data = hexStringToByteArray(blocks[i]);
  40 + byte[] decryptedBlock = dec.doFinal(data);
  41 + result.append( new String(decryptedBlock) );
  42 + }
  43 + } catch (GeneralSecurityException e) {
  44 + throw new RuntimeException("Decrypt error",e);
  45 + }
  46 + return result.reverse().toString();
  47 + }
  48 +
  49 + public static Map<String, String> parse(String url,String encoding) {
  50 + try {
  51 + String urlToParse = URLDecoder.decode(url,encoding);
  52 + String[] params = urlToParse.split("&");
  53 + Map<String, String> parsed = new HashMap<>();
  54 + for (int i = 0; i<params.length; i++ ) {
  55 + String[] p = params[i].split("=");
  56 + String name = p[0];
  57 + String value = (p.length==2)?p[1]:null;
  58 + parsed.put(name, value);
  59 + }
  60 + return parsed;
  61 + } catch (UnsupportedEncodingException e) {
  62 + throw new RuntimeException("Unknown encoding.",e);
  63 + }
  64 + }
  65 +
  66 + public static String getPublicKeyModulus( KeyPair keyPair ) {
  67 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
  68 + return publicKey.getModulus().toString(16);
  69 + }
  70 +
  71 + public static String getPublicKeyExponent( KeyPair keyPair ) {
  72 + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
  73 + return publicKey.getPublicExponent().toString(16);
  74 + }
  75 +
  76 + public static int getMaxDigits(int keyLength) {
  77 + return ((keyLength *2)/16)+3;
  78 + }
  79 +
  80 + public static String byteArrayToHexString(byte[] bytes) {
  81 + StringBuffer result = new StringBuffer();
  82 + for (int i=0; i < bytes.length; i++) {
  83 + result.append( Integer.toString( ( bytes[i] & 0xff ) + 0x100, 16).substring( 1 ) );
  84 + }
  85 + return result.toString();
  86 + }
  87 +
  88 + public static byte[] hexStringToByteArray(String data) {
  89 + int k = 0;
  90 + byte[] results = new byte[data.length() / 2];
  91 + for (int i = 0; i < data.length();) {
  92 + results[k] = (byte) (Character.digit(data.charAt(i++), 16) << 4);
  93 + results[k] += (byte) (Character.digit(data.charAt(i++), 16));
  94 + k++;
  95 + }
  96 + return results;
  97 + }
  98 +}
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -127,7 +127,7 @@ public class BasicData implements CommandLineRunner{
127 127  
128 128  
129 129 private void loadStationRouteInfo() {
130   - Iterator<StationRoute> iterator = stationRouteRepository.findAll2().iterator();
  130 + Iterator<StationRoute> iterator = stationRouteRepository.findAllEffective().iterator();
131 131 Map<String, Integer> map = new HashMap<>();
132 132 StationRoute route;
133 133  
... ...
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
... ... @@ -50,7 +50,7 @@ public class ArrivalData_GPS implements CommandLineRunner{
50 50  
51 51 @Override
52 52 public void run(String... arg0) throws Exception {
53   - Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 12, TimeUnit.SECONDS);
  53 + Application.mainServices.scheduleWithFixedDelay(dataLoaderThread, 30, 10, TimeUnit.SECONDS);
54 54 }
55 55  
56 56 @Component
... ...
src/main/java/com/bsth/data/directive/DirectiveCreator.java
... ... @@ -43,7 +43,7 @@ public class DirectiveCreator {
43 43 * @return Directive60 返回类型
44 44 * @throws
45 45 */
46   - public static D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state) {
  46 + public D60 createD60(String nbbm, String text, Short dispatchInstruct, int upDown, int state) {
47 47 Long timestamp = System.currentTimeMillis();
48 48  
49 49 Short company = Short.parseShort(BasicData.nbbm2CompanyCodeMap.get(nbbm));
... ... @@ -81,7 +81,7 @@ public class DirectiveCreator {
81 81 }
82 82  
83 83  
84   - public static D60 createD60_02(String nbbm, String text, int upDown, int state, Date alarmTime){
  84 + public D60 createD60_02(String nbbm, String text, int upDown, int state, Date alarmTime){
85 85 SimpleDateFormat sdfMMddHHmm = new SimpleDateFormat("MMddHHmm");
86 86  
87 87 Long timestamp = System.currentTimeMillis();
... ... @@ -129,19 +129,16 @@ public class DirectiveCreator {
129 129 * @param @param t 时间戳
130 130 * @throws
131 131 */
132   - public static D64 createD64(String nbbm, Integer lineCode, long t){
  132 + public D64 createD64(String nbbm, String lineCode, long t){
133 133 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
134 134  
135 135 D64 change = new D64();
136 136 D64Data data = new D64Data();
137 137 data.setCityCode(cityCode);
138 138 data.setDeviceId(deviceId);
  139 +
139 140 //线路编码补满6位数
140   - if(lineCode > 999999){
141   - logger.error("线路编码不能超过6位,code:" + lineCode);
142   - return null;
143   - }
144   - String lineCodeStr = String.format("%06d", lineCode);
  141 + String lineCodeStr = padLeft(lineCode, 6, '0');
145 142 data.setLineId(lineCodeStr);
146 143  
147 144 change.setDeviceId(deviceId);
... ... @@ -160,7 +157,7 @@ public class DirectiveCreator {
160 157 * @param @param lineId 线路ID
161 158 * @throws
162 159 */
163   - public static String createDeviceRefreshData(String deviceId, Integer lineCode) {
  160 + public String createDeviceRefreshData(String deviceId, String lineCode) {
164 161 Long t = System.currentTimeMillis();
165 162 Map<String, Object> param = new HashMap<>();
166 163 param.put("deviceId", deviceId);
... ... @@ -175,11 +172,7 @@ public class DirectiveCreator {
175 172 data.put("centerId", 1);
176 173  
177 174 //线路编码补满6位数
178   - if(lineCode > 999999){
179   - logger.error("线路编码不能超过6位,code:" + lineCode);
180   - return null;
181   - }
182   - String lineCodeStr = String.format("%06d", lineCode);
  175 + String lineCodeStr = padLeft(lineCode, 6, '0');
183 176  
184 177 data.put("lineId", lineCodeStr);
185 178 data.put("lineVersion", 0);
... ... @@ -189,7 +182,15 @@ public class DirectiveCreator {
189 182 return JSON.toJSONString(param);
190 183 }
191 184  
192   - public static void main(String[] args) {
193   - System.out.println(String.format("%06d", "1025"));
194   - }
  185 + public String padLeft(String oriStr,int len,char alexin){
  186 + String str = "";
  187 + int strlen = oriStr.length();
  188 + if(strlen < len){
  189 + for(int i=0;i<len-strlen;i++){
  190 + str = str+alexin;
  191 + }
  192 + }
  193 + str = str + oriStr;
  194 + return str;
  195 + }
195 196 }
... ...
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
... ... @@ -103,7 +103,6 @@ public class ForecastRealServer implements CommandLineRunner {
103 103 , gps.getStopNo(), eStation
104 104 , t - gps.getArrTime()));
105 105  
106   -
107 106 forecastMap.put(nbbm, forecastRes);
108 107 //GPS附加预计终点时间
109 108 gps.setExpectStopTime(expectStopTime(nbbm));
... ... @@ -118,14 +117,24 @@ public class ForecastRealServer implements CommandLineRunner {
118 117 * @Description: TODO(预计到达终点时间)
119 118 */
120 119 public Float expectStopTime(String nbbm){
121   - long t = System.currentTimeMillis();
  120 + long t = System.currentTimeMillis()
  121 + ,diff = 0L
  122 + ,firstExpTime;
122 123  
123 124 Float rs = null;
124 125 ForecastResult forecastRes = forecastMap.get(nbbm);
125   - if(null != forecastRes){
126   - List<ForecastResultItem> trs = forecastRes.getFollows();
127   - if(null != trs && trs.size() > 0)
128   - rs = ((float)((trs.get(trs.size() - 1).getTime()) - t)) / 1000 / 60;
  126 + if(null == forecastRes)
  127 + return rs;
  128 +
  129 + List<ForecastResultItem> trs = forecastRes.getFollows();
  130 + if(null != trs && trs.size() > 0){
  131 +
  132 + //当前时间已超过第一个预计到站时间,后续预测时间补上差值
  133 + firstExpTime = trs.get(0).getTime();
  134 + if(firstExpTime < t)
  135 + diff = t - firstExpTime;
  136 +
  137 + rs = ((float)((trs.get(trs.size() - 1).getTime()) - t + diff)) / 1000 / 60;
129 138 }
130 139  
131 140 //保留2位小数
... ...
src/main/java/com/bsth/data/forecast/SampleTimeDataLoader.java
... ... @@ -61,7 +61,7 @@ public class SampleTimeDataLoader extends Thread {
61 61 }
62 62  
63 63 // 加载全部路由信息
64   - List<StationRoute> allRoutes = stationRouteRepository.findAll2();
  64 + List<StationRoute> allRoutes = stationRouteRepository.findAllEffective();
65 65 // 线路和走向分组
66 66 ArrayListMultimap<String, StationRoute> groupMap = ArrayListMultimap.create();
67 67 for (StationRoute sr : allRoutes)
... ...
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
... ... @@ -71,7 +71,7 @@ public class GpsRealData implements CommandLineRunner{
71 71  
72 72 @Override
73 73 public void run(String... arg0) throws Exception {
74   - Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 8, TimeUnit.SECONDS);
  74 + Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 7, TimeUnit.SECONDS);
75 75 }
76 76  
77 77 public GpsEntity add(GpsEntity gps) {
... ...
src/main/java/com/bsth/data/match/Arrival2Schedule.java
... ... @@ -91,14 +91,6 @@ public class Arrival2Schedule implements ApplicationContextAware {
91 91 for(ArrivalEntity arr : arrList){
92 92 match(arr, schList);
93 93 }
94   -
95   - //车辆关联到班次
96   - //ScheduleRealInfo sch = dayOfSchedule.execPlamMap().get(this.nbbm);
97   - //if(null == sch){
98   - //dayOfSchedule.findByNbbm(this.nbbm);
99   - //dayOfSchedule.addExecPlan(sch);
100   - //dayOfSchedule.linkToSchPlan(this.nbbm);
101   - //}
102 94 }
103 95  
104 96 private void match(ArrivalEntity arr, List<ScheduleRealInfo> schList) {
... ... @@ -166,13 +158,7 @@ public class Arrival2Schedule implements ApplicationContextAware {
166 158  
167 159 //漂移判定
168 160 if(driftCheck(mr, arr)){
169   - mr.sch.setFcsjActualAll(mr.ts);
170   - //通知客户端
171   - sendUtils.sendFcsj(mr.sch);
172   - //持久化
173   - dayOfSchedule.save(mr.sch);
174   - //车辆当前执行班次
175   - dayOfSchedule.addExecPlan(mr.sch);
  161 + carOut(mr);
176 162 }
177 163 }
178 164 }
... ... @@ -213,29 +199,58 @@ public class Arrival2Schedule implements ApplicationContextAware {
213 199 //排序后的第一个 就是最合适的匹配
214 200 Collections.sort(mrs, mrComparator);
215 201 mr = mrs.get(0);
216   - mr.sch.setZdsjActualAll(mr.ts);
  202 + carInStop(mr);
  203 + }
  204 + }
  205 +
  206 + /**
  207 + *
  208 + * @Title: carOut
  209 + * @Description: TODO(车辆发出)
  210 + */
  211 + public void carOut(MatchResult mr){
  212 + //设置发车时间
  213 + mr.sch.setFcsjActualAll(mr.ts);
  214 + //通知客户端
  215 + sendUtils.sendFcsj(mr.sch);
  216 + //持久化
  217 + dayOfSchedule.save(mr.sch);
  218 + //车辆当前执行班次
  219 + dayOfSchedule.addExecPlan(mr.sch);
  220 + }
  221 +
  222 + /**
  223 + *
  224 + * @Title: carInStop
  225 + * @Description: TODO(车辆进入终点站)
  226 + */
  227 + public void carInStop(MatchResult mr){
  228 + mr.sch.setZdsjActualAll(mr.ts);
  229 +
  230 + int doneSum = dayOfSchedule.doneSum(mr.sch.getClZbh());
  231 + ScheduleRealInfo next = dayOfSchedule.next(mr.sch);
  232 + if(null != next){
  233 + next.setQdzArrDateSJ(mr.sch.getZdsjActual());
  234 + //下发调度指令
  235 + directiveService.send60Dispatch(next, doneSum, "到站@系统");
217 236  
218   - int doneSum = dayOfSchedule.doneSum(mr.sch.getClZbh());
219   - ScheduleRealInfo next = dayOfSchedule.next(mr.sch);
220   - if(null != next){
221   - next.setQdzArrDateSJ(mr.sch.getZdsjActual());
222   - //下发调度指令
223   - directiveService.send60Dispatch(next, doneSum, "到站@系统");
224   -
225   - //起点既停车场的进场班次
226   - if(next.getBcType().equals("in") && next.getJhlc() == null)
227   - next.setFcsjActualAll(mr.ts);
228   - }
229   - else//下发文本指令(已结束运营)
230   - directiveService.send60Phrase(nbbm, "到达终点 " + mr.sch.getZdzName() + ",已完成当日所有排班。", "系统");
231   - //通知客户端
232   - sendUtils.sendZdsj(mr.sch, next, doneSum);
233   - //持久化
234   - dayOfSchedule.save(mr.sch);
235   - logger.info(mr.sch.getClZbh() + "移除正在执行班次," + mr.sch.getFcsj());
236   - //移除车辆正在执行班次引用
237   - dayOfSchedule.removeExecPlan(mr.sch.getClZbh());
  237 + //完成“起点既停车场”的进场班次
  238 + if(next.getBcType().equals("in") && next.getJhlc() == null)
  239 + next.setFcsjActualAll(mr.ts);
  240 +
  241 + //套跑 -下发线路切换指令
  242 + if(!next.getXlBm().equals(mr.sch.getXlBm()))
  243 + directiveService.lineChange(next.getClZbh(), next.getXlBm(), "套跑@系统");
238 244 }
  245 + else//下发文本指令(已结束运营)
  246 + directiveService.send60Phrase(nbbm, "到达终点 " + mr.sch.getZdzName() + ",已完成当日所有排班。", "系统");
  247 + //通知客户端
  248 + sendUtils.sendZdsj(mr.sch, next, doneSum);
  249 + //持久化
  250 + dayOfSchedule.save(mr.sch);
  251 + logger.info(mr.sch.getClZbh() + "移除正在执行班次," + mr.sch.getFcsj());
  252 + //移除车辆正在执行班次索引
  253 + dayOfSchedule.removeExecPlan(mr.sch.getClZbh());
239 254 }
240 255  
241 256 /**
... ...
src/main/java/com/bsth/data/match/Arrival2Schedule_old.java deleted 100644 → 0
1   -package com.bsth.data.match;
2   -//package com.bsth.data.match;
3   -//
4   -//import java.util.ArrayList;
5   -//import java.util.Collections;
6   -//import java.util.List;
7   -//import java.util.Set;
8   -//
9   -//import org.slf4j.Logger;
10   -//import org.slf4j.LoggerFactory;
11   -//import org.springframework.beans.BeansException;
12   -//import org.springframework.context.ApplicationContext;
13   -//import org.springframework.context.ApplicationContextAware;
14   -//import org.springframework.stereotype.Component;
15   -//
16   -//import com.bsth.data.arrival.ArrivalComparator;
17   -//import com.bsth.data.arrival.ArrivalData_GPS;
18   -//import com.bsth.data.arrival.ArrivalEntity;
19   -//import com.bsth.data.schedule.DayOfSchedule;
20   -//import com.bsth.data.schedule.ScheduleComparator;
21   -//import com.bsth.entity.realcontrol.ScheduleRealInfo;
22   -//import com.bsth.service.directive.DirectiveService;
23   -//import com.bsth.websocket.handler.SendUtils;
24   -//
25   -///**
26   -// *
27   -// * @ClassName: Arrival2Schedule
28   -// * @Description: TODO(进出数据匹配班次)
29   -// * @author PanZhao
30   -// * @date 2016年8月10日 下午2:26:22
31   -// *
32   -// */
33   -//@Component
34   -//public class Arrival2Schedule implements ApplicationContextAware{
35   -//
36   -// private static ScheduleComparator.FCSJ schComparator;
37   -// private static ArrivalComparator arrComparator;
38   -// private static SendUtils sendUtils;
39   -// private static DayOfSchedule dayOfSchedule;
40   -// private static DirectiveService directiveService;
41   -//
42   -// private final static long MAX_RANGE = 1000 * 60 * 60 * 1L;
43   -//
44   -// static{
45   -// schComparator = new ScheduleComparator.FCSJ();
46   -// arrComparator = new ArrivalComparator();
47   -// }
48   -//
49   -// static Logger logger = LoggerFactory.getLogger(Arrival2Schedule.class);
50   -//
51   -// /**
52   -// *
53   -// * @Title: start
54   -// * @Description: TODO(开始)
55   -// * @param @param cars 需要匹配的车辆集合
56   -// */
57   -// public static void start(Set<String> cars){
58   -//
59   -// for(String car : cars){
60   -// new GpsMatchThread(car).start();
61   -// }
62   -// }
63   -//
64   -// public static class GpsMatchThread extends Thread{
65   -//
66   -// String nbbm;
67   -// public GpsMatchThread(String nbbm){
68   -// this.nbbm = nbbm;
69   -// }
70   -//
71   -// @Override
72   -// public void run() {
73   -// //班次列表
74   -// List<ScheduleRealInfo> schList = dayOfSchedule.findByNbbm(nbbm);
75   -// //进出起终点数据
76   -// List<ArrivalEntity> arrList = ArrivalData_GPS.getIncrement(nbbm);
77   -// logger.info("####匹配进出站增量数据 " + arrList.size());
78   -// //排序
79   -// Collections.sort(schList, schComparator);
80   -// Collections.sort(arrList, arrComparator);
81   -//
82   -// int si = lastMatchPoint(schList);
83   -// int ai = afterByTime(arrList, lastMatchTime(schList.get(si)));
84   -//
85   -// //按起始索引开始匹配
86   -// match(arrList, ai, schList, si);
87   -// }
88   -//
89   -// public void match(List<ArrivalEntity> arrList, int ai, List<ScheduleRealInfo> schList, int si){
90   -//
91   -// int sLen = schList.size();
92   -// for(; si < sLen; si ++)
93   -// match(arrList, ai, schList.get(si));
94   -// }
95   -//
96   -// public void match(List<ArrivalEntity> arrList, int ai, ScheduleRealInfo sch){
97   -// //烂班不参与
98   -// if(sch.isDestroy())
99   -// return;
100   -//
101   -// int aLen = arrList.size();
102   -//
103   -// List<MatchResult> inRsList = new ArrayList<>()
104   -// ,outRsList = new ArrayList<>();
105   -//
106   -// MatchResult mrs;
107   -// for(;ai < aLen; ai ++){
108   -// mrs = match(arrList.get(ai), sch);
109   -// if(!mrs.success)
110   -// continue;
111   -//
112   -// if(mrs.inOut == 0)
113   -// inRsList.add(mrs);
114   -// else if(mrs.inOut == 1)
115   -// outRsList.add(mrs);
116   -// }
117   -//
118   -// if(outRsList.size() > 0){
119   -// //排序后的第一个 就是最合适的匹配
120   -// Collections.sort(outRsList, new MatchResultComparator());
121   -// mrs = outRsList.get(0);
122   -//
123   -// mrs.sch.setFcsjActualAll(mrs.ts);
124   -// //通知客户端
125   -// sendUtils.sendFcsj(mrs.sch);
126   -// //持久化
127   -// dayOfSchedule.save(mrs.sch);
128   -// }
129   -//
130   -// if(inRsList.size() > 0){
131   -// //排序后的第一个 就是最合适的匹配
132   -// Collections.sort(inRsList, new MatchResultComparator());
133   -// mrs = inRsList.get(0);
134   -//
135   -// /*if(!dayOfSchedule.validEndTime(mrs.sch, mrs.ts)){
136   -// return;
137   -// }*/
138   -//
139   -// mrs.sch.setZdsjActualAll(mrs.ts);
140   -// int doneSum = dayOfSchedule.doneSum(mrs.sch.getClZbh());
141   -// ScheduleRealInfo next = dayOfSchedule.next(mrs.sch);
142   -// if(null != next){
143   -// next.setQdzArrDateSJ(mrs.sch.getZdsjActual());
144   -// //下发调度指令
145   -// directiveService.send60Dispatch(next, doneSum, "系统");
146   -// }
147   -// else{
148   -// //下发文本指令(已结束运营)
149   -// directiveService.send60Phrase(nbbm, "到达终点 " + mrs.sch.getZdzName() + ",已完成当日所有排班。", "系统");
150   -// }
151   -// //通知客户端
152   -// sendUtils.sendZdsj(mrs.sch, next, doneSum);
153   -// //持久化
154   -// dayOfSchedule.save(mrs.sch);
155   -// }
156   -// }
157   -//
158   -// public MatchResult match(ArrivalEntity arr, ScheduleRealInfo sch){
159   -// MatchResult mrs = new MatchResult();
160   -// mrs.inOut = arr.getInOut();
161   -// mrs.sch = sch;
162   -// mrs.ts = arr.getTs();
163   -//
164   -// if(Integer.parseInt(sch.getXlDir()) != arr.getUpDown()){
165   -// return mrs;
166   -// }
167   -//
168   -// if(arr.getInOut() == 1){
169   -// if(sch.getFcsjActual() == null
170   -// && sch.getQdzCode().equals(arr.getStopNo())
171   -// && dayOfSchedule.validStartTime(sch, arr.getTs())){
172   -//
173   -// mrs.diff = arr.getTs() - sch.getDfsjT();
174   -// if(Math.abs(mrs.diff) < MAX_RANGE)
175   -// mrs.success = true;
176   -// }
177   -// }
178   -// else if(arr.getInOut() == 0 && sch.getZdsj() != null){
179   -// if(sch.getZdsjActual() == null
180   -// && sch.getZdzCode().equals(arr.getStopNo())
181   -// && dayOfSchedule.validEndTime(sch, arr.getTs())){
182   -//
183   -// mrs.diff = arr.getTs() - sch.getZdsjT();
184   -// if(Math.abs(mrs.diff) < MAX_RANGE)
185   -// mrs.success = true;
186   -// }
187   -// }
188   -//
189   -// return mrs;
190   -// }
191   -//
192   -// /**
193   -// *
194   -// * @Title: lastMatchPoint
195   -// * @Description: TODO(最后一个已实发的班次索引)
196   -// */
197   -// public int lastMatchPoint(List<ScheduleRealInfo> schList){
198   -// int len = schList.size()
199   -// ,rs = 0;
200   -//
201   -// ScheduleRealInfo sch;
202   -// for(int i = len - 2; i >= 0; i --){
203   -// sch = schList.get(i);
204   -// if(sch.getFcsjActual() != null){
205   -// rs = i;
206   -// if(sch.getStatus() == 2)
207   -// rs ++;
208   -// break;
209   -// }
210   -// }
211   -// return rs;
212   -// }
213   -//
214   -// public long lastMatchTime(ScheduleRealInfo sch){
215   -// Long t = 0L;
216   -// if(null != sch.getFcsjActualTime())
217   -// t = sch.getFcsjActualTime();
218   -// if(null != sch.getZdsjActualTime())
219   -// t = sch.getZdsjActualTime();
220   -// return t;
221   -// }
222   -//
223   -// /**
224   -// *
225   -// * @Title: afterByTime
226   -// * @Description: TODO(参数时间戳之后的起始索引)
227   -// */
228   -// public int afterByTime(List<ArrivalEntity> arrList, long t){
229   -// int len = arrList.size()
230   -// ,rs = len - 1;
231   -//
232   -// for(int i = 0; i < len; i ++){
233   -// if(arrList.get(i).getTs() > t){
234   -// rs = i;
235   -// break;
236   -// }
237   -// }
238   -// return rs;
239   -// }
240   -// }
241   -//
242   -// @Override
243   -// public void setApplicationContext(ApplicationContext arg0) throws BeansException {
244   -// sendUtils = arg0.getBean(SendUtils.class);
245   -// dayOfSchedule = arg0.getBean(DayOfSchedule.class);
246   -// directiveService = arg0.getBean(DirectiveService.class);
247   -// }
248   -//}
src/main/java/com/bsth/repository/StationRouteRepository.java
... ... @@ -6,6 +6,7 @@ import java.util.Map;
6 6 import com.bsth.entity.schedule.CarConfigInfo;
7 7 import org.springframework.data.domain.Page;
8 8 import org.springframework.data.domain.Pageable;
  9 +import org.springframework.data.domain.Sort;
9 10 import org.springframework.data.jpa.domain.Specification;
10 11 import org.springframework.data.jpa.repository.EntityGraph;
11 12 import org.springframework.data.jpa.repository.Modifying;
... ... @@ -229,9 +230,22 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
229 230  
230 231 @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
231 232 @Query("select s from StationRoute s where s.destroy=0")
232   - List<StationRoute> findAll2();
  233 + List<StationRoute> findAllEffective();
233 234  
234   - @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2")
  235 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  236 + @Override
  237 + Page<StationRoute> findAll(Specification<StationRoute> spec, Pageable pageable);
  238 +
  239 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  240 + @Override
  241 + List<StationRoute> findAll(Specification<StationRoute> spec);
  242 +
  243 + @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH)
  244 + @Override
  245 + List<StationRoute> findAll(Specification<StationRoute> spec, Sort sort);
  246 +
  247 +
  248 + @Query("select new map(sr.station.id as stationid, sr.stationName as stationname) from StationRoute sr where sr.line.id=?1 and sr.directions=?2")
235 249 List<Map<String, Object>> findStations(Integer xlid, Integer xldir);
236 250  
237 251 @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode")
... ...
src/main/java/com/bsth/service/directive/DirectiveService.java
... ... @@ -53,7 +53,7 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
53 53 * @param @param lineId 新线路编码
54 54 * @throws
55 55 */
56   - int lineChange(String nbbm, Integer lineId, String sender);
  56 + int lineChange(String nbbm, String lineId, String sender);
57 57  
58 58 /**
59 59 *
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -38,7 +38,6 @@ import com.bsth.repository.directive.D64Repository;
38 38 import com.bsth.repository.directive.D80Repository;
39 39 import com.bsth.security.util.SecurityUtils;
40 40 import com.bsth.service.impl.BaseServiceImpl;
41   -import com.bsth.util.DateUtils;
42 41 import com.bsth.websocket.handler.RealControlSocketHandler;
43 42 import com.fasterxml.jackson.core.JsonProcessingException;
44 43 import com.fasterxml.jackson.databind.ObjectMapper;
... ... @@ -119,7 +118,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
119 118  
120 119 //下发0x02指令 调度指令(闹钟有效)
121 120 Long alarmTime = System.currentTimeMillis() + 1000 * 30;
122   - d60 = DirectiveCreator.createD60_02(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir())
  121 + d60 = new DirectiveCreator().createD60_02(sch.getClZbh(), text, Integer.parseInt(sch.getXlDir())
123 122 , 0, new Date(alarmTime));
124 123 } catch (Exception e) {
125 124 logger.error("生成调度指令时出现异常", e);
... ... @@ -193,7 +192,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
193 192 logger.info("切换运营状态, nbbm: " + nbbm + " ,state: " + state + " ,upDown:" + upDown);
194 193  
195 194 String text = "切换为 " + (upDown == 0 ? "上行" : "下行") + (state == 0 ? "营运" : "未营运");
196   - D60 d60 = DirectiveCreator.createD60(nbbm, text, (short) 0x03, upDown, state);
  195 + D60 d60 = new DirectiveCreator().createD60(nbbm, text, (short) 0x03, upDown, state);
197 196  
198 197 if (null == d60)
199 198 return -1;
... ... @@ -220,10 +219,12 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
220 219 * 线路切换
221 220 */
222 221 @Override
223   - public int lineChange(String nbbm, Integer lineCode, String sender) {
  222 + public int lineChange(String nbbm, String lineCode, String sender) {
  223 + DirectiveCreator crt = new DirectiveCreator();
  224 +
224 225 Long t = System.currentTimeMillis();
225 226 //生成64数据包
226   - D64 d64 = DirectiveCreator.createD64(nbbm, lineCode, t);
  227 + D64 d64 = crt.createD64(nbbm, lineCode, t);
227 228  
228 229 if(null != sender)
229 230 d64.setSender(sender);
... ... @@ -238,7 +239,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
238 239  
239 240 // 通知设备刷新线路文件,忽略结果
240 241 if (code == 0)
241   - GatewayHttpUtils.postJson(DirectiveCreator.createDeviceRefreshData(deviceId, lineCode));
  242 + GatewayHttpUtils.postJson(crt.createDeviceRefreshData(deviceId, lineCode));
242 243 else
243 244 d64.setErrorText("[刷新线路文件] 网关通讯失败, code: " + code);
244 245  
... ... @@ -278,7 +279,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
278 279 state = 0;
279 280 }
280 281  
281   - return DirectiveCreator.createD60(nbbm, text, dispatchInstruct, upDown, state);
  282 + return new DirectiveCreator().createD60(nbbm, text, dispatchInstruct, upDown, state);
282 283 }
283 284  
284 285 @Override
... ...
src/main/java/com/bsth/service/forecast/SampleServiceImpl.java
... ... @@ -66,7 +66,8 @@ public class SampleServiceImpl extends BaseServiceImpl&lt;Sample, Long&gt; implements
66 66  
67 67 @Override
68 68 public Map<String, Object> save(Sample t) {
69   - t.setTag(t.getTag() + t.getsDate() + " - " + t.geteDate());
  69 + if(null == t.getId())
  70 + t.setTag(t.getTag() + t.getsDate() + " - " + t.geteDate());
70 71 return super.save(t);
71 72 }
72 73  
... ...
src/main/resources/application-dev.properties
... ... @@ -26,6 +26,6 @@ spring.datasource.validation-query=select 1
26 26 ##
27 27 #222.66.0.204:5555
28 28 ##\u5B9E\u65F6gps
29   -http.gps.real.url= http://192.168.168.192:8080/transport_server/rtgps/
  29 +http.gps.real.url= http://27.115.69.123:8800/transport_server/rtgps/
30 30 ##\u6D88\u606F\u4E0B\u53D1
31   -http.send.directive = http://192.168.168.192:8080/transport_server/message/
32 31 \ No newline at end of file
  32 +http.send.directive = http://192.168.168.201:9090/transport_server/message/
33 33 \ No newline at end of file
... ...