Commit 6957b0da0a093f60a36d4f51ffcedd29246ea18c

Authored by ljq
2 parents a9f59587 93e97901

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

src/main/java/com/bsth/common/Constants.java
... ... @@ -37,6 +37,8 @@ public class Constants {
37 37  
38 38 //车载网关上行接口
39 39 public static final String UPSTREAM_URL = "/control/upstream";
  40 + //站点道闸上传入口
  41 + public static final String STATIONSIGNO_URL = "/control/stationSigno";
40 42 //rfid 上传入口
41 43 public static final String UP_RFID_URL = "/rfid/**";
42 44  
... ...
src/main/java/com/bsth/controller/directive/UpstreamEntrance.java
1 1 package com.bsth.controller.directive;
2 2  
  3 +import com.bsth.entity.realcontrol.ScheduleRealInfoTag;
  4 +import com.bsth.service.directive.DirectiveService;
3 5 import org.apache.commons.lang3.StringUtils;
4 6 import org.slf4j.Logger;
5 7 import org.slf4j.LoggerFactory;
... ... @@ -17,6 +19,9 @@ import com.bsth.entity.directive.D80;
17 19 import com.bsth.entity.directive.DC0_A4;
18 20 import com.bsth.entity.directive.DirectiveReponse;
19 21  
  22 +import java.util.List;
  23 +import java.util.Map;
  24 +
20 25 /**
21 26 *
22 27 * @ClassName: UpstreamEntrance
... ... @@ -35,6 +40,9 @@ public class UpstreamEntrance {
35 40 DayOfDirectives dayOfDirectives;
36 41  
37 42 @Autowired
  43 + DirectiveService directiveService;
  44 +
  45 + @Autowired
38 46 PilotReport pilotReport;
39 47  
40 48 @RequestMapping(value = "/upstream", method = RequestMethod.POST)
... ... @@ -90,4 +98,13 @@ public class UpstreamEntrance {
90 98 }
91 99 return "{\"errCode\":0}";
92 100 }
  101 +
  102 + @RequestMapping(value = "/stationSigno", method = RequestMethod.POST)
  103 + public Map<String, Object> stationSigno(@RequestParam Map<String, Object> map) {
  104 + return directiveService.stationSigno(map);
  105 + }
  106 + @RequestMapping(value = "/tagByLines", method = RequestMethod.GET)
  107 + public List<ScheduleRealInfoTag> tagByLines(@RequestParam String lines) {
  108 + return directiveService.tagByLines(lines);
  109 + }
93 110 }
... ...
src/main/java/com/bsth/data/BasicData.java
... ... @@ -42,6 +42,8 @@ public class BasicData {
42 42  
43 43 //车辆自编号和牌照号对照 (K: 车辆自编号 ,V:牌照号)
44 44 public static Map<String, String> nbbmCompanyPlateMap;
  45 + //车辆自编号和牌照号对照 (K: 牌照号 ,V:车辆自编号)
  46 + public static Map<String, String> plateCompanyNbbmMap;
45 47  
46 48 //站点编码和名称对照,包括停车场 (K: lineCode_updown_stationCode ,V:站点名称)
47 49 public static Map<String, String> stationCode2NameMap;
... ... @@ -200,6 +202,8 @@ public class BasicData {
200 202  
201 203 //车辆自编号和拍照号对照
202 204 Map<String, String> nbbmCompanyPlate = new HashMap<>();
  205 + //车辆牌照号和自编号对照
  206 + Map<String, String> plateCompanyNbbm = new HashMap<>();
203 207  
204 208 Iterator<Cars> carIterator = carsRepository.findAll().iterator();
205 209 Cars car;
... ... @@ -209,12 +213,29 @@ public class BasicData {
209 213 nbbm2CompanyCode.put(car.getInsideCode(), car.getBusinessCode());
210 214 nbbm2FgsCompanyCode.put(car.getInsideCode(), car.getBrancheCompanyCode() + "_" + car.getBusinessCode() );
211 215 nbbmCompanyPlate.put(car.getInsideCode(), car.getCarPlate());
  216 + String carPlate = car.getCarPlate();
  217 + if(carPlate.indexOf("沪") != -1){
  218 + String cps1[] = carPlate.split("沪");
  219 + carPlate = "";
  220 + for (int i=0;i<cps1.length;i++){
  221 + carPlate += cps1[i];
  222 + }
  223 + }
  224 + if(carPlate.indexOf("-") != -1){
  225 + String cps1[] = carPlate.split("-");
  226 + carPlate = "";
  227 + for (int i=0;i<cps1.length;i++){
  228 + carPlate += cps1[i];
  229 + }
  230 + }
  231 + plateCompanyNbbm.put(carPlate, car.getInsideCode());
212 232 }
213 233  
214 234 deviceId2NbbmMap = deviceId2Nbbm;
215 235 nbbm2CompanyCodeMap = nbbm2CompanyCode;
216 236 nbbm2FgsCompanyCodeMap = nbbm2FgsCompanyCode;
217 237 nbbmCompanyPlateMap =nbbmCompanyPlate;
  238 + plateCompanyNbbmMap =plateCompanyNbbm;
218 239 }
219 240  
220 241 /**
... ...
src/main/java/com/bsth/data/LineConfigData.java
... ... @@ -111,7 +111,7 @@ public class LineConfigData implements CommandLineRunner {
111 111 }
112 112  
113 113 public void set(LineConfig conf) {
114   - //lineConfigService.save(conf);
  114 +// lineConfigService.save(conf);
115 115 saveBuffers.add(conf);
116 116 setBuffer(conf);
117 117 }
... ...
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfoTag.java 0 → 100644
  1 +package com.bsth.entity.realcontrol;
  2 +
  3 +import java.util.Date;
  4 +
  5 +/**
  6 + * @author YouRuiFeng
  7 + * @Description: TODO(站点道闸给班次的标记类)
  8 + * @date 2021/2/23/023 15:03
  9 + */
  10 +public class ScheduleRealInfoTag {
  11 + // 路单ID
  12 + private Long realId;
  13 + // 站点道闸 进场业务ID
  14 + private String fBusIdIn;
  15 + // 站点道闸 出场业务ID
  16 + private String fBusIdOut;
  17 + // 实到 出场业务ID
  18 + private String fBusIdSd;
  19 + // 是否进场 1为进场
  20 + private int in;
  21 + // 进场时间戳
  22 + private Long inTime;
  23 + // 进场时间
  24 + private String inTimeStr;
  25 + // 是否进场 1为进场
  26 + private int out;
  27 + // 出场时间戳
  28 + private Long outTime;
  29 + // 出场时间
  30 + private String outTimeStr;
  31 + // 是否实到 1为进场
  32 + private int sdTag;
  33 + // 实到时间
  34 + private String sdTime;
  35 + // 车辆自编号
  36 + private String clZbh;
  37 + // 车牌号
  38 + private String carPlate;
  39 + // 线路编码
  40 + private String xlBm;
  41 + // 班次日期
  42 + private String scheduleDateStr;
  43 + // 创建日期 timestamp */
  44 + private Date createDate;
  45 + //修改日期 timestamp */
  46 + private Date updateDate;
  47 +
  48 + public Long getRealId() {
  49 + return realId;
  50 + }
  51 +
  52 + public void setRealId(Long realId) {
  53 + this.realId = realId;
  54 + }
  55 +
  56 + public String getfBusIdIn() {
  57 + return fBusIdIn;
  58 + }
  59 +
  60 + public void setfBusIdIn(String fBusIdIn) {
  61 + this.fBusIdIn = fBusIdIn;
  62 + }
  63 +
  64 + public String getfBusIdOut() {
  65 + return fBusIdOut;
  66 + }
  67 +
  68 + public void setfBusIdOut(String fBusIdOut) {
  69 + this.fBusIdOut = fBusIdOut;
  70 + }
  71 +
  72 + public String getfBusIdSd() {
  73 + return fBusIdSd;
  74 + }
  75 +
  76 + public void setfBusIdSd(String fBusIdSd) {
  77 + this.fBusIdSd = fBusIdSd;
  78 + }
  79 +
  80 + public int getIn() {
  81 + return in;
  82 + }
  83 +
  84 + public void setIn(int in) {
  85 + this.in = in;
  86 + }
  87 +
  88 + public Long getInTime() {
  89 + return inTime;
  90 + }
  91 +
  92 + public void setInTime(Long inTime) {
  93 + this.inTime = inTime;
  94 + }
  95 +
  96 + public String getInTimeStr() {
  97 + return inTimeStr;
  98 + }
  99 +
  100 + public void setInTimeStr(String inTimeStr) {
  101 + this.inTimeStr = inTimeStr;
  102 + }
  103 +
  104 + public int getOut() {
  105 + return out;
  106 + }
  107 +
  108 + public void setOut(int out) {
  109 + this.out = out;
  110 + }
  111 +
  112 + public Long getOutTime() {
  113 + return outTime;
  114 + }
  115 +
  116 + public void setOutTime(Long outTime) {
  117 + this.outTime = outTime;
  118 + }
  119 +
  120 + public String getOutTimeStr() {
  121 + return outTimeStr;
  122 + }
  123 +
  124 + public void setOutTimeStr(String outTimeStr) {
  125 + this.outTimeStr = outTimeStr;
  126 + }
  127 +
  128 + public int getSdTag() {
  129 + return sdTag;
  130 + }
  131 +
  132 + public void setSdTag(int sdTag) {
  133 + this.sdTag = sdTag;
  134 + }
  135 +
  136 + public String getSdTime() {
  137 + return sdTime;
  138 + }
  139 +
  140 + public void setSdTime(String sdTime) {
  141 + this.sdTime = sdTime;
  142 + }
  143 +
  144 + public String getClZbh() {
  145 + return clZbh;
  146 + }
  147 +
  148 + public void setClZbh(String clZbh) {
  149 + this.clZbh = clZbh;
  150 + }
  151 +
  152 + public String getCarPlate() {
  153 + return carPlate;
  154 + }
  155 +
  156 + public void setCarPlate(String carPlate) {
  157 + this.carPlate = carPlate;
  158 + }
  159 +
  160 + public String getXlBm() {
  161 + return xlBm;
  162 + }
  163 +
  164 + public void setXlBm(String xlBm) {
  165 + this.xlBm = xlBm;
  166 + }
  167 +
  168 + public String getScheduleDateStr() {
  169 + return scheduleDateStr;
  170 + }
  171 +
  172 + public void setScheduleDateStr(String scheduleDateStr) {
  173 + this.scheduleDateStr = scheduleDateStr;
  174 + }
  175 +
  176 + public Date getCreateDate() {
  177 + return createDate;
  178 + }
  179 +
  180 + public void setCreateDate(Date createDate) {
  181 + this.createDate = createDate;
  182 + }
  183 +
  184 + public Date getUpdateDate() {
  185 + return updateDate;
  186 + }
  187 +
  188 + public void setUpdateDate(Date updateDate) {
  189 + this.updateDate = updateDate;
  190 + }
  191 +}
... ...
src/main/java/com/bsth/filter/BaseFilter.java
... ... @@ -17,7 +17,7 @@ public abstract class BaseFilter implements Filter {
17 17 * 白名单
18 18 */
19 19 private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
20   - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT,Constants.XD_PAGE,Constants.FREE_URL,Constants.FREE_XD_CHILD_PAGES };
  20 + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS, Constants.STATIONSIGNO_URL, Constants.UP_RFID_URL, Constants.STATION_AND_SECTION_COUNT,Constants.XD_PAGE,Constants.FREE_URL,Constants.FREE_XD_CHILD_PAGES };
21 21  
22 22 @Override
23 23 public void destroy() {
... ...
src/main/java/com/bsth/security/WebSecurityConfig.java
... ... @@ -36,7 +36,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
36 36 public void configure(WebSecurity web) throws Exception {
37 37 // 白名单
38 38 web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA,
39   - Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT);
  39 + Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.STATIONSIGNO_URL, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT);
40 40 }
41 41  
42 42 @Override
... ...
src/main/java/com/bsth/security/filter/LoginInterceptor.java
... ... @@ -33,7 +33,7 @@ public class LoginInterceptor implements Filter {
33 33 * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证
34 34 */
35 35 private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE,
36   - Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT,Constants.XD_PAGE,Constants.FREE_URL,Constants.FREE_XD_CHILD_PAGES };
  36 + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.STATIONSIGNO_URL, Constants.UP_RFID_URL,Constants.STATION_AND_SECTION_COUNT,Constants.XD_PAGE,Constants.FREE_URL,Constants.FREE_XD_CHILD_PAGES };
37 37  
38 38  
39 39 @Override
... ...
src/main/java/com/bsth/service/directive/DirectiveService.java
... ... @@ -6,7 +6,9 @@ import com.bsth.entity.directive.D64;
6 6 import com.bsth.entity.directive.D80;
7 7 import com.bsth.entity.directive.DC0_A3;
8 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import com.bsth.entity.realcontrol.ScheduleRealInfoTag;
9 10 import com.bsth.service.BaseService;
  11 +import org.springframework.web.bind.annotation.RequestParam;
10 12  
11 13 import java.util.List;
12 14 import java.util.Map;
... ... @@ -97,4 +99,8 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
97 99 //int stateChange(String nbbm, Integer upDown, Integer state, String userName);
98 100  
99 101 Map<String,Object> deviceCofigList(Map<String, String> map, int page, int size);
  102 +
  103 + Map<String,Object> stationSigno(Map<String, Object> map);
  104 +
  105 + List<ScheduleRealInfoTag> tagByLines(String lines);
100 106 }
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -11,10 +11,12 @@ import com.bsth.data.gpsdata_v2.GpsRealData;
11 11 import com.bsth.data.gpsdata_v2.entity.GpsEntity;
12 12 import com.bsth.data.pilot80.PilotReport;
13 13 import com.bsth.data.schedule.DayOfSchedule;
  14 +import com.bsth.data.schedule.edit_logs.service.dto.SchEditInfoDto;
14 15 import com.bsth.data.utils.ListFilterUtils;
15 16 import com.bsth.data.utils.ListPageQueryUtils;
16 17 import com.bsth.entity.directive.*;
17 18 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  19 +import com.bsth.entity.realcontrol.ScheduleRealInfoTag;
18 20 import com.bsth.entity.sys.SysUser;
19 21 import com.bsth.repository.directive.D60Repository;
20 22 import com.bsth.repository.directive.D64Repository;
... ... @@ -23,9 +25,11 @@ import com.bsth.security.util.SecurityUtils;
23 25 import com.bsth.service.directive.dto.DeviceConfigDto;
24 26 import com.bsth.service.impl.BaseServiceImpl;
25 27 import com.bsth.websocket.handler.RealControlSocketHandler;
  28 +import com.bsth.websocket.handler.SendUtils;
26 29 import com.fasterxml.jackson.core.JsonProcessingException;
27 30 import com.fasterxml.jackson.databind.ObjectMapper;
28 31 import com.google.common.base.Splitter;
  32 +import com.google.common.collect.Lists;
29 33 import org.apache.commons.lang3.StringEscapeUtils;
30 34 import org.apache.commons.lang3.StringUtils;
31 35 import org.joda.time.format.DateTimeFormat;
... ... @@ -35,8 +39,12 @@ import org.slf4j.LoggerFactory;
35 39 import org.springframework.beans.factory.annotation.Autowired;
36 40 import org.springframework.jdbc.core.BeanPropertyRowMapper;
37 41 import org.springframework.jdbc.core.JdbcTemplate;
  42 +import org.springframework.jdbc.core.RowMapper;
38 43 import org.springframework.stereotype.Service;
  44 +import org.springframework.web.bind.annotation.RequestParam;
39 45  
  46 +import java.sql.ResultSet;
  47 +import java.sql.SQLException;
40 48 import java.util.*;
41 49  
42 50 @Service
... ... @@ -71,6 +79,12 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
71 79 @Autowired
72 80 JdbcTemplate jdbcTemplate;
73 81  
  82 + @Autowired
  83 + BasicData basicData;
  84 +
  85 + @Autowired
  86 + SendUtils sendUtils;
  87 +
74 88 //static Long schDiff = 1000 * 60 * 60L;
75 89  
76 90 private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm"), fmtHHmm_CN = DateTimeFormat.forPattern("HH点mm分");
... ... @@ -574,4 +588,272 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
574 588 }
575 589 return rs;
576 590 }
  591 +
  592 + @Override
  593 + public Map<String,Object> stationSigno(Map<String, Object> map) {
  594 + Map<String, Object> rs = new HashMap<>();
  595 + try {
  596 + StationSigno stationSigno = new StationSigno();
  597 +
  598 + String fPlateCode = map.get("fPlateCode")==null?"":map.get("fPlateCode").toString();
  599 + String fBusID = map.get("fBusID")==null?"":map.get("fBusID").toString();
  600 + Long fOutTime = map.get("fOutTime")==null?0:(Long.parseLong(map.get("fOutTime").toString())*1000);
  601 + int fIsOut = map.get("fIsOut")==null?0:Integer.parseInt(map.get("fIsOut").toString());
  602 + Long fInTime = map.get("fInTime")==null?0:(Long.parseLong(map.get("fInTime").toString())*1000);
  603 +// String fInPlate = map.get("fInPlate")==null?"":map.get("fInPlate").toString();
  604 +// String fInStatus = map.get("fInStatus")==null?"":map.get("fInStatus").toString();
  605 +// String fOutStatus = map.get("fOutStatus")==null?"":map.get("fOutStatus").toString();
  606 +// String fOutPlate = map.get("fOutPlate")==null?"":map.get("fOutPlate").toString();
  607 + if(fPlateCode.equals("")){
  608 + rs.put("code",-1);
  609 + rs.put("message","失败");
  610 + rs.put("info","车牌号为空");
  611 + return rs;
  612 + }
  613 + if(fPlateCode.indexOf("沪") != -1){
  614 + String cps1[] = fPlateCode.split("沪");
  615 + fPlateCode = "";
  616 + for (int i=0;i<cps1.length;i++){
  617 + fPlateCode += cps1[i];
  618 + }
  619 + }
  620 + if(fPlateCode.indexOf("-") != -1){
  621 + String cps1[] = fPlateCode.split("-");
  622 + fPlateCode = "";
  623 + for (int i=0;i<cps1.length;i++){
  624 + fPlateCode += cps1[i];
  625 + }
  626 + }
  627 +
  628 + ScheduleRealInfo sr = dayOfSchedule.executeCurr(basicData.plateCompanyNbbmMap.get(fPlateCode));
  629 + if(sr==null){
  630 + List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(basicData.plateCompanyNbbmMap.get(fPlateCode));
  631 + int size = list.size();
  632 +
  633 + // 班次完成10分钟内上传道闸消息,可以标记
  634 + Long time = 10*60*1000L;
  635 + for (int i = 0; i < size; i++) {
  636 + ScheduleRealInfo isr = list.get(i);
  637 + if (list.get(i).isDestroy())
  638 + continue;
  639 + if(fIsOut == 2 && Math.abs(isr.getFcsjT()-fOutTime)<time){
  640 + time = Math.abs(isr.getFcsjT()-fOutTime);
  641 + sr = isr;
  642 + }
  643 + if(fIsOut == 1 && Math.abs(isr.getZdsjT()-fInTime)<time){
  644 + time = Math.abs(isr.getZdsjT()-fInTime);
  645 + sr = isr;
  646 + }
  647 + }
  648 + if(sr==null){
  649 + rs.put("code",-1);
  650 + rs.put("message","失败");
  651 + rs.put("info","未找到车辆对应班次");
  652 + return rs;
  653 + }
  654 + }
  655 + ScheduleRealInfo prevSr = dayOfSchedule.prev(sr);
  656 + ScheduleRealInfo nextSr = dayOfSchedule.next(sr);
  657 +
  658 + boolean isMatch = false;
  659 + ScheduleRealInfo matchSr = null;
  660 + String inTimeStr ="",outTimeStr="";
  661 + /**
  662 + fIsOut 1:进场 2:出场
  663 + * 进场 如果道闸信息先发,则为当前班次, 道闸信息后发,则为上一个班次信息
  664 + *
  665 + * 出场 如果道闸信息先发,则为下一个班次信息, 道闸信息后发,则为当前班次
  666 + *
  667 + * 到达时间接近那个班次的进场/出场判定为这个班次
  668 + */
  669 + if (fIsOut == 1 && fInTime != 0) {
  670 + if(prevSr == null || (Math.abs((sr.getDfsjT()- fInTime)) < Math.abs((prevSr.getDfsjT()- fInTime)))){
  671 + isMatch = true;
  672 + matchSr = sr;
  673 + } else {//if(Math.abs((prevSr.getDfsjT())- fInTime) < 120)
  674 + isMatch = true;
  675 + matchSr = prevSr;
  676 + }
  677 + inTimeStr = fmtHHmm.print(fInTime);
  678 + } else if (fIsOut == 2 && fOutTime != 0) {
  679 + if(nextSr == null || (Math.abs((sr.getDfsjT()- fOutTime)) < Math.abs((nextSr.getDfsjT()- fOutTime)))){
  680 + isMatch = true;
  681 + matchSr = sr;
  682 + } else{ // if(Math.abs((nextSr.getDfsjT())- fInTime) < 120)
  683 + isMatch = true;
  684 + matchSr = nextSr;
  685 + }
  686 + outTimeStr = fmtHHmm.print(fOutTime);
  687 + }
  688 + if(isMatch){
  689 + ScheduleRealInfoTag tag = new ScheduleRealInfoTag();
  690 + Long real_id = matchSr.getId();
  691 + String lineCode = matchSr.getXlBm();
  692 + String dateStr = matchSr.getScheduleDateStr();
  693 + List<ScheduleRealInfoTag> tagList = jdbcTemplate.query("select * from bsth_c_s_sp_info_real_tag where real_id = "+real_id, new RowMapper<ScheduleRealInfoTag>() {
  694 + @Override
  695 + public ScheduleRealInfoTag mapRow(ResultSet resultSet, int i) throws SQLException {
  696 + ScheduleRealInfoTag srt = new ScheduleRealInfoTag();
  697 + srt.setRealId(resultSet.getLong("real_id"));
  698 + srt.setfBusIdIn(resultSet.getString("f_bus_id_in"));
  699 + srt.setfBusIdOut(resultSet.getString("f_bus_id_out"));
  700 + srt.setfBusIdSd(resultSet.getString("f_bus_id_sd"));
  701 + srt.setIn(resultSet.getInt("in"));
  702 + srt.setInTime(resultSet.getLong("in_time"));
  703 + srt.setInTimeStr(resultSet.getString("in_time_str"));
  704 + srt.setOut(resultSet.getInt("out"));
  705 + srt.setOutTime(resultSet.getLong("out_time"));
  706 + srt.setOutTimeStr(resultSet.getString("out_time_str"));
  707 + srt.setSdTag(resultSet.getInt("sd_tag"));
  708 + srt.setSdTime(resultSet.getString("sd_time"));
  709 + srt.setClZbh(resultSet.getString("cl_zbh"));
  710 + srt.setCarPlate(resultSet.getString("car_plate"));
  711 + srt.setXlBm(resultSet.getString("xl_bm"));
  712 + srt.setScheduleDateStr(resultSet.getString("schedule_date_str"));
  713 + return srt;
  714 + }
  715 + });
  716 + String sql;
  717 + if(tagList.size() > 0){
  718 + tag = tagList.get(0);
  719 + tag.setfBusIdIn(fBusID);
  720 + if(fIsOut==1){
  721 + sql = "UPDATE bsth_c_s_sp_info_real_tag set `in` = ? ,in_time=?,in_time_str=?,f_bus_id_in=? WHERE real_id=?";
  722 + jdbcTemplate.update(sql,1,fInTime,inTimeStr,fBusID,real_id);
  723 + tag.setIn(1);
  724 + tag.setfBusIdIn(fInTime.toString());
  725 + tag.setInTimeStr(inTimeStr);
  726 + } else if(fIsOut==2){
  727 + sql = "UPDATE bsth_c_s_sp_info_real_tag set `out` =?,out_time=?,out_time_str=?,f_bus_id_out=? WHERE real_id=?";
  728 + jdbcTemplate.update(sql,1,fOutTime,outTimeStr,fBusID,real_id);
  729 + tag.setOut(1);
  730 + tag.setOutTime(fOutTime);
  731 + tag.setOutTimeStr(outTimeStr);
  732 + }
  733 + } else{
  734 + tag.setRealId(real_id);
  735 + tag.setfBusIdIn(fBusID);
  736 + tag.setClZbh(matchSr.getClZbh());
  737 + tag.setCarPlate(fPlateCode);
  738 + tag.setXlBm(lineCode);
  739 + tag.setScheduleDateStr(dateStr);
  740 + if(fIsOut==1){
  741 + sql = "INSERT INTO bsth_c_s_sp_info_real_tag (real_id,`in`,in_time,in_time_str,cl_zbh,car_plate,f_bus_id_in,xl_bm,schedule_date_str)VALUES (?,?,?,?,?,?,?,?,?)";
  742 + jdbcTemplate.update(sql,real_id,1,fInTime,inTimeStr,matchSr.getClZbh(),fPlateCode,fBusID,lineCode,dateStr);
  743 + tag.setIn(1);
  744 + tag.setfBusIdIn(fInTime.toString());
  745 + tag.setInTimeStr(inTimeStr);
  746 + } else if(fIsOut==2){
  747 + sql = "INSERT INTO bsth_c_s_sp_info_real_tag (real_id,`out`,out_time,out_time_str,cl_zbh,car_plate,f_bus_id_out,xl_bm,schedule_date_str)VALUES (?,?,?,?,?,?,?,?,?)";
  748 + jdbcTemplate.update(sql,real_id,1,fOutTime,outTimeStr,matchSr.getClZbh(),fPlateCode,fBusID,lineCode,dateStr);
  749 + tag.setOut(1);
  750 + tag.setOutTime(fOutTime);
  751 + tag.setOutTimeStr(outTimeStr);
  752 + }
  753 + }
  754 + sendUtils.stationSigno(tag);
  755 +
  756 + // 进场班次,匹配的下一个班次中放实到字段内容
  757 + ScheduleRealInfo mNextSr = dayOfSchedule.next(matchSr);
  758 + if(fIsOut==1 && mNextSr != null){
  759 + ScheduleRealInfoTag tagNext = new ScheduleRealInfoTag();
  760 + Long nextId = mNextSr.getId();
  761 +// int haveNext = jdbcTemplate.queryForObject("select count(*) from bsth_c_s_sp_info_real_tag where real_id = "+nextId,Integer.class);
  762 + List<ScheduleRealInfoTag> tagNextList = jdbcTemplate.query("select * from bsth_c_s_sp_info_real_tag where real_id = "+nextId, new RowMapper<ScheduleRealInfoTag>() {
  763 + @Override
  764 + public ScheduleRealInfoTag mapRow(ResultSet resultSet, int i) throws SQLException {
  765 + ScheduleRealInfoTag srt = new ScheduleRealInfoTag();
  766 + srt.setRealId(resultSet.getLong("real_id"));
  767 + srt.setfBusIdIn(resultSet.getString("f_bus_id_in"));
  768 + srt.setfBusIdOut(resultSet.getString("f_bus_id_out"));
  769 + srt.setfBusIdSd(resultSet.getString("f_bus_id_sd"));
  770 + srt.setIn(resultSet.getInt("in"));
  771 + srt.setInTime(resultSet.getLong("in_time"));
  772 + srt.setInTimeStr(resultSet.getString("in_time_str"));
  773 + srt.setOut(resultSet.getInt("out"));
  774 + srt.setOutTime(resultSet.getLong("out_time"));
  775 + srt.setOutTimeStr(resultSet.getString("out_time_str"));
  776 + srt.setSdTag(resultSet.getInt("sd_tag"));
  777 + srt.setSdTime(resultSet.getString("sd_time"));
  778 + srt.setClZbh(resultSet.getString("cl_zbh"));
  779 + srt.setCarPlate(resultSet.getString("car_plate"));
  780 + srt.setXlBm(resultSet.getString("xl_bm"));
  781 + srt.setScheduleDateStr(resultSet.getString("schedule_date_str"));
  782 + return srt;
  783 + }
  784 + });
  785 +
  786 + if (tagNextList.size() < 1) {
  787 + sql = "INSERT INTO bsth_c_s_sp_info_real_tag (real_id,sd_tag,sd_time,cl_zbh,car_plate,f_bus_id_sd,xl_bm,schedule_date_str)VALUES (?,?,?,?,?,?,?,?)";
  788 + jdbcTemplate.update(sql,nextId,1,inTimeStr,matchSr.getClZbh(),fPlateCode,fBusID,lineCode,dateStr);
  789 + tagNext.setClZbh(matchSr.getClZbh());
  790 + tagNext.setCarPlate(fPlateCode);
  791 + tagNext.setXlBm(lineCode);
  792 + tagNext.setScheduleDateStr(dateStr);
  793 + } else{
  794 + sql = "UPDATE bsth_c_s_sp_info_real_tag set sd_tag = ? ,sd_time=?,f_bus_id_sd=? WHERE real_id=?";
  795 + jdbcTemplate.update(sql,1,inTimeStr,fBusID,nextId);
  796 + tagNext = tagNextList.get(0);
  797 + }
  798 + tagNext.setRealId(nextId);
  799 + tagNext.setfBusIdIn(fBusID);
  800 + tagNext.setSdTag(1);
  801 + tagNext.setSdTime(inTimeStr);
  802 +
  803 + sendUtils.stationSigno(tagNext);
  804 + }
  805 +
  806 + rs.put("code",0);
  807 + rs.put("message","成功");
  808 + return rs;
  809 + } else {
  810 + rs.put("code",-1);
  811 + rs.put("message","失败");
  812 + rs.put("info","未找到车辆对应班次");
  813 + return rs;
  814 + }
  815 + } catch (Exception e) {
  816 + e.printStackTrace();
  817 + logger.error("", e);
  818 + rs.put("code",-1);
  819 + rs.put("message","失败");
  820 + return rs;
  821 + }
  822 + }
  823 +
  824 + @Override
  825 + public List<ScheduleRealInfoTag> tagByLines(String lines) {
  826 + List<ScheduleRealInfoTag> list = new ArrayList<>();
  827 + List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines));
  828 + String day = DayOfSchedule.currSchDateMap.get(lineList.get(0));
  829 + try{
  830 + list = jdbcTemplate.query("select * from bsth_c_s_sp_info_real_tag where xl_bm in (?) and schedule_date_str = ? ", new RowMapper<ScheduleRealInfoTag>() {
  831 + @Override
  832 + public ScheduleRealInfoTag mapRow(ResultSet resultSet, int i) throws SQLException {
  833 + ScheduleRealInfoTag srt = new ScheduleRealInfoTag();
  834 + srt.setRealId(resultSet.getLong("real_id"));
  835 + srt.setfBusIdIn(resultSet.getString("f_bus_id_in"));
  836 + srt.setfBusIdOut(resultSet.getString("f_bus_id_out"));
  837 + srt.setfBusIdSd(resultSet.getString("f_bus_id_sd"));
  838 + srt.setIn(resultSet.getInt("in"));
  839 + srt.setInTime(resultSet.getLong("in_time"));
  840 + srt.setInTimeStr(resultSet.getString("in_time_str"));
  841 + srt.setOut(resultSet.getInt("out"));
  842 + srt.setOutTime(resultSet.getLong("out_time"));
  843 + srt.setOutTimeStr(resultSet.getString("out_time_str"));
  844 + srt.setSdTag(resultSet.getInt("sd_tag"));
  845 + srt.setSdTime(resultSet.getString("sd_time"));
  846 + srt.setClZbh(resultSet.getString("cl_zbh"));
  847 + srt.setCarPlate(resultSet.getString("car_plate"));
  848 + srt.setXlBm(resultSet.getString("xl_bm"));
  849 + srt.setScheduleDateStr(resultSet.getString("schedule_date_str"));
  850 + return srt;
  851 + }
  852 + }, lines, day);
  853 + }catch (Exception e){
  854 + logger.error(e.toString(),e);
  855 + return null;
  856 + }
  857 + return list;
  858 + }
577 859 }
... ...
src/main/java/com/bsth/websocket/handler/SendUtils.java
... ... @@ -7,6 +7,7 @@ import com.bsth.data.gpsdata_v2.entity.GpsEntity;
7 7 import com.bsth.data.safe_driv.SafeDriv;
8 8 import com.bsth.entity.directive.D80;
9 9 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  10 +import com.bsth.entity.realcontrol.ScheduleRealInfoTag;
10 11 import com.bsth.websocket.dto.WsScheduleRealInfo;
11 12 import com.fasterxml.jackson.core.JsonProcessingException;
12 13 import com.fasterxml.jackson.databind.ObjectMapper;
... ... @@ -125,7 +126,7 @@ public class SendUtils{
125 126  
126 127 Map<String, Object> map = new HashMap<>();
127 128 map.put("fn", "directive");
128   - map.put("t", WsScheduleRealInfo.getInstance(sch));;
  129 + map.put("t", WsScheduleRealInfo.getInstance(sch));
129 130  
130 131 ObjectMapper mapper = new ObjectMapper();
131 132  
... ... @@ -135,6 +136,25 @@ public class SendUtils{
135 136 logger.error("", e);
136 137 }
137 138 }
  139 + /**
  140 + *
  141 + * @Title: sendDirectiveToPage
  142 + * @Description: TODO(调度指令状态推送)
  143 + */
  144 + public void stationSigno(ScheduleRealInfoTag tag) {
  145 +
  146 + Map<String, Object> map = new HashMap<>();
  147 + map.put("fn", "stationSigno");
  148 + map.put("tag", tag);
  149 +
  150 + ObjectMapper mapper = new ObjectMapper();
  151 +
  152 + try {
  153 + socketHandler.sendMessageToLine(tag.getXlBm(), mapper.writeValueAsString(map));
  154 + } catch (JsonProcessingException e) {
  155 + logger.error("", e);
  156 + }
  157 + }
138 158  
139 159 public void send80ToPage(D80 d80) {
140 160 d80.getData().setNbbm(BasicData.deviceId2NbbmMap.get(d80.getDeviceId()));
... ...
src/main/resources/static/pages/control/line/js/webSocketHandle.js
... ... @@ -106,6 +106,9 @@ var msgHandle = {
106 106 }
107 107 $tr.find('td[data-name=clZbh]').attr('class', clazz);
108 108 },
  109 + // 站点道闸
  110 + // stationSigno: function(msg){
  111 + // },
109 112 refresh: function(msg){
110 113 //刷新
111 114 layer.msg('正在切换到 ' + msg.dateStr + '数据', {icon: 16, shade: 0.6, time: 0});
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/badge_tooltip.html
... ... @@ -81,4 +81,20 @@
81 81 </div>
82 82 </div>
83 83 </script>
  84 +
  85 +
  86 + <script id="sch-table-signo-sd-tootip-temp" type="text/html">
  87 + <div class="tl-tip-panel">
  88 + <div style="font-size: 13px;">
  89 + {{sd_time}}道闸
  90 + </div>
  91 + </div>
  92 + </script>
  93 + <script id="sch-table-signo-sf-tootip-temp" type="text/html">
  94 + <div class="tl-tip-panel">
  95 + <div style="font-size: 13px;">
  96 + {{sf_time}}道闸
  97 + </div>
  98 + </div>
  99 + </script>
84 100 </div>
... ...
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
... ... @@ -67,7 +67,12 @@
67 67 {{sch.clZbh}}
68 68 </dd>
69 69 <dd>{{sch.qdzArrDatejh}}</dd>
70   - <dd class="qdzArrDatesjDD"><span class="qdzArrDatesjSPAN">{{sch.qdzArrDatesj}}</span><span class="arrsj-diff">{{sch.arrsj_diff}}</span></dd>
  70 + <dd class="qdzArrDatesjDD">
  71 + <span class="qdzArrDatesjSPAN">{{sch.qdzArrDatesj}}</span><span class="arrsj-diff">{{sch.arrsj_diff}}</span>
  72 + {{if sch.sd_tag == 1}}
  73 + <i class="uk-icon-info-circle uk-icon-hover station_signo_sd" style="color: #000;"></i>
  74 + {{/if}}
  75 + </dd>
71 76 <dd data-sort-val={{sch.fcsjT}}>
72 77 {{sch.fcsj}}
73 78 {{if sch.bcType == "out"}}
... ... @@ -112,6 +117,9 @@
112 117 tl-wd
113 118 {{/if}} fcsjActualCell">
114 119 {{sch.fcsjActual}}<span class="fcsj-diff">{{sch.fcsj_diff}}</span>
  120 + {{if sch.sf_tag == 1}}
  121 + <i class="uk-icon-info-circle uk-icon-hover station_signo_sf" style="color: #000;"></i>
  122 + {{/if}}
115 123 </dd>
116 124 <dd data-uk-observe>
117 125  
... ... @@ -152,6 +160,16 @@
152 160 </dd>
153 161 </script>
154 162  
  163 +
  164 + <script id="line-schedule-sdsj-temp" type="text/html">
  165 + <dd class="qdzArrDatesjDD">
  166 + <span class="qdzArrDatesjSPAN">{{qdzArrDatesj}}</span><span class="arrsj-diff">{{arrsj_diff}}</span>
  167 + {{if sd_tag == 1}}
  168 + <i class="uk-icon-info-circle uk-icon-hover station_signo_sd" style="color: #000;"></i>
  169 + {{/if}}
  170 + </dd>
  171 + </script>
  172 +
155 173 <script id="line-schedule-sfsj-temp" type="text/html">
156 174 <dd data-uk-observe class="
157 175 {{if status==-1}}
... ... @@ -164,6 +182,9 @@
164 182 tl-wd
165 183 {{/if}} fcsjActualCell">
166 184 {{fcsjActual}}<span class="fcsj-diff">{{fcsj_diff}}</span>
  185 + {{if sf_tag == 1}}
  186 + <i class="uk-icon-info-circle uk-icon-hover station_signo_sf" style="color: #000;"></i>
  187 + {{/if}}
167 188 </dd>
168 189 </script>
169 190  
... ...
src/main/resources/static/real_control_v2/js/line_schedule/badge_tooltip.js
... ... @@ -192,4 +192,39 @@ var gb_schedule_badge_tootip = (function () {
192 192 events: _opts.events
193 193 });
194 194 });
  195 +
  196 + //实到道闸 tootip
  197 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .station_signo_sd', function() {
  198 + $(this).qtip({
  199 + show: _opts.show,
  200 + content: {
  201 + text: function() {
  202 + return temps['sch-table-signo-sd-tootip-temp'](getSch(this));
  203 + }
  204 + },
  205 + position: _opts.position,
  206 + style: {
  207 + classes: 'qtip-youtube sch-badge-tip'
  208 + },
  209 + hide: _opts.hide,
  210 + events: _opts.events
  211 + });
  212 + });
  213 + //实发道闸 tootip
  214 + $(document).on('mouseenter', '.schedule-wrap .ct_table_body .station_signo_sf', function() {
  215 + $(this).qtip({
  216 + show: _opts.show,
  217 + content: {
  218 + text: function() {
  219 + return temps['sch-table-signo-sf-tootip-temp'](getSch(this));
  220 + }
  221 + },
  222 + position: _opts.position,
  223 + style: {
  224 + classes: 'qtip-youtube sch-badge-tip'
  225 + },
  226 + hide: _opts.hide,
  227 + events: _opts.events
  228 + });
  229 + });
195 230 })();
196 231 \ No newline at end of file
... ...
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
... ... @@ -32,25 +32,39 @@ var gb_schedule_table = (function () {
32 32 $.get('/realSchedule/lines', {
33 33 lines: gb_data_basic.line_idx
34 34 }, function (rs) {
35   - for (var lineCode in rs) {
36   - line2Schedule[lineCode] = {};
37   -
38   - //排序
39   - rs[lineCode].sort(schedule_sort);
40   - //calc shift
41   - $.each(rs[lineCode], function () {
42   - if(this.status==-1)
43   - clearActualTime(this);
44   - calc_sch_real_shift(this);
45   - wfydcolor(this);
46   - line2Schedule[lineCode][this.id] = this;
47   - //子任务公里是否与计划平
48   - this.c_t_mileage_status = calcCTaskMileageStatus(this);
  35 + $.get('/control/tagByLines',{lines: gb_data_basic.line_idx},function (tagList) {
  36 + var tagMap = new Map();
  37 + $.each(tagList,function (i, tag) {
  38 + tagMap.set(tag.realId,tag);
49 39 });
50   - //计算应发未发
51   - calc_yfwf_num(lineCode);
52   - }
53   - ep.emit('data', rs);
  40 + for (var lineCode in rs) {
  41 + line2Schedule[lineCode] = {};
  42 +
  43 + //排序
  44 + rs[lineCode].sort(schedule_sort);
  45 + //calc shift
  46 + $.each(rs[lineCode], function () {
  47 + if(this.status==-1)
  48 + clearActualTime(this);
  49 + var tag = tagMap.get(this.id);
  50 + if(tag){
  51 + this.sd_tag = tag.sdTag;
  52 + this.sd_time = tag.sdTime;
  53 + this.sf_tag = tag.out;
  54 + this.sf_time = tag.outTimeStr;
  55 + }
  56 + calc_sch_real_shift(this);
  57 + wfydcolor(this);
  58 + line2Schedule[lineCode][this.id] = this;
  59 + //子任务公里是否与计划平
  60 + this.c_t_mileage_status = calcCTaskMileageStatus(this);
  61 + });
  62 + //计算应发未发
  63 + calc_yfwf_num(lineCode);
  64 + }
  65 + ep.emit('data', rs);
  66 + });
  67 +
54 68 });
55 69  
56 70 //加载班次表格渲染模板
... ... @@ -281,13 +295,26 @@ var gb_schedule_table = (function () {
281 295 line2Schedule[lineCode] = {};
282 296 }
283 297 else{
284   - //排序
285   - rs[lineCode].sort(schedule_sort);
286   - line2Schedule[lineCode] = {};
287   - //calc shift
288   - $.each(rs[lineCode], function () {
289   - calc_sch_real_shift(this);
290   - line2Schedule[lineCode][this.id] = this;
  298 + $.get('/control/tagByLines',{lines: lineCode},function (tagList) {
  299 + var tagMap = new Map();
  300 + $.each(tagList, function (i, tag) {
  301 + tagMap.set(tag.realId, tag);
  302 + });
  303 + //排序
  304 + rs[lineCode].sort(schedule_sort);
  305 + line2Schedule[lineCode] = {};
  306 + //calc shift
  307 + $.each(rs[lineCode], function () {
  308 + var tag = tagMap.get(this.id);
  309 + if(tag){
  310 + this.sd_tag = tag.sdTag;
  311 + this.sd_time = tag.sdTime;
  312 + this.sf_tag = tag.out;
  313 + this.sf_time = tag.outTimeStr;
  314 + }
  315 + calc_sch_real_shift(this);
  316 + line2Schedule[lineCode][this.id] = this;
  317 + });
291 318 });
292 319 }
293 320 //计算应发未发
... ... @@ -338,6 +365,25 @@ var gb_schedule_table = (function () {
338 365 markerLastByNbbm(ts[0], ts[1]);
339 366 }*/
340 367 };
  368 + /**
  369 + * 更新班次站点道闸
  370 + * @param sch
  371 + */
  372 + var updateScheduleSigno = function (tag) {
  373 + if(tag){
  374 + var sch = line2Schedule[tag.xlBm][tag.realId];
  375 + if(tag.sdTag == 1){
  376 + sch.sd_tag = tag.sdTag;
  377 + sch.sd_time = tag.sdTime;
  378 + } else if(tag.out == 1){
  379 + sch.sf_tag = tag.out;
  380 + sch.sf_time = tag.outTimeStr;
  381 + }
  382 + line2Schedule[tag.xlBm][sch.id] = sch;
  383 + updateDom(sch);
  384 + }
  385 +
  386 + };
341 387  
342 388  
343 389 /**
... ... @@ -367,7 +413,11 @@ var gb_schedule_table = (function () {
367 413 //车辆双击
368 414 gb_schedule_table_dbclick.carCellClick($newDds2);
369 415 $(dds[3]).text(sch.qdzArrDatejh ? sch.qdzArrDatejh : '');
370   - $(dds[4]).text(sch.qdzArrDatesj ? sch.qdzArrDatesj : '');
  416 + // $(dds[4]).text(sch.qdzArrDatesj ? sch.qdzArrDatesj : '');
  417 +
  418 + // 实到时间
  419 + var d4html = $(temps['line-schedule-sdsj-temp'](sch));
  420 + $(dds[4]).replaceWith(d4html);
371 421  
372 422 //计发时间
373 423 var d5html = temps['line-schedule-fcsj-temp'](sch);
... ... @@ -884,6 +934,7 @@ var gb_schedule_table = (function () {
884 934 show: show,
885 935 findScheduleByLine: findScheduleByLine,
886 936 updateSchedule: updateSchedule,
  937 + updateScheduleSigno: updateScheduleSigno,
887 938 updateData: updateData,
888 939 deheteSchedule: deheteSchedule,
889 940 insertSchedule: insertSchedule,
... ...
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
... ... @@ -181,6 +181,10 @@ var gb_sch_websocket = (function () {
181 181 var directiveStatus = function (msg) {
182 182 gb_schedule_table.updateSchedule(msg.t);
183 183 };
  184 + //指令状态改变
  185 + var stationSigno = function (msg) {
  186 + gb_schedule_table.updateScheduleSigno(msg.tag);
  187 + };
184 188  
185 189 //班次信号状态
186 190 var signalState = function (msg) {
... ... @@ -194,6 +198,7 @@ var gb_sch_websocket = (function () {
194 198 refreshSch: refreshSch,
195 199 d80Confirm: d80Confirm,
196 200 directive: directiveStatus,
  201 + stationSigno: stationSigno,
197 202 signal_state: signalState,
198 203 deviceOffline: deviceOffline,
199 204 safeDriv: safeDriv,
... ...