Commit b158575434b787626038b480e26b33769f525b74

Authored by 廖磊
2 parents 386c869d 4ad64ba2

Merge branch 'minhang' of

http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
src/main/java/com/bsth/controller/gps/GpsController.java
... ... @@ -91,11 +91,12 @@ public class GpsController {
91 91  
92 92 /**
93 93 * gps补全
  94 + * type 0 : 实时GPS 1:走补传
94 95 * @return
95 96 */
96 97 @RequestMapping(value = "/gpsCompletion", method = RequestMethod.POST)
97   - public Map<String, Object> gpsCompletion(@RequestParam long schId) {
98   - return gpsService.gpsCompletion(schId);
  98 + public Map<String, Object> gpsCompletion(@RequestParam long schId, @RequestParam int type) {
  99 + return gpsService.gpsCompletion(schId, type);
99 100 }
100 101  
101 102 /**
... ...
src/main/java/com/bsth/data/pilot80/PilotReport.java
... ... @@ -2,7 +2,6 @@ package com.bsth.data.pilot80;
2 2  
3 3 import com.bsth.data.BasicData;
4 4 import com.bsth.data.LineConfigData;
5   -import com.bsth.data.gpsdata.GpsEntity;
6 5 import com.bsth.data.gpsdata.GpsRealData;
7 6 import com.bsth.data.msg_queue.DirectivePushQueue;
8 7 import com.bsth.data.schedule.DayOfSchedule;
... ... @@ -16,7 +15,6 @@ import com.bsth.repository.directive.D80Repository;
16 15 import com.bsth.repository.directive.DC0A4Repository;
17 16 import com.bsth.service.directive.DirectiveService;
18 17 import com.bsth.websocket.handler.SendUtils;
19   -import com.google.common.collect.ArrayListMultimap;
20 18 import org.apache.commons.lang3.StringUtils;
21 19 import org.slf4j.Logger;
22 20 import org.slf4j.LoggerFactory;
... ... @@ -26,289 +24,278 @@ import org.springframework.stereotype.Component;
26 24 import java.util.ArrayList;
27 25 import java.util.Collection;
28 26 import java.util.List;
  27 +import java.util.concurrent.ConcurrentHashMap;
29 28  
30 29 /**
31   - *
32   - * @ClassName: PilotReport
33   - * @Description: TODO(设备80协议上报处理)
34 30 * @author PanZhao
35   - * @date 2016年8月14日 下午11:37:51
36   - *
  31 + * @ClassName: PilotReport
  32 + * @Description: TODO(设备80协议上报处理)
  33 + * @date 2016年8月14日 下午11:37:51
37 34 */
38 35 @Component
39 36 public class PilotReport {
40   -
41   - @Autowired
42   - D80Repository d80Repository;
43   - @Autowired
44   - DayOfSchedule dayOfSchedule;
45   - @Autowired
46   - LineConfigData lineConfigData;
47   - @Autowired
48   - DirectiveService directiveService;
49   - @Autowired
50   - GpsRealData gpsRealData;
51   - @Autowired
52   - SendUtils sendUtils;
53   -
54   - @Autowired
55   - DC0A4Repository dc0A4Repository;
56   -
57   - private static ArrayListMultimap<String, D80> d80MultiMap;
58   -
59   - Logger logger = LoggerFactory.getLogger(PilotReport.class);
60   -
61   - static{
62   - d80MultiMap = ArrayListMultimap.create();
63   - }
64   -
65   - public void report(D80 d80){
66   - //入库
67   - d80Repository.save(d80);
68   - //入缓存
69   - d80MultiMap.put(d80.getData().getLineId().toString(), d80);
70   -
71   - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
72   - //处理
73   - switch (d80.getData().getRequestCode()) {
74   - case 0xA3:
75   - //出场请求
76   - ScheduleRealInfo outSch = dayOfSchedule.searchNearByBcType(nbbm, "out");
77   - //如果有对应出场班次
78   - if(outSch != null){
79   - //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令
80   - if(outSch.getJhlc() == null)
81   - outSch = dayOfSchedule.next(outSch);
82   -
83   - //下发调度指令
84   - DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统");
85   - //directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统");
86   - //下发线路切换指令
87   - DirectivePushQueue.put64(outSch.getClZbh(), outSch.getXlBm(), "请出@系统");
88   - //directiveService.lineChange(outSch.getClZbh(), outSch.getXlBm(), "请出@系统");
89   - }else
90   - d80.setRemarks("没有出场计划");
91   -
92   - break;
93   -
94   - case 0xA5:
95   - //进场请求
96   - //ScheduleRealInfo inSch = dayOfSchedule.nextByBcType(nbbm, "in");
97   - //如果有对应出场班次
98   - //if(inSch != null){
99   - /*d80.setRemarks("计划进场时间:" + inSch.getDfsj());
100   - //当前GPS位置
101   - GpsEntity gps = gpsRealData.get(d80.getDeviceId());
102   - if(null != gps)
103   - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/
104   - //}/*else
105   - // d80.setRemarks("没有进场计划");*/
106   - break;
107   - }
108   -
109   - //推送到页面
110   - sendUtils.send80ToPage(d80);
111   - }
112   -
113   - public void report(DC0_A4 c0a4){
114   - String deviceId = c0a4.getData().getDeviceId();
115   - if(StringUtils.isNotEmpty(deviceId))
116   - c0a4.setId(deviceId);
117   -
118   - //入库
119   - dc0A4Repository.save(c0a4);
120   - }
121   -
122   - /**
123   - *
124   - * @Title: reply
125   - * @Description: TODO(调度员回复)
126   - */
127   - public void reply(D80 d80){
128   - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
129   - Short reqCode = d80.getData().getRequestCode();
130   - //默认短语回复
131   - //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false);
132   -
133   - switch (reqCode) {
134   - case 0xA3:
135   - //出场请求回复
136   - applyOutReply(d80);
137   - break;
138   - case 0xA5:
139   - //进场请求回复
140   - applyInReply(d80);
141   - break;
142   - }
143   - }
144   -
145   - /**
146   - *
147   - * @Title: applyOutReply
148   - * @Description: TODO(出场请求回复)
149   - */
150   - public void applyOutReply(D80 d80){
151   - //同意
152   - if(d80.getConfirmRs() == 0){
153   - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
154   -
155   - ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "out");
156   - if(null == sch)
157   - return;
158   -
159   - LineConfig conf = lineConfigData.get(sch.getXlBm());
160   - if(conf.getOutConfig() == 1){
161   - //为相关班次写入请求出场时间
162   - sch.setFcsjActualAll(d80.getTimestamp());
163   -
164   - dayOfSchedule.save(sch);
165   - //通知页面
166   - sendUtils.refreshSch(sch);
167   - }
168   - }
169   - }
170   -
171   - /**
172   - *
173   - * @Title: applyInReply
174   - * @Description: TODO(进场请求回复)
175   - */
176   - public void applyInReply(D80 d80){
177   - //同意
178   - if(d80.getConfirmRs() == 0){
179   - String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
180   -
181   - ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "in");
182   - if(null == sch)
183   - return;
184   -
185   - LineConfig conf = lineConfigData.get(sch.getXlBm());
186   - if(conf.getOutConfig() == 1){
187   - //为相关班次写入进场时间
188   - sch.setZdsjActualAll(d80.getTimestamp());
189   -
190   - //没有里程的进场班次
191   - if(isEmpty(sch.getBcsj()) && isEmpty(sch.getJhlc()))
192   - sch.setFcsjActualAll(d80.getTimestamp());
193   -
194   - dayOfSchedule.save(sch);
195   - //通知页面
196   - sendUtils.refreshSch(sch);
197   - }
198   - }
199   - }
200   -
201   - public boolean isEmpty(Integer v){
202   - return v == null || v.equals(0);
203   - }
204   -
205   - public boolean isEmpty(Double v){
206   - return v == null || v.equals(0);
207   - }
208   -
209   - public void defaultReply(String nbbm, short requestCode, boolean agree){
210   - Line line = BasicData.nbbm2LineMap.get(nbbm);
211   - String lineCode = null;
212   -
213   - if(line != null)
214   - lineCode = line.getLineCode();
215   - else{
216   - try{
217   - lineCode = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)).getLineId().toString();
218   - }catch(Exception e){
219   - logger.error("", e);
220   - }
221   - }
222   -
223   - if(null == lineCode)
224   - return;
225   -
226   - LineConfig conf = lineConfigData.get(lineCode);
227   - D80ReplyTemp temp = conf.findByCode(requestCode);
228   -
229   - if(null == temp)
230   - return;
231   -
232   - String text;
233   - if(agree)
234   - text = temp.getAgreeText();
235   - else
236   - text = temp.getRejectText();
237   -
238   - directiveService.send60Phrase(nbbm, text, "系统");
239   - }
240   -
241   - /**
242   - *
243   - * @Title: resumeOperation
244   - * @Description: TODO(恢复营运)
245   - */
246   - public void resumeOperation(D80 d80){
247   -
248   - }
249   -
250   - /**
251   - *
252   - * @Title: applyTiaodang
253   - * @Description: TODO(申请调档)
254   - */
255   - public void applyTiaodang(D80 d80){
256   -
257   - }
258   -
259   - /**
260   - *
261   - * @Title: unconfirmed80
262   - * @Description: TODO(根据lineCode 获取未处理的80数据)
263   - */
264   - public List<D80> unconfirmed80(Integer lineCode){
265   - List<D80> lineAll = d80MultiMap.get(lineCode.toString())
266   - ,rs = new ArrayList<>();
267   -
268   - for(D80 d80 : lineAll)
269   - if(!d80.isConfirm())
270   - rs.add(d80);
271   -
272   - return rs;
273   - }
274   -
275   - public D80 findById(int id){
276   - Collection<D80> all = d80MultiMap.values();
277   -
278   - for(D80 d80 : all){
279   - if(d80.getId() == id)
280   - return d80;
281   - }
282   -
283   - return null;
284   - }
285   -
286   - public String coordHtmlStr(GpsEntity gps){
287   -
288   - return "<span class=\"nt-coord\" data-lon=\""+gps.getLon()+"\" data-lat=\""+gps.getLat()+"\"></span>";
289   - }
290   -
291   - public Collection<D80> findAll(){
292   - return d80MultiMap.values();
293   - }
294   -
295   - public void clear(String lineCode){
296   - logger.info("清除 80数据 before: " + d80MultiMap.size());
297   - d80MultiMap.removeAll(lineCode);
298   - logger.info("清除 80数据 after: " + d80MultiMap.size());
299   - }
300   -
301   - public Collection<? extends D80> findByCar(String nbbm) {
302   - List<D80> rs = new ArrayList<>();
303   - String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
304   - if(null == deviceId)
305   - return rs;
306   -
307   - Collection<D80> all = findAll();
308   - for(D80 d80 : all){
309   - if(d80.getDeviceId().equals(deviceId))
310   - rs.add(d80);
311   - }
312   - return rs;
313   - }
  37 +
  38 + @Autowired
  39 + D80Repository d80Repository;
  40 + @Autowired
  41 + DayOfSchedule dayOfSchedule;
  42 + @Autowired
  43 + LineConfigData lineConfigData;
  44 + @Autowired
  45 + DirectiveService directiveService;
  46 + @Autowired
  47 + GpsRealData gpsRealData;
  48 + @Autowired
  49 + SendUtils sendUtils;
  50 +
  51 + @Autowired
  52 + DC0A4Repository dc0A4Repository;
  53 +
  54 + //private static ArrayListMultimap<String, D80> d80MultiMap;
  55 +
  56 + private static ConcurrentHashMap<Integer, D80> d80Maps;
  57 +
  58 + Logger logger = LoggerFactory.getLogger(PilotReport.class);
  59 +
  60 + static {
  61 + //d80MultiMap = ArrayListMultimap.create();
  62 + d80Maps = new ConcurrentHashMap<>();
  63 + }
  64 +
  65 + public void report(D80 d80) {
  66 + if (d80 == null)
  67 + return;
  68 + try {
  69 + //入库
  70 + d80Repository.save(d80);
  71 + //入缓存
  72 + d80Maps.put(d80.getId(), d80);
  73 + //d80MultiMap.put(d80.getData().getLineId().toString(), d80);
  74 +
  75 + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
  76 + //处理
  77 + switch (d80.getData().getRequestCode()) {
  78 + //出场请求
  79 + case 0xA3:
  80 + ScheduleRealInfo outSch = dayOfSchedule.searchNearByBcType(nbbm, "out");
  81 + //如果有对应出场班次
  82 + if (outSch != null) {
  83 + //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令
  84 + if (outSch.getJhlc() == null)
  85 + outSch = dayOfSchedule.next(outSch);
  86 +
  87 + //下发调度指令
  88 + DirectivePushQueue.put6002(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统");
  89 + //下发线路切换指令
  90 + DirectivePushQueue.put64(outSch.getClZbh(), outSch.getXlBm(), "请出@系统");
  91 + }
  92 + break;
  93 + }
  94 +
  95 + //推送到页面
  96 + sendUtils.send80ToPage(d80);
  97 + } catch (Exception e) {
  98 + logger.error("", e);
  99 + }
  100 + }
  101 +
  102 + public void report(DC0_A4 c0a4) {
  103 + String deviceId = c0a4.getData().getDeviceId();
  104 + if (StringUtils.isNotEmpty(deviceId))
  105 + c0a4.setId(deviceId);
  106 +
  107 + //入库
  108 + dc0A4Repository.save(c0a4);
  109 + }
  110 +
  111 + /**
  112 + * @Title: reply
  113 + * @Description: TODO(调度员回复)
  114 + */
  115 + public void reply(D80 d80) {
  116 + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
  117 + Short reqCode = d80.getData().getRequestCode();
  118 + //默认短语回复
  119 + //defaultReply(nbbm, reqCode, d80.getConfirmRs() == 0?true:false);
  120 +
  121 + switch (reqCode) {
  122 + case 0xA3:
  123 + //出场请求回复
  124 + applyOutReply(d80);
  125 + break;
  126 + case 0xA5:
  127 + //进场请求回复
  128 + applyInReply(d80);
  129 + break;
  130 + }
  131 + }
  132 +
  133 + /**
  134 + * @Title: applyOutReply
  135 + * @Description: TODO(出场请求回复)
  136 + */
  137 + public void applyOutReply(D80 d80) {
  138 + //同意
  139 + if (d80.getConfirmRs() == 0) {
  140 + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
  141 +
  142 + ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "out");
  143 + if (null == sch)
  144 + return;
  145 +
  146 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  147 + if (conf.getOutConfig() == 1) {
  148 + //为相关班次写入请求出场时间
  149 + sch.setFcsjActualAll(d80.getTimestamp());
  150 +
  151 + dayOfSchedule.save(sch);
  152 + //通知页面
  153 + sendUtils.refreshSch(sch);
  154 + }
  155 + }
  156 + }
  157 +
  158 + /**
  159 + * @Title: applyInReply
  160 + * @Description: TODO(进场请求回复)
  161 + */
  162 + public void applyInReply(D80 d80) {
  163 + //同意
  164 + if (d80.getConfirmRs() == 0) {
  165 + String nbbm = BasicData.deviceId2NbbmMap.get(d80.getDeviceId());
  166 +
  167 + ScheduleRealInfo sch = dayOfSchedule.nextByBcType(nbbm, "in");
  168 + if (null == sch)
  169 + return;
  170 +
  171 + LineConfig conf = lineConfigData.get(sch.getXlBm());
  172 + if (conf.getOutConfig() == 1) {
  173 + //为相关班次写入进场时间
  174 + sch.setZdsjActualAll(d80.getTimestamp());
  175 +
  176 + //没有里程的进场班次
  177 + if (isEmpty(sch.getBcsj()) && isEmpty(sch.getJhlc()))
  178 + sch.setFcsjActualAll(d80.getTimestamp());
  179 +
  180 + dayOfSchedule.save(sch);
  181 + //通知页面
  182 + sendUtils.refreshSch(sch);
  183 + }
  184 + }
  185 + }
  186 +
  187 + public boolean isEmpty(Integer v) {
  188 + return v == null || v.equals(0);
  189 + }
  190 +
  191 + public boolean isEmpty(Double v) {
  192 + return v == null || v.equals(0);
  193 + }
  194 +
  195 + public void defaultReply(String nbbm, short requestCode, boolean agree) {
  196 + Line line = BasicData.nbbm2LineMap.get(nbbm);
  197 + String lineCode = null;
  198 +
  199 + if (line != null)
  200 + lineCode = line.getLineCode();
  201 + else {
  202 + try {
  203 + lineCode = gpsRealData.get(BasicData.deviceId2NbbmMap.inverse().get(nbbm)).getLineId().toString();
  204 + } catch (Exception e) {
  205 + logger.error("", e);
  206 + }
  207 + }
  208 +
  209 + if (null == lineCode)
  210 + return;
  211 +
  212 + LineConfig conf = lineConfigData.get(lineCode);
  213 + D80ReplyTemp temp = conf.findByCode(requestCode);
  214 +
  215 + if (null == temp)
  216 + return;
  217 +
  218 + String text;
  219 + if (agree)
  220 + text = temp.getAgreeText();
  221 + else
  222 + text = temp.getRejectText();
  223 +
  224 + directiveService.send60Phrase(nbbm, text, "系统");
  225 + }
  226 +
  227 + /**
  228 + * @Title: resumeOperation
  229 + * @Description: TODO(恢复营运)
  230 + */
  231 + public void resumeOperation(D80 d80) {
  232 +
  233 + }
  234 +
  235 + /**
  236 + * @Title: applyTiaodang
  237 + * @Description: TODO(申请调档)
  238 + */
  239 + public void applyTiaodang(D80 d80) {
  240 +
  241 + }
  242 +
  243 + /**
  244 + * @Title: unconfirmed80
  245 + * @Description: TODO(根据lineCode 获取未处理的80数据)
  246 + */
  247 + public List<D80> unconfirmed80(String lineCode) {
  248 + List<D80> lineAll = findByLine(lineCode), rs = new ArrayList<>();
  249 +
  250 + for (D80 d80 : lineAll)
  251 + if (!d80.isConfirm())
  252 + rs.add(d80);
  253 +
  254 + return rs;
  255 + }
  256 +
  257 + public List<D80> findByLine(String lineCode) {
  258 + List<D80> rs = new ArrayList<>();
  259 + for (D80 d80 : d80Maps.values()) {
  260 + if (d80 != null && d80.getData().getLineId().equals(lineCode))
  261 + rs.add(d80);
  262 + }
  263 + return rs;
  264 + }
  265 +
  266 + public D80 findById(int id) {
  267 + return d80Maps.get(id);
  268 + }
  269 +
  270 +/* public String coordHtmlStr(GpsEntity gps) {
  271 +
  272 + return "<span class=\"nt-coord\" data-lon=\"" + gps.getLon() + "\" data-lat=\"" + gps.getLat() + "\"></span>";
  273 + }*/
  274 +
  275 + public Collection<D80> findAll() {
  276 + return d80Maps.values();
  277 + }
  278 +
  279 + public void clear(String lineCode) {
  280 + logger.info("清除 80数据 before: " + d80Maps.size());
  281 + List<D80> rems = findByLine(lineCode);
  282 + for (D80 d80 : rems) {
  283 + d80Maps.remove(d80.getId());
  284 + }
  285 + logger.info("清除 80数据 after: " + d80Maps.size());
  286 + }
  287 +
  288 + public Collection<? extends D80> findByCar(String nbbm) {
  289 + List<D80> rs = new ArrayList<>();
  290 + String deviceId = BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  291 + if (null == deviceId)
  292 + return rs;
  293 +
  294 + Collection<D80> all = findAll();
  295 + for (D80 d80 : all) {
  296 + if (d80.getDeviceId().equals(deviceId))
  297 + rs.add(d80);
  298 + }
  299 + return rs;
  300 + }
314 301 }
... ...
src/main/java/com/bsth/entity/directive/D80.java
1 1 package com.bsth.entity.directive;
2 2  
3   -import java.util.Date;
4   -
5   -import javax.persistence.CascadeType;
6   -import javax.persistence.Embeddable;
7   -import javax.persistence.Entity;
8   -import javax.persistence.FetchType;
9   -import javax.persistence.GeneratedValue;
10   -import javax.persistence.Id;
11   -import javax.persistence.NamedAttributeNode;
12   -import javax.persistence.NamedEntityGraph;
13   -import javax.persistence.NamedEntityGraphs;
14   -import javax.persistence.OneToOne;
15   -import javax.persistence.Table;
16   -import javax.persistence.Transient;
17   -
18 3 import com.bsth.entity.directive.DC0.DC0Data;
19 4  
  5 +import javax.persistence.*;
  6 +import java.util.Date;
  7 +
20 8 /**
21 9 *
22 10 * @ClassName: D80
... ... @@ -92,7 +80,7 @@ public class D80 {
92 80 /**
93 81 * 线路编码
94 82 */
95   - private Integer lineId;
  83 + private String lineId;
96 84  
97 85 /**
98 86 * 车辆内部编码
... ... @@ -116,13 +104,6 @@ public class D80 {
116 104 this.requestCode = requestCode;
117 105 }
118 106  
119   - public Integer getLineId() {
120   - return lineId;
121   - }
122   -
123   - public void setLineId(Integer lineId) {
124   - this.lineId = lineId;
125   - }
126 107  
127 108 public String getNbbm() {
128 109 return nbbm;
... ... @@ -131,6 +112,14 @@ public class D80 {
131 112 public void setNbbm(String nbbm) {
132 113 this.nbbm = nbbm;
133 114 }
  115 +
  116 + public String getLineId() {
  117 + return lineId;
  118 + }
  119 +
  120 + public void setLineId(String lineId) {
  121 + this.lineId = lineId;
  122 + }
134 123 }
135 124  
136 125 @Transient
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -302,7 +302,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
302 302  
303 303 Map<String, List<D80>> rs = new HashMap<>();
304 304 for (String code : lineList)
305   - rs.put(code, pilotReport.unconfirmed80(Integer.parseInt(code)));
  305 + rs.put(code, pilotReport.unconfirmed80(code));
306 306  
307 307 return rs;
308 308 }
... ...
src/main/java/com/bsth/service/gps/GpsService.java
... ... @@ -21,7 +21,7 @@ public interface GpsService {
21 21  
22 22 Map<String,Object> findRoadSpeed(String lineCode);
23 23  
24   - Map<String,Object> gpsCompletion(long schId);
  24 + Map<String,Object> gpsCompletion(long schId, int type);
25 25  
26 26 Map<String,Object> history_v2(String nbbm, long st, long et);
27 27  
... ...
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
... ... @@ -445,7 +445,7 @@ public class GpsServiceImpl implements GpsService {
445 445 * @return
446 446 */
447 447 @Override
448   - public Map<String, Object> gpsCompletion(long schId) {
  448 + public Map<String, Object> gpsCompletion(long schId, int type) {
449 449 Map<String, Object> rs = new HashMap<>();
450 450  
451 451 try {
... ... @@ -482,9 +482,15 @@ public class GpsServiceImpl implements GpsService {
482 482 long diff = ((sch.getDfsjT() - Long.parseLong(fs.get("ts").toString())) - 1000 * 70);
483 483  
484 484 String deviceId = BasicData.deviceId2NbbmMap.inverse().get(sch.getClZbh());
  485 + int serviceState;
485 486 for (Map<String, Object> map : list) {
486 487 map.put("device_id", deviceId);
487 488 map.put("ts", Long.parseLong(map.get("ts").toString()) + diff);
  489 + if(type==1){
  490 + //走补传协议
  491 + serviceState = Integer.parseInt(map.get("service_state").toString());
  492 + map.put("service_state", serviceState |= 0x00100000);
  493 + }
488 494 }
489 495  
490 496 String sqlBefore = "insert into bsth_c_template(", sqlValues = " values(";
... ...
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
... ... @@ -668,25 +668,23 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
668 668 * @return String
669 669 */
670 670 public String newTextFileToFTP(List<Object[]> objects,Integer lineId) {
671   -
672 671 // 返回值String
673 672 String stationRStr = "";
674   -
675 673 // windows下的文本文件换行符
676 674 //String enterStr = "\r\n";
677   -
678 675 // linux/unix下的文本文件换行符
679 676 String enterStr = "\r";
680   -
  677 + int defaultZdxh = 0;
681 678 if(objects.size()>0) {
682   -
683 679 for(int i = 0; i<objects.size();i++) {
684   -
  680 + defaultZdxh ++ ;
685 681 // 经度
686   - String lng = objects.get(i)[0].equals("") ? "" : objects.get(i)[0].toString();
  682 + String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString();
687 683  
688 684 // 纬度
689   - String lat = objects.get(i)[1].equals("") ? "" : objects.get(i)[1].toString();
  685 + String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString();
  686 +
  687 + Point point = new Point(Double.valueOf(lng), Double.valueOf(lat));
690 688  
691 689 lat = "\t" + lat;
692 690  
... ... @@ -696,23 +694,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
696 694 String stationMake = "";
697 695  
698 696 if(stationMakeStr.equals("E")) {
699   -
700 697 stationMake = "\t2";
701   -
702 698 }else {
703   -
704 699 stationMake ="\t1";
705   -
706 700 }
707 701  
708 702 // 站点序号
709   - String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString();
  703 + // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString();
  704 + String stationNo = String.valueOf(defaultZdxh);
710 705  
711 706 stationNo = "\t" + stationNo;
712 707  
713 708 // 站点编码
714 709 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString();
715 710  
  711 + int len = stationCode.length();
  712 + if(len<8) {
  713 + int dx = 8 - len;
  714 + String addStr = "";
  715 + for(int p =0;p<dx;p++) {
  716 + addStr = addStr + "0";
  717 + }
  718 + stationCode = addStr + stationCode;
  719 + }else if(len>8){
  720 + stationCode = stationCode.substring(8);
  721 + }
  722 +
716 723 stationCode = "\t" +stationCode;
717 724  
718 725 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000;
... ... @@ -732,41 +739,33 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
732 739  
733 740 // 限速
734 741 String sleepStr = "";
735   -
736 742 // 方向
737 743 int directions = objects.get(i)[8]==null ? null : Integer.valueOf(objects.get(i)[8].toString());
738   -
739 744 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
740 745 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions);
741   -
742 746 if(sobje.size()==1) {
743   -
744   - double dsleepStr = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString());
745   -
746   - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStr);
747   -
  747 + int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString());
  748 + sleepStr = "\t" + String.valueOf(dsleepStr);
748 749 }else if(sobje.size()>1){
749   -
750   - /** 这里暂时只根据站点名称去匹配所在路段的限速值 ,如果路段名称"至"之前的地名与站点名称等同,就认为站点在路段上。 */
751 750 for(int j =0;j<sobje.size();j++) {
752   -
753   - String sectionName = sobje.get(j)[3].toString();
754   -
755   - String sectionNameA[] = sectionName.split("至");
756   -
757   - if(stationName.equals(sectionNameA[0])){
758   -
759   - /*sleepStr = sobje.get(j)[2].toString();*/
760   -
761   - double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(j)[2].toString());
762   -
763   - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt);
764   -
  751 + double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString());
  752 + String pointsStr = sobje.get(j)[1]==null || sobje.get(j)[1].equals("") ? null : sobje.get(j)[1].toString();
  753 + pointsStr = pointsStr.substring(11, pointsStr.length()-1);
  754 + List<Point> ps = new ArrayList<>();
  755 + String[] pArray = pointsStr.split(",");
  756 + for(int a = 0; a <pArray.length; a++) {
  757 + String[] tmepA = pArray[a].split(" ");
  758 + Point temp = new Point(Double.valueOf(tmepA[0]), Double.valueOf(tmepA[1]));
  759 + ps.add(temp);
  760 + }
  761 + if(GeoUtils.isInSection(ps, point)) {
  762 + sleepStr = "\t" + String.valueOf((int)dsleepStrt);
  763 + break;
765 764 }
766   -
767 765 }
768 766 }
769   -
  767 + if(sleepStr.equals(""))
  768 + sleepStr = "\t" + "60";
770 769 stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
771 770 }
772 771  
... ... @@ -785,9 +784,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
785 784 for(int i = 0; i<objects.size();i++) {
786 785 if(Integer.valueOf(objects.get(i)[8].toString())==0) {
787 786 // 经度
788   - String lng = objects.get(i)[0].equals("") ? "" : objects.get(i)[0].toString();
  787 + String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString();
  788 +
789 789 // 纬度
790   - String lat = objects.get(i)[1].equals("") ? "" : objects.get(i)[1].toString();
  790 + String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString();
  791 +
  792 + Point point = new Point(Double.valueOf(lng), Double.valueOf(lat));
791 793 lat = "\t" + lat;
792 794 // 站点类型
793 795 String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString();
... ... @@ -802,6 +804,17 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
802 804 String stationNo = "\t" + xh;
803 805 // 站点编码
804 806 String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString();
  807 + int len = stationCode.length();
  808 + if(len<8) {
  809 + int dx = 8 - len;
  810 + String addStr = "";
  811 + for(int p =0;p<dx;p++) {
  812 + addStr = addStr + "0";
  813 + }
  814 + stationCode = addStr + stationCode;
  815 + }else if(len>8){
  816 + stationCode = stationCode.substring(8);
  817 + }
805 818 stationCode = "\t" +stationCode;
806 819 double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000;
807 820 String tempDistc = String.valueOf((int) dis);
... ... @@ -817,20 +830,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
817 830 /** 获取路段路由信息 @pararm:<lineId:线路ID;directions:方向> */
818 831 List<Object[]> sobje = routeRepository.sectionRouteVector(lineId,directions);
819 832 if(sobje.size()==1) {
820   - double dsleepStr = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(0)[2].toString());
821   - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStr);
  833 + int dsleepStr = sobje.get(0)[2] == null || sobje.get(0)[2].equals("") ? 60 : Integer.valueOf(sobje.get(0)[2].toString());
  834 + sleepStr = "\t" + String.valueOf(dsleepStr);
822 835 }else if(sobje.size()>1){
823   - /** 这里暂时只根据站点名称去匹配所在路段的限速值 ,如果路段名称"至"之前的地名与站点名称等同,就认为站点在路段上。 */
824 836 for(int j =0;j<sobje.size();j++) {
825   - String sectionName = sobje.get(j)[3].toString();
826   - String sectionNameA[] = sectionName.split("至");
827   - if(stationName.equals(sectionNameA[0])){
828   - /*sleepStr = sobje.get(j)[2].toString();*/
829   - double dsleepStrt = sobje.get(0)[2] == null ? 60d : Double.valueOf(sobje.get(j)[2].toString());
830   - sleepStr = "\t" + new DecimalFormat("0").format(dsleepStrt);
  837 + double dsleepStrt = sobje.get(j)[2] == null || sobje.get(j)[2].equals("") ? 60d : Double.valueOf(sobje.get(j)[2].toString());
  838 + String pointsStr = sobje.get(j)[1]==null || sobje.get(j)[1].equals("") ? null : sobje.get(j)[1].toString();
  839 + pointsStr = pointsStr.substring(11, pointsStr.length()-1);
  840 + List<Point> ps = new ArrayList<>();
  841 + String[] pArray = pointsStr.split(",");
  842 + for(int a = 0; a <pArray.length; a++) {
  843 + String[] tmepA = pArray[a].split(" ");
  844 + Point temp = new Point(Double.valueOf(tmepA[0]), Double.valueOf(tmepA[1]));
  845 + ps.add(temp);
  846 + }
  847 + if(GeoUtils.isInSection(ps, point)) {
  848 + sleepStr = "\t" + String.valueOf((int)dsleepStrt);
  849 + break;
831 850 }
832 851 }
833 852 }
  853 + if(sleepStr.equals(""))
  854 + sleepStr = "\t" + "60";
834 855 xh++;
835 856 restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr;
836 857 }
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -24,6 +24,7 @@ import com.bsth.webService.trafficManage.geotool.services.Internal;
24 24 import com.bsth.webService.trafficManage.org.tempuri.Results;
25 25 import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator;
26 26 import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap;
  27 +import org.apache.commons.lang.StringUtils;
27 28 import org.apache.commons.lang.time.DateUtils;
28 29 import org.slf4j.Logger;
29 30 import org.slf4j.LoggerFactory;
... ... @@ -1125,11 +1126,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{
1125 1126 }else{
1126 1127 flag = 0;
1127 1128 }
1128   - result += flag;
1129   - if(i !=ruleDayArray.length -1){
1130   - result +=",";
  1129 + if(flag > 0){
  1130 + result += flag + ",";
1131 1131 }
1132 1132 }
  1133 + // 去掉最后一个字符
  1134 + if(StringUtils.endsWith(result,",")){
  1135 + result = StringUtils.removeEnd(result,",");
  1136 + }
1133 1137 return result;
1134 1138 }
1135 1139 /**
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task_v2/add_in_out.html
... ... @@ -113,11 +113,6 @@
113 113 $f('startStation', f).on('change', function () {
114 114 $f('endStation', outf).val($(this).val());//.trigger('change');
115 115 }).trigger('change');
116   -
117   - //烂班原因
118   - if(sch.status == -1 &&
119   - gb_common.inOutExps.indexOf(sch.adjustExps)!=-1)
120   - $f('inOutReason',inf).val(sch.adjustExps).trigger('change');
121 116 }
122 117  
123 118 function repeat_Out(f) {
... ... @@ -130,6 +125,13 @@
130 125 code=sch.qdzCode;
131 126 $f('endStation', f).val(code).trigger('change'); //出场到主任务终点
132 127 $f('startDate', f).val($f('endDate', inf).val()).trigger('input');//开始时间
  128 +
  129 + //烂班原因
  130 + if(sch.status == -1 &&
  131 + gb_common.inOutExps.indexOf(sch.adjustExps)!=-1){
  132 + $f('reason',inf).val(sch.adjustExps);
  133 + $f('reason',outf).val(sch.adjustExps).trigger('change');
  134 + }
133 135 }
134 136  
135 137 function $f(name, f) {
... ...
src/main/resources/static/real_control_v2/js/common.js
... ... @@ -22,7 +22,7 @@ var gb_common = (function () {
22 22 };
23 23  
24 24 var adjustExps = ['配车', '保养', '故障', '肇事', '路阻', '纠纷', '缺人', '客稀', '缺车', '气候', '援外', '吊慢', '抽减', '其他'];
25   - var inOutExps = ['配车', '保养', '故障', '肇事', '路阻', '纠纷', '缺人', '客稀', '缺车', '气候', '援外', '吊慢', '抽减', '其他'];
  25 + var inOutExps = ['故障', '肇事', '纠纷', '其他'];
26 26  
27 27 var groupBy = function (list, field) {
28 28 var rs = {},
... ...
src/main/resources/static/real_control_v2/sch_manage/sch_imitate.html
... ... @@ -379,15 +379,33 @@
379 379 }
380 380 alt_confirm('确定班次信息? ' + sch.xlName + '、起点 ' + sch.qdzName + ' , 终点 ' + sch.zdzName + ' 、待发 ' + sch.dfsj, function () {
381 381 $('.shade-loading').show();
382   - gb_common.$post('/gps/gpsCompletion', {schId: schId}, function (rs) {
  382 + gb_common.$post('/gps/gpsCompletion', {schId: schId, type: 0}, function (rs) {
383 383 $('.shade-loading').hide();
384 384 $('.search-form').trigger('submit');
385 385 });
386 386 }, '我确定是这个班次');
387 387 };
388 388  
  389 + var gps_imitate_after = function (schId) {
  390 + var sch = schArray[schId];
  391 + if(sch.reissue){
  392 + UIkit.notify("<i class='uk-icon-times'></i> 你不能对一个班次重复操作!", {
  393 + status: 'danger'
  394 + });
  395 + return;
  396 + }
  397 + alt_confirm('确定补传班次信息? ' + sch.xlName + '、起点 ' + sch.qdzName + ' , 终点 ' + sch.zdzName + ' 、待发 ' + sch.dfsj, function () {
  398 + $('.shade-loading').show();
  399 + gb_common.$post('/gps/gpsCompletion', {schId: schId, type: 1}, function (rs) {
  400 + $('.shade-loading').hide();
  401 + $('.search-form').trigger('submit');
  402 + });
  403 + }, '我确定补传这个班次');
  404 + }
  405 +
389 406 var callbackHandler = {
390   - gps_imitate: gps_imitate
  407 + gps_imitate: gps_imitate,
  408 + gps_imitate_after: gps_imitate_after
391 409 }
392 410  
393 411 $.contextMenu({
... ... @@ -399,7 +417,11 @@
399 417 },
400 418 items: {
401 419 'gps_imitate': {
402   - name: '模拟轨迹'
  420 + name: '模拟轨迹(事前)'
  421 +
  422 + },
  423 + 'gps_imitate_after':{
  424 + name: '模拟轨迹(事后补传)'
403 425 }
404 426 }
405 427 });
... ...