Commit f16d9decd4419b74960cc8b4af29fad03de7ea53

Authored by 徐烜
2 parents 04e74994 dc0d588d

Update

Too many changes to show.

To preserve performance only 9 of 21 files are displayed.

src/main/java/com/bsth/controller/realcontrol/RealMapController.java
1 1 package com.bsth.controller.realcontrol;
2 2  
  3 +import com.bsth.data.gpsdata.arrival.GeoCacheData;
  4 +import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute;
3 5 import com.bsth.service.realcontrol.RealMapService;
4 6 import org.springframework.beans.factory.annotation.Autowired;
5 7 import org.springframework.web.bind.annotation.RequestMapping;
  8 +import org.springframework.web.bind.annotation.RequestMethod;
6 9 import org.springframework.web.bind.annotation.RequestParam;
7 10 import org.springframework.web.bind.annotation.RestController;
8 11  
... ... @@ -74,4 +77,9 @@ public class RealMapController {
74 77 public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx){
75 78 return realMapService.multiSectionRoute(codeIdx);
76 79 }
  80 +
  81 + @RequestMapping(value = "/lockAndFlxedTimeEnabled", method = RequestMethod.POST)
  82 + public void lockAndFlxedTimeEnabled(TimedEnableStationRoute tes){
  83 + GeoCacheData.tesMap.put(tes.getLineCode(), tes);
  84 + }
77 85 }
... ...
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
... ... @@ -102,7 +102,7 @@ public class anomalyCheckController {
102 102 }
103 103  
104 104 @RequestMapping(value = "/findSchByLpName")
105   - public List<ScheduleRealInfo> findSchByLpName(String lpName){
  105 + public List<ScheduleRealInfo> findSchByLpName(@RequestParam String lpName){
106 106 return dayOfSchedule.getLpScheduleMap().get(lpName);
107 107 }
108 108 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
... ... @@ -2,6 +2,7 @@ package com.bsth.data.gpsdata.arrival;
2 2  
3 3 import com.bsth.data.gpsdata.GpsEntity;
4 4 import com.bsth.data.gpsdata.arrival.entity.StationRoute;
  5 +import com.bsth.data.gpsdata.arrival.entity.TimedEnableStationRoute;
5 6 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 7 import com.bsth.data.gpsdata.arrival.utils.StationRouteComp;
7 8 import com.google.common.collect.ArrayListMultimap;
... ... @@ -53,6 +54,10 @@ public class GeoCacheData {
53 54 //线路限速信息
54 55 private static Map<String, Double> speedLimitMap;
55 56  
  57 + //需要定时刷新的站点路由
  58 + public static Map<String, TimedEnableStationRoute> tesMap = new HashMap<>();
  59 + //TimedEnableStationRoute
  60 +
56 61 @Autowired
57 62 JdbcTemplate jdbcTemplate;
58 63  
... ... @@ -282,6 +287,28 @@ public class GeoCacheData {
282 287 connectStationRoute(tempMap.get(key));
283 288 }
284 289  
  290 + //定时启用的站点走向
  291 + if(tesMap.size() > 0){
  292 + List<String> rems = new ArrayList<>();
  293 + long t = System.currentTimeMillis();
  294 + for(TimedEnableStationRoute tes : tesMap.values()){
  295 + if(tes.getEnableTime() > t){
  296 + logger.info("锁住站点路由," + tes.getLineCode());
  297 + tempMap.replaceValues(tes.getLineCode() + "_0", stationCacheMap.get(tes.getLineCode() + "_0"));
  298 + tempMap.replaceValues(tes.getLineCode() + "_1", stationCacheMap.get(tes.getLineCode() + "_1"));
  299 + }
  300 + else
  301 + rems.add(tes.getLineCode());
  302 + }
  303 +
  304 + //remove
  305 + if(rems.size() > 0){
  306 + for(String lineCode : rems){
  307 + logger.info("启用路由," + lineCode);
  308 + tesMap.remove(lineCode);
  309 + }
  310 + }
  311 + }
285 312 stationCacheMap = tempMap;
286 313 routeCodeMap = codeMap;
287 314 }
... ...
src/main/java/com/bsth/data/gpsdata/arrival/entity/TimedEnableStationRoute.java 0 → 100644
  1 +package com.bsth.data.gpsdata.arrival.entity;
  2 +
  3 +/**
  4 + * 定时启用站点路由
  5 + * Created by panzhao on 2017/8/28.
  6 + */
  7 +public class TimedEnableStationRoute {
  8 +
  9 + private String lineCode;
  10 +
  11 + private Long enableTime;
  12 +
  13 + public String getLineCode() {
  14 + return lineCode;
  15 + }
  16 +
  17 + public void setLineCode(String lineCode) {
  18 + this.lineCode = lineCode;
  19 + }
  20 +
  21 + public Long getEnableTime() {
  22 + return enableTime;
  23 + }
  24 +
  25 + public void setEnableTime(Long enableTime) {
  26 + this.enableTime = enableTime;
  27 + }
  28 +}
... ...
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
... ... @@ -278,12 +278,14 @@ public class DayOfSchedule {
278 278 List<String> lprms = new ArrayList<>();
279 279 Set<String> lps = lpScheduleMap.keySet();
280 280 for (String lp : lps) {
281   - if (lp.indexOf(lineCode + "_") != -1)
  281 + if (lp.startsWith(lineCode + "_"))
282 282 lprms.add(lp);
283 283 }
284 284  
285   - for (String lp : lprms)
  285 + for (String lp : lprms){
  286 + logger.info("清理路牌映射 " + lp);
286 287 lpScheduleMap.removeAll(lp);
  288 + }
287 289  
288 290 logger.info(lineCode + "排班清理 " + count);
289 291 }
... ...
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
... ... @@ -117,8 +117,7 @@ public class SchAttrCalculator {
117 117 for(int i = 1; i < len; i ++){
118 118 curr = list.get(i);
119 119  
120   - if(prve.getZdzName().equals(curr.getQdzName())
121   - || prve.getZdzCode().equals(curr.getQdzCode())){
  120 + if(isJoin(prve, curr)){
122 121 curr.setQdzArrDatejh(prve.getZdsj());
123 122 if(StringUtils.isNotEmpty(prve.getZdsjActual()))
124 123 curr.setQdzArrDatesj(prve.getZdsjActual());
... ... @@ -126,6 +125,13 @@ public class SchAttrCalculator {
126 125 prve = curr;
127 126 }
128 127 }
  128 +
  129 + private boolean isJoin(ScheduleRealInfo prve, ScheduleRealInfo curr) {
  130 + return prve.getZdzName().equals(curr.getQdzName())//名称相等
  131 + || prve.getZdzCode().equals(curr.getQdzCode())//编码相等
  132 + || prve.getZdzName().startsWith(curr.getQdzName())//起始包括
  133 + || curr.getQdzName().startsWith(prve.getZdzName());//起始包括
  134 + }
129 135  
130 136 /**
131 137 *
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -139,19 +139,19 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
139 139  
140 140 //去掉了 xlBm is not null
141 141 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
142   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)")
  142 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.fcsj, lpName")
143 143 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
144 144  
145 145 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
146   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.dfsj")
  146 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm =?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.lpName, s.realExecDate,s.fcsj")
147 147 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
148 148  
149 149 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
150   - @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?3 and s.bcType not in ('in','out','ldks') order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)")
  150 + @Query(value="select DISTINCT s from ScheduleRealInfo s where gsBm like %?1% and fgsBm like %?2% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?3 and s.bcType not in ('in','out','ldks') order by s.xlDir,s.realExecDate,s.fcsj, s.lpName")
151 151 List<ScheduleRealInfo> scheduleByDateAndLineByGs(String gsdm,String fgsdm,String date);
152 152  
153 153 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
154   - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)")
  154 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.fcsj, s.lpName")
155 155 List<ScheduleRealInfo> scheduleByDateAndLineQp2(String line,String date);
156 156  
157 157 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
... ...
src/main/java/com/bsth/service/oil/impl/YlxxbServiceImpl.java
... ... @@ -45,23 +45,25 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
45 45 JdbcTemplate jdbcTemplate;
46 46 @Override
47 47 public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {
48   -
  48 +
49 49 String rq=map.get("yyrq").toString();
50 50 String gsdm=map.get("gsdm_like").toString();
51 51 String fgsdm=map.get("fgsdm_like").toString();
52   -
53   - String sql=" select * from ("
54   - + "select *,CONCAT(nbbm,jsy) as nj "
55   - + " from bsth_c_ylxxb where yyrq='"+rq+"' "
56   - + " and gsdm ='"+gsdm+"') x where x.nj not in ("
57   - + " select CONCAT(nbbm,jsy) from bsth_c_ylb "
58   - + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"'"
59   - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"')"
60   - + " and x.nbbm in (select nbbm from bsth_c_ylb "
61   - + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"'"
62   - + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"')";
63   -
64   -
  52 +
  53 + String sql=" select * from ("
  54 + + "select *,CONCAT(nbbm,jsy) as nj "
  55 + + " from bsth_c_ylxxb where yyrq='"+rq+"' "
  56 + + " and gsdm ='"+gsdm+"' and jylx ='0') x where x.nj not in ("
  57 + + " select CONCAT(nbbm,jsy) from bsth_c_ylb "
  58 + + " where rq='"+rq+"'"
  59 + + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"')"
  60 + + " and x.nbbm in (select nbbm from bsth_c_ylb "
  61 + + " where rq='"+rq+"'"
  62 + + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"') "
  63 + + " and x.nbbm not in (select nbbm from bsth_c_ylxxb"
  64 + + " where yyrq='"+rq+"' and gsdm ='"+gsdm+"' AND jylx ='1')";
  65 +
  66 +
65 67 /*String sql= "select v.*,u.jsy as ldgh from "
66 68 + " ( select * from bsth_c_ylxxb x where "
67 69 + " DATE_FORMAT(x.yyrq,'%Y-%m-%d')='"+rq+"' and x.gsdm='"+gsdm+"'"
... ... @@ -76,43 +78,43 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
76 78 + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"'"
77 79 + " and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"' ) u "
78 80 + " on v.nbbm=u.nbbm ";*/
79   -
  81 +
80 82 //根具条件查询指定日期Ylxxb的数据
81 83 // List<Ylxxb> iterator=repository.checkYlxx(rq,gsdm);
82 84 /*if(map.get("gsdm_in")!=null){
83 85 map.put("ssgsdm_in", map.get("gsdm_in"));
84 86 map.remove("gsdm_in");
85   -
  87 +
86 88 }else{
87 89 map.put("ssgsdm_like", map.get("gsdm_like"));
88 90 map.remove("gsdm_like");
89 91 }*/
90   -
  92 +
91 93 //根具条件查询指定日期Ylb的数据
92 94 // List<Ylb> ylbIterator=ylbRepository.checkYl(rq,gsdm,fgsdm);
93   - List<Ylxxb> list=jdbcTemplate.query(sql,
94   - new RowMapper<Ylxxb>(){
95   - @Override
96   - public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
97   - Ylxxb s = new Ylxxb();
98   - s.setId(rs.getInt("id"));
99   - s.setYyrq(rs.getDate("yyrq"));
100   - s.setNbbm(rs.getString("nbbm"));
101   - s.setGsdm(rs.getString("gsdm"));
102   - s.setFgsdm(rs.getString("fgsdm"));
103   - s.setJsy(rs.getString("jsy"));
104   - s.setJzl(rs.getDouble("jzl"));
105   - s.setStationid(rs.getString("stationid"));
106   - s.setNylx(rs.getInt("nylx"));
107   - s.setJyggh(rs.getString("jyggh"));
108   - s.setYj(rs.getDouble("yj"));
  95 + List<Ylxxb> list=jdbcTemplate.query(sql,
  96 + new RowMapper<Ylxxb>(){
  97 + @Override
  98 + public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
  99 + Ylxxb s = new Ylxxb();
  100 + s.setId(rs.getInt("id"));
  101 + s.setYyrq(rs.getDate("yyrq"));
  102 + s.setNbbm(rs.getString("nbbm"));
  103 + s.setGsdm(rs.getString("gsdm"));
  104 + s.setFgsdm(rs.getString("fgsdm"));
  105 + s.setJsy(rs.getString("jsy"));
  106 + s.setJzl(rs.getDouble("jzl"));
  107 + s.setStationid(rs.getString("stationid"));
  108 + s.setNylx(rs.getInt("nylx"));
  109 + s.setJyggh(rs.getString("jyggh"));
  110 + s.setYj(rs.getDouble("yj"));
109 111 // s.setLdgh(rs.getString("ldgh"));
110   - s.setBz(rs.getString("bz"));
111   - return s;
112   - }
113   - });
114   -
115   -
  112 + s.setBz(rs.getString("bz"));
  113 + return s;
  114 + }
  115 + });
  116 +
  117 +
116 118 List<Ylb> listylb=ylbRepository.obtainYl(rq, gsdm, fgsdm, "", "", "nbbm");
117 119 for (int i = 0; i < list.size(); i++) {
118 120 String ldgh="";
... ... @@ -122,11 +124,11 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
122 124 if(ldgh.equals(""))
123 125 ldgh +=ylb.getJsy();
124 126 else
125   - ldgh += ","+ylb.getJsy();
  127 + ldgh += ","+ylb.getJsy();
126 128 }
127 129 }
128 130 list.get(i).setLdgh(ldgh);
129   -
  131 +
130 132 }
131 133 //正式使用用下面代码
132 134 // for (int i = 0; i < iterator.size(); i++) {
... ... @@ -147,16 +149,16 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
147 149 // list.add(y1);
148 150 // }
149 151 // }
150   -
151   -
152   -
  152 +
  153 +
  154 +
153 155 PageHelper pageHelper = new PageHelper(list.size(), map);
154 156 pageHelper.getMap();
155 157 PageObject<Ylxxb> pageObject = pageHelper.getPageObject();
156 158 pageObject.setDataList(list);
157 159 return pageObject;
158 160 }
159   - @Transactional
  161 + @Transactional
160 162 @Override
161 163 public Map<String, Object> checkJsy(Map<String, Object> map) throws Exception{
162 164 Map<String, Object> newMap=new HashMap<String,Object>();
... ... @@ -175,11 +177,13 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
175 177 Integer id =jsonObject.getInteger("id");
176 178 String jsy =jsonObject.getString("jsy");
177 179 Ylxxb ylxxb=repository.findOne(id);
178   - ylxxb.setJsy(jsy);
179   - ylxxb.setJylx(1);
180   - repository.save(ylxxb);
  180 + if(!ylxxb.getJsy().equals(jsy)){
  181 + ylxxb.setJsy(jsy);
  182 + ylxxb.setJylx(1);
  183 + repository.save(ylxxb);
  184 + }
181 185 }
182   - newMap.put("status", ResponseCode.SUCCESS);
  186 + newMap.put("status", ResponseCode.SUCCESS);
183 187 }catch(Exception e){
184 188 newMap.put("status", ResponseCode.ERROR);
185 189 logger.error("save erro.", e);
... ... @@ -188,4 +192,4 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
188 192 return newMap;
189 193 }
190 194  
191   -}
  195 +}
192 196 \ No newline at end of file
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -4669,8 +4669,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4669 4669 mr.setSjyygl(rs.getDouble("sjyygl"));
4670 4670 mr.setSjksgl(rs.getDouble("sjksgl"));
4671 4671 mr.setZgl(rs.getDouble("zyygl"));
4672   - mr.setZddfgl(rs.getDouble("sddfgl"));
4673   - mr.setSddfgl(rs.getDouble("zddfgl"));
  4672 + mr.setZddfgl(rs.getDouble("zddfgl"));
  4673 + mr.setSddfgl(rs.getDouble("sddfgl"));
4674 4674 mr.setWqwxhgl(rs.getDouble("wqwxhgl"));
4675 4675 mr.setBfwxhgl(rs.getDouble("bfwxhgl"));
4676 4676 mr.setPygl(rs.getDouble("pygl"));
... ... @@ -4763,8 +4763,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4763 4763 sReport.setSjyybc(rs.getInt("sjyybc"));
4764 4764 sReport.setSjksbc(rs.getInt("sjksbc"));
4765 4765 sReport.setZbc(rs.getInt("zyybc"));
4766   - sReport.setZddfbc(rs.getInt("sddfbc"));
4767   - sReport.setSddfbc(rs.getInt("zddfbc"));
  4766 + sReport.setZddfbc(rs.getInt("zddfbc"));
  4767 + sReport.setSddfbc(rs.getInt("sddfbc"));
4768 4768 sReport.setWqwxhbc(rs.getInt("wqwxhbc"));
4769 4769 sReport.setBfwxhbc(rs.getInt("bfwxhbc"));
4770 4770 sReport.setPybc(rs.getInt("pybc"));
... ...