Commit ba7766fd1cb527b740cf3d56b7f552ef827b5765

Authored by 娄高锋
2 parents 55929802 01d68b3d

Merge branch 'minhang' of 192.168.168.201:panzhaov5/bsth_control into minhang

Showing 32 changed files with 685 additions and 78 deletions

Too many changes to show.

To preserve performance only 32 of 75 files are displayed.

@@ -251,7 +251,7 @@ @@ -251,7 +251,7 @@
251 <groupId>org.drools</groupId> 251 <groupId>org.drools</groupId>
252 <artifactId>drools-bom</artifactId> 252 <artifactId>drools-bom</artifactId>
253 <type>pom</type> 253 <type>pom</type>
254 - <version>6.2.0.Final</version> 254 + <version>6.3.0.Final</version>
255 <scope>import</scope> 255 <scope>import</scope>
256 </dependency> 256 </dependency>
257 </dependencies> 257 </dependencies>
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
@@ -22,6 +22,9 @@ public class BasicDataController { @@ -22,6 +22,9 @@ public class BasicDataController {
22 @Autowired 22 @Autowired
23 BasicData.BasicDataLoader dataLoader; 23 BasicData.BasicDataLoader dataLoader;
24 24
  25 + @Autowired
  26 + BasicData basicData;
  27 +
25 Logger logger = LoggerFactory.getLogger(this.getClass()); 28 Logger logger = LoggerFactory.getLogger(this.getClass());
26 29
27 @RequestMapping("/cars") 30 @RequestMapping("/cars")
@@ -114,4 +117,13 @@ public class BasicDataController { @@ -114,4 +117,13 @@ public class BasicDataController {
114 } 117 }
115 return rs; 118 return rs;
116 } 119 }
  120 +
  121 + /**
  122 + * 车辆自编号和车牌号对照
  123 + * @return
  124 + */
  125 + @RequestMapping("/nbbm2PlateNo")
  126 + public Map<String, String> nbbm2PlateNo(){
  127 + return basicData.getNbbm2PlateNo();
  128 + }
117 } 129 }
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -7,6 +7,7 @@ import com.bsth.controller.realcontrol.dto.DfsjChange; @@ -7,6 +7,7 @@ import com.bsth.controller.realcontrol.dto.DfsjChange;
7 import com.bsth.data.BasicData; 7 import com.bsth.data.BasicData;
8 import com.bsth.data.schedule.DayOfSchedule; 8 import com.bsth.data.schedule.DayOfSchedule;
9 import com.bsth.entity.realcontrol.ScheduleRealInfo; 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.entity.schedule.SchedulePlanInfo;
10 import com.bsth.service.realcontrol.ScheduleRealInfoService; 11 import com.bsth.service.realcontrol.ScheduleRealInfoService;
11 import org.apache.commons.lang3.StringEscapeUtils; 12 import org.apache.commons.lang3.StringEscapeUtils;
12 import org.joda.time.format.DateTimeFormat; 13 import org.joda.time.format.DateTimeFormat;
@@ -439,5 +440,13 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -439,5 +440,13 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
439 public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){ 440 public Map<String, Object> exportWaybillMore(@RequestParam Map<String, Object> map){
440 return scheduleRealInfoService.exportWaybillMore(map); 441 return scheduleRealInfoService.exportWaybillMore(map);
441 } 442 }
442 - 443 +
  444 + /**
  445 + * 获取当日计划排班 , 从计划表抓取数据
  446 + * @return
  447 + */
  448 + @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
  449 + public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
  450 + return scheduleRealInfoService.currentSchedulePlan(lineCode);
  451 + }
443 } 452 }
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
1 package com.bsth.controller.schedule.core; 1 package com.bsth.controller.schedule.core;
2 2
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.common.ResponseCode;
3 import com.bsth.controller.schedule.BController; 5 import com.bsth.controller.schedule.BController;
4 import com.bsth.entity.schedule.SchedulePlan; 6 import com.bsth.entity.schedule.SchedulePlan;
  7 +import com.bsth.entity.sys.CompanyAuthority;
  8 +import com.bsth.entity.sys.SysUser;
5 import com.bsth.service.schedule.SchedulePlanService; 9 import com.bsth.service.schedule.SchedulePlanService;
  10 +import com.bsth.service.sys.SysUserService;
6 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
7 -import org.springframework.web.bind.annotation.RequestMapping;  
8 -import org.springframework.web.bind.annotation.RequestMethod;  
9 -import org.springframework.web.bind.annotation.RestController; 12 +import org.springframework.web.bind.annotation.*;
  13 +
  14 +import javax.servlet.http.HttpSession;
  15 +import java.util.Date;
  16 +import java.util.HashMap;
  17 +import java.util.List;
  18 +import java.util.Map;
10 19
11 /** 20 /**
12 * Created by xu on 16/6/16. 21 * Created by xu on 16/6/16.
@@ -16,6 +25,33 @@ import org.springframework.web.bind.annotation.RestController; @@ -16,6 +25,33 @@ import org.springframework.web.bind.annotation.RestController;
16 public class SchedulePlanController extends BController<SchedulePlan, Long> { 25 public class SchedulePlanController extends BController<SchedulePlan, Long> {
17 @Autowired 26 @Autowired
18 private SchedulePlanService schedulePlanService; 27 private SchedulePlanService schedulePlanService;
  28 + @Autowired
  29 + private SysUserService sysUserService;
  30 +
  31 + @Override
  32 + public Map<String, Object> save(@RequestBody SchedulePlan schedulePlan, HttpSession httpSession) {
  33 + // 用户信息
  34 + String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME));
  35 + SysUser sysUser = sysUserService.findByUserName(userName);
  36 +
  37 + Date cdate = new Date();
  38 + schedulePlan.setCreateBy(sysUser);
  39 + schedulePlan.setCreateDate(cdate);
  40 + schedulePlan.setUpdateBy(sysUser);
  41 + schedulePlan.setUpdateDate(cdate);
  42 +
  43 + // 如果多个公司,选第一个,以后改成页面控制
  44 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) httpSession.getAttribute(Constants.COMPANY_AUTHORITYS);
  45 + if (cmyAuths == null || cmyAuths.size() == 0)
  46 + schedulePlanService.save(schedulePlan, new CompanyAuthority());
  47 + else
  48 + schedulePlanService.save(schedulePlan, cmyAuths.get(0));
  49 +
  50 + Map<String, Object> rtn = new HashMap<>();
  51 + rtn.put("status", ResponseCode.SUCCESS);
  52 + rtn.put("data", new Object());
  53 + return rtn;
  54 + }
19 55
20 /** 56 /**
21 * 获取明天的一歌排班计划。 57 * 获取明天的一歌排班计划。
@@ -31,4 +67,24 @@ public class SchedulePlanController extends BController&lt;SchedulePlan, Long&gt; { @@ -31,4 +67,24 @@ public class SchedulePlanController extends BController&lt;SchedulePlan, Long&gt; {
31 } 67 }
32 } 68 }
33 69
  70 + /**
  71 + * 创建指定线路,指定时间范围内的排班计划,使用的时刻表情况
  72 + * @param xlid 线路id
  73 + * @param from 开始时间
  74 + * @param to 结束时间
  75 + * @return
  76 + * @throws Exception
  77 + */
  78 + @RequestMapping(value = "/valttinfo/{xlid}/{from}/{to}", method = RequestMethod.GET)
  79 + public Map<String, Object> validateTTInfo(
  80 + @PathVariable(value = "xlid") Integer xlid,
  81 + @PathVariable(value = "from") Date from,
  82 + @PathVariable(value = "to") Date to
  83 + ) throws Exception {
  84 + Map<String, Object> rtn = new HashMap<>();
  85 + rtn.put("status", ResponseCode.SUCCESS);
  86 + rtn.put("data", schedulePlanService.validateTTInfo(xlid, from, to));
  87 + return rtn;
  88 + }
  89 +
34 } 90 }
src/main/java/com/bsth/data/BasicData.java
@@ -13,6 +13,7 @@ import org.slf4j.Logger; @@ -13,6 +13,7 @@ import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 13 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.boot.CommandLineRunner; 15 import org.springframework.boot.CommandLineRunner;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
16 import org.springframework.stereotype.Component; 17 import org.springframework.stereotype.Component;
17 18
18 import java.util.*; 19 import java.util.*;
@@ -89,6 +90,18 @@ public class BasicData implements CommandLineRunner { @@ -89,6 +90,18 @@ public class BasicData implements CommandLineRunner {
89 return name != null? name: stationCode2NameMap.get(prefix + code); 90 return name != null? name: stationCode2NameMap.get(prefix + code);
90 } 91 }
91 92
  93 + @Autowired
  94 + JdbcTemplate jdbcTemplate;
  95 + public Map<String, String> getNbbm2PlateNo(){
  96 + List<Map<String, Object>> list = jdbcTemplate.queryForList("select CAR_CODE,CAR_PLATE from bsth_c_cars where CAR_CODE is not null and CAR_PLATE is not null");
  97 +
  98 + Map<String, String> rs = new HashMap<>();
  99 + for(Map<String, Object> map : list){
  100 + rs.put(map.get("CAR_CODE").toString(), map.get("CAR_PLATE").toString());
  101 + }
  102 + return rs;
  103 + }
  104 +
92 @Component 105 @Component
93 public static class BasicDataLoader extends Thread { 106 public static class BasicDataLoader extends Thread {
94 107
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
@@ -3,6 +3,7 @@ package com.bsth.data.gpsdata; @@ -3,6 +3,7 @@ package com.bsth.data.gpsdata;
3 import com.bsth.data.BasicData; 3 import com.bsth.data.BasicData;
4 import com.bsth.data.forecast.ForecastRealServer; 4 import com.bsth.data.forecast.ForecastRealServer;
5 import com.bsth.data.gpsdata.thread.GpsDataLoaderThread; 5 import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  6 +import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
6 import com.bsth.data.schedule.DayOfSchedule; 7 import com.bsth.data.schedule.DayOfSchedule;
7 import com.bsth.entity.realcontrol.ScheduleRealInfo; 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 import com.google.common.collect.TreeMultimap; 9 import com.google.common.collect.TreeMultimap;
@@ -35,6 +36,9 @@ public class GpsRealData implements CommandLineRunner { @@ -35,6 +36,9 @@ public class GpsRealData implements CommandLineRunner {
35 GpsDataLoaderThread gpsDataLoader; 36 GpsDataLoaderThread gpsDataLoader;
36 37
37 @Autowired 38 @Autowired
  39 + OfflineMonitorThread offlineMonitorThread;
  40 +
  41 + @Autowired
38 DayOfSchedule dayOfSchedule; 42 DayOfSchedule dayOfSchedule;
39 43
40 @Autowired 44 @Autowired
@@ -52,11 +56,12 @@ public class GpsRealData implements CommandLineRunner { @@ -52,11 +56,12 @@ public class GpsRealData implements CommandLineRunner {
52 public void run(String... arg0) throws Exception { 56 public void run(String... arg0) throws Exception {
53 logger.info("gpsDataLoader,20,5"); 57 logger.info("gpsDataLoader,20,5");
54 //定时从网关获取GPS数据 58 //定时从网关获取GPS数据
55 - //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 15, TimeUnit.SECONDS); 59 + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 5, TimeUnit.SECONDS);
56 //定时扫描掉离线 60 //定时扫描掉离线
57 - 61 + //Application.mainServices.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);
58 } 62 }
59 63
  64 +
60 public void put(GpsEntity gps) { 65 public void put(GpsEntity gps) {
61 String device = gps.getDeviceId(); 66 String device = gps.getDeviceId();
62 GpsEntity old = gpsMap.get(device); 67 GpsEntity old = gpsMap.get(device);
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
@@ -19,10 +19,22 @@ public abstract class SignalHandle { @@ -19,10 +19,22 @@ public abstract class SignalHandle {
19 return prevs != null && prevs.size() > 0 && prevs.getTail() != null; 19 return prevs != null && prevs.size() > 0 && prevs.getTail() != null;
20 } 20 }
21 21
22 - protected boolean isDriftSignal(GpsEntity gps) { 22 +/* protected boolean isDriftSignal(GpsEntity gps) {
  23 + return gps.getLat() == 0 || gps.getLon() == 0;
  24 + }*/
  25 +
  26 + /**
  27 + * gps掉线
  28 + * @param gps
  29 + * @return
  30 + */
  31 + protected boolean isGpsOffline(GpsEntity gps){
23 return gps.getLat() == 0 || gps.getLon() == 0; 32 return gps.getLat() == 0 || gps.getLon() == 0;
24 } 33 }
25 34
  35 + protected boolean isOffline(GpsEntity gps){
  36 + return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline");
  37 + }
26 /** 38 /**
27 * 是不是异常信号 39 * 是不是异常信号
28 * 40 *
@@ -34,7 +46,7 @@ public abstract class SignalHandle { @@ -34,7 +46,7 @@ public abstract class SignalHandle {
34 /** 46 /**
35 * 连续异常信号个数统计 47 * 连续异常信号个数统计
36 * 48 *
37 - * @param prevs 49 + * @param
38 * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) { 50 * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
39 * int count = 0; 51 * int count = 0;
40 * <p> 52 * <p>
@@ -78,9 +90,9 @@ public abstract class SignalHandle { @@ -78,9 +90,9 @@ public abstract class SignalHandle {
78 return false; 90 return false;
79 91
80 GpsEntity prev = prevs.getTail(); 92 GpsEntity prev = prevs.getTail();
81 - //从漂移状态恢复  
82 - if (isDriftSignal(prev)  
83 - && !isDriftSignal(gps)) { 93 + //从异常状态恢复
  94 + if (isGpsOffline(prev)
  95 + && !isGpsOffline(gps)) {
84 return true; 96 return true;
85 } 97 }
86 98
src/main/java/com/bsth/data/gpsdata/arrival/handlers/AbnormalStateHandle.java
@@ -30,6 +30,9 @@ public class AbnormalStateHandle extends SignalHandle{ @@ -30,6 +30,9 @@ public class AbnormalStateHandle extends SignalHandle{
30 @Override 30 @Override
31 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { 31 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
32 32
  33 + if(isOffline(gps))
  34 + return false;
  35 +
33 if(overspeed(gps)) 36 if(overspeed(gps))
34 return true; 37 return true;
35 38
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
@@ -46,10 +46,13 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -46,10 +46,13 @@ public class InOutStationSignalHandle extends SignalHandle{
46 46
47 private final static int MAX_BEFORE_TIME = 1000 * 60 * 72; 47 private final static int MAX_BEFORE_TIME = 1000 * 60 * 72;
48 48
  49 + //最大的班次时间差,防止异常的GPS时间打乱数据
  50 + private final static int MAX_NORMAL_DIFF = 1000 * 60 * 60 * 12;
  51 +
49 @Override 52 @Override
50 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { 53 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
51 - //忽略漂移信号  
52 - if(isDriftSignal(gps)) 54 + //忽略掉线信号
  55 + if(isGpsOffline(gps))
53 return false; 56 return false;
54 57
55 //从异常状态恢复的第一个信号 58 //从异常状态恢复的第一个信号
@@ -106,8 +109,14 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -106,8 +109,14 @@ public class InOutStationSignalHandle extends SignalHandle{
106 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); 109 ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm());
107 String qdzCode = sch.getQdzCode(); 110 String qdzCode = sch.getQdzCode();
108 111
  112 + int diff = (int) (sch.getDfsjT() - gps.getTimestamp());
  113 +
109 //首班出场最多提前1.2小时 114 //首班出场最多提前1.2小时
110 - if(dayOfSchedule.isFirstOut(sch) && sch.getDfsjT() - gps.getTimestamp() > MAX_BEFORE_TIME) 115 + if(dayOfSchedule.isFirstOut(sch) && diff > MAX_BEFORE_TIME)
  116 + return;
  117 +
  118 + //正常班次最大时间差
  119 + if(Math.abs(diff) > MAX_NORMAL_DIFF)
111 return; 120 return;
112 121
113 //起点发车 122 //起点发车
@@ -169,8 +178,13 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -169,8 +178,13 @@ public class InOutStationSignalHandle extends SignalHandle{
169 178
170 if(gps.getStopNo().equals(sch.getZdzCode())){ 179 if(gps.getStopNo().equals(sch.getZdzCode())){
171 180
  181 + int diff = (int) (sch.getZdsjT() - gps.getTimestamp());
172 //进场最多提前1.2小时 182 //进场最多提前1.2小时
173 - if(sch.getBcType().equals("in") && sch.getZdsjT() - gps.getTimestamp() > MAX_BEFORE_TIME) 183 + if(sch.getBcType().equals("in") && diff > MAX_BEFORE_TIME)
  184 + return;
  185 +
  186 + //正常班次最大时间差
  187 + if(Math.abs(diff) > MAX_NORMAL_DIFF)
174 return; 188 return;
175 189
176 //实达时间不覆盖 190 //实达时间不覆盖
@@ -195,7 +209,7 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -195,7 +209,7 @@ public class InOutStationSignalHandle extends SignalHandle{
195 //进站既进场 209 //进站既进场
196 inStationAndInPark(sch, next); 210 inStationAndInPark(sch, next);
197 //将gps转换为下一个班次走向的站内信号 211 //将gps转换为下一个班次走向的站内信号
198 - transformUpdown(gps, sch); 212 + transformUpdown(gps, next);
199 } 213 }
200 } 214 }
201 else if(sch.getFcsjActual() == null){ 215 else if(sch.getFcsjActual() == null){
@@ -217,6 +231,11 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -217,6 +231,11 @@ public class InOutStationSignalHandle extends SignalHandle{
217 231
218 sendUtils.refreshSch(next); 232 sendUtils.refreshSch(next);
219 dayOfSchedule.save(next); 233 dayOfSchedule.save(next);
  234 +
  235 + //分班的时候,需要再跳过1个班次
  236 + next = dayOfSchedule.next(next);
  237 + if(next != null)
  238 + dayOfSchedule.addExecPlan(next);
220 } 239 }
221 } 240 }
222 241
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
@@ -21,9 +21,10 @@ public class OfflineSignalHandle extends SignalHandle{ @@ -21,9 +21,10 @@ public class OfflineSignalHandle extends SignalHandle{
21 21
22 @Override 22 @Override
23 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { 23 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
24 - //漂移信号不管  
25 - if(isDriftSignal(gps)){ 24 + //掉线信号不管
  25 + if(isGpsOffline(gps)){
26 gps.setSignalState("drift"); 26 gps.setSignalState("drift");
  27 + gps.setAbnormalStatus("gps-offline");
27 return true; 28 return true;
28 } 29 }
29 30
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java
@@ -88,6 +88,7 @@ public class GpsDataLoaderThread extends Thread { @@ -88,6 +88,7 @@ public class GpsDataLoaderThread extends Thread {
88 String nbbm; 88 String nbbm;
89 GpsEntity old; 89 GpsEntity old;
90 for (GpsEntity gps : list) { 90 for (GpsEntity gps : list) {
  91 +
91 //没有设备号 92 //没有设备号
92 if (StringUtils.isBlank(gps.getDeviceId())) 93 if (StringUtils.isBlank(gps.getDeviceId()))
93 continue; 94 continue;
src/main/java/com/bsth/data/gpsdata/thread/OfflineMonitorThread.java
@@ -2,7 +2,11 @@ package com.bsth.data.gpsdata.thread; @@ -2,7 +2,11 @@ package com.bsth.data.gpsdata.thread;
2 2
3 import com.bsth.data.gpsdata.GpsEntity; 3 import com.bsth.data.gpsdata.GpsEntity;
4 import com.bsth.data.gpsdata.GpsRealData; 4 import com.bsth.data.gpsdata.GpsRealData;
  5 +import com.bsth.websocket.handler.SendUtils;
  6 +import org.slf4j.Logger;
  7 +import org.slf4j.LoggerFactory;
5 import org.springframework.beans.factory.annotation.Autowired; 8 import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
6 10
7 import java.util.Collection; 11 import java.util.Collection;
8 12
@@ -10,35 +14,45 @@ import java.util.Collection; @@ -10,35 +14,45 @@ import java.util.Collection;
10 * GPS掉离线监控 14 * GPS掉离线监控
11 * Created by panzhao on 2017/1/11. 15 * Created by panzhao on 2017/1/11.
12 */ 16 */
  17 +@Component
13 public class OfflineMonitorThread extends Thread{ 18 public class OfflineMonitorThread extends Thread{
14 19
15 @Autowired 20 @Autowired
16 GpsRealData gpsRealData; 21 GpsRealData gpsRealData;
17 22
18 - //有任务时 掉线阈值  
19 - private final static int LOSE_TIME = 1000 * 60 * 2; 23 + //掉线阈值
  24 + private final static int LOSE_TIME = 1000 * 60 * 10;
  25 +
  26 + Logger logger = LoggerFactory.getLogger(this.getClass());
  27 +
  28 + @Autowired
  29 + SendUtils sendUtils;
20 30
21 //无任务时 离线阈值 31 //无任务时 离线阈值
22 - private final static int OFFLINE_TIME = 1000 * 60 * 10; 32 + //private final static int OFFLINE_TIME = 1000 * 60 * 10;
23 33
24 @Override 34 @Override
25 public void run() { 35 public void run() {
26 - long t = System.currentTimeMillis();  
27 - Collection<GpsEntity> list = gpsRealData.all();  
28 -  
29 - String state;  
30 - for(GpsEntity gps : list){  
31 - state = gps.getAbnormalStatus();  
32 -  
33 - if(state.equals("offline"))  
34 - continue;  
35 -  
36 -  
37 - //if(state.equals("lose"))  
38 - //if(!state.equals("lose"))  
39 - //if(state.equals(""))  
40 - //if(gps.getTimestamp())  
41 - //if(gps.getAbnormalStatus().equals("lose")) 36 + try{
  37 + long t = System.currentTimeMillis();
  38 + Collection<GpsEntity> list = gpsRealData.all();
  39 +
  40 + String state;
  41 + for(GpsEntity gps : list){
  42 + state = gps.getAbnormalStatus();
  43 +
  44 + if(state != null && state.equals("offline"))
  45 + continue;
  46 +
  47 + if (t - gps.getTimestamp() > LOSE_TIME){
  48 + gps.setAbnormalStatus("offline");
  49 +
  50 + //通知页面有设备掉线
  51 + sendUtils.deviceOffline(gps);
  52 + }
  53 + }
  54 + }catch (Exception e){
  55 + logger.error("", e);
42 } 56 }
43 } 57 }
44 } 58 }
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -49,6 +49,9 @@ public class DayOfSchedule implements CommandLineRunner { @@ -49,6 +49,9 @@ public class DayOfSchedule implements CommandLineRunner {
49 49
50 Logger logger = LoggerFactory.getLogger(this.getClass()); 50 Logger logger = LoggerFactory.getLogger(this.getClass());
51 51
  52 + //按线路分组的 “计划” 排班数据
  53 + public static Map<String, List<SchedulePlanInfo>> schedulePlanMap;
  54 +
52 // 按车辆分组的班次数据 55 // 按车辆分组的班次数据
53 private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap; 56 private static ArrayListMultimap<String, ScheduleRealInfo> nbbmScheduleMap;
54 57
@@ -101,6 +104,8 @@ public class DayOfSchedule implements CommandLineRunner { @@ -101,6 +104,8 @@ public class DayOfSchedule implements CommandLineRunner {
101 currSchDateMap = new HashMap<>(); 104 currSchDateMap = new HashMap<>();
102 nbbm2SEStationMap = TreeMultimap.create(); 105 nbbm2SEStationMap = TreeMultimap.create();
103 carExecutePlanMap = new HashMap<>(); 106 carExecutePlanMap = new HashMap<>();
  107 +
  108 + schedulePlanMap = new HashMap<>();
104 } 109 }
105 110
106 @Autowired 111 @Autowired
@@ -328,6 +333,8 @@ public class DayOfSchedule implements CommandLineRunner { @@ -328,6 +333,8 @@ public class DayOfSchedule implements CommandLineRunner {
328 333
329 // 查询计划排班 334 // 查询计划排班
330 List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator()); 335 List<SchedulePlanInfo> planItr = cleanSchPlanItr(schPlanService.list(data).iterator());
  336 + //保存一份原始计划排班数据
  337 + schedulePlanMap.put(lineCode, planItr);
331 338
332 // 转换为实际排班 339 // 转换为实际排班
333 realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); 340 realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class);
@@ -374,6 +381,7 @@ public class DayOfSchedule implements CommandLineRunner { @@ -374,6 +381,7 @@ public class DayOfSchedule implements CommandLineRunner {
374 } catch (Exception e) { 381 } catch (Exception e) {
375 logger.error("", e); 382 logger.error("", e);
376 } 383 }
  384 +
377 return realList; 385 return realList;
378 } 386 }
379 387
@@ -399,7 +407,7 @@ public class DayOfSchedule implements CommandLineRunner { @@ -399,7 +407,7 @@ public class DayOfSchedule implements CommandLineRunner {
399 new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); 407 new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class);
400 } 408 }
401 409
402 - private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { 410 + public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
403 List<SchedulePlanInfo> list = new ArrayList<>(); 411 List<SchedulePlanInfo> list = new ArrayList<>();
404 412
405 SchedulePlanInfo sp; 413 SchedulePlanInfo sp;
src/main/java/com/bsth/entity/schedule/SchedulePlanInfo.java
@@ -157,6 +157,7 @@ public class SchedulePlanInfo { @@ -157,6 +157,7 @@ public class SchedulePlanInfo {
157 Line xl, 157 Line xl,
158 ScheduleResult_output scheduleResult_output, 158 ScheduleResult_output scheduleResult_output,
159 TTInfoDetail ttInfoDetail, 159 TTInfoDetail ttInfoDetail,
  160 + Boolean isFb,
160 CarConfigInfo carConfigInfo, 161 CarConfigInfo carConfigInfo,
161 List<EmployeeConfigInfo> employeeConfigInfoList, 162 List<EmployeeConfigInfo> employeeConfigInfoList,
162 SchedulePlan schedulePlan) { 163 SchedulePlan schedulePlan) {
@@ -191,7 +192,7 @@ public class SchedulePlanInfo { @@ -191,7 +192,7 @@ public class SchedulePlanInfo {
191 // TODO:报道时间,出场时间没有 192 // TODO:报道时间,出场时间没有
192 // 关联的驾驶员 193 // 关联的驾驶员
193 EmployeeConfigInfo employeeConfigInfo = null; 194 EmployeeConfigInfo employeeConfigInfo = null;
194 - if (ttInfoDetail.getIsFB()) { 195 + if (isFb) {
195 if (employeeConfigInfoList.size() > 1) { 196 if (employeeConfigInfoList.size() > 1) {
196 employeeConfigInfo = employeeConfigInfoList.get(1); 197 employeeConfigInfo = employeeConfigInfoList.get(1);
197 } else { 198 } else {
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -28,7 +28,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -28,7 +28,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
28 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") 28 @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)")
29 List<ScheduleRealInfo> queryUserInfo(String line,String date); 29 List<ScheduleRealInfo> queryUserInfo(String line,String date);
30 30
31 - @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)") 31 + @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName,s.sGh,s.sName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName,s.sGh,s.sName order by (lpName+1)")
32 List<ScheduleRealInfo> queryUserInfo2(String line,String date); 32 List<ScheduleRealInfo> queryUserInfo2(String line,String date);
33 33
34 @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.clZbh ") 34 @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.clZbh ")
src/main/java/com/bsth/repository/schedule/SchedulePlanInfoRepository.java
@@ -33,17 +33,18 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -33,17 +33,18 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
33 "lp_name as lpName, " + 33 "lp_name as lpName, " +
34 "cl as clId, " + 34 "cl as clId, " +
35 "cl_zbh as clZbh, " + 35 "cl_zbh as clZbh, " +
36 - "group_concat(distinct fcsj) ccsj, " + 36 + "group_concat(fcsj) ccsj, " +
  37 + "group_concat(bc_type) bctype, " +
37 "group_concat(distinct j) jsyId, " + 38 "group_concat(distinct j) jsyId, " +
38 "group_concat(distinct j_gh) jsyGh, " + 39 "group_concat(distinct j_gh) jsyGh, " +
39 "group_concat(distinct j_name) jsyName, " + 40 "group_concat(distinct j_name) jsyName, " +
40 "group_concat(distinct s) spyId, " + 41 "group_concat(distinct s) spyId, " +
41 "group_concat(distinct s_gh) spyGh, " + 42 "group_concat(distinct s_gh) spyGh, " +
42 "group_concat(distinct s_name) spyName, " + 43 "group_concat(distinct s_name) spyName, " +
43 - "max(create_date) as createDate " + 44 + "max(create_date) as createDate, " +
  45 + "group_concat(fcno) fcno " +
44 "from bsth_c_s_sp_info " + 46 "from bsth_c_s_sp_info " +
45 - "where bc_type = 'out' and " +  
46 - "xl = ?1 and " + 47 + "where xl = ?1 and " +
47 "schedule_date = ?2 " + 48 "schedule_date = ?2 " +
48 "group by xl_name, schedule_date, lp, lp_name, cl, cl_zbh " + 49 "group by xl_name, schedule_date, lp, lp_name, cl, cl_zbh " +
49 "order by xl_name, schedule_date, lp ", nativeQuery = true) 50 "order by xl_name, schedule_date, lp ", nativeQuery = true)
@@ -71,14 +72,16 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -71,14 +72,16 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
71 "scpinfo.scheduleDate = :p3 and " + 72 "scpinfo.scheduleDate = :p3 and " +
72 "scpinfo.lpName = :p4 and " + 73 "scpinfo.lpName = :p4 and " +
73 "scpinfo.fcsj = :p5 and " + 74 "scpinfo.fcsj = :p5 and " +
74 - "scpinfo.bcType = :p6 ") 75 + "scpinfo.bcType = :p6 and " +
  76 + "scpinfo.fcno = :p7 " )
75 int updateGroupInfo_type_2_4( 77 int updateGroupInfo_type_2_4(
76 @Param("p1") String fcsj, 78 @Param("p1") String fcsj,
77 @Param("p2") Integer xlid, 79 @Param("p2") Integer xlid,
78 @Param("p3") Date scheduleDate, 80 @Param("p3") Date scheduleDate,
79 @Param("p4") String lpName, 81 @Param("p4") String lpName,
80 @Param("p5") String fcsj_src, 82 @Param("p5") String fcsj_src,
81 - @Param("p6") String bcType); 83 + @Param("p6") String bcType,
  84 + @Param("p7") Integer fcno);
82 85
83 @Modifying 86 @Modifying
84 @Query(value = "update " + 87 @Query(value = "update " +
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -3,6 +3,7 @@ package com.bsth.service.realcontrol; @@ -3,6 +3,7 @@ package com.bsth.service.realcontrol;
3 import com.bsth.controller.realcontrol.dto.ChangePersonCar; 3 import com.bsth.controller.realcontrol.dto.ChangePersonCar;
4 import com.bsth.controller.realcontrol.dto.DfsjChange; 4 import com.bsth.controller.realcontrol.dto.DfsjChange;
5 import com.bsth.entity.realcontrol.ScheduleRealInfo; 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.schedule.SchedulePlanInfo;
6 import com.bsth.service.BaseService; 7 import com.bsth.service.BaseService;
7 import org.springframework.stereotype.Service; 8 import org.springframework.stereotype.Service;
8 9
@@ -148,4 +149,6 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -148,4 +149,6 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
148 List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map); 149 List<Map<String, Object>> scheduleDailyExport(Map<String, Object> map);
149 150
150 Map<String, Object> exportWaybillMore(Map<String, Object> map); 151 Map<String, Object> exportWaybillMore(Map<String, Object> map);
  152 +
  153 + List<SchedulePlanInfo> currentSchedulePlan(String lineCode);
151 } 154 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -24,6 +24,7 @@ import com.bsth.entity.realcontrol.SvgAttribute; @@ -24,6 +24,7 @@ import com.bsth.entity.realcontrol.SvgAttribute;
24 import com.bsth.entity.schedule.CarConfigInfo; 24 import com.bsth.entity.schedule.CarConfigInfo;
25 import com.bsth.entity.schedule.EmployeeConfigInfo; 25 import com.bsth.entity.schedule.EmployeeConfigInfo;
26 import com.bsth.entity.schedule.GuideboardInfo; 26 import com.bsth.entity.schedule.GuideboardInfo;
  27 +import com.bsth.entity.schedule.SchedulePlanInfo;
27 import com.bsth.entity.sys.DutyEmployee; 28 import com.bsth.entity.sys.DutyEmployee;
28 import com.bsth.entity.sys.SysUser; 29 import com.bsth.entity.sys.SysUser;
29 import com.bsth.repository.LineRepository; 30 import com.bsth.repository.LineRepository;
@@ -38,6 +39,7 @@ import com.bsth.security.util.SecurityUtils; @@ -38,6 +39,7 @@ import com.bsth.security.util.SecurityUtils;
38 import com.bsth.service.SectionRouteService; 39 import com.bsth.service.SectionRouteService;
39 import com.bsth.service.impl.BaseServiceImpl; 40 import com.bsth.service.impl.BaseServiceImpl;
40 import com.bsth.service.realcontrol.ScheduleRealInfoService; 41 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  42 +import com.bsth.service.schedule.SchedulePlanInfoService;
41 import com.bsth.service.sys.DutyEmployeeService; 43 import com.bsth.service.sys.DutyEmployeeService;
42 import com.bsth.util.*; 44 import com.bsth.util.*;
43 import com.bsth.websocket.handler.SendUtils; 45 import com.bsth.websocket.handler.SendUtils;
@@ -55,11 +57,7 @@ import org.slf4j.LoggerFactory; @@ -55,11 +57,7 @@ import org.slf4j.LoggerFactory;
55 import org.springframework.beans.factory.annotation.Autowired; 57 import org.springframework.beans.factory.annotation.Autowired;
56 import org.springframework.stereotype.Service; 58 import org.springframework.stereotype.Service;
57 59
58 -import java.io.BufferedInputStream;  
59 -import java.io.BufferedOutputStream;  
60 -import java.io.File;  
61 -import java.io.FileInputStream;  
62 -import java.io.FileOutputStream; 60 +import java.io.*;
63 import java.text.DecimalFormat; 61 import java.text.DecimalFormat;
64 import java.text.ParseException; 62 import java.text.ParseException;
65 import java.text.SimpleDateFormat; 63 import java.text.SimpleDateFormat;
@@ -2179,7 +2177,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2179,7 +2177,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2179 2177
2180 for (ChangePersonCar cpc : cpcs) { 2178 for (ChangePersonCar cpc : cpcs) {
2181 2179
2182 - if (map.get(cpc.getClZbh()) == null) { 2180 + if (cpc.getClZbh() != null && map.get(cpc.getClZbh()) == null) {
2183 rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); 2181 rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
2184 rs.put("status", ResponseCode.ERROR); 2182 rs.put("status", ResponseCode.ERROR);
2185 return rs; 2183 return rs;
@@ -3228,5 +3226,25 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3228,5 +3226,25 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3228 map.put("fileName", file.getName()); 3226 map.put("fileName", file.getName());
3229 return map; 3227 return map;
3230 } 3228 }
3231 - 3229 +
  3230 + @Autowired
  3231 + SchedulePlanInfoService schPlanService;
  3232 + @Override
  3233 + public List<SchedulePlanInfo> currentSchedulePlan(String lineCode) {
  3234 + List<SchedulePlanInfo> rs = dayOfSchedule.schedulePlanMap.get(lineCode);
  3235 +
  3236 + if(rs==null || rs.size()==0){
  3237 + //尝试刷新内存
  3238 + Map<String, Object> data = new HashMap<>();
  3239 + data.put("scheduleDate_eq", dayOfSchedule.currSchDateMap.get(lineCode));
  3240 + data.put("xlBm_eq", lineCode);
  3241 + List<SchedulePlanInfo> planItr = dayOfSchedule.cleanSchPlanItr(schPlanService.list(data).iterator());
  3242 +
  3243 + if(planItr.size() > 0){
  3244 + dayOfSchedule.schedulePlanMap.put(lineCode, planItr);
  3245 + return planItr;
  3246 + }
  3247 + }
  3248 + return rs;
  3249 + }
3232 } 3250 }
3233 \ No newline at end of file 3251 \ No newline at end of file
src/main/java/com/bsth/service/schedule/SchedulePlanInfoService.java
@@ -4,6 +4,7 @@ import com.bsth.entity.schedule.SchedulePlanInfo; @@ -4,6 +4,7 @@ import com.bsth.entity.schedule.SchedulePlanInfo;
4 import com.bsth.service.BaseService; 4 import com.bsth.service.BaseService;
5 import org.joda.time.DateTime; 5 import org.joda.time.DateTime;
6 6
  7 +import java.util.ArrayList;
7 import java.util.Date; 8 import java.util.Date;
8 import java.util.List; 9 import java.util.List;
9 10
@@ -117,6 +118,11 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -117,6 +118,11 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
117 /** 创建时间 */ 118 /** 创建时间 */
118 private Date createDate; 119 private Date createDate;
119 120
  121 + /** 出场班次1发车的顺序号 */
  122 + private Integer fcno1;
  123 + /** 出场班次2发车的顺序号 */
  124 + private Integer fcno2;
  125 +
120 public GroupInfo() {} 126 public GroupInfo() {}
121 127
122 public GroupInfo(Object[] datas) { 128 public GroupInfo(Object[] datas) {
@@ -132,19 +138,40 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -132,19 +138,40 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
132 this.clId = Integer.valueOf(String.valueOf(datas[4])); 138 this.clId = Integer.valueOf(String.valueOf(datas[4]));
133 // 车辆自编号 139 // 车辆自编号
134 this.clZbh = String.valueOf(datas[5]); 140 this.clZbh = String.valueOf(datas[5]);
135 - // 出场时间,如果有多个,需要分开 141 + // 出场时间,出场班次,如果有多个,需要分开
136 Object ccsj = datas[6]; 142 Object ccsj = datas[6];
  143 + Object bctype = datas[7];
  144 + Object fcno = datas[15];
  145 +
137 if (ccsj != null) { 146 if (ccsj != null) {
138 String[] ccsj_array = ((String) ccsj).split(","); 147 String[] ccsj_array = ((String) ccsj).split(",");
139 - if (ccsj_array.length > 1) {  
140 - this.ccsj1 = String.valueOf(ccsj_array[0]);  
141 - this.ccsj2 = String.valueOf(ccsj_array[1]);  
142 - } else {  
143 - this.ccsj1 = String.valueOf(ccsj_array[0]); 148 + String[] bctype_array = ((String) bctype).split(",");
  149 + String[] fcno_array = ((String) fcno).split(",");
  150 + List<Integer> bctype_index = new ArrayList<>();
  151 +
  152 + for (int i = 0; i < bctype_array.length; i++) {
  153 + if (bctype_index.size() == 2) { // 只记录2个出场
  154 + break;
  155 + }
  156 + if (bctype_array[i].equals("out")) {
  157 + bctype_index.add(i);
  158 + }
  159 + }
  160 +
  161 + if (bctype_index.size() == 1) {
  162 + this.ccsj1 = String.valueOf(ccsj_array[bctype_index.get(0)]);
  163 + this.fcno1 = Integer.valueOf(fcno_array[bctype_index.get(0)]);
  164 + } else if (bctype_index.size() == 2) {
  165 + this.ccsj1 = String.valueOf(ccsj_array[bctype_index.get(0)]);
  166 + this.ccsj2 = String.valueOf(ccsj_array[bctype_index.get(1)]);
  167 +
  168 + this.fcno1 = Integer.valueOf(fcno_array[bctype_index.get(0)]);
  169 + this.fcno2 = Integer.valueOf(fcno_array[bctype_index.get(1)]);
144 } 170 }
  171 +
145 } 172 }
146 // 驾驶员id,如果有多个,需要分开 173 // 驾驶员id,如果有多个,需要分开
147 - Object jsyId = datas[7]; 174 + Object jsyId = datas[8];
148 if (jsyId != null) { 175 if (jsyId != null) {
149 String[] jsyId_array = ((String) jsyId).split(","); 176 String[] jsyId_array = ((String) jsyId).split(",");
150 if (jsyId_array.length > 1) { 177 if (jsyId_array.length > 1) {
@@ -155,7 +182,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -155,7 +182,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
155 } 182 }
156 } 183 }
157 // 驾驶员工号,如果有多个,需要分开 184 // 驾驶员工号,如果有多个,需要分开
158 - Object jsyGh = datas[8]; 185 + Object jsyGh = datas[9];
159 if (jsyGh != null) { 186 if (jsyGh != null) {
160 String[] jsyGh_array = ((String) jsyGh).split(","); 187 String[] jsyGh_array = ((String) jsyGh).split(",");
161 if (jsyGh_array.length > 1) { 188 if (jsyGh_array.length > 1) {
@@ -166,7 +193,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -166,7 +193,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
166 } 193 }
167 } 194 }
168 // 驾驶员名字,如果有多个,需要分开 195 // 驾驶员名字,如果有多个,需要分开
169 - Object jsyName = datas[9]; 196 + Object jsyName = datas[10];
170 if (jsyName != null) { 197 if (jsyName != null) {
171 String[] jsyName_array = ((String) jsyName).split(","); 198 String[] jsyName_array = ((String) jsyName).split(",");
172 if (jsyName_array.length > 1) { 199 if (jsyName_array.length > 1) {
@@ -178,7 +205,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -178,7 +205,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
178 } 205 }
179 206
180 // 售票员id,如果有多个,需要分开 207 // 售票员id,如果有多个,需要分开
181 - Object spyId = datas[10]; 208 + Object spyId = datas[11];
182 if (spyId != null) { 209 if (spyId != null) {
183 String[] spyId_array = ((String) spyId).split(","); 210 String[] spyId_array = ((String) spyId).split(",");
184 if (spyId_array.length > 1) { 211 if (spyId_array.length > 1) {
@@ -190,7 +217,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -190,7 +217,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
190 } 217 }
191 218
192 // 售票员工号,如果有多个,需要分开 219 // 售票员工号,如果有多个,需要分开
193 - Object spyGh = datas[11]; 220 + Object spyGh = datas[12];
194 if (spyGh != null) { 221 if (spyGh != null) {
195 String[] spyGh_array = ((String) spyGh).split(","); 222 String[] spyGh_array = ((String) spyGh).split(",");
196 if (spyGh_array.length > 1) { 223 if (spyGh_array.length > 1) {
@@ -201,7 +228,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -201,7 +228,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
201 } 228 }
202 } 229 }
203 // 售票员名字,如果有多个,需要分开 230 // 售票员名字,如果有多个,需要分开
204 - Object spyName = datas[12]; 231 + Object spyName = datas[13];
205 if (spyName != null) { 232 if (spyName != null) {
206 String[] spyName_array = ((String) spyName).split(","); 233 String[] spyName_array = ((String) spyName).split(",");
207 if (spyName_array.length > 1) { 234 if (spyName_array.length > 1) {
@@ -212,7 +239,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -212,7 +239,7 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
212 } 239 }
213 } 240 }
214 // 创建时间 241 // 创建时间
215 - this.createDate = new DateTime(datas[13]).toDate(); 242 + this.createDate = new DateTime(datas[14]).toDate();
216 243
217 // TODO:可能还有其他字段 244 // TODO:可能还有其他字段
218 } 245 }
@@ -384,5 +411,21 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L @@ -384,5 +411,21 @@ public interface SchedulePlanInfoService extends BaseService&lt;SchedulePlanInfo, L
384 public void setXlId(Integer xlId) { 411 public void setXlId(Integer xlId) {
385 this.xlId = xlId; 412 this.xlId = xlId;
386 } 413 }
  414 +
  415 + public Integer getFcno1() {
  416 + return fcno1;
  417 + }
  418 +
  419 + public void setFcno1(Integer fcno1) {
  420 + this.fcno1 = fcno1;
  421 + }
  422 +
  423 + public Integer getFcno2() {
  424 + return fcno2;
  425 + }
  426 +
  427 + public void setFcno2(Integer fcno2) {
  428 + this.fcno2 = fcno2;
  429 + }
387 } 430 }
388 } 431 }
src/main/java/com/bsth/service/schedule/SchedulePlanInfoServiceImpl.java
@@ -55,7 +55,8 @@ public class SchedulePlanInfoServiceImpl extends BaseServiceImpl&lt;SchedulePlanInf @@ -55,7 +55,8 @@ public class SchedulePlanInfoServiceImpl extends BaseServiceImpl&lt;SchedulePlanInf
55 groupInfoUpdate.getUpdate().getScheduleDate(), 55 groupInfoUpdate.getUpdate().getScheduleDate(),
56 groupInfoUpdate.getSrc().getLpName(), 56 groupInfoUpdate.getSrc().getLpName(),
57 groupInfoUpdate.getSrc().getCcsj1(), 57 groupInfoUpdate.getSrc().getCcsj1(),
58 - "out" 58 + "out",
  59 + groupInfoUpdate.getSrc().getFcno1()
59 ); 60 );
60 } 61 }
61 62
@@ -94,7 +95,8 @@ public class SchedulePlanInfoServiceImpl extends BaseServiceImpl&lt;SchedulePlanInf @@ -94,7 +95,8 @@ public class SchedulePlanInfoServiceImpl extends BaseServiceImpl&lt;SchedulePlanInf
94 groupInfoUpdate.getUpdate().getScheduleDate(), 95 groupInfoUpdate.getUpdate().getScheduleDate(),
95 groupInfoUpdate.getSrc().getLpName(), 96 groupInfoUpdate.getSrc().getLpName(),
96 groupInfoUpdate.getSrc().getCcsj2(), 97 groupInfoUpdate.getSrc().getCcsj2(),
97 - "out" 98 + "out",
  99 + groupInfoUpdate.getSrc().getFcno2()
98 ); 100 );
99 } 101 }
100 102
src/main/java/com/bsth/service/schedule/SchedulePlanService.java
1 package com.bsth.service.schedule; 1 package com.bsth.service.schedule;
2 2
3 import com.bsth.entity.schedule.SchedulePlan; 3 import com.bsth.entity.schedule.SchedulePlan;
  4 +import com.bsth.entity.sys.CompanyAuthority;
  5 +import com.bsth.service.schedule.rules.ttinfo2.Result;
  6 +
  7 +import java.util.Date;
4 8
5 /** 9 /**
6 * Created by xu on 16/6/16. 10 * Created by xu on 16/6/16.
7 */ 11 */
8 public interface SchedulePlanService extends BService<SchedulePlan, Long> { 12 public interface SchedulePlanService extends BService<SchedulePlan, Long> {
  13 +
  14 + SchedulePlan save(SchedulePlan schedulePlan, CompanyAuthority companyAuthority);
  15 +
9 /** 16 /**
10 * 获取有明日排班的计划。 17 * 获取有明日排班的计划。
11 * @return 18 * @return
12 */ 19 */
13 SchedulePlan findSchedulePlanTommorw(); 20 SchedulePlan findSchedulePlanTommorw();
14 -} 21 +
  22 + /**
  23 + * 验证使用的时刻表。
  24 + * @param xlid 线路id
  25 + * @param from 开始时间
  26 + * @param to 结束时间
  27 + * @return
  28 + */
  29 + Result validateTTInfo(Integer xlid, Date from, Date to);
  30 +}
15 \ No newline at end of file 31 \ No newline at end of file
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
@@ -3,19 +3,27 @@ package com.bsth.service.schedule.impl; @@ -3,19 +3,27 @@ package com.bsth.service.schedule.impl;
3 import com.bsth.entity.Line; 3 import com.bsth.entity.Line;
4 import com.bsth.entity.schedule.*; 4 import com.bsth.entity.schedule.*;
5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat; 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  6 +import com.bsth.entity.sys.CompanyAuthority;
6 import com.bsth.repository.schedule.SchedulePlanInfoRepository; 7 import com.bsth.repository.schedule.SchedulePlanInfoRepository;
7 import com.bsth.repository.schedule.SchedulePlanRepository; 8 import com.bsth.repository.schedule.SchedulePlanRepository;
  9 +import com.bsth.service.LineService;
8 import com.bsth.service.schedule.SchedulePlanService; 10 import com.bsth.service.schedule.SchedulePlanService;
  11 +import com.bsth.service.schedule.TTInfoDetailService;
  12 +import com.bsth.service.schedule.TTInfoService;
9 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; 13 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
10 import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; 14 import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
11 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
12 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; 16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
13 import com.bsth.service.schedule.rules.strategy.IStrategy; 17 import com.bsth.service.schedule.rules.strategy.IStrategy;
  18 +import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
  19 +import com.bsth.service.schedule.rules.ttinfo2.Result;
14 import com.google.common.collect.Multimap; 20 import com.google.common.collect.Multimap;
15 import org.apache.commons.lang3.StringUtils; 21 import org.apache.commons.lang3.StringUtils;
16 import org.joda.time.DateTime; 22 import org.joda.time.DateTime;
17 import org.kie.api.KieBase; 23 import org.kie.api.KieBase;
18 import org.kie.api.runtime.KieSession; 24 import org.kie.api.runtime.KieSession;
  25 +import org.slf4j.Logger;
  26 +import org.slf4j.LoggerFactory;
19 import org.springframework.beans.factory.annotation.Autowired; 27 import org.springframework.beans.factory.annotation.Autowired;
20 import org.springframework.stereotype.Service; 28 import org.springframework.stereotype.Service;
21 import org.springframework.transaction.annotation.Isolation; 29 import org.springframework.transaction.annotation.Isolation;
@@ -37,10 +45,18 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -37,10 +45,18 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
37 private SchedulePlanRepository schedulePlanRepository; 45 private SchedulePlanRepository schedulePlanRepository;
38 @Autowired 46 @Autowired
39 private SchedulePlanInfoRepository schedulePlanInfoRepository; 47 private SchedulePlanInfoRepository schedulePlanInfoRepository;
  48 + @Autowired
  49 + private LineService lineService;
  50 + @Autowired
  51 + private TTInfoService ttInfoService;
  52 + @Autowired
  53 + private TTInfoDetailService ttInfoDetailService;
  54 +
  55 + /** 日志记录器 */
  56 + private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class);
40 57
41 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) 58 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
42 - @Override  
43 - public SchedulePlan save(SchedulePlan schedulePlan) { 59 + public SchedulePlan save(SchedulePlan schedulePlan, CompanyAuthority companyAuthority) {
44 // 1-1、查找线路具体信息 60 // 1-1、查找线路具体信息
45 Line xl = strategy.getLine(schedulePlan.getXl().getId()); 61 Line xl = strategy.getLine(schedulePlan.getXl().getId());
46 // 1-2、查出指定线路的所有规则 62 // 1-2、查出指定线路的所有规则
@@ -106,18 +122,41 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -106,18 +122,41 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
106 employeeConfigInfoList.add(employeeConfigMaps.get(Long.valueOf(eid))); 122 employeeConfigInfoList.add(employeeConfigMaps.get(Long.valueOf(eid)));
107 } 123 }
108 // 排班明细(这个要迭代的) 124 // 排班明细(这个要迭代的)
109 - Collection<TTInfoDetail> ttInfoDetails = gbdTTinfoMaps.get(scheduleResult_output.getSd().toDate()).get( 125 + Collection<TTInfoDetail> ttInfoDetails_ = gbdTTinfoMaps.get(scheduleResult_output.getSd().toDate()).get(
110 Long.parseLong(scheduleResult_output.getGuideboardId())); 126 Long.parseLong(scheduleResult_output.getGuideboardId()));
  127 + List<TTInfoDetail> ttInfoDetails = new ArrayList<>(ttInfoDetails_);
  128 +
  129 + // 排序ttInfoDetails
  130 + Collections.sort(ttInfoDetails, new Comparator<TTInfoDetail>() {
  131 + @Override
  132 + public int compare(TTInfoDetail o1, TTInfoDetail o2) {
  133 + return o1.getFcno().compareTo(o2.getFcno());
  134 + }
  135 + });
  136 +
  137 + Boolean isFb = false; // 是否分班
111 for (TTInfoDetail ttInfoDetail : ttInfoDetails) { 138 for (TTInfoDetail ttInfoDetail : ttInfoDetails) {
  139 + if (ttInfoDetail.getIsFB())
  140 + isFb = ttInfoDetail.getIsFB();
  141 +
112 SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo( 142 SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
113 xl, 143 xl,
114 scheduleResult_output, 144 scheduleResult_output,
115 ttInfoDetail, 145 ttInfoDetail,
  146 + isFb,
116 configInfo, 147 configInfo,
117 employeeConfigInfoList, 148 employeeConfigInfoList,
118 schedulePlan); 149 schedulePlan);
  150 +
  151 + // 公司,分公司编码
  152 + schedulePlanInfo.setGsBm(companyAuthority.getCompanyCode());
  153 + schedulePlanInfo.setGsName(companyAuthority.getCompanyName());
  154 + schedulePlanInfo.setFgsBm(companyAuthority.getSubCompanyCode());
  155 + schedulePlanInfo.setFgsName(companyAuthority.getSubCompanyName());
  156 +
119 schedulePlanInfos.add(schedulePlanInfo); 157 schedulePlanInfos.add(schedulePlanInfo);
120 ttInfoMap.put(ttInfoDetail.getTtinfo().getId(), ttInfoDetail.getTtinfo().getName()); 158 ttInfoMap.put(ttInfoDetail.getTtinfo().getId(), ttInfoDetail.getTtinfo().getName());
  159 +
121 } 160 }
122 } 161 }
123 162
@@ -144,4 +183,36 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -144,4 +183,36 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
144 } 183 }
145 return null; 184 return null;
146 } 185 }
  186 +
  187 + @Override
  188 + public Result validateTTInfo(Integer xlid, Date from, Date to) {
  189 + // 构造drools session->载入数据->启动规则->计算->销毁session
  190 + // 创建session,内部配置的是stateful
  191 + KieSession session = kieBase.newKieSession();
  192 + // 设置gloable对象,在drl中通过别名使用
  193 + session.setGlobal("log", logger);
  194 + session.setGlobal("lineService", lineService);
  195 + session.setGlobal("ttInfoDetailService", ttInfoDetailService);
  196 +
  197 + Result rs = new Result(); // 输出gloable对象
  198 + session.setGlobal("rs", rs);
  199 +
  200 + // 载入数据
  201 + CalcuParam calcuParam = new CalcuParam(
  202 + new DateTime(from), new DateTime(to), xlid);
  203 + session.insert(calcuParam);
  204 + List<TTInfo> ttInfos = ttInfoService.findAll();
  205 + for (TTInfo ttInfo: ttInfos)
  206 + session.insert(ttInfo);
  207 +
  208 +
  209 + // 执行rule
  210 + session.fireAllRules();
  211 +
  212 + // 执行完毕销毁,有日志的也要关闭
  213 + session.dispose();
  214 +
  215 +
  216 + return rs;
  217 + }
147 } 218 }
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
@@ -169,8 +169,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im @@ -169,8 +169,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl&lt;TTInfoDetail, Long&gt; im
169 Map<String, Object> ktrParms = new HashMap<>(); 169 Map<String, Object> ktrParms = new HashMap<>();
170 File ktrFile = new File(this.getClass().getResource( 170 File ktrFile = new File(this.getClass().getResource(
171 dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); 171 dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI());
  172 +// File ktrFile2 = new File(this.getClass().getResource(
  173 +// dataToolsProperties.getTtinfodetailDatainputktr()).toURI());
172 File ktrFile2 = new File(this.getClass().getResource( 174 File ktrFile2 = new File(this.getClass().getResource(
173 - dataToolsProperties.getTtinfodetailDatainputktr()).toURI()); 175 + dataToolsProperties.getTtinfodetailDatainputktr2()).toURI());
174 176
175 // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 177 // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径
176 ktrParms.put("transpath", ktrFile.getAbsolutePath()); 178 ktrParms.put("transpath", ktrFile.getAbsolutePath());
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
@@ -52,6 +52,9 @@ public class MyDroolsConfiguration { @@ -52,6 +52,9 @@ public class MyDroolsConfiguration {
52 // 3.2、写入drl(写法超多,有点混乱) 52 // 3.2、写入drl(写法超多,有点混乱)
53 // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入 53 // 这里使用文件的形式写入,TODO:以后考虑从数据库中读drl写入
54 // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的 54 // 注意kfs写的时候如果指定path,强制为src/main/resources/加上文件名,还有就是文件名不要重复否则会覆盖的
  55 + kfs.write("src/main/resources/functions.drl", kieServices.getResources()
  56 + .newInputStreamResource(this.getClass().getResourceAsStream(
  57 + "/rules/functions.drl"), "UTF-8"));
55 kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources() 58 kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources()
56 .newInputStreamResource(this.getClass().getResourceAsStream( 59 .newInputStreamResource(this.getClass().getResourceAsStream(
57 "/rules/HelloWorld.drl"), "UTF-8")); 60 "/rules/HelloWorld.drl"), "UTF-8"));
@@ -61,6 +64,9 @@ public class MyDroolsConfiguration { @@ -61,6 +64,9 @@ public class MyDroolsConfiguration {
61 kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources() 64 kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources()
62 .newInputStreamResource(this.getClass().getResourceAsStream( 65 .newInputStreamResource(this.getClass().getResourceAsStream(
63 "/rules/ttinfo.drl"), "UTF-8")); 66 "/rules/ttinfo.drl"), "UTF-8"));
  67 + kfs.write("src/main/resources/ttinfo2.drl", kieServices.getResources()
  68 + .newInputStreamResource(this.getClass().getResourceAsStream(
  69 + "/rules/ttinfo2.drl"), "UTF-8"));
64 // TODO:还有其他drl.... 70 // TODO:还有其他drl....
65 71
66 // 4、创建KieBuilder,使用KieFileSystem构建 72 // 4、创建KieBuilder,使用KieFileSystem构建
src/main/java/com/bsth/service/schedule/rules/ttinfo2/CalcuParam.java 0 → 100644
  1 +package com.bsth.service.schedule.rules.ttinfo2;
  2 +
  3 +import org.joda.time.DateTime;
  4 +
  5 +/**
  6 + * 时刻表计算参数。
  7 + */
  8 +public class CalcuParam {
  9 + /** 开始计算时间 */
  10 + private DateTime fromDate;
  11 + /** 结束计算时间 */
  12 + private DateTime toDate;
  13 + /** 线路id */
  14 + private Integer xlId;
  15 +
  16 + public CalcuParam() {}
  17 + public CalcuParam(
  18 + DateTime fromDate,
  19 + DateTime toDate,
  20 + Integer xlId) {
  21 + this.fromDate = fromDate;
  22 + this.toDate = toDate;
  23 + this.xlId = xlId;
  24 + }
  25 +
  26 + public DateTime getFromDate() {
  27 + return fromDate;
  28 + }
  29 +
  30 + public void setFromDate(DateTime fromDate) {
  31 + this.fromDate = fromDate;
  32 + }
  33 +
  34 + public DateTime getToDate() {
  35 + return toDate;
  36 + }
  37 +
  38 + public void setToDate(DateTime toDate) {
  39 + this.toDate = toDate;
  40 + }
  41 +
  42 + public Integer getXlId() {
  43 + return xlId;
  44 + }
  45 +
  46 + public void setXlId(Integer xlId) {
  47 + this.xlId = xlId;
  48 + }
  49 +}
src/main/java/com/bsth/service/schedule/rules/ttinfo2/ErrorBcCountFunction.java 0 → 100644
  1 +package com.bsth.service.schedule.rules.ttinfo2;
  2 +
  3 +import com.bsth.entity.schedule.TTInfoDetail;
  4 +import org.kie.api.runtime.rule.AccumulateFunction;
  5 +
  6 +import java.io.*;
  7 +
  8 +/**
  9 + * Created by xu on 17/2/28.
  10 + */
  11 +public class ErrorBcCountFunction implements AccumulateFunction {
  12 + @Override
  13 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  14 + }
  15 +
  16 + @Override
  17 + public void writeExternal(ObjectOutput out) throws IOException {
  18 + }
  19 +
  20 + protected static class ErrorCountData implements Externalizable {
  21 + public long errorcount = 0;
  22 + public TTInfoDetail ttInfoDetail;
  23 +
  24 + public ErrorCountData() {
  25 + }
  26 +
  27 + @Override
  28 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  29 + errorcount = in.readLong();
  30 + ttInfoDetail = (TTInfoDetail) in.readObject();
  31 + }
  32 +
  33 + @Override
  34 + public void writeExternal(ObjectOutput out) throws IOException {
  35 + out.writeLong(errorcount);
  36 + out.writeObject(ttInfoDetail);
  37 + }
  38 + }
  39 +
  40 + @Override
  41 + public Serializable createContext() {
  42 + return new ErrorCountData();
  43 + }
  44 +
  45 + @Override
  46 + public void init(Serializable context) throws Exception {
  47 + ErrorCountData errorCountData = (ErrorCountData) context;
  48 + errorCountData.errorcount = 0;
  49 + }
  50 +
  51 + @Override
  52 + public void accumulate(Serializable context, Object value) {
  53 + ErrorCountData errorCountData = (ErrorCountData) context;
  54 + TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
  55 +
  56 + if (ttInfoDetail.getTtinfo() == null) {
  57 + errorCountData.errorcount ++;
  58 + return;
  59 + }
  60 +
  61 + if ("in".equals(ttInfoDetail.getBcType())) {
  62 + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getTcc() == null) {
  63 + errorCountData.errorcount ++;
  64 + }
  65 + } else if ("out".equals(ttInfoDetail.getBcType())) {
  66 + if (ttInfoDetail.getTcc() == null || ttInfoDetail.getZdz() == null) {
  67 + errorCountData.errorcount ++;
  68 + }
  69 + } else {
  70 + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getZdz() == null) {
  71 + errorCountData.errorcount ++;
  72 + }
  73 + }
  74 + }
  75 +
  76 + @Override
  77 + public void reverse(Serializable context, Object value) throws Exception {
  78 + ErrorCountData errorCountData = (ErrorCountData) context;
  79 + TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
  80 +
  81 + if (ttInfoDetail.getTtinfo() == null) {
  82 + errorCountData.errorcount --;
  83 + return;
  84 + }
  85 +
  86 + if ("in".equals(ttInfoDetail.getBcType())) {
  87 + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getTcc() == null) {
  88 + errorCountData.errorcount --;
  89 + }
  90 + } else if ("out".equals(ttInfoDetail.getBcType())) {
  91 + if (ttInfoDetail.getTcc() == null || ttInfoDetail.getZdz() == null) {
  92 + errorCountData.errorcount --;
  93 + }
  94 + } else {
  95 + if (ttInfoDetail.getQdz() == null || ttInfoDetail.getZdz() == null) {
  96 + errorCountData.errorcount --;
  97 + }
  98 + }
  99 +
  100 + }
  101 +
  102 + @Override
  103 + public Object getResult(Serializable context) throws Exception {
  104 + ErrorCountData errorCountData = (ErrorCountData) context;
  105 + return errorCountData.errorcount;
  106 + }
  107 +
  108 + @Override
  109 + public boolean supportsReverse() {
  110 + return true;
  111 + }
  112 +
  113 + @Override
  114 + public Class<?> getResultType() {
  115 + return Number.class;
  116 + }
  117 +}
src/main/java/com/bsth/service/schedule/rules/ttinfo2/Result.java 0 → 100644
  1 +package com.bsth.service.schedule.rules.ttinfo2;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * 输出结果值。
  8 + */
  9 +public class Result {
  10 + private List<StatInfo> infos = new ArrayList<>();
  11 +
  12 + public List<StatInfo> getInfos() {
  13 + return infos;
  14 + }
  15 +
  16 + public void setInfos(List<StatInfo> infos) {
  17 + this.infos = infos;
  18 + }
  19 +
  20 + public static class StatInfo {
  21 + /** 时刻表id */
  22 + private Long ttid;
  23 + /** 时刻表名字 */
  24 + private String ttname;
  25 +
  26 + /** 所有班次数 */
  27 + private Long allbc;
  28 + /** 进场班次数 */
  29 + private Long inbc;
  30 + /** 出场班次数 */
  31 + private Long outbc;
  32 + /** 营运班次数 */
  33 + private Long yybc;
  34 +
  35 + /** 错误班次数 */
  36 + private Long errorbc;
  37 +
  38 + public Long getTtid() {
  39 + return ttid;
  40 + }
  41 +
  42 + public void setTtid(Long ttid) {
  43 + this.ttid = ttid;
  44 + }
  45 +
  46 + public String getTtname() {
  47 + return ttname;
  48 + }
  49 +
  50 + public void setTtname(String ttname) {
  51 + this.ttname = ttname;
  52 + }
  53 +
  54 + public Long getAllbc() {
  55 + return allbc;
  56 + }
  57 +
  58 + public void setAllbc(Long allbc) {
  59 + this.allbc = allbc;
  60 + }
  61 +
  62 + public Long getInbc() {
  63 + return inbc;
  64 + }
  65 +
  66 + public void setInbc(Long inbc) {
  67 + this.inbc = inbc;
  68 + }
  69 +
  70 + public Long getOutbc() {
  71 + return outbc;
  72 + }
  73 +
  74 + public void setOutbc(Long outbc) {
  75 + this.outbc = outbc;
  76 + }
  77 +
  78 + public Long getYybc() {
  79 + return yybc;
  80 + }
  81 +
  82 + public void setYybc(Long yybc) {
  83 + this.yybc = yybc;
  84 + }
  85 +
  86 + public Long getErrorbc() {
  87 + return errorbc;
  88 + }
  89 +
  90 + public void setErrorbc(Long errorbc) {
  91 + this.errorbc = errorbc;
  92 + }
  93 + }
  94 +}
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
@@ -72,6 +72,9 @@ public class DataToolsProperties { @@ -72,6 +72,9 @@ public class DataToolsProperties {
72 /** 时刻表明细信息导入 */ 72 /** 时刻表明细信息导入 */
73 @NotNull 73 @NotNull
74 private String ttinfodetailDatainputktr; 74 private String ttinfodetailDatainputktr;
  75 + /** 时刻表明细信息导入 */
  76 + @NotNull
  77 + private String ttinfodetailDatainputktr2;
75 /** 排班规则信息导入 */ 78 /** 排班规则信息导入 */
76 @NotNull 79 @NotNull
77 private String scheduleruleDatainputktr; 80 private String scheduleruleDatainputktr;
@@ -320,4 +323,12 @@ public class DataToolsProperties { @@ -320,4 +323,12 @@ public class DataToolsProperties {
320 public void setGuideboardsDataoutputktr(String guideboardsDataoutputktr) { 323 public void setGuideboardsDataoutputktr(String guideboardsDataoutputktr) {
321 this.guideboardsDataoutputktr = guideboardsDataoutputktr; 324 this.guideboardsDataoutputktr = guideboardsDataoutputktr;
322 } 325 }
  326 +
  327 + public String getTtinfodetailDatainputktr2() {
  328 + return ttinfodetailDatainputktr2;
  329 + }
  330 +
  331 + public void setTtinfodetailDatainputktr2(String ttinfodetailDatainputktr2) {
  332 + this.ttinfodetailDatainputktr2 = ttinfodetailDatainputktr2;
  333 + }
323 } 334 }
src/main/java/com/bsth/websocket/handler/SendUtils.java
@@ -3,6 +3,7 @@ package com.bsth.websocket.handler; @@ -3,6 +3,7 @@ package com.bsth.websocket.handler;
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.bsth.data.BasicData; 4 import com.bsth.data.BasicData;
5 import com.bsth.data.LineConfigData; 5 import com.bsth.data.LineConfigData;
  6 +import com.bsth.data.gpsdata.GpsEntity;
6 import com.bsth.data.gpsdata.arrival.entity.SignalState; 7 import com.bsth.data.gpsdata.arrival.entity.SignalState;
7 import com.bsth.entity.directive.D80; 8 import com.bsth.entity.directive.D80;
8 import com.bsth.entity.realcontrol.ScheduleRealInfo; 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
@@ -170,4 +171,17 @@ public class SendUtils{ @@ -170,4 +171,17 @@ public class SendUtils{
170 list.add(sch); 171 list.add(sch);
171 refreshSch(list); 172 refreshSch(list);
172 } 173 }
  174 +
  175 + public void deviceOffline(GpsEntity gps){
  176 + Map<String, Object> map = new HashMap<>();
  177 + map.put("fn", "deviceOffline");
  178 + map.put("gps", gps);;
  179 + ObjectMapper mapper = new ObjectMapper();
  180 +
  181 + try {
  182 + socketHandler.sendMessageToLine(gps.getLineId().toString(), mapper.writeValueAsString(map));
  183 + } catch (JsonProcessingException e) {
  184 + logger.error("", e);
  185 + }
  186 + }
173 } 187 }
src/main/resources/application-dev.properties
@@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 spring.jpa.database= MYSQL 8 spring.jpa.database= MYSQL
9 spring.jpa.show-sql= false 9 spring.jpa.show-sql= false
10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11 -spring.datasource.url= jdbc:mysql://192.168.168.201/:3306/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 +spring.datasource.url= jdbc:mysql://localhost:3306/qp_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 spring.datasource.username= root 12 spring.datasource.username= root
13 -spring.datasource.password= 123456 13 +spring.datasource.password= root
14 #DATASOURCE 14 #DATASOURCE
15 spring.datasource.max-active=100 15 spring.datasource.max-active=100
16 spring.datasource.max-idle=8 16 spring.datasource.max-idle=8
src/main/resources/datatools/config-dev.properties
@@ -30,11 +30,13 @@ datatools.guideboards_datainputktr=/datatools/ktrs/guideboardDataInput.ktr @@ -30,11 +30,13 @@ datatools.guideboards_datainputktr=/datatools/ktrs/guideboardDataInput.ktr
30 # 时刻表基础信息导入 30 # 时刻表基础信息导入
31 datatools.ttinfo_datainputktr=/datatools/ktrs/ttinfoDataInput.ktr 31 datatools.ttinfo_datainputktr=/datatools/ktrs/ttinfoDataInput.ktr
32 # 时刻表明细信息导入(元数据) 32 # 时刻表明细信息导入(元数据)
33 -datatools.ttinfodetail_metadatainputktr=/datatools/ktrs/ttinfodetailMetaData.ktr 33 +datatools.ttinfodetail_metadatainputktr=/datatools/ktrs/ttinfodetailDataInputMetaData.ktr
34 # 时刻表明细编辑用数据 34 # 时刻表明细编辑用数据
35 datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr 35 datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
36 # 时刻表明细信息导入 36 # 时刻表明细信息导入
37 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr 37 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
  38 +# 时刻表明细信息导入2
  39 +datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr
38 40
39 # 车辆配置信息导入 41 # 车辆配置信息导入
40 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr 42 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr
src/main/resources/datatools/config-prod.properties
@@ -31,11 +31,13 @@ datatools.guideboards_datainputktr=/datatools/ktrs/guideboardDataInput.ktr @@ -31,11 +31,13 @@ datatools.guideboards_datainputktr=/datatools/ktrs/guideboardDataInput.ktr
31 # 时刻表基础信息导入 31 # 时刻表基础信息导入
32 datatools.ttinfo_datainputktr=/datatools/ktrs/ttinfoDataInput.ktr 32 datatools.ttinfo_datainputktr=/datatools/ktrs/ttinfoDataInput.ktr
33 # 时刻表明细信息导入(元数据) 33 # 时刻表明细信息导入(元数据)
34 -datatools.ttinfodetail_metadatainputktr=/datatools/ktrs/ttinfodetailMetaData.ktr 34 +datatools.ttinfodetail_metadatainputktr=/datatools/ktrs/ttinfodetailDataInputMetaData.ktr
35 # 时刻表明细编辑用数据 35 # 时刻表明细编辑用数据
36 datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr 36 datatools.ttinfodetail_foreditktr=/datatools/ktrs/ttinfodetailoutputforedit.ktr
37 # 时刻表明细信息导入 37 # 时刻表明细信息导入
38 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr 38 datatools.ttinfodetail_datainputktr=/datatools/ktrs/ttinfodetailDataInput.ktr
  39 +# 时刻表明细信息导入2
  40 +datatools.ttinfodetail_datainputktr2=/datatools/ktrs/ttinfodetailDataInput2.ktr
39 41
40 # 车辆配置信息导入 42 # 车辆配置信息导入
41 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr 43 datatools.carsconfig_datainputktr=/datatools/ktrs/carsConfigDataInput.ktr