Commit 1508d0decef31c6cd9ce31a8bb6710f08f3ceca9

Authored by 潘钊
2 parents fd05d4f4 c3898a2d

Merge branch 'minhang' into pudong

Showing 45 changed files with 1591 additions and 136 deletions
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
... ... @@ -22,6 +22,9 @@ public class BasicDataController {
22 22 @Autowired
23 23 BasicData.BasicDataLoader dataLoader;
24 24  
  25 + @Autowired
  26 + BasicData basicData;
  27 +
25 28 Logger logger = LoggerFactory.getLogger(this.getClass());
26 29  
27 30 @RequestMapping("/cars")
... ... @@ -114,4 +117,13 @@ public class BasicDataController {
114 117 }
115 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 7 import com.bsth.data.BasicData;
8 8 import com.bsth.data.schedule.DayOfSchedule;
9 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.entity.schedule.SchedulePlanInfo;
10 11 import com.bsth.service.realcontrol.ScheduleRealInfoService;
11 12 import org.apache.commons.lang3.StringEscapeUtils;
12 13 import org.joda.time.format.DateTimeFormat;
... ... @@ -444,9 +445,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
444 445 * 获取当日计划排班 , 从计划表抓取数据
445 446 * @return
446 447 */
447   - @RequestMapping(value = "currentSchedulePlan", method = RequestMethod.GET)
448   - public Map<String, Object> currentSchedulePlan(@RequestParam String lineCodes){
449   - return scheduleRealInfoService.currentSchedulePlan(lineCodes);
  448 + @RequestMapping(value = "currSchedulePlanByLineCode", method = RequestMethod.GET)
  449 + public List<SchedulePlanInfo> currentSchedulePlan(@RequestParam String lineCode){
  450 + return scheduleRealInfoService.currentSchedulePlan(lineCode);
450 451 }
451   -
452 452 }
... ...
src/main/java/com/bsth/controller/schedule/core/SchedulePlanController.java
1 1 package com.bsth.controller.schedule.core;
2 2  
  3 +import com.bsth.common.Constants;
  4 +import com.bsth.common.ResponseCode;
3 5 import com.bsth.controller.schedule.BController;
4 6 import com.bsth.entity.schedule.SchedulePlan;
  7 +import com.bsth.entity.sys.CompanyAuthority;
5 8 import com.bsth.service.schedule.SchedulePlanService;
6 9 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;
  10 +import org.springframework.web.bind.annotation.*;
  11 +
  12 +import javax.servlet.http.HttpSession;
  13 +import java.util.Date;
  14 +import java.util.HashMap;
  15 +import java.util.List;
  16 +import java.util.Map;
10 17  
11 18 /**
12 19 * Created by xu on 16/6/16.
... ... @@ -17,6 +24,21 @@ public class SchedulePlanController extends BController&lt;SchedulePlan, Long&gt; {
17 24 @Autowired
18 25 private SchedulePlanService schedulePlanService;
19 26  
  27 + @Override
  28 + public Map<String, Object> save(@RequestBody SchedulePlan schedulePlan, HttpSession httpSession) {
  29 + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) httpSession.getAttribute(Constants.COMPANY_AUTHORITYS);
  30 + // TODO:如果多个公司,选第一个,以后改成页面控制
  31 + if (cmyAuths == null || cmyAuths.size() == 0)
  32 + schedulePlanService.save(schedulePlan, new CompanyAuthority());
  33 + else
  34 + schedulePlanService.save(schedulePlan, cmyAuths.get(0));
  35 +
  36 + Map<String, Object> rtn = new HashMap<>();
  37 + rtn.put("status", ResponseCode.SUCCESS);
  38 + rtn.put("data", new Object());
  39 + return rtn;
  40 + }
  41 +
20 42 /**
21 43 * 获取明天的一歌排班计划。
22 44 * @return
... ... @@ -31,4 +53,25 @@ public class SchedulePlanController extends BController&lt;SchedulePlan, Long&gt; {
31 53 }
32 54 }
33 55  
  56 + /**
  57 + * 创建指定线路,指定时间范围内的排班计划,使用的时刻表情况
  58 + * @param xlid 线路id
  59 + * @param from 开始时间
  60 + * @param to 结束时间
  61 + * @return
  62 + * @throws Exception
  63 + */
  64 + @RequestMapping(value = "/valttinfo/{xlid}/{from}/{to}", method = RequestMethod.GET)
  65 + public Map<String, Object> validateTTInfo(
  66 + @PathVariable(value = "xlid") Integer xlid,
  67 + @PathVariable(value = "from") Date from,
  68 + @PathVariable(value = "to") Date to
  69 + ) throws Exception {
  70 + // TODO:测试数据
  71 + Map<String, Object> rtn = new HashMap<>();
  72 + rtn.put("status", ResponseCode.SUCCESS);
  73 + rtn.put("data", schedulePlanService.validateTTInfo(xlid, from, to));
  74 + return rtn;
  75 + }
  76 +
34 77 }
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -13,6 +13,7 @@ import org.slf4j.Logger;
13 13 import org.slf4j.LoggerFactory;
14 14 import org.springframework.beans.factory.annotation.Autowired;
15 15 import org.springframework.boot.CommandLineRunner;
  16 +import org.springframework.jdbc.core.JdbcTemplate;
16 17 import org.springframework.stereotype.Component;
17 18  
18 19 import java.util.*;
... ... @@ -89,6 +90,18 @@ public class BasicData implements CommandLineRunner {
89 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 105 @Component
93 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 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.forecast.ForecastRealServer;
5 5 import com.bsth.data.gpsdata.thread.GpsDataLoaderThread;
  6 +import com.bsth.data.gpsdata.thread.OfflineMonitorThread;
6 7 import com.bsth.data.schedule.DayOfSchedule;
7 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
8 9 import com.google.common.collect.TreeMultimap;
... ... @@ -35,6 +36,9 @@ public class GpsRealData implements CommandLineRunner {
35 36 GpsDataLoaderThread gpsDataLoader;
36 37  
37 38 @Autowired
  39 + OfflineMonitorThread offlineMonitorThread;
  40 +
  41 + @Autowired
38 42 DayOfSchedule dayOfSchedule;
39 43  
40 44 @Autowired
... ... @@ -54,9 +58,10 @@ public class GpsRealData implements CommandLineRunner {
54 58 //定时从网关获取GPS数据
55 59 //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 15, TimeUnit.SECONDS);
56 60 //定时扫描掉离线
57   -
  61 + //Application.mainServices.scheduleWithFixedDelay(offlineMonitorThread, 60, 20, TimeUnit.SECONDS);
58 62 }
59 63  
  64 +
60 65 public void put(GpsEntity gps) {
61 66 String device = gps.getDeviceId();
62 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 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 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 46 /**
35 47 * 连续异常信号个数统计
36 48 *
37   - * @param prevs
  49 + * @param
38 50 * @return protected int abnormalCount(CircleQueue<GpsEntity> prevs) {
39 51 * int count = 0;
40 52 * <p>
... ... @@ -78,9 +90,9 @@ public abstract class SignalHandle {
78 90 return false;
79 91  
80 92 GpsEntity prev = prevs.getTail();
81   - //从漂移状态恢复
82   - if (isDriftSignal(prev)
83   - && !isDriftSignal(gps)) {
  93 + //从异常状态恢复
  94 + if (isGpsOffline(prev)
  95 + && !isGpsOffline(gps)) {
84 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 30 @Override
31 31 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
32 32  
  33 + if(isOffline(gps))
  34 + return false;
  35 +
33 36 if(overspeed(gps))
34 37 return true;
35 38  
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
... ... @@ -48,8 +48,8 @@ public class InOutStationSignalHandle extends SignalHandle{
48 48  
49 49 @Override
50 50 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
51   - //忽略漂移信号
52   - if(isDriftSignal(gps))
  51 + //忽略掉线信号
  52 + if(isGpsOffline(gps))
53 53 return false;
54 54  
55 55 //从异常状态恢复的第一个信号
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/OfflineSignalHandle.java
... ... @@ -21,9 +21,10 @@ public class OfflineSignalHandle extends SignalHandle{
21 21  
22 22 @Override
23 23 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
24   - //漂移信号不管
25   - if(isDriftSignal(gps)){
  24 + //掉线信号不管
  25 + if(isGpsOffline(gps)){
26 26 gps.setSignalState("drift");
  27 + gps.setAbnormalStatus("gps-offline");
27 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 88 String nbbm;
89 89 GpsEntity old;
90 90 for (GpsEntity gps : list) {
  91 +
91 92 //没有设备号
92 93 if (StringUtils.isBlank(gps.getDeviceId()))
93 94 continue;
... ...
src/main/java/com/bsth/data/gpsdata/thread/OfflineMonitorThread.java
... ... @@ -2,7 +2,11 @@ package com.bsth.data.gpsdata.thread;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
4 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 8 import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
6 10  
7 11 import java.util.Collection;
8 12  
... ... @@ -10,35 +14,45 @@ import java.util.Collection;
10 14 * GPS掉离线监控
11 15 * Created by panzhao on 2017/1/11.
12 16 */
  17 +@Component
13 18 public class OfflineMonitorThread extends Thread{
14 19  
15 20 @Autowired
16 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 34 @Override
25 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
... ... @@ -407,7 +407,7 @@ public class DayOfSchedule implements CommandLineRunner {
407 407 new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class);
408 408 }
409 409  
410   - private List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
  410 + public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
411 411 List<SchedulePlanInfo> list = new ArrayList<>();
412 412  
413 413 SchedulePlanInfo sp;
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -3,6 +3,7 @@ package com.bsth.service.realcontrol;
3 3 import com.bsth.controller.realcontrol.dto.ChangePersonCar;
4 4 import com.bsth.controller.realcontrol.dto.DfsjChange;
5 5 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  6 +import com.bsth.entity.schedule.SchedulePlanInfo;
6 7 import com.bsth.service.BaseService;
7 8 import org.springframework.stereotype.Service;
8 9  
... ... @@ -149,5 +150,5 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
149 150  
150 151 Map<String, Object> exportWaybillMore(Map<String, Object> map);
151 152  
152   - Map<String,Object> currentSchedulePlan(String lineCodes);
  153 + List<SchedulePlanInfo> currentSchedulePlan(String lineCode);
153 154 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -24,6 +24,7 @@ import com.bsth.entity.realcontrol.SvgAttribute;
24 24 import com.bsth.entity.schedule.CarConfigInfo;
25 25 import com.bsth.entity.schedule.EmployeeConfigInfo;
26 26 import com.bsth.entity.schedule.GuideboardInfo;
  27 +import com.bsth.entity.schedule.SchedulePlanInfo;
27 28 import com.bsth.entity.sys.DutyEmployee;
28 29 import com.bsth.entity.sys.SysUser;
29 30 import com.bsth.repository.LineRepository;
... ... @@ -34,11 +35,11 @@ import com.bsth.repository.realcontrol.SvgAttributeRepository;
34 35 import com.bsth.repository.schedule.CarConfigInfoRepository;
35 36 import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
36 37 import com.bsth.repository.schedule.GuideboardInfoRepository;
37   -import com.bsth.repository.schedule.SchedulePlanRepository;
38 38 import com.bsth.security.util.SecurityUtils;
39 39 import com.bsth.service.SectionRouteService;
40 40 import com.bsth.service.impl.BaseServiceImpl;
41 41 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  42 +import com.bsth.service.schedule.SchedulePlanInfoService;
42 43 import com.bsth.service.sys.DutyEmployeeService;
43 44 import com.bsth.util.*;
44 45 import com.bsth.websocket.handler.SendUtils;
... ... @@ -2176,7 +2177,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2176 2177  
2177 2178 for (ChangePersonCar cpc : cpcs) {
2178 2179  
2179   - if (map.get(cpc.getClZbh()) == null) {
  2180 + if (cpc.getClZbh() != null && map.get(cpc.getClZbh()) == null) {
2180 2181 rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!");
2181 2182 rs.put("status", ResponseCode.ERROR);
2182 2183 return rs;
... ... @@ -3226,16 +3227,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3226 3227 return map;
3227 3228 }
3228 3229  
3229   -
3230   - @Autowired
3231   - SchedulePlanRepository schedulePlanRepository;
3232   -
  3230 + @Autowired
  3231 + SchedulePlanInfoService schPlanService;
3233 3232 @Override
3234   - public Map<String, Object> currentSchedulePlan(String lineCodes) {
3235   - List<String> codes = Splitter.on(",").splitToList(lineCodes);
3236   -
3237   - //List<SchedulePlan> list = schedulePlanRepository.findByMultiLineCode(codes);
3238   - //System.out.println(list);
3239   - return null;
  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;
3240 3249 }
3241 3250 }
3242 3251 \ No newline at end of file
... ...
src/main/java/com/bsth/service/schedule/SchedulePlanService.java
1 1 package com.bsth.service.schedule;
2 2  
3 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 10 * Created by xu on 16/6/16.
7 11 */
8 12 public interface SchedulePlanService extends BService<SchedulePlan, Long> {
  13 +
  14 + SchedulePlan save(SchedulePlan schedulePlan, CompanyAuthority companyAuthority);
  15 +
9 16 /**
10 17 * 获取有明日排班的计划。
11 18 * @return
12 19 */
13 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 31 \ No newline at end of file
... ...
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
... ... @@ -3,19 +3,26 @@ package com.bsth.service.schedule.impl;
3 3 import com.bsth.entity.Line;
4 4 import com.bsth.entity.schedule.*;
5 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
  6 +import com.bsth.entity.sys.CompanyAuthority;
6 7 import com.bsth.repository.schedule.SchedulePlanInfoRepository;
7 8 import com.bsth.repository.schedule.SchedulePlanRepository;
  9 +import com.bsth.service.LineService;
8 10 import com.bsth.service.schedule.SchedulePlanService;
  11 +import com.bsth.service.schedule.TTInfoService;
9 12 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
10 13 import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
11 14 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
12 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
13 16 import com.bsth.service.schedule.rules.strategy.IStrategy;
  17 +import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
  18 +import com.bsth.service.schedule.rules.ttinfo2.Result;
14 19 import com.google.common.collect.Multimap;
15 20 import org.apache.commons.lang3.StringUtils;
16 21 import org.joda.time.DateTime;
17 22 import org.kie.api.KieBase;
18 23 import org.kie.api.runtime.KieSession;
  24 +import org.slf4j.Logger;
  25 +import org.slf4j.LoggerFactory;
19 26 import org.springframework.beans.factory.annotation.Autowired;
20 27 import org.springframework.stereotype.Service;
21 28 import org.springframework.transaction.annotation.Isolation;
... ... @@ -37,10 +44,16 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
37 44 private SchedulePlanRepository schedulePlanRepository;
38 45 @Autowired
39 46 private SchedulePlanInfoRepository schedulePlanInfoRepository;
  47 + @Autowired
  48 + private LineService lineService;
  49 + @Autowired
  50 + private TTInfoService ttInfoService;
  51 +
  52 + /** 日志记录器 */
  53 + private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class);
40 54  
41 55 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
42   - @Override
43   - public SchedulePlan save(SchedulePlan schedulePlan) {
  56 + public SchedulePlan save(SchedulePlan schedulePlan, CompanyAuthority companyAuthority) {
44 57 // 1-1、查找线路具体信息
45 58 Line xl = strategy.getLine(schedulePlan.getXl().getId());
46 59 // 1-2、查出指定线路的所有规则
... ... @@ -116,6 +129,13 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
116 129 configInfo,
117 130 employeeConfigInfoList,
118 131 schedulePlan);
  132 +
  133 + // 公司,分公司编码
  134 + schedulePlanInfo.setGsBm(companyAuthority.getCompanyCode());
  135 + schedulePlanInfo.setGsName(companyAuthority.getCompanyName());
  136 + schedulePlanInfo.setFgsBm(companyAuthority.getSubCompanyCode());
  137 + schedulePlanInfo.setFgsName(companyAuthority.getSubCompanyName());
  138 +
119 139 schedulePlanInfos.add(schedulePlanInfo);
120 140 ttInfoMap.put(ttInfoDetail.getTtinfo().getId(), ttInfoDetail.getTtinfo().getName());
121 141 }
... ... @@ -144,4 +164,32 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
144 164 }
145 165 return null;
146 166 }
  167 +
  168 + @Override
  169 + public Result validateTTInfo(Integer xlid, Date from, Date to) {
  170 + // 构造drools session->载入数据->启动规则->计算->销毁session
  171 + // 创建session,内部配置的是stateful
  172 + KieSession session = kieBase.newKieSession();
  173 + // TODO:设置gloable对象,在drl中通过别名使用
  174 + session.setGlobal("log", logger);
  175 + session.setGlobal("lineService", lineService);
  176 +
  177 + // 载入数据
  178 + CalcuParam calcuParam = new CalcuParam(
  179 + new DateTime(from), new DateTime(to), xlid);
  180 + session.insert(calcuParam);
  181 + List<TTInfo> ttInfos = ttInfoService.findAll();
  182 + for (TTInfo ttInfo: ttInfos)
  183 + session.insert(ttInfo);
  184 +
  185 +
  186 + // 执行rule
  187 + session.fireAllRules();
  188 +
  189 + // 执行完毕销毁,有日志的也要关闭
  190 + session.dispose();
  191 +
  192 +
  193 + return null;
  194 + }
147 195 }
... ...
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
... ... @@ -61,6 +61,9 @@ public class MyDroolsConfiguration {
61 61 kfs.write("src/main/resources/ttinfo.drl", kieServices.getResources()
62 62 .newInputStreamResource(this.getClass().getResourceAsStream(
63 63 "/rules/ttinfo.drl"), "UTF-8"));
  64 + kfs.write("src/main/resources/ttinfo2.drl", kieServices.getResources()
  65 + .newInputStreamResource(this.getClass().getResourceAsStream(
  66 + "/rules/ttinfo2.drl"), "UTF-8"));
64 67 // TODO:还有其他drl....
65 68  
66 69 // 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/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 static class StatInfo {
  13 + /** 时刻表id */
  14 + private Long ttid;
  15 + /** 时刻表名字 */
  16 + private String ttname;
  17 +
  18 + /** 所有班次数 */
  19 + private Integer allbc;
  20 + /** 进场班次数 */
  21 + private Integer inbc;
  22 + /** 出场班次数 */
  23 + private Integer outbc;
  24 + /** 营运班次数 */
  25 + private Integer yybc;
  26 +
  27 + /** 错误班次数 */
  28 + private Integer errorbc;
  29 +
  30 + public Long getTtid() {
  31 + return ttid;
  32 + }
  33 +
  34 + public void setTtid(Long ttid) {
  35 + this.ttid = ttid;
  36 + }
  37 +
  38 + public String getTtname() {
  39 + return ttname;
  40 + }
  41 +
  42 + public void setTtname(String ttname) {
  43 + this.ttname = ttname;
  44 + }
  45 +
  46 + public Integer getAllbc() {
  47 + return allbc;
  48 + }
  49 +
  50 + public void setAllbc(Integer allbc) {
  51 + this.allbc = allbc;
  52 + }
  53 +
  54 + public Integer getInbc() {
  55 + return inbc;
  56 + }
  57 +
  58 + public void setInbc(Integer inbc) {
  59 + this.inbc = inbc;
  60 + }
  61 +
  62 + public Integer getOutbc() {
  63 + return outbc;
  64 + }
  65 +
  66 + public void setOutbc(Integer outbc) {
  67 + this.outbc = outbc;
  68 + }
  69 +
  70 + public Integer getYybc() {
  71 + return yybc;
  72 + }
  73 +
  74 + public void setYybc(Integer yybc) {
  75 + this.yybc = yybc;
  76 + }
  77 +
  78 + public Integer getErrorbc() {
  79 + return errorbc;
  80 + }
  81 +
  82 + public void setErrorbc(Integer errorbc) {
  83 + this.errorbc = errorbc;
  84 + }
  85 + }
  86 +}
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java
... ... @@ -3,6 +3,7 @@ package com.bsth.websocket.handler;
3 3 import com.alibaba.fastjson.JSONObject;
4 4 import com.bsth.data.BasicData;
5 5 import com.bsth.data.LineConfigData;
  6 +import com.bsth.data.gpsdata.GpsEntity;
6 7 import com.bsth.data.gpsdata.arrival.entity.SignalState;
7 8 import com.bsth.entity.directive.D80;
8 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
... ... @@ -170,4 +171,17 @@ public class SendUtils{
170 171 list.add(sch);
171 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/rules/ttinfo2.drl 0 → 100644
  1 +package com.bsth.service.schedule.ttinfo2;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +import org.apache.commons.lang3.StringUtils;
  6 +
  7 +import com.bsth.service.schedule.rules.ttinfo2.Result;
  8 +import com.bsth.service.schedule.rules.ttinfo2.Result.StatInfo;
  9 +import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
  10 +
  11 +import com.bsth.entity.schedule.TTInfo;
  12 +import com.bsth.entity.schedule.TTInfoDetail;
  13 +import com.bsth.entity.Line;
  14 +
  15 +import com.bsth.service.LineService;
  16 +
  17 +import org.slf4j.Logger
  18 +import org.joda.time.format.DateTimeFormat;
  19 +
  20 +// 全局日志类(一般使用调用此规则的service类)
  21 +global Logger log;
  22 +global LineService lineService;
  23 +// 输出
  24 +global Result rs;
  25 +
  26 +/*
  27 + 规则说明:
  28 + 1、找出指定线路,指定时间范围的时刻表
  29 + 2、统计这些时刻表班次数据的情况
  30 +*/
  31 +
  32 +//-------------- 第一阶段、计算规则迭代数据(天数) ------------//
  33 +declare Calcu_iter_days_result
  34 + xlId: Integer // 线路Id
  35 + xlName: String // 线路名字
  36 +
  37 + // 迭代数据
  38 + calcu_day: Integer // 准备计算第几天
  39 + calcu_weekday: Integer // 准备计算星期几(1到7)
  40 + calcu_date: DateTime // 准备计算的具体日期
  41 +
  42 + // 范围数据
  43 + calcu_days: Integer // 总共需要计算的天数
  44 + calcu_start_date: DateTime // 开始计算日期
  45 + calcu_end_date: DateTime // 结束计算日期
  46 +
  47 + // 时刻表映射数据
  48 + ttinfomap: Map // 指定时间段内,用的时刻表id映射 Map<Long, Long>
  49 +end
  50 +
  51 +rule "calcu_iter_days"
  52 + salience 1900
  53 + when
  54 + CalcuParam(
  55 + $xlId: xlId,
  56 + $fromDate: fromDate,
  57 + $toDate: toDate,
  58 + $fromDate.isBefore($toDate) || $fromDate.isEqual($toDate)
  59 + )
  60 + then
  61 + // 构造Calcu_iter_days_result对象,进行下一步计算
  62 + Calcu_iter_days_result cidr = new Calcu_iter_days_result();
  63 + Period p = new Period($fromDate, $toDate, PeriodType.days());
  64 +
  65 + Line line = (Line) lineService.findById($xlId);
  66 +
  67 + cidr.setXlId($xlId);
  68 + cidr.setXlName(line.getName());
  69 +
  70 + cidr.setCalcu_day(new Integer(1));
  71 + cidr.setCalcu_weekday(Integer.valueOf($fromDate.getDayOfWeek()));
  72 + cidr.setCalcu_date($fromDate);
  73 +
  74 + cidr.setCalcu_days(Integer.valueOf(p.getDays() + 1));
  75 + cidr.setCalcu_start_date($fromDate);
  76 + cidr.setCalcu_end_date($toDate);
  77 +
  78 + cidr.setTtinfomap(new HashMap());
  79 +
  80 + log.info(
  81 + "线路={}-id={},开始时间={},结束时间={},总共计算的天数={},将从开始时间迭代",
  82 + cidr.getXlName(),
  83 + cidr.getXlId(),
  84 + cidr.getCalcu_start_date(),
  85 + cidr.getCalcu_end_date(),
  86 + cidr.getCalcu_days()
  87 + );
  88 +
  89 + insert(cidr);
  90 +end
  91 +
  92 +//-------------- 第二阶段、包装时刻表实体类到内部对象 ------------//
  93 +
  94 +declare TTInfo_wrap
  95 + id: Long // 时刻表id
  96 + name: String // 时刻表名字
  97 + weekdays: List // 周一到周日是否启用 List<Boolean>
  98 + specialDays: List // 特殊节假日 List<DateTime>
  99 + updateDate: DateTime // 最新修改时间
  100 +end
  101 +
  102 +rule "TTInfo_wrap_result"
  103 + salience 900
  104 + when
  105 + CalcuParam($xlId: xlId)
  106 + $ttinfo: TTInfo(
  107 + xl.id == $xlId,
  108 + isEnableDisTemplate == true,
  109 + isCancel == false
  110 + )
  111 + then
  112 + TTInfo_wrap ttInfo_wrap = new TTInfo_wrap();
  113 + ttInfo_wrap.setId($ttinfo.getId());
  114 + ttInfo_wrap.setName($ttinfo.getName());
  115 + ttInfo_wrap.setUpdateDate(new DateTime($ttinfo.getUpdateDate()));
  116 + ttInfo_wrap.setWeekdays(new ArrayList());
  117 + ttInfo_wrap.setSpecialDays(new ArrayList());
  118 +
  119 + String[] days = $ttinfo.getRule_days().split(",");
  120 + for (int i = 0; i < 7; i++) {
  121 + if ("1".equals(days[i])) {
  122 + ttInfo_wrap.getWeekdays().add(true);
  123 + } else {
  124 + ttInfo_wrap.getWeekdays().add(false);
  125 + }
  126 + }
  127 +
  128 + if (StringUtils.isNotEmpty($ttinfo.getSpecial_days())) {
  129 + String[] sdays = $ttinfo.getSpecial_days().split(",");
  130 + for (int i = 0; i < sdays.length; i++) {
  131 + ttInfo_wrap.getSpecialDays().add(
  132 + DateTimeFormat.forPattern(
  133 + "yyyy-MM-dd").parseDateTime(sdays[i]));
  134 + }
  135 + }
  136 +
  137 + log.info("时刻表={},id={},常规日期={},特殊日期={}",
  138 + ttInfo_wrap.getName(),
  139 + ttInfo_wrap.getId(),
  140 + ttInfo_wrap.getWeekdays(),
  141 + ttInfo_wrap.getSpecialDays());
  142 +
  143 + insert(ttInfo_wrap);
  144 +
  145 +end
  146 +
  147 +//-------------- 第三阶段、时刻表的日期匹配 ------------//
  148 +
  149 +rule "Calcu_iter_days_special_day" // 特殊日期匹配
  150 + salience 800
  151 + when
  152 + $cid : Calcu_iter_days_result(
  153 + $calcu_date: calcu_date,
  154 + $calcu_day: calcu_day,
  155 + calcu_day <= calcu_days
  156 + )
  157 + TTInfo_wrap(
  158 + $tid: id,
  159 + $tname: name,
  160 + specialDays contains $calcu_date
  161 + )
  162 + then
  163 + // 更新迭代对象
  164 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  165 + $cid.setCalcu_day(new_calcu_day);
  166 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  167 + $cid.setCalcu_date(new_calcu_date);
  168 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  169 +
  170 + log.info("启用特殊日期时刻表:" +
  171 + "时刻表id={} 特殊日期={}",
  172 + $tid, $calcu_date);
  173 +
  174 + // 判定使用的时刻表
  175 + if (!$cid.getTtinfomap().containsKey($tid)) {
  176 + $cid.getTtinfomap().put($tid, $tid);
  177 + StatInfo statInfo = new StatInfo();
  178 + statInfo.setTtid($tid);
  179 + statInfo.setTtname($tname);
  180 + insert(statInfo);
  181 + }
  182 + update($cid);
  183 +
  184 +end
  185 +
  186 +rule "Calcu_iter_days_normal_day" // 平日匹配
  187 + salience 700
  188 + when
  189 + $cid : Calcu_iter_days_result(
  190 + $calcu_date: calcu_date,
  191 + $calcu_weekday: calcu_weekday,
  192 + $calcu_day: calcu_day,
  193 + calcu_day <= calcu_days
  194 + )
  195 + TTInfo_wrap(
  196 + $tid: id,
  197 + $tname: name,
  198 + specialDays not contains $calcu_date,
  199 + weekdays[$calcu_weekday - 1] == Boolean.TRUE
  200 + )
  201 + then
  202 + // 更新迭代对象
  203 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  204 + $cid.setCalcu_day(new_calcu_day);
  205 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  206 + $cid.setCalcu_date(new_calcu_date);
  207 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  208 +
  209 +
  210 + log.info("启用常规日期时刻表:" +
  211 + "时刻表id={} 常规日期={} 星期几={}",
  212 + $tid, $calcu_date, $calcu_weekday);
  213 +
  214 + // 判定使用的时刻表
  215 + if (!$cid.getTtinfomap().containsKey($tid)) {
  216 + $cid.getTtinfomap().put($tid, $tid);
  217 + StatInfo statInfo = new StatInfo();
  218 + statInfo.setTtid($tid);
  219 + statInfo.setTtname($tname);
  220 + insert(statInfo);
  221 + }
  222 + update($cid);
  223 +
  224 +end
  225 +
  226 +rule "Calcu_iter_days_other_day" // 都没有的情况下,匹配
  227 + salience 500
  228 + when
  229 + $cid : Calcu_iter_days_result(
  230 + $calcu_date: calcu_date,
  231 + $calcu_weekday: calcu_weekday,
  232 + $calcu_day: calcu_day,
  233 + calcu_day <= calcu_days
  234 + )
  235 + TTInfo_wrap(
  236 + $tid: id,
  237 + $tname: name,
  238 + specialDays not contains $calcu_date,
  239 + weekdays[$calcu_weekday - 1] == false
  240 + )
  241 + then
  242 + // 更新迭代对象
  243 + Integer new_calcu_day = Integer.valueOf($calcu_day + 1);
  244 + $cid.setCalcu_day(new_calcu_day);
  245 + DateTime new_calcu_date = $calcu_date.plusDays(1);
  246 + $cid.setCalcu_date(new_calcu_date);
  247 + $cid.setCalcu_weekday(Integer.valueOf(new_calcu_date.getDayOfWeek()));
  248 +
  249 + log.info("启用默认日期时刻表:" +
  250 + "时刻表id={} 常规日期={} 星期几={}",
  251 + $tid, $calcu_date, $calcu_weekday);
  252 +
  253 + // 判定使用的时刻表
  254 + if (!$cid.getTtinfomap().containsKey($tid)) {
  255 + $cid.getTtinfomap().put($tid, $tid);
  256 + StatInfo statInfo = new StatInfo();
  257 + statInfo.setTtid($tid);
  258 + statInfo.setTtname($tname);
  259 + insert(statInfo);
  260 + }
  261 + update($cid);
  262 +
  263 +end
  264 +
  265 +//-------------- 第四阶段、时刻表明细统计值 ------------//
  266 +
  267 +rule "statinfo_result"
  268 + when
  269 + $statInfo: StatInfo()
  270 + then
  271 +
  272 + log.info("TODO:时刻表={},id={}", $statInfo.getTtname(), $statInfo.getTtid());
  273 +
  274 +end
  275 +
  276 +
  277 +
  278 +
  279 +
  280 +
  281 +
  282 +
  283 +
  284 +
  285 +
  286 +
  287 +
  288 +
  289 +
  290 +
... ...
src/main/resources/static/pages/scheduleApp/Gruntfile.js
... ... @@ -85,7 +85,8 @@ module.exports = function (grunt) {
85 85 'module/common/dts2/guideboardGroup/saGuideboardgroup.js', // 路牌选择整合指令
86 86 'module/common/dts2/employeeGroup/saEmployeegroup.js', // 人员选饿整合指令
87 87 'module/common/dts2/bcGroup/saBcgroup.js', // 班次选择整合指令
88   - 'module/common/dts2/ttinfotable/saTimeTable.js' // 时刻表显示指令
  88 + 'module/common/dts2/ttinfotable/saTimeTable.js', // 时刻表显示指令
  89 + 'module/common/dts2/scheduleplan/saScpdate.js' // saScpdate指令(非通用指令,只在排版计划form中使用)
89 90 ],
90 91 dest: 'module/common/prj-common-directive.js'
91 92 },
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdate.js 0 → 100644
  1 +/**
  2 + * saScpdate指令(非通用指令,只在排版计划form中使用)。
  3 + * 属性如下:
  4 + * name(必须):控件的名字
  5 + * xlid(必须):线路id
  6 + * xlname(必须):线路名字
  7 + * from(必须):独立作用域-绑定的开始时间属性名
  8 + * to(必须):独立作用域-绑定的结束时间属性名
  9 + * error(必须):独立作用域-绑定的错误描述属性名
  10 + */
  11 +angular.module('ScheduleApp').directive(
  12 + 'saScpdate',
  13 + [
  14 + 'SchedulePlanManageService_g',
  15 + function(service) {
  16 + return {
  17 + restrict: 'E',
  18 + templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html',
  19 + scope: {
  20 + from: '=',
  21 + to: '=',
  22 + xlid: '=',
  23 + xlname: '=',
  24 + error: '='
  25 + },
  26 + controllerAs: '$saScpdateCtrl',
  27 + bindToController: true,
  28 + controller: function() {
  29 + var self = this;
  30 +
  31 + // 内部ng-model值,用于和required配对
  32 + self.$$internalmodel = undefined;
  33 +
  34 + // 内部数据源(时刻表的一些信息)
  35 + self.$$ds = [];
  36 +
  37 + },
  38 + compile: function(tElem, tAttrs) {
  39 + // 获取所有属性,并验证
  40 + var $name_attr = tAttrs['name']; // 控件的名字
  41 + if (!$name_attr) {
  42 + throw "必须有名称属性";
  43 + }
  44 +
  45 + // controlAs名字
  46 + var ctrlAs = '$saScpdateCtrl';
  47 +
  48 + // 线路id
  49 + var xl_id = undefined;
  50 + // 线路名字
  51 + var xl_name = undefined;
  52 + // 开始时间
  53 + var from_date = undefined;
  54 + // 结束时间
  55 + var to_date = undefined;
  56 +
  57 + // 内部添加required验证,将所有的错误应用到required验证上去
  58 + tElem.find("div").attr("required", "");
  59 +
  60 + return {
  61 + pre: function(scope, element, attr) {
  62 +
  63 + },
  64 +
  65 + post: function(scope, element, attr) {
  66 + // 属性值
  67 + if ($name_attr) {
  68 + scope[ctrlAs]["$name_attr"] = $name_attr;
  69 + }
  70 +
  71 + // 开始日期open属性,及方法
  72 + scope[ctrlAs].$$fromDateOpen = false;
  73 + scope[ctrlAs].$$fromDate_open = function() {
  74 + scope[ctrlAs].$$fromDateOpen = true;
  75 + };
  76 +
  77 + // 结束日期open属性,及方法
  78 + scope[ctrlAs].$$toDateOpen = false;
  79 + scope[ctrlAs].$$toDate_open = function() {
  80 + scope[ctrlAs].$$toDateOpen = true;
  81 + };
  82 +
  83 +
  84 + // 内部模型刷新
  85 + scope[ctrlAs].$$internal_model_refresh = function() {
  86 + if (!xl_id) {
  87 + scope[ctrlAs].$$internalmodel = undefined;
  88 + scope[ctrlAs].error = "线路必须选择";
  89 + return;
  90 + }
  91 + if (!xl_name) {
  92 + scope[ctrlAs].$$internalmodel = undefined;
  93 + scope[ctrlAs].error = "线路必须选择";
  94 + return;
  95 + }
  96 +
  97 + if (!from_date) {
  98 + scope[ctrlAs].$$internalmodel = undefined;
  99 + scope[ctrlAs].error = "开始日期必须选择";
  100 + return;
  101 + }
  102 + if (!to_date) {
  103 + scope[ctrlAs].$$internalmodel = undefined;
  104 + scope[ctrlAs].error = "结束日期必须选择";
  105 + return;
  106 + }
  107 + if (from_date > to_date) {
  108 + scope[ctrlAs].$$internalmodel = undefined;
  109 + scope[ctrlAs].error = "开始日期必须在结束日期之前";
  110 + return;
  111 + }
  112 +
  113 + var QClass = service.ttinfo;
  114 + QClass.val({xlid: xl_id, from: from_date, to: to_date},
  115 + function(result) {
  116 + scope[ctrlAs].$$ds = [];
  117 +
  118 + // 模拟数据
  119 + scope[ctrlAs].$$ds.push(
  120 + {
  121 + xlid: 63020,
  122 + ttid: 79,
  123 + xlname: '青浦8路',
  124 + ttname: '测试周末表',
  125 +
  126 + allbc: 18,
  127 + inbc: 4,
  128 + outbc: 4,
  129 + yybc: 14,
  130 +
  131 + errorbc: 0
  132 +
  133 + },
  134 + {
  135 + xlid: 63020,
  136 + ttid: 80,
  137 + xlname: '青浦8路',
  138 + ttname: '周四周五test',
  139 +
  140 + allbc: 18,
  141 + inbc: 4,
  142 + outbc: 4,
  143 + yybc: 14,
  144 +
  145 + errorbc: 10
  146 +
  147 + },
  148 + {
  149 + xlid: 63020,
  150 + ttid: 64,
  151 + xlname: '青浦8路',
  152 + ttname: '青浦8路时刻表1111',
  153 +
  154 + allbc: 18,
  155 + inbc: 4,
  156 + outbc: 4,
  157 + yybc: 14,
  158 +
  159 + errorbc: 10
  160 +
  161 + }
  162 + );
  163 +
  164 +
  165 +
  166 + scope[ctrlAs].$$internalmodel = "ok";
  167 + },
  168 + function() {
  169 + scope[ctrlAs].$$internalmodel = undefined;
  170 + scope[ctrlAs].error = "获取时刻表数据失败!";
  171 + }
  172 + );
  173 +
  174 +
  175 + scope[ctrlAs].$$internalmodel = "ok";
  176 + };
  177 +
  178 + scope[ctrlAs].$$internal_model_refresh(); // 初始执行
  179 +
  180 + //--------------------- 监控属性方法 -------------------//
  181 + // 监控线路id模型值变化
  182 + scope.$watch(
  183 + function() {
  184 + return scope[ctrlAs].xlid;
  185 + },
  186 + function(newValue, oldValue) {
  187 + xl_id = newValue;
  188 + scope[ctrlAs].$$internal_model_refresh();
  189 + }
  190 + );
  191 + // 监控线路name模型值变化
  192 + scope.$watch(
  193 + function() {
  194 + return scope[ctrlAs].xlname;
  195 + },
  196 + function(newValue, oldValue) {
  197 + xl_name = newValue;
  198 + scope[ctrlAs].$$internal_model_refresh();
  199 + }
  200 + );
  201 +
  202 + // 监控开始时间模型值变化
  203 + scope.$watch(
  204 + function() {
  205 + return scope[ctrlAs].from;
  206 + },
  207 + function(newValue, oldValue) {
  208 + from_date = newValue;
  209 + scope[ctrlAs].$$internal_model_refresh();
  210 + }
  211 + );
  212 + // 监控结束时间模型值变化
  213 + scope.$watch(
  214 + function() {
  215 + return scope[ctrlAs].to;
  216 + },
  217 + function(newValue, oldValue) {
  218 + to_date = newValue;
  219 + scope[ctrlAs].$$internal_model_refresh();
  220 + }
  221 + );
  222 +
  223 + }
  224 + };
  225 + }
  226 + };
  227 + }
  228 + ]
  229 +);
0 230 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html 0 → 100644
  1 +<div name="{{$saScpdateCtrl.$name_attr}}" ng-model="$saScpdateCtrl.$$internalmodel">
  2 +
  3 + <style>
  4 + .scp-date-select {
  5 + min-height: 180px;
  6 + border: 1px solid #ddd;
  7 + }
  8 + .scp-date-select .scp-date-input {
  9 + margin: 0px 5px 5px 5px;
  10 + padding-top: 7px;
  11 + padding-left: 0;
  12 + }
  13 + .scp-date-select .scp-date-select-cont {
  14 + text-align: left;
  15 + min-height: 100px;
  16 + padding-right: 0px;
  17 + }
  18 + .scp-date-select .scp-date-select-body {
  19 + margin-top: 10px;
  20 + overflow: auto;
  21 + width: auto;
  22 + min-height: 100px;
  23 + }
  24 +
  25 + .scp-date-select .scp-date-select-body h3 {
  26 + margin: 7px 0 5px;
  27 + text-indent: 5px;
  28 + margin: 0;
  29 + height: 31px;
  30 + line-height: 31px;
  31 + color: #2765A7;
  32 +
  33 + text-overflow: ellipsis;
  34 + overflow: hidden;
  35 + white-space: nowrap;
  36 + }
  37 +
  38 + .scp-date-select .scp-date-select-body .increase-popover-width {
  39 + max-width: 450px;
  40 + }
  41 +
  42 +
  43 +
  44 + </style>
  45 +
  46 + <div class="col-md-12 scp-date-select">
  47 + <div class="col-md-12 scp-date-input">
  48 + <div class="col-md-12">
  49 + 使用的时刻表,共{{$saScpdateCtrl.$$ds.length}}个
  50 + </div>
  51 + </div>
  52 + <div class="col-md-12 scp-date-select-cont">
  53 + <div class="scp-date-select-body">
  54 +
  55 + <script type="text/ng-template" id="$saScpdateCtrl_popover.html">
  56 + <div><span ng-bind="info.ttname"></span></div>
  57 + <div><span>统计班次:{{info.allbc}}个,出场:{{info.outbc}}个,进场:{{info.inbc}}个,营运:{{info.yybc}}个</span></div>
  58 + <div><span>异常班次:{{info.errorbc}}个</span></div>
  59 + </script>
  60 +
  61 + <div ng-repeat="info in $saScpdateCtrl.$$ds track by $index">
  62 +
  63 + <div class="col-md-12" uib-popover-template="'$saScpdateCtrl_popover.html'"
  64 + popover-class="increase-popover-width"
  65 + popover-trigger="mouseenter">
  66 + <h3 class="col-md-8">
  67 + <a ui-sref="ttInfoDetailManage_edit3({xlid: info.xlid, ttid : info.ttid, xlname: info.xlname, ttname : info.ttname, rflag : true})">
  68 + {{info.ttname}}
  69 + </a>
  70 + </h3>
  71 + <span class="glyphicon glyphicon-ok" aria-hidden="true" ng-if="info.errorbc == 0"></span>
  72 + <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-if="info.errorbc > 0"></span>
  73 + </div>
  74 + </div>
  75 + </div>
  76 + </div>
  77 + </div>
  78 +
  79 +
  80 +
  81 +</div>
0 82 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -3817,3 +3817,233 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saTimetable&#39;, [&#39;$compile&#39;, &#39;$window&#39;,
3817 3817 };
3818 3818 }
3819 3819 ]);
  3820 +
  3821 +/**
  3822 + * saScpdate指令(非通用指令,只在排版计划form中使用)。
  3823 + * 属性如下:
  3824 + * name(必须):控件的名字
  3825 + * xlid(必须):线路id
  3826 + * xlname(必须):线路名字
  3827 + * from(必须):独立作用域-绑定的开始时间属性名
  3828 + * to(必须):独立作用域-绑定的结束时间属性名
  3829 + * error(必须):独立作用域-绑定的错误描述属性名
  3830 + */
  3831 +angular.module('ScheduleApp').directive(
  3832 + 'saScpdate',
  3833 + [
  3834 + 'SchedulePlanManageService_g',
  3835 + function(service) {
  3836 + return {
  3837 + restrict: 'E',
  3838 + templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html',
  3839 + scope: {
  3840 + from: '=',
  3841 + to: '=',
  3842 + xlid: '=',
  3843 + xlname: '=',
  3844 + error: '='
  3845 + },
  3846 + controllerAs: '$saScpdateCtrl',
  3847 + bindToController: true,
  3848 + controller: function() {
  3849 + var self = this;
  3850 +
  3851 + // 内部ng-model值,用于和required配对
  3852 + self.$$internalmodel = undefined;
  3853 +
  3854 + // 内部数据源(时刻表的一些信息)
  3855 + self.$$ds = [];
  3856 +
  3857 + },
  3858 + compile: function(tElem, tAttrs) {
  3859 + // 获取所有属性,并验证
  3860 + var $name_attr = tAttrs['name']; // 控件的名字
  3861 + if (!$name_attr) {
  3862 + throw "必须有名称属性";
  3863 + }
  3864 +
  3865 + // controlAs名字
  3866 + var ctrlAs = '$saScpdateCtrl';
  3867 +
  3868 + // 线路id
  3869 + var xl_id = undefined;
  3870 + // 线路名字
  3871 + var xl_name = undefined;
  3872 + // 开始时间
  3873 + var from_date = undefined;
  3874 + // 结束时间
  3875 + var to_date = undefined;
  3876 +
  3877 + // 内部添加required验证,将所有的错误应用到required验证上去
  3878 + tElem.find("div").attr("required", "");
  3879 +
  3880 + return {
  3881 + pre: function(scope, element, attr) {
  3882 +
  3883 + },
  3884 +
  3885 + post: function(scope, element, attr) {
  3886 + // 属性值
  3887 + if ($name_attr) {
  3888 + scope[ctrlAs]["$name_attr"] = $name_attr;
  3889 + }
  3890 +
  3891 + // 开始日期open属性,及方法
  3892 + scope[ctrlAs].$$fromDateOpen = false;
  3893 + scope[ctrlAs].$$fromDate_open = function() {
  3894 + scope[ctrlAs].$$fromDateOpen = true;
  3895 + };
  3896 +
  3897 + // 结束日期open属性,及方法
  3898 + scope[ctrlAs].$$toDateOpen = false;
  3899 + scope[ctrlAs].$$toDate_open = function() {
  3900 + scope[ctrlAs].$$toDateOpen = true;
  3901 + };
  3902 +
  3903 +
  3904 + // 内部模型刷新
  3905 + scope[ctrlAs].$$internal_model_refresh = function() {
  3906 + if (!xl_id) {
  3907 + scope[ctrlAs].$$internalmodel = undefined;
  3908 + scope[ctrlAs].error = "线路必须选择";
  3909 + return;
  3910 + }
  3911 + if (!xl_name) {
  3912 + scope[ctrlAs].$$internalmodel = undefined;
  3913 + scope[ctrlAs].error = "线路必须选择";
  3914 + return;
  3915 + }
  3916 +
  3917 + if (!from_date) {
  3918 + scope[ctrlAs].$$internalmodel = undefined;
  3919 + scope[ctrlAs].error = "开始日期必须选择";
  3920 + return;
  3921 + }
  3922 + if (!to_date) {
  3923 + scope[ctrlAs].$$internalmodel = undefined;
  3924 + scope[ctrlAs].error = "结束日期必须选择";
  3925 + return;
  3926 + }
  3927 + if (from_date > to_date) {
  3928 + scope[ctrlAs].$$internalmodel = undefined;
  3929 + scope[ctrlAs].error = "开始日期必须在结束日期之前";
  3930 + return;
  3931 + }
  3932 +
  3933 + var QClass = service.ttinfo;
  3934 + QClass.val({xlid: xl_id, from: from_date, to: to_date},
  3935 + function(result) {
  3936 + scope[ctrlAs].$$ds = [];
  3937 +
  3938 + // 模拟数据
  3939 + scope[ctrlAs].$$ds.push(
  3940 + {
  3941 + xlid: 63020,
  3942 + ttid: 79,
  3943 + xlname: '青浦8路',
  3944 + ttname: '测试周末表',
  3945 +
  3946 + allbc: 18,
  3947 + inbc: 4,
  3948 + outbc: 4,
  3949 + yybc: 14,
  3950 +
  3951 + errorbc: 0
  3952 +
  3953 + },
  3954 + {
  3955 + xlid: 63020,
  3956 + ttid: 80,
  3957 + xlname: '青浦8路',
  3958 + ttname: '周四周五test',
  3959 +
  3960 + allbc: 18,
  3961 + inbc: 4,
  3962 + outbc: 4,
  3963 + yybc: 14,
  3964 +
  3965 + errorbc: 10
  3966 +
  3967 + },
  3968 + {
  3969 + xlid: 63020,
  3970 + ttid: 64,
  3971 + xlname: '青浦8路',
  3972 + ttname: '青浦8路时刻表1111',
  3973 +
  3974 + allbc: 18,
  3975 + inbc: 4,
  3976 + outbc: 4,
  3977 + yybc: 14,
  3978 +
  3979 + errorbc: 10
  3980 +
  3981 + }
  3982 + );
  3983 +
  3984 +
  3985 +
  3986 + scope[ctrlAs].$$internalmodel = "ok";
  3987 + },
  3988 + function() {
  3989 + scope[ctrlAs].$$internalmodel = undefined;
  3990 + scope[ctrlAs].error = "获取时刻表数据失败!";
  3991 + }
  3992 + );
  3993 +
  3994 +
  3995 + scope[ctrlAs].$$internalmodel = "ok";
  3996 + };
  3997 +
  3998 + scope[ctrlAs].$$internal_model_refresh(); // 初始执行
  3999 +
  4000 + //--------------------- 监控属性方法 -------------------//
  4001 + // 监控线路id模型值变化
  4002 + scope.$watch(
  4003 + function() {
  4004 + return scope[ctrlAs].xlid;
  4005 + },
  4006 + function(newValue, oldValue) {
  4007 + xl_id = newValue;
  4008 + scope[ctrlAs].$$internal_model_refresh();
  4009 + }
  4010 + );
  4011 + // 监控线路name模型值变化
  4012 + scope.$watch(
  4013 + function() {
  4014 + return scope[ctrlAs].xlname;
  4015 + },
  4016 + function(newValue, oldValue) {
  4017 + xl_name = newValue;
  4018 + scope[ctrlAs].$$internal_model_refresh();
  4019 + }
  4020 + );
  4021 +
  4022 + // 监控开始时间模型值变化
  4023 + scope.$watch(
  4024 + function() {
  4025 + return scope[ctrlAs].from;
  4026 + },
  4027 + function(newValue, oldValue) {
  4028 + from_date = newValue;
  4029 + scope[ctrlAs].$$internal_model_refresh();
  4030 + }
  4031 + );
  4032 + // 监控结束时间模型值变化
  4033 + scope.$watch(
  4034 + function() {
  4035 + return scope[ctrlAs].to;
  4036 + },
  4037 + function(newValue, oldValue) {
  4038 + to_date = newValue;
  4039 + scope[ctrlAs].$$internal_model_refresh();
  4040 + }
  4041 + );
  4042 +
  4043 + }
  4044 + };
  4045 + }
  4046 + };
  4047 + }
  4048 + ]
  4049 +);
3820 4050 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
... ... @@ -468,6 +468,15 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;SchedulePlanManageService_g&#39;, [&#39;$resource
468 468 method: 'GET'
469 469 }
470 470 }
  471 + ),
  472 + ttinfo: $resource(
  473 + '/spc/valttinfo/:xlid/:from/:to',
  474 + {xlid: '@xlid', from: '@from', to: '@to'},
  475 + {
  476 + val: {
  477 + method: 'GET'
  478 + }
  479 + }
471 480 )
472 481 };
473 482 }]);
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/form.html
... ... @@ -43,24 +43,26 @@
43 43 <div class="form-group has-success has-feedback">
44 44 <label class="col-md-2 control-label">线路*:</label>
45 45 <div class="col-md-3">
46   - <sa-Select3 model="ctrl.schedulePlanManageForSave"
47   - name="xl"
48   - placeholder="请输拼音..."
49   - dcvalue="{{ctrl.schedulePlanManageForSave.xl.id}}"
  46 + <sa-Select5 name="xl"
  47 + model="ctrl.schedulePlanManageForSave"
  48 + cmaps="{'xl.id' : 'id', 'xl.name': 'name'}"
50 49 dcname="xl.id"
51 50 icname="id"
52   - icnames="name"
53   - datatype="xl"
54   - mlp="true"
  51 + dsparams="{{ {type: 'ajax', param:{type: 'all', 'destroy_eq': 0}, atype:'xl' } | json }}"
  52 + iterobjname="item"
  53 + iterobjexp="item.name"
  54 + searchph="请输拼音..."
  55 + searchexp="this.name"
55 56 required >
56   - </sa-Select3>
  57 + </sa-Select5>
57 58 </div>
58 59 <!-- 隐藏块,显示验证信息 -->
59 60 <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required">
60 61 线路必须选择
61 62 </div>
62 63 </div>
63   - <div class="form-group">
  64 +
  65 + <div class="form-group has-success has-feedback">
64 66 <label class="col-md-2 control-label">开始日期*:</label>
65 67 <div class="col-md-3">
66 68 <div class="input-group">
... ... @@ -82,7 +84,7 @@
82 84 </div>
83 85 </div>
84 86  
85   - <div class="form-group">
  87 + <div class="form-group has-success has-feedback">
86 88 <label class="col-md-2 control-label">结束日期*:</label>
87 89 <div class="col-md-3">
88 90 <div class="input-group">
... ... @@ -104,6 +106,24 @@
104 106 </div>
105 107 </div>
106 108  
  109 + <!--<div class="form-group has-success has-feedback">-->
  110 + <!--<label class="col-md-2 control-label">时刻表信息*:</label>-->
  111 + <!--<div class="col-md-6">-->
  112 + <!--<sa-Scpdate name="scp_s_t_date"-->
  113 + <!--xlid="ctrl.schedulePlanManageForSave.xl.id"-->
  114 + <!--xlname="ctrl.schedulePlanManageForSave.xl.name"-->
  115 + <!--from="ctrl.schedulePlanManageForSave.scheduleFromTime"-->
  116 + <!--to="ctrl.schedulePlanManageForSave.scheduleToTime"-->
  117 + <!--error="ctrl.scperror"-->
  118 + <!--required-->
  119 + <!-->-->
  120 + <!--</sa-Scpdate>-->
  121 + <!--</div>-->
  122 + <!--<div class="alert alert-danger well-sm" ng-show="myForm.scp_s_t_date.$error.required">-->
  123 + <!--{{ctrl.scperror}}-->
  124 + <!--</div>-->
  125 + <!--</div>-->
  126 +
107 127 <!-- 其他form-group -->
108 128  
109 129 </div>
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/list.html
... ... @@ -15,15 +15,18 @@
15 15 <tr role="row" class="filter">
16 16 <td></td>
17 17 <td>
18   - <sa-Select3 model="ctrl.searchCondition()"
19   - name="xl"
20   - placeholder="请输拼音..."
21   - dcvalue="{{ctrl.searchCondition()['xl.id_eq']}}"
  18 + <sa-Select5 name="xl"
  19 + model="ctrl.searchCondition()"
  20 + cmaps="{'xl.id_eq': 'id', 'xl.name_eq': 'name'}"
22 21 dcname="xl.id_eq"
23 22 icname="id"
24   - icnames="name"
25   - datatype="xl">
26   - </sa-Select3>
  23 + dsparams="{{ {type: 'ajax', param:{type: 'all', 'destroy_eq': 0}, atype:'xl' } | json }}"
  24 + iterobjname="item"
  25 + iterobjexp="item.name"
  26 + searchph="请输拼音..."
  27 + searchexp="this.name"
  28 + required >
  29 + </sa-Select5>
27 30 </td>
28 31 <td>
29 32 <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition().name_like" placeholder="输入时刻表名称..."/>
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/module.js
... ... @@ -146,6 +146,10 @@ angular.module(&#39;ScheduleApp&#39;).controller(
146 146 self.schedulePlanManageForSave = new SPlan;
147 147 self.schedulePlanManageForSave.xl = {};
148 148  
  149 + // 初始表单,从查询条件中获取线路id
  150 + self.schedulePlanManageForSave.xl.id = service.getSearchCondition()['xl.id_eq'];
  151 + self.schedulePlanManageForSave.xl.name = service.getSearchCondition()['xl.name_eq'];
  152 +
149 153 // 提交方法
150 154 self.submit = function() {
151 155 console.log(self.schedulePlanManageForSave);
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/service.js
... ... @@ -46,6 +46,15 @@ angular.module(&#39;ScheduleApp&#39;).factory(&#39;SchedulePlanManageService_g&#39;, [&#39;$resource
46 46 method: 'GET'
47 47 }
48 48 }
  49 + ),
  50 + ttinfo: $resource(
  51 + '/spc/valttinfo/:xlid/:from/:to',
  52 + {xlid: '@xlid', from: '@from', to: '@to'},
  53 + {
  54 + val: {
  55 + method: 'GET'
  56 + }
  57 + }
49 58 )
50 59 };
51 60 }]);
... ...
src/main/resources/static/real_control_v2/css/home.css
... ... @@ -298,4 +298,8 @@ span.signal-state-speed-limit{
298 298  
299 299 .qtip-home-rb .uk-list li{
300 300 padding: 4px 2px;
  301 +}
  302 +
  303 +.home-gps-table dl.offline dd:nth-of-type(1) a{
  304 + color: #a3a2a2;
301 305 }
302 306 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/css/main.css
... ... @@ -784,4 +784,30 @@ li.map-panel {
784 784 #cache_data_manage-modal .uk-table td,
785 785 #cache_data_manage-modal .uk-table th{
786 786 padding: 8px 8px 6px;
  787 +}
  788 +
  789 +
  790 +.ps-help-panel{
  791 + color: grey;
  792 + padding: 5px 2px;
  793 +}
  794 +
  795 +.ps-help-panel small{
  796 + display: block;
  797 +}
  798 +
  799 +
  800 +svg text.offline{
  801 + fill: #534e4e !important;
  802 +}
  803 +
  804 +svg rect.offline{
  805 + stroke: #abaaaa !important;
  806 + fill: #b8b8b8 !important;
  807 +}
  808 +
  809 +.tooltip .tooltip-container .title a>.abnormal-text{
  810 + font-size: 14px;
  811 + color: #ff5e5e;
  812 + font-weight: 600;
787 813 }
788 814 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/fragments/home/line_panel.html
... ... @@ -25,7 +25,7 @@
25 25 </script>
26 26  
27 27 <script id="home-gps-tbody-temp" type="text/html">
28   - <dl id="home_gps_{{deviceId}}" data-device-id="{{deviceId}}">
  28 + <dl id="home_gps_{{deviceId}}" data-device-id="{{deviceId}}" {{if abnormalStatus=='offline'}}class="offline"{{/if}}>
29 29 <dd title="{{nbbm}}"><a>{{nbbm}}</a></dd>
30 30 <dd>{{speed}}</dd>
31 31 <dd>{{expectStopTime}}</dd>
... ...
src/main/resources/static/real_control_v2/fragments/home/tooltip.html
... ... @@ -3,7 +3,18 @@
3 3 <div class="tooltip" >
4 4 <div class="tooltip-container">
5 5 <div class="title">
6   - <a href="javascript:;" data-for="station" class="tip_modal">{{nbbm}}</a>
  6 + <a href="javascript:;" data-for="station" class="tip_modal">
  7 + {{nbbm}}
  8 + {{if abnormalStatus == 'outBounds'}}
  9 + <span class="abnormal-text">越界</span>
  10 + {{else if abnormalStatus == 'overspeed'}}
  11 + <span class="abnormal-text">超速</span>
  12 + {{else if abnormalStatus == 'gps-offline'}}
  13 + <span class="abnormal-text">GPS掉线</span>
  14 + {{else if abnormalStatus == 'offline'}}
  15 + <span class="abnormal-text">已离线</span>
  16 + {{/if}}
  17 + </a>
7 18 </div>
8 19 <div>
9 20 <span class="field">站点:</span>{{stationName}}
... ... @@ -36,7 +47,9 @@
36 47 <div class="tooltip multi-tooltip" >
37 48 <div class="tooltip-container">
38 49 <div class="title">
39   - <a href="javascript:;" data-for="station" class="tip_modal">{{gps.nbbm}}</a>
  50 + <a href="javascript:;" data-for="station" class="tip_modal">
  51 + {{gps.nbbm}}
  52 + </a>
40 53 </div>
41 54 <div>
42 55 <span class="field">站点:</span>{{gps.stationName}}
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/curr_date_schedule.html
... ... @@ -75,6 +75,16 @@
75 75 .curr-schedule-table dl dt:nth-of-type(18), .curr-schedule-table dl dd:nth-of-type(18) {
76 76 width: 5%;
77 77 }
  78 +
  79 + #curr-date-schedule-modal .line_list_ul li{
  80 + margin-top:0 !important;
  81 + padding: 5px;
  82 + cursor: default;
  83 + }
  84 +
  85 + #curr-date-schedule-modal .line_list_ul li.active{
  86 + background: #93d1ff;
  87 + }
78 88 </style>
79 89  
80 90 <div class="uk-modal-dialog uk-modal-dialog-large">
... ... @@ -83,15 +93,12 @@
83 93 <h2>当日计划排班</h2></div>
84 94  
85 95 <div class="uk-grid uk-grid-collapse">
86   - <div class="uk-width-medium-1-10">
87   - <ul class="uk-list uk-list-line uk-width-medium-1-1">
88   - <li>219路</li>
89   - <li>784路</li>
90   - <li>166路</li>
  96 + <div class="uk-width-medium-1-10" style="border-right: 1px solid #81c7fb;border-top: 1px solid #81c7fb;box-shadow: 3px -2px 2px 0 rgba(129, 199, 251, 0.19), 4px -3px 2px 0 rgba(129, 199, 251, 0.2);width: calc(10% - 3px);margin-right: 3px;">
  97 + <ul class="uk-list uk-list-line uk-width-medium-1-1 line_list_ul">
91 98 </ul>
92 99 </div>
93 100 <div class="uk-width-medium-9-10">
94   - <div class="ct_table_wrap">
  101 + <div class="ct_table_wrap" style="height: 460px;">
95 102 <div class="ct_table curr-schedule-table">
96 103 <div class="ct_table_head">
97 104 <dl>
... ... @@ -124,6 +131,53 @@
124 131 </div>
125 132 </div>
126 133  
  134 + <script id="curr_schedule_tree-temp" type="text/html">
  135 + {{each list as line i}}
  136 + <li data-id="{{line.lineCode}}">{{line.name}}</li>
  137 + {{/each}}
  138 + </script>
  139 +
  140 + <script id="curr_schedule_list-temp" type="text/html">
  141 + {{each list as sch i}}
  142 + <dl>
  143 + <dd>{{sch.scheduleDateStr}}</dd>
  144 + <dd>{{sch.xlBm}}</dd>
  145 + <dd>{{sch.lpName}}</dd>
  146 + <dd>{{sch.clZbh}}</dd>
  147 + <dd>{{sch.plate}}</dd>
  148 + <dd>营运</dd>
  149 + <dd>{{sch.personArray[0].jGh}}</dd>
  150 + <dd>{{sch.personArray[0].jName}}</dd>
  151 + <dd>{{sch.personArray[0].sGh}}</dd>
  152 + <dd>{{sch.personArray[0].sName}}</dd>
  153 +
  154 + {{if sch.personArray.length >= 2}}
  155 + <dd>{{sch.personArray[1].jGh}}</dd>
  156 + <dd>{{sch.personArray[1].jName}}</dd>
  157 + <dd>{{sch.personArray[1].sGh}}</dd>
  158 + <dd>{{sch.personArray[1].sName}}</dd>
  159 + {{else}}
  160 + <dd></dd>
  161 + <dd></dd>
  162 + <dd></dd>
  163 + <dd></dd>
  164 + {{/if}}
  165 +
  166 +
  167 + {{if sch.personArray.length >= 3}}
  168 + <dd>{{sch.personArray[2].jGh}}</dd>
  169 + <dd>{{sch.personArray[2].jName}}</dd>
  170 + <dd>{{sch.personArray[2].sGh}}</dd>
  171 + <dd>{{sch.personArray[2].sName}}</dd>
  172 + {{else}}
  173 + <dd></dd>
  174 + <dd></dd>
  175 + <dd></dd>
  176 + <dd></dd>
  177 + {{/if}}
  178 + </dl>
  179 + {{/each}}
  180 + </script>
127 181  
128 182 <script>
129 183 (function () {
... ... @@ -132,13 +186,76 @@
132 186 $(modal).on('init', function (e, data) {
133 187 e.stopPropagation();
134 188  
  189 + //线路列表
  190 + var htmlStr = template('curr_schedule_tree-temp', {list: gb_data_basic.activeLines});
  191 + $('.line_list_ul', modal).html(htmlStr);
135 192  
  193 + //默认点击第一个
  194 + $('.line_list_ul li:eq(0)', modal).trigger('click');
136 195 });
137 196  
  197 + $(modal).on('click', '.line_list_ul li', function () {
  198 + $('.line_list_ul li.active').removeClass('active');
  199 + $(this).addClass('active');
  200 + query($(this).data('id'));
  201 + });
  202 +
  203 + var query = function (lineCode) {
  204 + $.get('/realSchedule/currSchedulePlanByLineCode', {lineCode: lineCode}, function (rs) {
  205 +
138 206  
139   - var query = function () {
  207 + var data=[];
  208 + //先按路牌分组
  209 + var lpMapData = gb_common.groupBy(rs, 'lpName');
140 210  
  211 + for(var lp in lpMapData){
  212 + data.push(mergeSchData(lpMapData[lp]));
  213 + }
  214 +
  215 + var htmlStr = template('curr_schedule_list-temp', {list: data});
  216 + $('.ct_table_body', modal).html(htmlStr);
  217 + });
141 218 };
  219 +
  220 + /**
  221 + * 合并同一个路牌下的班次
  222 + * @param list
  223 + */
  224 + function mergeSchData(list) {
  225 + var sch = list[0];
  226 + sch.scheduleDateStr = moment(sch.scheduleDate).format('YYYY-MM-DD');
  227 + //车牌号
  228 + sch.plate = gb_data_basic.nbbm2PlateMap()[sch.clZbh];
  229 +
  230 + var personArray=[];
  231 + $.each(list, function () {
  232 + if(!isExist(personArray, this)){
  233 + personArray.push(getPerson(this));
  234 + }
  235 + });
  236 +
  237 + sch.personArray=personArray;
  238 + return sch;
  239 + }
  240 +
  241 + function getPerson(sch){
  242 + return {
  243 + jGh: sch.jGh,
  244 + jName: sch.jName,
  245 + sGh: sch.sGh,
  246 + sName: sch.sName
  247 + }
  248 + }
  249 +
  250 + function isExist(array, sch) {
  251 + for(var i = 0, person; person=array[i++];){
  252 + if(person.jGh == sch.jGh && person.sGh == sch.sGh){
  253 + return true;
  254 + }
  255 + }
  256 +
  257 + return false;
  258 + }
142 259 })();
143 260 </script>
144 261 </div>
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/line_config/line_config.html
... ... @@ -3,33 +3,37 @@
3 3 <button class="uk-modal-close uk-close" type="button"></button>
4 4 <div class="uk-grid uk-flex-middle" data-uk-grid-margin>
5 5 <div class="uk-width-medium-1-6 uk-height-viewport line-config-tree" data-uk-observe>
6   - <h3 class="title" >线路配置</h3>
  6 + <h3 class="title">线路配置</h3>
7 7 <div class="uk-accordion" data-uk-accordion="{showfirst:false}"></div>
8 8 </div>
9   - <div class="uk-width-medium-5-6 uk-height-viewport right-container" >
  9 + <div class="uk-width-medium-5-6 uk-height-viewport right-container">
10 10 <div id="line_config_entity_panel"></div>
11 11 <div id="buffer_config_panel"></div>
12 12 </div>
13 13 </div>
  14 +
  15 + <div style="position: absolute;top: 10px;left: 40%;padding: 10px;color: #fe4242;background: #f2f2f2;box-shadow: 3px 1px 4px 0 rgba(0, 0, 0, 0.2), 1px 0px 5px 0 rgba(0, 0, 0, 0.19);font-size: 16px;">
  16 + 功能调试中,当前页面暂不可用!!!
  17 + </div>
14 18 </div>
15 19  
16 20  
17 21 <script id="nav-line_config-modal-tree-temp" type="text/html">
18   - {{each array as line i}}
19   - <h3 class="uk-accordion-title" data-id="{{line.lineCode}}">{{line.name}}</h3>
20   - <div class="uk-accordion-content">
21   - <ul class="uk-list uk-list-line">
22   - <li><a>班次更新时间</a></li>
23   - <li><a>出场时间类型</a></li>
24   - <li><a>原线路回场</a></li>
25   - <li><a>到站缓冲区设置</a></li>
26   - <li><a>应急停靠</a></li>
27   - <li><a class="disabled">漂移判定</a></li>
28   - <li><a class="disabled">到离站预测</a></li>
29   - <li><a class="disabled">挂牌时刻表</a></li>
30   - </ul>
31   - </div>
32   - {{/each}}
  22 + {{each array as line i}}
  23 + <h3 class="uk-accordion-title" data-id="{{line.lineCode}}">{{line.name}}</h3>
  24 + <div class="uk-accordion-content">
  25 + <ul class="uk-list uk-list-line">
  26 + <li><a>班次更新时间</a></li>
  27 + <li><a>出场时间类型</a></li>
  28 + <li><a>原线路回场</a></li>
  29 + <li><a>到站缓冲区设置</a></li>
  30 + <li><a>应急停靠</a></li>
  31 + <li><a class="disabled">漂移判定</a></li>
  32 + <li><a class="disabled">到离站预测</a></li>
  33 + <li><a class="disabled">挂牌时刻表</a></li>
  34 + </ul>
  35 + </div>
  36 + {{/each}}
33 37 </script>
34 38  
35 39 <script>
... ... @@ -37,7 +41,7 @@
37 41 var modal = '#nav-line_config-modal',
38 42 lineConfig, activeCode;
39 43  
40   - $(modal).on('init', function(e, data) {
  44 + $(modal).on('init', function (e, data) {
41 45 e.stopPropagation();
42 46 var htmlStr = template('nav-line_config-modal-tree-temp', {array: gb_data_basic.activeLines});
43 47 $('.line-config-tree .uk-accordion', modal).html(htmlStr);
... ...
src/main/resources/static/real_control_v2/js/data/data_basic.js
... ... @@ -91,6 +91,11 @@ var gb_data_basic = (function () {
91 91 $.get('/basic/nbbm2deviceId', function (rs) {
92 92 ep.emit('nbbm2deviceId', rs);
93 93 });
  94 + //nbbm to 车牌号
  95 + var nbbm2PlateMap;
  96 + $.get('/basic/nbbm2PlateNo', function (rs) {
  97 + nbbm2PlateMap = rs;
  98 + });
94 99  
95 100 //模拟图属性数据
96 101 gb_common.$get('/realSchedule/svgAttr', {idx: line_idx}, function (rs) {
... ... @@ -190,6 +195,9 @@ var gb_data_basic = (function () {
190 195 allPersonnel = data;
191 196 cb && cb();
192 197 });
  198 + },
  199 + nbbm2PlateMap: function () {
  200 + return nbbm2PlateMap;
193 201 }
194 202 };
195 203 })();
... ...
src/main/resources/static/real_control_v2/js/data/data_gps.js
1 1 /* gps 数据管理模块 */
2 2  
3   -var gb_data_gps = (function() {
  3 +var gb_data_gps = (function () {
4 4  
5 5 //fixed time refresh delay
6 6 var delay = 1000 * 7;
... ... @@ -9,15 +9,15 @@ var gb_data_gps = (function() {
9 9 //refresh after callback
10 10 var refreshEventCallbacks = [];
11 11 //register callback function
12   - var registerCallback = function(cb) {
  12 + var registerCallback = function (cb) {
13 13 if (cb)
14 14 refreshEventCallbacks.push(cb);
15 15 };
16 16  
17   - var refresh = function(cb) {
  17 + var refresh = function (cb) {
18 18 $.ajax({
19 19 url: '/gps/real/line',
20   - data:{lineCodes: gb_data_basic.line_idx},
  20 + data: {lineCodes: gb_data_basic.line_idx},
21 21 success: function (rs) {
22 22 refreshData(rs);
23 23 cb();
... ... @@ -29,16 +29,16 @@ var gb_data_gps = (function() {
29 29 });
30 30 };
31 31  
32   - var refreshData = function(rs) {
  32 + var refreshData = function (rs) {
33 33 var old, addArr = [],
34 34 upArr = [],
35 35 upDownChange = [];
36 36  
37 37 var schArray;
38   - $.each(rs, function() {
  38 + $.each(rs, function () {
39 39 old = realData[this.deviceId];
40 40 if (old) {
41   - if (this.timestamp > old.timestamp){
  41 + if (this.timestamp > old.timestamp) {
42 42 if (old.upDown != this.upDown)
43 43 upDownChange.push(this);
44 44 else
... ... @@ -49,9 +49,9 @@ var gb_data_gps = (function() {
49 49 addArr.push(this);
50 50  
51 51 //班次信息
52   - if(this.schId){
53   - schArray=gb_schedule_table.findScheduleByLine(this.lineId);
54   - if(schArray)
  52 + if (this.schId) {
  53 + schArray = gb_schedule_table.findScheduleByLine(this.lineId);
  54 + if (schArray)
55 55 this.sch = schArray[this.schId];
56 56 }
57 57  
... ... @@ -62,27 +62,27 @@ var gb_data_gps = (function() {
62 62  
63 63 //console.log('add array size: ' + addArr.length, 'up array size: ' + upArr.length);
64 64 //CCCallFuncN
65   - $.each(refreshEventCallbacks, function(i, cb) {
  65 + $.each(refreshEventCallbacks, function (i, cb) {
66 66 cb(addArr, upArr, upDownChange);
67 67 });
68 68  
69 69 };
70 70  
71 71 var startFixedTime;
72   - var fixedTimeRefresh = function() {
  72 + var fixedTimeRefresh = function () {
73 73 if (startFixedTime)
74 74 return;
75 75 startFixedTime = true;
76 76  
77   - (function() {
  77 + (function () {
78 78 var f = arguments.callee;
79   - refresh(function() {
  79 + refresh(function () {
80 80 setTimeout(f, delay);
81 81 });
82 82 })();
83 83 };
84 84  
85   - var gpsByLineCode = function(lineCode) {
  85 + var gpsByLineCode = function (lineCode) {
86 86 var rs = [];
87 87 for (var device in realData) {
88 88 if (realData[device].lineId == lineCode)
... ... @@ -91,20 +91,38 @@ var gb_data_gps = (function() {
91 91 return rs;
92 92 };
93 93  
94   - var findOne = function(deviceId){
  94 + var findOne = function (deviceId) {
95 95 return realData[deviceId];
96 96 };
97 97  
98   - var findGpsByNbbm = function(nbbm){
  98 + var findGpsByNbbm = function (nbbm) {
99 99 return realData[gb_data_basic.nbbm2deviceMap()[nbbm]];
100 100 };
101 101  
  102 + /**
  103 + * 设备掉线事件
  104 + */
  105 + var deviceOffline = function (gps) {
  106 + $.each(offlineCallbacks, function (i, cb) {
  107 + cb(gps);
  108 + });
  109 + };
  110 +
  111 + //注册掉线事件回调函数
  112 + var offlineCallbacks = [];
  113 + var registerOfflineCb = function (cb) {
  114 + if (cb)
  115 + offlineCallbacks.push(cb);
  116 + };
  117 +
102 118 return {
103 119 fixedTimeRefresh: fixedTimeRefresh,
104 120 registerCallback: registerCallback,
105 121 allGps: realData,
106 122 gpsByLineCode: gpsByLineCode,
107 123 findOne: findOne,
108   - findGpsByNbbm: findGpsByNbbm
  124 + findGpsByNbbm: findGpsByNbbm,
  125 + deviceOffline: deviceOffline,
  126 + registerOfflineCb: registerOfflineCb
109 127 };
110 128 })();
... ...
src/main/resources/static/real_control_v2/js/data/gps_abnormal.js
1 1 /** gps 信号异常状态,无效 | 越界 | 超速
2 2 *
3 3 *
4   - * 前端计算略微有点卡顿, 交由后端计算
  4 + * ########### 这个文件被废弃 ##############
  5 + *
  6 + * 前端计算略微有点卡顿, 交由后端计算
5 7 * */
6 8  
7 9 var gb_gps_abnormal = (function () {
... ...
src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
... ... @@ -13,6 +13,11 @@
13 13 "header": 1
14 14 },
15 15 {
  16 + "id": 1.2,
  17 + "text": "当日计划排班",
  18 + "event": "curr_date_schedule"
  19 + },
  20 + {
16 21 "id": 1.3,
17 22 "text": "缓存数据管理",
18 23 "event": "cache_data_manage"
... ...
src/main/resources/static/real_control_v2/js/home/line_panel.js
... ... @@ -79,6 +79,9 @@ var gb_home_line_panel = (function() {
79 79 };
80 80  
81 81 var updateRow = function(e, t) {
  82 + if(e.hasClass('offline'))
  83 + e.removeClass('offline');
  84 +
82 85 var cells = e.find('dd');
83 86 $(cells[1]).text(t.speed);
84 87 $(cells[2]).html(t.expectStopTime == null ? '' : t.expectStopTime);
... ... @@ -138,6 +141,18 @@ var gb_home_line_panel = (function() {
138 141 return rs;
139 142 }
140 143  
  144 + /**
  145 + * 设备掉线事件
  146 + */
  147 + gb_data_gps.registerOfflineCb(deviceOffline);
  148 +
  149 + function deviceOffline(gps) {
  150 + //模拟图掉线
  151 + gb_svg_chart.deviceOffline(gps);
  152 + //主页表格掉线
  153 + $('#home-main-content .data-body .home-gps-table dl#home_gps_'+gps.deviceId).addClass('offline');
  154 + }
  155 +
141 156 //文件载入完毕
142 157 res_load_ep.emitLater('load_home_line_panel');
143 158  
... ...
src/main/resources/static/real_control_v2/js/line_schedule/context_menu.js
... ... @@ -98,11 +98,19 @@ var gb_schedule_context_menu = (function () {
98 98 }, '确定下发指令');
99 99 },
100 100 jgtz: function (schArray) {
101   - var idArr = [];
  101 + //忽略进出场班次
  102 + schArray = schArray.filter(function (sch) {
  103 + return sch.bcType != 'in' && sch.bcType != 'out';
  104 + });
  105 +
  106 + var idArr = [], qdz = schArray[0].qdzCode;
102 107 $.each(schArray, function () {
103   - idArr.push(this.id);
  108 + if(this.qdzCode==qdz)
  109 + idArr.push(this.id);
104 110 });
105   - var elem = UIkit.modal.prompt('请输入间隔(分钟)', 0, function (newValue) {
  111 +
  112 + var ps = '<div class="ps-help-panel"><small>1、忽略进出场班次</small><small>2、与选中的第一个班次起点站不同的也将被忽略</small></div>';
  113 + var elem = UIkit.modal.prompt('请输入间隔(分钟)' + ps, 0, function (newValue) {
106 114 if (!isNaN(newValue) && newValue > 0) {
107 115 gb_common.$post_arr('/realSchedule/spaceAdjust', {ids: idArr, space: newValue}, function (rs) {
108 116 //刷新数据
... ...
src/main/resources/static/real_control_v2/js/utils/svg_chart.js
... ... @@ -244,7 +244,9 @@ var gb_svg_chart = (function () {
244 244 });
245 245 e.classed({'abnormal': function (d) {
246 246 return d.abnormalClaszz;
247   - }});
  247 + }, 'offline': function (d) {
  248 + return d['abnormalStatus']=='offline';
  249 + }});
248 250 //update tip position
249 251 gb_svg_tooltip.update(e);
250 252 },
... ... @@ -259,23 +261,28 @@ var gb_svg_chart = (function () {
259 261 var svgs = $('.line-chart[data-code=' + lineCode + ']'),
260 262 data = gb_data_gps.gpsByLineCode(lineCode);
261 263  
262   - var list = [], suffix;
  264 + var list = [], suffix, abmStatus;
263 265 //过滤无站点字段的数据
264 266 $.each(data, function () {
265 267 if (!this.stopNo || this.stopNo == '')
266 268 return true;
267 269  
268   - suffix = '';
269   - this['abnormalClaszz'] = true;
270   - if(this['abnormalStatus']=='outBounds'){
271   - suffix = '界';
272   - }
273   - else if(this['abnormalStatus']=='overspeed'){
274   - suffix = '速';
  270 + abmStatus = this['abnormalStatus'];
  271 + if(abmStatus != 'offline'){
  272 + suffix = '';
  273 + this['abnormalClaszz'] = true;
  274 + if(abmStatus=='outBounds')
  275 + suffix = '界';
  276 + else if(abmStatus=='overspeed')
  277 + suffix = '速';
  278 + else if(abmStatus=='gps-offline')
  279 + suffix = '掉';
  280 + else
  281 + this['abnormalClaszz'] = false;
275 282 }
276 283 else
277 284 this['abnormalClaszz'] = false;
278   -
  285 +
279 286 this.suffix = suffix;
280 287 list.push(this);
281 288 });
... ... @@ -350,8 +357,19 @@ var gb_svg_chart = (function () {
350 357 .attr('y', isDown ? y + 24 : y - 14);
351 358 };
352 359  
  360 +
  361 + /**
  362 + * 设备掉线
  363 + * @param gps
  364 + */
  365 + var deviceOffline = function (gps) {
  366 + $('svg text[_id=tx_'+gps.deviceId+']').addClass('offline');
  367 + $('svg rect[_id=tx_'+gps.deviceId+']').addClass('offline');
  368 + };
  369 +
353 370 return {
354 371 draw_line: draw_line,
355   - setGps: setGps
  372 + setGps: setGps,
  373 + deviceOffline: deviceOffline
356 374 };
357 375 })();
... ...
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
... ... @@ -149,7 +149,8 @@ var gb_sch_websocket = (function () {
149 149 refreshSch: refreshSch,
150 150 d80Confirm: d80Confirm,
151 151 directive: directiveStatus,
152   - signal_state: signalState
  152 + signal_state: signalState,
  153 + deviceOffline: deviceOffline
153 154 };
154 155  
155 156 function currentSecond() {
... ... @@ -241,6 +242,14 @@ var gb_sch_websocket = (function () {
241 242 setTimeout(f, 5000);
242 243 }();
243 244  
  245 + /**
  246 + * 设备掉线
  247 + * @param msg
  248 + */
  249 + function deviceOffline(msg) {
  250 + gb_data_gps.deviceOffline(msg.gps);
  251 + }
  252 +
244 253 return {
245 254 sock: schSock
246 255 };
... ...
src/main/resources/static/real_control_v2/mapmonitor/fragments/playback/run.html
... ... @@ -208,11 +208,13 @@
208 208 }
209 209  
210 210 var toCenterTimer;
211   -
  211 + var markerIsVisible;
212 212 function fixedToCenter() {
213 213 toCenterTimer = setInterval(function () {
214   - map.panTo(marker.getPosition());
215   - }, 4000);
  214 + var markerIsVisible = BMapLib.GeoUtils.isPointInRect(marker.point,map.getBounds());
  215 + if(!markerIsVisible)
  216 + map.panTo(marker.getPosition());
  217 + }, 400);
216 218 }
217 219  
218 220 //暂停
... ...