Commit 5a29b12e5d03b2bc2ce54274b7366ee54323f622

Authored by 潘钊
2 parents a2e754a0 0fc4bdad

Merge branch 'minhang' into pudong

Too many changes to show.

To preserve performance only 8 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/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/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
1 1 package com.bsth.service.oil.impl;
2 2  
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.text.ParseException;
  6 +import java.text.SimpleDateFormat;
  7 +import java.util.ArrayList;
  8 +import java.util.HashMap;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +import javax.transaction.Transactional;
  13 +
  14 +import org.apache.commons.lang3.StringEscapeUtils;
  15 +import org.slf4j.Logger;
  16 +import org.slf4j.LoggerFactory;
  17 +import org.springframework.beans.factory.annotation.Autowired;
  18 +import org.springframework.jdbc.core.JdbcTemplate;
  19 +import org.springframework.jdbc.core.RowMapper;
  20 +import org.springframework.stereotype.Service;
  21 +
3 22 import com.alibaba.fastjson.JSONArray;
4 23 import com.alibaba.fastjson.JSONObject;
5 24 import com.bsth.common.ResponseCode;
  25 +import com.bsth.entity.excep.Offline;
6 26 import com.bsth.entity.oil.Ylb;
7 27 import com.bsth.entity.oil.Ylxxb;
  28 +import com.bsth.entity.search.CustomerSpecs;
8 29 import com.bsth.repository.oil.YlbRepository;
9 30 import com.bsth.repository.oil.YlxxbRepository;
10 31 import com.bsth.service.impl.BaseServiceImpl;
11 32 import com.bsth.service.oil.YlxxbService;
12 33 import com.bsth.util.PageHelper;
13 34 import com.bsth.util.PageObject;
14   -import org.apache.commons.lang3.StringEscapeUtils;
15   -import org.slf4j.Logger;
16   -import org.slf4j.LoggerFactory;
17   -import org.springframework.beans.factory.annotation.Autowired;
18   -import org.springframework.jdbc.core.JdbcTemplate;
19   -import org.springframework.jdbc.core.RowMapper;
20   -import org.springframework.stereotype.Service;
21   -
22   -import javax.transaction.Transactional;
23   -import java.sql.ResultSet;
24   -import java.sql.SQLException;
25   -import java.util.HashMap;
26   -import java.util.List;
27   -import java.util.Map;
28 35  
29 36 @Service
30 37 public class YlxxbServiceImpl extends BaseServiceImpl<Ylxxb,Integer> implements YlxxbService
... ... @@ -185,4 +192,4 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
185 192 return newMap;
186 193 }
187 194  
188   -}
  195 +}
189 196 \ No newline at end of file
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -4077,7 +4077,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4077 4077 Long zdsjActual_=Long.parseLong(zdsjActual_s[0])*60+Long.parseLong(zdsjActual_s[1]);
4078 4078 if((zdsj_-zdsjActual_)>0){
4079 4079 zdsjk =String.valueOf(zdsj_-zdsjActual_);
4080   - }else{
  4080 + }
  4081 + if(((zdsj_-zdsjActual_)<0)){
4081 4082 zdsjm =String.valueOf(zdsjActual_-zdsj_);
4082 4083 }
4083 4084 }
... ... @@ -4104,7 +4105,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4104 4105 Long fcsjActural_=Long.parseLong(fcsjActural_s[0])*60+Long.parseLong(fcsjActural_s[1]);
4105 4106 if((zdsj_-fcsjActural_)>0){
4106 4107 fcsjk =String.valueOf(zdsj_-fcsjActural_);
4107   - }else{
  4108 + }
  4109 + if((zdsj_-fcsjActural_)<0){
4108 4110 fcsjm =String.valueOf(fcsjActural_-zdsj_);
4109 4111 }
4110 4112 }
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -4,6 +4,7 @@ import com.bsth.entity.Line;
4 4 import com.bsth.entity.Personnel;
5 5 import com.bsth.entity.StationRoute;
6 6 import com.bsth.entity.excep.ArrivalInfo;
  7 +import com.bsth.entity.mcy_forms.Daily;
7 8 import com.bsth.entity.oil.Dlb;
8 9 import com.bsth.entity.oil.Ylb;
9 10 import com.bsth.entity.realcontrol.ChildTaskPlan;
... ... @@ -19,6 +20,8 @@ import com.bsth.util.ComparableChild;
19 20 import com.bsth.util.ComparableJob;
20 21 import com.bsth.util.ReportUtils;
21 22 import com.bsth.util.db.DBUtils_MS;
  23 +import com.google.protobuf.StringValue;
  24 +
22 25 import org.apache.commons.lang.StringUtils;
23 26 import org.slf4j.Logger;
24 27 import org.slf4j.LoggerFactory;
... ... @@ -36,6 +39,8 @@ import java.text.ParseException;
36 39 import java.text.SimpleDateFormat;
37 40 import java.util.*;
38 41  
  42 +import javax.persistence.criteria.CriteriaBuilder.In;
  43 +
39 44 @Service
40 45 public class ReportServiceImpl implements ReportService{
41 46  
... ... @@ -66,16 +71,16 @@ public class ReportServiceImpl implements ReportService{
66 71 List<ScheduleRealInfo> list=scheduleRealInfoRepository.findByDate2(line,date,clzbh);
67 72  
68 73 // jdbcTemplate.query("select * from bsth_c_s_sp_info_real where line=?1 "
69   -// + "and DATE_FORMAT(schedule_date,'%Y-%m-%d')=?2 and cl_zbl=?3",
70   -// new Object[]{line,date,clzbh},
71   -// new RowMapper(){
72   -// @Override
73   -// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
74   -// ScheduleRealInfo s = new ScheduleRealInfo();
  74 +// + "and DATE_FORMAT(schedule_date,'%Y-%m-%d')=?2 and cl_zbl=?3",
  75 +// new Object[]{line,date,clzbh},
  76 +// new RowMapper(){
  77 +// @Override
  78 +// public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
  79 +// ScheduleRealInfo s = new ScheduleRealInfo();
75 80 //// s.
76   -// return s;
77   -// }
78   -// });
  81 +// return s;
  82 +// }
  83 +// });
79 84  
80 85 return list;
81 86 }
... ... @@ -283,11 +288,11 @@ public class ReportServiceImpl implements ReportService{
283 288 + " group by equipment_code ) ";
284 289  
285 290 Map<String, Object> map=new HashMap<String,Object>();
286   -
  291 +
287 292 /*List<Map<String, Object>> listPc= jdbcTemplate.query(sqlPc,
288 293 new RowMapper<Map<String, Object>>(){
289 294 @Override
290   - public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
  295 + public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
291 296 Map<String, Object> m=new HashMap<String,Object>();
292 297 m.put("zbh", rs.getString("cl_zbh"));
293 298 return m;
... ... @@ -1453,7 +1458,7 @@ public class ReportServiceImpl implements ReportService{
1453 1458 keyMap.get("18:01——(末)").add(ttMap);
1454 1459 }
1455 1460 }
1456   -
  1461 +
1457 1462 for(String key : keyMap.keySet()){
1458 1463 Map<String, Object> tempMap = new HashMap<String, Object>();
1459 1464 List<Map<String, Object>> list2 = keyMap.get(key);
... ... @@ -1472,7 +1477,7 @@ public class ReportServiceImpl implements ReportService{
1472 1477 }else{
1473 1478 String[] split = m.get("fcsj").toString().split(":");
1474 1479 int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);
1475   -
  1480 +
1476 1481 int xlDir = Integer.valueOf(m.get("dir").toString());
1477 1482 int bcsj = Integer.valueOf(m.get("bcsj").toString());
1478 1483 if(temp >= fcsj){
... ... @@ -1493,17 +1498,17 @@ public class ReportServiceImpl implements ReportService{
1493 1498 }
1494 1499 }
1495 1500 lpname=m.get("lp").toString();
1496   -
  1501 +
1497 1502 }
1498 1503 sxtsbc++;
1499 1504 }
1500   -
  1505 +
1501 1506 } else {
1502   -
  1507 +
1503 1508 fcsj_x.add(fcsj);
1504 1509 xxsj += bcsj;
1505 1510 xxbc ++;
1506   -
  1511 +
1507 1512 if(!ists){
1508 1513 if(lpname.equals("")){
1509 1514 lpname=m.get("lp").toString();
... ... @@ -1517,7 +1522,7 @@ public class ReportServiceImpl implements ReportService{
1517 1522 }
1518 1523 xxtsbc++;
1519 1524 }
1520   -
  1525 +
1521 1526 }
1522 1527 if(temp < fcsj){
1523 1528 cjs.add(fcsj - temp);
... ... @@ -1539,7 +1544,7 @@ public class ReportServiceImpl implements ReportService{
1539 1544 cjs.add(fcsj_s.get(i)-fcsjs);
1540 1545 fcsjs=fcsj_s.get(i);
1541 1546 }
1542   -
  1547 +
1543 1548 }
1544 1549 Collections.sort(fcsj_x);
1545 1550 int fcsjx=0;
... ... @@ -1550,7 +1555,7 @@ public class ReportServiceImpl implements ReportService{
1550 1555 cjs.add(fcsj_x.get(i)-fcsjx);
1551 1556 fcsjx =fcsj_x.get(i);
1552 1557 }
1553   -
  1558 +
1554 1559 }
1555 1560 Collections.sort(cjs);
1556 1561 for(int i : cjs){
... ... @@ -1849,7 +1854,7 @@ public class ReportServiceImpl implements ReportService{
1849 1854 // while (it.hasNext()) {
1850 1855 // ChildTaskPlan childTaskPlan = it.next();
1851 1856 // if (childTaskPlan.isDestroy()) {
1852   -// }
  1857 +// }
1853 1858 // }
1854 1859 // }
1855 1860 }
... ... @@ -2218,7 +2223,7 @@ public class ReportServiceImpl implements ReportService{
2218 2223 , (i+1));
2219 2224 }
2220 2225 inoutList.add(map1);
2221   -
  2226 +
2222 2227 /*for (int j = 0; j < listStation.size(); j++) {
2223 2228 map2=new HashMap<String,Object>();
2224 2229 StationRoute s=listStation.get(j);
... ... @@ -2230,7 +2235,7 @@ public class ReportServiceImpl implements ReportService{
2230 2235 }
2231 2236 }
2232 2237 Map<String, String> m=this.strInOut(arrivalList,lzsj);
2233   -
  2238 +
2234 2239 map2.put(s.getStationCode()+"in", m.get("in"));
2235 2240 map2.put(s.getStationCode()+"out", m.get("out"));
2236 2241 map2.put(s.getStationCode(), m.get("type"));
... ... @@ -3233,4 +3238,4 @@ class ComparableAcuals implements Comparator&lt;ScheduleRealInfo&gt;{
3233 3238 return o1.getFcsjActualTime().compareTo(o2.getFcsjActualTime());
3234 3239 }
3235 3240  
3236   -}
  3241 +}
3237 3242 \ No newline at end of file
... ...