Commit da438d8a9f7f21d63bcd0972ef90531df773c146

Authored by 潘钊
1 parent b41e4c1a

update

Showing 25 changed files with 363 additions and 493 deletions
src/main/java/com/bsth/StartCommand.java
@@ -8,7 +8,6 @@ import com.bsth.util.DateUtils; @@ -8,7 +8,6 @@ import com.bsth.util.DateUtils;
8 import com.bsth.vehicle.common.CommonRefreshThread; 8 import com.bsth.vehicle.common.CommonRefreshThread;
9 import com.bsth.vehicle.directive.thread.DirectivePersistenceThread; 9 import com.bsth.vehicle.directive.thread.DirectivePersistenceThread;
10 import com.bsth.vehicle.directive.thread.FirstScheduleIssuedThread; 10 import com.bsth.vehicle.directive.thread.FirstScheduleIssuedThread;
11 -import com.bsth.vehicle.directive.thread.RevertLineThread;  
12 import com.bsth.vehicle.gpsdata.GpsArrivalStationThread; 11 import com.bsth.vehicle.gpsdata.GpsArrivalStationThread;
13 import com.bsth.vehicle.gpsdata.GpsRefreshThread; 12 import com.bsth.vehicle.gpsdata.GpsRefreshThread;
14 import org.slf4j.Logger; 13 import org.slf4j.Logger;
@@ -34,7 +33,7 @@ public class StartCommand implements CommandLineRunner{ @@ -34,7 +33,7 @@ public class StartCommand implements CommandLineRunner{
34 @Autowired 33 @Autowired
35 SecurityMetadataSourceService invocationSecurityMetadataSourceService; 34 SecurityMetadataSourceService invocationSecurityMetadataSourceService;
36 35
37 - public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(8); 36 + public static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(7);
38 37
39 @Autowired 38 @Autowired
40 GpsRefreshThread gpsRefreshThread; 39 GpsRefreshThread gpsRefreshThread;
@@ -50,8 +49,6 @@ public class StartCommand implements CommandLineRunner{ @@ -50,8 +49,6 @@ public class StartCommand implements CommandLineRunner{
50 GpsArrivalStationThread gpsArrivalStationThread; 49 GpsArrivalStationThread gpsArrivalStationThread;
51 @Autowired 50 @Autowired
52 FirstScheduleIssuedThread firstScheduleIssuedThread; 51 FirstScheduleIssuedThread firstScheduleIssuedThread;
53 - @Autowired  
54 - RevertLineThread revertLineThread;  
55 52
56 @Override 53 @Override
57 public void run(String... arg0){ 54 public void run(String... arg0){
@@ -105,11 +102,6 @@ public class StartCommand implements CommandLineRunner{ @@ -105,11 +102,6 @@ public class StartCommand implements CommandLineRunner{
105 */ 102 */
106 //scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS); 103 //scheduler.scheduleWithFixedDelay(firstScheduleIssuedThread, 60 , 60 * 2, TimeUnit.SECONDS);
107 104
108 - /**  
109 - * 还车线程(2分钟运行一次)  
110 - * 将借出的车刷回原线路  
111 - */  
112 - scheduler.scheduleWithFixedDelay(revertLineThread, 60 , 60 * 2 , TimeUnit.SECONDS);  
113 } catch (Exception e) { 105 } catch (Exception e) {
114 e.printStackTrace(); 106 e.printStackTrace();
115 } 107 }
src/main/java/com/bsth/controller/realcontrol/DeviceRevertLineController.java deleted 100644 → 0
1 -package com.bsth.controller.realcontrol;  
2 -  
3 -import org.springframework.web.bind.annotation.RequestMapping;  
4 -import org.springframework.web.bind.annotation.RestController;  
5 -  
6 -import com.bsth.controller.BaseController;  
7 -import com.bsth.entity.realcontrol.DeviceRevertLine;  
8 -  
9 -@RestController  
10 -@RequestMapping("/deviceRevert")  
11 -public class DeviceRevertLineController extends BaseController<DeviceRevertLine, Integer>{  
12 -  
13 -}  
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -56,8 +56,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -56,8 +56,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
56 */ 56 */
57 @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST) 57 @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST)
58 public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks, 58 public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks,
59 - @RequestParam String dfsj) {  
60 - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj); 59 + @RequestParam String dfsj, String clZbh, String jsy, String spy) {
  60 + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, clZbh, jsy, spy);
61 } 61 }
62 62
63 /** 63 /**
@@ -127,9 +127,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -127,9 +127,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
127 * 售票员 @throws 127 * 售票员 @throws
128 */ 128 */
129 @RequestMapping(value = "/adjust", method = RequestMethod.POST) 129 @RequestMapping(value = "/adjust", method = RequestMethod.POST)
130 - public Map<String, Object> adjust(@RequestParam Long id, @RequestParam String nbbm, @RequestParam String jsy,  
131 - @RequestParam String spy) {  
132 - return scheduleRealInfoService.adjust(id, nbbm, jsy, spy); 130 + public Map<String, Object> adjust(@RequestParam Long id, String nbbm, String jsy,
  131 + String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
  132 + return scheduleRealInfoService.adjust(id, nbbm, jsy, spy, revertLine, borrowLine, borrowTimeStr, revertTimeStr);
133 } 133 }
134 134
135 /** 135 /**
src/main/java/com/bsth/entity/realcontrol/DeviceRevertLine.java deleted 100644 → 0
1 -package com.bsth.entity.realcontrol;  
2 -  
3 -import java.util.Date;  
4 -  
5 -import javax.persistence.Column;  
6 -import javax.persistence.Entity;  
7 -import javax.persistence.GeneratedValue;  
8 -import javax.persistence.Id;  
9 -import javax.persistence.Table;  
10 -  
11 -/**  
12 - *  
13 - * @ClassName: VehicleRevertLine  
14 - * @Description: TODO(设备线路还原)  
15 - * @author PanZhao  
16 - * @date 2016年7月6日 下午5:31:13  
17 - *  
18 - */  
19 -@Entity  
20 -@Table(name = "bsth_v_line_revert")  
21 -public class DeviceRevertLine {  
22 -  
23 - @Id  
24 - @GeneratedValue  
25 - private Integer id;  
26 -  
27 - /**  
28 - * 车辆内部编码  
29 - */  
30 - private String nbbm;  
31 -  
32 - /**  
33 - * 出借时间  
34 - */  
35 - private Long borrowTime;  
36 -  
37 - private String borrowTimeStr;  
38 -  
39 - /**  
40 - * 出借线路  
41 - */  
42 - private String borrowLine;  
43 -  
44 - /**  
45 - * 归还时间  
46 - */  
47 - private Long revertTime;  
48 -  
49 - private String revertTimeStr;  
50 -  
51 - /**  
52 - * 归还线路  
53 - */  
54 - private String revertLine;  
55 -  
56 - /** 创建日期 */  
57 - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")  
58 - private Date createDate;  
59 -  
60 - /** 状态 1 已还车 */  
61 - private Integer status;  
62 -  
63 - public Integer getId() {  
64 - return id;  
65 - }  
66 -  
67 - public void setId(Integer id) {  
68 - this.id = id;  
69 - }  
70 -  
71 - public String getNbbm() {  
72 - return nbbm;  
73 - }  
74 -  
75 - public void setNbbm(String nbbm) {  
76 - this.nbbm = nbbm;  
77 - }  
78 -  
79 - public String getBorrowLine() {  
80 - return borrowLine;  
81 - }  
82 -  
83 - public void setBorrowLine(String borrowLine) {  
84 - this.borrowLine = borrowLine;  
85 - }  
86 -  
87 - public String getRevertLine() {  
88 - return revertLine;  
89 - }  
90 -  
91 - public void setRevertLine(String revertLine) {  
92 - this.revertLine = revertLine;  
93 - }  
94 -  
95 - public Long getBorrowTime() {  
96 - return borrowTime;  
97 - }  
98 -  
99 - public void setBorrowTime(Long borrowTime) {  
100 - this.borrowTime = borrowTime;  
101 - }  
102 -  
103 - public String getBorrowTimeStr() {  
104 - return borrowTimeStr;  
105 - }  
106 -  
107 - public void setBorrowTimeStr(String borrowTimeStr) {  
108 - this.borrowTimeStr = borrowTimeStr;  
109 - }  
110 -  
111 - public Long getRevertTime() {  
112 - return revertTime;  
113 - }  
114 -  
115 - public void setRevertTime(Long revertTime) {  
116 - this.revertTime = revertTime;  
117 - }  
118 -  
119 - public String getRevertTimeStr() {  
120 - return revertTimeStr;  
121 - }  
122 -  
123 - public void setRevertTimeStr(String revertTimeStr) {  
124 - this.revertTimeStr = revertTimeStr;  
125 - }  
126 -  
127 - public Date getCreateDate() {  
128 - return createDate;  
129 - }  
130 -  
131 - public void setCreateDate(Date createDate) {  
132 - this.createDate = createDate;  
133 - }  
134 -  
135 - public Integer getStatus() {  
136 - return status;  
137 - }  
138 -  
139 - public void setStatus(Integer status) {  
140 - this.status = status;  
141 - }  
142 -}  
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -151,8 +151,8 @@ public class ScheduleRealInfo { @@ -151,8 +151,8 @@ public class ScheduleRealInfo {
151 151
152 public void addRemarks(String remark){ 152 public void addRemarks(String remark){
153 String newRem = this.getRemarks(); 153 String newRem = this.getRemarks();
154 - if(null == newRem)  
155 - newRem = ""; 154 + if(null == newRem || newRem.trim() == "")
  155 + return;
156 newRem += remark + ";"; 156 newRem += remark + ";";
157 this.setRemarks(newRem); 157 this.setRemarks(newRem);
158 } 158 }
@@ -587,6 +587,28 @@ public class ScheduleRealInfo { @@ -587,6 +587,28 @@ public class ScheduleRealInfo {
587 /** 587 /**
588 * 588 *
589 * @Title: setFcsjActualAll 589 * @Title: setFcsjActualAll
  590 + * @Description: TODO(设置实际发车时间)
  591 + * @throws
  592 + */
  593 + public void setFcsjActualAll(Long t){
  594 + this.fcsjActualTime = t;
  595 + this.fcsjActual = sdfHHmm.format(new Date(t));
  596 + }
  597 +
  598 + /**
  599 + *
  600 + * @Title: setFcsjActualAll
  601 + * @Description: TODO(设置实际终点时间)
  602 + * @throws
  603 + */
  604 + public void setZdsjActualAll(Long t){
  605 + this.zdsjActualTime = t;
  606 + this.zdsjActual = sdfHHmm.format(new Date(t));
  607 + }
  608 +
  609 + /**
  610 + *
  611 + * @Title: setFcsjActualAll
590 * @Description: TODO(设置实际终点时间) 612 * @Description: TODO(设置实际终点时间)
591 * @throws 613 * @throws
592 */ 614 */
src/main/java/com/bsth/repository/realcontrol/DeviceRevertLineRepository.java deleted 100644 → 0
1 -package com.bsth.repository.realcontrol;  
2 -  
3 -import java.util.List;  
4 -  
5 -import org.springframework.data.jpa.repository.Query;  
6 -import org.springframework.stereotype.Repository;  
7 -  
8 -import com.bsth.entity.realcontrol.DeviceRevertLine;  
9 -import com.bsth.repository.BaseRepository;  
10 -  
11 -@Repository  
12 -public interface DeviceRevertLineRepository extends BaseRepository<DeviceRevertLine, Integer>{  
13 -  
14 - @Query(value = "select dr from DeviceRevertLine dr where dr.revertTime > ?1 and dr.revertTime < ?2 and dr.status = ?3")  
15 - public List<DeviceRevertLine> findByDateAndStatus(Long st, Long et, Integer status);  
16 -}  
src/main/java/com/bsth/service/realcontrol/DeviceRevertLineService.java deleted 100644 → 0
1 -package com.bsth.service.realcontrol;  
2 -  
3 -import com.bsth.entity.realcontrol.DeviceRevertLine;  
4 -import com.bsth.service.BaseService;  
5 -  
6 -public interface DeviceRevertLineService extends BaseService<DeviceRevertLine, Integer>{  
7 -  
8 -}  
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -14,7 +14,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -14,7 +14,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
14 14
15 Map<String, Collection<ScheduleRealInfo>> findByLines(String lines); 15 Map<String, Collection<ScheduleRealInfo>> findByLines(String lines);
16 16
17 - Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj); 17 + Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj,String nbbm,String jsy,String spy);
18 18
19 Map<String, Object> destroy(String idsStr, int spaceAdjust, String remarks, String reason, int spaceNum); 19 Map<String, Object> destroy(String idsStr, int spaceAdjust, String remarks, String reason, int spaceNum);
20 20
@@ -26,7 +26,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -26,7 +26,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
26 26
27 List<Map<String, String>> sreachVehic(String nbbm); 27 List<Map<String, String>> sreachVehic(String nbbm);
28 28
29 - Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy); 29 + Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr);
30 30
31 /** 31 /**
32 * 32 *
src/main/java/com/bsth/service/realcontrol/buffer/GetSchedulePlanThread.java
@@ -48,13 +48,16 @@ public class GetSchedulePlanThread extends Thread{ @@ -48,13 +48,16 @@ public class GetSchedulePlanThread extends Thread{
48 ScheduleBuffer.clear(); 48 ScheduleBuffer.clear();
49 49
50 List<ScheduleRealInfo> realList = null; 50 List<ScheduleRealInfo> realList = null;
51 - String dateStr = sdfyyyyMMdd.format(new Date()); 51 + String dateStr = /*sdfyyyyMMdd.format(new Date())*/"2016-06-01";
52 Date cDate = sdfyyyyMMdd.parse(dateStr); 52 Date cDate = sdfyyyyMMdd.parse(dateStr);
53 //查询数据库是否有今日排班 53 //查询数据库是否有今日排班
54 int size = scheduleRealInfoRepository.countByDate(cDate); 54 int size = scheduleRealInfoRepository.countByDate(cDate);
55 if(size > 0){ 55 if(size > 0){
56 //从数据库恢复当日排班 56 //从数据库恢复当日排班
57 realList = scheduleRealInfoRepository.findByDate(cDate); 57 realList = scheduleRealInfoRepository.findByDate(cDate);
  58 + logger.info("从数据库恢复当日排班 " + realList.size());
  59 + //写入缓存
  60 + ScheduleBuffer.init(realList);
58 } 61 }
59 else{ 62 else{
60 List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(cDate); 63 List<SchedulePlanInfo> list = schedulePlanInfoRepository.findByDate(cDate);
@@ -75,13 +78,12 @@ public class GetSchedulePlanThread extends Thread{ @@ -75,13 +78,12 @@ public class GetSchedulePlanThread extends Thread{
75 item.setSpId(item.getId()); 78 item.setSpId(item.getId());
76 item.setId(id ++);//设置ID 79 item.setId(id ++);//设置ID
77 } 80 }
  81 +
  82 + //写入缓存
  83 + ScheduleBuffer.init(realList);
78 //入库 84 //入库
79 new BatchSaveUtils<ScheduleRealInfo>().saveList(realList, ScheduleRealInfo.class); 85 new BatchSaveUtils<ScheduleRealInfo>().saveList(realList, ScheduleRealInfo.class);
80 } 86 }
81 -  
82 - //写入缓存  
83 - ScheduleBuffer.init(realList);  
84 -  
85 logger.info("获取当天实际排班计划数量:" + realList.size()); 87 logger.info("获取当天实际排班计划数量:" + realList.size());
86 }catch(Exception e){ 88 }catch(Exception e){
87 logger.error("",e); 89 logger.error("",e);
src/main/java/com/bsth/service/realcontrol/buffer/ScheduleBuffer.java
@@ -108,7 +108,7 @@ public class ScheduleBuffer { @@ -108,7 +108,7 @@ public class ScheduleBuffer {
108 calcArrDateQd(code); 108 calcArrDateQd(code);
109 109
110 //计算班次平均间隔 110 //计算班次平均间隔
111 - //calcAvgSpace(); 111 + calcAvgSpace();
112 }catch(Exception e){ 112 }catch(Exception e){
113 logger.error("缓存排班数据失败...", e); 113 logger.error("缓存排班数据失败...", e);
114 return -1; 114 return -1;
@@ -148,7 +148,6 @@ public class ScheduleBuffer { @@ -148,7 +148,6 @@ public class ScheduleBuffer {
148 schSpaceMap.put(lineCode + "_0", sumUp / upList.size()); 148 schSpaceMap.put(lineCode + "_0", sumUp / upList.size());
149 schSpaceMap.put(lineCode + "_1", sumDown / downList.size()); 149 schSpaceMap.put(lineCode + "_1", sumDown / downList.size());
150 } 150 }
151 - System.out.println(schSpaceMap);  
152 } 151 }
153 152
154 public static int put(ScheduleRealInfo sch){ 153 public static int put(ScheduleRealInfo sch){
@@ -161,7 +160,10 @@ public class ScheduleBuffer { @@ -161,7 +160,10 @@ public class ScheduleBuffer {
161 vehLinkedMap.get(zbh).add(sch); 160 vehLinkedMap.get(zbh).add(sch);
162 161
163 //重新排序 162 //重新排序
164 - Collections.sort(vehLinkedMap.get(zbh), scheduleComparator); 163 + //Collections.sort(vehLinkedMap.get(zbh), scheduleComparator);
  164 +
  165 + //重新计算应到时间
  166 + calcArrDateQd(vehLinkedMap.get(zbh));
165 return 0; 167 return 0;
166 } 168 }
167 169
@@ -213,6 +215,23 @@ public class ScheduleBuffer { @@ -213,6 +215,23 @@ public class ScheduleBuffer {
213 return finishLinkedMap.get(nbbm) == null ? 0 : finishLinkedMap.get(nbbm).size(); 215 return finishLinkedMap.get(nbbm) == null ? 0 : finishLinkedMap.get(nbbm).size();
214 } 216 }
215 217
  218 + public static void calcArrDateQd(List<ScheduleRealInfo> list){
  219 + //排序
  220 + Collections.sort(list, scheduleComparator);
  221 + int len = list.size();
  222 + if(len == 0)
  223 + return;
  224 +
  225 + ScheduleRealInfo prve = list.get(0), curr;
  226 + for(int i = 1; i < len; i ++){
  227 + curr = list.get(i);
  228 + if(prve.getZdzName().equals(curr.getQdzName()))
  229 + curr.setQdzArrDateJH(prve.getZdsj());
  230 +
  231 + prve = curr;
  232 + }
  233 + }
  234 +
216 /** 235 /**
217 * 236 *
218 * @Title: calcArrDateQd 237 * @Title: calcArrDateQd
@@ -229,25 +248,8 @@ public class ScheduleBuffer { @@ -229,25 +248,8 @@ public class ScheduleBuffer {
229 248
230 //链接班次 249 //链接班次
231 Set<String> set = map.keySet(); 250 Set<String> set = map.keySet();
232 - List<ScheduleRealInfo> subList;  
233 - int len;  
234 - ScheduleRealInfo prve, curr;  
235 for(String k : set){ 251 for(String k : set){
236 - subList = map.get(k);  
237 - //排序  
238 - Collections.sort(subList, scheduleComparator);  
239 - len = subList.size();  
240 - if(len == 0)  
241 - continue;  
242 -  
243 - prve = subList.get(0);  
244 - for(int i = 1; i < len; i ++){  
245 - curr = subList.get(i);  
246 - if(prve.getZdzName().equals(curr.getQdzName()))  
247 - curr.setQdzArrDateJH(prve.getZdsj());  
248 -  
249 - prve = curr;  
250 - } 252 + calcArrDateQd(map.get(k));
251 } 253 }
252 } 254 }
253 255
src/main/java/com/bsth/service/realcontrol/impl/DeviceRevertLineServiceImpl.java deleted 100644 → 0
1 -package com.bsth.service.realcontrol.impl;  
2 -  
3 -import java.text.ParseException;  
4 -import java.text.SimpleDateFormat;  
5 -import java.util.Date;  
6 -import java.util.Map;  
7 -  
8 -import org.slf4j.Logger;  
9 -import org.slf4j.LoggerFactory;  
10 -import org.springframework.stereotype.Service;  
11 -  
12 -import com.bsth.entity.realcontrol.DeviceRevertLine;  
13 -import com.bsth.service.impl.BaseServiceImpl;  
14 -import com.bsth.service.realcontrol.DeviceRevertLineService;  
15 -  
16 -@Service  
17 -public class DeviceRevertLineServiceImpl extends BaseServiceImpl<DeviceRevertLine, Integer> implements DeviceRevertLineService {  
18 -  
19 - Logger logger = LoggerFactory.getLogger(this.getClass());  
20 -  
21 - SimpleDateFormat sdfHHmm = new SimpleDateFormat("HH:mm")  
22 - ,sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd")  
23 - ,sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
24 -  
25 - @Override  
26 - public Map<String, Object> save(DeviceRevertLine t) {  
27 -  
28 - String dateStr = sdfyyyyMMdd.format(new Date());  
29 -  
30 - try {  
31 - t.setStatus(0);  
32 - t.setBorrowTime(sdfyyyyMMddHHmm.parse(dateStr + " " + t.getBorrowTimeStr()).getTime());  
33 - t.setRevertTime(sdfyyyyMMddHHmm.parse(dateStr + " " + t.getRevertTimeStr()).getTime());  
34 - } catch (ParseException e) {  
35 - logger.error("", e);  
36 - }  
37 - return super.save(t);  
38 - }  
39 -}  
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
1 package com.bsth.service.realcontrol.impl; 1 package com.bsth.service.realcontrol.impl;
2 2
3 import java.io.File; 3 import java.io.File;
  4 +import java.text.ParseException;
4 import java.text.SimpleDateFormat; 5 import java.text.SimpleDateFormat;
5 import java.util.ArrayList; 6 import java.util.ArrayList;
6 import java.util.Collection; 7 import java.util.Collection;
@@ -34,6 +35,7 @@ import com.bsth.service.impl.BaseServiceImpl; @@ -34,6 +35,7 @@ import com.bsth.service.impl.BaseServiceImpl;
34 import com.bsth.service.realcontrol.ScheduleRealInfoService; 35 import com.bsth.service.realcontrol.ScheduleRealInfoService;
35 import com.bsth.service.realcontrol.buffer.ScheduleBuffer; 36 import com.bsth.service.realcontrol.buffer.ScheduleBuffer;
36 import com.bsth.util.ReportUtils; 37 import com.bsth.util.ReportUtils;
  38 +import com.bsth.vehicle.BorrowCenter;
37 import com.bsth.vehicle.common.CommonMapped; 39 import com.bsth.vehicle.common.CommonMapped;
38 import com.google.common.base.Splitter; 40 import com.google.common.base.Splitter;
39 import com.google.common.collect.ArrayListMultimap; 41 import com.google.common.collect.ArrayListMultimap;
@@ -52,6 +54,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -52,6 +54,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
52 54
53 @Autowired 55 @Autowired
54 CarConfigInfoRepository carConfigInfoRepository; 56 CarConfigInfoRepository carConfigInfoRepository;
  57 +
  58 + @Autowired
  59 + BorrowCenter borrowCenter;
55 60
56 Logger logger = LoggerFactory.getLogger(this.getClass()); 61 Logger logger = LoggerFactory.getLogger(this.getClass());
57 62
@@ -71,7 +76,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -71,7 +76,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
71 } 76 }
72 77
73 @Override 78 @Override
74 - public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj) { 79 + public Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String nbbm,String jsy,String spy) {
75 Map<String, Object> map = new HashMap<>(); 80 Map<String, Object> map = new HashMap<>();
76 try { 81 try {
77 82
@@ -79,12 +84,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -79,12 +84,24 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
79 schedule.setDfsjT(sdfMinute.parse(sdfMonth.format(new Date()) + " " + dfsj).getTime()); 84 schedule.setDfsjT(sdfMinute.parse(sdfMonth.format(new Date()) + " " + dfsj).getTime());
80 schedule.setDfsj(dfsj); 85 schedule.setDfsj(dfsj);
81 schedule.addRemarks(remarks + ";"); 86 schedule.addRemarks(remarks + ";");
  87 + schedule.setClZbh(nbbm);
  88 + if(jsy != null && jsy.indexOf("/") != -1){
  89 + String[] jsyArray = jsy.split("/");
  90 + schedule.setjGh(jsyArray[0]);
  91 + schedule.setjName(jsyArray[1]);
  92 + }
  93 +
  94 + if(spy != null && spy.indexOf("/") != -1){
  95 + String[] spyArray = spy.split("/");
  96 + schedule.setsGh(spyArray[0]);
  97 + schedule.setsName(spyArray[1]);
  98 + }
  99 +
82 // 持久化到数据库 100 // 持久化到数据库
83 ScheduleBuffer.persistentList.add(schedule); 101 ScheduleBuffer.persistentList.add(schedule);
84 102
85 map.put("status", ResponseCode.SUCCESS); 103 map.put("status", ResponseCode.SUCCESS);
86 - map.put("dfsj", dfsj);  
87 - map.put("remarks", schedule.getRemarks()); 104 + map.put("t", schedule);
88 } catch (Exception e) { 105 } catch (Exception e) {
89 logger.error("", e); 106 logger.error("", e);
90 map.put("status", ResponseCode.ERROR); 107 map.put("status", ResponseCode.ERROR);
@@ -246,6 +263,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -246,6 +263,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
246 263
247 // 加入缓存 264 // 加入缓存
248 ScheduleBuffer.put(t); 265 ScheduleBuffer.put(t);
  266 + //将该临加之后的班次作为更新返回页面
  267 + List<ScheduleRealInfo> list = ScheduleBuffer.vehLinkedMap.get(t.getClZbh())
  268 + ,rsList = null;
  269 +
  270 + for(ScheduleRealInfo sch : list){
  271 + if(sch.getId() == t.getId())
  272 + rsList = new ArrayList<>();
  273 +
  274 + if(rsList != null)
  275 + rsList.add(sch);
  276 + }
  277 +
  278 + map.put("ups", rsList);
249 return map; 279 return map;
250 } 280 }
251 281
@@ -281,10 +311,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -281,10 +311,11 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
281 } 311 }
282 312
283 @Override 313 @Override
284 - public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy) { 314 + public Map<String, Object> adjust(Long id, String nbbm, String jsy, String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) {
285 // 班次 315 // 班次
286 ScheduleRealInfo schedule = ScheduleBuffer.pkSchedulMap.get(id); 316 ScheduleRealInfo schedule = ScheduleBuffer.pkSchedulMap.get(id);
287 317
  318 + String rq = sdfMonth.format(new Date());
288 // 换车 319 // 换车
289 if (!StringUtils.isBlank(nbbm)) { 320 if (!StringUtils.isBlank(nbbm)) {
290 adjustCar(schedule, nbbm); 321 adjustCar(schedule, nbbm);
@@ -302,6 +333,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -302,6 +333,26 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
302 tempArray = Splitter.on("/").splitToList(spy); 333 tempArray = Splitter.on("/").splitToList(spy);
303 adjustConductor(schedule, tempArray.get(0), tempArray.get(1)); 334 adjustConductor(schedule, tempArray.get(0), tempArray.get(1));
304 } 335 }
  336 +
  337 + if(borrowLine != null && borrowTimeStr != null){
  338 + try {
  339 + //跨线路借车
  340 + Long t = sdfMinute.parse(rq + " " + borrowTimeStr).getTime();
  341 + borrowCenter.put(nbbm, borrowLine, 0, t);
  342 + } catch (ParseException e) {
  343 + e.printStackTrace();
  344 + }
  345 + }
  346 +
  347 + if(revertLine != null && revertTimeStr != null){
  348 + //定时还车
  349 + try {
  350 + Long t = sdfMinute.parse(rq + " " + revertTimeStr).getTime();
  351 + borrowCenter.put(nbbm, revertLine, 1, t);
  352 + } catch (ParseException e) {
  353 + e.printStackTrace();
  354 + }
  355 + }
305 356
306 ScheduleBuffer.persistentList.add(schedule); 357 ScheduleBuffer.persistentList.add(schedule);
307 358
@@ -394,7 +445,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -394,7 +445,10 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
394 sch.setFcsjActualTime(sdfMinute.parse(rq + " " + fcsjActual).getTime()); 445 sch.setFcsjActualTime(sdfMinute.parse(rq + " " + fcsjActual).getTime());
395 sch.setFcsjActual(fcsjActual); 446 sch.setFcsjActual(fcsjActual);
396 sch.addRemarks(remarks); 447 sch.addRemarks(remarks);
397 - 448 + //改变状态
  449 + if(sch.getZdsjActual() == null)
  450 + sch.setStatus(1);
  451 +
398 ScheduleBuffer.persistentList.add(sch); 452 ScheduleBuffer.persistentList.add(sch);
399 rs.put("status", ResponseCode.SUCCESS); 453 rs.put("status", ResponseCode.SUCCESS);
400 rs.put("t", sch); 454 rs.put("t", sch);
@@ -524,8 +578,20 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -524,8 +578,20 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
524 sch.setBcType(bcType); 578 sch.setBcType(bcType);
525 sch.setClZbh(clZbh); 579 sch.setClZbh(clZbh);
526 sch.setFcsjAll(fcsj); 580 sch.setFcsjAll(fcsj);
527 - sch.setFcsjActualAll(fcsjActual);  
528 - sch.setZdsjActualAll(zdsjActual); 581 + if(null == fcsjActual){
  582 + sch.setFcsjActual(null);
  583 + sch.setFcsjActualTime(null);
  584 + }
  585 + else
  586 + sch.setFcsjActualAll(fcsjActual);
  587 +
  588 + if(null == zdsjActual){
  589 + sch.setZdsjActual(null);
  590 + sch.setZdsjActualTime(null);
  591 + }
  592 + else
  593 + sch.setZdsjActualAll(zdsjActual);
  594 +
529 sch.setjGh(jsy[0]); 595 sch.setjGh(jsy[0]);
530 sch.setjName(jsy[1]); 596 sch.setjName(jsy[1]);
531 sch.setsGh(spy[0]); 597 sch.setsGh(spy[0]);
src/main/java/com/bsth/vehicle/BorrowCenter.java 0 → 100644
  1 +package com.bsth.vehicle;
  2 +
  3 +import java.util.concurrent.Executors;
  4 +import java.util.concurrent.ScheduledExecutorService;
  5 +import java.util.concurrent.TimeUnit;
  6 +
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Component;
  11 +
  12 +import com.bsth.vehicle.directive.service.DirectiveService;
  13 +
  14 +/**
  15 + *
  16 + * @ClassName: BorrowCenter
  17 + * @Description: TODO(借还车中心^_^)
  18 + * @author PanZhao
  19 + * @date 2016年7月12日 下午11:49:36
  20 + *
  21 + */
  22 +@Component
  23 +public class BorrowCenter {
  24 +
  25 + ScheduledExecutorService scheduler;
  26 +
  27 + @Autowired
  28 + DirectiveService directiveService;
  29 +
  30 + Logger logger = LoggerFactory.getLogger(BorrowCenter.class);
  31 +
  32 + /**
  33 + * 构造函数
  34 + */
  35 + public BorrowCenter() {
  36 + scheduler = Executors.newScheduledThreadPool(15);
  37 + }
  38 +
  39 + /**
  40 + *
  41 + * @Title: put
  42 + * @param @param nbbm 车辆
  43 + * @param @param lineCode 线路代码
  44 + * @param @param type 0 借出,1归还
  45 + * @param @param time 时间
  46 + * @throws
  47 + */
  48 + public void put(String nbbm, Integer lineCode, int type, Long time){
  49 + Long t = System.currentTimeMillis();
  50 + if(t >= time){
  51 + //立即执行
  52 + new Thread(new ChangeThread(nbbm, lineCode, type)).start();
  53 + }
  54 + else{
  55 + //定时线程
  56 + scheduler.schedule(new ChangeThread(nbbm, lineCode, type), (time - t) / 1000, TimeUnit.SECONDS);
  57 + }
  58 + }
  59 +
  60 + public class ChangeThread implements Runnable{
  61 + String nbbm;
  62 + Integer lineCode;
  63 + int type;
  64 +
  65 + public ChangeThread(String nbbm, Integer lineCode, int type) {
  66 + this.nbbm = nbbm;
  67 + this.lineCode = lineCode;
  68 + this.type = type;
  69 + }
  70 +
  71 + @Override
  72 + public void run() {
  73 + logger.info("nbbm " + (type==0?"借出":"归还") + "线路代码 " + lineCode);
  74 + directiveService.lineChange(nbbm, lineCode);
  75 + }
  76 + }
  77 +}
src/main/java/com/bsth/vehicle/directive/thread/RevertLineThread.java deleted 100644 → 0
1 -package com.bsth.vehicle.directive.thread;  
2 -  
3 -import java.util.List;  
4 -  
5 -import org.springframework.beans.factory.annotation.Autowired;  
6 -import org.springframework.stereotype.Component;  
7 -  
8 -import com.bsth.entity.realcontrol.DeviceRevertLine;  
9 -import com.bsth.repository.realcontrol.DeviceRevertLineRepository;  
10 -import com.bsth.vehicle.directive.service.DirectiveService;  
11 -  
12 -/**  
13 - *  
14 - * @ClassName: DeviceRevertLineThread  
15 - * @Description: TODO(设备线路还原线程, 将借出的车还原到原线路)  
16 - * @author PanZhao  
17 - * @date 2016年7月7日 上午11:30:38  
18 - *  
19 - */  
20 -@Component  
21 -public class RevertLineThread extends Thread{  
22 -  
23 - @Autowired  
24 - DeviceRevertLineRepository deviceRevertLineRepository;  
25 -  
26 - @Autowired  
27 - DirectiveService directiveService;  
28 -  
29 - @Override  
30 - public void run() {  
31 - Long et = System.currentTimeMillis()  
32 - ,st = et - (1000 * 60 * 5);  
33 -  
34 - List<DeviceRevertLine> list = deviceRevertLineRepository.findByDateAndStatus(st, et, 0);  
35 -  
36 - if(list.size() == 0)  
37 - return;  
38 -  
39 - int code;  
40 - for(DeviceRevertLine revertLine : list){  
41 - //还车  
42 - code = directiveService.lineChange(revertLine.getNbbm(), Integer.parseInt(revertLine.getRevertLine()));  
43 -  
44 - if(code == 0){  
45 - //改变状态  
46 - revertLine.setStatus(1);  
47 - deviceRevertLineRepository.save(revertLine);  
48 - }  
49 - }  
50 - }  
51 -}  
src/main/java/com/bsth/vehicle/gpsdata/GpsArrivalStationThread.java
@@ -9,7 +9,6 @@ import java.util.ArrayList; @@ -9,7 +9,6 @@ import java.util.ArrayList;
9 import java.util.Calendar; 9 import java.util.Calendar;
10 import java.util.Date; 10 import java.util.Date;
11 import java.util.HashSet; 11 import java.util.HashSet;
12 -import java.util.Iterator;  
13 import java.util.LinkedList; 12 import java.util.LinkedList;
14 import java.util.List; 13 import java.util.List;
15 import java.util.Set; 14 import java.util.Set;
@@ -50,7 +49,7 @@ public class GpsArrivalStationThread extends Thread{ @@ -50,7 +49,7 @@ public class GpsArrivalStationThread extends Thread{
50 @Autowired 49 @Autowired
51 RealControlSocketHandler socketHandler; 50 RealControlSocketHandler socketHandler;
52 51
53 - private static int diff = 1000 * 60 * 20; 52 + Long diff = 1000 * 60 * 20L;
54 53
55 @Override 54 @Override
56 public void run() { 55 public void run() {
@@ -70,8 +69,7 @@ public class GpsArrivalStationThread extends Thread{ @@ -70,8 +69,7 @@ public class GpsArrivalStationThread extends Thread{
70 69
71 List<ArrivalInfo> rsList = null; 70 List<ArrivalInfo> rsList = null;
72 LinkedList<ScheduleRealInfo> linked = null; 71 LinkedList<ScheduleRealInfo> linked = null;
73 - int[] status;  
74 - ScheduleRealInfo sch; 72 + ArrivalInfo[] status;
75 for(String nbbm : set){ 73 for(String nbbm : set){
76 rsList = GpsArrivalDataBuffer.pops(nbbm); 74 rsList = GpsArrivalDataBuffer.pops(nbbm);
77 //和该车辆未执行班次进行匹配 75 //和该车辆未执行班次进行匹配
@@ -79,28 +77,43 @@ public class GpsArrivalStationThread extends Thread{ @@ -79,28 +77,43 @@ public class GpsArrivalStationThread extends Thread{
79 77
80 if(null == linked || linked.size() == 0) 78 if(null == linked || linked.size() == 0)
81 continue; 79 continue;
82 - //第一个未执行班次  
83 - sch = linked.getFirst();  
84 80
85 - //匹配结果  
86 - status = match(rsList, sch);  
87 - }  
88 - //  
89 - /*GpsArrivalDataBuffer.putAll(list);  
90 - //实际到离站和计划排班相匹配  
91 -  
92 - Set<String> keySet = GpsArrivalDataBuffer.allMap.keySet();  
93 - System.out.println("开始...");  
94 - List<ScheduleRealInfo> schList;  
95 - for(String key : keySet){  
96 - schList = extractSched(ScheduleBuffer.vehLinkedMap.get(key));  
97 - if(null != schList)  
98 - match(GpsArrivalDataBuffer.allMap.get(key), schList); 81 + try{
  82 + for(ScheduleRealInfo schedule : linked){
  83 + //匹配结果
  84 + status = match(rsList, schedule);
  85 +
  86 + //发车
  87 + if(status[0] != null){
  88 + //班次状态改为正在执行
  89 + schedule.setStatus(1);
  90 + ScheduleBuffer.persistentList.add(schedule);
  91 + //推送到页面
  92 + sendFcsj(schedule);
  93 +
  94 + rsList.remove(status[0]);
  95 + }
  96 +
  97 + //到达终点
  98 + if(status[1] != null){
  99 + //完成当前班次
  100 + ScheduleRealInfo nextSch = ScheduleBuffer.finishSch(schedule);
  101 + //到达终点,发送下一班次的调度指令
  102 + int finish = ScheduleBuffer.getFinishSchNo(nextSch.getClZbh());
  103 + directiveService.send60Dispatch(nextSch, finish);
  104 + //推送到页面
  105 + sendZdsj(schedule, nextSch, finish);
  106 +
  107 + rsList.remove(status[1]);
  108 + }
  109 + }
  110 + }catch(Exception e){
  111 + e.printStackTrace();
  112 + }
99 } 113 }
100 - System.out.println("结束...");*/  
101 } 114 }
102 115
103 - public int[] match(List<ArrivalInfo> arrList, ScheduleRealInfo sch){ 116 + public ArrivalInfo[] match(List<ArrivalInfo> arrList, ScheduleRealInfo sch){
104 //进出分组 117 //进出分组
105 List<ArrivalInfo> in = new ArrayList<>(), out = new ArrayList<>(); 118 List<ArrivalInfo> in = new ArrayList<>(), out = new ArrayList<>();
106 for(ArrivalInfo arr : arrList){ 119 for(ArrivalInfo arr : arrList){
@@ -109,95 +122,46 @@ public class GpsArrivalStationThread extends Thread{ @@ -109,95 +122,46 @@ public class GpsArrivalStationThread extends Thread{
109 else 122 else
110 out.add(arr); 123 out.add(arr);
111 } 124 }
112 - int s1 = 0, s2 = 0; 125 + ArrivalInfo a1 = null, a2 = null;
113 //匹配发车时间 126 //匹配发车时间
114 - if(sch.getFcsjActual() == null)  
115 - s1 = matchOut(arrList, sch); 127 + if(sch.getFcsjActual() == null && sch.getFcsj() != null)
  128 + a1 = matchOut(out, sch);
116 129
117 //匹配终点时间 130 //匹配终点时间
118 - if(sch.getZdsjActual() == null)  
119 - s2 = matchIn(arrList, sch); 131 + if(sch.getZdsjActual() == null && sch.getZdsj() != null)
  132 + a2 = matchIn(in, sch);
120 133
121 - return new int[]{s1,s2}; 134 + return new ArrivalInfo[]{a1,a2};
122 } 135 }
123 136
124 - public int matchOut(List<ArrivalInfo> arrList, ScheduleRealInfo sch){  
125 - 137 + public ArrivalInfo matchOut(List<ArrivalInfo> arrList, ScheduleRealInfo sch){
  138 + Long space = /*ScheduleBuffer.schSpaceMap.get(sch.getXlBm() + "_" + sch.getXlDir())*/diff;
126 for(ArrivalInfo arr : arrList){ 139 for(ArrivalInfo arr : arrList){
127 - if(arr.getStopNo().equals(sch.getQdzCode())){ 140 + if(arr.getStopNo().equals(sch.getQdzCode())
  141 + && Math.abs((arr.getTs() - sch.getFcsjT())) < space){
  142 + sch.setFcsjActualAll(arr.getTs());
  143 +
  144 + return arr;
128 145
129 } 146 }
130 } 147 }
131 - return 0; 148 + return null;
132 } 149 }
133 150
134 - public int matchIn(List<ArrivalInfo> arrList, ScheduleRealInfo sch){  
135 - return 0;  
136 - }  
137 -  
138 -  
139 - /**  
140 - *  
141 - * @Title: match  
142 - * @Description: TODO(实际和计划进行匹配)  
143 - * @param @param arrList 实际GPS到离站链表  
144 - * @param @param schList 计划排班链表  
145 - * @throws  
146 - */  
147 - /*public void match(List<ArrivalInfo> arrList, List<ScheduleRealInfo> schList){  
148 - Iterator<ScheduleRealInfo> schIterator = schList.iterator();  
149 -  
150 - while(schIterator.hasNext())  
151 - match(schIterator.next(), arrList);  
152 - }*/  
153 -  
154 -  
155 - /*public void match(ScheduleRealInfo scInfo, List<ArrivalInfo> arrList){ 151 + public ArrivalInfo matchIn(List<ArrivalInfo> arrList, ScheduleRealInfo sch){
  152 + Long space = /*ScheduleBuffer.schSpaceMap.get(sch.getXlBm() + "_" + sch.getXlDir())*/diff;
156 for(ArrivalInfo arr : arrList){ 153 for(ArrivalInfo arr : arrList){
157 - match(scInfo, arr);  
158 - }  
159 - }*/  
160 -  
161 -/* public void match(ScheduleRealInfo scInfo, ArrivalInfo arr){  
162 - try{  
163 - //匹配起点  
164 - matchStart(scInfo, arr);  
165 -  
166 - //匹配终点  
167 - matchEnd(scInfo, arr);  
168 - }catch(Exception e){  
169 - e.printStackTrace();  
170 - }  
171 - }*/  
172 -  
173 - /**  
174 - *  
175 - * @Title: matchStart  
176 - * @Description: TODO(匹配起点 出站时间)  
177 - * @param @param scInfo  
178 - * @throws  
179 - */  
180 - public void matchStart(ScheduleRealInfo scInfo, ArrivalInfo arr){  
181 - if(scInfo.getFcsjT() == null  
182 - || arr.getInOut() != 1 || scInfo.getFcsjActual() != null)  
183 - return;  
184 -  
185 - Long ts = arr.getTs();  
186 - //起点站和发车时间比比较  
187 - if(scInfo.getQdzCode().equals(arr.getStopNo())  
188 - && Math.abs(scInfo.getFcsjT() - ts) < diff){  
189 - scInfo.setFcsjActualTime(ts);  
190 - scInfo.setFcsjActual(sdf.format(ts));  
191 -  
192 - System.out.println("成功匹配一个起点...");  
193 - //班次状态改为正在执行  
194 - scInfo.setStatus(1);  
195 - ScheduleBuffer.persistentList.add(scInfo);  
196 - //推送到页面  
197 - sendFcsj(scInfo); 154 + if(arr.getStopNo().equals(sch.getZdzCode())
  155 + && Math.abs((arr.getTs() - sch.getZdsjT())) < space){
  156 + sch.setZdsjActualAll(arr.getTs());
  157 +
  158 + return arr;
  159 + }
198 } 160 }
  161 + return null;
199 } 162 }
200 163
  164 +
201 /** 165 /**
202 * @Title: sendFcsj 166 * @Title: sendFcsj
203 * @Description: TODO(推送发车信息) 167 * @Description: TODO(推送发车信息)
@@ -213,35 +177,6 @@ public class GpsArrivalStationThread extends Thread{ @@ -213,35 +177,6 @@ public class GpsArrivalStationThread extends Thread{
213 } 177 }
214 178
215 /** 179 /**
216 - *  
217 - * @Title: matchEnd  
218 - * @Description: TODO(匹配终点 进站时间)  
219 - * @throws  
220 - */  
221 - public void matchEnd(ScheduleRealInfo scInfo, ArrivalInfo arr){  
222 - if(scInfo.getZdsjT() == null  
223 - || arr.getInOut() != 0 || scInfo.getZdsjActual() != null)  
224 - return;  
225 -  
226 - Long ts = arr.getTs();  
227 - //终点站和发车时间比较  
228 - if(scInfo.getZdzCode().equals(arr.getStopNo())  
229 - && Math.abs(scInfo.getZdsjT() - ts) < diff){  
230 - scInfo.setZdsjActualTime(ts);  
231 - scInfo.setZdsjActual(sdf.format(ts));  
232 -  
233 - System.out.println("成功匹配一个终点...");  
234 - //完成当前班次  
235 - ScheduleRealInfo nextSch = ScheduleBuffer.finishSch(scInfo);  
236 - //到达终点,发送下一班次的调度指令  
237 - int finish = ScheduleBuffer.getFinishSchNo(nextSch.getClZbh());  
238 - directiveService.send60Dispatch(nextSch, finish);  
239 - //推送到页面  
240 - sendZdsj(scInfo, nextSch, finish);  
241 - }  
242 - }  
243 -  
244 - /**  
245 * @Title: sendFcsj 180 * @Title: sendFcsj
246 * @Description: TODO(推送到达终点时间) 181 * @Description: TODO(推送到达终点时间)
247 * @param @param schedule 班次 182 * @param @param schedule 班次
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= true 9 spring.jpa.show-sql= true
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/control 11 +spring.datasource.url= jdbc:mysql://127.0.0.1:3306/control
12 spring.datasource.username= root 12 spring.datasource.username= root
13 -spring.datasource.password= 123456 13 +spring.datasource.password= panzhao
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/static/pages/control/line/child_pages/child_task.html
@@ -441,14 +441,18 @@ $(function(){ @@ -441,14 +441,18 @@ $(function(){
441 param.qdzName = searchStationName(route, param.qdzCode); 441 param.qdzName = searchStationName(route, param.qdzCode);
442 param.zdzName = searchStationName(route, param.zdzCode); 442 param.zdzName = searchStationName(route, param.zdzCode);
443 443
  444 + layer.msg('操作中...', {icon: 16,time:0});
444 $post('/realSchedule', param, function(rs){ 445 $post('/realSchedule', param, function(rs){
445 var sch = rs.t; 446 var sch = rs.t;
446 //前端缓存更新 447 //前端缓存更新
447 scheduleLineMap[param.xlBm][param.lpName].push(sch); 448 scheduleLineMap[param.xlBm][param.lpName].push(sch);
448 //刷新表格 449 //刷新表格
449 _alone.addScheduleToTable(sch); 450 _alone.addScheduleToTable(sch);
  451 + _alone.refreshScheduleArray(rs.ups);
  452 +
450 //关闭弹出层 453 //关闭弹出层
451 layer.closeAll(); 454 layer.closeAll();
  455 + layer.alert('临加班次成功!',{icon:1, shift: 5});
452 }); 456 });
453 }); 457 });
454 458
src/main/resources/static/pages/control/line/child_pages/vehicAndper_adjust.html
@@ -192,13 +192,17 @@ @@ -192,13 +192,17 @@
192 //驾驶员 192 //驾驶员
193 $.get('/realSchedule/driver', {lineCode: lineCode}, function(rs){ 193 $.get('/realSchedule/driver', {lineCode: lineCode}, function(rs){
194 rs.splice(0, 0, placeholder); 194 rs.splice(0, 0, placeholder);
195 - initPinYinSelect2(wrap + ' select[name=jsy]', rs); 195 + initPinYinSelect2(wrap + ' select[name=jsy]', rs, function(that){
  196 + that.val(schedul.jGh + '/' + schedul.jName).change();
  197 + });
196 198
197 }); 199 });
198 //售票员 200 //售票员
199 $.get('/realSchedule/conductor', {lineCode: lineCode}, function(rs){ 201 $.get('/realSchedule/conductor', {lineCode: lineCode}, function(rs){
200 rs.splice(0, 0, placeholder); 202 rs.splice(0, 0, placeholder);
201 - initPinYinSelect2(wrap + ' select[name=spy]', rs); 203 + initPinYinSelect2(wrap + ' select[name=spy]', rs, function(that){
  204 + that.val(schedul.sGh + '/' + schedul.sName).change();
  205 + });
202 }); 206 });
203 }; 207 };
204 208
@@ -243,15 +247,14 @@ @@ -243,15 +247,14 @@
243 idArray.push($(this).data('id')); 247 idArray.push($(this).data('id'));
244 }); 248 });
245 249
  250 + if(!$("#borrowInfoPanel").is(":hidden")){
  251 + params.borrowLine = lineSelect.val();
  252 + }
246 syncSubmit(idArray, params ,function(){ 253 syncSubmit(idArray, params ,function(){
  254 + layer.closeAll();
247 layer.msg('操作完成!'); 255 layer.msg('操作完成!');
248 //刷新表格 256 //刷新表格
249 refreshMainList(); 257 refreshMainList();
250 - //提交借车信息  
251 - if(!$("#borrowInfoPanel").is(":hidden")){  
252 - params.borrowLine = lineSelect.val();  
253 - $post('/deviceRevert', params);  
254 - }  
255 }); 258 });
256 }); 259 });
257 }); 260 });
src/main/resources/static/pages/control/line/css/lineControl.css
@@ -1853,7 +1853,8 @@ a.task-item-success{ @@ -1853,7 +1853,8 @@ a.task-item-success{
1853 } 1853 }
1854 1854
1855 select.form-control.custom-val-error, 1855 select.form-control.custom-val-error,
1856 -input.form-control.custom-val-error{ 1856 +input.form-control.custom-val-error,
  1857 +.select2-selection.custom-val-error{
1857 border: 1px solid #e75555; 1858 border: 1px solid #e75555;
1858 color: #e75555; 1859 color: #e75555;
1859 } 1860 }
src/main/resources/static/pages/control/line/js/data.js
@@ -159,6 +159,10 @@ var _data = (function(){ @@ -159,6 +159,10 @@ var _data = (function(){
159 //根据设备号获取GPS 159 //根据设备号获取GPS
160 getGpsByDeviceId: function(deviceId){ 160 getGpsByDeviceId: function(deviceId){
161 return allGps[deviceId]; 161 return allGps[deviceId];
  162 + },
  163 + //获取所有GPS
  164 + findAllGps: function(){
  165 + return allGps;
162 } 166 }
163 }; 167 };
164 168
src/main/resources/static/pages/control/line/js/drawSvg.js
@@ -176,9 +176,11 @@ var drawSvg = (function(){ @@ -176,9 +176,11 @@ var drawSvg = (function(){
176 176
177 //画出GPS点 177 //画出GPS点
178 drawVehicle: function(gpsArray){ 178 drawVehicle: function(gpsArray){
179 -  
180 for(var i = 0, gps; gps = gpsArray[i ++];){ 179 for(var i = 0, gps; gps = gpsArray[i ++];){
181 //drawGpsToSvg(gps, aloneSvgMapp[gps.lineId]); 180 //drawGpsToSvg(gps, aloneSvgMapp[gps.lineId]);
  181 +
  182 + //暂时先清空重新画
  183 + homeSvgMapp[gps.lineId].select('g.gps-g-wrap').html('');
182 drawGpsToSvg(gps, homeSvgMapp[gps.lineId]); 184 drawGpsToSvg(gps, homeSvgMapp[gps.lineId]);
183 } 185 }
184 186
src/main/resources/static/pages/control/line/js/main.js
@@ -59,12 +59,14 @@ @@ -59,12 +59,14 @@
59 59
60 //模拟图GPS刷新事件 60 //模拟图GPS刷新事件
61 $('#tab_home').on('gps_refresh', function(e, add, up){ 61 $('#tab_home').on('gps_refresh', function(e, add, up){
62 - //附加班次信息  
63 - addList = _data.attachSchedulInfo(add);  
64 - drawSvg.drawVehicle(addList); 62 + //现在先每次全量画
  63 + var list = _data.findAllGps();
  64 + _data.attachSchedulInfo(list);
  65 +
  66 + drawSvg.drawVehicle(list);
65 67
66 //按线路分组 68 //按线路分组
67 - var listMap = groupByLine(addList); 69 + var listMap = groupByLine(list);
68 console.log('listMap', listMap); 70 console.log('listMap', listMap);
69 for(var key in listMap){ 71 for(var key in listMap){
70 var htmlStr = template('home_table_temp', {list: listMap[key]}); 72 var htmlStr = template('home_table_temp', {list: listMap[key]});
src/main/resources/static/pages/control/line/js/rightMenu.js
@@ -205,15 +205,17 @@ var _menu = (function() { @@ -205,15 +205,17 @@ var _menu = (function() {
205 $('#outgoAdjustForm select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change(); 205 $('#outgoAdjustForm select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change();
206 }); 206 });
207 207
208 - $('#outgoAdjustForm button.confirm').one('click', function(){ 208 + $('#outgoAdjustForm button.confirm').on('click', function(){
  209 + var check = customFormValidate('#outgoAdjustForm');
  210 + if(!check)return;
209 211
210 var params = $('#outgoAdjustForm').serializeJSON(); 212 var params = $('#outgoAdjustForm').serializeJSON();
211 $post('/realSchedule/outgoAdjust', params, function(rs){ 213 $post('/realSchedule/outgoAdjust', params, function(rs){
212 layer.close(index); 214 layer.close(index);
213 - schedul.dfsj = rs.dfsj;  
214 - schedul.remarks = rs.remarks;  
215 - _alone.refreshSchedule(schedul);  
216 - layer.msg('调整成功!'); 215 + if(rs.t){
  216 + layer.msg('调整成功!');
  217 + _alone.refreshSchedule(rs.t);
  218 + }
217 }); 219 });
218 }); 220 });
219 } 221 }
@@ -312,10 +314,8 @@ var _menu = (function() { @@ -312,10 +314,8 @@ var _menu = (function() {
312 $('.confirm', '#realOutgoAdjust').on('click', function(){ 314 $('.confirm', '#realOutgoAdjust').on('click', function(){
313 var params = $('#realOutgoAdjust').serializeJSON(); 315 var params = $('#realOutgoAdjust').serializeJSON();
314 if(!params.fcsjActual){ 316 if(!params.fcsjActual){
315 - layer.msg('实发时刻不能为空');return;  
316 - }  
317 - if(!$.trim(params.remarks)){  
318 - layer.msg('备注不能为空');return; 317 + layer.msg('实发时刻不能为空');
  318 + return;
319 } 319 }
320 layer.close(index); 320 layer.close(index);
321 $post('/realSchedule/realOutAdjust', params 321 $post('/realSchedule/realOutAdjust', params
@@ -478,14 +478,12 @@ var _menu = (function() { @@ -478,14 +478,12 @@ var _menu = (function() {
478 478
479 }); 479 });
480 //售票员 480 //售票员
481 - $.get('/realSchedule/conductor', {lineCode: schedul.xlBm}, function(rs){  
482 - initPinYinSelect2('#schinfoFineTune select[name=spy]' , rs, function(rs){  
483 - initPinYinSelect2('#outgoAdjustForm select[name=spy]' , rs, function(that){  
484 - //默认选中  
485 - that.val(schedul.sGh + '/' + schedul.sName).change();  
486 - }); 481 + $.get('/realSchedule/conductor', {lineCode: schedul.xlBm}, function(rs){
  482 + initPinYinSelect2('#schinfoFineTune select[name=spy]' , rs, function(that){
  483 + //默认选中
  484 + that.val(schedul.sGh + '/' + schedul.sName).change();
487 }); 485 });
488 - }); 486 + });
489 //车辆 487 //车辆
490 $.get('/realSchedule/cars', {lineCode: schedul.xlBm}, function(rs){ 488 $.get('/realSchedule/cars', {lineCode: schedul.xlBm}, function(rs){
491 $('#schinfoFineTune select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change(); 489 $('#schinfoFineTune select[name=clZbh]').select2({data: rs}).val(schedul.clZbh).change();
@@ -502,10 +500,9 @@ var _menu = (function() { @@ -502,10 +500,9 @@ var _menu = (function() {
502 //确定 500 //确定
503 $('#schinfoFineTune button.confirm').on('click', function(){ 501 $('#schinfoFineTune button.confirm').on('click', function(){
504 var params = $('form#schinfoFineTune').serializeJSON(); 502 var params = $('form#schinfoFineTune').serializeJSON();
505 - if(!$.trim(params.fcsj)){  
506 - layer.msg('计发时间不能为空!');  
507 - return;  
508 - } 503 +
  504 + if(!customFormValidate('form#schinfoFineTune'))return;
  505 +
509 $post('/realSchedule/schInfoFineTune', params, function(rs){ 506 $post('/realSchedule/schInfoFineTune', params, function(rs){
510 layer.close(index); 507 layer.close(index);
511 if(rs.t) 508 if(rs.t)
@@ -542,5 +539,35 @@ var _menu = (function() { @@ -542,5 +539,35 @@ var _menu = (function() {
542 layer.alert('服务器出现异常!', {icon: 2, title: '操作失败'}); 539 layer.alert('服务器出现异常!', {icon: 2, title: '操作失败'});
543 } 540 }
544 541
  542 + /**
  543 + * 自定义表单校验
  544 + */
  545 + function customFormValidate(f){
  546 + var rs = true;
  547 + //所有可见的项
  548 + var es = $('input,select', f);
  549 +
  550 + for(var i = 0, e; e = es[i++];){
  551 + if($(e).attr('required') && ( $(e).val() == null || $(e).val() == '')){
  552 + if($(e).hasClass('select2-hidden-accessible'))
  553 + $(e).next().find('.select2-selection').addClass('custom-val-error');
  554 + else
  555 + $(e).addClass('custom-val-error');
  556 + rs = false;
  557 + }
  558 + else{
  559 + if($(e).hasClass('select2-hidden-accessible'))
  560 + $(e).next().find('.select2-selection').removeClass('custom-val-error');
  561 + else
  562 + $(e).removeClass('custom-val-error');
  563 + }
  564 + }
  565 +
  566 + if(!rs){
  567 + layer.alert('数据完整性校验失败,请检查输入项', {icon: 2, title: '操作失败', shift: 5});
  568 + }
  569 + return rs;
  570 + }
  571 +
545 return menuObject; 572 return menuObject;
546 })(); 573 })();
547 \ No newline at end of file 574 \ No newline at end of file
src/main/resources/static/pages/control/line/temps/alone_tp.html
@@ -149,7 +149,7 @@ @@ -149,7 +149,7 @@
149 {{/if}} 149 {{/if}}
150 150
151 <td class="hide-lt-1080" data-name="remarks"> 151 <td class="hide-lt-1080" data-name="remarks">
152 - {{if item.remarks != null}} 152 + {{if item.remarks != null && item.length > 0}}
153 <a class="remarks-popover" href="javascript:;" data-toggle="popover" data-content="{{item.remarks}}" >备注...</a> 153 <a class="remarks-popover" href="javascript:;" data-toggle="popover" data-content="{{item.remarks}}" >备注...</a>
154 {{/if}} 154 {{/if}}
155 </td> 155 </td>
@@ -236,7 +236,7 @@ @@ -236,7 +236,7 @@
236 <div class="form-custom-row"> 236 <div class="form-custom-row">
237 <div class="item"> 237 <div class="item">
238 <span class="item-label" style="width: 80px;">车辆编码: </span> 238 <span class="item-label" style="width: 80px;">车辆编码: </span>
239 - <select class="form-control" value="{{clZbh}}" name="clZbh"></select> 239 + <select class="form-control" value="{{clZbh}}" required=1 name="clZbh"></select>
240 </div> 240 </div>
241 <div class="item"> 241 <div class="item">
242 <span class="item-label" style="width: 80px;">路&nbsp;牌: </span> 242 <span class="item-label" style="width: 80px;">路&nbsp;牌: </span>
@@ -251,14 +251,14 @@ @@ -251,14 +251,14 @@
251 </div> 251 </div>
252 <div class="item"> 252 <div class="item">
253 <span class="item-label" style="width: 80px;">预发时刻: </span> 253 <span class="item-label" style="width: 80px;">预发时刻: </span>
254 - <input type="time" class="form-control" value="{{dfsj}}" name="dfsj"> 254 + <input type="time" class="form-control" required=1 value="{{dfsj}}" name="dfsj">
255 </div> 255 </div>
256 </div> 256 </div>
257 257
258 <div class="form-custom-row"> 258 <div class="form-custom-row">
259 <div class="item"> 259 <div class="item">
260 <span class="item-label" style="width: 80px;">驾驶员: </span> 260 <span class="item-label" style="width: 80px;">驾驶员: </span>
261 - <select class="form-control" value="{{jName}}" name="jsy"></select> 261 + <select class="form-control" value="{{jName}}" required=1 name="jsy"></select>
262 </div> 262 </div>
263 <div class="item"> 263 <div class="item">
264 <span class="item-label" style="width: 80px;">售票员: </span> 264 <span class="item-label" style="width: 80px;">售票员: </span>
@@ -370,7 +370,7 @@ @@ -370,7 +370,7 @@
370 <div class="form-custom-row"> 370 <div class="form-custom-row">
371 <div class="item"> 371 <div class="item">
372 <span class="item-label" style="width: 80px;">车辆编码: </span> 372 <span class="item-label" style="width: 80px;">车辆编码: </span>
373 - <select class="form-control" value="{{clZbh}}" name="clZbh"></select> 373 + <select class="form-control" value="{{clZbh}}" name="clZbh" required=1></select>
374 </div> 374 </div>
375 <div class="item"> 375 <div class="item">
376 <span class="item-label" style="width: 80px;">路&nbsp;牌: </span> 376 <span class="item-label" style="width: 80px;">路&nbsp;牌: </span>
@@ -381,18 +381,18 @@ @@ -381,18 +381,18 @@
381 <div class="form-custom-row"> 381 <div class="form-custom-row">
382 <div class="item"> 382 <div class="item">
383 <span class="item-label" style="width: 80px;">驾驶员: </span> 383 <span class="item-label" style="width: 80px;">驾驶员: </span>
384 - <select class="form-control" value="{{jName}}" name="jsy"></select> 384 + <select class="form-control" value="{{jName}}" name="jsy" required=1></select>
385 </div> 385 </div>
386 <div class="item"> 386 <div class="item">
387 <span class="item-label" style="width: 80px;">售票员: </span> 387 <span class="item-label" style="width: 80px;">售票员: </span>
388 - <select class="form-control" value="{{sName}}" name="spy"></select> 388 + <select class="form-control" value="{{sName}}" name="spy" ></select>
389 </div> 389 </div>
390 </div> 390 </div>
391 391
392 <div class="form-custom-row"> 392 <div class="form-custom-row">
393 <div class="item"> 393 <div class="item">
394 <span class="item-label" style="width: 80px;">计发时刻: </span> 394 <span class="item-label" style="width: 80px;">计发时刻: </span>
395 - <input type="time" class="form-control" value="{{fcsj}}" name="fcsj"> 395 + <input type="time" class="form-control" value="{{fcsj}}" name="fcsj" required=1>
396 </div> 396 </div>
397 <div class="item"> 397 <div class="item">
398 <span class="item-label" style="width: 80px;">实际时刻: </span> 398 <span class="item-label" style="width: 80px;">实际时刻: </span>
src/main/resources/static/pages/control/line/temps/console.html
@@ -7,8 +7,8 @@ @@ -7,8 +7,8 @@
7 <span class="log-item-text">{{data.nbbm}} {{text}}</span> 7 <span class="log-item-text">{{data.nbbm}} {{text}}</span>
8 <span class="log-item-time">{{dateStr}}</span> 8 <span class="log-item-time">{{dateStr}}</span>
9 <span class="log-item-handle"> 9 <span class="log-item-handle">
10 - <button type="button" class="btn blue btn-sm">同意</button>  
11 - <button type="button" class="btn red btn-sm">不同意</button> 10 + <!--<button type="button" class="btn blue btn-sm">同意</button>
  11 + <button type="button" class="btn red btn-sm">不同意</button>-->
12 </span> 12 </span>
13 </div> 13 </div>
14 </script> 14 </script>
@@ -19,8 +19,8 @@ @@ -19,8 +19,8 @@
19 <span class="log-item-text">执行班次 {{t.fcsj}}</span> 19 <span class="log-item-text">执行班次 {{t.fcsj}}</span>
20 <span class="log-item-time">{{dataStr}}</span> 20 <span class="log-item-time">{{dataStr}}</span>
21 <span class="log-item-handle"> 21 <span class="log-item-handle">
22 - <a href="javascript:;" class="font-blue-steel log-close">确定</a>  
23 - <a href="javascript:;" class="font-red">地图</a> 22 + <!--<a href="javascript:;" class="font-blue-steel log-close">确定</a>
  23 + <a href="javascript:;" class="font-red">地图</a>-->
24 </span> 24 </span>
25 </div> 25 </div>
26 </script> 26 </script>
@@ -30,8 +30,8 @@ @@ -30,8 +30,8 @@
30 <span class="log-item-text">{{t.zdsjActual}} {{t.clZbh}} 到达 {{t.zdzName}};已完成 {{finish}} 个班次;下一发车时间 {{nt.fcsj}};由{{nt.qdzName}} 发往 {{nt.zdzName}};应到{{nt.zdsj}}</span> 30 <span class="log-item-text">{{t.zdsjActual}} {{t.clZbh}} 到达 {{t.zdzName}};已完成 {{finish}} 个班次;下一发车时间 {{nt.fcsj}};由{{nt.qdzName}} 发往 {{nt.zdzName}};应到{{nt.zdsj}}</span>
31 <span class="log-item-time">{{dataStr}}</span> 31 <span class="log-item-time">{{dataStr}}</span>
32 <span class="log-item-handle"> 32 <span class="log-item-handle">
33 - <a href="javascript:;" class="font-blue-steel log-close">确定</a>  
34 - <a href="javascript:;" class="font-red">地图</a> 33 + <!--<a href="javascript:;" class="font-blue-steel log-close">确定</a>
  34 + <a href="javascript:;" class="font-red">地图</a>-->
35 </span> 35 </span>
36 </div> 36 </div>
37 </script> 37 </script>
38 \ No newline at end of file 38 \ No newline at end of file