Commit f06d9fa5e846b74c9686bba158f99702585edb8d

Authored by zlz
2 parents 1184e731 be2c4b67

Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control into pudong

Showing 78 changed files with 5284 additions and 3252 deletions
src/main/java/com/bsth/XDApplication.java
@@ -146,7 +146,7 @@ public class XDApplication implements CommandLineRunner { @@ -146,7 +146,7 @@ public class XDApplication implements CommandLineRunner {
146 sexec.scheduleWithFixedDelay(schedulePstThread, 120, 10, TimeUnit.SECONDS);//班次延迟入库线程 146 sexec.scheduleWithFixedDelay(schedulePstThread, 120, 10, TimeUnit.SECONDS);//班次延迟入库线程
147 sexec.scheduleWithFixedDelay(seiPstThread, 160, 60, TimeUnit.SECONDS);//班次修正日志入库 147 sexec.scheduleWithFixedDelay(seiPstThread, 160, 60, TimeUnit.SECONDS);//班次修正日志入库
148 sexec.scheduleWithFixedDelay(directivesPstThread, 180, 120, TimeUnit.SECONDS);//调度指令延迟入库 148 sexec.scheduleWithFixedDelay(directivesPstThread, 180, 120, TimeUnit.SECONDS);//调度指令延迟入库
149 - //sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作) 149 + sexec.scheduleWithFixedDelay(threadMonotor, 240, 60, TimeUnit.SECONDS);//线程监听(防止重要的线程阻塞、异常结束。以及部分主备切换工作)
150 sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据 150 sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据
151 sexec.scheduleWithFixedDelay(basicDataLoader, 2, 2, TimeUnit.HOURS);//基础数据更新 151 sexec.scheduleWithFixedDelay(basicDataLoader, 2, 2, TimeUnit.HOURS);//基础数据更新
152 sexec.scheduleWithFixedDelay(autoExecScanThread, 160, 50, TimeUnit.SECONDS);//班次自动执行 152 sexec.scheduleWithFixedDelay(autoExecScanThread, 160, 50, TimeUnit.SECONDS);//班次自动执行
src/main/java/com/bsth/controller/DownloadController.java
@@ -19,9 +19,6 @@ import org.springframework.http.MediaType; @@ -19,9 +19,6 @@ import org.springframework.http.MediaType;
19 import org.springframework.http.ResponseEntity; 19 import org.springframework.http.ResponseEntity;
20 import org.springframework.stereotype.Component; 20 import org.springframework.stereotype.Component;
21 import org.springframework.web.bind.annotation.RequestMapping; 21 import org.springframework.web.bind.annotation.RequestMapping;
22 -  
23 -import com.google.protobuf.UnknownFieldSet.Field;  
24 -import com.mysql.fabric.Response;  
25 22
26 /** 23 /**
27 * <一句话功能简述> 24 * <一句话功能简述>
@@ -55,11 +52,12 @@ public class DownloadController @@ -55,11 +52,12 @@ public class DownloadController
55 headers, HttpStatus.CREATED); 52 headers, HttpStatus.CREATED);
56 } 53 }
57 54
58 - @RequestMapping("download") 55 + @RequestMapping("download")
59 public void download(HttpServletResponse response,String fileName) 56 public void download(HttpServletResponse response,String fileName)
60 throws IOException { 57 throws IOException {
61 // String fileNames=URLDecoder.decode(fileName,"UTF-8"); 58 // String fileNames=URLDecoder.decode(fileName,"UTF-8");
62 - fileName =fileName + ".xls"; 59 + if(!fileName.contains(".xls"))
  60 + fileName =fileName + ".xls";
63 String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName; 61 String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName;
64 File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的 62 File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的
65 // String filename = file.getName();// 获取日志文件名称 63 // String filename = file.getName();// 获取日志文件名称
@@ -82,6 +80,7 @@ public class DownloadController @@ -82,6 +80,7 @@ public class DownloadController
82 public void downloadList(HttpServletResponse response,String fileName) 80 public void downloadList(HttpServletResponse response,String fileName)
83 throws IOException { 81 throws IOException {
84 // String fileNames=URLDecoder.decode(fileName,"UTF-8"); 82 // String fileNames=URLDecoder.decode(fileName,"UTF-8");
  83 + File files = new File(this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName);//
85 fileName = fileName + ".zip"; 84 fileName = fileName + ".zip";
86 String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName; 85 String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName;
87 File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的 86 File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的
@@ -99,7 +98,8 @@ public class DownloadController @@ -99,7 +98,8 @@ public class DownloadController
99 os.flush(); 98 os.flush();
100 os.close(); 99 os.close();
101 file.delete(); 100 file.delete();
102 - } 101 + deleteFiles(files);
  102 + }
103 103
104 104
105 @RequestMapping("downloadModel") 105 @RequestMapping("downloadModel")
@@ -125,4 +125,23 @@ public class DownloadController @@ -125,4 +125,23 @@ public class DownloadController
125 } 125 }
126 126
127 127
  128 + /**
  129 + * 删除文件夹
  130 + * @param files
  131 + * @return
  132 + */
  133 + public Boolean deleteFiles(File files){
  134 + if (files.isDirectory()) {
  135 + String[] children = files.list();
  136 + //递归删除目录中的子目录下
  137 + for (int i=0; i<children.length; i++) {
  138 + boolean success = deleteFiles(new File(files, children[i]));
  139 + if (!success) {
  140 + return false;
  141 + }
  142 + }
  143 + }
  144 + //目录此时为空,可以删除
  145 + return files.delete();
  146 + }
128 } 147 }
src/main/java/com/bsth/controller/LineVersionsController.java
1 package com.bsth.controller; 1 package com.bsth.controller;
2 2
3 -import java.text.ParseException;  
4 -import java.text.SimpleDateFormat;  
5 -import java.util.Date;  
6 import java.util.List; 3 import java.util.List;
7 import java.util.Map; 4 import java.util.Map;
8 5
@@ -12,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod; @@ -12,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
12 import org.springframework.web.bind.annotation.RequestParam; 9 import org.springframework.web.bind.annotation.RequestParam;
13 import org.springframework.web.bind.annotation.RestController; 10 import org.springframework.web.bind.annotation.RestController;
14 11
15 -import com.bsth.entity.Line;  
16 import com.bsth.entity.LineVersions; 12 import com.bsth.entity.LineVersions;
17 import com.bsth.repository.LineRepository; 13 import com.bsth.repository.LineRepository;
18 import com.bsth.service.LineVersionsService; 14 import com.bsth.service.LineVersionsService;
@@ -80,4 +76,13 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer @@ -80,4 +76,13 @@ public class LineVersionsController extends BaseController&lt;LineVersions, Integer
80 return service.add(map); 76 return service.add(map);
81 } 77 }
82 78
  79 + /**
  80 + * 根据线路id获取当前版本号
  81 + *
  82 + */
  83 + @RequestMapping(value = "findCurrentVersion", method = RequestMethod.GET)
  84 + public Integer findCurrentVersion(@RequestParam(defaultValue = "lineId") int lineId) {
  85 + return service.findCurrentVersion(lineId);
  86 + }
  87 +
83 } 88 }
src/main/java/com/bsth/controller/oil/YlbController.java
@@ -210,7 +210,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -210,7 +210,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
210 return maps; 210 return maps;
211 } 211 }
212 @RequestMapping(value="/oilListMonth") 212 @RequestMapping(value="/oilListMonth")
213 - public List<Ylb> oilListMonth(@RequestParam Map<String, Object> map){ 213 + public List<Map<String, Object>> oilListMonth(@RequestParam Map<String, Object> map){
214 return yblService.oilListMonth(map); 214 return yblService.oilListMonth(map);
215 } 215 }
216 216
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -23,9 +23,6 @@ import java.util.*; @@ -23,9 +23,6 @@ import java.util.*;
23 @RequestMapping("/realSchedule") 23 @RequestMapping("/realSchedule")
24 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> { 24 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
25 25
26 - /*@Autowired  
27 - GetSchedulePlanThread getSchedulePlanThread;*/  
28 -  
29 @Autowired 26 @Autowired
30 ScheduleRealInfoService scheduleRealInfoService; 27 ScheduleRealInfoService scheduleRealInfoService;
31 28
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
@@ -110,4 +110,14 @@ public class anomalyCheckController { @@ -110,4 +110,14 @@ public class anomalyCheckController {
110 dayOfSchedule.removeExecPlan(nbbm); 110 dayOfSchedule.removeExecPlan(nbbm);
111 return 1; 111 return 1;
112 } 112 }
  113 +
  114 + @RequestMapping(value = "/sch_re_calc_id_maps")
  115 + public int reCalcIdMaps(){
  116 + return dayOfSchedule.reCalcIdMaps();
  117 + }
  118 +
  119 + @RequestMapping(value = "/sch_size_string")
  120 + public String schSizeString(){
  121 + return dayOfSchedule.sizeString();
  122 + }
113 } 123 }
src/main/java/com/bsth/controller/report/ReportController.java
@@ -278,6 +278,12 @@ public class ReportController { @@ -278,6 +278,12 @@ public class ReportController {
278 return service.countByList(map); 278 return service.countByList(map);
279 } 279 }
280 280
  281 + @RequestMapping(value="/countLineMileage2")
  282 + public List<Map<String,Object>> countLineMileage2(@RequestParam Map<String, Object> map){
  283 +
  284 + return service.countByList2(map);
  285 + }
  286 +
281 @RequestMapping(value="/countBusMileage") 287 @RequestMapping(value="/countBusMileage")
282 public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){ 288 public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){
283 return service.countByBusList(map); 289 return service.countByBusList(map);
@@ -325,4 +331,10 @@ public class ReportController { @@ -325,4 +331,10 @@ public class ReportController {
325 331
326 return lMap; 332 return lMap;
327 } 333 }
  334 +
  335 +
  336 + @RequestMapping(value="/online")
  337 + public Map<String, Object> online(@RequestParam Map<String, Object> map){
  338 + return service.online(map);
  339 + }
328 } 340 }
src/main/java/com/bsth/data/ThreadMonotor.java
1 package com.bsth.data; 1 package com.bsth.data;
2 2
3 -import org.slf4j.Logger;  
4 -import org.slf4j.LoggerFactory; 3 +import com.bsth.data.gpsdata_v2.DataHandleProcess;
  4 +import com.bsth.data.gpsdata_v2.thread.GpsDataLoaderThread;
5 import org.springframework.stereotype.Component; 5 import org.springframework.stereotype.Component;
6 6
7 /** 7 /**
@@ -10,32 +10,10 @@ import org.springframework.stereotype.Component; @@ -10,32 +10,10 @@ import org.springframework.stereotype.Component;
10 @Component 10 @Component
11 public class ThreadMonotor extends Thread{ 11 public class ThreadMonotor extends Thread{
12 12
13 - Logger log = LoggerFactory.getLogger(this.getClass());  
14 -  
15 @Override 13 @Override
16 public void run() { 14 public void run() {
17 -  
18 - //线调GPS分析主线程  
19 - /*if(GpsRealAnalyse.isBlock()){  
20 - log.warn("GpsRealAnalyse isBlock true !!!!");  
21 - GpsRealAnalyse.shutdown();  
22 - }*/  
23 -  
24 - /*if(GpsRealAnalyse.isIdle()){  
25 - //切换到备用的网关实时GPS对照数据 15 + //切换到备用的网关实时GPS对照数据
  16 + if(DataHandleProcess.isBlock())
26 GpsDataLoaderThread.setFlag(-1); 17 GpsDataLoaderThread.setFlag(-1);
27 - }*/  
28 -  
29 - //webSocket 消息推送队列  
30 - /*if(WebSocketPushQueue.isIdle()){  
31 - log.warn("WebSocketPushQueue isIdle true !!!!");  
32 - WebSocketPushQueue.start();  
33 - }*/  
34 -  
35 - //网关指令推送队列(系统自动发送的)  
36 - /*if(DirectivePushQueue.isIdle()){  
37 - log.warn("DirectivePushQueue isIdle true !!!!");  
38 - DirectivePushQueue.start();  
39 - }*/  
40 } 18 }
41 } 19 }
42 \ No newline at end of file 20 \ No newline at end of file
src/main/java/com/bsth/data/car_out_info/CarOutInfoHandler.java
@@ -50,6 +50,9 @@ public class CarOutInfoHandler { @@ -50,6 +50,9 @@ public class CarOutInfoHandler {
50 50
51 Logger logger = LoggerFactory.getLogger(this.getClass()); 51 Logger logger = LoggerFactory.getLogger(this.getClass());
52 52
  53 +
  54 + ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();
  55 + List<ScheduleRealInfo> pstList = new ArrayList<>();
53 /** 56 /**
54 * 全量更新发车信息表 57 * 全量更新发车信息表
55 */ 58 */
@@ -57,24 +60,27 @@ public class CarOutInfoHandler { @@ -57,24 +60,27 @@ public class CarOutInfoHandler {
57 try{ 60 try{
58 //将班次按线路分组 61 //将班次按线路分组
59 List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); 62 List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll());
60 - ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create();  
61 for(ScheduleRealInfo sch : all){ 63 for(ScheduleRealInfo sch : all){
62 xlMaps.put(sch.getXlBm(), sch); 64 xlMaps.put(sch.getXlBm(), sch);
63 } 65 }
64 66
65 Set<String> ks = xlMaps.keySet(); 67 Set<String> ks = xlMaps.keySet();
66 for (String k : ks) { 68 for (String k : ks) {
67 - update(xlMaps.get(k)); 69 + pstList.addAll(update(xlMaps.get(k)));
68 } 70 }
  71 +
  72 + save(pstList);
  73 + pstList.clear();
  74 + xlMaps.clear();
  75 + logger.info("更新发车信息表!!");
69 }catch (Exception e){ 76 }catch (Exception e){
70 logger.error("", e); 77 logger.error("", e);
71 } 78 }
72 } 79 }
73 80
74 - public void update(List<ScheduleRealInfo> list) { 81 + public List<ScheduleRealInfo> update(List<ScheduleRealInfo> list) {
75 if (list.size() == 0) 82 if (list.size() == 0)
76 - return;  
77 - String lineCode = list.get(0).getXlBm(); 83 + return new ArrayList<>();
78 //按上下行分组 84 //按上下行分组
79 List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>(); 85 List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>();
80 for (ScheduleRealInfo sch : list) { 86 for (ScheduleRealInfo sch : list) {
@@ -87,7 +93,12 @@ public class CarOutInfoHandler { @@ -87,7 +93,12 @@ public class CarOutInfoHandler {
87 ScheduleRealInfo[] upArray = nexts(ups), 93 ScheduleRealInfo[] upArray = nexts(ups),
88 downArray = nexts(downs); 94 downArray = nexts(downs);
89 95
90 - final List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray); 96 + List<ScheduleRealInfo> pstArray = mergeArray(upArray, downArray);
  97 +
  98 + return pstArray;
  99 + }
  100 +
  101 + private void save(final List<ScheduleRealInfo> pstList){
91 //编程式事务 102 //编程式事务
92 DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); 103 DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
93 DefaultTransactionDefinition def = new DefaultTransactionDefinition(); 104 DefaultTransactionDefinition def = new DefaultTransactionDefinition();
@@ -96,13 +107,13 @@ public class CarOutInfoHandler { @@ -96,13 +107,13 @@ public class CarOutInfoHandler {
96 107
97 try{ 108 try{
98 //删除 109 //删除
99 - jdbcTemplate.update("delete from bsth_t_clfcxxb where line_code=?", lineCode); 110 + jdbcTemplate.update("delete from bsth_t_clfcxxb");
100 //重新写入 111 //重新写入
101 jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" + 112 jdbcTemplate.batchUpdate("insert into bsth_t_clfcxxb(rq, line_code, line_name, lp_name, lp_sn, dfsj, nbbm, cph, bc_type, end_station_name, updown, jGh, jName, remarks, sn)" +
102 " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() { 113 " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() {
103 @Override 114 @Override
104 public void setValues(PreparedStatement ps, int i) throws SQLException { 115 public void setValues(PreparedStatement ps, int i) throws SQLException {
105 - ScheduleRealInfo sch = pstArray.get(i); 116 + ScheduleRealInfo sch = pstList.get(i);
106 ps.setString(1, sch.getScheduleDateStr()); 117 ps.setString(1, sch.getScheduleDateStr());
107 ps.setString(2, sch.getXlBm()); 118 ps.setString(2, sch.getXlBm());
108 ps.setString(3, sch.getXlName()); 119 ps.setString(3, sch.getXlName());
@@ -122,7 +133,7 @@ public class CarOutInfoHandler { @@ -122,7 +133,7 @@ public class CarOutInfoHandler {
122 133
123 @Override 134 @Override
124 public int getBatchSize() { 135 public int getBatchSize() {
125 - return pstArray.size(); 136 + return pstList.size();
126 } 137 }
127 }); 138 });
128 139
@@ -159,8 +170,8 @@ public class CarOutInfoHandler { @@ -159,8 +170,8 @@ public class CarOutInfoHandler {
159 ScheduleRealInfo[] array = new ScheduleRealInfo[3]; 170 ScheduleRealInfo[] array = new ScheduleRealInfo[3];
160 Collections.sort(list, schDFSJComparator); 171 Collections.sort(list, schDFSJComparator);
161 172
162 - int count = 0, threshold = 1000 * 60 * 60 * 4;  
163 - long t = System.currentTimeMillis(); 173 + int count = 0;//, threshold = 1000 * 60 * 60 * 4;
  174 + //long t = System.currentTimeMillis();
164 for (ScheduleRealInfo sch : list) { 175 for (ScheduleRealInfo sch : list) {
165 if (count == 3) 176 if (count == 3)
166 break; 177 break;
@@ -180,8 +191,8 @@ public class CarOutInfoHandler { @@ -180,8 +191,8 @@ public class CarOutInfoHandler {
180 || StringUtils.isNotEmpty(sch.getZdsjActual())) 191 || StringUtils.isNotEmpty(sch.getZdsjActual()))
181 continue; 192 continue;
182 193
183 - if (t - sch.getDfsjT() > threshold)  
184 - continue; 194 + /*if (t - sch.getDfsjT() > threshold)
  195 + continue;*/
185 196
186 array[count] = sch; 197 array[count] = sch;
187 count++; 198 count++;
src/main/java/com/bsth/data/directive/DayOfDirectives.java
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
16 16
17 import java.util.*; 17 import java.util.*;
  18 +import java.util.concurrent.ConcurrentHashMap;
18 19
19 /** 20 /**
20 * 21 *
@@ -52,8 +53,8 @@ public class DayOfDirectives { @@ -52,8 +53,8 @@ public class DayOfDirectives {
52 53
53 54
54 static{ 55 static{
55 - d60Map = new HashMap<>();  
56 - d64Map = new HashMap<>(); 56 + d60Map = new ConcurrentHashMap<>();
  57 + d64Map = new ConcurrentHashMap<>();
57 pstDirectives = new LinkedList<>(); 58 pstDirectives = new LinkedList<>();
58 } 59 }
59 60
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
@@ -51,10 +51,6 @@ public class DirectivesPstThread extends Thread { @@ -51,10 +51,6 @@ public class DirectivesPstThread extends Thread {
51 logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId()); 51 logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId());
52 continue; 52 continue;
53 } 53 }
54 - if(dayOfSchedule.get(sch.getId()) == null){  
55 - logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。");  
56 - continue;  
57 - }  
58 } 54 }
59 d60Repository.save(d60); 55 d60Repository.save(d60);
60 } 56 }
src/main/java/com/bsth/data/gpsdata_v2/DataHandleProcess.java
@@ -46,8 +46,17 @@ public class DataHandleProcess { @@ -46,8 +46,17 @@ public class DataHandleProcess {
46 @Autowired 46 @Autowired
47 GpsRealData gpsRealData; 47 GpsRealData gpsRealData;
48 48
  49 + static long lastTime;
  50 +
  51 + public static boolean isBlock() {
  52 + return System.currentTimeMillis() - lastTime > 1000 * 20;
  53 + }
  54 +
49 public void handle(List<GpsEntity> list) { 55 public void handle(List<GpsEntity> list) {
50 try { 56 try {
  57 + if(list.size() == 0)
  58 + return;
  59 + lastTime = System.currentTimeMillis();
51 //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑) 60 //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑)
52 ArrayListMultimap multimap = ArrayListMultimap.create(); 61 ArrayListMultimap multimap = ArrayListMultimap.create();
53 for (GpsEntity gps : list) { 62 for (GpsEntity gps : list) {
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
@@ -38,7 +38,7 @@ public class GpsCacheData { @@ -38,7 +38,7 @@ public class GpsCacheData {
38 * @param nbbm 38 * @param nbbm
39 */ 39 */
40 public static void remove(String nbbm){ 40 public static void remove(String nbbm){
41 - logger.info("清除车辆到离站轨迹, " + nbbm); 41 + //logger.info("清除车辆到离站轨迹, " + nbbm);
42 trailListMultimap.removeAll(nbbm); 42 trailListMultimap.removeAll(nbbm);
43 } 43 }
44 44
src/main/java/com/bsth/data/gpsdata_v2/utils/SignalSchPlanMatcher.java
@@ -45,7 +45,8 @@ public class SignalSchPlanMatcher { @@ -45,7 +45,8 @@ public class SignalSchPlanMatcher {
45 45
46 if(null != near && !near.getId().equals(sch.getId())){ 46 if(null != near && !near.getId().equals(sch.getId())){
47 47
48 - if(Math.abs(t - near.getDfsjT()) < Math.abs((t - sch.getDfsjT()))){ 48 + int nearDiff = (int) Math.abs(t - near.getDfsjT());
  49 + if(nearDiff < 1000 * 60 * 8 && nearDiff < Math.abs((t - sch.getDfsjT()))){
49 50
50 dayOfSchedule.addExecPlan(near); 51 dayOfSchedule.addExecPlan(near);
51 return false; 52 return false;
@@ -57,47 +58,6 @@ public class SignalSchPlanMatcher { @@ -57,47 +58,6 @@ public class SignalSchPlanMatcher {
57 log.error("", e); 58 log.error("", e);
58 } 59 }
59 return true; 60 return true;
60 - /*try{  
61 - //会不会是分班没有完成  
62 - if(sch.getBcType().equals("in") && t - sch.getDfsjT() > 1000 * 60 * 20){  
63 - ScheduleRealInfo fbFirst = dayOfSchedule.nextByBcType(sch, "normal");  
64 -  
65 - if(fbFirst == null || !fbFirst.getQdzCode().equals(gps.getStopNo()))  
66 - return;  
67 -  
68 - long dt = fbFirst.getDfsjT();  
69 - //晚于待发前4分钟 -执行分班的首个营运  
70 - if(dt - t < 1000 * 60 * 4){  
71 - dayOfSchedule.addExecPlan(fbFirst);  
72 - return;  
73 - }  
74 - }  
75 -  
76 - //线路编码不匹配  
77 - if("out".equals(sch.getBcType()) && !sch.getXlBm().equals(gps.getLineId())){  
78 - ScheduleRealInfo nextOut = dayOfSchedule.nextByBcType(sch, "out");  
79 - if(nextOut != null && nextOut.getXlBm().equals(gps.getLineId())  
80 - && fcSpace(sch, gps) > fcSpace(nextOut, gps)){  
81 - dayOfSchedule.addExecPlan(nextOut);  
82 - return;  
83 - }  
84 - }  
85 - }catch (Exception e){  
86 - log.error("", e);  
87 - }  
88 -  
89 - //下一个相同走向的班次  
90 - ScheduleRealInfo next = dayOfSchedule.nextSame(sch);  
91 - if(next == null || !next.getQdzCode().equals(sch.getQdzCode()))  
92 - return;  
93 -  
94 - //晚于班次间隔百分之70,跳下一个班次  
95 - double s = (int) (next.getDfsjT() - sch.getDfsjT());  
96 - double r = (int) (t - sch.getDfsjT());  
97 - if(r / s > 0.7){  
98 - if(dayOfSchedule.addExecPlan(next))  
99 - outMatch(gps, next);  
100 - }*/  
101 } 61 }
102 62
103 /** 63 /**
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -13,11 +13,8 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; @@ -13,11 +13,8 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo;
13 import com.bsth.entity.schedule.SchedulePlanInfo; 13 import com.bsth.entity.schedule.SchedulePlanInfo;
14 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 14 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
15 import com.bsth.service.schedule.SchedulePlanInfoService; 15 import com.bsth.service.schedule.SchedulePlanInfoService;
16 -import com.bsth.util.BatchSaveUtils;  
17 import com.bsth.websocket.handler.SendUtils; 16 import com.bsth.websocket.handler.SendUtils;
18 -import com.google.common.base.Predicate;  
19 import com.google.common.collect.ArrayListMultimap; 17 import com.google.common.collect.ArrayListMultimap;
20 -import com.google.common.collect.Collections2;  
21 import org.apache.commons.lang3.StringUtils; 18 import org.apache.commons.lang3.StringUtils;
22 import org.joda.time.format.DateTimeFormat; 19 import org.joda.time.format.DateTimeFormat;
23 import org.joda.time.format.DateTimeFormatter; 20 import org.joda.time.format.DateTimeFormatter;
@@ -25,12 +22,20 @@ import org.slf4j.Logger; @@ -25,12 +22,20 @@ import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory; 22 import org.slf4j.LoggerFactory;
26 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.dao.DataIntegrityViolationException; 24 import org.springframework.dao.DataIntegrityViolationException;
  25 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
28 import org.springframework.jdbc.core.JdbcTemplate; 26 import org.springframework.jdbc.core.JdbcTemplate;
  27 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
29 import org.springframework.stereotype.Component; 28 import org.springframework.stereotype.Component;
  29 +import org.springframework.transaction.TransactionDefinition;
  30 +import org.springframework.transaction.TransactionStatus;
  31 +import org.springframework.transaction.support.DefaultTransactionDefinition;
30 32
  33 +import java.sql.PreparedStatement;
  34 +import java.sql.SQLException;
31 import java.text.ParseException; 35 import java.text.ParseException;
32 import java.text.SimpleDateFormat; 36 import java.text.SimpleDateFormat;
33 import java.util.*; 37 import java.util.*;
  38 +import java.util.concurrent.ConcurrentHashMap;
34 import java.util.concurrent.ConcurrentLinkedQueue; 39 import java.util.concurrent.ConcurrentLinkedQueue;
35 40
36 /** 41 /**
@@ -65,6 +70,8 @@ public class DayOfSchedule { @@ -65,6 +70,8 @@ public class DayOfSchedule {
65 // 排序器 70 // 排序器
66 private static ScheduleComparator.FCSJ schFCSJComparator; 71 private static ScheduleComparator.FCSJ schFCSJComparator;
67 72
  73 + private static Long sch_max_id=-1L;
  74 +
68 @Autowired 75 @Autowired
69 LineConfigData lineConfigData; 76 LineConfigData lineConfigData;
70 77
@@ -92,11 +99,11 @@ public class DayOfSchedule { @@ -92,11 +99,11 @@ public class DayOfSchedule {
92 nbbmScheduleMap = ArrayListMultimap.create(); 99 nbbmScheduleMap = ArrayListMultimap.create();
93 lpScheduleMap = ArrayListMultimap.create(); 100 lpScheduleMap = ArrayListMultimap.create();
94 101
95 - id2SchedulMap = new HashMap<>(); 102 + id2SchedulMap = new ConcurrentHashMap<>();
96 pstBuffer = new ConcurrentLinkedQueue<>(); 103 pstBuffer = new ConcurrentLinkedQueue<>();
97 schFCSJComparator = new ScheduleComparator.FCSJ(); 104 schFCSJComparator = new ScheduleComparator.FCSJ();
98 currSchDateMap = new HashMap<>(); 105 currSchDateMap = new HashMap<>();
99 - carExecutePlanMap = new HashMap<>(); 106 + carExecutePlanMap = new ConcurrentHashMap<>();
100 107
101 schedulePlanMap = new HashMap<>(); 108 schedulePlanMap = new HashMap<>();
102 } 109 }
@@ -258,7 +265,7 @@ public class DayOfSchedule { @@ -258,7 +265,7 @@ public class DayOfSchedule {
258 public void clearRAMData(String lineCode) { 265 public void clearRAMData(String lineCode) {
259 int count = 0; 266 int count = 0;
260 List<ScheduleRealInfo> remList = new ArrayList<>(); 267 List<ScheduleRealInfo> remList = new ArrayList<>();
261 - Collection<ScheduleRealInfo> all = id2SchedulMap.values(); 268 + Collection<ScheduleRealInfo> all = nbbmScheduleMap.values();
262 for (ScheduleRealInfo sch : all) { 269 for (ScheduleRealInfo sch : all) {
263 if (sch.getXlBm().equals(lineCode)) 270 if (sch.getXlBm().equals(lineCode))
264 remList.add(sch); 271 remList.add(sch);
@@ -324,11 +331,13 @@ public class DayOfSchedule { @@ -324,11 +331,13 @@ public class DayOfSchedule {
324 // 转换为实际排班 331 // 转换为实际排班
325 realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); 332 realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class);
326 333
  334 + Date d = new Date();
327 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); 335 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
328 String fcsj; 336 String fcsj;
329 for (ScheduleRealInfo sch : realList) { 337 for (ScheduleRealInfo sch : realList) {
330 sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); 338 sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime()));
331 sch.setRealExecDate(sch.getScheduleDateStr()); 339 sch.setRealExecDate(sch.getScheduleDateStr());
  340 + sch.setCreateDate(d);
332 341
333 if (StringUtils.isEmpty(sch.getFcsj())) 342 if (StringUtils.isEmpty(sch.getFcsj()))
334 sch.setFcsj("00:00"); 343 sch.setFcsj("00:00");
@@ -377,26 +386,108 @@ public class DayOfSchedule { @@ -377,26 +386,108 @@ public class DayOfSchedule {
377 return realList; 386 return realList;
378 } 387 }
379 388
  389 +
  390 + public synchronized long getId(){
  391 + if(sch_max_id==-1){
  392 + sch_max_id = schRepository.getMaxId();
  393 + if(null == sch_max_id)
  394 + sch_max_id = 3000L;//留一点空间补数据用
  395 + sch_max_id += 5;
  396 + }
  397 + else
  398 + sch_max_id ++;
  399 + return sch_max_id;
  400 + }
  401 +
380 /** 402 /**
381 * @Title: batchSave 403 * @Title: batchSave
382 * @Description: TODO(批量入库) 404 * @Description: TODO(批量入库)
383 */ 405 */
384 private void batchSave(List<ScheduleRealInfo> list) { 406 private void batchSave(List<ScheduleRealInfo> list) {
385 - // 查询数据库最大ID  
386 - Long id = schRepository.getMaxId();  
387 - if (null == id)  
388 - id = 0L;  
389 - id++;  
390 -  
391 SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); 407 SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
392 for (ScheduleRealInfo item : list) { 408 for (ScheduleRealInfo item : list) {
393 item.setSpId(item.getId());// 保留原始的计划ID 409 item.setSpId(item.getId());// 保留原始的计划ID
394 - item.setId(id++);// 设置ID 410 + item.setId(getId());// 设置ID
395 item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); 411 item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate()));
396 } 412 }
397 413
  414 + //编程式事务
  415 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  416 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  417 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  418 + TransactionStatus status = tran.getTransaction(def);
  419 +
  420 + try{
  421 + final List<ScheduleRealInfo> pstList = list;
  422 + //写入
  423 + jdbcTemplate.batchUpdate("insert into bsth_c_s_sp_info_real(id,bc_type,bcs,bcsj,cl_zbh,create_date,dfsj,directive_state,fcno,fcsj,fcsj_actual,j_gh,j_name,jhlc,lp_name,qdz_code,qdz_name,real_exec_date,remarks,s_gh,s_name,schedule_date,schedule_date_str,sflj,sp_id,status,update_date,xl_bm,xl_dir,xl_name,zdsj,zdsj_actual,zdz_code,zdz_name,ccno,df_auto,fgs_bm,fgs_name,gs_bm,gs_name,online,adjust_exps,reissue,jhlc_orig,sigin_compate,drift_status,cc_service,major_station_name)" +
  424 + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() {
  425 + @Override
  426 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  427 + ScheduleRealInfo sch = pstList.get(i);
  428 + ps.setLong(1, sch.getId());
  429 + ps.setString(2, sch.getBcType());
  430 + ps.setInt(3, sch.getBcs()==null?0:sch.getBcs());
  431 + ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj());
  432 + ps.setString(5, sch.getClZbh());
  433 + ps.setTimestamp(6, new java.sql.Timestamp(sch.getCreateDate().getTime()));
  434 + ps.setString(7, sch.getDfsj());
  435 + ps.setInt(8, sch.getDirectiveState());
  436 + ps.setInt(9, sch.getFcno()==null?0:sch.getFcno());
  437 + ps.setString(10, sch.getFcsj());
  438 + ps.setString(11, sch.getFcsjActual());
  439 + ps.setString(12, sch.getjGh());
  440 + ps.setString(13, sch.getjName());
  441 + ps.setDouble(14, sch.getJhlc());
  442 + ps.setString(15, sch.getLpName());
  443 + ps.setString(16, sch.getQdzCode());
  444 + ps.setString(17, sch.getQdzName());
  445 + ps.setString(18, sch.getRealExecDate());
  446 + ps.setString(19, sch.getRemarks());
  447 + ps.setString(20, sch.getsGh());
  448 + ps.setString(21, sch.getsName());
  449 + ps.setTimestamp(22, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
  450 + ps.setString(23, sch.getScheduleDateStr());
  451 + ps.setBoolean(24, sch.isSflj());
  452 + ps.setLong(25, sch.getSpId());
  453 + ps.setInt(26, sch.getStatus());
  454 + ps.setTimestamp(27, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
  455 + ps.setString(28, sch.getXlBm());
  456 + ps.setString(29, sch.getXlDir());
  457 + ps.setString(30, sch.getXlName());
  458 + ps.setString(31, sch.getZdsj());
  459 + ps.setString(32, sch.getZdsjActual());
  460 + ps.setString(33, sch.getZdzCode());
  461 + ps.setString(34, sch.getZdzName());
  462 + ps.setInt(35, sch.getCcno()==null?0:sch.getCcno());
  463 + ps.setBoolean(36, sch.isDfAuto());
  464 + ps.setString(37, sch.getFgsBm());
  465 + ps.setString(38, sch.getFgsName());
  466 + ps.setString(39, sch.getGsBm());
  467 + ps.setString(40, sch.getGsName());
  468 + ps.setBoolean(41, sch.isOnline());
  469 + ps.setString(42, sch.getAdjustExps());
  470 + ps.setBoolean(43, sch.isReissue());
  471 + ps.setDouble(44, sch.getJhlcOrig());
  472 + ps.setInt(45, sch.getSiginCompate());
  473 + ps.setInt(46, sch.getDriftStatus());
  474 + ps.setBoolean(47, sch.isCcService());
  475 + ps.setString(48, sch.getMajorStationName());
  476 + }
  477 +
  478 + @Override
  479 + public int getBatchSize() {
  480 + return pstList.size();
  481 + }
  482 + });
  483 +
  484 + tran.commit(status);
  485 + }catch (Exception e){
  486 + tran.rollback(status);
  487 + logger.error("real schedule batchSave error...", e);
  488 + }
398 // 入库 489 // 入库
399 - new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); 490 + //new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class);
400 } 491 }
401 492
402 public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { 493 public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) {
@@ -420,7 +511,7 @@ public class DayOfSchedule { @@ -420,7 +511,7 @@ public class DayOfSchedule {
420 public List<ScheduleRealInfo> findByLineCode(String lineCode) { 511 public List<ScheduleRealInfo> findByLineCode(String lineCode) {
421 List<ScheduleRealInfo> rs = new ArrayList<>(); 512 List<ScheduleRealInfo> rs = new ArrayList<>();
422 513
423 - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); 514 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
424 for (ScheduleRealInfo sch : schs) { 515 for (ScheduleRealInfo sch : schs) {
425 if (sch.getXlBm().equals(lineCode)) 516 if (sch.getXlBm().equals(lineCode))
426 rs.add(sch); 517 rs.add(sch);
@@ -435,7 +526,7 @@ public class DayOfSchedule { @@ -435,7 +526,7 @@ public class DayOfSchedule {
435 public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { 526 public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) {
436 ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); 527 ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
437 528
438 - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); 529 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
439 for (ScheduleRealInfo sch : schs) { 530 for (ScheduleRealInfo sch : schs) {
440 if (lineList.contains(sch.getXlBm())) { 531 if (lineList.contains(sch.getXlBm())) {
441 mMap.put(sch.getXlBm(), sch); 532 mMap.put(sch.getXlBm(), sch);
@@ -492,24 +583,6 @@ public class DayOfSchedule { @@ -492,24 +583,6 @@ public class DayOfSchedule {
492 return next(list, sch); 583 return next(list, sch);
493 } 584 }
494 585
495 - /**  
496 - * 下一个相同走向的班次  
497 - *  
498 - * @param sch  
499 - * @return  
500 - */  
501 - public ScheduleRealInfo nextSame(final ScheduleRealInfo sch) {  
502 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
503 - Collection<ScheduleRealInfo> subList = Collections2.filter(list, new Predicate<ScheduleRealInfo>() {  
504 -  
505 - @Override  
506 - public boolean apply(ScheduleRealInfo item) {  
507 - return item.getXlDir().equals(sch.getXlDir());  
508 - }  
509 - });  
510 - return next(subList, sch);  
511 - }  
512 -  
513 586
514 /** 587 /**
515 * 下一个班次 588 * 下一个班次
@@ -657,8 +730,7 @@ public class DayOfSchedule { @@ -657,8 +730,7 @@ public class DayOfSchedule {
657 .calcRealDate(sch) 730 .calcRealDate(sch)
658 .calcAllTimeByFcsj(sch); 731 .calcAllTimeByFcsj(sch);
659 732
660 - String nbbm = sch.getClZbh();  
661 - nbbmScheduleMap.put(nbbm, sch); 733 + nbbmScheduleMap.put(sch.getClZbh(), sch);
662 734
663 //主键索引 735 //主键索引
664 id2SchedulMap.put(sch.getId(), sch); 736 id2SchedulMap.put(sch.getId(), sch);
@@ -675,7 +747,6 @@ public class DayOfSchedule { @@ -675,7 +747,6 @@ public class DayOfSchedule {
675 } 747 }
676 748
677 public void delete(ScheduleRealInfo sch) { 749 public void delete(ScheduleRealInfo sch) {
678 - //ScheduleRealInfo sch = id2SchedulMap.get(id);  
679 if (!sch.isSflj()) 750 if (!sch.isSflj())
680 return; 751 return;
681 752
@@ -715,36 +786,6 @@ public class DayOfSchedule { @@ -715,36 +786,6 @@ public class DayOfSchedule {
715 return rs; 786 return rs;
716 } 787 }
717 788
718 - public boolean validTime(ScheduleRealInfo sch, Long ts) {  
719 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
720 - int ci = list.indexOf(sch);  
721 - ScheduleRealInfo prve, next;  
722 - if (ci > 0) {  
723 - //之前班次实际时间不能大于该时间  
724 - for (int i = ci - 1; i >= 0; i--) {  
725 - prve = list.get(i);  
726 - if (prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts)  
727 - return false;  
728 -  
729 - if (prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts)  
730 - return false;  
731 - }  
732 - }  
733 -  
734 - if (ci < list.size() - 1) {  
735 - //之后班次实际时间不能小于该时间  
736 - for (int i = ci + 1; i < list.size(); i++) {  
737 - next = list.get(i);  
738 - if (next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts)  
739 - return false;  
740 -  
741 - if (next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts)  
742 - return false;  
743 - }  
744 - }  
745 - return true;  
746 - }  
747 -  
748 public void save(ScheduleRealInfo sch) { 789 public void save(ScheduleRealInfo sch) {
749 sch.setUpdateDate(new Date()); 790 sch.setUpdateDate(new Date());
750 pstBuffer.add(sch); 791 pstBuffer.add(sch);
@@ -768,26 +809,6 @@ public class DayOfSchedule { @@ -768,26 +809,6 @@ public class DayOfSchedule {
768 return sch; 809 return sch;
769 } 810 }
770 811
771 - /**  
772 - * @Title: nextByBcType  
773 - * @Description: TODO(获取下一个指定班次类型的班次)  
774 - */  
775 - public ScheduleRealInfo nextByBcType(ScheduleRealInfo sch, String bcType) {  
776 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
777 - Collections.sort(list, schFCSJComparator);  
778 -  
779 - boolean flag = false;  
780 - for (ScheduleRealInfo temp : list) {  
781 -  
782 - if (flag && temp.getBcType().equals(bcType))  
783 - return temp;  
784 -  
785 - if (temp == sch) {  
786 - flag = true;  
787 - }  
788 - }  
789 - return null;  
790 - }  
791 812
792 /** 813 /**
793 * 搜索离当前时间最近的一个指定类型的班次 814 * 搜索离当前时间最近的一个指定类型的班次
@@ -857,6 +878,8 @@ public class DayOfSchedule { @@ -857,6 +878,8 @@ public class DayOfSchedule {
857 * @return 878 * @return
858 */ 879 */
859 public ScheduleRealInfo executeCurr(String nbbm) { 880 public ScheduleRealInfo executeCurr(String nbbm) {
  881 + if(StringUtils.isEmpty(nbbm))
  882 + return null;
860 return carExecutePlanMap.get(nbbm); 883 return carExecutePlanMap.get(nbbm);
861 } 884 }
862 885
@@ -892,12 +915,12 @@ public class DayOfSchedule { @@ -892,12 +915,12 @@ public class DayOfSchedule {
892 } 915 }
893 916
894 public void reCalcExecPlan(String nbbm) { 917 public void reCalcExecPlan(String nbbm) {
895 - logger.info("reCalcExecPlan...: " + nbbm);  
896 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); 918 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
897 Collections.sort(list, schFCSJComparator); 919 Collections.sort(list, schFCSJComparator);
898 920
899 ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list); 921 ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list);
900 - carExecutePlanMap.put(nbbm, sch); 922 + if(null != sch)
  923 + carExecutePlanMap.put(nbbm, sch);
901 } 924 }
902 925
903 /** 926 /**
@@ -1026,4 +1049,36 @@ public class DayOfSchedule { @@ -1026,4 +1049,36 @@ public class DayOfSchedule {
1026 schAttrCalculator.calcQdzTimePlan(new ArrayList<ScheduleRealInfo>(map.get(k))); 1049 schAttrCalculator.calcQdzTimePlan(new ArrayList<ScheduleRealInfo>(map.get(k)));
1027 } 1050 }
1028 } 1051 }
  1052 +
  1053 + public int dbCount(String lineCode, String currSchDate) {
  1054 + int count = -1;
  1055 +
  1056 + try{
  1057 + count = jdbcTemplate.queryForObject("select count(*) from bsth_c_s_sp_info_real where schedule_date='"+currSchDate+"' and xl_bm='"+lineCode+"'", java.lang.Integer.class);
  1058 +
  1059 + }catch (Exception e){
  1060 + logger.error("", e);
  1061 + }
  1062 + return count;
  1063 + }
  1064 +
  1065 + /**
  1066 + * 重新计算ID对照map
  1067 + */
  1068 + public int reCalcIdMaps(){
  1069 + Collection<ScheduleRealInfo> all = findAll();
  1070 + Map<Long, ScheduleRealInfo> id2SchedulMapCopy = new ConcurrentHashMap<>();
  1071 +
  1072 + for(ScheduleRealInfo sch : all){
  1073 + id2SchedulMapCopy.put(sch.getId(), sch);
  1074 + }
  1075 +
  1076 + id2SchedulMap = id2SchedulMapCopy;
  1077 +
  1078 + return id2SchedulMap.size();
  1079 + }
  1080 +
  1081 + public String sizeString(){
  1082 + return id2SchedulMap.size() + "/" + nbbmScheduleMap.size();
  1083 + }
1029 } 1084 }
1030 \ No newline at end of file 1085 \ No newline at end of file
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
@@ -206,6 +206,8 @@ public class SchAttrCalculator { @@ -206,6 +206,8 @@ public class SchAttrCalculator {
206 * @return 206 * @return
207 */ 207 */
208 public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) { 208 public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) {
  209 + if(list.size()==0)
  210 + return null;
209 String lineCode = list.get(0).getXlBm(); 211 String lineCode = list.get(0).getXlBm();
210 LineConfig conf = lineConfigData.get(lineCode); 212 LineConfig conf = lineConfigData.get(lineCode);
211 213
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
@@ -7,9 +7,18 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; @@ -7,9 +7,18 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
7 import org.slf4j.Logger; 7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
10 -import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;  
11 -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; 10 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  11 +import org.springframework.jdbc.core.JdbcTemplate;
  12 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
12 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
  14 +import org.springframework.transaction.TransactionDefinition;
  15 +import org.springframework.transaction.TransactionStatus;
  16 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  17 +
  18 +import java.sql.PreparedStatement;
  19 +import java.sql.SQLException;
  20 +import java.util.ArrayList;
  21 +import java.util.List;
13 22
14 /** 23 /**
15 * @author PanZhao 24 * @author PanZhao
@@ -24,18 +33,20 @@ public class SchedulePstThread extends Thread { @@ -24,18 +33,20 @@ public class SchedulePstThread extends Thread {
24 ScheduleRealInfoRepository scheduleRepository; 33 ScheduleRealInfoRepository scheduleRepository;
25 34
26 @Autowired 35 @Autowired
27 - NamedParameterJdbcTemplate jdbcTemplate; 36 + JdbcTemplate jdbcTemplate;
28 37
29 @Autowired 38 @Autowired
30 DayOfSchedule dayOfSchedule; 39 DayOfSchedule dayOfSchedule;
31 40
32 Logger logger = LoggerFactory.getLogger(this.getClass()); 41 Logger logger = LoggerFactory.getLogger(this.getClass());
33 42
  43 + static List<ScheduleRealInfo> saveList = new ArrayList<>();
  44 +
34 @Override 45 @Override
35 public void run() { 46 public void run() {
36 47
37 ScheduleRealInfo schedule; 48 ScheduleRealInfo schedule;
38 - for (int i = 0; i < 1000; i++) { 49 + for (int i = 0; i < 500; i++) {
39 schedule = DayOfSchedule.pstBuffer.poll(); 50 schedule = DayOfSchedule.pstBuffer.poll();
40 if (null == schedule) 51 if (null == schedule)
41 break; 52 break;
@@ -45,46 +56,106 @@ public class SchedulePstThread extends Thread { @@ -45,46 +56,106 @@ public class SchedulePstThread extends Thread {
45 continue; 56 continue;
46 } 57 }
47 58
48 - save(schedule); 59 + saveList.add(schedule);
49 } 60 }
  61 +
  62 + //写入数据库
  63 + save();
50 } 64 }
51 65
52 - /**  
53 - * 班次更新到数据库,不走jpa  
54 - *  
55 - * @param sch  
56 - */  
57 - public void save(ScheduleRealInfo sch) {  
58 - if (sch.getId() == null) {  
59 - logger.error("入库的班次没有ID, " + JSON.toJSONString(sch));  
60 - return;  
61 - }  
62 66
63 - if(sch.getSaveFailCount() > 5){  
64 - logger.error("入库失败上限, " + JSON.toJSONString(sch));  
65 - return;  
66 - } 67 + private void save(){
  68 + //记录同步数据
  69 + logger.info("real schedule update size: " + saveList.size());
  70 + logger.info(JSON.toJSONString(saveList));
  71 +
  72 + //批量入库
  73 + update2Db();
  74 +
  75 + //清空容器
  76 + saveList.clear();
  77 + }
  78 +
  79 + private void update2Db(){
  80 + final List<ScheduleRealInfo> pstList = saveList;
  81 + //编程式事务
  82 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  83 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  84 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  85 + TransactionStatus status = tran.getTransaction(def);
  86 +
  87 + try{
  88 + //更新
  89 + jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" +
  90 + ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" +
  91 + ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" +
  92 + ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" +
  93 + ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" +
  94 + ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=? where id=?", new BatchPreparedStatementSetter() {
  95 + @Override
  96 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  97 + ScheduleRealInfo sch = pstList.get(i);
  98 + ps.setString(1, sch.getBcType());
  99 + ps.setInt(2, sch.getBcs()==null?0:sch.getBcs());
  100 + ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj());
  101 + ps.setString(4, sch.getClZbh());
  102 + ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime()));
  103 + ps.setString(6, sch.getDfsj());
  104 + ps.setInt(7, sch.getDirectiveState());
  105 + ps.setInt(8, sch.getFcno()==null?0:sch.getFcno());
  106 + ps.setString(9, sch.getFcsj());
  107 + ps.setString(10, sch.getFcsjActual());
  108 + ps.setString(11, sch.getjGh());
  109 + ps.setString(12, sch.getjName());
  110 + ps.setDouble(13, sch.getJhlc());
  111 + ps.setString(14, sch.getLpName());
  112 + ps.setString(15, sch.getQdzCode());
  113 + ps.setString(16, sch.getQdzName());
  114 + ps.setString(17, sch.getRealExecDate());
  115 + ps.setString(18, sch.getRemarks());
  116 + ps.setString(19, sch.getsGh());
  117 + ps.setString(20, sch.getsName());
  118 + ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
  119 + ps.setString(22, sch.getScheduleDateStr());
  120 + ps.setBoolean(23, sch.isSflj());
  121 + ps.setLong(24, sch.getSpId());
  122 + ps.setInt(25, sch.getStatus());
  123 + ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
  124 + ps.setString(27, sch.getXlBm());
  125 + ps.setString(28, sch.getXlDir());
  126 + ps.setString(29, sch.getXlName());
  127 + ps.setString(30, sch.getZdsj());
  128 + ps.setString(31, sch.getZdsjActual());
  129 + ps.setString(32, sch.getZdzCode());
  130 + ps.setString(33, sch.getZdzName());
  131 + ps.setInt(34, sch.getCcno()==null?0:sch.getCcno());
  132 + ps.setBoolean(35, sch.isDfAuto());
  133 + ps.setString(36, sch.getFgsBm());
  134 + ps.setString(37, sch.getFgsName());
  135 + ps.setString(38, sch.getGsBm());
  136 + ps.setString(39, sch.getGsName());
  137 + ps.setBoolean(40, sch.isOnline());
  138 + ps.setString(41, sch.getAdjustExps());
  139 + ps.setBoolean(42, sch.isReissue());
  140 + ps.setDouble(43, sch.getJhlcOrig());
  141 + ps.setInt(44, sch.getSiginCompate());
  142 + ps.setInt(45, sch.getDriftStatus());
  143 + ps.setBoolean(46, sch.isCcService());
  144 + ps.setString(47, sch.getMajorStationName());
  145 +
  146 + ps.setLong(48, sch.getId());
  147 + }
  148 +
  149 + @Override
  150 + public int getBatchSize() {
  151 + return pstList.size();
  152 + }
  153 + });
67 154
68 - try {  
69 - String sql = "UPDATE bsth_c_s_sp_info_real" +  
70 - " SET adjust_exps=:adjustExps, bc_type=:bcType, bcs=:bcs, bcsj=:bcsj, ccno=:ccno, cl_zbh=:clZbh, df_auto=:dfAuto," +  
71 - " dfsj=:dfsj, directive_state=:directiveState, fcno=:fcno, fcsj=:fcsj, fcsj_actual=:fcsjActual, fgs_bm=:fgsBm, fgs_name=:fgsName, gs_bm=:gsBm, gs_name=:gsName," +  
72 - " j_gh=:jGh, j_name=:jName, jhlc=:jhlc, jhlc_orig=:jhlcOrig, lp_name=:lpName, ONLINE=:online, qdz_code=:qdzCode, qdz_name=:qdzName," +  
73 - " real_exec_date=:realExecDate, reissue=:reissue, remarks=:remarks, s_gh=:sGh, s_name=:sName, schedule_date=:scheduleDate," +  
74 - " schedule_date_str=:scheduleDateStr, sflj=:sflj, sp_id=:spId, STATUS=:status, update_date=:updateDate, xl_bm=:xlBm, xl_dir=:xlDir, xl_name=:xlName," +  
75 - " zdsj=:zdsj, zdsj_actual=:zdsjActual, zdz_code=:zdzCode, zdz_name=:zdzName" +  
76 - " WHERE " +  
77 - " id=:id";  
78 -  
79 - jdbcTemplate.update(sql, new BeanPropertySqlParameterSource(sch));  
80 - sch.setSaveFailCount(0);  
81 - } catch (Exception e) {  
82 - //下次入库再试  
83 - sch.setSaveFailCount(sch.getSaveFailCount()+1);  
84 - dayOfSchedule.save(sch);  
85 -  
86 - logger.error("班次 " + sch.getId() + "入库失败," + JSON.toJSONString(sch));  
87 - logger.error("", e); 155 + tran.commit(status);
  156 + }catch (Exception e){
  157 + tran.rollback(status);
  158 + logger.error("同步数据库失败," , e);
88 } 159 }
89 } 160 }
90 } 161 }
src/main/java/com/bsth/data/schedule/thread/ScheduleRefreshThread.java
@@ -56,7 +56,7 @@ public class ScheduleRefreshThread extends Thread{ @@ -56,7 +56,7 @@ public class ScheduleRefreshThread extends Thread{
56 56
57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ 57 if(oldSchDate == null || !oldSchDate.equals(currSchDate)){
58 58
59 - logger.info(lineCode + "开始翻班, " + currSchDate); 59 + //logger.info(lineCode + "开始翻班, " + currSchDate);
60 60
61 try{ 61 try{
62 //清除指令数据 62 //清除指令数据
@@ -74,6 +74,14 @@ public class ScheduleRefreshThread extends Thread{ @@ -74,6 +74,14 @@ public class ScheduleRefreshThread extends Thread{
74 //重载排班数据 74 //重载排班数据
75 dayOfSchedule.reloadSch(lineCode, currSchDate, false); 75 dayOfSchedule.reloadSch(lineCode, currSchDate, false);
76 logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size()); 76 logger.info(lineCode + "翻班完成, " + currSchDate + " -班次数量:" + dayOfSchedule.findByLineCode(lineCode).size());
  77 +
  78 +
  79 + //校验一下数据库和缓存的数据
  80 + int dbCount = dayOfSchedule.dbCount(lineCode, currSchDate);
  81 + logger.info(lineCode + " 数据库数量:" + dbCount);
  82 + if(dbCount != dayOfSchedule.findByLineCode(lineCode).size()){
  83 + logger.error("异常异常异常,,数据库和缓存数量不一致," + lineCode);
  84 + }
77 } 85 }
78 }catch (Exception e){ 86 }catch (Exception e){
79 logger.error("班次更新失败!! -" + lineCode, e); 87 logger.error("班次更新失败!! -" + lineCode, e);
src/main/java/com/bsth/entity/oil/Dlb.java
@@ -73,7 +73,7 @@ public class Dlb { @@ -73,7 +73,7 @@ public class Dlb {
73 private String fgsname; 73 private String fgsname;
74 74
75 75
76 - private String lp; 76 + private String lp="";
77 77
78 public Integer getId() { 78 public Integer getId() {
79 return id; 79 return id;
src/main/java/com/bsth/entity/oil/Ylb.java
@@ -56,7 +56,7 @@ public class Ylb { @@ -56,7 +56,7 @@ public class Ylb {
56 //进场顺序(根据最先出场和最后进场来关联车辆的存油量) 56 //进场顺序(根据最先出场和最后进场来关联车辆的存油量)
57 private int jcsx; 57 private int jcsx;
58 58
59 - private String lp; 59 + private String lp="";
60 @Transient 60 @Transient
61 private String bglyh; 61 private String bglyh;
62 62
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
@@ -24,7 +24,6 @@ import java.util.Set; @@ -24,7 +24,6 @@ import java.util.Set;
24 public class ScheduleRealInfo { 24 public class ScheduleRealInfo {
25 /** 主键Id */ 25 /** 主键Id */
26 @Id 26 @Id
27 - @GeneratedValue  
28 private Long id; 27 private Long id;
29 28
30 /** 计划ID */ 29 /** 计划ID */
src/main/java/com/bsth/repository/LineVersionsRepository.java
@@ -73,4 +73,10 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int @@ -73,4 +73,10 @@ public interface LineVersionsRepository extends BaseRepository&lt;LineVersions, Int
73 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")") 73 @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")")
74 public LineVersions findBylineIdAndVersions(Integer id, Integer versions); 74 public LineVersions findBylineIdAndVersions(Integer id, Integer versions);
75 75
  76 +
  77 + /**
  78 + * 获取线路版本的上一个版本
  79 + */
  80 + @Query(value = " SELECT lv.versions FROM LineVersions lv where lv.line.id = ?1 and lv.status=1")
  81 + public Integer findCurrentVersion(Integer id);
76 } 82 }
src/main/java/com/bsth/repository/oil/YlbRepository.java
@@ -52,7 +52,11 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -52,7 +52,11 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
52 + " order by nbbm , rq desc,jcsx desc",nativeQuery=true) 52 + " order by nbbm , rq desc,jcsx desc",nativeQuery=true)
53 List<Ylb> listByRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm); 53 List<Ylb> listByRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm);
54 54
55 - 55 + @Query(value="select * from bsth_c_ylb where rq>=?1 "
  56 + + " and rq<= ?2 and ssgsdm =?3"
  57 + + " and fgsdm =?4 and xlbm like %?5% "
  58 + + " order by nbbm , rq desc,jcsx desc",nativeQuery=true)
  59 + List<Ylb> listByMonthJcsx(String rq,String rq2,String gsbm,String fgsbm,String xlbm);
56 60
57 /** 61 /**
58 * 当天YLB信息 62 * 当天YLB信息
src/main/java/com/bsth/service/LineVersionsService.java
@@ -33,6 +33,9 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt; @@ -33,6 +33,9 @@ public interface LineVersionsService extends BaseService&lt;LineVersions, Integer&gt;
33 List<LineVersions> lineUpdate(); 33 List<LineVersions> lineUpdate();
34 34
35 LineVersions findLineVersionsMax(int lineId); 35 LineVersions findLineVersionsMax(int lineId);
  36 +
  37 + // 返回当前线路版本
  38 + Integer findCurrentVersion(int lineId);
36 39
37 Map<String, Object> add(Map<String, Object> map); 40 Map<String, Object> add(Map<String, Object> map);
38 41
src/main/java/com/bsth/service/calc/impl/CalcWaybillServiceImpl.java
@@ -69,7 +69,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -69,7 +69,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
69 return newMap; 69 return newMap;
70 } 70 }
71 71
72 - String sql = "select c.id,c.out_config,c.start_opt,c.trust,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id"; 72 + String sql = "select c.id,c.out_config,c.start_opt,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id";
73 if(line.length() != 0){ 73 if(line.length() != 0){
74 sql += " where t.line_code = " + line; 74 sql += " where t.line_code = " + line;
75 } 75 }
@@ -82,7 +82,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer @@ -82,7 +82,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl&lt;CalcWaybill, Integer
82 m.put("id", rs.getLong("id")); 82 m.put("id", rs.getLong("id"));
83 m.put("out_config", rs.getString("out_config")); 83 m.put("out_config", rs.getString("out_config"));
84 m.put("start_opt", rs.getString("start_opt")); 84 m.put("start_opt", rs.getString("start_opt"));
85 - m.put("trust", rs.getString("trust"));  
86 m.put("line_code", rs.getString("line_code")); 85 m.put("line_code", rs.getString("line_code"));
87 return m; 86 return m;
88 }}); 87 }});
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
@@ -441,7 +441,7 @@ public class FormsServiceImpl implements FormsService { @@ -441,7 +441,7 @@ public class FormsServiceImpl implements FormsService {
441 + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name " 441 + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name "
442 + "FROM bsth_c_s_sp_info_real r where 1=1 " 442 + "FROM bsth_c_s_sp_info_real r where 1=1 "
443 + " and r.schedule_date_str='"+date + "' " 443 + " and r.schedule_date_str='"+date + "' "
444 - + " and r.xl_bm like '%"+line+"%' " 444 + + " and r.xl_bm = '"+line+"' "
445 + " and r.gs_bm like '%"+gsdmShif+"%' " 445 + " and r.gs_bm like '%"+gsdmShif+"%' "
446 + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t" 446 + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t"
447 + " GROUP BY t.schedule_date,t.j_name,t.s_name, " 447 + " GROUP BY t.schedule_date,t.j_name,t.s_name, "
@@ -787,27 +787,25 @@ public class FormsServiceImpl implements FormsService { @@ -787,27 +787,25 @@ public class FormsServiceImpl implements FormsService {
787 List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); 787 List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm");
788 for (int i = 0; i < listYlb.size(); i++) { 788 for (int i = 0; i < listYlb.size(); i++) {
789 Ylb y=listYlb.get(i); 789 Ylb y=listYlb.get(i);
790 - String jsy=y.getJsy();  
791 - String line=y.getXlbm();  
792 - String clzbh=y.getNbbm();  
793 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
794 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
795 - for (int j = 0; j < listReal.size(); j++) {  
796 - ScheduleRealInfo s=listReal.get(j);  
797 - if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)  
798 - &&s.getXlBm().equals(line)){  
799 - if(y.getLp()==null){  
800 - newList.add(s);  
801 - Set<ChildTaskPlan> cts = s.getcTasks();  
802 - if(cts != null && cts.size() > 0){  
803 - newList_.add(s);  
804 - }else{  
805 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
806 - newList_.add(s);  
807 - }  
808 - }  
809 - }else{  
810 - if(y.getLp().equals(s.getLpName())){ 790 + boolean fage=false;
  791 + if(xlbm.equals("")){
  792 + fage=true;
  793 + }else{
  794 + if(xlbm.equals(y.getXlbm())){
  795 + fage=true;
  796 + }
  797 + }
  798 + if(fage){
  799 + String jsy=y.getJsy();
  800 + String line=y.getXlbm();
  801 + String clzbh=y.getNbbm();
  802 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  803 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  804 + for (int j = 0; j < listReal.size(); j++) {
  805 + ScheduleRealInfo s=listReal.get(j);
  806 + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
  807 + &&s.getXlBm().equals(line)){
  808 + if(y.getLp()==null){
811 newList.add(s); 809 newList.add(s);
812 Set<ChildTaskPlan> cts = s.getcTasks(); 810 Set<ChildTaskPlan> cts = s.getcTasks();
813 if(cts != null && cts.size() > 0){ 811 if(cts != null && cts.size() > 0){
@@ -817,65 +815,75 @@ public class FormsServiceImpl implements FormsService { @@ -817,65 +815,75 @@ public class FormsServiceImpl implements FormsService {
817 newList_.add(s); 815 newList_.add(s);
818 } 816 }
819 } 817 }
  818 + }else{
  819 + if(y.getLp().equals(s.getLpName())){
  820 + newList.add(s);
  821 + Set<ChildTaskPlan> cts = s.getcTasks();
  822 + if(cts != null && cts.size() > 0){
  823 + newList_.add(s);
  824 + }else{
  825 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  826 + newList_.add(s);
  827 + }
  828 + }
  829 + }
820 } 830 }
821 } 831 }
822 } 832 }
  833 + double jhgl=culateMileageService.culateJhgl(newList);
  834 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  835 + double yygl=culateMileageService.culateSjgl(newList_);
  836 + double ljgl=culateMileageService.culateLjgl(newList_);
  837 + double ksgl=culateMileageService.culateKsgl(newList_);
  838 + double jcgl=culateMileageService.culateJccgl(newList_);
  839 +
  840 + double zyygl=Arith.add(yygl, ljgl);
  841 + double zksgl=Arith.add(ksgl, jcgl);
  842 +
  843 + Singledata sin=new Singledata();
  844 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  845 +
  846 + sin.setEmptMileage(String.valueOf(zksgl));
  847 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  848 + sin.setxL(y.getXlbm());
  849 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
  850 + sin.setClzbh(clzbh);
  851 + sin.setJsy(jsy);
  852 + sin.setrQ(startDate);
  853 + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  854 + sin.setSgh("");
  855 + sin.setsName("");
  856 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  857 + sin.setHyl(df.format(y.getYh()));
  858 + sin.setJzl(df.format(y.getJzl()));
  859 + sin.setUnyyyl(df.format(y.getSh()));
  860 + listY.add(sin);
823 } 861 }
824 - double jhgl=culateMileageService.culateJhgl(newList);  
825 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
826 - double yygl=culateMileageService.culateSjgl(newList_);  
827 - double ljgl=culateMileageService.culateLjgl(newList_);  
828 - double ksgl=culateMileageService.culateKsgl(newList_);  
829 - double jcgl=culateMileageService.culateJccgl(newList_);  
830 862
831 - double zyygl=Arith.add(yygl, ljgl);  
832 - double zksgl=Arith.add(ksgl, jcgl);  
833 -  
834 - Singledata sin=new Singledata();  
835 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
836 -  
837 - sin.setEmptMileage(String.valueOf(zksgl));  
838 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
839 - sin.setxL(y.getXlbm());  
840 - sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));  
841 - sin.setClzbh(clzbh);  
842 - sin.setJsy(jsy);  
843 - sin.setrQ(startDate);  
844 - sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
845 - sin.setSgh("");  
846 - sin.setsName("");  
847 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
848 - sin.setHyl(df.format(y.getYh()));  
849 - sin.setJzl(df.format(y.getJzl()));  
850 - sin.setUnyyyl(df.format(y.getSh()));  
851 - listY.add(sin);  
852 } 863 }
853 864
854 List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); 865 List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm");
855 for (int i = 0; i < listDlb.size(); i++) { 866 for (int i = 0; i < listDlb.size(); i++) {
856 -  
857 Dlb y=listDlb.get(i); 867 Dlb y=listDlb.get(i);
858 - String jsy=y.getJsy();  
859 - String line=y.getXlbm();  
860 - String clzbh=y.getNbbm();  
861 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
862 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
863 - for (int j = 0; j < listReal.size(); j++) {  
864 - ScheduleRealInfo s=listReal.get(j);  
865 - if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)  
866 - &&s.getXlBm().equals(line)){  
867 - if(y.getLp()==null){  
868 - newList.add(s);  
869 - Set<ChildTaskPlan> cts = s.getcTasks();  
870 - if(cts != null && cts.size() > 0){  
871 - newList_.add(s);  
872 - }else{  
873 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
874 - newList_.add(s);  
875 - }  
876 - }  
877 - }else{  
878 - if(y.getLp().equals(s.getLpName())){ 868 + boolean fage=false;
  869 + if(xlbm.equals("")){
  870 + fage=true;
  871 + }else{
  872 + if(xlbm.equals(y.getXlbm())){
  873 + fage=true;
  874 + }
  875 + }
  876 + if(fage){
  877 + String jsy=y.getJsy();
  878 + String line=y.getXlbm();
  879 + String clzbh=y.getNbbm();
  880 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  881 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  882 + for (int j = 0; j < listReal.size(); j++) {
  883 + ScheduleRealInfo s=listReal.get(j);
  884 + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
  885 + &&s.getXlBm().equals(line)){
  886 + if(y.getLp()==null){
879 newList.add(s); 887 newList.add(s);
880 Set<ChildTaskPlan> cts = s.getcTasks(); 888 Set<ChildTaskPlan> cts = s.getcTasks();
881 if(cts != null && cts.size() > 0){ 889 if(cts != null && cts.size() > 0){
@@ -885,38 +893,50 @@ public class FormsServiceImpl implements FormsService { @@ -885,38 +893,50 @@ public class FormsServiceImpl implements FormsService {
885 newList_.add(s); 893 newList_.add(s);
886 } 894 }
887 } 895 }
  896 + }else{
  897 + if(y.getLp().equals(s.getLpName())){
  898 + newList.add(s);
  899 + Set<ChildTaskPlan> cts = s.getcTasks();
  900 + if(cts != null && cts.size() > 0){
  901 + newList_.add(s);
  902 + }else{
  903 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  904 + newList_.add(s);
  905 + }
  906 + }
  907 + }
888 } 908 }
889 } 909 }
890 } 910 }
  911 + double jhgl=culateMileageService.culateJhgl(newList);
  912 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  913 + double yygl=culateMileageService.culateSjgl(newList_);
  914 + double ljgl=culateMileageService.culateLjgl(newList_);
  915 + double ksgl=culateMileageService.culateKsgl(newList_);
  916 + double jcgl=culateMileageService.culateJccgl(newList_);
  917 +
  918 + double zyygl=Arith.add(yygl, ljgl);
  919 + double zksgl=Arith.add(ksgl, jcgl);
  920 +
  921 + Singledata sin=new Singledata();
  922 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  923 +
  924 + sin.setEmptMileage(String.valueOf(zksgl));
  925 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  926 + sin.setxL(y.getXlbm());
  927 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
  928 + sin.setClzbh(clzbh);
  929 + sin.setJsy(jsy);
  930 + sin.setrQ(startDate);
  931 + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  932 + sin.setSgh("");
  933 + sin.setsName("");
  934 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  935 + sin.setHyl(df.format(y.getHd()));
  936 + sin.setJzl(df.format(y.getCdl()));
  937 + sin.setUnyyyl(df.format(y.getSh()));
  938 + listD.add(sin);
891 } 939 }
892 - double jhgl=culateMileageService.culateJhgl(newList);  
893 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
894 - double yygl=culateMileageService.culateSjgl(newList_);  
895 - double ljgl=culateMileageService.culateLjgl(newList_);  
896 - double ksgl=culateMileageService.culateKsgl(newList_);  
897 - double jcgl=culateMileageService.culateJccgl(newList_);  
898 -  
899 - double zyygl=Arith.add(yygl, ljgl);  
900 - double zksgl=Arith.add(ksgl, jcgl);  
901 -  
902 - Singledata sin=new Singledata();  
903 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
904 -  
905 - sin.setEmptMileage(String.valueOf(zksgl));  
906 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
907 - sin.setxL(y.getXlbm());  
908 - sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));  
909 - sin.setClzbh(clzbh);  
910 - sin.setJsy(jsy);  
911 - sin.setrQ(startDate);  
912 - sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
913 - sin.setSgh("");  
914 - sin.setsName("");  
915 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
916 - sin.setHyl(df.format(y.getHd()));  
917 - sin.setJzl(df.format(y.getCdl()));  
918 - sin.setUnyyyl(df.format(y.getSh()));  
919 - listD.add(sin);  
920 } 940 }
921 941
922 Collections.sort(listY,new SingledataByXlbm()); 942 Collections.sort(listY,new SingledataByXlbm());
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
@@ -250,5 +250,13 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ @@ -250,5 +250,13 @@ public class LineVersionsServiceImpl extends BaseServiceImpl&lt;LineVersions, Integ
250 } 250 }
251 return resultMap; 251 return resultMap;
252 } 252 }
  253 +
  254 + /**
  255 + * 获取当前线路版本号
  256 + */
  257 + @Override
  258 + public Integer findCurrentVersion(int lineId) {
  259 + return repository.findCurrentVersion(lineId);
  260 + }
253 261
254 } 262 }
src/main/java/com/bsth/service/impl/StationServiceImpl.java
@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject; @@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONObject;
18 import com.bsth.common.ResponseCode; 18 import com.bsth.common.ResponseCode;
19 import com.bsth.entity.Line; 19 import com.bsth.entity.Line;
20 import com.bsth.entity.LineInformation; 20 import com.bsth.entity.LineInformation;
  21 +import com.bsth.entity.LineVersions;
21 import com.bsth.entity.Section; 22 import com.bsth.entity.Section;
22 import com.bsth.entity.SectionRoute; 23 import com.bsth.entity.SectionRoute;
23 import com.bsth.entity.SectionRouteCache; 24 import com.bsth.entity.SectionRouteCache;
@@ -26,12 +27,14 @@ import com.bsth.entity.StationRoute; @@ -26,12 +27,14 @@ import com.bsth.entity.StationRoute;
26 import com.bsth.entity.StationRouteCache; 27 import com.bsth.entity.StationRouteCache;
27 import com.bsth.repository.LineInformationRepository; 28 import com.bsth.repository.LineInformationRepository;
28 import com.bsth.repository.LineRepository; 29 import com.bsth.repository.LineRepository;
  30 +import com.bsth.repository.LineVersionsRepository;
29 import com.bsth.repository.SectionRepository; 31 import com.bsth.repository.SectionRepository;
30 import com.bsth.repository.SectionRouteCacheRepository; 32 import com.bsth.repository.SectionRouteCacheRepository;
31 import com.bsth.repository.SectionRouteRepository; 33 import com.bsth.repository.SectionRouteRepository;
32 import com.bsth.repository.StationRepository; 34 import com.bsth.repository.StationRepository;
33 import com.bsth.repository.StationRouteCacheRepository; 35 import com.bsth.repository.StationRouteCacheRepository;
34 import com.bsth.repository.StationRouteRepository; 36 import com.bsth.repository.StationRouteRepository;
  37 +import com.bsth.service.LineVersionsService;
35 import com.bsth.service.StationService; 38 import com.bsth.service.StationService;
36 import com.bsth.util.GetUIDAndCode; 39 import com.bsth.util.GetUIDAndCode;
37 import com.bsth.util.TransGPS; 40 import com.bsth.util.TransGPS;
@@ -83,6 +86,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -83,6 +86,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
83 @Autowired 86 @Autowired
84 private SectionRouteCacheRepository sectionRouteCacheRepository; 87 private SectionRouteCacheRepository sectionRouteCacheRepository;
85 88
  89 + @Autowired
  90 + LineVersionsRepository lineVersionsRepository;
  91 +
86 private GeoUtils geoUtils; 92 private GeoUtils geoUtils;
87 93
88 Logger logger = LoggerFactory.getLogger(this.getClass()); 94 Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -293,20 +299,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -293,20 +299,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
293 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString()); 299 Integer stationId = Integer.parseInt(isHaveMap.get("id").toString());
294 arg0 = repository.findOne(stationId); 300 arg0 = repository.findOne(stationId);
295 301
296 - if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)  
297 - List<Station> list = new ArrayList<>();  
298 - list.add(arg0);  
299 - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);  
300 - Station station = stationlist.get(0);  
301 - // 站点编码  
302 - long stationCode = GetUIDAndCode.getStationId();  
303 - station.setStationCod(String.valueOf(stationCode));  
304 - station.setId((int)stationCode);  
305 - station.setCreateDate(null);  
306 - station.setUpdateDate(null);  
307 - repository.save(station);  
308 - arg0 = station;  
309 - } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 302 + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  303 + arg0 = loopStartStation;
  304 + } else {
310 List<Station> list = new ArrayList<>(); 305 List<Station> list = new ArrayList<>();
311 list.add(arg0); 306 list.add(arg0);
312 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); 307 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
@@ -318,12 +313,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -318,12 +313,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
318 station.setCreateDate(null); 313 station.setCreateDate(null);
319 station.setUpdateDate(null); 314 station.setUpdateDate(null);
320 repository.save(station); 315 repository.save(station);
321 - arg0 = station;  
322 - loopStartStation = arg0;  
323 - repository.save(arg0);  
324 - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站  
325 - arg0 = loopStartStation;  
326 - } 316 + arg0 = station;
  317 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  318 + loopStartStation = arg0;
  319 + }
  320 + }
327 }else { 321 }else {
328 // 站点编码 322 // 站点编码
329 long stationCode = GetUIDAndCode.getStationId(); 323 long stationCode = GetUIDAndCode.getStationId();
@@ -417,8 +411,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -417,8 +411,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
417 // 中途站 411 // 中途站
418 route.setStationMark("Z"); 412 route.setStationMark("Z");
419 } 413 }
420 - // 版本号  
421 - route.setVersions(versions); 414 + // 版本号(获取线路当前版本)
  415 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  416 + route.setVersions(version);
422 // 站点ID 417 // 站点ID
423 route.setStation(arg0); 418 route.setStation(arg0);
424 // 方向 419 // 方向
@@ -782,68 +777,65 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -782,68 +777,65 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
782 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); 777 Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString());
783 // 说明 778 // 说明
784 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); 779 String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString();
785 - if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) {  
786 - stationId = Integer.parseInt(isHaveMap.get("id").toString());  
787 - }else {  
788 - // 站点编码  
789 - stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();  
790 - // 站点ID  
791 - stationId = Integer.valueOf(stationCod);  
792 - // 圆半径  
793 - Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());  
794 - // 图形类型  
795 - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();  
796 - // 创建人  
797 - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());  
798 - // 修改人  
799 - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());  
800 - // 城建坐标经度  
801 - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());  
802 - // 城建坐标纬度  
803 - Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());  
804 - // 道路编码  
805 - String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();  
806 - // 原坐标类型  
807 - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();  
808 - // WGS经纬度  
809 - Float gLonx = null;  
810 - // WGS纬度  
811 - Float gLaty = null;  
812 - if(bJwpointsArray.length>0) {  
813 - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);  
814 - gLonx = (float)resultPoint.getLng();  
815 - gLaty = (float)resultPoint.getLat();  
816 - }  
817 - // 多边形原坐标点集合  
818 - String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();  
819 - // 多边形WGS坐标点集合  
820 - String gPloygonGrid ="";  
821 - if(!bPloygonGrid.equals("")) {  
822 - String bPloygonGridArray[] = bPloygonGrid.split(",");  
823 - int bLen_ = bPloygonGridArray.length;  
824 - for(int b = 0 ;b<bLen_;b++) {  
825 - String tempArray[]= bPloygonGridArray[b].split(" ");  
826 - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);  
827 - if(b==0) {  
828 - gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());  
829 - }else {  
830 - gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());  
831 - }  
832 - } 780 + // 站点编码
  781 + stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString();
  782 + // 站点ID
  783 + stationId = Integer.valueOf(stationCod);
  784 + // 圆半径
  785 + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString());
  786 + // 图形类型
  787 + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString();
  788 + // 创建人
  789 + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString());
  790 + // 修改人
  791 + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString());
  792 + // 城建坐标经度
  793 + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString());
  794 + // 城建坐标纬度
  795 + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString());
  796 + // 道路编码
  797 + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString();
  798 + // 原坐标类型
  799 + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString();
  800 + // WGS经纬度
  801 + Float gLonx = null;
  802 + // WGS纬度
  803 + Float gLaty = null;
  804 + if(bJwpointsArray.length>0) {
  805 + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]);
  806 + gLonx = (float)resultPoint.getLng();
  807 + gLaty = (float)resultPoint.getLat();
  808 + }
  809 + // 多边形原坐标点集合
  810 + String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString();
  811 + // 多边形WGS坐标点集合
  812 + String gPloygonGrid ="";
  813 + if(!bPloygonGrid.equals("")) {
  814 + String bPloygonGridArray[] = bPloygonGrid.split(",");
  815 + int bLen_ = bPloygonGridArray.length;
  816 + for(int b = 0 ;b<bLen_;b++) {
  817 + String tempArray[]= bPloygonGridArray[b].split(" ");
  818 + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]);
  819 + if(b==0) {
  820 + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  821 + }else {
  822 + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat());
  823 + }
833 } 824 }
834 - if(bPloygonGrid.equals(""))  
835 - bPloygonGrid = null;  
836 - else  
837 - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";  
838 - if(gPloygonGrid.equals(""))  
839 - gPloygonGrid = null;  
840 - else  
841 - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";  
842 - // 保存站点  
843 - repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,  
844 - gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,  
845 - shapesType, versions, descriptions, createBy, updateBy,stationId);  
846 } 825 }
  826 + if(bPloygonGrid.equals(""))
  827 + bPloygonGrid = null;
  828 + else
  829 + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))";
  830 + if(gPloygonGrid.equals(""))
  831 + gPloygonGrid = null;
  832 + else
  833 + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))";
  834 + // 保存站点
  835 + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints,
  836 + gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius,
  837 + shapesType, versions, descriptions, createBy, updateBy,stationId);
  838 +
847 Station station = repository.findOne(stationId); 839 Station station = repository.findOne(stationId);
848 StationRoute arg0 = new StationRoute(); 840 StationRoute arg0 = new StationRoute();
849 // 距离 841 // 距离
@@ -1200,8 +1192,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1200,8 +1192,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1200 sectionRoute.setLine(resultLine); 1192 sectionRoute.setLine(resultLine);
1201 // 路段编码 1193 // 路段编码
1202 sectionRoute.setSectionCode(sectionCode); 1194 sectionRoute.setSectionCode(sectionCode);
1203 - // 版本  
1204 - sectionRoute.setVersions(versions); 1195 + // 版本号(获取线路当前版本)
  1196 + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId());
  1197 + sectionRoute.setVersions(version);
1205 sectionRoute.setDestroy(destroy); 1198 sectionRoute.setDestroy(destroy);
1206 // 方向 1199 // 方向
1207 sectionRoute.setDirections(directions); 1200 sectionRoute.setDirections(directions);
@@ -1229,8 +1222,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1229,8 +1222,8 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1229 String libraryPointstr = s.getbJwpoints(); 1222 String libraryPointstr = s.getbJwpoints();
1230 String points[] = libraryPointstr.toString().split(" "); 1223 String points[] = libraryPointstr.toString().split(" ");
1231 Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1])); 1224 Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1]));
1232 - // 在100m内认为是同一个站点  
1233 - Circle circle = new Circle(center, 100); 1225 + // 在40m内认为是同一个站点
  1226 + Circle circle = new Circle(center, 40);
1234 // 匹配到了用数据库中的点替换 1227 // 匹配到了用数据库中的点替换
1235 if (geoUtils.isPointInCircle(point, circle)) { 1228 if (geoUtils.isPointInCircle(point, circle)) {
1236 map.put("name", s.getStationName().toString()); 1229 map.put("name", s.getStationName().toString());
@@ -1372,20 +1365,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1372,20 +1365,9 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1372 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString()); 1365 Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString());
1373 arg0 = repository.findOne(stationId); 1366 arg0 = repository.findOne(stationId);
1374 1367
1375 - if ((i==0 || i==stationsArray.size()-1) && resultLine.getLinePlayType() != 1) {// (起终点站)  
1376 - List<Station> list = new ArrayList<>();  
1377 - list.add(arg0);  
1378 - List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);  
1379 - Station station = stationlist.get(0);  
1380 - // 站点编码  
1381 - long stationCode = GetUIDAndCode.getStationId();  
1382 - station.setStationCod(String.valueOf(stationCode));  
1383 - station.setId((int)stationCode);  
1384 - station.setCreateDate(null);  
1385 - station.setUpdateDate(null);  
1386 - repository.save(station);  
1387 - arg0 = station;  
1388 - } else if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 1368 + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1369 + arg0 = loopStartStation;
  1370 + } else {
1389 List<Station> list = new ArrayList<>(); 1371 List<Station> list = new ArrayList<>();
1390 list.add(arg0); 1372 list.add(arg0);
1391 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); 1373 List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class);
@@ -1397,12 +1379,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1397,12 +1379,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1397 station.setCreateDate(null); 1379 station.setCreateDate(null);
1398 station.setUpdateDate(null); 1380 station.setUpdateDate(null);
1399 repository.save(station); 1381 repository.save(station);
1400 - arg0 = station;  
1401 - loopStartStation = arg0;  
1402 - repository.save(arg0);  
1403 - } else if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站  
1404 - arg0 = loopStartStation;  
1405 - } 1382 + arg0 = station;
  1383 + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站
  1384 + loopStartStation = arg0;
  1385 + }
  1386 + }
1406 }else { 1387 }else {
1407 // 站点编码 1388 // 站点编码
1408 long stationCode = GetUIDAndCode.getStationId(); 1389 long stationCode = GetUIDAndCode.getStationId();
src/main/java/com/bsth/service/oil/YlbService.java
@@ -19,7 +19,7 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{ @@ -19,7 +19,7 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{
19 19
20 Map<String, Object> sumYlb(Map<String, Object> map); 20 Map<String, Object> sumYlb(Map<String, Object> map);
21 String checkJsy(Map<String, Object> map); 21 String checkJsy(Map<String, Object> map);
22 - List<Ylb> oilListMonth(Map<String, Object> map); 22 + List<Map<String, Object>> oilListMonth(Map<String, Object> map);
23 List<Ylb> listYlb(Map<String, Object> map); 23 List<Ylb> listYlb(Map<String, Object> map);
24 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx); 24 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx);
25 25
src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java
@@ -576,55 +576,44 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS @@ -576,55 +576,44 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
576 if(map.get("nbbm_eq")!=null){ 576 if(map.get("nbbm_eq")!=null){
577 nbbm=map.get("nbbm_eq").toString(); 577 nbbm=map.get("nbbm_eq").toString();
578 } 578 }
579 - List<Dlb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm);  
580 -// List<Cdl> cylList=cdlRepository.obtainCdl(nbbm, gsbm);  
581 - List<Dlb> ylbList=repository.obtainDl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");  
582 - List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,1,gsbm);  
583 - for (int i = 0; i < ylxxbList.size(); i++) {  
584 - Boolean fage=true;  
585 - Ylxxb y1=ylxxbList.get(i);  
586 - for(int y=0;y<ylbList.size();y++){  
587 - Dlb y2=ylbList.get(y);  
588 - if(y1.getNbbm().equals(y2.getNbbm())){  
589 - fage=false;  
590 - break;  
591 - } 579 +
  580 + String sql="select * from bsth_c_jdl j where j.gs_bm ='"+gsbm+"' "
  581 + + " and j.fgs_bm ='"+fgsbm+"' and rq ='"+rq+"' "
  582 + + "and nbbm not in (select nbbm from bsth_c_dlb d"
  583 + + " where ssgsdm ='"+gsbm+"' and fgsdm ='"+fgsbm+"'"
  584 + + " and rq='"+rq+"')";
  585 + List<Jdl> listJdl=jdbcTemplate.query(sql,
  586 + new RowMapper<Jdl>(){
  587 + @Override
  588 + public Jdl mapRow(ResultSet rs, int rowNum) throws SQLException {
  589 + Jdl s = new Jdl();
  590 + s.setNbbm(rs.getString("nbbm"));
  591 + s.setGsBm(rs.getString("gs_bm"));
  592 + s.setFgsBm(rs.getString("fgs_bm"));
  593 + s.setJdl(rs.getDouble("jdl"));
  594 + s.setRq(rs.getDate("rq"));
  595 + return s;
592 } 596 }
593 -  
594 - if(fage){  
595 - Dlb t=new Dlb();  
596 - t.setNbbm(y1.getNbbm());  
597 - t.setRq(y1.getYyrq());  
598 - t.setJsy(y1.getJsy());  
599 - t.setCdl(y1.getJzl());  
600 - t.setSsgsdm(y1.getGsdm());  
601 - String fgsdm="";  
602 - if(null!=carsMap.get(y1.getNbbm())){  
603 - fgsdm=carsMap.get(y1.getNbbm());  
604 - }  
605 - t.setFgsdm(fgsdm); 597 + });
  598 + for (int i = 0; i < listJdl.size(); i++) {
  599 + Jdl j=listJdl.get(i);
  600 + Dlb t=new Dlb();
  601 + Line line= BasicData.nbbm2LineMap.get(j.getNbbm());
  602 + if(null !=line){
  603 + t.setCdl(j.getJdl());
  604 + t.setNbbm(j.getNbbm());
  605 + t.setRq(j.getRq());
  606 + t.setJsy("");
  607 + t.setCdl(j.getJdl());
  608 + t.setSsgsdm(j.getGsBm());
  609 + t.setFgsdm(j.getFgsBm());
  610 + t.setJzcd(100.0);
  611 + t.setCzcd(100.0);
  612 + t.setHd(0.0);
606 t.setJcsx(1); 613 t.setJcsx(1);
607 - Line line= BasicData.nbbm2LineMap.get(y1.getNbbm());  
608 - if(null !=line){  
609 - t.setXlbm(line.getLineCode());  
610 - boolean status=true;  
611 - for (int j = 0; j < ylListBe.size(); j++) {  
612 - Dlb b=ylListBe.get(j);  
613 - if(b.getNbbm().equals(y1.getNbbm())){  
614 - t.setCzcd(b.getJzcd());  
615 - status=false;  
616 - break;  
617 - }  
618 - }  
619 - if(status){  
620 - t.setCzcd(0.0);  
621 - }  
622 - t.setJzcd(100.0);  
623 - t.setHd(0.0);  
624 - if(fgsdm.equals(fgsbm)){  
625 - repository.save(t);  
626 - }  
627 - } 614 + t.setXlbm(line.getLineCode());
  615 + t.setLp("");
  616 + repository.save(t);
628 } 617 }
629 } 618 }
630 newMap.put("status", ResponseCode.SUCCESS); 619 newMap.put("status", ResponseCode.SUCCESS);
@@ -983,17 +972,22 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS @@ -983,17 +972,22 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
983 for (int j = 0; j < dlbList.size(); j++) { 972 for (int j = 0; j < dlbList.size(); j++) {
984 Dlb t=dlbList.get(j); 973 Dlb t=dlbList.get(j);
985 boolean fage=true; 974 boolean fage=true;
986 - for (int i = 0; i < listpbDc.size(); i++) {  
987 - Map<String, Object> m = listpbDc.get(i);  
988 - if(t.getNbbm().equals(m.get("clZbh").toString())  
989 - &&t.getJsy().equals(m.get("jGh").toString())  
990 - &&t.getXlbm().equals(m.get("xlBm").toString())  
991 - &&t.getLp().equals(m.get("lpName").toString())){  
992 - //该条记录不用删除  
993 - fage =false;  
994 - dlbList_upd.add(t); 975 + if(t.getLp().isEmpty()){
  976 + fage=false;
  977 + }else{
  978 + for (int i = 0; i < listpbDc.size(); i++) {
  979 + Map<String, Object> m = listpbDc.get(i);
  980 + if(t.getNbbm().equals(m.get("clZbh").toString())
  981 + &&t.getJsy().equals(m.get("jGh").toString())
  982 + &&t.getXlbm().equals(m.get("xlBm").toString())
  983 + &&t.getLp().equals(m.get("lpName").toString())){
  984 + //该条记录不用删除
  985 + fage =false;
  986 + dlbList_upd.add(t);
  987 + }
995 } 988 }
996 } 989 }
  990 +
997 if(fage){ 991 if(fage){
998 dlbList_del.add(t); 992 dlbList_del.add(t);
999 } 993 }
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
@@ -38,6 +38,7 @@ import com.bsth.entity.oil.Ylb; @@ -38,6 +38,7 @@ import com.bsth.entity.oil.Ylb;
38 import com.bsth.entity.oil.Ylxxb; 38 import com.bsth.entity.oil.Ylxxb;
39 import com.bsth.entity.search.CustomerSpecs; 39 import com.bsth.entity.search.CustomerSpecs;
40 import com.bsth.repository.CarsRepository; 40 import com.bsth.repository.CarsRepository;
  41 +import com.bsth.repository.LineRepository;
41 import com.bsth.repository.oil.CylRepository; 42 import com.bsth.repository.oil.CylRepository;
42 import com.bsth.repository.oil.DlbRepository; 43 import com.bsth.repository.oil.DlbRepository;
43 import com.bsth.repository.oil.YlbRepository; 44 import com.bsth.repository.oil.YlbRepository;
@@ -73,6 +74,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -73,6 +74,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
73 @Autowired 74 @Autowired
74 CarsRepository carsRepository; 75 CarsRepository carsRepository;
75 76
  77 +
  78 + @Autowired
  79 + LineRepository lineRepository;
  80 +
76 @Autowired 81 @Autowired
77 ScheduleRealInfoService scheduleRealInfoService; 82 ScheduleRealInfoService scheduleRealInfoService;
78 83
@@ -832,7 +837,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -832,7 +837,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
832 837
833 838
834 @Override 839 @Override
835 - public List<Ylb> oilListMonth(Map<String, Object> map) { 840 + public List<Map<String, Object>> oilListMonth(Map<String, Object> map) {
  841 + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
  842 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
  843 +
836 String type=map.get("type").toString(); 844 String type=map.get("type").toString();
837 String date=map.get("date").toString().trim(); 845 String date=map.get("date").toString().trim();
838 String gsdm=map.get("gsdm").toString(); 846 String gsdm=map.get("gsdm").toString();
@@ -840,7 +848,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -840,7 +848,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
840 String date2=date.substring(0, 8)+"01"; 848 String date2=date.substring(0, 8)+"01";
841 String lineStr=""; 849 String lineStr="";
842 String line =map.get("line").toString().trim(); 850 String line =map.get("line").toString().trim();
843 - if(line !=null && !line.equals("")){ 851 + /*if(line !=null && !line.equals("")){
844 lineStr =" and xlbm= '"+ line +"'"; 852 lineStr =" and xlbm= '"+ line +"'";
845 }else{ 853 }else{
846 lineStr =" and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' "; 854 lineStr =" and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' ";
@@ -868,23 +876,86 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -868,23 +876,86 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
868 s.setJzyl(rs.getDouble("jzyl")); 876 s.setJzyl(rs.getDouble("jzyl"));
869 return s; 877 return s;
870 } 878 }
871 - }); 879 + }); */
872 880
873 - if(type != null && type.equals("export")){  
874 - SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),  
875 - sdfSimple = new SimpleDateFormat("yyyyMMdd");  
876 -  
877 - List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();  
878 - for(Ylb ylb : list){  
879 - Map<String, Object> m = new HashMap<String, Object>();  
880 - m.put("nbbm", ylb.getNbbm()!=null?ylb.getNbbm():"");  
881 - m.put("rq", ylb.getRq()!=null?sdfMonth.format(ylb.getRq()):"");  
882 - m.put("jzyl", ylb.getJzyl()!=null?ylb.getJzyl():"");  
883 - mapList.add(m); 881 + double qtyy=0.0;//其他用油
  882 + double cdyy=0.0;//车队用油
  883 + double byyy=0.0;//保养用油
  884 + double cjxx=0.0;//车间小修
  885 + double cjgb=0.0;//车间高保
  886 + double fyyyhj=0.0;//非营运用油合计
  887 + List<Ylb> listYlb=repository.listByMonthJcsx(date2, date, gsdm, fgsdm, line);
  888 +
  889 + Map<String, Object> ms=new HashMap<String,Object>();
  890 + List<Ylb> list=new ArrayList<Ylb>();
  891 + for (int i = 0; i < listYlb.size(); i++) {
  892 + Ylb t=listYlb.get(i);
  893 + fyyyhj =Arith.add(fyyyhj, t.getSh());
  894 + if(t.getShyy()==null){
  895 + qtyy=Arith.add(qtyy, t.getSh());
  896 + }else{
  897 + if(t.getShyy().equals("6")){
  898 + cdyy=Arith.add(cdyy, t.getSh());
  899 + }else if(t.getShyy().equals("2")){
  900 + byyy=Arith.add(byyy, t.getSh());
  901 + }else if(t.getShyy().equals("7")){
  902 + cjxx=Arith.add(cjxx, t.getSh());
  903 + }else if(t.getShyy().equals("8")){
  904 + cjgb=Arith.add(cjgb, t.getSh());
  905 + }else{
  906 + qtyy=Arith.add(qtyy, t.getSh());
  907 + }
  908 + }
  909 + if(ms.get(t.getNbbm())==null){
  910 + ms.put(t.getNbbm(), t.getNbbm());
  911 + list.add(t);
884 } 912 }
  913 + }
  914 +
  915 + List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
  916 + int size = 0;
  917 + Map<String, Object> m_ = new HashMap<String, Object>();
  918 + double ycyhj=0.0;
  919 + for(Ylb ylb : list){
  920 + ycyhj=Arith.add(ycyhj, ylb.getJzyl());
  921 + int x=size%3;
  922 + if(x==0 && size>0){
  923 + mapList.add(m_);
  924 + m_ = new HashMap<String, Object>();
  925 + }
  926 + size++;
  927 + m_.put("xh"+x, size);
  928 + m_.put("nbbm"+x, ylb.getNbbm()!=null?ylb.getNbbm():"");
  929 + m_.put("rq"+x, ylb.getRq()!=null?sdfMonth.format(ylb.getRq()):"");
  930 + m_.put("jzyl"+x, ylb.getJzyl()!=null?ylb.getJzyl():"");
885 931
  932 + }
  933 + if(m_.get("nbbm0")!=null){
  934 + if(m_.get("nbbm1")==null){
  935 + m_.put("xh1", "");
  936 + m_.put("nbbm1" , "");
  937 + m_.put("rq1" , "");
  938 + m_.put("jzyl1" , "");
  939 + }
  940 + if(m_.get("nbbm2")==null){
  941 + m_.put("xh2", "");
  942 + m_.put("nbbm2" , "");
  943 + m_.put("rq2" , "");
  944 + m_.put("jzyl2" , "");
  945 + }
  946 + mapList.add(m_);
  947 + }
  948 +
  949 + if(type != null && type.equals("export")){
886 List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); 950 List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
887 Map<String, Object> m = new HashMap<String, Object>(); 951 Map<String, Object> m = new HashMap<String, Object>();
  952 + m.put("ycyhj", ycyhj);
  953 + m.put("qtyy", qtyy);
  954 + m.put("cdyy", cdyy);
  955 + m.put("byyy", byyy);
  956 + m.put("cjxx", cjxx);
  957 + m.put("cjgb", cjgb);
  958 + m.put("fyyyhj", fyyyhj);
888 ReportUtils ee = new ReportUtils(); 959 ReportUtils ee = new ReportUtils();
889 try { 960 try {
890 listI.add(mapList.iterator()); 961 listI.add(mapList.iterator());
@@ -895,9 +966,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -895,9 +966,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
895 // TODO: handle exception 966 // TODO: handle exception
896 e.printStackTrace(); 967 e.printStackTrace();
897 } 968 }
  969 + }else{
  970 + m_=new HashMap<String,Object>();
  971 + m_.put("xh0", "99");
  972 + m_.put("nbbm0", "存油合计:"+ycyhj +" 非营运用油: 其他用油:"+qtyy +",车队:"+cdyy+",保养用油:"+byyy
  973 + +",车间(小修):"+cjxx+",车间(高保):"+cjgb+",非营运用油合计:"+fyyyhj);
  974 + mapList.add(m_);
898 } 975 }
899 976
900 - return list; 977 + return mapList;
901 } 978 }
902 979
903 @Override 980 @Override
@@ -1429,8 +1506,14 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1429,8 +1506,14 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1429 try{ 1506 try{
1430 String date = map.get("date").toString(); 1507 String date = map.get("date").toString();
1431 String line = map.get("line").toString(); 1508 String line = map.get("line").toString();
1432 - String gsdm = map.get("gsdm").toString();  
1433 - String fgsdm = map.get("fgsdm").toString(); 1509 + List<Line> listLine=lineRepository.findLineByCode(line);
  1510 + String gsdm ="";
  1511 + String fgsdm ="";
  1512 + if(listLine.size()>0){
  1513 + Line l=listLine.get(0);
  1514 + gsdm=l.getCompany();
  1515 + fgsdm=l.getBrancheCompany();
  1516 + }
1434 1517
1435 List<Map<String, Object>> listpbYc=new ArrayList<Map<String, Object>>();//油车数据 1518 List<Map<String, Object>> listpbYc=new ArrayList<Map<String, Object>>();//油车数据
1436 List<Map<String, Object>> listpbDc=new ArrayList<Map<String, Object>>();//电车数据 1519 List<Map<String, Object>> listpbDc=new ArrayList<Map<String, Object>>();//电车数据
@@ -1462,15 +1545,22 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1462,15 +1545,22 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1462 for (int j = 0; j < ylbList.size(); j++) { 1545 for (int j = 0; j < ylbList.size(); j++) {
1463 Ylb t=ylbList.get(j); 1546 Ylb t=ylbList.get(j);
1464 boolean fage=true; 1547 boolean fage=true;
1465 - for (int i = 0; i < listpbYc.size(); i++) {  
1466 - Map<String, Object> m = listpbYc.get(i);  
1467 - if(t.getNbbm().equals(m.get("clZbh").toString())  
1468 - &&t.getJsy().equals(m.get("jGh").toString())  
1469 - &&t.getXlbm().equals(m.get("xlBm").toString())  
1470 - &&t.getLp().equals(m.get("lpName").toString())){  
1471 - //该条记录不用删除  
1472 - fage =false;  
1473 - ylbList_upd.add(t); 1548 + if(t.getLp().isEmpty()){
  1549 + fage=false;
  1550 + }else{
  1551 + for (int i = 0; i < listpbYc.size(); i++) {
  1552 + Map<String, Object> m = listpbYc.get(i);
  1553 + if(t.getNbbm().equals(m.get("clZbh").toString())
  1554 + &&t.getJsy().equals(m.get("jGh").toString())
  1555 + &&t.getXlbm().equals(m.get("xlBm").toString())
  1556 + &&t.getLp().equals(m.get("lpName").toString())){
  1557 + //该条记录不用删除
  1558 +
  1559 +
  1560 +
  1561 + fage =false;
  1562 + ylbList_upd.add(t);
  1563 + }
1474 } 1564 }
1475 } 1565 }
1476 if(fage){ 1566 if(fage){
@@ -1478,7 +1568,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1478,7 +1568,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1478 } 1568 }
1479 1569
1480 } 1570 }
1481 - 1571 + String nbbmStr="";
1482 List<Ylb> list=new ArrayList<Ylb>(); 1572 List<Ylb> list=new ArrayList<Ylb>();
1483 /* 1573 /*
1484 * 第一步 修改车辆里程 和加注量 1574 * 第一步 修改车辆里程 和加注量
@@ -1499,43 +1589,45 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1499,43 +1589,45 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1499 type = "update"; 1589 type = "update";
1500 } 1590 }
1501 } 1591 }
1502 - // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量  
1503 - if (maps.get("seqNumber").toString().equals("1")) {  
1504 - boolean fage = true;  
1505 - for (int i = 0; i < ylListBe.size(); i++) {  
1506 - Ylb ylb = ylListBe.get(i);  
1507 - if (maps.get("clZbh").toString().equals(ylb.getNbbm())) {  
1508 - if(ylb.getJzyl()>0){  
1509 - t.setCzyl(ylb.getJzyl());  
1510 - fage = false;  
1511 - break; 1592 + if(type.equals("add")){
  1593 + // 当日的第一个班次,出场油量等于前一天的最后一个班次的进场油量
  1594 + if (maps.get("seqNumber").toString().equals("1")) {
  1595 + boolean fage = true;
  1596 + for (int i = 0; i < ylListBe.size(); i++) {
  1597 + Ylb ylb = ylListBe.get(i);
  1598 + if (maps.get("clZbh").toString().equals(ylb.getNbbm())) {
  1599 + if(ylb.getJzyl()>0){
  1600 + t.setCzyl(ylb.getJzyl());
  1601 + fage = false;
  1602 + break;
  1603 + }
1512 } 1604 }
1513 } 1605 }
1514 - }  
1515 - if (fage) {  
1516 - for (int y = 0; y < clyList.size(); y++) {  
1517 - Cyl cyl = clyList.get(y);  
1518 - if (maps.get("clZbh").toString().equals(cyl.getNbbm())) {  
1519 - if(cyl!=null){  
1520 - if(cyl.getCyl()>=0){  
1521 - t.setCzyl(cyl.getCyl());  
1522 - fage = false;  
1523 - break;  
1524 - }else {  
1525 - if(cyl.getCxrl()!=null){  
1526 - if(cyl.getCxrl()>0){  
1527 - t.setCzyl(cyl.getCxrl());  
1528 - fage = false;  
1529 - break; 1606 + if (fage) {
  1607 + for (int y = 0; y < clyList.size(); y++) {
  1608 + Cyl cyl = clyList.get(y);
  1609 + if (maps.get("clZbh").toString().equals(cyl.getNbbm())) {
  1610 + if(cyl!=null){
  1611 + if(cyl.getCyl()>=0){
  1612 + t.setCzyl(cyl.getCyl());
  1613 + fage = false;
  1614 + break;
  1615 + }else {
  1616 + if(cyl.getCxrl()!=null){
  1617 + if(cyl.getCxrl()>0){
  1618 + t.setCzyl(cyl.getCxrl());
  1619 + fage = false;
  1620 + break;
  1621 + }
1530 } 1622 }
1531 } 1623 }
1532 } 1624 }
1533 } 1625 }
1534 } 1626 }
1535 } 1627 }
1536 - }  
1537 - if (fage) {  
1538 - t.setCzyl(0.0); 1628 + if (fage) {
  1629 + t.setCzyl(0.0);
  1630 + }
1539 } 1631 }
1540 } 1632 }
1541 1633
@@ -1592,21 +1684,114 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1592,21 +1684,114 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1592 t.setLp(maps.get("lpName")==null?"":maps.get("lpName").toString()); 1684 t.setLp(maps.get("lpName")==null?"":maps.get("lpName").toString());
1593 if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){ 1685 if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){
1594 if(type.equals("add")){ 1686 if(type.equals("add")){
  1687 + if(nbbmStr.indexOf(t.getNbbm())<0){
  1688 + nbbmStr +=t.getNbbm()+",";
  1689 + }
1595 t.setCreatetime(new Date()); 1690 t.setCreatetime(new Date());
1596 }else{ 1691 }else{
1597 t.setUpdatetime(new Date()); 1692 t.setUpdatetime(new Date());
1598 } 1693 }
1599 } 1694 }
1600 - repository.save(t); 1695 + try {
  1696 + repository.save(t);
  1697 + } catch (Exception e) {
  1698 + // TODO: handle exception
  1699 + if(e.getMessage().indexOf("PK_YLB_UK")>0){
  1700 + newMap.put("fage", "存在相同数据,数据已经过滤");
  1701 + logger.info("油量存在相同数据,数据已经过滤");
  1702 + }
  1703 + }
1601 1704
1602 } 1705 }
1603 1706
1604 for (int i = 0; i < ylbList_del.size(); i++) { 1707 for (int i = 0; i < ylbList_del.size(); i++) {
1605 Ylb y=ylbList_del.get(i); 1708 Ylb y=ylbList_del.get(i);
  1709 + if(nbbmStr.indexOf(y.getNbbm())<0){
  1710 + nbbmStr +=y.getNbbm()+",";
  1711 + }
1606 repository.delete(y.getId()); 1712 repository.delete(y.getId());
1607 } 1713 }
  1714 +
  1715 + //重新计算删除了的或者新增了的车的车的油耗信息(考虑车辆可能跨线路,从分公司赛选计算)
  1716 + double czyl=0.0;
  1717 + List<Ylb> iterator2=this.listOrderBy(date,gsdm,fgsdm,line,"","nbbm,jcsx");
  1718 + String[] nbbms=nbbmStr.split(",");
  1719 + for (int i = 0; i < nbbms.length; i++) {
  1720 + String clzbm=nbbms[i];
  1721 + // 得到一天总的加油和里程(根据车,时间)
  1722 + List<Object[]> sumList = repository.sumLcYl(clzbm, sdf.parse(date),"",gsdm,fgsdm);
  1723 + // 保存总的加油量
  1724 + Double jzl = 0.0;
  1725 + // 保存总的里程
  1726 + Double zlc = 0.0;
  1727 + for (int j = 0; j < sumList.size(); j++) {
  1728 + jzl = Arith.add(jzl, Double.valueOf(sumList.get(j)[0].toString()));
  1729 + zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString()));
  1730 + }
  1731 + // 保留两位小数
  1732 + DecimalFormat df = new DecimalFormat("#.00");
  1733 + Double zyl = 0.0;
  1734 + Double nextJzyl = 0.0;
  1735 + for (int j = 0; j < iterator2.size(); j++) {
  1736 + Ylb t = iterator2.get(j);
  1737 + if(t.getNbbm().equals(clzbm)){
  1738 + if (t.getJcsx() == 1) {
  1739 + // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量
  1740 + czyl = t.getCzyl();
  1741 + zyl =jzl;
  1742 + Double yh=0.0;
  1743 + if(zlc>0 ){
  1744 + yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
  1745 + }
  1746 + nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh);
  1747 + //把进场油量的小数和整数分别取出
  1748 + if(zlc>0 && t.getZlc()>0){
  1749 + long l=Math.round(nextJzyl);
  1750 + double ylxs=l*100/100;
  1751 + yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));
  1752 + t.setYh(yh);
  1753 + t.setJzyl(ylxs);
  1754 + nextJzyl=ylxs;
  1755 + }else{
  1756 + t.setYh(yh);
  1757 + t.setJzyl(nextJzyl);
  1758 + }
  1759 + } else {
  1760 + t.setCzyl(nextJzyl);
  1761 + Double yh=0.0;
  1762 + if(zlc>0){
  1763 + yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
  1764 + }
  1765 + nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);
  1766 + if(zlc>0 && t.getZlc()>0){
  1767 + long l=0l;
  1768 + double ylxs=0.0;
  1769 + if(j==iterator2.size()-1){
  1770 + ylxs=czyl;
  1771 + }else{
  1772 + if(iterator2.get(j+1).getNbbm().equals(t.getNbbm())){
  1773 + l=Math.round(nextJzyl);
  1774 + ylxs=l*100/100;
  1775 + }else{
  1776 + ylxs=czyl;
  1777 + }
  1778 +
  1779 + }
  1780 + yh=Arith.add(yh, Arith.sub(nextJzyl,ylxs));
  1781 + t.setYh(yh);
  1782 + t.setJzyl(ylxs);
  1783 + nextJzyl=ylxs;
  1784 + }else{
  1785 + t.setYh(yh);
  1786 + t.setJzyl(nextJzyl);
  1787 + }
  1788 + }
  1789 + repository.save(t);
  1790 + }
  1791 + }
  1792 + }
  1793 +
1608 //重新统计油车数据结束 1794 //重新统计油车数据结束
1609 -  
1610 1795
1611 1796
1612 //重新获取电耗数据开始 1797 //重新获取电耗数据开始
@@ -1619,7 +1804,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1619,7 +1804,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1619 List<Dlb> updDlb=mapList.get("updList"); 1804 List<Dlb> updDlb=mapList.get("updList");
1620 for (int i = 0; i < updDlb.size(); i++) { 1805 for (int i = 0; i < updDlb.size(); i++) {
1621 Dlb d=updDlb.get(i); 1806 Dlb d=updDlb.get(i);
1622 - dlbRepository.save(d); 1807 + try {
  1808 + dlbRepository.save(d);
  1809 + } catch (Exception e) {
  1810 + // TODO: handle exception
  1811 + if(e.getMessage().indexOf("PK_DLB_UK")>0){
  1812 + newMap.put("fage", "存在相同数据,数据已经过滤");
  1813 + logger.info("电量存在相同数据,数据已经过滤");
  1814 + }
  1815 + }
1623 } 1816 }
1624 //重新获取电耗数据结束 1817 //重新获取电耗数据结束
1625 newMap.put("status", ResponseCode.SUCCESS); 1818 newMap.put("status", ResponseCode.SUCCESS);
src/main/java/com/bsth/service/realcontrol/impl/ChildTaskPlanServiceImpl.java
@@ -18,6 +18,7 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -18,6 +18,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
18 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
19 19
20 import javax.transaction.Transactional; 20 import javax.transaction.Transactional;
  21 +import java.util.Date;
21 import java.util.HashMap; 22 import java.util.HashMap;
22 import java.util.Map; 23 import java.util.Map;
23 24
@@ -78,7 +79,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl&lt;ChildTaskPlan, Lon @@ -78,7 +79,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl&lt;ChildTaskPlan, Lon
78 ccServiceSch.setScheduleDateStr(sch.getScheduleDateStr()); 79 ccServiceSch.setScheduleDateStr(sch.getScheduleDateStr());
79 ccServiceSch.setRealExecDate(sch.getRealExecDate()); 80 ccServiceSch.setRealExecDate(sch.getRealExecDate());
80 81
81 - ccServiceSch.setId(null); 82 + ccServiceSch.setId(dayOfSchedule.getId());
82 ccServiceSch.setSpId(null); 83 ccServiceSch.setSpId(null);
83 ccServiceSch.setClZbh(t.getNbbm()); 84 ccServiceSch.setClZbh(t.getNbbm());
84 ccServiceSch.setCcService(true); 85 ccServiceSch.setCcService(true);
@@ -96,6 +97,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl&lt;ChildTaskPlan, Lon @@ -96,6 +97,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl&lt;ChildTaskPlan, Lon
96 ccServiceSch.setZdsjActual(ccServiceSch.getZdsj()); 97 ccServiceSch.setZdsjActual(ccServiceSch.getZdsj());
97 ccServiceSch.setRemarks(t.getRemarks()); 98 ccServiceSch.setRemarks(t.getRemarks());
98 ccServiceSch.setStatus(2); 99 ccServiceSch.setStatus(2);
  100 + ccServiceSch.setCreateDate(new Date());
99 if("1".equals(t.getType2())){ 101 if("1".equals(t.getType2())){
100 ccServiceSch.setBcType("normal"); 102 ccServiceSch.setBcType("normal");
101 } 103 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -77,7 +77,7 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -77,7 +77,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
77 import org.springframework.jdbc.core.RowMapper; 77 import org.springframework.jdbc.core.RowMapper;
78 import org.springframework.stereotype.Service; 78 import org.springframework.stereotype.Service;
79 79
80 -import java.io.*; 80 +import java.io.File;
81 import java.sql.ResultSet; 81 import java.sql.ResultSet;
82 import java.sql.SQLException; 82 import java.sql.SQLException;
83 import java.text.DecimalFormat; 83 import java.text.DecimalFormat;
@@ -85,8 +85,6 @@ import java.text.ParseException; @@ -85,8 +85,6 @@ import java.text.ParseException;
85 import java.text.SimpleDateFormat; 85 import java.text.SimpleDateFormat;
86 import java.util.*; 86 import java.util.*;
87 import java.util.regex.Pattern; 87 import java.util.regex.Pattern;
88 -import java.util.zip.ZipEntry;  
89 -import java.util.zip.ZipOutputStream;  
90 88
91 @Service 89 @Service
92 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> 90 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
@@ -503,6 +501,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -503,6 +501,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
503 return rs; 501 return rs;
504 } 502 }
505 503
  504 + t.setId(dayOfSchedule.getId());
506 //实时入库 505 //实时入库
507 rs = super.save(t); 506 rs = super.save(t);
508 } catch (Exception e) { 507 } catch (Exception e) {
@@ -603,6 +602,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -603,6 +602,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
603 return rs; 602 return rs;
604 } 603 }
605 604
  605 + t.setId(dayOfSchedule.getId());
606 //实时入库 606 //实时入库
607 super.save(t); 607 super.save(t);
608 608
@@ -3344,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3344,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3344 if("major".equals(bcType)){ 3344 if("major".equals(bcType)){
3345 sch.setMajorStationName(majorStationName); 3345 sch.setMajorStationName(majorStationName);
3346 } 3346 }
  3347 +
  3348 + dayOfSchedule.save(sch);
3347 } 3349 }
3348 } catch (Exception e) { 3350 } catch (Exception e) {
3349 logger.error("", e); 3351 logger.error("", e);
@@ -4336,7 +4338,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4336,7 +4338,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4336 return new ArrayList<Map<String, Object>>(); 4338 return new ArrayList<Map<String, Object>>();
4337 } 4339 }
4338 4340
4339 - public void exportWaybill_pl(List<ScheduleRealInfo> listpl,String date,String jName, String clZbh,String lpName) { 4341 + public void exportWaybill_pl(List<ScheduleRealInfo> listpl,
  4342 + String date, String jName, String clZbh, String lpName) {
4340 ReportUtils ee = new ReportUtils(); 4343 ReportUtils ee = new ReportUtils();
4341 ReportRelatedUtils rru = new ReportRelatedUtils(); 4344 ReportRelatedUtils rru = new ReportRelatedUtils();
4342 List<Iterator<?>> list = new ArrayList<Iterator<?>>(); 4345 List<Iterator<?>> list = new ArrayList<Iterator<?>>();
@@ -4359,7 +4362,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4359,7 +4362,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4359 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); 4362 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
4360 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); 4363 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
4361 //计算里程和班次数,并放入Map里 4364 //计算里程和班次数,并放入Map里
4362 - Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId()); 4365 + Map<String, Object> map = this.MapById(scheduleRealInfos.get(0).getId());
4363 4366
4364 map.put("jhlc",Arith.add(culateMieageService.culateJhgl(scheduleRealInfos),culateMieageService.culateJhJccgl(scheduleRealInfos))); 4367 map.put("jhlc",Arith.add(culateMieageService.culateJhgl(scheduleRealInfos),culateMieageService.culateJhJccgl(scheduleRealInfos)));
4365 map.put("remMileage",culateMieageService.culateLbgl(scheduleRealInfos)); 4368 map.put("remMileage",culateMieageService.culateLbgl(scheduleRealInfos));
@@ -4506,7 +4509,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4506,7 +4509,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4506 4509
4507 4510
4508 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; 4511 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
4509 -  
4510 list.add(listMap.iterator()); 4512 list.add(listMap.iterator());
4511 String xls=""; 4513 String xls="";
4512 if(map.get("type").toString().equals("0")){ 4514 if(map.get("type").toString().equals("0")){
@@ -4514,15 +4516,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4514,15 +4516,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4514 }else{ 4516 }else{
4515 xls="waybill_minhang_dl.xls"; 4517 xls="waybill_minhang_dl.xls";
4516 } 4518 }
  4519 + map.put("sheetName", jName + "-" + clZbh + "-" + lpName);
4517 ee.excelReplace(list, new Object[]{map}, path + "mould/"+xls, 4520 ee.excelReplace(list, new Object[]{map}, path + "mould/"+xls,
4518 path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); 4521 path + "export/" + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");
4519 -// return scheduleRealInfos;  
4520 } 4522 }
4521 4523
4522 @Override 4524 @Override
4523 public Map<String, Object> exportWaybillMore(Map<String, Object> map) { 4525 public Map<String, Object> exportWaybillMore(Map<String, Object> map) {
4524 String date = map.get("date").toString(); 4526 String date = map.get("date").toString();
4525 String line = map.get("line").toString(); 4527 String line = map.get("line").toString();
  4528 + ReportUtils ee = new ReportUtils();
4526 List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class); 4529 List<List> lists = JSON.parseArray(map.get("strs").toString(), List.class);
4527 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/"; 4530 String path = this.getClass().getResource("/").getPath() + "static/pages/forms/export/";
4528 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), 4531 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
@@ -4532,16 +4535,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4532,16 +4535,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4532 try { 4535 try {
4533 while (true) { 4536 while (true) {
4534 String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date)); 4537 String fileUrl = path + "行车路单" + sdfSimple.format(sdfMonth.parse(date));
4535 - file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/"));  
4536 - if (file.exists()) { 4538 +// file = new File(fileUrl + (num == 0 ? "/" : "(" + num + ")/")); //新建文件夹
  4539 + file = new File(fileUrl + (num == 0 ? ".xls" : "(" + num + ").xls")); //新建excel文件
  4540 + if (file.exists()) { //判断是否已存在重名
4537 num++; 4541 num++;
4538 } else { 4542 } else {
4539 break; 4543 break;
4540 } 4544 }
4541 } 4545 }
4542 - file.mkdirs(); 4546 +// file.mkdirs(); //创建
4543 List<ScheduleRealInfo> lists_line=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date); 4547 List<ScheduleRealInfo> lists_line=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
4544 - for (List<String> list : lists) { 4548 +
  4549 + List<File> files = new ArrayList<File>();
  4550 + for (List<String> list : lists){
4545 List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); 4551 List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
4546 String jName = list.get(0); 4552 String jName = list.get(0);
4547 String clZbh = list.get(1); 4553 String clZbh = list.get(1);
@@ -4556,26 +4562,37 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -4556,26 +4562,37 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4556 this.exportWaybill_pl(newList, date, jName, clZbh, lpName); 4562 this.exportWaybill_pl(newList, date, jName, clZbh, lpName);
4557 File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls"); 4563 File temp = new File(path + date + "-" + jName + "-" + clZbh + "-" + lpName + "-行车路单.xls");
4558 String fileName = file.getName(); 4564 String fileName = file.getName();
4559 - temp.renameTo(new File(path + fileName + "/" + temp.getName()));  
4560 -  
4561 - File[] listFiles = file.listFiles();  
4562 - ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip")));  
4563 -// zos.setEncoding("gbk");  
4564 -// zos.putNextEntry(new ZipEntry(fileName + "/"));  
4565 - for (int i = 0; i < listFiles.length; i++) {  
4566 - zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName()));  
4567 - BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i]));  
4568 - BufferedOutputStream bos = new BufferedOutputStream(zos);  
4569 - int bytesRead = 0;  
4570 - for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) {  
4571 -// zos.write(buffer, 0, bytesRead);  
4572 -// zos.flush();  
4573 - bos.write(buffer, 0, bytesRead);  
4574 - bos.flush();  
4575 - }  
4576 - }  
4577 - zos.close();  
4578 - } 4565 + files.add(temp);
  4566 + }
  4567 + for(int i = 1; i < files.size(); i++){
  4568 + File file1 = files.get(0);
  4569 + File file2 = files.get(i);
  4570 + ee.copySheetByFile(file2, file1, 0, 145);
  4571 + }
  4572 + File newFile = files.get(0);
  4573 + newFile.renameTo(file);
  4574 +
  4575 +// temp.renameTo(new File(path + fileName + "/" + temp.getName()));
  4576 +// File[] listFiles = file.listFiles();
  4577 +// ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(path + file.getName() + ".zip")));
  4578 +//// zos.setEncoding("gbk");
  4579 +//// zos.putNextEntry(new ZipEntry(fileName + "/"));
  4580 +// for (int i = 0; i < listFiles.length; i++) {
  4581 +// zos.putNextEntry(new ZipEntry(fileName + "/" + listFiles[i].getName()));
  4582 +// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(listFiles[i]));
  4583 +// BufferedOutputStream bos = new BufferedOutputStream(zos);
  4584 +// int bytesRead = 0;
  4585 +// for (byte[] buffer = new byte[BUF_SIZE]; ((bytesRead = bis.read(buffer, 0, BUF_SIZE)) != -1); ) {
  4586 +//// zos.write(buffer, 0, bytesRead);
  4587 +//// zos.flush();
  4588 +// bos.write(buffer, 0, bytesRead);
  4589 +// bos.flush();
  4590 +// }
  4591 +//// bos.close();
  4592 +// bis.close();
  4593 +// }
  4594 +// zos.close();
  4595 +// }
4579 4596
4580 } catch (Exception e) { 4597 } catch (Exception e) {
4581 // TODO: handle exception 4598 // TODO: handle exception
src/main/java/com/bsth/service/report/ReportService.java
@@ -46,8 +46,12 @@ public interface ReportService { @@ -46,8 +46,12 @@ public interface ReportService {
46 List<Map<String, String>> userList(Map<String, Object> map); 46 List<Map<String, String>> userList(Map<String, Object> map);
47 47
48 List<Map<String, Object>> countByList(Map<String, Object> map); 48 List<Map<String, Object>> countByList(Map<String, Object> map);
  49 + List<Map<String, Object>> countByList2(Map<String, Object> map);
  50 +
49 51
50 List<Map<String, Object>> countByBusList(Map<String, Object> map); 52 List<Map<String, Object>> countByBusList(Map<String, Object> map);
51 53
52 List<Map<String, Object>> countDjg(Map<String, Object> map); 54 List<Map<String, Object>> countDjg(Map<String, Object> map);
  55 +
  56 + Map<String, Object> online(Map<String, Object> map);
53 } 57 }
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java
@@ -1198,7 +1198,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ @@ -1198,7 +1198,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1198 Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); 1198 Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
1199 while (it.hasNext()) { 1199 while (it.hasNext()) {
1200 ChildTaskPlan childTaskPlan = it.next(); 1200 ChildTaskPlan childTaskPlan = it.next();
1201 - if(item.equals("空放")){ 1201 +// if(item.equals("空放")){
1202 /*if(childTaskPlan.getType2().equals("1")){ 1202 /*if(childTaskPlan.getType2().equals("1")){
1203 if (!childTaskPlan.isDestroy()) { 1203 if (!childTaskPlan.isDestroy()) {
1204 if(childTaskPlan.getReason().equals(item)){ 1204 if(childTaskPlan.getReason().equals(item)){
@@ -1206,7 +1206,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ @@ -1206,7 +1206,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1206 } 1206 }
1207 } 1207 }
1208 }*/ 1208 }*/
1209 - }else{ 1209 +// }else{
1210 if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){ 1210 if(childTaskPlan.getType2().equals("2")||childTaskPlan.getType2().equals("3")){
1211 if (!childTaskPlan.isDestroy()) { 1211 if (!childTaskPlan.isDestroy()) {
1212 if(childTaskPlan.getReason().equals(item)){ 1212 if(childTaskPlan.getReason().equals(item)){
@@ -1214,7 +1214,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{ @@ -1214,7 +1214,7 @@ public class CulateMileageServiceImpl implements CulateMileageService{
1214 } 1214 }
1215 } 1215 }
1216 } 1216 }
1217 - } 1217 +// }
1218 } 1218 }
1219 } 1219 }
1220 } 1220 }
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
@@ -2546,6 +2546,111 @@ public class ReportServiceImpl implements ReportService{ @@ -2546,6 +2546,111 @@ public class ReportServiceImpl implements ReportService{
2546 } 2546 }
2547 2547
2548 2548
  2549 + @Override
  2550 + public List<Map<String, Object>> countByList2(Map<String, Object> map) {
  2551 + // TODO Auto-generated method stub
  2552 +
  2553 + List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
  2554 + String gsdm="";
  2555 + if(map.get("gsdm")!=null){
  2556 + gsdm=map.get("gsdm").toString();
  2557 + }
  2558 + String fgsdm="";
  2559 + if(map.get("fgsdm")!=null){
  2560 + fgsdm=map.get("fgsdm").toString();
  2561 + }
  2562 + String line="";
  2563 + if(map.get("line")!=null){
  2564 + line=map.get("line").toString();
  2565 + }
  2566 + String date="";
  2567 + if(map.get("date")!=null){
  2568 + date=map.get("date").toString();
  2569 + }
  2570 + String date2="";
  2571 + if(map.get("date2")!=null){
  2572 + date2=map.get("date2").toString();
  2573 + }
  2574 + String xlName="";
  2575 + if(map.get("xlName")!=null){
  2576 + xlName=map.get("xlName").toString();
  2577 + }
  2578 + String type="";
  2579 + if(map.get("type")!=null){
  2580 + type=map.get("type").toString();
  2581 + }
  2582 + //所有班次信息
  2583 + List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
  2584 + line =line.trim();
  2585 + List<Line> lineList=lineRepository.findLineBygsBm(gsdm, fgsdm, "");
  2586 +// if(line.equals("")){
  2587 +// //查询所有线路
  2588 +// list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2,gsdm,fgsdm);
  2589 +// }else{
  2590 + //查询单条线路
  2591 +// list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);
  2592 +// }
  2593 +
  2594 +
  2595 + String sql="select r.xl_bm"
  2596 + + " from bsth_c_s_sp_info_real r where"
  2597 + + " r.schedule_date_str >= '"+date+"' and r.schedule_date_str >= '"+date2+"'";
  2598 +
  2599 +
  2600 + if(line.equals("")){
  2601 + sql +="and r.gs_bm='"+gsdm+"' "
  2602 + + " and r.fgs_bm='"+fgsdm+"'";
  2603 + }else{
  2604 + sql += " and r.xl_bm = '"+line+"'";
  2605 + }
  2606 + sql += " group by r.xl_bm";
  2607 +
  2608 + List<String> listLine=jdbcTemplate.query(sql, new RowMapper<String>() {
  2609 + @Override
  2610 + public String mapRow(ResultSet arg0, int arg1) throws SQLException {
  2611 + String ve = arg0.getString("xl_bm");
  2612 + return ve;
  2613 + }
  2614 + });
  2615 + for (int i = 0; i < listLine.size(); i++) {
  2616 + List<ScheduleRealInfo> lists =scheduleRealInfoRepository.scheduleByDateAndLineTj2(listLine.get(i), date,date2);
  2617 + list.addAll(lists);
  2618 + //计算线路的各项公里
  2619 + if(lists.size()>0){
  2620 + Map<String, Object> newMap=staticTj(lists,"z");
  2621 + lMap.add(newMap);
  2622 + }
  2623 + }
  2624 + if(list.size()>0){
  2625 + Map<String, Object> newMap=staticTj(list,"f");
  2626 + lMap.add(newMap);
  2627 + }
  2628 + if(type.equals("export")){
  2629 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  2630 + Map<String, Object> m = new HashMap<String, Object>();
  2631 + m.put("date", date);
  2632 + m.put("date1", date2);
  2633 + String by=map.get("by").toString();
  2634 + String xls="";
  2635 + if(by.equals("sj")){
  2636 + xls="countByLine.xls";
  2637 + }else{
  2638 + xls="countByLines.xls";
  2639 + }
  2640 + ReportUtils ee = new ReportUtils();
  2641 + try {
  2642 + listI.add(lMap.iterator());
  2643 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  2644 + ee.excelReplace(listI, new Object[]{m}, path + "mould/"+xls,
  2645 + path + "export/线路公里统计表.xls");
  2646 + } catch (Exception e) {
  2647 + // TODO: handle exception
  2648 + e.printStackTrace();
  2649 + }
  2650 + }
  2651 + return lMap;
  2652 + }
  2653 +
2549 public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,String status){ 2654 public final Map<String, Object> staticTj(List<ScheduleRealInfo> list,String status){
2550 2655
2551 List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>(); 2656 List<ScheduleRealInfo> lists=new ArrayList<ScheduleRealInfo>();
@@ -3343,6 +3448,121 @@ public class ReportServiceImpl implements ReportService{ @@ -3343,6 +3448,121 @@ public class ReportServiceImpl implements ReportService{
3343 map.put("djgxx", mapList); 3448 map.put("djgxx", mapList);
3344 return map; 3449 return map;
3345 } 3450 }
  3451 +
  3452 +
  3453 + @Override
  3454 + public Map<String, Object> online(Map<String, Object> map) {
  3455 + String line =map.get("line").toString();
  3456 + String date =map.get("date").toString();
  3457 + String type =map.get("type").toString();
  3458 + DecimalFormat df = new DecimalFormat("#0.00");
  3459 + String sql="select cl_zbh from bsth_c_s_sp_info_real where "
  3460 + + " schedule_date_str ='"+date+"' and xl_bm='"+line+"' group by cl_zbh";
  3461 + List<String> list= jdbcTemplate.query(sql,
  3462 + new RowMapper<String>(){
  3463 + @Override
  3464 + public String mapRow(ResultSet rs, int rowNum) throws SQLException {
  3465 + String clzbh=rs.getString("cl_zbh");
  3466 + return clzbh;
  3467 + }
  3468 + });
  3469 + List<Line> lineList=lineRepository.findLineByCode(line);
  3470 + int qzpcs =0;
  3471 + for (int i = 0; i < lineList.size(); i++) {
  3472 + Line l=lineList.get(i);
  3473 + qzpcs = l.getWarrantCar()==null?0:l.getWarrantCar();
  3474 + }
  3475 +
  3476 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  3477 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  3478 + int zxcl=0;
  3479 + try {
  3480 + Long date1 = simpleDateFormat.parse(date+" 00:00:01").getTime();
  3481 + Long date2=simpleDateFormat.parse(date+" 23:59:59").getTime();
  3482 + Date dates=simpleDateFormat.parse(date+" 00:00:00");
  3483 + List<ArrivalInfo> lists=load_online(line,date1,date2,dates);
  3484 + for (int i = 0; i < list.size(); i++) {
  3485 + String nbbm=list.get(i);
  3486 + String sbbb=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  3487 + for (int j = 0; j < lists.size(); j++) {
  3488 + ArrivalInfo a=lists.get(i);
  3489 + if(a.getDeviceId().equals(sbbb)){
  3490 + zxcl ++;
  3491 + break;
  3492 + }
  3493 + }
  3494 +
  3495 + }
  3496 + } catch (ParseException e) {
  3497 + // TODO Auto-generated catch block
  3498 + e.printStackTrace();
  3499 + }
  3500 + map.put("xlName", BasicData.lineCode2NameMap.get(line));
  3501 + map.put("qzpcs", qzpcs);
  3502 + map.put("ccs", list.size());
  3503 + map.put("zxcl", zxcl);
  3504 + String zxl="0";
  3505 + if(list.size()>0){
  3506 + zxl = df.format(zxcl/list.size());
  3507 + }
  3508 + map.put("zxl", zxl+"%");
  3509 +
  3510 + if(type.equals("export")){
  3511 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  3512 +
  3513 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3514 + Map<String, Object> m = new HashMap<String, Object>();
  3515 + m.put("date", date);
  3516 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3517 + m.put("qzpcs", qzpcs);
  3518 + m.put("ccs", list.size());
  3519 + m.put("zxcl", zxcl);
  3520 + m.put("zxl", zxl+"%");
  3521 + lMap.add(m);
  3522 + ReportUtils ee = new ReportUtils();
  3523 + try {
  3524 + listI.add(lMap.iterator());
  3525 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3526 + ee.excelReplace(listI, new Object[]{m}, path + "mould/onlinelist.xls",
  3527 + path + "export/车辆在线率统计.xls");
  3528 + } catch (Exception e) {
  3529 + // TODO: handle exception
  3530 + e.printStackTrace();
  3531 + }
  3532 + }
  3533 + return map;
  3534 + }
  3535 +
  3536 + public List<ArrivalInfo> load_online(String line,Long date1,Long date2,Date dates){
  3537 + List<ArrivalInfo> list = null;
  3538 + Calendar cal = Calendar.getInstance();
  3539 + cal.setTime(dates);
  3540 + //周数,表分区字段
  3541 + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);
  3542 +
  3543 + Connection conn = null;
  3544 + PreparedStatement ps = null;
  3545 + ResultSet rs = null;
  3546 +
  3547 + String sql = "select * from bsth_c_arrival_info where line_id=? AND weeks_year=? AND ts > ? AND ts <=? order by ts";
  3548 + try{
  3549 + conn = DBUtils_MS.getConnection();
  3550 + ps = conn.prepareStatement(sql);
  3551 + ps.setString(1,line);
  3552 + ps.setInt(2, weeks_year);
  3553 + ps.setLong(3, date1);
  3554 + ps.setLong(4, date2);
  3555 + rs = ps.executeQuery();
  3556 +
  3557 + list = resultSet2Set(rs);
  3558 + }catch(Exception e){
  3559 + logger.error("", e);
  3560 + }finally {
  3561 + DBUtils_MS.close(rs, ps, conn);
  3562 + }
  3563 + return list;
  3564 + }
  3565 +
3346 3566
3347 } 3567 }
3348 3568
src/main/java/com/bsth/util/ReportUtils.java
@@ -18,6 +18,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet; @@ -18,6 +18,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
18 import org.apache.poi.hssf.usermodel.HSSFWorkbook; 18 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
19 import org.apache.poi.poifs.filesystem.POIFSFileSystem; 19 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
20 import org.apache.poi.ss.usermodel.Cell; 20 import org.apache.poi.ss.usermodel.Cell;
  21 +import org.apache.poi.ss.util.CellRangeAddress;
21 22
22 import com.bsth.entity.Line; 23 import com.bsth.entity.Line;
23 import com.bsth.entity.realcontrol.ScheduleRealInfo; 24 import com.bsth.entity.realcontrol.ScheduleRealInfo;
@@ -114,6 +115,145 @@ public class ReportUtils { @@ -114,6 +115,145 @@ public class ReportUtils {
114 } 115 }
115 } 116 }
116 117
  118 + /**
  119 + * 将file1中的一页sheet复制到file2中
  120 + *
  121 + * @param file1
  122 + * 原sheet所在的excel文件
  123 + * @param file2
  124 + * 目标excel文件
  125 + * @param page
  126 + * 原excel中要被复制的sheet的位置(从0开始)
  127 + * @param rate
  128 + * 调整复制后的缩放倍率(列如:145,则为缩放145%)
  129 + */
  130 + public void copySheetByFile(File file1, File file2, int page, int rate) {
  131 + try {
  132 + // 把源文件放入流中
  133 + POIFSFileSystem fs1 = new POIFSFileSystem(new FileInputStream(file1));
  134 + HSSFWorkbook wb1 = new HSSFWorkbook(fs1);
  135 + HSSFSheet sheet = wb1.getSheetAt(page);
  136 + POIFSFileSystem fs2 = new POIFSFileSystem(new FileInputStream(file2));
  137 + HSSFWorkbook wb2 = new HSSFWorkbook(fs2);
  138 + HSSFSheet createSheet = wb2.createSheet(sheet.getSheetName());
  139 + HSSFCellStyle createCellStyle = wb2.createCellStyle();
  140 + HSSFRow row;
  141 +
  142 + createSheet.setZoom(rate, 100);
  143 + for(int i = 0; i < sheet.getRow(0).getPhysicalNumberOfCells(); i++){
  144 + createSheet.setColumnWidth(i, sheet.getColumnWidth(i));
  145 + }
  146 +
  147 + List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();
  148 + for(int l = 0; l < mergedRegions.size(); l++){
  149 + //复制源表中的合并单元格
  150 + createSheet.addMergedRegion(mergedRegions.get(l));
  151 + }
  152 + int firstRow = sheet.getFirstRowNum();
  153 + int lastRow = sheet.getLastRowNum();
  154 + for(int k = firstRow; k <= lastRow; k++){
  155 + // 创建新建excel Sheet的行
  156 + HSSFRow rowCreat = createSheet.createRow(k);
  157 + // 取得源有excel Sheet的行
  158 + row = sheet.getRow(k);
  159 +// rowCreat.setHeight(row.getHeight()); //设置行高
  160 + // 单元格式样
  161 + int firstCell = row.getFirstCellNum();
  162 + int lastCell = row.getLastCellNum();
  163 + for (int j = firstCell; j < lastCell; j++) {
  164 + // 自动适应列宽 貌似不起作用
  165 +// createSheet.autoSizeColumn(j);
  166 +// System.out.println(row.getCell(j));
  167 + rowCreat.createCell(j);
  168 + String strVal = "";
  169 + if (row.getCell(j)==null) {
  170 +
  171 + } else {
  172 + strVal = row.getCell(j).getStringCellValue();
  173 + rowCreat.getCell(j).setCellValue(strVal);
  174 + copyCellStyle(wb1, row.getCell(j).getCellStyle(), createCellStyle);
  175 + createCellStyle.setBorderTop((short)1);
  176 + createCellStyle.setBorderLeft((short)1);
  177 + createCellStyle.setBorderRight((short)1);
  178 + createCellStyle.setBorderBottom((short)1);
  179 + rowCreat.getCell(j).setCellStyle(createCellStyle);
  180 + }
  181 + }
  182 + }
  183 +
  184 +// int firstRowNum = createSheet.getFirstRowNum();
  185 +// int lastRowNum = createSheet.getLastRowNum();
  186 +// int test = 0;
  187 +// for(int k = firstRowNum; k <= lastRowNum; k++){
  188 +// HSSFRow createRow = createSheet.getRow(k);
  189 +// int firstCellNum = createRow.getFirstCellNum();
  190 +// int lastCellNum = createRow.getLastCellNum();
  191 +// for(int i = firstCellNum; i < lastCellNum; i++){
  192 +// HSSFCell cell = createRow.getCell(i);
  193 +// cell.getCellStyle().setBorderTop(HSSFCellStyle.BORDER_THIN);
  194 +// cell.getCellStyle().setBorderLeft(HSSFCellStyle.BORDER_THIN);
  195 +// cell.getCellStyle().setBorderRight(HSSFCellStyle.BORDER_THIN);
  196 +// cell.getCellStyle().setBorderBottom(HSSFCellStyle.BORDER_THIN);
  197 +// test ++;
  198 +// }
  199 +// }
  200 +// System.out.println("test = " + test);
  201 +
  202 + FileOutputStream fileOut = new FileOutputStream(file2);
  203 + wb2.write(fileOut);
  204 + fileOut.close();
  205 + wb2.close();
  206 + wb1.close();
  207 + fs2.close();
  208 + fs1.close();
  209 + file1.delete();
  210 +// // 创建目标文件夹
  211 +// createFolder(targetPath);
  212 + // 输出文件
  213 + } catch (Exception e) {
  214 + e.printStackTrace();
  215 + }
  216 + }
  217 +
  218 + public void test(File file){
  219 + POIFSFileSystem fs;
  220 + try {
  221 + fs = new POIFSFileSystem(new FileInputStream(file));
  222 + HSSFWorkbook wb = new HSSFWorkbook(fs);
  223 + for(int j = 0; j < wb.getNumberOfSheets(); j++){
  224 + HSSFSheet sheet = wb.getSheetAt(j);
  225 + int firstRowNum = sheet.getFirstRowNum();
  226 + int lastRowNum = sheet.getLastRowNum();
  227 + int test = 0;
  228 + for(int k = firstRowNum; k <= lastRowNum; k++){
  229 + HSSFRow createRow = sheet.getRow(k);
  230 + int firstCellNum = createRow.getFirstCellNum();
  231 + int lastCellNum = createRow.getLastCellNum();
  232 + for(int i = firstCellNum; i < lastCellNum; i++){
  233 + HSSFCell cell = createRow.getCell(i);
  234 + HSSFCellStyle cellStyle = wb.createCellStyle();
  235 +
  236 + cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
  237 + cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  238 + cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
  239 + cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  240 + cell.setCellStyle(cellStyle);
  241 + test ++;
  242 + }
  243 + }
  244 + System.out.println("test = " + test);
  245 +
  246 + FileOutputStream fileOut = new FileOutputStream(file);
  247 + wb.write(fileOut);
  248 + fileOut.close();
  249 + }
  250 + } catch (Exception e) {
  251 + // TODO Auto-generated catch block
  252 + e.printStackTrace();
  253 + }
  254 +
  255 + }
  256 +
117 public String getCellValue(HSSFCell cell) { 257 public String getCellValue(HSSFCell cell) {
118 int cellType = 0; 258 int cellType = 0;
119 String result = ""; 259 String result = "";
src/main/resources/fatso/start.js
@@ -16,7 +16,7 @@ var platform = process.platform; @@ -16,7 +16,7 @@ var platform = process.platform;
16 var iswin = platform=='win32'; 16 var iswin = platform=='win32';
17 var sp = platform=='win32'?'\\':'/'; 17 var sp = platform=='win32'?'\\':'/';
18 //不参与的目录 18 //不参与的目录
19 -var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+sp+'authorize_all', 'summary', 'history_sch' ,'report'+sp+'oil'] 19 +var excludes = ['scheduleApp', 'trafficManage', 'control', 'permission'+sp+'authorize_all', 'summary', 'history_sch' ,'report'+sp+'oil','base'+sp+'geo_data_edit']
20 ,ep = new EventProxy() 20 ,ep = new EventProxy()
21 ,pName = 'bsth_control' 21 ,pName = 'bsth_control'
22 ,path = process.cwd() 22 ,path = process.cwd()
src/main/resources/logback.xml
@@ -250,6 +250,29 @@ @@ -250,6 +250,29 @@
250 <!--<appender-ref ref="STDOUT" />--> 250 <!--<appender-ref ref="STDOUT" />-->
251 <!--</logger>--> 251 <!--</logger>-->
252 252
  253 + <!-- 实际排班数据库更新日志 -->
  254 + <!-- 消息队列纪录 -->
  255 + <appender name="REAL_SCHEDULE_UPDATE"
  256 + class="ch.qos.logback.core.rolling.RollingFileAppender">
  257 + <file>${LOG_BASE}/real_sch_db/update.log</file>
  258 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  259 + <fileNamePattern>${LOG_BASE}/real_sch_db/update-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  260 + <timeBasedFileNamingAndTriggeringPolicy
  261 + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  262 + <maxFileSize>100MB</maxFileSize>
  263 + </timeBasedFileNamingAndTriggeringPolicy>
  264 + </rollingPolicy>
  265 +
  266 + <layout class="ch.qos.logback.classic.PatternLayout">
  267 + <pattern>%d{MM-dd HH:mm:ss.SSS} %-5level -%msg%n
  268 + </pattern>
  269 + </layout>
  270 + </appender>
  271 + <logger name="com.bsth.data.schedule.thread.SchedulePstThread"
  272 + level="INFO" additivity="false">
  273 + <appender-ref ref="REAL_SCHEDULE_UPDATE" />
  274 + </logger>
  275 +
253 <!--JdbcTemplate的日志输出器 --> 276 <!--JdbcTemplate的日志输出器 -->
254 <logger name="org.springframework.jdbc.core.StatementCreatorUtils" 277 <logger name="org.springframework.jdbc.core.StatementCreatorUtils"
255 additivity="false" level="INFO"> 278 additivity="false" level="INFO">
src/main/resources/static/pages/base/geo_data_edit/main.html 0 → 100644
  1 +<!DOCTYPE html>
  2 +<html lang="zh-cn">
  3 +
  4 +<head>
  5 + <meta charset="UTF-8">
  6 + <link rel="stylesheet" href="/assets/plugins/uk3.0/uikit.min.css"/>
  7 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" />
  8 + <!-- flatpickr -->
  9 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.css">
  10 + <!-- tooltip css-->
  11 + <link rel="stylesheet" href="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.css" />
  12 + <link rel="stylesheet" href="/real_control_v2/css/pace.css" />
  13 + <style>
  14 + /* ^_^ baidu map hide logo */
  15 + .anchorBL, .anchorBL, .amap-logo, .amap-copyright {
  16 + display: none;
  17 + }
  18 +
  19 + html,body{
  20 + height: 100%;
  21 + }
  22 + .ct_page{
  23 + padding: 0;
  24 + height: 100%;
  25 + }
  26 +
  27 + div#map_wrap{
  28 + height: 100%;
  29 + }
  30 +
  31 + .main_left_panel{
  32 + position: absolute;
  33 + z-index: 999;
  34 + height: calc(100% - 20px);
  35 + width: 300px;
  36 + background: #fffffff5;
  37 + top: 7px;
  38 + left: 5px;
  39 + box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48);
  40 + }
  41 + .main_lt_search_panel{
  42 + position: absolute;
  43 + z-index: 99;
  44 + top: 10px;
  45 + left: 330px;
  46 + background: #fffffff5;
  47 + box-shadow: 5px 5px 15px rgba(90, 90, 90, 0.48);
  48 + }
  49 + .main_rt_tools_panel{
  50 + position: absolute;
  51 + z-index: 99;
  52 + top: 7px;
  53 + right: 7px;
  54 + background: #ffffff;
  55 + box-shadow: -5px 4px 15px rgba(90, 90, 90, 0.48);
  56 + padding: 0 12px;
  57 + text-align: center;
  58 + border-radius: 7px;
  59 + height: 28px;
  60 + }
  61 +
  62 + .main_rt_tools_panel>._icon{
  63 + margin: 0 9px;
  64 + }
  65 + .search_input{
  66 + width: 250px;
  67 + height: 42px;
  68 + }
  69 +
  70 + .search_input::placeholder{
  71 + color: grey;
  72 + font-size: 12px;
  73 + }
  74 + </style>
  75 +</head>
  76 +
  77 +<body>
  78 +<div class="ct_page" >
  79 + <div id="map_wrap">
  80 + </div>
  81 + <div class="main_left_panel">
  82 + <div class="_line_info">
  83 +
  84 + </div>
  85 + </div>
  86 + <div class="main_lt_search_panel">
  87 + <div class="uk-inline">
  88 + <span class="uk-form-icon uk-form-icon-flip" uk-icon="icon: search"></span>
  89 + <input class="uk-input search_input" placeholder="搜索地图位置" type="text">
  90 + </div>
  91 + </div>
  92 + <div class="main_rt_tools_panel">
  93 + <a uk-icon="icon: info;ratio: .9" class="_icon"></a>
  94 + <a uk-icon="icon: expand;ratio: .9" class="_icon"></a>
  95 + </div>
  96 +</div>
  97 +<!-- 百度 -->
  98 +<script src="http://api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>
  99 +<script src="/metronic_v4.5.4/plugins/jquery.min.js"></script>
  100 +<script src="/assets/plugins/uk3.0/uikit.min.js"></script>
  101 +<script src="/assets/plugins/uk3.0/uikit-icons.min.js"></script>
  102 +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" ></script>
  103 +<!-- EventProxy -->
  104 +<script src="/assets/js/eventproxy.js"></script>
  105 +<!-- art-template 模版引擎 -->
  106 +<script src="/assets/plugins/template.js"></script>
  107 +<script src="/real_control_v2/assets/plugins/moment/moment.min.js"></script>
  108 +<!-- jquery.serializejson JSON序列化插件 -->
  109 +<script src="/assets/plugins/jquery.serializejson.js" merge="plugins"></script>
  110 +<!-- flatpickr -->
  111 +<script src="/real_control_v2/assets/plugins/flatpickr/flatpickr.min.js" ></script>
  112 +<script src="/real_control_v2/assets/plugins/flatpickr/l10n/zh.js" ></script>
  113 +<!-- qtip -->
  114 +<script src="/real_control_v2/assets/plugins/qtip/jquery.qtip.min.js" ></script>
  115 +<script>
  116 + top.document.title = "绘制线路";
  117 + // 关闭左侧栏
  118 + if (!top.$('body').hasClass('page-sidebar-closed')) {top.$('.menu-toggler.sidebar-toggler').click();}
  119 +
  120 + //初始化地图
  121 + if(!window.BMap){
  122 + alert('地图没有加载成功,请确认是否能正常连接外网!!');
  123 + }
  124 + var gb_map_consts = {
  125 + mapContainer: '#map_wrap',
  126 + center_point: {
  127 + lng: 121.544336,
  128 + lat: 31.221315
  129 + }
  130 + };
  131 +
  132 + map = new BMap.Map($(gb_map_consts.mapContainer)[0]);
  133 + //map.setMapStyle({style:'dark'});
  134 + //中心点和缩放级别
  135 + map.centerAndZoom(new BMap.Point(gb_map_consts.center_point.lng, gb_map_consts.center_point.lat), 13);
  136 + map.enableScrollWheelZoom();
  137 +</script>
  138 +</body>
  139 +</html>
0 \ No newline at end of file 140 \ No newline at end of file
src/main/resources/static/pages/base/geo_data_edit/uk3_wrap.html 0 → 100644
  1 +<iframe src="/pages/base/geo_data_edit/main.html?origin=real_control_iframe" frameborder="0" style="height: 100%;width: 100%;"></iframe>
0 \ No newline at end of file 2 \ No newline at end of file
src/main/resources/static/pages/base/line/css/bmap_base.css
@@ -190,12 +190,10 @@ ul li a:hover:not(.active) { @@ -190,12 +190,10 @@ ul li a:hover:not(.active) {
190 .radio_label { 190 .radio_label {
191 display:block; 191 display:block;
192 color: white; 192 color: white;
193 - float: left;  
194 cursor: pointer; 193 cursor: pointer;
195 margin-left: 50px; 194 margin-left: 50px;
196 font-size: 20px; 195 font-size: 20px;
197 margin-top: 5px; 196 margin-top: 5px;
198 - text-align: center;  
199 } 197 }
200 .radioclass { 198 .radioclass {
201 margin-top: 6px !important; 199 margin-top: 6px !important;
@@ -207,7 +205,4 @@ ul li a:hover:not(.active) { @@ -207,7 +205,4 @@ ul li a:hover:not(.active) {
207 } 205 }
208 .on { 206 .on {
209 background-position: 0 0; 207 background-position: 0 0;
210 -}  
211 -  
212 -  
213 - 208 +}
214 \ No newline at end of file 209 \ No newline at end of file
src/main/resources/static/pages/base/line/map.html
@@ -196,12 +196,12 @@ $(function(){ @@ -196,12 +196,12 @@ $(function(){
196 params.lineId=line.id; 196 params.lineId=line.id;
197 params.dir = line.dir; 197 params.dir = line.dir;
198 $.get('/stationroute/findCachePoint',params,function(data){ 198 $.get('/stationroute/findCachePoint',params,function(data){
199 - var station_radio_html = '<div id="station_radio">'; 199 + var station_radio_html = '<div id="station_radio" >';
200 var cont = 1; 200 var cont = 1;
201 var check = 'checked="checked"'; 201 var check = 'checked="checked"';
202 $.each(data,function(){ 202 $.each(data,function(){
203 stationRouteMap[this.stationRouteId] = this; 203 stationRouteMap[this.stationRouteId] = this;
204 - station_radio_html += '<div class="radio"><label class="radio_label on"><input name="stationRadio" type="radio" class="radioclass" value="'+this.stationRouteId+'" '+(cont==1?check:"")+' />'+this.stationRouteStationName+"</label></div>"; 204 + station_radio_html += '<div class="radio" ><label class="radio_label on"><input name="stationRadio" type="radio" class="radioclass" value="'+this.stationRouteId+'" '+(cont==1?check:"")+' />'+this.stationRouteStationName+"</label></div>";
205 cont++; 205 cont++;
206 }); 206 });
207 station_radio_html += '</div>'; 207 station_radio_html += '</div>';
src/main/resources/static/pages/base/linecast/cast.html
@@ -166,6 +166,33 @@ function getTreeData(cb){ @@ -166,6 +166,33 @@ function getTreeData(cb){
166 }); 166 });
167 } 167 }
168 168
  169 +/**
  170 + * 将模块List 转换为树结构
  171 + * @param arr
  172 + * @returns {Array}
  173 + */
  174 +function createTreeData(arr){
  175 + var treeData = [];
  176 + var len = arr.length;
  177 + for(var i = 0; i < len; i ++){
  178 + var pId = arr[i].pId;
  179 + arr[i].text = arr[i].name;
  180 + if(!pId){
  181 + treeData.push(arr[i]);
  182 + }
  183 +
  184 + for(var j = 0; j < len; j ++){
  185 + if(pId == arr[j].id){
  186 + if(!arr[j].children)
  187 + arr[j].children = [];
  188 + arr[j].children.push(arr[i]);
  189 + break;
  190 + }
  191 + }
  192 + }
  193 + return treeData;
  194 +}
  195 +
169 function getModuleTreeData(userId){ 196 function getModuleTreeData(userId){
170 197
171 198
src/main/resources/static/pages/base/section/js/add-form-events.js
@@ -22,12 +22,8 @@ $(function(){ @@ -22,12 +22,8 @@ $(function(){
22 $('#lineIdInput').val(lineSelectValueArray[0]);// 设值线路编码. 22 $('#lineIdInput').val(lineSelectValueArray[0]);// 设值线路编码.
23 $('#lineCodeInput').val(lineSelectValueArray[1]);// 设值线路ID. 23 $('#lineCodeInput').val(lineSelectValueArray[1]);// 设值线路ID.
24 // 版本号赋值 24 // 版本号赋值
25 - $.get('/lineVersions/findByLineId',{'lineId':lineSelectValueArray[0]},function(lineVersions){  
26 - $.each(lineVersions,function(){  
27 - if (this.status == 1) {  
28 - $('#versionsInput').val(this.versions);  
29 - }  
30 - }) 25 + $.get('/lineVersions/findCurrentVersion',{'lineId':lineSelectValueArray[0]},function(versions){
  26 + $('#versionsInput').val(versions);
31 }); 27 });
32 // 获取该线路下的路段路由. 28 // 获取该线路下的路段路由.
33 PublicFunctions.getSectionRouteInfo(lineSelectValueArray[0],function(array) { 29 PublicFunctions.getSectionRouteInfo(lineSelectValueArray[0],function(array) {
src/main/resources/static/pages/base/station/js/add-form-events.js
@@ -24,12 +24,8 @@ $(function(){ @@ -24,12 +24,8 @@ $(function(){
24 $('#lineCodeInput').val(lineSelectValueArray[1]); 24 $('#lineCodeInput').val(lineSelectValueArray[1]);
25 var params = {'lineCode_eq':lineSelectValueArray[1],'destroy_eq':0,'directions_eq':dir}; 25 var params = {'lineCode_eq':lineSelectValueArray[1],'destroy_eq':0,'directions_eq':dir};
26 // 版本号赋值 26 // 版本号赋值
27 - $.get('/lineVersions/findByLineId',{'lineId':lineSelectValueArray[0]},function(lineVersions){  
28 - $.each(lineVersions,function(){  
29 - if (this.status == 1) {  
30 - $('#versionsInput').val(this.versions);  
31 - }  
32 - }) 27 + $.get('/lineVersions/findCurrentVersion',{'lineId':lineSelectValueArray[0]},function(versions){
  28 + $('#versionsInput').val(versions);
33 }); 29 });
34 initSelect(params); 30 initSelect(params);
35 } 31 }
src/main/resources/static/pages/base/stationroute/add.html
@@ -237,12 +237,8 @@ $(&#39;#add_station_mobal&#39;).on(&#39;AddStationMobal.show&#39;, function(e, addMap,ajaxd,stao @@ -237,12 +237,8 @@ $(&#39;#add_station_mobal&#39;).on(&#39;AddStationMobal.show&#39;, function(e, addMap,ajaxd,stao
237 // 是否撤销 237 // 是否撤销
238 $('#destroySelect').val(0); 238 $('#destroySelect').val(0);
239 // 版本号 239 // 版本号
240 - $.get('/lineVersions/findByLineId',{'lineId':Line.id},function(lineVersions){  
241 - $.each(lineVersions,function(){  
242 - if (this.status == 1) {  
243 - $('#versionsInput').val(this.versions);  
244 - }  
245 - }) 240 + $.get('/lineVersions/findCurrentVersion',{'lineId':Line.id},function(versions){
  241 + $('#versionsInput').val(versions);
246 }); 242 });
247 243
248 var initzdlyP = {'line.id_eq':Line.id,'destroy_eq':0,'directions_eq':Station.dir}; 244 var initzdlyP = {'line.id_eq':Line.id,'destroy_eq':0,'directions_eq':Station.dir};
src/main/resources/static/pages/base/stationroute/js/stationroute-list-map.js
@@ -216,7 +216,6 @@ var WorldsBMap = function () { @@ -216,7 +216,6 @@ var WorldsBMap = function () {
216 216
217 // 地图画多边形 217 // 地图画多边形
218 pointsPolygon : function(objStation) { 218 pointsPolygon : function(objStation) {
219 - debugger  
220 219
221 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) 220 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
222 mapBValue.setZoom(15); 221 mapBValue.setZoom(15);
@@ -374,7 +373,6 @@ var WorldsBMap = function () { @@ -374,7 +373,6 @@ var WorldsBMap = function () {
374 373
375 // 画圆 374 // 画圆
376 pointsCircle : function(objStation) { 375 pointsCircle : function(objStation) {
377 - debugger  
378 376
379 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) 377 // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增)
380 mapBValue.setZoom(16); 378 mapBValue.setZoom(16);
src/main/resources/static/pages/base/timesmodel/js/v2/ParameterObj.js
@@ -895,7 +895,7 @@ var ParameterObj = function() { @@ -895,7 +895,7 @@ var ParameterObj = function() {
895 }, 895 },
896 896
897 /** 897 /**
898 - * 获取固定的停站时间(固定停站时间都是选的最大值 898 + * 获取固定的停站时间(固定停站时间都是选的最大值,非平均停站
899 * @param oTimeObj 时间对象 899 * @param oTimeObj 时间对象
900 * @param bIsUp 是否上行 900 * @param bIsUp 是否上行
901 * @param iXXTime 行驶时间 901 * @param iXXTime 行驶时间
@@ -1082,6 +1082,85 @@ var ParameterObj = function() { @@ -1082,6 +1082,85 @@ var ParameterObj = function() {
1082 }, 1082 },
1083 1083
1084 /** 1084 /**
  1085 + * 获取固定的停站时间(固定停站时间都是选的最小值,非平均停站)
  1086 + * @param oTimeObj 时间对象
  1087 + * @param bIsUp 是否上行
  1088 + * @returns int 停站时间
  1089 + */
  1090 + fnCalcuFixedMinStopNumber: function(oTimeObj, bIsUp) {
  1091 + _validInternal(); // 验证
  1092 + var oParam = this;
  1093 +
  1094 + // 双向停站
  1095 + if (oParam.isTwoWayStop()) {
  1096 + if (bIsUp) { // 上行
  1097 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1098 + return 3;
  1099 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1100 + return 3;
  1101 + } else { // 低谷
  1102 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1103 + return 10;
  1104 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1105 + return 10;
  1106 + } else { // 早高峰,晚高峰之间
  1107 + return 10;
  1108 + }
  1109 + }
  1110 +
  1111 + } else { // 下行
  1112 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1113 + return 3;
  1114 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1115 + return 3;
  1116 + } else { // 低谷
  1117 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1118 + return 10;
  1119 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1120 + return 10;
  1121 + } else { // 早高峰,晚高峰之间
  1122 + return 10;
  1123 + }
  1124 + }
  1125 + }
  1126 + } else { // 主站停站
  1127 + if (bIsUp == oParam.isUpOneWayStop()) {
  1128 + if (bIsUp) { // 上行
  1129 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1130 + return 2;
  1131 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1132 + return 2;
  1133 + } else { // 低谷
  1134 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1135 + return 10;
  1136 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1137 + return 10;
  1138 + } else { // 早高峰,晚高峰之间
  1139 + return 10;
  1140 + }
  1141 + }
  1142 + } else { // 下行
  1143 + if (this.isMPeakBc(oTimeObj)) { // 早高峰
  1144 + return 2;
  1145 + } else if (this.isEPeakBc(oTimeObj)) { // 晚高峰
  1146 + return 2;
  1147 + } else { // 低谷
  1148 + if (this.isTroughBeforMPeakStartBc(oTimeObj)) { // 早高峰开始前
  1149 + return 10;
  1150 + } else if (this.isTroughAfterEPeakEndBc(oTimeObj)) { // 晚高峰结束后
  1151 + return 10;
  1152 + } else { // 早高峰,晚高峰之间
  1153 + return 10;
  1154 + }
  1155 + }
  1156 + }
  1157 + } else { // 副站停战,2到3分钟
  1158 + return 2;
  1159 + }
  1160 + }
  1161 + },
  1162 +
  1163 + /**
1085 * 获取行驶时间。 1164 * 获取行驶时间。
1086 * @param timeObj 班次时间字符串 1165 * @param timeObj 班次时间字符串
1087 * @param isUp 是否上行 1166 * @param isUp 是否上行
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalBcObj.js
@@ -32,6 +32,7 @@ var InternalBcObj = function( @@ -32,6 +32,7 @@ var InternalBcObj = function(
32 this._$_bcsj = otherParamObj.bcsj; // 班次历时 32 this._$_bcsj = otherParamObj.bcsj; // 班次历时
33 this._$_arrtime = otherParamObj.arrtime; // 到达时间对象 33 this._$_arrtime = otherParamObj.arrtime; // 到达时间对象
34 this._$_stoptime = otherParamObj.stoptime; // 停站时间 34 this._$_stoptime = otherParamObj.stoptime; // 停站时间
  35 + this._$_iEatTime = 0; // 吃饭时间
35 this._$_tccid = otherParamObj.tccid; // 停车场id 36 this._$_tccid = otherParamObj.tccid; // 停车场id
36 this._$_ttinfoid = otherParamObj.ttinfoid; // 时刻表id 37 this._$_ttinfoid = otherParamObj.ttinfoid; // 时刻表id
37 this._$_xlid = otherParamObj.xl; // 线路id 38 this._$_xlid = otherParamObj.xl; // 线路id
@@ -45,6 +46,13 @@ var InternalBcObj = function( @@ -45,6 +46,13 @@ var InternalBcObj = function(
45 46
46 //------------------- get/set 方法 -------------------// 47 //------------------- get/set 方法 -------------------//
47 48
  49 +InternalBcObj.prototype.fnSetEatTime = function(iTime) {
  50 + this._$_iEatTime = iTime;
  51 +};
  52 +InternalBcObj.prototype.fnGetEatTime = function() {
  53 + return this._$_iEatTime;
  54 +};
  55 +
48 InternalBcObj.prototype.fnSetDelFlag = function(bFlag) { 56 InternalBcObj.prototype.fnSetDelFlag = function(bFlag) {
49 this._$_bDelFlag = bFlag; 57 this._$_bDelFlag = bFlag;
50 }; 58 };
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalLpObj.js
1 -/**  
2 - * 内部路牌对象。  
3 - * @constructor  
4 - */  
5 -var InternalLpObj = function(  
6 - orilpObj, // 原始路牌对象  
7 - qCount, // 总共多少圈  
8 - isUp // 圈是以上行开始还是下行开始  
9 -) {  
10 - // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了)  
11 - this._$$_orign_lp_obj = orilpObj;  
12 -  
13 - this._$_isUp = isUp;  
14 -  
15 - // 路牌的圈数,注意每个路牌的圈数都是一致的,  
16 - // 但并不是每一圈都有值  
17 - // 第1圈从上标线开始  
18 - // 第0圈表示中标线的第一个班次组成的半圈  
19 - // 有多少圈根据最终迭代的结果来看  
20 - this._$_qCount = qCount;  
21 - // 保存的是 InternalGroupBcObj 对象  
22 - this._$_groupBcArray = new Array(qCount);  
23 -  
24 - var i;  
25 - for (i = 0; i < this._$_qCount; i++) {  
26 - this._$_groupBcArray[i] = new InternalGroupObj(  
27 - this, this._$_isUp, undefined, undefined);  
28 - }  
29 -  
30 - // 距离上一个路牌的最小发车间隔时间  
31 - // 用于纵向添加班次的时候使用  
32 - // 默认第一个路牌为0  
33 - this._$_minVerticalIntervalTime = 0;  
34 -  
35 - // 详细记录每圈每个方向上的发车间隔时间  
36 - // 第一维度表示圈数,第二维度表示第一个方向,第二个方向  
37 - // 第一个方向是否上行由 _$_isUp 决定  
38 - // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔  
39 - // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔  
40 - this._$_aVerticalIntervalTime = new Array(this._$_qCount);  
41 - var i;  
42 - for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) {  
43 - this._$_aVerticalIntervalTime[i] = new Array(2);  
44 - }  
45 -  
46 - // 班型的相关变量  
47 - this._$_bx_isLb = false; // 是否连班  
48 - this._$_bx_isfb = false; // 是否分班  
49 - this._$_bx_isfb_5_2 = false; // 是否5休2分班  
50 - this._$_bx_desc; // 班型描述(默认为路牌编号)  
51 -  
52 - // 其他班次(进出场,例包,吃饭等),TODO:以后再拆  
53 - this._$_other_bc_array = [];  
54 -  
55 - // TODO:  
56 -  
57 -};  
58 -  
59 -//------------------- get/set 方法 -------------------//  
60 -  
61 -InternalLpObj.prototype.getOtherBcArray = function() {  
62 - return this._$_other_bc_array;  
63 -};  
64 -InternalLpObj.prototype.addOtherBcArray = function(ba) {  
65 - this._$_other_bc_array = this._$_other_bc_array.concat(ba);  
66 -};  
67 -  
68 -/**  
69 - * 获取圈  
70 - * @param qIndex 圈index  
71 - */  
72 -InternalLpObj.prototype.getGroup = function(qIndex) {  
73 - return this._$_groupBcArray[qIndex];  
74 -};  
75 -  
76 -/**  
77 - * 获取班次。  
78 - * @param qIndex 第几圈  
79 - * @param bcIndex 第几个班次  
80 - */  
81 -InternalLpObj.prototype.getBc = function(qIndex, bcIndex) {  
82 - var group = this._$_groupBcArray[qIndex];  
83 - var bc;  
84 - if (bcIndex == 0) {  
85 - bc = group.getBc1();  
86 - } else if (bcIndex == 1) {  
87 - bc = group.getBc2();  
88 - }  
89 - return bc;  
90 -};  
91 -  
92 -/**  
93 - * 在具体位置设置班次。  
94 - * @param qIndex 第几圈  
95 - * @param bcIndex 第几个班次  
96 - * @param bc 班次对象  
97 - */  
98 -InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) {  
99 - var group = this._$_groupBcArray[qIndex];  
100 - if (bcIndex == 0) {  
101 - group.setBc1(bc);  
102 - bc.setGroup(group);  
103 - } else if (bcIndex == 1) {  
104 - group.setBc2(bc);  
105 - bc.setGroup(group);  
106 - }  
107 -};  
108 -  
109 -/**  
110 - * 设置原始路牌对象。  
111 - * @param lpObj 原始路牌对象  
112 - */  
113 -InternalLpObj.prototype.setLp = function(lpObj) {  
114 - this._$$_orign_lp_obj = lpObj;  
115 - var i;  
116 - var group;  
117 - for (i = 0; i < this._$_groupBcArray.length; i++) {  
118 - group = this._$_groupBcArray[i];  
119 - if (group) {  
120 - group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象  
121 - }  
122 - }  
123 -};  
124 -  
125 -InternalLpObj.prototype.getLpNo = function() {  
126 - return this._$$_orign_lp_obj.lpNo;  
127 -};  
128 -InternalLpObj.prototype.getLpName = function() {  
129 - return this._$$_orign_lp_obj.lpName;  
130 -};  
131 -InternalLpObj.prototype.setBxFb5_2 = function(fb) {  
132 - this._$_bx_isfb_5_2 = fb;  
133 -};  
134 -InternalLpObj.prototype.isBxFb5_2 = function() {  
135 - return this._$_bx_isfb_5_2;  
136 -};  
137 -InternalLpObj.prototype.setBxLb = function(lb) {  
138 - this._$_bx_isLb = lb;  
139 -};  
140 -InternalLpObj.prototype.isBxLb = function() {  
141 - return this._$_bx_isLb;  
142 -};  
143 -  
144 -InternalLpObj.prototype.setBxFb = function(fb) {  
145 - this._$_bx_isfb = fb;  
146 -};  
147 -InternalLpObj.prototype.isBxFb = function() {  
148 - return this._$_bx_isfb;  
149 -};  
150 -  
151 -/**  
152 - * 设置路牌的班型描述(最终是设置班次的路牌名字)。  
153 - * @param desc 描述  
154 - */  
155 -InternalLpObj.prototype.setBxDesc = function(desc) {  
156 - // 最终原始路牌的名字  
157 - this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo;  
158 - // 内部对象的班型描述  
159 - this._$_bx_desc = desc;  
160 -};  
161 -/**  
162 - * 获取版型描述  
163 - * @returns string  
164 - */  
165 -InternalLpObj.prototype.getBxDesc = function() {  
166 - return this._$_bx_desc;  
167 -};  
168 -  
169 -/**  
170 - * 设置纵向最小发车间隔时间。  
171 - * @param v  
172 - */  
173 -InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) {  
174 - // 第一个路牌,都为0  
175 - this._$_minVerticalIntervalTime = v;  
176 -};  
177 -/**  
178 - * 获取纵向最小发车间隔时间。  
179 - * @returns {number|*}  
180 - */  
181 -InternalLpObj.prototype.getVerticalMinIntervalTime = function() {  
182 - return this._$_minVerticalIntervalTime;  
183 -};  
184 -  
185 -/**  
186 - * 设置纵向发车间隔。  
187 - * @param iQindex 圈index  
188 - * @param iBindex 班次index  
189 - * @param iTime 间隔时间  
190 - */  
191 -InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) {  
192 - this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime;  
193 -};  
194 -  
195 -/**  
196 - * 返回纵向发车间隔。  
197 - * @param iQindex 圈index  
198 - * @param iBindex 班次index  
199 - */  
200 -InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) {  
201 - return this._$_aVerticalIntervalTime[iQindex][iBindex];  
202 -};  
203 -  
204 -//-------------------- 班次操作方法(查询,统计,删除) -----------------------//  
205 -  
206 -/**  
207 - * 返回总共班次数。  
208 - */  
209 -InternalLpObj.prototype.getBcCount = function() {  
210 - var i;  
211 - var group;  
212 - var bccount = 0;  
213 - for (i = 0; i < this._$_groupBcArray.length; i++) {  
214 - group = this._$_groupBcArray[i];  
215 - if (group) {  
216 - if (group.getBc1()) {  
217 - bccount += 1;  
218 - }  
219 - if (group.getBc2()) {  
220 - bccount += 1;  
221 - }  
222 - }  
223 - }  
224 -  
225 - return bccount;  
226 -};  
227 -  
228 -/**  
229 - * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。  
230 - * @returns arrays (InternalBcObj)  
231 - */  
232 -InternalLpObj.prototype.getBcArray = function() {  
233 - var bcArray = [];  
234 - var i;  
235 - var group;  
236 - for (i = 0; i < this._$_groupBcArray.length; i++) {  
237 - group = this._$_groupBcArray[i];  
238 - if (group) {  
239 - group.getBc1() ? bcArray.push(group.getBc1()) : "";  
240 - group.getBc2() ? bcArray.push(group.getBc2()) : "";  
241 - }  
242 - }  
243 -  
244 - return bcArray;  
245 -};  
246 -  
247 -/**  
248 - * 获取最小(最早)班次对象。  
249 - * @returns [{圈index},{班次index}]  
250 - */  
251 -InternalLpObj.prototype.getMinBcObjPosition = function() {  
252 - var i;  
253 - var bIndex = [];  
254 - for (i = 0; i < this._$_groupBcArray.length; i++) {  
255 - if (this._$_groupBcArray[i].getBc1()) {  
256 - bIndex.push(i);  
257 - bIndex.push(0);  
258 - break;  
259 - }  
260 - if (this._$_groupBcArray[i].getBc2()) {  
261 - bIndex.push(i);  
262 - bIndex.push(1);  
263 - break;  
264 - }  
265 - }  
266 - return bIndex;  
267 -};  
268 -  
269 -/**  
270 - * 获取最大(最晚)班次对象。  
271 - * @returns [{圈index},{班次index}]  
272 - */  
273 -InternalLpObj.prototype.getMaxBcObjPosition = function() {  
274 - var i;  
275 - var bIndex = [];  
276 - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {  
277 - if (this._$_groupBcArray[i].getBc2()) {  
278 - bIndex.push(i);  
279 - bIndex.push(1);  
280 - break;  
281 - }  
282 - if (this._$_groupBcArray[i].getBc1()) {  
283 - bIndex.push(i);  
284 - bIndex.push(0);  
285 - break;  
286 - }  
287 - }  
288 - return bIndex;  
289 -};  
290 -  
291 -InternalLpObj.prototype.getMinBcObj = function() {  
292 - var i;  
293 - var bcObj;  
294 - for (i = 0; i < this._$_groupBcArray.length; i++) {  
295 - bcObj = this._$_groupBcArray[i].getBc1();  
296 - if (bcObj) {  
297 - break;  
298 - }  
299 - bcObj = this._$_groupBcArray[i].getBc2();  
300 - if (bcObj) {  
301 - break;  
302 - }  
303 - }  
304 - return bcObj;  
305 -};  
306 -InternalLpObj.prototype.getMaxBcObj = function() {  
307 - var i;  
308 - var bcObj;  
309 - for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {  
310 - bcObj = this._$_groupBcArray[i].getBc2();  
311 - if (bcObj) {  
312 - break;  
313 - }  
314 - bcObj = this._$_groupBcArray[i].getBc1();  
315 - if (bcObj) {  
316 - break;  
317 - }  
318 - }  
319 - return bcObj;  
320 -};  
321 -  
322 -/**  
323 - * 获取车次链信息。  
324 - * @param num 第几个车次链  
325 - * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}  
326 - */  
327 -InternalLpObj.prototype.fnGetBcChainInfo = function(num) {  
328 - // 计算总的车次链信息  
329 - var aChainInfo = [];  
330 - var oChainInfo;  
331 - var aBcIndex = this.getMinBcObjPosition();  
332 - var oBc;  
333 - var iQIndex;  
334 - var iBcIndex;  
335 - var i;  
336 - var bFlag;  
337 -  
338 - var iBcount = 0;  
339 -  
340 - if (aBcIndex.length == 2) {  
341 - iBcount = 1;  
342 - oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};  
343 - aChainInfo.push(oChainInfo);  
344 - bFlag = true;  
345 -  
346 - // 下一个班次的索引  
347 - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;  
348 - iBcIndex = aBcIndex[1] == 0 ? 1 : 0;  
349 -  
350 - for (i = iQIndex; i < this._$_qCount; i++) {  
351 - while (iBcIndex <= 1) {  
352 - oBc = this.getBc(i, iBcIndex);  
353 - if (!oBc) {  
354 - if (bFlag) {  
355 - // 车次链结尾是这个班次的前一个班次  
356 - oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;  
357 - oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;  
358 - oChainInfo.bcount = iBcount;  
359 - }  
360 -  
361 - bFlag = false;  
362 - } else {  
363 - if (bFlag) {  
364 - iBcount ++;  
365 - oChainInfo.bcount = iBcount;  
366 - } else {  
367 - // 下一个车次链开始  
368 - iBcount = 1;  
369 - oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};  
370 - aChainInfo.push(oChainInfo);  
371 - bFlag = true;  
372 - }  
373 - }  
374 -  
375 -  
376 - iBcIndex ++;  
377 - }  
378 - iBcIndex = 0;  
379 - }  
380 -  
381 - }  
382 -  
383 - return aChainInfo[num];  
384 -};  
385 -  
386 -/**  
387 - * 获取车次链的个数。  
388 - * @returns int  
389 - */  
390 -InternalLpObj.prototype.fnGetBcChainCount = function() {  
391 - var iChainCount = 0;  
392 - var aBcIndex = this.getMinBcObjPosition();  
393 -  
394 - var oBc;  
395 - var iQIndex;  
396 - var iBcIndex;  
397 - var i;  
398 - var bFlag;  
399 -  
400 - if (aBcIndex.length == 2) {  
401 - iChainCount = 1;  
402 - bFlag = true;  
403 -  
404 - // 下一个班次的索引  
405 - iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;  
406 - iBcIndex = aBcIndex[1] == 0 ? 1 : 0;  
407 -  
408 - for (i = iQIndex; i < this._$_qCount; i++) {  
409 - while (iBcIndex <= 1) {  
410 - oBc = this.getBc(i, iBcIndex);  
411 - if (!oBc) {  
412 - bFlag = false;  
413 - } else {  
414 - if (bFlag) {  
415 -  
416 - } else {  
417 - iChainCount ++;  
418 - bFlag = true;  
419 - }  
420 - }  
421 -  
422 -  
423 - iBcIndex ++;  
424 - }  
425 - iBcIndex = 0;  
426 - }  
427 -  
428 - }  
429 -  
430 -  
431 - return iChainCount;  
432 -};  
433 -  
434 -/**  
435 - * 在具体位置移除班次。  
436 - * @param qIndex 第几圈  
437 - * @param bcIndex 第几个班次  
438 - */  
439 -InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {  
440 - var group = this._$_groupBcArray[qIndex];  
441 - if (bcIndex == 0) {  
442 - group.removeBc1();  
443 - } else if (bcIndex == 1) {  
444 - group.removeBc2();  
445 - }  
446 -};  
447 -  
448 -/**  
449 - * 使用指定时间匹配返回离之最近的第几圈第几个班次,  
450 - * 使用时间差的绝度值,比较,取最小的  
451 - * 如果有两个一样的时间差,取比fctime大的时间  
452 - * @param fctime moment 比较用时间  
453 - * @param groupArray 圈数组  
454 - * @param hasUp boolean 计算上行班次  
455 - * @param hasDown boolean 计算下行班次  
456 - * @returns [{第几圈},{第几个班次}]  
457 - */  
458 -InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(  
459 - fctime, groupArray, hasUp, hasDown  
460 -) {  
461 - var i;  
462 - var timediff; // 时间差取绝对值  
463 - var qIndex;  
464 - var bcIndex;  
465 -  
466 - var group;  
467 - var bc1time;  
468 - var bc2time;  
469 -  
470 - var tempdiff;  
471 - for (i = 0; i < this._$_qCount; i++) {  
472 - group = groupArray[i];  
473 - if (group) {  
474 - if (group.getBc1() && hasUp) {  
475 - bc1time = group.getBc1().getFcTimeObj();  
476 - tempdiff = Math.abs(bc1time.diff(fctime));  
477 -  
478 - if (!timediff) {  
479 - timediff = Math.abs(tempdiff);  
480 - qIndex = i;  
481 - bcIndex = 0;  
482 - } else {  
483 - if (tempdiff < timediff) {  
484 - timediff = tempdiff;  
485 - qIndex = i;  
486 - bcIndex = 0;  
487 - } if (Math.abs(tempdiff) == timediff) {  
488 - if (bc1time.isBefore(fctime)) {  
489 - timediff = tempdiff;  
490 - qIndex = i;  
491 - bcIndex = 0;  
492 - }  
493 -  
494 - }  
495 - }  
496 - }  
497 -  
498 - if (group.getBc2() && hasDown) {  
499 - bc2time = group.getBc2().getFcTimeObj();  
500 - tempdiff = Math.abs(bc2time.diff(fctime));  
501 -  
502 - if (!timediff) {  
503 - timediff = Math.abs(tempdiff);  
504 - qIndex = i;  
505 - bcIndex = 1;  
506 - } else {  
507 - if (tempdiff < timediff) {  
508 - timediff = tempdiff;  
509 - qIndex = i;  
510 - bcIndex = 1;  
511 - } if (Math.abs(tempdiff) == timediff) {  
512 - if (bc2time.isBefore(fctime)) {  
513 - timediff = tempdiff;  
514 - qIndex = i;  
515 - bcIndex = 1;  
516 - }  
517 -  
518 - }  
519 - }  
520 - }  
521 - }  
522 - }  
523 -  
524 - var rst = [];  
525 - rst.push(qIndex);  
526 - rst.push(bcIndex);  
527 -  
528 - return rst;  
529 -};  
530 -  
531 -/**  
532 - * 使用指定时间匹配返回离之最近的第几圈第几个班次,  
533 - * 使用时间差的绝度值,比较,取最小的  
534 - * 如果有两个一样的时间差,取比fctime大的时间  
535 - * @param fctime moment 比较用时间  
536 - * @param hasUp boolean 计算上行班次  
537 - * @param hasDown boolean 计算下行班次  
538 - * @returns [{第几圈},{第几个班次}]  
539 - */  
540 -InternalLpObj.prototype.getQBcIndexWithFcTime = function(  
541 - fctime, hasUp, hasDown  
542 -) {  
543 - return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);  
544 -};  
545 -  
546 -//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//  
547 -  
548 -/**  
549 - * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌  
550 - * 注意,之前有班次会删除后再创建。  
551 - * @param startTime 开始时间  
552 - * @param endTime 结束时间  
553 - * @param isUp 第一个班次是上行还是下行  
554 - * @param fromQ 从第几圈开始加入  
555 - * @param paramObj 参数对象  
556 - * @param factory 工厂对象  
557 - */  
558 -InternalLpObj.prototype.initDataFromTimeToTime = function(  
559 - startTime,  
560 - endTime,  
561 - isUp,  
562 - fromQ,  
563 - paramObj,  
564 - factory) {  
565 -  
566 - var bcData = []; // 班次数组  
567 - var bcObj;  
568 - var kssj = startTime;  
569 - var fcno = 1; // 发车顺序号  
570 - var bcCount = 1; // 班次数  
571 - do {  
572 - bcObj = factory.createBcObj(  
573 - this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象  
574 - bcData.push(bcObj);  
575 -  
576 - kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());  
577 - fcno ++;  
578 - bcCount ++;  
579 - isUp = !isUp;  
580 - } while(kssj.isBefore(endTime));  
581 - bcCount--;  
582 -  
583 - //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));  
584 - //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));  
585 - //console.log("endtime: " + endTime.format("HH:mm"));  
586 -  
587 - if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {  
588 - // 如果最后一个班次的到达时间超过结束时间,也要去除  
589 - bcData.splice(bcCount - 1, 1);  
590 - }  
591 -  
592 - this._initDataFromLbBcArray(bcData, fromQ);  
593 -  
594 -};  
595 -  
596 -/**  
597 - * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。  
598 - * @param bcArray 连班班次数组  
599 - * @param fromQ 从第几圈开始加入  
600 - */  
601 -InternalLpObj.prototype._initDataFromLbBcArray = function(  
602 - bcArray,  
603 - fromQ  
604 -) {  
605 - var _bc1Obj;  
606 - var _bc2Obj;  
607 - var _qObj;  
608 -  
609 - // 第一班次是上行还是下行  
610 - var isUp = bcArray[0].isUp();  
611 -  
612 - if (bcArray.length > 0 && fromQ < this._$_qCount) {  
613 - // 构造圈数  
614 - if (isUp != this._$_isUp) {  
615 - // 如果方向不一致,意味着第一个班次是半圈  
616 - // 加半圈,并加在bc2上  
617 - _bc2Obj = bcArray.slice(0, 1)[0];  
618 - _qObj = new InternalGroupObj(  
619 - this,  
620 - this._$_isUp,  
621 - undefined,  
622 - _bc2Obj  
623 - );  
624 - _bc2Obj.setGroup(_qObj);  
625 - this._$_groupBcArray[fromQ] = _qObj;  
626 -  
627 - bcArray.splice(0, 1);  
628 - fromQ ++;  
629 - }  
630 -  
631 - var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈  
632 - var qCount2 = bcArray.length % 2; // 最后是否有半圈  
633 -  
634 - while (fromQ < this._$_qCount) {  
635 - if (qCount1 > 0) {  
636 - _bc1Obj = bcArray.slice(0, 1)[0];  
637 - _bc2Obj = bcArray.slice(1, 2)[0];  
638 - _qObj = new InternalGroupObj(  
639 - this,  
640 - this._$_isUp,  
641 - _bc1Obj,  
642 - _bc2Obj  
643 - );  
644 - _bc1Obj.setGroup(_qObj);  
645 - _bc2Obj.setGroup(_qObj);  
646 - this._$_groupBcArray[fromQ] = _qObj;  
647 -  
648 - bcArray.splice(0, 2);  
649 - qCount1 --;  
650 - } else if (qCount2 > 0) {  
651 - // 加半圈,并加在bc1上  
652 - _bc1Obj = bcArray.slice(0, 1)[0];  
653 - _qObj = new InternalGroupObj(  
654 - this,  
655 - this._$_isUp,  
656 - _bc1Obj,  
657 - undefined  
658 - );  
659 - _bc1Obj.setGroup(_qObj);  
660 - this._$_groupBcArray[fromQ] = _qObj;  
661 -  
662 - bcArray.splice(0, 1);  
663 - qCount2 --;  
664 - } else {  
665 - break;  
666 - }  
667 -  
668 - fromQ ++;  
669 - }  
670 - }  
671 -};  
672 -  
673 -//-------------------------- 其他方法 ----------------------------//  
674 -  
675 -/**  
676 - * 从指定位置的班次开始,往后所有的班次修正发车时间  
677 - * @param groupIndex  
678 - * @param bcIndex  
679 - * @param time  
680 - */  
681 -InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {  
682 - var i;  
683 - var oCurBc;  
684 -  
685 - // 修正之前班次的停站时间  
686 - //oCurBc = this.getBc(  
687 - // bcIndex == 0 ? groupIndex - 1 : groupIndex,  
688 - // bcIndex == 1 ? 0 : 1  
689 - //);  
690 - //if (oCurBc) {  
691 - // oCurBc.setStopTime(oCurBc.getStopTime() + time);  
692 - //}  
693 -  
694 -  
695 - for (i = groupIndex; i < this._$_qCount; i++) {  
696 - if (bcIndex == 0) {  
697 - oCurBc = this.getBc(i, 0);  
698 - if (oCurBc) {  
699 - oCurBc.addMinuteToFcsj(time);  
700 - }  
701 - oCurBc = this.getBc(i, 1);  
702 - if (oCurBc) {  
703 - oCurBc.addMinuteToFcsj(time);  
704 - }  
705 -  
706 - } else {  
707 - oCurBc = this.getBc(i, 1);  
708 - if (oCurBc) {  
709 - oCurBc.addMinuteToFcsj(time);  
710 - }  
711 -  
712 - }  
713 -  
714 - bcIndex = 0;  
715 - }  
716 -};  
717 -  
718 -/**  
719 - * 在指定位置添加一个吃饭班次。  
720 - * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array  
721 - * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化  
722 - * @param groupIndex  
723 - * @param bcIndex  
724 - * @param factory  
725 - * @param paramObj  
726 - * @returns int 相差时间(吃饭时间距离和停站时间相差值)  
727 - */  
728 -InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {  
729 - var oPreBc;  
730 - var oEatBc;  
731 - var iBcModifyTime;  
732 - oPreBc = this.getBc( // 前一个邻接班次  
733 - bcIndex == 0 ? groupIndex - 1 : groupIndex,  
734 - bcIndex == 1 ? 0 : 1);  
735 - if (oPreBc) { // 存在前一个班次  
736 - oEatBc = factory.createBcObj(  
737 - this,  
738 - "cf",  
739 - !oPreBc.isUp(), // 和上一个班次方向相反  
740 - 1,  
741 - oPreBc.getArrTimeObj(), // 使用上一个班次的到达时间作为开始时间  
742 - paramObj  
743 - );  
744 -  
745 - //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间  
746 -  
747 - // 修正之后的班次发车时间  
748 - // 注意:之后那个班次发车时间就是吃饭班次的到达时间  
749 - iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");  
750 - this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);  
751 -  
752 - oPreBc.setStopTime(0);  
753 - this._$_other_bc_array.push(oEatBc);  
754 -  
755 - return iBcModifyTime;  
756 - } else {  
757 - return false;  
758 - }  
759 -  
760 -};  
761 -  
762 -  
763 -// TODO  
764 -  
765 -/**  
766 - *  
767 - *  
768 - */  
769 -InternalLpObj.prototype.calcuLpBx = function() {  
770 -  
771 -};  
772 -  
773 - 1 +/**
  2 + * 内部路牌对象。
  3 + * @constructor
  4 + */
  5 +var InternalLpObj = function(
  6 + orilpObj, // 原始路牌对象
  7 + qCount, // 总共多少圈
  8 + isUp // 圈是以上行开始还是下行开始
  9 +) {
  10 + // TODO:原始路牌对象(这个路牌是对接外部gantt图像,以后有机会改了)
  11 + this._$$_orign_lp_obj = orilpObj;
  12 +
  13 + this._$_isUp = isUp;
  14 +
  15 + // 路牌的圈数,注意每个路牌的圈数都是一致的,
  16 + // 但并不是每一圈都有值
  17 + // 第1圈从上标线开始
  18 + // 第0圈表示中标线的第一个班次组成的半圈
  19 + // 有多少圈根据最终迭代的结果来看
  20 + this._$_qCount = qCount;
  21 + // 保存的是 InternalGroupBcObj 对象
  22 + this._$_groupBcArray = new Array(qCount);
  23 +
  24 + var i;
  25 + for (i = 0; i < this._$_qCount; i++) {
  26 + this._$_groupBcArray[i] = new InternalGroupObj(
  27 + this, this._$_isUp, undefined, undefined);
  28 + }
  29 +
  30 + // 距离上一个路牌的最小发车间隔时间
  31 + // 用于纵向添加班次的时候使用
  32 + // 默认第一个路牌为0
  33 + this._$_minVerticalIntervalTime = 0;
  34 +
  35 + // 详细记录每圈每个方向上的发车间隔时间
  36 + // 第一维度表示圈数,第二维度表示第一个方向,第二个方向
  37 + // 第一个方向是否上行由 _$_isUp 决定
  38 + // 这里的间隔表示下一个路牌上的班次距离本路牌的班次发车时间间隔
  39 + // 如果当前是最后一个路牌,表示第一个路牌的下一圈同方向班次距离本班次的间隔
  40 + this._$_aVerticalIntervalTime = new Array(this._$_qCount);
  41 + var i;
  42 + for (i = 0; i < this._$_aVerticalIntervalTime.length; i++) {
  43 + this._$_aVerticalIntervalTime[i] = new Array(2);
  44 + }
  45 +
  46 + // 班型的相关变量
  47 + this._$_bx_isLb = false; // 是否连班
  48 + this._$_bx_isfb = false; // 是否分班
  49 + this._$_bx_isfb_5_2 = false; // 是否5休2分班
  50 + this._$_bx_desc; // 班型描述(默认为路牌编号)
  51 +
  52 + // 其他班次(进出场,例包,吃饭等),TODO:以后再拆
  53 + this._$_other_bc_array = [];
  54 +
  55 + // TODO:
  56 +
  57 +};
  58 +
  59 +//------------------- get/set 方法 -------------------//
  60 +
  61 +InternalLpObj.prototype.getOtherBcArray = function() {
  62 + return this._$_other_bc_array;
  63 +};
  64 +InternalLpObj.prototype.addOtherBcArray = function(ba) {
  65 + this._$_other_bc_array = this._$_other_bc_array.concat(ba);
  66 +};
  67 +
  68 +/**
  69 + * 获取圈
  70 + * @param qIndex 圈index
  71 + */
  72 +InternalLpObj.prototype.getGroup = function(qIndex) {
  73 + return this._$_groupBcArray[qIndex];
  74 +};
  75 +
  76 +/**
  77 + * 获取班次。
  78 + * @param qIndex 第几圈
  79 + * @param bcIndex 第几个班次
  80 + */
  81 +InternalLpObj.prototype.getBc = function(qIndex, bcIndex) {
  82 + var group = this._$_groupBcArray[qIndex];
  83 + var bc;
  84 + if (bcIndex == 0) {
  85 + bc = group.getBc1();
  86 + } else if (bcIndex == 1) {
  87 + bc = group.getBc2();
  88 + }
  89 + return bc;
  90 +};
  91 +
  92 +/**
  93 + * 在具体位置设置班次。
  94 + * @param qIndex 第几圈
  95 + * @param bcIndex 第几个班次
  96 + * @param bc 班次对象
  97 + */
  98 +InternalLpObj.prototype.setBc = function(qIndex, bcIndex, bc) {
  99 + var group = this._$_groupBcArray[qIndex];
  100 + if (bcIndex == 0) {
  101 + group.setBc1(bc);
  102 + bc.setGroup(group);
  103 + } else if (bcIndex == 1) {
  104 + group.setBc2(bc);
  105 + bc.setGroup(group);
  106 + }
  107 +};
  108 +
  109 +/**
  110 + * 设置原始路牌对象。
  111 + * @param lpObj 原始路牌对象
  112 + */
  113 +InternalLpObj.prototype.setLp = function(lpObj) {
  114 + this._$$_orign_lp_obj = lpObj;
  115 + var i;
  116 + var group;
  117 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  118 + group = this._$_groupBcArray[i];
  119 + if (group) {
  120 + group.setLp(this); // 圈和班次保存都是 InternalLpObj 对象
  121 + }
  122 + }
  123 +};
  124 +
  125 +InternalLpObj.prototype.getLpNo = function() {
  126 + return this._$$_orign_lp_obj.lpNo;
  127 +};
  128 +InternalLpObj.prototype.getLpName = function() {
  129 + return this._$$_orign_lp_obj.lpName;
  130 +};
  131 +InternalLpObj.prototype.setBxFb5_2 = function(fb) {
  132 + this._$_bx_isfb_5_2 = fb;
  133 +};
  134 +InternalLpObj.prototype.isBxFb5_2 = function() {
  135 + return this._$_bx_isfb_5_2;
  136 +};
  137 +InternalLpObj.prototype.setBxLb = function(lb) {
  138 + this._$_bx_isLb = lb;
  139 +};
  140 +InternalLpObj.prototype.isBxLb = function() {
  141 + return this._$_bx_isLb;
  142 +};
  143 +
  144 +InternalLpObj.prototype.setBxFb = function(fb) {
  145 + this._$_bx_isfb = fb;
  146 +};
  147 +InternalLpObj.prototype.isBxFb = function() {
  148 + return this._$_bx_isfb;
  149 +};
  150 +
  151 +/**
  152 + * 设置路牌的班型描述(最终是设置班次的路牌名字)。
  153 + * @param desc 描述
  154 + */
  155 +InternalLpObj.prototype.setBxDesc = function(desc) {
  156 + // 最终原始路牌的名字
  157 + this._$$_orign_lp_obj.lpName = desc + "_" + this._$$_orign_lp_obj.lpNo;
  158 + // 内部对象的班型描述
  159 + this._$_bx_desc = desc;
  160 +};
  161 +/**
  162 + * 获取版型描述
  163 + * @returns string
  164 + */
  165 +InternalLpObj.prototype.getBxDesc = function() {
  166 + return this._$_bx_desc;
  167 +};
  168 +
  169 +/**
  170 + * 设置纵向最小发车间隔时间。
  171 + * @param v
  172 + */
  173 +InternalLpObj.prototype.setVerticalMinIntervalTime = function(v) {
  174 + // 第一个路牌,都为0
  175 + this._$_minVerticalIntervalTime = v;
  176 +};
  177 +/**
  178 + * 获取纵向最小发车间隔时间。
  179 + * @returns {number|*}
  180 + */
  181 +InternalLpObj.prototype.getVerticalMinIntervalTime = function() {
  182 + return this._$_minVerticalIntervalTime;
  183 +};
  184 +
  185 +/**
  186 + * 设置纵向发车间隔。
  187 + * @param iQindex 圈index
  188 + * @param iBindex 班次index
  189 + * @param iTime 间隔时间
  190 + */
  191 +InternalLpObj.prototype.fnSetVerticalIntervalTime = function(iQindex, iBindex, iTime) {
  192 + this._$_aVerticalIntervalTime[iQindex][iBindex] = iTime;
  193 +};
  194 +
  195 +/**
  196 + * 返回纵向发车间隔。
  197 + * @param iQindex 圈index
  198 + * @param iBindex 班次index
  199 + */
  200 +InternalLpObj.prototype.fnGetVerticalIntervalTime = function(iQindex, iBindex) {
  201 + return this._$_aVerticalIntervalTime[iQindex][iBindex];
  202 +};
  203 +
  204 +//-------------------- 班次操作方法(查询,统计,删除) -----------------------//
  205 +
  206 +/**
  207 + * 返回总共班次数。
  208 + */
  209 +InternalLpObj.prototype.getBcCount = function() {
  210 + var i;
  211 + var group;
  212 + var bccount = 0;
  213 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  214 + group = this._$_groupBcArray[i];
  215 + if (group) {
  216 + if (group.getBc1()) {
  217 + bccount += 1;
  218 + }
  219 + if (group.getBc2()) {
  220 + bccount += 1;
  221 + }
  222 + }
  223 + }
  224 +
  225 + return bccount;
  226 +};
  227 +
  228 +/**
  229 + * 返回班次列表,过滤空的班次,将所有存在的班次连成连续的对象数组返回。
  230 + * @returns arrays (InternalBcObj)
  231 + */
  232 +InternalLpObj.prototype.getBcArray = function() {
  233 + var bcArray = [];
  234 + var i;
  235 + var group;
  236 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  237 + group = this._$_groupBcArray[i];
  238 + if (group) {
  239 + group.getBc1() ? bcArray.push(group.getBc1()) : "";
  240 + group.getBc2() ? bcArray.push(group.getBc2()) : "";
  241 + }
  242 + }
  243 +
  244 + return bcArray;
  245 +};
  246 +
  247 +/**
  248 + * 获取最小(最早)班次对象。
  249 + * @returns [{圈index},{班次index}]
  250 + */
  251 +InternalLpObj.prototype.getMinBcObjPosition = function() {
  252 + var i;
  253 + var bIndex = [];
  254 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  255 + if (this._$_groupBcArray[i].getBc1()) {
  256 + bIndex.push(i);
  257 + bIndex.push(0);
  258 + break;
  259 + }
  260 + if (this._$_groupBcArray[i].getBc2()) {
  261 + bIndex.push(i);
  262 + bIndex.push(1);
  263 + break;
  264 + }
  265 + }
  266 + return bIndex;
  267 +};
  268 +
  269 +/**
  270 + * 获取最大(最晚)班次对象。
  271 + * @returns [{圈index},{班次index}]
  272 + */
  273 +InternalLpObj.prototype.getMaxBcObjPosition = function() {
  274 + var i;
  275 + var bIndex = [];
  276 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  277 + if (this._$_groupBcArray[i].getBc2()) {
  278 + bIndex.push(i);
  279 + bIndex.push(1);
  280 + break;
  281 + }
  282 + if (this._$_groupBcArray[i].getBc1()) {
  283 + bIndex.push(i);
  284 + bIndex.push(0);
  285 + break;
  286 + }
  287 + }
  288 + return bIndex;
  289 +};
  290 +
  291 +InternalLpObj.prototype.getMinBcObj = function() {
  292 + var i;
  293 + var bcObj;
  294 + for (i = 0; i < this._$_groupBcArray.length; i++) {
  295 + bcObj = this._$_groupBcArray[i].getBc1();
  296 + if (bcObj) {
  297 + break;
  298 + }
  299 + bcObj = this._$_groupBcArray[i].getBc2();
  300 + if (bcObj) {
  301 + break;
  302 + }
  303 + }
  304 + return bcObj;
  305 +};
  306 +InternalLpObj.prototype.getMaxBcObj = function() {
  307 + var i;
  308 + var bcObj;
  309 + for (i = this._$_groupBcArray.length - 1; i >= 0; i--) {
  310 + bcObj = this._$_groupBcArray[i].getBc2();
  311 + if (bcObj) {
  312 + break;
  313 + }
  314 + bcObj = this._$_groupBcArray[i].getBc1();
  315 + if (bcObj) {
  316 + break;
  317 + }
  318 + }
  319 + return bcObj;
  320 +};
  321 +
  322 +/**
  323 + * 获取车次链信息。
  324 + * @param num 第几个车次链
  325 + * @returns object {s_q: {开始圈索引},s_b : {开始班次索引},e_q : {结束圈索引},e_b : {结束班次索引}, bcount : {班次数}}
  326 + */
  327 +InternalLpObj.prototype.fnGetBcChainInfo = function(num) {
  328 + // 计算总的车次链信息
  329 + var aChainInfo = [];
  330 + var oChainInfo;
  331 + var aBcIndex = this.getMinBcObjPosition();
  332 + var oBc;
  333 + var iQIndex;
  334 + var iBcIndex;
  335 + var i;
  336 + var bFlag;
  337 +
  338 + var iBcount = 0;
  339 +
  340 + if (aBcIndex.length == 2) {
  341 + iBcount = 1;
  342 + oChainInfo = {s_q : aBcIndex[0], s_b : aBcIndex[1], e_q : aBcIndex[0], e_b : aBcIndex[1], bcount: 1};
  343 + aChainInfo.push(oChainInfo);
  344 + bFlag = true;
  345 +
  346 + // 下一个班次的索引
  347 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  348 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  349 +
  350 + for (i = iQIndex; i < this._$_qCount; i++) {
  351 + while (iBcIndex <= 1) {
  352 + oBc = this.getBc(i, iBcIndex);
  353 + if (!oBc) {
  354 + if (bFlag) {
  355 + // 车次链结尾是这个班次的前一个班次
  356 + oChainInfo.e_q = iBcIndex == 0 ? i - 1 : i;
  357 + oChainInfo.e_b = iBcIndex == 0 ? 1 : 0;
  358 + oChainInfo.bcount = iBcount;
  359 + }
  360 +
  361 + bFlag = false;
  362 + } else {
  363 + if (bFlag) {
  364 + iBcount ++;
  365 + oChainInfo.bcount = iBcount;
  366 + } else {
  367 + // 下一个车次链开始
  368 + iBcount = 1;
  369 + oChainInfo = {s_q : i, s_b : iBcIndex, e_q : i, e_b : iBcIndex, bcount: 1};
  370 + aChainInfo.push(oChainInfo);
  371 + bFlag = true;
  372 + }
  373 + }
  374 +
  375 +
  376 + iBcIndex ++;
  377 + }
  378 + iBcIndex = 0;
  379 + }
  380 +
  381 + }
  382 +
  383 + return aChainInfo[num];
  384 +};
  385 +
  386 +/**
  387 + * 获取车次链的个数。
  388 + * @returns int
  389 + */
  390 +InternalLpObj.prototype.fnGetBcChainCount = function() {
  391 + var iChainCount = 0;
  392 + var aBcIndex = this.getMinBcObjPosition();
  393 +
  394 + var oBc;
  395 + var iQIndex;
  396 + var iBcIndex;
  397 + var i;
  398 + var bFlag;
  399 +
  400 + if (aBcIndex.length == 2) {
  401 + iChainCount = 1;
  402 + bFlag = true;
  403 +
  404 + // 下一个班次的索引
  405 + iQIndex = aBcIndex[1] == 0 ? aBcIndex[0] : aBcIndex[0] + 1;
  406 + iBcIndex = aBcIndex[1] == 0 ? 1 : 0;
  407 +
  408 + for (i = iQIndex; i < this._$_qCount; i++) {
  409 + while (iBcIndex <= 1) {
  410 + oBc = this.getBc(i, iBcIndex);
  411 + if (!oBc) {
  412 + bFlag = false;
  413 + } else {
  414 + if (bFlag) {
  415 +
  416 + } else {
  417 + iChainCount ++;
  418 + bFlag = true;
  419 + }
  420 + }
  421 +
  422 +
  423 + iBcIndex ++;
  424 + }
  425 + iBcIndex = 0;
  426 + }
  427 +
  428 + }
  429 +
  430 +
  431 + return iChainCount;
  432 +};
  433 +
  434 +/**
  435 + * 在具体位置移除班次。
  436 + * @param qIndex 第几圈
  437 + * @param bcIndex 第几个班次
  438 + */
  439 +InternalLpObj.prototype.removeBc = function(qIndex, bcIndex) {
  440 + var group = this._$_groupBcArray[qIndex];
  441 + if (bcIndex == 0) {
  442 + group.removeBc1();
  443 + } else if (bcIndex == 1) {
  444 + group.removeBc2();
  445 + }
  446 +};
  447 +
  448 +/**
  449 + * 使用指定时间匹配返回离之最近的第几圈第几个班次,
  450 + * 使用时间差的绝度值,比较,取最小的
  451 + * 如果有两个一样的时间差,取比fctime大的时间
  452 + * @param fctime moment 比较用时间
  453 + * @param groupArray 圈数组
  454 + * @param hasUp boolean 计算上行班次
  455 + * @param hasDown boolean 计算下行班次
  456 + * @returns [{第几圈},{第几个班次}]
  457 + */
  458 +InternalLpObj.prototype.getgetQBcIndexWithFcTimeFromGroupArray = function(
  459 + fctime, groupArray, hasUp, hasDown
  460 +) {
  461 + var i;
  462 + var timediff; // 时间差取绝对值
  463 + var qIndex;
  464 + var bcIndex;
  465 +
  466 + var group;
  467 + var bc1time;
  468 + var bc2time;
  469 +
  470 + var tempdiff;
  471 + for (i = 0; i < this._$_qCount; i++) {
  472 + group = groupArray[i];
  473 + if (group) {
  474 + if (group.getBc1() && hasUp) {
  475 + bc1time = group.getBc1().getFcTimeObj();
  476 + tempdiff = Math.abs(bc1time.diff(fctime));
  477 +
  478 + if (!timediff) {
  479 + timediff = Math.abs(tempdiff);
  480 + qIndex = i;
  481 + bcIndex = 0;
  482 + } else {
  483 + if (tempdiff < timediff) {
  484 + timediff = tempdiff;
  485 + qIndex = i;
  486 + bcIndex = 0;
  487 + } if (Math.abs(tempdiff) == timediff) {
  488 + if (bc1time.isBefore(fctime)) {
  489 + timediff = tempdiff;
  490 + qIndex = i;
  491 + bcIndex = 0;
  492 + }
  493 +
  494 + }
  495 + }
  496 + }
  497 +
  498 + if (group.getBc2() && hasDown) {
  499 + bc2time = group.getBc2().getFcTimeObj();
  500 + tempdiff = Math.abs(bc2time.diff(fctime));
  501 +
  502 + if (!timediff) {
  503 + timediff = Math.abs(tempdiff);
  504 + qIndex = i;
  505 + bcIndex = 1;
  506 + } else {
  507 + if (tempdiff < timediff) {
  508 + timediff = tempdiff;
  509 + qIndex = i;
  510 + bcIndex = 1;
  511 + } if (Math.abs(tempdiff) == timediff) {
  512 + if (bc2time.isBefore(fctime)) {
  513 + timediff = tempdiff;
  514 + qIndex = i;
  515 + bcIndex = 1;
  516 + }
  517 +
  518 + }
  519 + }
  520 + }
  521 + }
  522 + }
  523 +
  524 + var rst = [];
  525 + rst.push(qIndex);
  526 + rst.push(bcIndex);
  527 +
  528 + return rst;
  529 +};
  530 +
  531 +/**
  532 + * 使用指定时间匹配返回离之最近的第几圈第几个班次,
  533 + * 使用时间差的绝度值,比较,取最小的
  534 + * 如果有两个一样的时间差,取比fctime大的时间
  535 + * @param fctime moment 比较用时间
  536 + * @param hasUp boolean 计算上行班次
  537 + * @param hasDown boolean 计算下行班次
  538 + * @returns [{第几圈},{第几个班次}]
  539 + */
  540 +InternalLpObj.prototype.getQBcIndexWithFcTime = function(
  541 + fctime, hasUp, hasDown
  542 +) {
  543 + return this.getgetQBcIndexWithFcTimeFromGroupArray(fctime, this._$_groupBcArray, hasUp, hasDown);
  544 +};
  545 +
  546 +//---------------------- 内部数据初始化方法(不同于构造函数)---------------------//
  547 +
  548 +/**
  549 + * 从指定开始时间到结束时间创建不间断班次(连班),并初始化路牌
  550 + * 注意,之前有班次会删除后再创建。
  551 + * @param startTime 开始时间
  552 + * @param endTime 结束时间
  553 + * @param isUp 第一个班次是上行还是下行
  554 + * @param fromQ 从第几圈开始加入
  555 + * @param paramObj 参数对象
  556 + * @param factory 工厂对象
  557 + */
  558 +InternalLpObj.prototype.initDataFromTimeToTime = function(
  559 + startTime,
  560 + endTime,
  561 + isUp,
  562 + fromQ,
  563 + paramObj,
  564 + factory) {
  565 +
  566 + var bcData = []; // 班次数组
  567 + var bcObj;
  568 + var kssj = startTime;
  569 + var fcno = 1; // 发车顺序号
  570 + var bcCount = 1; // 班次数
  571 + do {
  572 + bcObj = factory.createBcObj(
  573 + this, "normal", isUp, fcno, kssj, paramObj); // this就是所属路牌对象
  574 + bcData.push(bcObj);
  575 +
  576 + kssj = paramObj.addMinute(kssj, bcObj.getBcTime() + bcObj.getStopTime());
  577 + fcno ++;
  578 + bcCount ++;
  579 + isUp = !isUp;
  580 + } while(kssj.isBefore(endTime));
  581 + bcCount--;
  582 +
  583 + //console.log("last -1;" + bcData[bcCount -2].getFcTimeObj().format("HH:mm"));
  584 + //console.log("last;" + bcData[bcCount -1].getFcTimeObj().format("HH:mm"));
  585 + //console.log("endtime: " + endTime.format("HH:mm"));
  586 +
  587 + //if (bcCount > 0 && bcData[bcCount - 1].getArrTimeObj().isAfter(endTime)) {
  588 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  589 + // bcData.splice(bcCount - 1, 1);
  590 + //}
  591 +
  592 + this._initDataFromLbBcArray(bcData, fromQ);
  593 +
  594 +};
  595 +
  596 +/**
  597 + * 使用连班的班次数组初始化路牌(相应的圈会被覆盖)。
  598 + * @param bcArray 连班班次数组
  599 + * @param fromQ 从第几圈开始加入
  600 + */
  601 +InternalLpObj.prototype._initDataFromLbBcArray = function(
  602 + bcArray,
  603 + fromQ
  604 +) {
  605 + var _bc1Obj;
  606 + var _bc2Obj;
  607 + var _qObj;
  608 +
  609 + // 第一班次是上行还是下行
  610 + var isUp = bcArray[0].isUp();
  611 +
  612 + if (bcArray.length > 0 && fromQ < this._$_qCount) {
  613 + // 构造圈数
  614 + if (isUp != this._$_isUp) {
  615 + // 如果方向不一致,意味着第一个班次是半圈
  616 + // 加半圈,并加在bc2上
  617 + _bc2Obj = bcArray.slice(0, 1)[0];
  618 + _qObj = new InternalGroupObj(
  619 + this,
  620 + this._$_isUp,
  621 + undefined,
  622 + _bc2Obj
  623 + );
  624 + _bc2Obj.setGroup(_qObj);
  625 + this._$_groupBcArray[fromQ] = _qObj;
  626 +
  627 + bcArray.splice(0, 1);
  628 + fromQ ++;
  629 + }
  630 +
  631 + var qCount1 = Math.floor(bcArray.length / 2); // 需要添加多少圈
  632 + var qCount2 = bcArray.length % 2; // 最后是否有半圈
  633 +
  634 + while (fromQ < this._$_qCount) {
  635 + if (qCount1 > 0) {
  636 + _bc1Obj = bcArray.slice(0, 1)[0];
  637 + _bc2Obj = bcArray.slice(1, 2)[0];
  638 + _qObj = new InternalGroupObj(
  639 + this,
  640 + this._$_isUp,
  641 + _bc1Obj,
  642 + _bc2Obj
  643 + );
  644 + _bc1Obj.setGroup(_qObj);
  645 + _bc2Obj.setGroup(_qObj);
  646 + this._$_groupBcArray[fromQ] = _qObj;
  647 +
  648 + bcArray.splice(0, 2);
  649 + qCount1 --;
  650 + } else if (qCount2 > 0) {
  651 + // 加半圈,并加在bc1上
  652 + _bc1Obj = bcArray.slice(0, 1)[0];
  653 + _qObj = new InternalGroupObj(
  654 + this,
  655 + this._$_isUp,
  656 + _bc1Obj,
  657 + undefined
  658 + );
  659 + _bc1Obj.setGroup(_qObj);
  660 + this._$_groupBcArray[fromQ] = _qObj;
  661 +
  662 + bcArray.splice(0, 1);
  663 + qCount2 --;
  664 + } else {
  665 + break;
  666 + }
  667 +
  668 + fromQ ++;
  669 + }
  670 + }
  671 +};
  672 +
  673 +//-------------------------- 其他方法 ----------------------------//
  674 +
  675 +/**
  676 + * 从指定位置的班次开始,往后所有的班次修正发车时间
  677 + * @param groupIndex
  678 + * @param bcIndex
  679 + * @param time
  680 + */
  681 +InternalLpObj.prototype.fnAddMinuteToBcFcsj = function(groupIndex, bcIndex, time) {
  682 + var i;
  683 + var oCurBc;
  684 +
  685 + // 修正之前班次的停站时间
  686 + //oCurBc = this.getBc(
  687 + // bcIndex == 0 ? groupIndex - 1 : groupIndex,
  688 + // bcIndex == 1 ? 0 : 1
  689 + //);
  690 + //if (oCurBc) {
  691 + // oCurBc.setStopTime(oCurBc.getStopTime() + time);
  692 + //}
  693 +
  694 +
  695 + for (i = groupIndex; i < this._$_qCount; i++) {
  696 + if (bcIndex == 0) {
  697 + oCurBc = this.getBc(i, 0);
  698 + if (oCurBc) {
  699 + oCurBc.addMinuteToFcsj(time);
  700 + }
  701 + oCurBc = this.getBc(i, 1);
  702 + if (oCurBc) {
  703 + oCurBc.addMinuteToFcsj(time);
  704 + }
  705 +
  706 + } else {
  707 + oCurBc = this.getBc(i, 1);
  708 + if (oCurBc) {
  709 + oCurBc.addMinuteToFcsj(time);
  710 + }
  711 +
  712 + }
  713 +
  714 + bcIndex = 0;
  715 + }
  716 +};
  717 +
  718 +/**
  719 + * 在指定位置添加一个吃饭班次。
  720 + * 注1:吃饭班次不是普通班次,不记录进圈,记录进_$_other_bc_array
  721 + * 注2:添加吃饭班次时,会修改之前班次的停战时间,所以导致之后的班次的停战都会发生变化
  722 + * @param groupIndex
  723 + * @param bcIndex
  724 + * @param factory
  725 + * @param paramObj
  726 + * @returns int 相差时间(吃饭时间距离和停站时间相差值)
  727 + */
  728 +InternalLpObj.prototype.fnAddEatBc = function(groupIndex, bcIndex, factory, paramObj) {
  729 + var oPreBc;
  730 + var oEatBc;
  731 + var iBcModifyTime;
  732 + oPreBc = this.getBc( // 前一个邻接班次
  733 + bcIndex == 0 ? groupIndex - 1 : groupIndex,
  734 + bcIndex == 1 ? 0 : 1);
  735 + if (oPreBc) { // 存在前一个班次
  736 + oEatBc = factory.createBcObj(
  737 + this,
  738 + "cf",
  739 + !oPreBc.isUp(), // 和上一个班次方向相反
  740 + 1,
  741 + paramObj.addMinute(oPreBc.getArrTimeObj(), oPreBc.getStopTime()), // 使用上一个班次的到达时间作为开始时间
  742 + paramObj
  743 + );
  744 +
  745 + //iBcModifyTime = oEatBc.getBcTime() - oPreBc.getStopTime(); // 后续班次要调整的时间
  746 +
  747 + // 修正之后的班次发车时间
  748 + // 注意:之后那个班次发车时间就是吃饭班次的到达时间
  749 + iBcModifyTime = oEatBc.getArrTimeObj().diff(this.getBc(groupIndex, bcIndex).getFcTimeObj(), "m");
  750 + this.fnAddMinuteToBcFcsj(groupIndex, bcIndex, iBcModifyTime);
  751 +
  752 + oPreBc.setStopTime(0); // 不重置停站时间
  753 + oPreBc.fnSetEatTime(oEatBc.getBcTime());
  754 +
  755 + //this._$_other_bc_array.push(oEatBc);
  756 +
  757 + return iBcModifyTime;
  758 + } else {
  759 + return false;
  760 + }
  761 +
  762 +};
  763 +
  764 +/**
  765 + * 调整路牌的班次,通过调整停站时间,或者班次发车时间,不能让班次的到达时间和下一个班次的发车时间重叠。
  766 + * @param iPeakAverStopTime 高峰平均停站时间
  767 + * @param iTroughAverStopTime 低谷平均停站时间
  768 + * @param oParam 参数对象
  769 + */
  770 +InternalLpObj.prototype.fnAdjustBcInterval = function(iPeakAverStopTime, iTroughAverStopTime, oParam) {
  771 + // 获取车次链个数
  772 + var iBcChainCount = this.fnGetBcChainCount();
  773 +
  774 + var i;
  775 + var j;
  776 + var oBcIndex;
  777 + var iQIndex;
  778 + var iBcIndex;
  779 + var iBcCount;
  780 + var oBc;
  781 + var oNextBc;
  782 +
  783 + var iBcStopTime;
  784 +
  785 + for (i = 0; i < iBcChainCount; i++) {
  786 + oBcIndex = this.fnGetBcChainInfo(i);
  787 + iQIndex = oBcIndex["s_q"];
  788 + iBcIndex = oBcIndex["s_b"];
  789 + iBcCount = oBcIndex["bcount"];
  790 +
  791 + for (j = 0; j < iBcCount - 1; j++) {
  792 + oBc = this.getBc(iQIndex, iBcIndex);
  793 + oNextBc = this.getBc(
  794 + iBcIndex == 0 ? iQIndex : iQIndex + 1,
  795 + iBcIndex == 0 ? 1 : 0);
  796 +
  797 + // 不改变当前班次的行驶时间,修正停站时间和下一个班次的发车时间
  798 + iBcStopTime = oNextBc.getFcTimeObj().diff(oBc.getArrTimeObj(), "m");
  799 + if (iBcStopTime < 0) {
  800 + // 当前班次使用最小停站时间
  801 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  802 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  803 +
  804 + } else {
  805 + if (iBcStopTime == oBc.getStopTime() + oBc.fnGetEatTime()) {
  806 + // 停站时间一致,没有问题
  807 +
  808 +
  809 + } else {
  810 + // TODO:当前班次使用最小停站时间
  811 + oBc.setStopTime(oParam.fnCalcuFixedMinStopNumber(oBc.getArrTimeObj(), oBc.isUp()));
  812 + oNextBc.addMinuteToFcsj(oBc.getStopTime() + oBc.fnGetEatTime() - iBcStopTime);
  813 +
  814 + }
  815 + }
  816 +
  817 + iBcIndex = iBcIndex == 0 ? 1 : 0;
  818 + iQIndex = iBcIndex == 0 ? iQIndex + 1 : iQIndex;
  819 + }
  820 +
  821 + this.getBc(iQIndex, iBcIndex).setStopTime(0);
  822 + }
  823 +
  824 +
  825 +};
  826 +
  827 +
  828 +// TODO
  829 +
  830 +/**
  831 + *
  832 + *
  833 + */
  834 +InternalLpObj.prototype.calcuLpBx = function() {
  835 +
  836 +};
  837 +
  838 +
  839 +
  840 +
  841 +
  842 +
  843 +
src/main/resources/static/pages/base/timesmodel/js/v2/core/InternalScheduleObj.js
1 -/**  
2 - * 内部行车计划对象。  
3 - * @constructor  
4 - */  
5 -var InternalScheduleObj = function(paramObj, lpArray, factory) {  
6 - // 参数对象  
7 - var _paramObj = paramObj;  
8 - // 外部的路牌数组  
9 - var _lpArray = lpArray;  
10 - // 工厂对象  
11 - var _factory = factory;  
12 -  
13 - //------------------ 初始化方法1,以及计算关联的内部变量 -----------------//  
14 - var _qIsUp; // 每一圈是上行开始还是下行开始  
15 - var _qCount = 0; // 总的圈数  
16 - var _internalLpArray = []; // 内部对象数组  
17 - var _aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)  
18 - {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},  
19 - {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},  
20 - {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},  
21 - {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},  
22 - {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},  
23 - {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},  
24 - {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},  
25 - {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}  
26 - ];  
27 -  
28 - var _fnInitFun1 = function() { // 初始化方法1  
29 - console.log("//---------------- 行车计划,初始化方法1 start ----------------//");  
30 -  
31 - //----------------------- 1、确定上标线的方向,圈的方向 -------------------//  
32 -  
33 - // 确定_qIsUp,哪个方向的首班车晚就用哪个  
34 - _qIsUp = _paramObj.getUpFirstDTimeObj().isBefore(  
35 - _paramObj.getDownFirstDTimeObj()) ? false : true;  
36 - // 上标线开始时间,就是方向的首班车时间  
37 - var st = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();  
38 - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向  
39 - var et;  
40 - var et_IsUp;  
41 - if (_paramObj.getUpLastDtimeObj().isBefore(  
42 - _paramObj.getDownLastDTimeObj())) {  
43 - et = _paramObj.getDownLastDTimeObj();  
44 - et_IsUp = false;  
45 - } else {  
46 - et = _paramObj.getUpLastDtimeObj();  
47 - et_IsUp = true;  
48 - }  
49 -  
50 - //------------------------ 2、计算总共有多少圈 ------------------------//  
51 -  
52 - // 以开始时间,结束时间,构造上标线用连班班次发车时间  
53 - var bcFcsjArrays = []; // 班次发车时间对象数组  
54 - var bcArsjArrays = []; // 班次到达时间对象数组  
55 - var isUp = _qIsUp; // 方向  
56 - var bcCount = 1; // 班次数  
57 -  
58 - var _kssj = st; // 开始时间  
59 - var _bcsj = paramObj.calcuTravelTime(_kssj, isUp); // 班次历时  
60 - var _arrsj = paramObj.addMinute(_kssj, _bcsj); // 到达时间  
61 - var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); // 停站时间  
62 -  
63 - do {  
64 - bcFcsjArrays.push(_kssj);  
65 - bcArsjArrays.push(_arrsj);  
66 -  
67 - _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime);  
68 - _bcsj = paramObj.calcuTravelTime(_kssj, isUp);  
69 - _arrsj = paramObj.addMinute(_kssj, _bcsj);  
70 - _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);  
71 -  
72 - bcCount ++;  
73 - isUp = !isUp;  
74 - } while(_kssj.isBefore(et));  
75 - bcCount--; // 因为先做do,所以总的班次要减1  
76 - if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) {  
77 - // 如果最后一个班次的到达时间超过结束时间,也要去除  
78 - bcFcsjArrays.splice(bcCount - 1, 1);  
79 - bcArsjArrays.splice(bcCount - 1, 1);  
80 - bcCount--;  
81 - }  
82 - var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈  
83 - var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈  
84 -  
85 - // 利用连班数组计算圈数  
86 - _qCount = 1; // 前面加1圈,补中标线的班次  
87 - _qCount += _qCount_p1;  
88 - _qCount += _qCount_p2;  
89 -  
90 - // 计算最后是不是还要补一圈  
91 - if (_qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题)  
92 - if (_qCount_p2 == 0) { // 没有余下班次,整数圈数  
93 - // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行  
94 - // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致  
95 - if (!_qIsUp == et_IsUp) {  
96 - // 一致不用加圈数  
97 - } else {  
98 - // 不一致需要加圈补最后一个结束时间班次  
99 - _qCount ++;  
100 - }  
101 - } else {  
102 - // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里  
103 - // 不需要在补圈数了  
104 - }  
105 - }  
106 -  
107 - //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------//  
108 -  
109 - // 创建内部的路牌数组,并把之前的连班路牌添加进上标线路牌中  
110 - var i;  
111 - for (i = 0; i < _lpArray.length; i++) {  
112 - _internalLpArray.push(new InternalLpObj(_lpArray[i], _qCount, _qIsUp));  
113 - }  
114 - // 初始化上标线,从第1圈开始  
115 - _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory);  
116 -  
117 - // 以上标线为基础,计算各种班型工时对应的圈数、班次数  
118 - var aBcArray = _internalLpArray[0].getBcArray();  
119 - if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算  
120 - aBcArray.splice(aBcArray.length - 1, 1);  
121 - }  
122 - var sum = 0;  
123 - // 加吃饭时间  
124 - sum += _paramObj.fnGetLunchTime();  
125 - sum += _paramObj.fnGetDinnerTime();  
126 - // 加进出场时间  
127 - sum += _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();  
128 - sum += _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime();  
129 - // 例保时间  
130 - //sum += _paramObj.getLbTime() * 2;  
131 - for (i = 0; i < aBcArray.length; i++) {  
132 - sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();  
133 - }  
134 - for (i = 0; i < _aBxDesc.length; i++) {  
135 - _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2);  
136 - _aBxDesc[i].fBcCount = ((_aBxDesc[i].fHoursV * 60) / _aBxDesc[i].fAverTime) * 2;  
137 - }  
138 -  
139 - // 在第一个班次之前再添加一个模拟班次,用于中标线的作用  
140 - // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除  
141 - var iFirstStopTime =  
142 - _paramObj.fnCalcuFixedStopNumber(  
143 - _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -10),  
144 - _qIsUp  
145 - );  
146 - var iXXTime = _qIsUp ? _paramObj.getDownTroughTime() : _paramObj.getUpTroughTime();  
147 - var oFlagBc = _factory.createBcObj( // 标记班次  
148 - _internalLpArray[0],  
149 - "normal",  
150 - !_qIsUp,  
151 - 1,  
152 - _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -(iFirstStopTime + iXXTime)),  
153 - _paramObj  
154 - );  
155 - oFlagBc.fnSetDelFlag(true); // 标记了删除记号  
156 -  
157 - _internalLpArray[0].setBc(0, 1, oFlagBc);  
158 -  
159 - // 在最后一圈也补上一个或者2个模拟班次,暂时标记,最后需要删除  
160 - var aMaxBcIndex = _internalLpArray[0].getMaxBcObjPosition();  
161 - if (aMaxBcIndex[0] == _qCount - 1) { // 可能加半圈  
162 - oFlagBc = _factory.createBcObj( // 标记班次  
163 - _internalLpArray[0],  
164 - "normal",  
165 - !_qIsUp,  
166 - 1,  
167 - _paramObj.addMinute(  
168 - _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),  
169 - _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),  
170 - _paramObj  
171 - );  
172 - oFlagBc.fnSetDelFlag(true); // 标记了删除记号  
173 - _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);  
174 -  
175 - } else { // 加完整的一圈  
176 - oFlagBc = _factory.createBcObj( // 标记班次  
177 - _internalLpArray[0],  
178 - "normal",  
179 - _qIsUp,  
180 - 1,  
181 - _paramObj.addMinute(  
182 - _internalLpArray[0].getBc(_qCount - 2, 1).getArrTimeObj(),  
183 - _internalLpArray[0].getBc(_qCount - 2, 1).getStopTime()),  
184 - _paramObj  
185 - );  
186 - oFlagBc.fnSetDelFlag(true); // 标记了删除记号  
187 - _internalLpArray[0].setBc(_qCount - 1, 0, oFlagBc);  
188 -  
189 - oFlagBc = _factory.createBcObj( // 标记班次  
190 - _internalLpArray[0],  
191 - "normal",  
192 - !_qIsUp,  
193 - 1,  
194 - _paramObj.addMinute(  
195 - _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),  
196 - _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),  
197 - _paramObj  
198 - );  
199 - oFlagBc.fnSetDelFlag(true); // 标记了删除记号  
200 - _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);  
201 -  
202 - }  
203 -  
204 - console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") +  
205 - "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm"));  
206 - console.log("下行首班车时间:" + _paramObj.getDownFirstDTimeObj().format("HH:mm") +  
207 - "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm"));  
208 - console.log("总共计算的圈数:" + _qCount);  
209 - console.log("圈的方向isUP:" + _qIsUp);  
210 - console.log("班型描述(以下):");  
211 - console.log(_aBxDesc);  
212 - console.log("所有路牌间隔描述(以下):");  
213 - for (i = 0; i < _internalLpArray.length; i++) {  
214 - console.log(_internalLpArray[i]._$_aVerticalIntervalTime);  
215 - }  
216 - console.log("//---------------- 行车计划,初始化方法1 end ----------------//");  
217 -  
218 - };  
219 -  
220 - //------------------ 初始化方法2,以及计算关联的内部变量 ----------------//  
221 - var _approximate_zgfQIndex; // 预估早高峰车辆从第几圈开始全部发出  
222 - var _approximate_zgfBIndex; // 预估早高峰车辆从第几圈第几个班次开始全部发出(上行或下行)  
223 - var _approximate_wgfQIndex; // 预估晚高峰车辆从第几圈开始全部发出  
224 - var _approximate_wgfBIndex; // 预估晚高峰车辆从第几圈第几个班次开始全部发出(上行或下行)  
225 -  
226 - var _fnInitFun2 = function() { // 初始化方法2  
227 - console.log("//---------------- 行车计划,初始化方法2 start ----------------//");  
228 -  
229 - //------------------------ 1、计算车辆总数 ------------------------//  
230 - // 是用高峰上行周转时间除以高峰平均间隔得到的  
231 - // 这样算还算合理,车辆不多不少,待以后有新的算法再修正  
232 - var iClCount = _paramObj.calcuClzx();  
233 -  
234 - //------------------------ 2、计算所有路牌的发车在各个圈中的间隔 --------------------//  
235 - var i;  
236 - var j;  
237 - var iBindex = 1;  
238 - var iZzsj;  
239 - var oLp;  
240 - var iC1;  
241 - var iC2;  
242 -  
243 - for (i = 0; i < _qCount - 1; i++) {  
244 - while (iBindex <= 1) {  
245 - // 每圈每个方向的周转时间不一致,以上标线为主  
246 - oLp = _internalLpArray[0];  
247 - iZzsj = oLp.getBc(i + 1, iBindex).getFcTimeObj().diff(  
248 - oLp.getBc(i, iBindex).getFcTimeObj(), "m"  
249 - );  
250 -  
251 - iC1 = Math.floor(iZzsj / iClCount);  
252 - iC2 = iZzsj % iClCount;  
253 -  
254 - for (j = 0; j < iClCount - iC2; j++) {  
255 - oLp = _internalLpArray[j];  
256 - oLp.fnSetVerticalIntervalTime(i, iBindex, iC1);  
257 - }  
258 -  
259 - for (j = 0; j < iC2; j++) {  
260 - oLp = _internalLpArray[iClCount - iC2 + j];  
261 - oLp.fnSetVerticalIntervalTime(i, iBindex, iC1 + 1);  
262 - }  
263 -  
264 - iBindex ++;  
265 -  
266 - }  
267 - iBindex = 0;  
268 - }  
269 - // 最后一圈没有下一圈的参照,周转时间没发获取,由于都是低谷,所以使用倒数第二圈的间隔最为最后一圈的间隔  
270 - for (i = 0; i < _internalLpArray.length; i++) {  
271 - oLp = _internalLpArray[i];  
272 - oLp.fnSetVerticalIntervalTime(_qCount - 1, 0, oLp.fnGetVerticalIntervalTime(_qCount - 2, 0));  
273 - oLp.fnSetVerticalIntervalTime(_qCount - 1, 1, oLp.fnGetVerticalIntervalTime(_qCount - 2, 1));  
274 - }  
275 -  
276 - //------------------------ 3、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//  
277 -  
278 - // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次  
279 - // 以这个班次为早高峰起点,全部出车策略  
280 - var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(  
281 - _paramObj.getMPeakStartTimeObj(), true, true);  
282 - var qIndex = qbcIndexArray[0]; // 第几圈  
283 - var bIndex = qbcIndexArray[1]; // 第几个班次  
284 -  
285 - for (i = 1; i < _internalLpArray.length; i++) {  
286 - _fnGenerateBcAndSetBc(i, qIndex, bIndex);  
287 - }  
288 -  
289 - _approximate_zgfQIndex = qIndex;  
290 - _approximate_zgfBIndex = bIndex;  
291 -  
292 - //------------------------ 4、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//  
293 -  
294 - // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次  
295 - // 以这个班次为早高峰起点,全部出车策略  
296 - qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(  
297 - _paramObj.getEPeakStartTimeObj(), true, true);  
298 - qIndex = qbcIndexArray[0]; // 第几圈  
299 - bIndex = qbcIndexArray[1]; // 第几个班次  
300 -  
301 - for (i = 1; i < _internalLpArray.length; i++) {  
302 - _fnGenerateBcAndSetBc(i, qIndex, bIndex);  
303 - }  
304 -  
305 - _approximate_wgfQIndex = qIndex;  
306 - _approximate_wgfBIndex = bIndex;  
307 -  
308 - console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟");  
309 - console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟");  
310 - console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出");  
311 - console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出");  
312 - console.log("//---------------- 行车计划,初始化方法2 end ----------------//");  
313 - };  
314 -  
315 - //----------------------- 初始化方法3,计算连班分班的路牌分布 ----------------//  
316 - var _iBx_lb_lpcount; // 连班路牌数  
317 - var _iBx_5_2_fb_lpcount; // 5休2分班路牌数  
318 - var _iBx_other_fb_lpcount; // 其他分班路牌数  
319 -  
320 - var _fnInitFun3 = function() { // 初始化方法3  
321 - console.log("//---------------- 行车计划,初始化方法3 start ----------------//");  
322 -  
323 - //--------------------- 1、计算分班连班班型车辆分布数 --------------------//  
324 - // 总共车辆数(高峰最大车辆数)  
325 - var iCls = _paramObj.calcuClzx();  
326 - // 低谷最少配车(连班车数量)  
327 - var iDgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx());  
328 - // 加班车路牌数(做5休2的路牌数)  
329 - var i_5_2_lpes = _paramObj.getJBLpes();  
330 -  
331 - // 做些简单的验证  
332 - if (iCls < iDgminpc) {  
333 - alert("总配车数小于低谷最小配车");  
334 - throw "总配车数小于低谷最小配车";  
335 - }  
336 - if (iDgminpc < 2) {  
337 - alert("连班路牌小于2,办不到啊");  
338 - throw "连班路牌小于2,办不到啊";  
339 - }  
340 - if (iCls - iDgminpc < i_5_2_lpes) {  
341 - alert("总分班路牌数小于加班路牌数");  
342 - throw "总分班路牌数小于加班路牌数";  
343 - }  
344 -  
345 - _iBx_lb_lpcount = iDgminpc;  
346 - _iBx_5_2_fb_lpcount = i_5_2_lpes;  
347 - _iBx_other_fb_lpcount = iCls - iDgminpc - i_5_2_lpes;  
348 -  
349 - //------------------------ 2、利用间隔法计算连班路牌分布 --------------------//  
350 - var i;  
351 - var j;  
352 - var iC1 = Math.floor(_internalLpArray.length / _iBx_lb_lpcount);  
353 - var iC2 = _internalLpArray.length % _iBx_lb_lpcount;  
354 - var iLpIndex;  
355 -  
356 - for (i = 0; i < _iBx_lb_lpcount - iC2; i++) {  
357 - iLpIndex = i * iC1;  
358 - _internalLpArray[iLpIndex].setBxLb(true);  
359 - _internalLpArray[iLpIndex].setBxDesc("连班");  
360 - }  
361 - for (j = 0; j < iC2; j++) {  
362 - iLpIndex = i * iC1 + j * (iC1 + 1);  
363 - _internalLpArray[iLpIndex].setBxLb(true);  
364 - _internalLpArray[iLpIndex].setBxDesc("连班");  
365 - }  
366 -  
367 - //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------//  
368 - // 获取分班路牌索引  
369 - var aNotLbIndexes = [];  
370 - for (i = 0; i < _internalLpArray.length; i++) {  
371 - if (!_internalLpArray[i].isBxLb()) {  
372 - aNotLbIndexes.push(i);  
373 - }  
374 - }  
375 - // 先5休2分班  
376 - iC1 = Math.floor(aNotLbIndexes.length / _iBx_5_2_fb_lpcount);  
377 - iC2 = aNotLbIndexes.length % _iBx_5_2_fb_lpcount;  
378 -  
379 - for (i = 0; i < _iBx_5_2_fb_lpcount - iC2; i++) {  
380 - iLpIndex = aNotLbIndexes[i * iC1];  
381 - _internalLpArray[iLpIndex].setBxLb(false);  
382 - _internalLpArray[iLpIndex].setBxFb(true);  
383 - _internalLpArray[iLpIndex].setBxFb5_2(true);  
384 - _internalLpArray[iLpIndex].setBxDesc("5休2分班");  
385 - }  
386 - for (i = 0; i < iC2; i++) {  
387 - iLpIndex = aNotLbIndexes[_iBx_lb_lpcount - iC2 + i * (iC1 + 1)];  
388 - _internalLpArray[iLpIndex].setBxLb(false);  
389 - _internalLpArray[iLpIndex].setBxFb(true);  
390 - _internalLpArray[iLpIndex].setBxFb5_2(true);  
391 - _internalLpArray[iLpIndex].setBxDesc("5休2分班");  
392 - }  
393 - // 其他分班  
394 - for (i = 0; i < aNotLbIndexes.length; i++) {  
395 - iLpIndex = aNotLbIndexes[i];  
396 - if (!_internalLpArray[iLpIndex].isBxFb5_2()) {  
397 - _internalLpArray[iLpIndex].setBxLb(false);  
398 - _internalLpArray[iLpIndex].setBxFb(true);  
399 - _internalLpArray[iLpIndex].setBxFb5_2(false);  
400 - _internalLpArray[iLpIndex].setBxDesc("其他分班");  
401 - }  
402 - }  
403 -  
404 -  
405 - console.log("连班路牌数:" + _iBx_lb_lpcount);  
406 - console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount);  
407 - console.log("其他分班路牌数:" + _iBx_other_fb_lpcount);  
408 - var aLbIndexes = [];  
409 - for (i = 0; i < _internalLpArray.length; i++) {  
410 - if (_internalLpArray[i].isBxLb()) {  
411 - aLbIndexes.push(i);  
412 - }  
413 - }  
414 - console.log("连班路牌indexes=" + aLbIndexes);  
415 - var a_5_2_fbIndexes = [];  
416 - for (i = 0; i < _internalLpArray.length; i++) {  
417 - if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) {  
418 - a_5_2_fbIndexes.push(i);  
419 - }  
420 - }  
421 - console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);  
422 - var a_other_fbIndexes = [];  
423 - for (i = 0; i < _internalLpArray.length; i++) {  
424 - if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) {  
425 - a_other_fbIndexes.push(i);  
426 - }  
427 - }  
428 - console.log("其他分班路牌indexes=" + a_other_fbIndexes);  
429 -  
430 - console.log("//---------------- 行车计划,初始化方法3 end ----------------//");  
431 - };  
432 -  
433 - //----------------------- 初始化方法4,计算中标线位置 -------------------------//  
434 - var _iZbx_lpIndex; // 中标线对应第几个路牌  
435 -  
436 - var _fnInitFun4 = function() { // 初始化方法4  
437 - console.log("//---------------- 行车计划,初始化方法3 start ----------------//");  
438 -  
439 - //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------//  
440 - // 构造中标线  
441 - // 中标线开始时间,就是方向的首班车时间  
442 - var oSt = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();  
443 - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向  
444 - // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向  
445 - var oEt;  
446 - if (_paramObj.getUpLastDtimeObj().isBefore(  
447 - _paramObj.getDownLastDTimeObj())) {  
448 - oEt = _paramObj.getDownLastDTimeObj();  
449 - } else {  
450 - oEt = _paramObj.getUpLastDtimeObj();  
451 - }  
452 -  
453 - var oTempLp = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp);  
454 - oTempLp.initDataFromTimeToTime(  
455 - oSt,  
456 - oEt,  
457 - !_qIsUp,  
458 - 0,  
459 - _paramObj,  
460 - _factory  
461 - );  
462 -  
463 - //------------------------ 2、找出中标线的早高峰班次,计算应该插在当前路牌数组的那个位置 ----------------//  
464 - // 找出中标线对应的早高峰的班次对象  
465 - var oZb_gf_bc = oTempLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);  
466 -  
467 - // 把所有连班路牌高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌  
468 - // 中标线和上标线一样在连班路牌上  
469 - var aTempq = [];  
470 - var oTempq;  
471 - var oTempb;  
472 - var i;  
473 - var oLp;  
474 -  
475 - var aLbIndexes = []; // 连班的路牌索引  
476 - for (i = 0; i < _internalLpArray.length; i++) {  
477 - if (_internalLpArray[i].isBxLb()) {  
478 - aLbIndexes.push(i);  
479 - }  
480 - }  
481 -  
482 - for (i = 0; i < aLbIndexes.length; i++) {  
483 - oLp = _internalLpArray[aLbIndexes[i]];  
484 -  
485 - oTempb = oLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);  
486 - if (oTempb.isUp() == _qIsUp) {  
487 - oTempq = new InternalGroupObj(oLp, _qIsUp, oTempb, undefined);  
488 - } else {  
489 - oTempq = new InternalGroupObj(oLp, _qIsUp, undefined, oTempb);  
490 - }  
491 - aTempq.push(oTempq);  
492 -  
493 - }  
494 -  
495 - var aTtindex = oTempLp.getgetQBcIndexWithFcTimeFromGroupArray(  
496 - oZb_gf_bc.getFcTimeObj(),  
497 - aTempq,  
498 - true,  
499 - true  
500 - );  
501 -  
502 - _iZbx_lpIndex = aLbIndexes[aTtindex[0]]; // 中标线放在第几个路牌  
503 - oTempLp.setLp(_lpArray[_iZbx_lpIndex]); // 设置原始路牌对象  
504 - oTempLp._$_aVerticalIntervalTime = _internalLpArray[_iZbx_lpIndex]._$_aVerticalIntervalTime; // 设置纵向最小发车间隔  
505 - oTempLp.setBxLb(_internalLpArray[_iZbx_lpIndex].isBxLb());  
506 - oTempLp.setBxFb(_internalLpArray[_iZbx_lpIndex].isBxFb());  
507 - oTempLp.setBxFb5_2(_internalLpArray[_iZbx_lpIndex].isBxFb5_2());  
508 -  
509 - // 修正除了第一个班次外,其余其他班次  
510 - var iBcindex = 0;  
511 - for (i = 1; i < _qCount; i++) {  
512 - while (iBcindex <= 1) {  
513 - if (oTempLp.getBc(i, iBcindex)) { // 替换存在的班次  
514 - oTempLp.setBc(i, iBcindex, _fnGenerateBc(_iZbx_lpIndex, i, iBcindex));  
515 - }  
516 - iBcindex ++;  
517 - }  
518 - iBcindex = 0;  
519 - }  
520 -  
521 - _internalLpArray[_iZbx_lpIndex] = oTempLp;  
522 -  
523 - console.log("中标线对应第" + (_iZbx_lpIndex + 1) + "个路牌");  
524 -  
525 - console.log("//---------------- 行车计划,初始化方法4 end ----------------//");  
526 - };  
527 -  
528 - //-------------------- 重要的内部方法 -----------------------//  
529 - /**  
530 - * 核心方法,利用路牌间隔纵向生成班次。  
531 - * @param iLpindex 路牌索引  
532 - * @param iQindex 圈索引  
533 - * @param iBcindex 班次索引  
534 - * @returns object InternalBcObj,失败 false  
535 - */  
536 - var _fnGenerateBc = function(iLpindex, iQindex, iBcindex) {  
537 - // 以上标线为起始点,使用路牌在不同圈,班次索引的发车间隔,计算班次  
538 - // 注意,发车间隔是指下一个班次应该距离当前班次间隔,是从下往上的  
539 -  
540 - // 1、参数验证  
541 - if (iLpindex == 0) { // 上标线的班次不需要生成  
542 - return false;  
543 - }  
544 -  
545 - // 2、计算间隔  
546 - var i;  
547 - var oLp;  
548 - var iTime = 0;  
549 - for (i = 0; i < iLpindex; i++) {  
550 - oLp = _internalLpArray[i];  
551 - iTime += oLp.fnGetVerticalIntervalTime(iQindex, iBcindex);  
552 - }  
553 -  
554 - // 3、生成班次  
555 - var _oKsbc = _internalLpArray[0].getBc(iQindex, iBcindex);  
556 - if (!_oKsbc) {  
557 - return false;  
558 - }  
559 - var _oKssj = _paramObj.addMinute(_oKsbc.getFcTimeObj(), iTime);  
560 - var _oBc = _factory.createBcObj(  
561 - _internalLpArray[iLpindex],  
562 - "normal", _oKsbc.isUp(),  
563 - 1, _oKssj, _paramObj);  
564 -  
565 - return _oBc;  
566 -  
567 - };  
568 -  
569 - /**  
570 - * 核心方法,在指定位置生成班次并添加到路牌指定位置中。  
571 - * @param lpIndex 第几个路牌  
572 - * @param qIndex 第几圈  
573 - * @param bcIndex 第几个班次  
574 - */  
575 - var _fnGenerateBcAndSetBc = function(lpIndex, qIndex, bcIndex) {  
576 - var _bcObj = _fnGenerateBc(lpIndex, qIndex, bcIndex);  
577 - if (_bcObj) {  
578 - _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj);  
579 - }  
580 - };  
581 -  
582 -  
583 - /**  
584 - * 在指定位置生成班次(内部重要方法)。  
585 - * @param lpIndex 第几个路牌  
586 - * @param qIndex 第几圈  
587 - * @param bcIndex 第几个班次  
588 - * @returns InternalBcObj  
589 - */  
590 - var _generateBc = function(lpIndex, qIndex, bcIndex) {  
591 - // 在初始化布局后使用,否则没有参照班次加不了  
592 - // 初始化布局后,相当于把时刻表比作一个围棋棋盘,行为路牌数,列为圈数  
593 - // 上标线,中标线,早晚高峰已经布局在棋盘上,其余的空格可以创建班次  
594 -  
595 - // 这个生成班次是以上一班次时间,以发车间隔为基础添加的,纵向加  
596 - // 和生成标线时那种一直往后加班次时不一样,那种是以前一个班次为基础,横向加  
597 -  
598 - // 1、生成的班次以同一圈同一个方向里离它最早的班次的发车时间为基础  
599 - // 2、以每个路牌的纵向最小发车间隔时间为计算发车间隔  
600 - // 3、如果班次发车时间越界不管,有其余方法排除这种情况  
601 -  
602 - // 1、查找同圈同方向里最近的班次,找不到报错(因为有标线存在是不可能找不到的)  
603 - var _i;  
604 - var _bcObj;  
605 - for (_i = lpIndex - 1; _i >= 0; _i--) {  
606 - _bcObj = _internalLpArray[_i].getBc(qIndex, bcIndex);  
607 - if (_bcObj) {  
608 - break;  
609 - }  
610 - }  
611 - if (!_bcObj) {  
612 - return false;  
613 - //alert("无法在指定位置生成班次");  
614 - //throw "无法在路牌index=" + lpIndex + ",圈index=" + qIndex + ",班次index=" + bcIndex + "生成班次";  
615 - }  
616 -  
617 - // 2、计算发车间隔  
618 - var _intervalTime = 0;  
619 - for (_i = _i + 1; _i <= lpIndex; _i++) {  
620 - _intervalTime += _internalLpArray[_i].getVerticalMinIntervalTime();  
621 - }  
622 -  
623 - // 3、计算班次并添加班次  
624 - var _kssj = _paramObj.addMinute(_bcObj.getFcTimeObj(), _intervalTime);  
625 - _bcObj = _factory.createBcObj(  
626 - _internalLpArray[lpIndex],  
627 - "normal", _bcObj.isUp(),  
628 - 1, _kssj, _paramObj);  
629 - _bcObj.setGroup(_internalLpArray[lpIndex].getGroup(qIndex));  
630 -  
631 - return _bcObj;  
632 -  
633 - // TODO:这种添加班次的方法,可能造成相邻班次的停站时间问题  
634 - // TODO:主要是由于中标线的问题,但是误差不会很大,  
635 - // TODO:后面有方法直接调整停站时间(所谓的平滑过度时间)  
636 - };  
637 -  
638 - /**  
639 - * 在指定位置生成班次并添加到路牌指定位置中。  
640 - * @param lpIndex 第几个路牌  
641 - * @param qIndex 第几圈  
642 - * @param bcIndex 第几个班次  
643 - */  
644 - var _generateBcAndSetBc = function(lpIndex, qIndex, bcIndex) {  
645 - var _bcObj = _generateBc(lpIndex, qIndex, bcIndex);  
646 - _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj);  
647 -  
648 - };  
649 -  
650 - /**  
651 - * 查找离指定时间最近的前面的班次索引信息  
652 - * @param timeObj 查找时间  
653 - * @param isUp 是否上行  
654 - * @returns [{路牌index},{圈index},{班次index}]  
655 - */  
656 - var _findUpClosedBcIndexWithTime = function(timeObj, isUp) {  
657 -  
658 - // dododo  
659 -  
660 - var _lpObj;  
661 - var _groupObj;  
662 - var _bcObj;  
663 - var _i;  
664 - var _j;  
665 - var timediff; // 时间差取绝对值  
666 -  
667 - var _lpIndex;  
668 - var _up_qIndex;  
669 - var _up_bIndex;  
670 -  
671 - for (_i = 0; _i < _qCount; _i++) {  
672 - for (_j = 0; _j < _internalLpArray.length; _j++) {  
673 - _lpObj = _internalLpArray[_j];  
674 - _groupObj = _lpObj.getGroup(_i);  
675 - _bcObj = isUp ? _groupObj.getBc1() : _groupObj.getBc2();  
676 - if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的  
677 - _bcObj = _generateBc(_j, _i, isUp == _qIsUp ? 0 : 1);  
678 - }  
679 - if (_bcObj) {  
680 - if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) {  
681 - if (!timediff) {  
682 - timediff = timeObj.diff(_bcObj.getFcTimeObj());  
683 - _lpIndex = _j;  
684 - _up_qIndex = _i;  
685 - _up_bIndex = isUp == _qIsUp ? 0 : 1;  
686 - } else {  
687 - if (timeObj.diff(_bcObj.getFcTimeObj()) < timediff) {  
688 - timediff = timeObj.diff(_bcObj.getFcTimeObj());  
689 - _lpIndex = _j;  
690 - _up_qIndex = _i;  
691 - _up_bIndex = isUp == _qIsUp ? 0 : 1;  
692 - }  
693 - }  
694 - }  
695 - }  
696 - }  
697 - }  
698 -  
699 - if (_lpIndex == undefined) {  
700 - return false;  
701 - }  
702 -  
703 - var bcindex = [];  
704 - bcindex.push(_lpIndex);  
705 - bcindex.push(_up_qIndex);  
706 - bcindex.push(_up_bIndex);  
707 -  
708 - return bcindex;  
709 - };  
710 -  
711 - /**  
712 - * 查找离指定时间最近的后面的班次索引信息  
713 - * @param timeObj 查找时间  
714 - * @param isUp 是否上行  
715 - * @returns [{路牌index},{圈index},{班次index}]  
716 - */  
717 - var _findDownClosedBcIndexWithTime = function(timeObj, isUp) {  
718 - var _lpObj;  
719 - var _groupObj;  
720 - var _bcObj;  
721 - var _i;  
722 - var _j;  
723 - var timediff; // 时间差取绝对值  
724 -  
725 - var _lpIndex;  
726 - var _down_qIndex;  
727 - var _down_bIndex;  
728 -  
729 - var flag;  
730 -  
731 - for (_i = 0; _i < _qCount; _i++) {  
732 - for (_j = 0; _j < _internalLpArray.length; _j++) {  
733 - _lpObj = _internalLpArray[_j];  
734 - _groupObj = _lpObj.getGroup(_i);  
735 - _bcObj = isUp ? _groupObj.getBc1() : _groupObj.getBc2();  
736 - if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的  
737 - _bcObj = _generateBc(_j, _i, isUp == _qIsUp ? 0 : 1);  
738 - }  
739 - if (_bcObj) {  
740 - //console.log("timeobj -> bcobj diff flag " +  
741 - // timeObj.format("HH:mm") + "->" +  
742 - // _bcObj.getFcTimeObj().format("HH:mm") +  
743 - // timeObj.diff(_bcObj.getFcTimeObj()) +  
744 - // (timeObj.diff(_bcObj.getFcTimeObj()) <= 0)  
745 - //);  
746 -  
747 - flag = (timeObj.diff(_bcObj.getFcTimeObj())) <= 0;  
748 -  
749 - if (flag) {  
750 - if (!timediff) {  
751 - timediff = timeObj.diff(_bcObj.getFcTimeObj());  
752 - _lpIndex = _j;  
753 - _down_qIndex = _i;  
754 - _down_bIndex = isUp == _qIsUp ? 0 : 1;  
755 - } else {  
756 - if ((timeObj.diff(_bcObj.getFcTimeObj())) > timediff) {  
757 - timediff = timeObj.diff(_bcObj.getFcTimeObj());  
758 - _lpIndex = _j;  
759 - _down_qIndex = _i;  
760 - _down_bIndex = isUp == _qIsUp ? 0 : 1;  
761 - }  
762 - }  
763 - }  
764 - }  
765 - }  
766 - }  
767 -  
768 - if (_lpIndex == undefined) {  
769 - return false;  
770 - }  
771 -  
772 - var bcindex = [];  
773 - bcindex.push(_lpIndex);  
774 - bcindex.push(_down_qIndex);  
775 - bcindex.push(_down_bIndex);  
776 -  
777 - return bcindex;  
778 - };  
779 -  
780 - return {  
781 - //------------- 布局初始化方法 ------------//  
782 - /**  
783 - * 初始化数据,使用标线初始化  
784 - */  
785 - fnInitDataWithBxLayout: function() {  
786 - // 初始化布局1,构造上标线,计算圈数,把上标线数据放入第一个路牌中  
787 - _fnInitFun1();  
788 - // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次,计算路牌在各个圈中的间隔  
789 - _fnInitFun2();  
790 - // 初始化布局3,计算连班分班路牌分布  
791 - _fnInitFun3();  
792 - // 初始化布局4,计算中标线位置  
793 - _fnInitFun4();  
794 -  
795 - },  
796 -  
797 - /**  
798 - * 调整高峰班次,  
799 - * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间  
800 - * 当初始化定好布局后(上标线,中标线),然后确定每个路牌的班型(连班,分班,5休2分班)后  
801 - * 然后重新计算框在高峰时间段内的班次索引,不足的添加,之前多加的删除(只删除分班路牌上的)  
802 - * @param isZgf 是否早高峰  
803 - * @param isUp 是否上行  
804 - */  
805 - fnAdjustGfbc : function(isZgf, isUp) {  
806 - var oStartTime; // 开始时间  
807 - var oEndTime; // 结束时间  
808 - var iStartBcIndex; // 开始班次索引  
809 - var iEndBcIndex; // 结束班次索引  
810 -  
811 - oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj();  
812 - oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj();  
813 -  
814 - aStartBcIndex = _findUpClosedBcIndexWithTime(oStartTime, isUp);  
815 - aEndBcIndex = _findDownClosedBcIndexWithTime(oEndTime, isUp);  
816 -  
817 - var iLpIndex;  
818 - var iQIndex;  
819 - var iBcIndex;  
820 - var iQInternelCount; // 高峰时间段中间包含的圈数  
821 - var i;  
822 - var j;  
823 -  
824 - var oLp;  
825 -  
826 - if (aStartBcIndex && aEndBcIndex) {  
827 - iLpIndex = aStartBcIndex[0];  
828 - iQIndex = aStartBcIndex[1];  
829 - iBcIndex = aStartBcIndex[2];  
830 -  
831 - // 处理头  
832 - // 删除头部多余班次  
833 - for (j = 0; j < iLpIndex; j++) {  
834 - oLp = _internalLpArray[j];  
835 - if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {  
836 - oLp.removeBc(iQIndex, iBcIndex);  
837 - }  
838 - }  
839 -  
840 - for (j = iLpIndex; j < _internalLpArray.length; j++) {  
841 - oLp = _internalLpArray[j];  
842 - if (!oLp.getBc(iQIndex, iBcIndex)) {  
843 - _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);  
844 - }  
845 - }  
846 -  
847 - // 处理中间  
848 - iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1;  
849 - for (i = 1; i <= iQInternelCount; i++) {  
850 - oLp = _internalLpArray[iQIndex + i];  
851 - if (!oLp.getBc(iQIndex + i, iBcIndex)) {  
852 - _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex);  
853 - }  
854 - }  
855 -  
856 - // 处理尾部  
857 - iLpIndex = aEndBcIndex[0];  
858 - iQIndex = aEndBcIndex[1];  
859 - iBcIndex = aEndBcIndex[2];  
860 -  
861 - // 删除尾部多余的班次  
862 - for (j = iLpIndex; j < _internalLpArray.length; j++) {  
863 - oLp = _internalLpArray[j];  
864 - if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {  
865 - oLp.removeBc(iQIndex, iBcIndex);  
866 - }  
867 - }  
868 -  
869 - if (aStartBcIndex[1] != aEndBcIndex[1]) { // 指定时间范围跨圈  
870 - for (j = 0; j < iLpIndex; j++) {  
871 - oLp = _internalLpArray[j];  
872 - if (!oLp.getBc(iQIndex, iBcIndex)) {  
873 - _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);  
874 - }  
875 - }  
876 - } else {  
877 - // 不跨圈,不用处理,处理头的时候已经加了  
878 - }  
879 -  
880 - }  
881 -  
882 - },  
883 -  
884 - /**  
885 - * 按照营运时间要求补充班次,  
886 - * 早高峰7:45分以前出场运营,  
887 - * 晚高峰16:10分以前出场运营  
888 - */  
889 - fnCalcuLpBc_yy: function() {  
890 - // 补班次的时候,针对的是分班班型  
891 - var i;  
892 - var _oLp;  
893 - var _oBc;  
894 - var _aMinBcIndex;  
895 - var _aMaxBcIndex;  
896 -  
897 - var _qIndex;  
898 - var _bIndex;  
899 -  
900 - var _zgfCDate = _paramObj.toTimeObj("7:45");  
901 - var _wgfCDate = _paramObj.toTimeObj("16:10");  
902 - var _ccsj;  
903 -  
904 - for (i = 0; i < _internalLpArray.length; i++) {  
905 - _oLp = _internalLpArray[i];  
906 - if (_oLp.isBxFb()) { // 分班路牌  
907 - // 早高峰部分  
908 - _aMinBcIndex = _oLp.getMinBcObjPosition();  
909 - _qIndex = _aMinBcIndex[0];  
910 - _bIndex = _aMinBcIndex[1];  
911 - _oBc = _oLp.getBc(_qIndex, _bIndex);  
912 - if (_qIsUp) {  
913 - _ccsj = _bIndex == 0 ?  
914 - _paramObj.getUpOutTime() :  
915 - _paramObj.getDownOutTime();  
916 - } else {  
917 - _ccsj = _bIndex == 0 ?  
918 - _paramObj.getDownOutTime() :  
919 - _paramObj.getUpOutTime();  
920 - }  
921 - if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {  
922 - _fnGenerateBcAndSetBc(  
923 - i,  
924 - _bIndex == 0 ? _qIndex - 1 : _qIndex,  
925 - _bIndex == 0 ? 1 : 0  
926 - )  
927 - }  
928 -  
929 - // 晚高峰部分  
930 - _aMaxBcIndex = _oLp.getMaxBcObjPosition();  
931 - _qIndex = _aMaxBcIndex[0];  
932 - _bIndex = _aMaxBcIndex[1];  
933 - _oBc = _oLp.getBc(  
934 - _bIndex == 0 ? _qIndex - 1 : _qIndex,  
935 - _bIndex == 0 ? 1 : 0  
936 - );  
937 - if (!_oBc) { // 前一个班次不存在,再判定加不加  
938 - _oBc = _oLp.getBc(_qIndex, _bIndex);  
939 - if (_qIsUp) {  
940 - _ccsj = _bIndex == 0 ?  
941 - _paramObj.getUpOutTime() :  
942 - _paramObj.getDownOutTime();  
943 - } else {  
944 - _ccsj = _bIndex == 0 ?  
945 - _paramObj.getDownOutTime() :  
946 - _paramObj.getUpOutTime();  
947 - }  
948 - if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {  
949 - _fnGenerateBcAndSetBc(  
950 - i,  
951 - _bIndex == 0 ? _qIndex - 1 : _qIndex,  
952 - _bIndex == 0 ? 1 : 0  
953 - )  
954 - }  
955 - }  
956 - }  
957 - }  
958 - },  
959 -  
960 - /**  
961 - * 补充做5休2的班型班次。  
962 - * 1、确认5_2班型大致多少圈(小数点过.7进位)  
963 - * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加  
964 - * 3、如果前面的车次链班次少,则从前面的车次链开始加  
965 - * 4、如果车次链班次数一样,从从后面的车次链开始加  
966 - * 5、加班次时都是往车次链前方加  
967 - * 6、如果前面车次链不能再加班次了,从后面车次链加  
968 - */  
969 - fnCalcuLpBx_5_2: function() {  
970 - // 计算做5休2班型所需的班次数  
971 - var iBxBcount = _aBxDesc[6].fBcCount;  
972 - if (iBxBcount - Math.floor(iBxBcount) > 0.7) {  
973 - iBxBcount = Math.floor(iBxBcount) + 1;  
974 - } else {  
975 - iBxBcount = Math.floor(iBxBcount);  
976 - }  
977 -  
978 - var i;  
979 - var j;  
980 - var oLp;  
981 - var iAddBcCount;  
982 - var oBcChain1;  
983 - var oBcChain2;  
984 - var iQindex;  
985 - var iBindex;  
986 -  
987 - for (i = 0; i < _internalLpArray.length; i++) {  
988 - oLp = _internalLpArray[i];  
989 - if (oLp.isBxFb5_2()) {  
990 - iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数  
991 - for (j = 1; j <= iAddBcCount; j++) {  
992 - oBcChain1 = oLp.fnGetBcChainInfo(0);  
993 - oBcChain2 = oLp.fnGetBcChainInfo(1);  
994 -  
995 - if (oBcChain1.bcount < oBcChain2.bcount) {  
996 - iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q;  
997 - iBindex = oBcChain1.s_b == 0 ? 1 : 0;  
998 - // 往车次链往前不能加,就往后加  
999 - if (_fnGenerateBc(i, iQindex, iBindex)) {  
1000 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1001 - } else {  
1002 - iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;  
1003 - iBindex = oBcChain1.e_b == 0 ? 1 : 0;  
1004 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1005 - }  
1006 -  
1007 - } else if (oBcChain1.bcount > oBcChain2.bcount) {  
1008 - iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;  
1009 - iBindex = oBcChain2.s_b == 0 ? 1 : 0;  
1010 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1011 - } else {  
1012 - iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;  
1013 - iBindex = oBcChain2.s_b == 0 ? 1 : 0;  
1014 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1015 - }  
1016 - }  
1017 - }  
1018 - }  
1019 -  
1020 - },  
1021 -  
1022 - /**  
1023 - * 补其他分班班型班次。  
1024 - * 从车次链的后面开始加  
1025 - */  
1026 - fnCalcuLpBx_other: function() {  
1027 - // TODO:暂时使用做2休1的班型  
1028 - // 计算做5休2班型所需的班次数  
1029 - var iBxBcount = _aBxDesc[4].fBcCount;  
1030 - if (iBxBcount - Math.floor(iBxBcount) > 0.7) {  
1031 - iBxBcount = Math.floor(iBxBcount) + 1;  
1032 - } else {  
1033 - iBxBcount = Math.floor(iBxBcount);  
1034 - }  
1035 -  
1036 - var i;  
1037 - var j;  
1038 - var oLp;  
1039 - var iAddBcCount;  
1040 - var oBcChain1;  
1041 - var oBcChain2;  
1042 - var iQindex;  
1043 - var iBindex;  
1044 -  
1045 - for (i = 0; i < _internalLpArray.length; i++) {  
1046 - oLp = _internalLpArray[i];  
1047 - if (oLp.isBxFb() && !oLp.isBxFb5_2()) {  
1048 - iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数  
1049 - for (j = 1; j <= iAddBcCount; j++) {  
1050 - oBcChain1 = oLp.fnGetBcChainInfo(0);  
1051 - oBcChain2 = oLp.fnGetBcChainInfo(1);  
1052 -  
1053 - if (oBcChain1.bcount < oBcChain2.bcount) {  
1054 - iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;  
1055 - iBindex = oBcChain1.e_b == 0 ? 1 : 0;  
1056 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1057 - } else if (oBcChain1.bcount > oBcChain2.bcount) {  
1058 - iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;  
1059 - iBindex = oBcChain2.e_b == 0 ? 1 : 0;  
1060 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1061 - } else {  
1062 - iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;  
1063 - iBindex = oBcChain2.e_b == 0 ? 1 : 0;  
1064 - _fnGenerateBcAndSetBc(i, iQindex, iBindex);  
1065 - }  
1066 - }  
1067 - }  
1068 - }  
1069 -  
1070 - },  
1071 -  
1072 - /**  
1073 - * 补充连班路牌班次。  
1074 - * 1、上标线,中标线中间的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向上标线起始班次靠拢  
1075 - * 2、中标线以下的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向中标线起始班次靠拢  
1076 - */  
1077 - fnCalcuLpBx_lb: function() {  
1078 - // 补充连班的班次,参照上标线,中标线补充不足的班次  
1079 -  
1080 - var aLbLpindexes = []; // 除上标线,中标线的连班路牌索引  
1081 - var i;  
1082 - for (i = 0; i < _internalLpArray.length; i++) {  
1083 - if (_internalLpArray[i].isBxLb() && i != 0 && i != _iZbx_lpIndex) {  
1084 - aLbLpindexes.push(i);  
1085 - }  
1086 - }  
1087 -  
1088 - var oEndsj = // 结束时间  
1089 - _paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj()) ?  
1090 - _paramObj.getDownLastDTimeObj() :  
1091 - _paramObj.getUpLastDtimeObj();  
1092 -  
1093 - var oLp;  
1094 - var aMinbcPos;  
1095 - var oBc;  
1096 - var j;  
1097 - var iTempBcIndex;  
1098 -  
1099 - // 1、从最小班次开始,往后补充班次  
1100 - for (i = 0; i < aLbLpindexes.length; i++) {  
1101 - oLp = _internalLpArray[aLbLpindexes[i]];  
1102 -  
1103 - // 最小班次索引  
1104 - aMinbcPos = oLp.getMinBcObjPosition();  
1105 - // 使用纵向分隔补充班次,从最小班次向后补  
1106 - iTempBcIndex = aMinbcPos[1] == 0 ? 1 : 0;  
1107 - j = iTempBcIndex == 0 ? aMinbcPos[0] + 1 : aMinbcPos[0];  
1108 -  
1109 - while (j < _qCount) {  
1110 - while (iTempBcIndex <= 1) {  
1111 - oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex);  
1112 - if (oBc &&  
1113 - oBc.getFcTimeObj().isBefore(oEndsj) &&  
1114 - oBc.getArrTimeObj().isBefore(oEndsj)) {  
1115 - oLp.setBc(j, iTempBcIndex, oBc);  
1116 - }  
1117 - iTempBcIndex++;  
1118 - }  
1119 - iTempBcIndex = 0;  
1120 - j++;  
1121 - }  
1122 -  
1123 - }  
1124 -  
1125 - // 2、上标线中标线之间的路牌,从最小的班次往前补充班次  
1126 -  
1127 - // 还要补充缺失的班次,差上标线几个班次要往前补上  
1128 - var iBccount;  
1129 - var iQindex;  
1130 - var iBindex;  
1131 - // 补上标线到中标线之间的连班路牌的班次  
1132 - for (i = 0; i < aLbLpindexes.length; i++) {  
1133 - if (aLbLpindexes[i] > 0 && aLbLpindexes[i] < _iZbx_lpIndex) {  
1134 - oLp = _internalLpArray[aLbLpindexes[i]];  
1135 - aMinbcPos = oLp.getMinBcObjPosition();  
1136 - iQindex = aMinbcPos[0];  
1137 - iBindex = aMinbcPos[1];  
1138 - iBccount = (iQindex - 1) * 2 + iBindex; // 距离上标线起始站点差几个班次  
1139 - for (j = 0; j < iBccount; j++) {  
1140 - if (iBindex == 0) {  
1141 - iQindex --;  
1142 - iBindex = 1;  
1143 - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);  
1144 - } else if (iBindex == 1) {  
1145 - iBindex --;  
1146 - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);  
1147 - }  
1148 - }  
1149 -  
1150 - }  
1151 -  
1152 - }  
1153 -  
1154 - // 3、中标线之后的路牌,从最小的班次往前补充班次  
1155 -  
1156 - // 补中标线以下的连班路牌的班次  
1157 - for (i = 0; i < aLbLpindexes.length; i++) {  
1158 - if (aLbLpindexes[i] > _iZbx_lpIndex) {  
1159 - oLp = _internalLpArray[aLbLpindexes[i]];  
1160 - aMinbcPos = oLp.getMinBcObjPosition();  
1161 - iQindex = aMinbcPos[0];  
1162 - iBindex = aMinbcPos[1];  
1163 - iBccount = (iQindex - 0) * 2 + iBindex - 1; // 距离上标线起始站点差几个班次  
1164 - for (j = 0; j < iBccount; j++) {  
1165 - if (iBindex == 0) {  
1166 - iQindex --;  
1167 - iBindex = 1;  
1168 - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);  
1169 - } else if (iBindex == 1) {  
1170 - iBindex --;  
1171 - _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);  
1172 - }  
1173 - }  
1174 - }  
1175 - }  
1176 -  
1177 - },  
1178 -  
1179 - /**  
1180 - * 计算末班车(一般都落在连班班型上,因为按照现在的布局方法,分班路牌不会一直连到最后)。  
1181 - * 1、确定末班车早的班次  
1182 - * 2、从后往前找到与这个班次最匹配的班次的位置(第几个路牌,第几圈,第几个班次),然后覆盖  
1183 - * 3、从第2步找的位置,往上找与另一个末班车匹配的班次位置,然后覆盖  
1184 - */  
1185 - fnCalcuLastBc: function() {  
1186 - //-------------------- 1、确定末班车早的方向,时间 -----------------------//  
1187 - var _oLastTime;  
1188 - var _bLastIsUp;  
1189 - if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {  
1190 - _oLastTime = _paramObj.getUpLastDtimeObj();  
1191 - _bLastIsUp = true;  
1192 - } else {  
1193 - _oLastTime = _paramObj.getDownLastDTimeObj();  
1194 - _bLastIsUp = false;  
1195 - }  
1196 -  
1197 - //-------------------- 2、确定比 _oLastTime 小或者等于的班次位置,并修改班次时间到末班车时间 -----------------//  
1198 - var i;  
1199 - var j;  
1200 - var _oBc;  
1201 - var _oLp;  
1202 - var _aBcIndex;  
1203 -  
1204 - for (i = _qCount - 1; i >= 0; i--) {  
1205 - if (_aBcIndex) {  
1206 - break;  
1207 - }  
1208 - // 从大到小找到第一个合适的班次索引  
1209 - for (j = _internalLpArray.length - 1; j >= 0; j--) {  
1210 - _oLp = _internalLpArray[j];  
1211 - if (_oLp.isBxLb()) {  
1212 - _oBc = _oLp.getBc(i, _qIsUp == _bLastIsUp ? 0 : 1);  
1213 - }  
1214 - if (_oBc != undefined && _oBc.getFcTimeObj().isBefore(_oLastTime)) {  
1215 - _aBcIndex = [];  
1216 - _aBcIndex.push(j); // 路牌索引  
1217 - _aBcIndex.push(i); // 圈索引  
1218 - _aBcIndex.push(_qIsUp == _bLastIsUp ? 0 : 1); // 班次索引  
1219 - break;  
1220 - }  
1221 - }  
1222 - }  
1223 -  
1224 - //-------------------- 3、预估哪个个班次离末班最近,用末班替换,并删除后面的多余班次 -----------------//  
1225 - // 第2步找到的班次不一定是最适合的,需要把之后的班次模拟出来再比较一下  
1226 - var _aBcIndexes = []; // 里面放对象 {lpIndex,qIndex,bcIndex,fcsjTime}  
1227 - _oBc = undefined;  
1228 - for (i = _aBcIndex[0]; i < _internalLpArray.length; i++) {  
1229 - _oLp = _internalLpArray[i];  
1230 - if (_oLp.isBxLb()) {  
1231 - _oBc = _oLp.getBc(_aBcIndex[1], _aBcIndex[2]);  
1232 - if (_oBc == undefined) {  
1233 - _oBc = _fnGenerateBc(i, _aBcIndex[1], _aBcIndex[2]);  
1234 - }  
1235 - _aBcIndexes.push({  
1236 - lpIndex: i,  
1237 - qIndex: _aBcIndex[1],  
1238 - bcIndex: _aBcIndex[2],  
1239 - bcObj: _oBc  
1240 - })  
1241 - }  
1242 - }  
1243 - var _oBcIndex_find; // 第几个路牌离末班车最近  
1244 - for (i = _aBcIndexes.length - 1; i >= 0; i--) {  
1245 - if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {  
1246 - _oBcIndex_find = _aBcIndexes[i];  
1247 - break;  
1248 - }  
1249 - }  
1250 - // 替换成末班车  
1251 - _oBc = _oBcIndex_find.bcObj;  
1252 - _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));  
1253 - _internalLpArray[_oBcIndex_find.lpIndex].setBc(  
1254 - _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc  
1255 - );  
1256 -  
1257 - // 删除多余班次呢  
1258 - for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {  
1259 - _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);  
1260 - }  
1261 -  
1262 - //---------------------- 4、从第3步找到的位置,开始往上找,确定另一个末班车,并删除后面多余的班次 -------------//  
1263 - // 因为另一个末班车时间晚,肯定在后面,并且必须在之前的路牌  
1264 - // 如果在之后的路牌,则意味着之前那个末班车位置不对,连班连起来会有两个之前的末班车  
1265 - // 计算大的末班车时间  
1266 - if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {  
1267 - _oLastTime = _paramObj.getDownLastDTimeObj();  
1268 - _bLastIsUp = false;  
1269 - } else {  
1270 - _oLastTime = _paramObj.getUpLastDtimeObj();  
1271 - _bLastIsUp = true;  
1272 - }  
1273 - _aBcIndexes = [];  
1274 - for (i = _oBcIndex_find.lpIndex; i >=0; i--) {  
1275 - _oLp = _internalLpArray[i];  
1276 - if (_oLp.isBxLb()) {  
1277 - _oBc = _oLp.getBc(  
1278 - _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1279 - _oBcIndex_find.bcIndex == 0 ? 1 : 0  
1280 - );  
1281 - if (_oBc == undefined) {  
1282 - _oBc = _fnGenerateBc(  
1283 - i,  
1284 - _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1285 - _oBcIndex_find.bcIndex == 0 ? 1 : 0  
1286 - );  
1287 - }  
1288 - if (!_oBc) { // 纵向生成班次失败,用横向生成班次,发车时间取前一班次的到达时间加停战时间  
1289 - _oBc = _factory.createBcObj(  
1290 - _oLp,  
1291 - "normal",  
1292 - _bLastIsUp,  
1293 - 3,  
1294 - _oLp.getBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex).getArrTimeObj(),  
1295 - _paramObj  
1296 - );  
1297 -  
1298 - }  
1299 - _aBcIndexes.push({  
1300 - lpIndex: i,  
1301 - qIndex: _oBcIndex_find.bcIndex == 0 ? _oBcIndex_find.qIndex : _oBcIndex_find.qIndex + 1,  
1302 - bcIndex: _oBcIndex_find.bcIndex == 0 ? 1 : 0,  
1303 - bcObj: _oBc  
1304 - })  
1305 - }  
1306 - }  
1307 -  
1308 - console.log(_aBcIndexes);  
1309 -  
1310 - _oBcIndex_find = _aBcIndexes[0];  
1311 -  
1312 - for (i = 0; i < _aBcIndexes.length; i++) {  
1313 - if (_aBcIndexes[i].bcObj.getFcTimeObj().isBefore(_oLastTime)) {  
1314 - _oBcIndex_find = _aBcIndexes[i];  
1315 - break;  
1316 - }  
1317 - }  
1318 - // 替换成末班车  
1319 - _oBc = _oBcIndex_find.bcObj;  
1320 - _oBc.addMinuteToFcsj(_oLastTime.diff(_oBc.getFcTimeObj(), "m"));  
1321 - _internalLpArray[_oBcIndex_find.lpIndex].setBc(  
1322 - _oBcIndex_find.qIndex, _oBcIndex_find.bcIndex, _oBc  
1323 - );  
1324 -  
1325 - // 删除多余班次呢  
1326 - for (i = _oBcIndex_find.lpIndex + 1; i < _internalLpArray.length; i++) {  
1327 - _internalLpArray[i].removeBc(_oBcIndex_find.qIndex, _oBcIndex_find.bcIndex);  
1328 - }  
1329 -  
1330 -  
1331 - },  
1332 -  
1333 - /**  
1334 - * 添加吃饭班次。  
1335 - */  
1336 - fnCalcuEatBc: function() {  
1337 - // 吃午饭时间范围,10:15 到 12:15  
1338 - // 吃晚饭时间范围,18:00 到 19:00  
1339 -  
1340 - if (!_paramObj.fnIsEat()) {  
1341 - return;  
1342 - }  
1343 -  
1344 - // 午饭index  
1345 - var aLEIndex;  
1346 - // 晚饭index  
1347 - var aDEIndex;  
1348 -  
1349 - // 所有吃饭都默认在一个方向,两个方向暂时不考虑  
1350 - if (_paramObj.fnIsUpEat()) {  
1351 - aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false);  
1352 - aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false);  
1353 - } else {  
1354 - aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true);  
1355 - aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true);  
1356 - }  
1357 -  
1358 - // 午饭第几圈,第几个班次  
1359 - var iLEQIndex = aLEIndex[0];  
1360 - var iLEBIndex = aLEIndex[1];  
1361 - // 晚饭第几圈,第几个班次  
1362 - var iDEQIndex = aDEIndex[0];  
1363 - var iDEBIndex = aDEIndex[1];  
1364 -  
1365 - // 注意,本模型只有连班才有吃饭  
1366 -  
1367 - var i;  
1368 - var oLp;  
1369 - var aLbIndex = []; // 连班班型的路牌索引  
1370 - for (i = 0; i < _internalLpArray.length; i++) {  
1371 - oLp = _internalLpArray[i];  
1372 - if (oLp.isBxLb()) {  
1373 - aLbIndex.push(i);  
1374 - }  
1375 - }  
1376 -  
1377 - var iLTime;  
1378 - var iDtime;  
1379 - var j;  
1380 - for (i = 0; i < aLbIndex.length; i++) {  
1381 - oLp = _internalLpArray[aLbIndex[i]];  
1382 -  
1383 - // 午饭  
1384 - iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj);  
1385 - // 晚饭  
1386 - iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj);  
1387 -  
1388 - if (i == aLbIndex.length - 1) {  
1389 - for (j = aLbIndex[i]; j < _internalLpArray.length; j++) {  
1390 - oLp = _internalLpArray[j];  
1391 - if (oLp.isBxFb()) { // 5休2班型不调整  
1392 - // 修正午饭之后路牌班次的发车时间  
1393 - oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);  
1394 - oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);  
1395 - }  
1396 - }  
1397 - } else {  
1398 - for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) {  
1399 - oLp = _internalLpArray[j];  
1400 - if (oLp.isBxFb()) {  
1401 - // 修正午饭之后路牌班次的发车时间  
1402 - oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);  
1403 - oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);  
1404 - }  
1405 - }  
1406 - }  
1407 - }  
1408 -  
1409 - },  
1410 -  
1411 - /**  
1412 - * 补每个路牌的其他班次(进出场,例保班次)。  
1413 - */  
1414 - fnCalcuOtherBc: function() {  
1415 - var i;  
1416 - var _lpObj;  
1417 - var _minBcIndex;  
1418 - var _maxBcIndex;  
1419 - var _minBc;  
1420 - var _maxBc;  
1421 - var _otherbc = [];  
1422 -  
1423 - for (i = 0; i < _internalLpArray.length; i++) {  
1424 - _lpObj = _internalLpArray[i];  
1425 - _minBcIndex = _lpObj.getMinBcObjPosition();  
1426 - _maxBcIndex = _lpObj.getMaxBcObjPosition();  
1427 - _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]);  
1428 - _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]);  
1429 -  
1430 - _otherbc = [];  
1431 - //_otherbc.push(_factory.createBcObj(  
1432 - // _lpObj, "bd", true, 1,  
1433 - // _minBc.getFcTimeObj(),  
1434 - // _paramObj  
1435 - //));  
1436 - _otherbc.push(_factory.createBcObj(  
1437 - _lpObj, "out", true, 1,  
1438 - _minBc.getFcTimeObj(),  
1439 - _paramObj  
1440 - ));  
1441 -  
1442 - _maxBc.setArrTimeObj(_paramObj.addMinute(_maxBc.getFcTimeObj(), _maxBc.getBcTime()));  
1443 - _maxBc.setStopTime(0);  
1444 - _otherbc.push(_factory.createBcObj(  
1445 - _lpObj, "in", true, 1,  
1446 - _maxBc.getArrTimeObj(),  
1447 - _paramObj  
1448 - ));  
1449 - //_otherbc.push(_factory.createBcObj(  
1450 - // _lpObj, "lc", true, 1,  
1451 - // _maxBc.getArrTimeObj(),  
1452 - // _paramObj  
1453 - //));  
1454 -  
1455 - _lpObj.addOtherBcArray(_otherbc);  
1456 - }  
1457 -  
1458 - },  
1459 -  
1460 - /**  
1461 - * 祛除上标线有删除标记的班次。  
1462 - */  
1463 - fnRemoveDelFlagBc: function() {  
1464 - var oLp = _internalLpArray[0];  
1465 - var aMinBcIndex = oLp.getMinBcObjPosition();  
1466 - oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]);  
1467 -  
1468 - var aMaxBcIndex = oLp.getMaxBcObjPosition();  
1469 - if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) {  
1470 - oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]);  
1471 - }  
1472 - },  
1473 -  
1474 - /**  
1475 - * 调整班次纵向间隔(发车时间调整)。  
1476 - * 1、只调整分班班次的发车时间  
1477 - * 2、调整每两个连班之间的分班班次组  
1478 - * 3、如果不是连续的班次才调整  
1479 - */  
1480 - fnAdjust_vertical_bc_interval: function() {  
1481 - var i;  
1482 - var j;  
1483 - var iBIndex = 0;  
1484 - var oLbGroup = {};  
1485 - var oLp;  
1486 - for (i = 0; i < _qCount; i++) {  
1487 - while (iBIndex <= 1) {  
1488 - oLbGroup[i + "_" + iBIndex] = [];  
1489 - for (j = 0; j < _internalLpArray.length; j++) {  
1490 - oLp = _internalLpArray[j];  
1491 - if (oLp.isBxLb()) {  
1492 - if (oLp.getBc(i, iBIndex)) {  
1493 - oLbGroup[i + "_" + iBIndex].push(j);  
1494 - }  
1495 - }  
1496 - }  
1497 - if (oLbGroup[i + "_" + iBIndex].length == 1) {  
1498 - oLbGroup[i + "_" + iBIndex] = [];  
1499 - }  
1500 -  
1501 - iBIndex ++;  
1502 - }  
1503 - iBIndex = 0;  
1504 - }  
1505 -  
1506 - //console.log(oLbGroup);  
1507 -  
1508 - var sKey;  
1509 - var iQindex;  
1510 - var iBindex;  
1511 - var aBcLb = [];  
1512 -  
1513 - var oLbGroup_m = {};  
1514 - var aLbGroup = [];  
1515 -  
1516 -  
1517 - // 计算需要调整的连班区间  
1518 - for (sKey in oLbGroup) {  
1519 - iQindex = sKey.split('_')[0];  
1520 - iBindex = sKey.split('_')[1];  
1521 - oLbGroup_m[sKey] = [];  
1522 - for (i = 0; i < oLbGroup[sKey].length - 1; i++) {  
1523 - aBcLb = [];  
1524 - for (j = oLbGroup[sKey][i] + 1; j <= oLbGroup[sKey][i + 1] - 1; j++) {  
1525 - oLp = _internalLpArray[j];  
1526 - if (oLp.getBc(iQindex, iBindex)) {  
1527 - aBcLb.push(j);  
1528 - }  
1529 - }  
1530 - if (aBcLb.length != 0 && aBcLb.length < (oLbGroup[sKey][i + 1] - oLbGroup[sKey][i] - 1)) {  
1531 - aLbGroup = [];  
1532 - aLbGroup.push(oLbGroup[sKey][i]);  
1533 - aLbGroup.push(oLbGroup[sKey][i + 1]);  
1534 - aLbGroup.push(aBcLb);  
1535 - oLbGroup_m[sKey].push(aLbGroup);  
1536 - }  
1537 - }  
1538 - }  
1539 -  
1540 - console.log(oLbGroup_m);  
1541 -  
1542 - var iStartLpIndex;  
1543 - var iEndLpIndex;  
1544 - var iDCount;  
1545 - var iDiffTime;  
1546 -  
1547 - var iC1;  
1548 - var iC2;  
1549 - var oKssj;  
1550 -  
1551 - for (sKey in oLbGroup_m) {  
1552 - iQindex = sKey.split('_')[0];  
1553 - iBindex = sKey.split('_')[1];  
1554 -  
1555 - for (i = 0; i < oLbGroup_m[sKey].length; i++) {  
1556 - aLbGroup = oLbGroup_m[sKey][i];  
1557 -  
1558 - iStartLpIndex = aLbGroup[0];  
1559 - iEndLpIndex = aLbGroup[1];  
1560 - iDCount = aLbGroup[2].length + 1;  
1561 -  
1562 - iDiffTime = _internalLpArray[iEndLpIndex].getBc(iQindex, iBindex).getFcTimeObj().diff(  
1563 - _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj(), 'm');  
1564 -  
1565 - iC1 = Math.floor(iDiffTime / iDCount);  
1566 - iC2 = iDiffTime % iDCount;  
1567 - oKssj = _internalLpArray[iStartLpIndex].getBc(iQindex, iBindex).getFcTimeObj();  
1568 -  
1569 - for (j = 1; j <= iDCount - iC2; j++) {  
1570 - if (j - 1 < aLbGroup[2].length) {  
1571 - oKssj = _paramObj.addMinute(oKssj, iC1);  
1572 - _internalLpArray[aLbGroup[2][j - 1]].getBc(  
1573 - iQindex, iBindex).setFcTimeObj(oKssj);  
1574 - }  
1575 - }  
1576 -  
1577 - for (j = 1; j < iC2; j++) {  
1578 - oKssj = _paramObj.addMinute(oKssj, iC1 + 1);  
1579 - _internalLpArray[aLbGroup[2][iDCount - iC2 + j - 1]].getBc(  
1580 - iQindex, iBindex).setFcTimeObj(oKssj);  
1581 - }  
1582 -  
1583 - }  
1584 - }  
1585 -  
1586 - },  
1587 -  
1588 - //------------- 其他方法 -------------//  
1589 - /**  
1590 - * 内部数据转化成显示用的班次数组。  
1591 - */  
1592 - fnToGanttBcArray: function() {  
1593 - var aAllBc = [];  
1594 - var aLpBc = [];  
1595 - var oLp;  
1596 - var i;  
1597 - var j;  
1598 -  
1599 - for (i = 0; i < _internalLpArray.length; i++) {  
1600 - oLp = _internalLpArray[i];  
1601 - aLpBc = [];  
1602 - aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());  
1603 - // 按照发车时间排序  
1604 - aLpBc.sort(function(o1, o2) {  
1605 - if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {  
1606 - return -1;  
1607 - } else {  
1608 - return 1;  
1609 - }  
1610 - });  
1611 -  
1612 - // 重新赋值fcno  
1613 - for (j = 0; j < aLpBc.length; j++) {  
1614 - aLpBc[j].fnSetFcno(j + 1);  
1615 - }  
1616 -  
1617 - aAllBc = aAllBc.concat(aLpBc);  
1618 - }  
1619 -  
1620 - var aGanttBc = [];  
1621 - for (i = 0; i < aAllBc.length; i++) {  
1622 - aGanttBc.push(aAllBc[i].toGanttBcObj());  
1623 - }  
1624 -  
1625 - return aGanttBc;  
1626 - }  
1627 -  
1628 - };  
1629 - 1 +/**
  2 + * 内部行车计划对象。
  3 + * @constructor
  4 + */
  5 +var InternalScheduleObj = function(paramObj, lpArray, factory) {
  6 + // 参数对象
  7 + var _paramObj = paramObj;
  8 + // 外部的路牌数组
  9 + var _lpArray = lpArray;
  10 + // 工厂对象
  11 + var _factory = factory;
  12 +
  13 + //------------------ 初始化方法1,以及计算关联的内部变量 -----------------//
  14 + var _qIsUp; // 每一圈是上行开始还是下行开始
  15 + var _qCount = 0; // 总的圈数
  16 + var _internalLpArray = []; // 内部对象数组
  17 + var _aBxDesc = [ // 各种班型描述(班型名称,平均工时,平均需要的班次数,平均工时)
  18 + {'sType':'六工一休', 'fHoursV':6.66, 'fBcCount': 0, 'fAverTime': 0},
  19 + {'sType':'五工一休', 'fHoursV':6.85, 'fBcCount': 0, 'fAverTime': 0},
  20 + {'sType':'四工一休', 'fHoursV':7.14, 'fBcCount': 0, 'fAverTime': 0},
  21 + {'sType':'三工一休', 'fHoursV':7.61, 'fBcCount': 0, 'fAverTime': 0},
  22 + {'sType':'二工一休', 'fHoursV':8.57, 'fBcCount': 0, 'fAverTime': 0},
  23 + {'sType':'一工一休', 'fHoursV':11.42, 'fBcCount': 0, 'fAverTime': 0},
  24 + {'sType':'五工二休', 'fHoursV':7.99, 'fBcCount': 0, 'fAverTime': 0},
  25 + {'sType':'无工休', 'fHoursV':5.43, 'fBcCount': 0, 'fAverTime': 0}
  26 + ];
  27 +
  28 + var _fnInitFun1 = function() { // 初始化方法1
  29 + console.log("//---------------- 行车计划,初始化方法1 start ----------------//");
  30 +
  31 + //----------------------- 1、确定上标线的方向,圈的方向 -------------------//
  32 +
  33 + // 确定_qIsUp,哪个方向的首班车晚就用哪个
  34 + _qIsUp = _paramObj.getUpFirstDTimeObj().isBefore(
  35 + _paramObj.getDownFirstDTimeObj()) ? false : true;
  36 + // 上标线开始时间,就是方向的首班车时间
  37 + var st = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
  38 + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
  39 + var et;
  40 + var et_IsUp;
  41 + if (_paramObj.getUpLastDtimeObj().isBefore(
  42 + _paramObj.getDownLastDTimeObj())) {
  43 + et = _paramObj.getDownLastDTimeObj();
  44 + et_IsUp = false;
  45 + } else {
  46 + et = _paramObj.getUpLastDtimeObj();
  47 + et_IsUp = true;
  48 + }
  49 +
  50 + //------------------------ 2、计算总共有多少圈 ------------------------//
  51 +
  52 + // 以开始时间,结束时间,构造上标线用连班班次发车时间
  53 + var bcFcsjArrays = []; // 班次发车时间对象数组
  54 + var bcArsjArrays = []; // 班次到达时间对象数组
  55 + var isUp = _qIsUp; // 方向
  56 + var bcCount = 1; // 班次数
  57 +
  58 + var _kssj = st; // 开始时间
  59 + var _bcsj = paramObj.calcuTravelTime(_kssj, isUp); // 班次历时
  60 + var _arrsj = paramObj.addMinute(_kssj, _bcsj); // 到达时间
  61 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj); // 停站时间
  62 +
  63 + do {
  64 + bcFcsjArrays.push(_kssj);
  65 + bcArsjArrays.push(_arrsj);
  66 +
  67 + _kssj = paramObj.addMinute(_kssj, _bcsj + _stoptime);
  68 + _bcsj = paramObj.calcuTravelTime(_kssj, isUp);
  69 + _arrsj = paramObj.addMinute(_kssj, _bcsj);
  70 + _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  71 +
  72 + bcCount ++;
  73 + isUp = !isUp;
  74 + } while(_kssj.isBefore(et));
  75 + bcCount--; // 因为先做do,所以总的班次要减1
  76 + //if (bcCount > 0 && bcArsjArrays[bcCount - 1].isAfter(et)) {
  77 + // // 如果最后一个班次的到达时间超过结束时间,也要去除
  78 + // bcFcsjArrays.splice(bcCount - 1, 1);
  79 + // bcArsjArrays.splice(bcCount - 1, 1);
  80 + // bcCount--;
  81 + //}
  82 + var _qCount_p1 = Math.floor(bcCount / 2); // 2个班次一圈
  83 + var _qCount_p2 = bcCount % 2; // 余下的1个班次也算一圈
  84 +
  85 + // 利用连班数组计算圈数
  86 + _qCount = 1; // 前面加1圈,补中标线的班次
  87 + _qCount += _qCount_p1;
  88 + _qCount += _qCount_p2;
  89 +
  90 + // 计算最后是不是还要补一圈
  91 + if (_qCount > 1) { // 总的圈数就1圈,没必要加了(其实是不可能的,除非参数里问题)
  92 + if (_qCount_p2 == 0) { // 没有余下班次,整数圈数
  93 + // 最后一个班次的方向一定和开始的方向相反,如:上-下,上-下,上-下,一共三圈,最后一个班次为下行
  94 + // 判定最后一个班次的方向和上标线判定结束时间的班次方向是否一致
  95 + if (!_qIsUp == et_IsUp) {
  96 + // 一致不用加圈数
  97 + } else {
  98 + // 不一致需要加圈补最后一个结束时间班次
  99 + _qCount ++;
  100 + }
  101 + } else {
  102 + // 有余下的圈数,最后要不补的班次不管上行,下行都在这一圈里
  103 + // 不需要在补圈数了
  104 + }
  105 + }
  106 +
  107 + //------------------------ 3、根据路牌数,圈数创建路牌对象 ----------------------//
  108 +
  109 + // 创建内部的路牌数组,并把之前的连班路牌添加进上标线路牌中
  110 + var i;
  111 + for (i = 0; i < _lpArray.length; i++) {
  112 + _internalLpArray.push(new InternalLpObj(_lpArray[i], _qCount, _qIsUp));
  113 + }
  114 + // 初始化上标线,从第1圈开始
  115 + _internalLpArray[0].initDataFromTimeToTime(bcFcsjArrays[0], et, _qIsUp, 1, _paramObj, _factory);
  116 +
  117 + // 以上标线为基础,计算各种班型工时对应的圈数、班次数
  118 + var aBcArray = _internalLpArray[0].getBcArray();
  119 + if (aBcArray.length % 2 != 0) { // 不能整除2,去除一个班次计算
  120 + aBcArray.splice(aBcArray.length - 1, 1);
  121 + }
  122 +
  123 + // 午饭吃饭时间
  124 + var iLTime = _paramObj.fnGetLunchTime();
  125 + // 晚饭吃饭时间
  126 + var iDTime = _paramObj.fnGetDinnerTime();
  127 + // 出场时间
  128 + var iOutTime = _qIsUp ? _paramObj.getUpOutTime() : _paramObj.getDownOutTime();
  129 + // 进场时间
  130 + var iInTime = _qIsUp ? _paramObj.getDownInTime() : _paramObj.getUpInTime();
  131 + // 例保时间
  132 + var iBTime = _paramObj.getLbTime();
  133 +
  134 + var sum = 0; // 总班次时间
  135 + for (i = 0; i < aBcArray.length; i++) {
  136 + sum += aBcArray[i].getBcTime() + aBcArray[i].getStopTime();
  137 + }
  138 + sum += iLTime; // 加午饭时间
  139 + sum += iDTime; // 加晚饭时间
  140 + for (i = 0; i < _aBxDesc.length; i++) {
  141 + _aBxDesc[i].fAverTime = sum / (aBcArray.length / 2); // 平均周转时间不算进出场,例保时间
  142 +
  143 + // 计算5休2的班次数(双进出场,4个例保)
  144 + if (i == 6) {
  145 + _aBxDesc[i].fQCount =
  146 + (_aBxDesc[i].fHoursV * 60 - iOutTime * 2 - iInTime * 2 - iBTime * 4) /
  147 + _aBxDesc[i].fAverTime;
  148 + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2;
  149 + } else { // 进出场,2个例保
  150 + _aBxDesc[i].fQCount =
  151 + (_aBxDesc[i].fHoursV * 60 - iOutTime - iInTime - iBTime * 2) /
  152 + _aBxDesc[i].fAverTime;
  153 + _aBxDesc[i].fBcCount = _aBxDesc[i].fQCount * 2;
  154 + }
  155 + }
  156 +
  157 +
  158 + // 在第一个班次之前再添加一个模拟班次,用于中标线的作用
  159 + // 那一圈必定是低谷,而且圈索引0,班次索引1,暂时标记,最后删除
  160 + var iFirstStopTime =
  161 + _paramObj.fnCalcuFixedStopNumber(
  162 + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -10),
  163 + _qIsUp
  164 + );
  165 + var iXXTime = _qIsUp ? _paramObj.getDownTroughTime() : _paramObj.getUpTroughTime();
  166 + var oFlagBc = _factory.createBcObj( // 标记班次
  167 + _internalLpArray[0],
  168 + "normal",
  169 + !_qIsUp,
  170 + 1,
  171 + _paramObj.addMinute(aBcArray[0].getFcTimeObj(), -(iFirstStopTime + iXXTime)),
  172 + _paramObj
  173 + );
  174 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  175 +
  176 + _internalLpArray[0].setBc(0, 1, oFlagBc);
  177 +
  178 + // 在最后一圈也补上一个或者2个模拟班次,暂时标记,最后需要删除
  179 + var aMaxBcIndex = _internalLpArray[0].getMaxBcObjPosition();
  180 + if (aMaxBcIndex[0] == _qCount - 1) { // 可能加半圈
  181 + oFlagBc = _factory.createBcObj( // 标记班次
  182 + _internalLpArray[0],
  183 + "normal",
  184 + !_qIsUp,
  185 + 1,
  186 + _paramObj.addMinute(
  187 + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),
  188 + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),
  189 + _paramObj
  190 + );
  191 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  192 + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);
  193 +
  194 + } else { // 加完整的一圈
  195 + oFlagBc = _factory.createBcObj( // 标记班次
  196 + _internalLpArray[0],
  197 + "normal",
  198 + _qIsUp,
  199 + 1,
  200 + _paramObj.addMinute(
  201 + _internalLpArray[0].getBc(_qCount - 2, 1).getArrTimeObj(),
  202 + _internalLpArray[0].getBc(_qCount - 2, 1).getStopTime()),
  203 + _paramObj
  204 + );
  205 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  206 + _internalLpArray[0].setBc(_qCount - 1, 0, oFlagBc);
  207 +
  208 + oFlagBc = _factory.createBcObj( // 标记班次
  209 + _internalLpArray[0],
  210 + "normal",
  211 + !_qIsUp,
  212 + 1,
  213 + _paramObj.addMinute(
  214 + _internalLpArray[0].getBc(_qCount - 1, 0).getArrTimeObj(),
  215 + _internalLpArray[0].getBc(_qCount - 1, 0).getStopTime()),
  216 + _paramObj
  217 + );
  218 + oFlagBc.fnSetDelFlag(true); // 标记了删除记号
  219 + _internalLpArray[0].setBc(_qCount - 1, 1, oFlagBc);
  220 +
  221 + }
  222 +
  223 + console.log("上行首班车时间:" + _paramObj.getUpFirstDTimeObj().format("HH:mm") +
  224 + "上行末班车时间:" + _paramObj.getUpLastDtimeObj().format("HH:mm"));
  225 + console.log("下行首班车时间:" + _paramObj.getDownFirstDTimeObj().format("HH:mm") +
  226 + "下行末班车时间:" + _paramObj.getDownLastDTimeObj().format("HH:mm"));
  227 + console.log("总共计算的圈数:" + _qCount);
  228 + console.log("圈的方向isUP:" + _qIsUp);
  229 + console.log("班型描述(以下):");
  230 + console.log(_aBxDesc);
  231 + console.log("所有路牌间隔描述(以下):");
  232 + for (i = 0; i < _internalLpArray.length; i++) {
  233 + console.log(_internalLpArray[i]._$_aVerticalIntervalTime);
  234 + }
  235 + console.log("//---------------- 行车计划,初始化方法1 end ----------------//");
  236 +
  237 + };
  238 +
  239 + //------------------ 初始化方法2,以及计算关联的内部变量 ----------------//
  240 + var _approximate_zgfQIndex; // 预估早高峰车辆从第几圈开始全部发出
  241 + var _approximate_zgfBIndex; // 预估早高峰车辆从第几圈第几个班次开始全部发出(上行或下行)
  242 + var _approximate_wgfQIndex; // 预估晚高峰车辆从第几圈开始全部发出
  243 + var _approximate_wgfBIndex; // 预估晚高峰车辆从第几圈第几个班次开始全部发出(上行或下行)
  244 +
  245 + var _fnInitFun2 = function() { // 初始化方法2
  246 + console.log("//---------------- 行车计划,初始化方法2 start ----------------//");
  247 +
  248 + //------------------------ 1、计算车辆总数 ------------------------//
  249 + // 是用高峰上行周转时间除以高峰平均间隔得到的
  250 + // 这样算还算合理,车辆不多不少,待以后有新的算法再修正
  251 + var iClCount = _paramObj.calcuClzx();
  252 +
  253 + //------------------------ 2、计算所有路牌的发车在各个圈中的间隔 --------------------//
  254 + var i;
  255 + var j;
  256 + var iBindex = 1;
  257 + var iZzsj;
  258 + var oLp;
  259 + var iC1;
  260 + var iC2;
  261 +
  262 + for (i = 0; i < _qCount - 1; i++) {
  263 + while (iBindex <= 1) {
  264 + // 每圈每个方向的周转时间不一致,以上标线为主
  265 + oLp = _internalLpArray[0];
  266 + iZzsj = oLp.getBc(i + 1, iBindex).getFcTimeObj().diff(
  267 + oLp.getBc(i, iBindex).getFcTimeObj(), "m"
  268 + );
  269 +
  270 + iC1 = Math.floor(iZzsj / iClCount);
  271 + iC2 = iZzsj % iClCount;
  272 +
  273 + for (j = 0; j < iClCount - iC2; j++) {
  274 + oLp = _internalLpArray[j];
  275 + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1);
  276 + }
  277 +
  278 + for (j = 0; j < iC2; j++) {
  279 + oLp = _internalLpArray[iClCount - iC2 + j];
  280 + oLp.fnSetVerticalIntervalTime(i, iBindex, iC1 + 1);
  281 + }
  282 +
  283 + iBindex ++;
  284 +
  285 + }
  286 + iBindex = 0;
  287 + }
  288 + // 最后一圈没有下一圈的参照,周转时间没发获取,由于都是低谷,所以使用倒数第二圈的间隔最为最后一圈的间隔
  289 + for (i = 0; i < _internalLpArray.length; i++) {
  290 + oLp = _internalLpArray[i];
  291 + oLp.fnSetVerticalIntervalTime(_qCount - 1, 0, oLp.fnGetVerticalIntervalTime(_qCount - 2, 0));
  292 + oLp.fnSetVerticalIntervalTime(_qCount - 1, 1, oLp.fnGetVerticalIntervalTime(_qCount - 2, 1));
  293 + }
  294 +
  295 + //------------------------ 3、预估早高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
  296 +
  297 + // 以上标线为标准,查找离早高峰开始时间最近的班次作为早高峰开始班次
  298 + // 以这个班次为早高峰起点,全部出车策略
  299 + var qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
  300 + _paramObj.getMPeakStartTimeObj(), true, true);
  301 + var qIndex = qbcIndexArray[0]; // 第几圈
  302 + var bIndex = qbcIndexArray[1]; // 第几个班次
  303 +
  304 + for (i = 1; i < _internalLpArray.length; i++) {
  305 + _fnGenerateBcAndSetBc(i, qIndex, bIndex);
  306 + }
  307 +
  308 + _approximate_zgfQIndex = qIndex;
  309 + _approximate_zgfBIndex = bIndex;
  310 +
  311 + //------------------------ 4、预估晚高峰全部出车第几圈第几个班次全部出车,计算路牌之间的发车间隔 ------------------//
  312 +
  313 + // 以上标线为标准,查找离晚高峰开始时间最近的班次作为晚高峰开始班次
  314 + // 以这个班次为早高峰起点,全部出车策略
  315 + qbcIndexArray = _internalLpArray[0].getQBcIndexWithFcTime(
  316 + _paramObj.getEPeakStartTimeObj(), true, true);
  317 + qIndex = qbcIndexArray[0]; // 第几圈
  318 + bIndex = qbcIndexArray[1]; // 第几个班次
  319 +
  320 + for (i = 1; i < _internalLpArray.length; i++) {
  321 + _fnGenerateBcAndSetBc(i, qIndex, bIndex);
  322 + }
  323 +
  324 + _approximate_wgfQIndex = qIndex;
  325 + _approximate_wgfBIndex = bIndex;
  326 +
  327 + console.log("早高峰周转时间(固定最大停战时间):" + _paramObj.calcuPeakZzsj() + "分钟");
  328 + console.log("早高峰发车时间范围:" + _paramObj.getMPeakMinFcjx() + "分钟 --- " + _paramObj.getMPeakMaxFcjx() + "分钟");
  329 + console.log("预估早高峰第" + _approximate_zgfQIndex + "(index)圈,第" + _approximate_zgfBIndex + "(index)班次车辆全部发出");
  330 + console.log("预估晚高峰第" + _approximate_wgfQIndex + "(index)圈,第" + _approximate_wgfBIndex + "(index)班次车辆全部发出");
  331 + console.log("//---------------- 行车计划,初始化方法2 end ----------------//");
  332 + };
  333 +
  334 + //----------------------- 初始化方法3,计算连班分班的路牌分布 ----------------//
  335 + var _iBx_lb_lpcount; // 连班路牌数
  336 + var _iBx_5_2_fb_lpcount; // 5休2分班路牌数
  337 + var _iBx_other_fb_lpcount; // 其他分班路牌数
  338 +
  339 + var _fnInitFun3 = function() { // 初始化方法3
  340 + console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
  341 +
  342 + //--------------------- 1、计算分班连班班型车辆分布数 --------------------//
  343 + // 总共车辆数(高峰最大车辆数)
  344 + var iCls = _paramObj.calcuClzx();
  345 + // 低谷最少配车(连班车数量)
  346 + var iDgminpc = Math.round(_paramObj.calcuTroughZzsj() / _paramObj.getTroughMaxFcjx());
  347 + // 加班车路牌数(做5休2的路牌数)
  348 + var i_5_2_lpes = _paramObj.getJBLpes();
  349 +
  350 + // 做些简单的验证
  351 + if (iCls < iDgminpc) {
  352 + alert("总配车数小于低谷最小配车");
  353 + throw "总配车数小于低谷最小配车";
  354 + }
  355 + if (iDgminpc < 2) {
  356 + alert("连班路牌小于2,办不到啊");
  357 + throw "连班路牌小于2,办不到啊";
  358 + }
  359 + if (iCls - iDgminpc < i_5_2_lpes) {
  360 + alert("总分班路牌数小于加班路牌数");
  361 + throw "总分班路牌数小于加班路牌数";
  362 + }
  363 +
  364 + //// 修正连班路牌数,班次间隔大于20的,加1,直至班次间隔小于20
  365 + //while(_paramObj.calcuPeakZzsj() / iDgminpc > 20) {
  366 + // iDgminpc ++;
  367 + //}
  368 + _iBx_lb_lpcount = iDgminpc;
  369 +
  370 + _iBx_5_2_fb_lpcount = i_5_2_lpes;
  371 + _iBx_other_fb_lpcount = iCls - _iBx_lb_lpcount - i_5_2_lpes;
  372 +
  373 + //------------------------ 2、利用间隔法计算连班路牌分布 --------------------//
  374 + var i;
  375 + var j;
  376 + var iC1 = Math.floor(_internalLpArray.length / _iBx_lb_lpcount);
  377 + var iC2 = _internalLpArray.length % _iBx_lb_lpcount;
  378 + var iLpIndex;
  379 +
  380 + for (i = 0; i < _iBx_lb_lpcount - iC2; i++) {
  381 + iLpIndex = i * iC1;
  382 + _internalLpArray[iLpIndex].setBxLb(true);
  383 + _internalLpArray[iLpIndex].setBxDesc("连班");
  384 + }
  385 + for (j = 0; j < iC2; j++) {
  386 + iLpIndex = i * iC1 + j * (iC1 + 1);
  387 + _internalLpArray[iLpIndex].setBxLb(true);
  388 + _internalLpArray[iLpIndex].setBxDesc("连班");
  389 + }
  390 +
  391 + //------------------------ 3、利用间隔法计算分班班型路牌分布 --------------------//
  392 + // 获取分班路牌索引
  393 + var aNotLbIndexes = [];
  394 + for (i = 0; i < _internalLpArray.length; i++) {
  395 + if (!_internalLpArray[i].isBxLb()) {
  396 + aNotLbIndexes.push(i);
  397 + }
  398 + }
  399 + // 先5休2分班
  400 + iC1 = Math.floor(aNotLbIndexes.length / _iBx_5_2_fb_lpcount);
  401 + iC2 = aNotLbIndexes.length % _iBx_5_2_fb_lpcount;
  402 +
  403 + for (i = 0; i < _iBx_5_2_fb_lpcount - iC2; i++) {
  404 + iLpIndex = aNotLbIndexes[i * iC1];
  405 + _internalLpArray[iLpIndex].setBxLb(false);
  406 + _internalLpArray[iLpIndex].setBxFb(true);
  407 + _internalLpArray[iLpIndex].setBxFb5_2(true);
  408 + _internalLpArray[iLpIndex].setBxDesc("5休2分班");
  409 + }
  410 + for (i = 0; i < iC2; i++) {
  411 + iLpIndex = aNotLbIndexes[_iBx_lb_lpcount - iC2 + i * (iC1 + 1)];
  412 + _internalLpArray[iLpIndex].setBxLb(false);
  413 + _internalLpArray[iLpIndex].setBxFb(true);
  414 + _internalLpArray[iLpIndex].setBxFb5_2(true);
  415 + _internalLpArray[iLpIndex].setBxDesc("5休2分班");
  416 + }
  417 + // 其他分班
  418 + for (i = 0; i < aNotLbIndexes.length; i++) {
  419 + iLpIndex = aNotLbIndexes[i];
  420 + if (!_internalLpArray[iLpIndex].isBxFb5_2()) {
  421 + _internalLpArray[iLpIndex].setBxLb(false);
  422 + _internalLpArray[iLpIndex].setBxFb(true);
  423 + _internalLpArray[iLpIndex].setBxFb5_2(false);
  424 + _internalLpArray[iLpIndex].setBxDesc("其他分班");
  425 + }
  426 + }
  427 +
  428 + console.log("高峰周转时间:" + _paramObj.calcuPeakZzsj());
  429 + console.log("连班路牌数:" + _iBx_lb_lpcount);
  430 + console.log("5休2分班路牌数:" + _iBx_5_2_fb_lpcount);
  431 + console.log("其他分班路牌数:" + _iBx_other_fb_lpcount);
  432 + var aLbIndexes = [];
  433 + for (i = 0; i < _internalLpArray.length; i++) {
  434 + if (_internalLpArray[i].isBxLb()) {
  435 + aLbIndexes.push(i);
  436 + }
  437 + }
  438 + console.log("连班路牌indexes=" + aLbIndexes);
  439 + var a_5_2_fbIndexes = [];
  440 + for (i = 0; i < _internalLpArray.length; i++) {
  441 + if (_internalLpArray[i].isBxFb() && _internalLpArray[i].isBxFb5_2()) {
  442 + a_5_2_fbIndexes.push(i);
  443 + }
  444 + }
  445 + console.log("5休2分班路牌indexes=" + a_5_2_fbIndexes);
  446 + var a_other_fbIndexes = [];
  447 + for (i = 0; i < _internalLpArray.length; i++) {
  448 + if (_internalLpArray[i].isBxFb() && !_internalLpArray[i].isBxFb5_2()) {
  449 + a_other_fbIndexes.push(i);
  450 + }
  451 + }
  452 + console.log("其他分班路牌indexes=" + a_other_fbIndexes);
  453 +
  454 + console.log("//---------------- 行车计划,初始化方法3 end ----------------//");
  455 + };
  456 +
  457 + //----------------------- 初始化方法4,计算中标线位置 -------------------------//
  458 + var _iZbx_lpIndex; // 中标线对应第几个路牌
  459 +
  460 + var _fnInitFun4 = function() { // 初始化方法4
  461 + console.log("//---------------- 行车计划,初始化方法3 start ----------------//");
  462 +
  463 + //---------------------------- 1、模拟一个中标线,使用临时路牌 ----------------------//
  464 + // 构造中标线
  465 + // 中标线开始时间,就是方向的首班车时间
  466 + var oSt = !_qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
  467 + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
  468 + // 上标线结束时间,使用最晚的末班车时间,结束时间的班次方向
  469 + var oEt;
  470 + if (_paramObj.getUpLastDtimeObj().isBefore(
  471 + _paramObj.getDownLastDTimeObj())) {
  472 + oEt = _paramObj.getDownLastDTimeObj();
  473 + } else {
  474 + oEt = _paramObj.getUpLastDtimeObj();
  475 + }
  476 +
  477 + var oTempLp = new InternalLpObj({lpNo: -999, lpName: "-999"}, _qCount, _qIsUp);
  478 + oTempLp.initDataFromTimeToTime(
  479 + oSt,
  480 + oEt,
  481 + !_qIsUp,
  482 + 0,
  483 + _paramObj,
  484 + _factory
  485 + );
  486 +
  487 + //------------------------ 2、找出中标线的早高峰班次,计算应该插在当前路牌数组的那个位置 ----------------//
  488 + // 找出中标线对应的早高峰的班次对象
  489 + var oZb_gf_bc = oTempLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
  490 +
  491 + // 把所有连班路牌高峰班次重新构造成一个一个的圈数组,计算对应中标线最近的是第几个路牌
  492 + // 中标线和上标线一样在连班路牌上
  493 + var aTempq = [];
  494 + var oTempq;
  495 + var oTempb;
  496 + var i;
  497 + var oLp;
  498 +
  499 + var aLbIndexes = []; // 连班的路牌索引
  500 + for (i = 0; i < _internalLpArray.length; i++) {
  501 + if (_internalLpArray[i].isBxLb()) {
  502 + aLbIndexes.push(i);
  503 + }
  504 + }
  505 +
  506 + for (i = 0; i < aLbIndexes.length; i++) {
  507 + oLp = _internalLpArray[aLbIndexes[i]];
  508 +
  509 + oTempb = oLp.getBc(_approximate_zgfQIndex, _approximate_zgfBIndex);
  510 + if (oTempb.isUp() == _qIsUp) {
  511 + oTempq = new InternalGroupObj(oLp, _qIsUp, oTempb, undefined);
  512 + } else {
  513 + oTempq = new InternalGroupObj(oLp, _qIsUp, undefined, oTempb);
  514 + }
  515 + aTempq.push(oTempq);
  516 +
  517 + }
  518 +
  519 + var aTtindex = oTempLp.getgetQBcIndexWithFcTimeFromGroupArray(
  520 + oZb_gf_bc.getFcTimeObj(),
  521 + aTempq,
  522 + true,
  523 + true
  524 + );
  525 +
  526 + _iZbx_lpIndex = aLbIndexes[aTtindex[0]]; // 中标线放在第几个路牌
  527 + oTempLp.setLp(_lpArray[_iZbx_lpIndex]); // 设置原始路牌对象
  528 + oTempLp._$_aVerticalIntervalTime = _internalLpArray[_iZbx_lpIndex]._$_aVerticalIntervalTime; // 设置纵向最小发车间隔
  529 + oTempLp.setBxLb(_internalLpArray[_iZbx_lpIndex].isBxLb());
  530 + oTempLp.setBxFb(_internalLpArray[_iZbx_lpIndex].isBxFb());
  531 + oTempLp.setBxFb5_2(_internalLpArray[_iZbx_lpIndex].isBxFb5_2());
  532 +
  533 + // 修正除了第一个班次外,其余其他班次
  534 + var iBcindex = 0;
  535 + for (i = 1; i < _qCount; i++) {
  536 + while (iBcindex <= 1) {
  537 + if (oTempLp.getBc(i, iBcindex)) { // 替换存在的班次
  538 + oTempLp.setBc(i, iBcindex, _fnGenerateBc(_iZbx_lpIndex, i, iBcindex));
  539 + }
  540 + iBcindex ++;
  541 + }
  542 + iBcindex = 0;
  543 + }
  544 +
  545 + _internalLpArray[_iZbx_lpIndex] = oTempLp;
  546 +
  547 + console.log("中标线对应第" + (_iZbx_lpIndex + 1) + "个路牌");
  548 +
  549 + console.log("//---------------- 行车计划,初始化方法4 end ----------------//");
  550 + };
  551 +
  552 + //-------------------- 重要的内部方法 -----------------------//
  553 + /**
  554 + * 核心方法,利用路牌间隔纵向生成班次。
  555 + * @param iLpindex 路牌索引
  556 + * @param iQindex 圈索引
  557 + * @param iBcindex 班次索引
  558 + * @returns object InternalBcObj,失败 false
  559 + */
  560 + var _fnGenerateBc = function(iLpindex, iQindex, iBcindex) {
  561 + // 以上标线为起始点,使用路牌在不同圈,班次索引的发车间隔,计算班次
  562 + // 注意,发车间隔是指下一个班次应该距离当前班次间隔,是从下往上的
  563 +
  564 + // 1、参数验证
  565 + if (iLpindex == 0) { // 上标线的班次不需要生成
  566 + return false;
  567 + }
  568 +
  569 + // 2、计算间隔
  570 + var i;
  571 + var oLp;
  572 + var iTime = 0;
  573 + for (i = 0; i < iLpindex; i++) {
  574 + oLp = _internalLpArray[i];
  575 + iTime += oLp.fnGetVerticalIntervalTime(iQindex, iBcindex);
  576 + }
  577 +
  578 + // 3、生成班次
  579 + var _oKsbc = _internalLpArray[0].getBc(iQindex, iBcindex);
  580 + if (!_oKsbc) {
  581 + return false;
  582 + }
  583 + var _oKssj = _paramObj.addMinute(_oKsbc.getFcTimeObj(), iTime);
  584 + var _oBc = _factory.createBcObj(
  585 + _internalLpArray[iLpindex],
  586 + "normal", _oKsbc.isUp(),
  587 + 1, _oKssj, _paramObj);
  588 +
  589 + return _oBc;
  590 +
  591 + };
  592 +
  593 + /**
  594 + * 核心方法,在指定位置生成班次并添加到路牌指定位置中。
  595 + * @param lpIndex 第几个路牌
  596 + * @param qIndex 第几圈
  597 + * @param bcIndex 第几个班次
  598 + */
  599 + var _fnGenerateBcAndSetBc = function(lpIndex, qIndex, bcIndex) {
  600 + var _bcObj = _fnGenerateBc(lpIndex, qIndex, bcIndex);
  601 + if (_bcObj) {
  602 + _internalLpArray[lpIndex].setBc(qIndex, bcIndex, _bcObj);
  603 + }
  604 + };
  605 +
  606 + /**
  607 + * 获取班次列表。
  608 + * @param oIsUp 是否上行
  609 + * @param oStartTime 开始时间对象
  610 + * @returns [(InternalBcObj)]
  611 + */
  612 + var _fnGetBcList2 = function(oIsUp, oStartTime) {
  613 + var i;
  614 + var j;
  615 + var oLp;
  616 + var oBc;
  617 + var aBc = [];
  618 +
  619 + for (j = 0; j < _qCount; j++) {
  620 + for (i = 0; i < _internalLpArray.length; i++) {
  621 + oLp = _internalLpArray[i];
  622 + oBc = oLp.getBc(
  623 + j,
  624 + _qIsUp == oIsUp ? 0 : 1
  625 + );
  626 + if (oBc && oBc.getFcTimeObj().isAfter(oStartTime)) {
  627 + aBc.push(oBc);
  628 + }
  629 + }
  630 + }
  631 +
  632 + var aBcFcTime = [];
  633 + for (i = 0; i < aBc.length; i++) {
  634 + oBc = aBc[i];
  635 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
  636 + }
  637 + console.log((oIsUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
  638 +
  639 + return aBc;
  640 + };
  641 +
  642 + /**
  643 + * 获取班次列表。
  644 + * @param isUp boolean 是否上行
  645 + * @returns [(InternalBcObj)]
  646 + */
  647 + var _fnGetBcList = function(isUp) {
  648 + var i;
  649 + var j;
  650 + var oLp;
  651 + var oBc;
  652 + var aBc = [];
  653 +
  654 + for (j = 0; j < _qCount; j++) {
  655 + for (i = 0; i < _internalLpArray.length; i++) {
  656 + oLp = _internalLpArray[i];
  657 + oBc = oLp.getBc(
  658 + j,
  659 + _qIsUp == isUp ? 0 : 1
  660 + );
  661 + if (oBc) {
  662 + aBc.push(oBc);
  663 + }
  664 + }
  665 + }
  666 +
  667 + var aBcFcTime = [];
  668 + for (i = 0; i < aBc.length; i++) {
  669 + oBc = aBc[i];
  670 + aBcFcTime.push(oBc.getFcTimeObj().format("HH:mm"));
  671 + }
  672 + console.log((isUp ? "上行班次列表:" : "下行班次列表:") + aBcFcTime.join(","));
  673 +
  674 + return aBc;
  675 + };
  676 +
  677 + /**
  678 + * 查找离指定时间最近的前面的班次索引信息
  679 + * @param timeObj 查找时间
  680 + * @param isUp 是否上行
  681 + * @returns [{路牌index},{圈index},{班次index}]
  682 + */
  683 + var _fnFindUpClosedBcIndexWithTime = function(timeObj, isUp) {
  684 +
  685 + var _lpObj;
  686 + var _groupObj;
  687 + var _bcObj;
  688 + var _i;
  689 + var _j;
  690 + var timediff; // 时间差取绝对值
  691 +
  692 + var _lpIndex;
  693 + var _up_qIndex;
  694 + var _up_bIndex;
  695 +
  696 + for (_i = 0; _i < _qCount; _i++) {
  697 + for (_j = 0; _j < _internalLpArray.length; _j++) {
  698 + _lpObj = _internalLpArray[_j];
  699 + _groupObj = _lpObj.getGroup(_i);
  700 + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2();
  701 + if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的
  702 + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1);
  703 + }
  704 + if (_bcObj) {
  705 + if (timeObj.diff(_bcObj.getFcTimeObj()) >= 0) {
  706 + if (!timediff) {
  707 + timediff = timeObj.diff(_bcObj.getFcTimeObj());
  708 + _lpIndex = _j;
  709 + _up_qIndex = _i;
  710 + _up_bIndex = isUp == _qIsUp ? 0 : 1;
  711 + } else {
  712 + if (timeObj.diff(_bcObj.getFcTimeObj()) < timediff) {
  713 + timediff = timeObj.diff(_bcObj.getFcTimeObj());
  714 + _lpIndex = _j;
  715 + _up_qIndex = _i;
  716 + _up_bIndex = isUp == _qIsUp ? 0 : 1;
  717 + }
  718 + }
  719 + }
  720 + }
  721 + }
  722 + }
  723 +
  724 + if (_lpIndex == undefined) {
  725 + return false;
  726 + }
  727 +
  728 + var bcindex = [];
  729 + bcindex.push(_lpIndex);
  730 + bcindex.push(_up_qIndex);
  731 + bcindex.push(_up_bIndex);
  732 +
  733 + return bcindex;
  734 + };
  735 +
  736 + /**
  737 + * 查找离指定时间最近的后面的班次索引信息
  738 + * @param timeObj 查找时间
  739 + * @param isUp 是否上行
  740 + * @returns [{路牌index},{圈index},{班次index}]
  741 + */
  742 + var _fnFindDownClosedBcIndexWithTime = function(timeObj, isUp) {
  743 + var _lpObj;
  744 + var _groupObj;
  745 + var _bcObj;
  746 + var _i;
  747 + var _j;
  748 + var timediff; // 时间差取绝对值
  749 +
  750 + var _lpIndex;
  751 + var _down_qIndex;
  752 + var _down_bIndex;
  753 +
  754 + var flag;
  755 +
  756 + for (_i = 0; _i < _qCount; _i++) {
  757 + for (_j = 0; _j < _internalLpArray.length; _j++) {
  758 + _lpObj = _internalLpArray[_j];
  759 + _groupObj = _lpObj.getGroup(_i);
  760 + // TODO:bug
  761 + _bcObj = isUp == _qIsUp ? _groupObj.getBc1() : _groupObj.getBc2();
  762 + if (!_bcObj) { // 没有班次动态生成一个,可能生成不出的
  763 + _bcObj = _fnGenerateBc(_j, _i, isUp == _qIsUp ? 0 : 1);
  764 + }
  765 + if (_bcObj) {
  766 + //console.log("timeobj -> bcobj diff flag " +
  767 + // timeObj.format("HH:mm") + "->" +
  768 + // _bcObj.getFcTimeObj().format("HH:mm") +
  769 + // timeObj.diff(_bcObj.getFcTimeObj()) +
  770 + // (timeObj.diff(_bcObj.getFcTimeObj()) <= 0)
  771 + //);
  772 +
  773 + flag = (timeObj.diff(_bcObj.getFcTimeObj())) <= 0;
  774 +
  775 + if (flag) {
  776 + if (!timediff) {
  777 + timediff = timeObj.diff(_bcObj.getFcTimeObj());
  778 + _lpIndex = _j;
  779 + _down_qIndex = _i;
  780 + _down_bIndex = isUp == _qIsUp ? 0 : 1;
  781 + } else {
  782 + if ((timeObj.diff(_bcObj.getFcTimeObj())) > timediff) {
  783 + timediff = timeObj.diff(_bcObj.getFcTimeObj());
  784 + _lpIndex = _j;
  785 + _down_qIndex = _i;
  786 + _down_bIndex = isUp == _qIsUp ? 0 : 1;
  787 + }
  788 + }
  789 + }
  790 + }
  791 + }
  792 + }
  793 +
  794 + if (_lpIndex == undefined) {
  795 + return false;
  796 + }
  797 +
  798 + var bcindex = [];
  799 + bcindex.push(_lpIndex);
  800 + bcindex.push(_down_qIndex);
  801 + bcindex.push(_down_bIndex);
  802 +
  803 + return bcindex;
  804 + };
  805 +
  806 + /**
  807 + * 获取班次索引。
  808 + * @param oBc 班次对象
  809 + * @returns [{路牌索引},{圈索引},{班次索引}]
  810 + */
  811 + var _fnGetBcIndex = function(oBc) {
  812 + // 路牌索引
  813 + var i;
  814 + var iLpIndex;
  815 + for (i = 0; i < _internalLpArray.length; i++) {
  816 + if (_internalLpArray[i]._$$_orign_lp_obj == oBc._$$_internal_lp_obj._$$_orign_lp_obj) {
  817 + iLpIndex = i;
  818 + break;
  819 + }
  820 + }
  821 + // 圈索引
  822 + var j;
  823 + var iGroupIndex;
  824 + var bFlag = false;
  825 + for (i = 0; i < _internalLpArray.length; i++) {
  826 + if (bFlag) {
  827 + break;
  828 + }
  829 + for (j = 0; j < _qCount; j++) {
  830 + if (_internalLpArray[i]._$_groupBcArray[j] == oBc._$$_internal_group_obj) {
  831 + iGroupIndex = j;
  832 + bFlag = true;
  833 + break;
  834 + }
  835 + }
  836 + }
  837 + // 班次索引
  838 + var iBcIndex = _qIsUp == oBc.isUp() ? 0 : 1;
  839 +
  840 + if (iLpIndex == undefined) {
  841 + return null;
  842 + } else {
  843 + return [].concat(iLpIndex, iGroupIndex, iBcIndex);
  844 + }
  845 +
  846 + };
  847 +
  848 + return {
  849 + //------------- 布局初始化方法 ------------//
  850 + /**
  851 + * 初始化数据,使用标线初始化
  852 + */
  853 + fnInitDataWithBxLayout: function() {
  854 + // 初始化布局1,构造上标线,计算圈数,把上标线数据放入第一个路牌中
  855 + _fnInitFun1();
  856 + // 初始化布局2,从上标线的某个班次开始,构造所有路牌的早高峰班次,晚高峰班次,计算路牌在各个圈中的间隔
  857 + _fnInitFun2();
  858 + // 初始化布局3,计算连班分班路牌分布
  859 + _fnInitFun3();
  860 + // 初始化布局4,计算中标线位置
  861 + _fnInitFun4();
  862 +
  863 + },
  864 +
  865 + /**
  866 + * 调整高峰班次,
  867 + * 初始化生成早高峰,晚高峰班次并不准确,因为根据高峰时间段,并不在一个完整圈内,应该是在两个或多个圈之间
  868 + * 当初始化定好布局后(上标线,中标线),然后确定每个路牌的班型(连班,分班,5休2分班)后
  869 + * 然后重新计算框在高峰时间段内的班次索引,不足的添加,之前多加的删除(只删除分班路牌上的)
  870 + * @param isZgf 是否早高峰
  871 + * @param isUp 是否上行
  872 + */
  873 + fnAdjustGfbc : function(isZgf, isUp) {
  874 + var oStartTime; // 开始时间
  875 + var oEndTime; // 结束时间
  876 + var aStartBcIndex; // 开始班次索引
  877 + var aEndBcIndex; // 结束班次索引
  878 +
  879 + oStartTime = isZgf ? _paramObj.getMPeakStartTimeObj() : _paramObj.getEPeakStartTimeObj();
  880 + oEndTime = isZgf ? _paramObj.getMPeakEndTimeObj() : _paramObj.getEPeakEndTimeObj();
  881 +
  882 + aStartBcIndex = _fnFindUpClosedBcIndexWithTime(oStartTime, isUp);
  883 + aEndBcIndex = _fnFindDownClosedBcIndexWithTime(oEndTime, isUp);
  884 +
  885 + var iLpIndex;
  886 + var iQIndex;
  887 + var iBcIndex;
  888 + var iQInternelCount; // 高峰时间段中间包含的圈数
  889 + var i;
  890 + var j;
  891 +
  892 + var oLp;
  893 +
  894 + if (aStartBcIndex && aEndBcIndex) {
  895 + iLpIndex = aStartBcIndex[0];
  896 + iQIndex = aStartBcIndex[1];
  897 + iBcIndex = aStartBcIndex[2];
  898 +
  899 + // 处理头
  900 + // 删除头部多余班次
  901 + for (j = 0; j < iLpIndex; j++) {
  902 + oLp = _internalLpArray[j];
  903 + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {
  904 + oLp.removeBc(iQIndex, iBcIndex);
  905 + }
  906 + }
  907 +
  908 + for (j = iLpIndex; j < _internalLpArray.length; j++) {
  909 + oLp = _internalLpArray[j];
  910 + if (!oLp.getBc(iQIndex, iBcIndex)) {
  911 + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);
  912 + }
  913 + }
  914 +
  915 + // 处理中间
  916 + iQInternelCount = aEndBcIndex[1] - aStartBcIndex[1] - 1;
  917 + for (i = 1; i <= iQInternelCount; i++) {
  918 + oLp = _internalLpArray[iQIndex + i];
  919 +
  920 + if (!oLp.getBc(iQIndex + i, iBcIndex)) {
  921 + _fnGenerateBcAndSetBc(i, iQIndex + i, iBcIndex);
  922 + }
  923 + }
  924 +
  925 + // 处理尾部
  926 + iLpIndex = aEndBcIndex[0];
  927 + iQIndex = aEndBcIndex[1];
  928 + iBcIndex = aEndBcIndex[2];
  929 +
  930 + // 删除尾部多余的班次
  931 + for (j = iLpIndex; j < _internalLpArray.length; j++) {
  932 + oLp = _internalLpArray[j];
  933 + if (oLp.isBxFb() && oLp.getBc(iQIndex, iBcIndex)) {
  934 + oLp.removeBc(iQIndex, iBcIndex);
  935 + }
  936 + }
  937 +
  938 + if (aStartBcIndex[1] != aEndBcIndex[1]) { // 指定时间范围跨圈
  939 + for (j = 0; j < iLpIndex; j++) {
  940 + oLp = _internalLpArray[j];
  941 + if (!oLp.getBc(iQIndex, iBcIndex)) {
  942 + _fnGenerateBcAndSetBc(j, iQIndex, iBcIndex);
  943 + }
  944 + }
  945 + } else {
  946 + // 不跨圈,不用处理,处理头的时候已经加了
  947 + }
  948 +
  949 + }
  950 +
  951 + },
  952 +
  953 + /**
  954 + * 按照营运时间要求补充班次,
  955 + * 早高峰7:45分以前出场运营,
  956 + * 晚高峰16:10分以前出场运营
  957 + */
  958 + fnCalcuLpBc_yy: function() {
  959 + // 补班次的时候,针对的是分班班型
  960 + var i;
  961 + var _oLp;
  962 + var _oBc;
  963 + var _aMinBcIndex;
  964 + var _aMaxBcIndex;
  965 +
  966 + var _qIndex;
  967 + var _bIndex;
  968 +
  969 + var _zgfCDate = _paramObj.toTimeObj("7:45");
  970 + var _wgfCDate = _paramObj.toTimeObj("16:10");
  971 + var _ccsj;
  972 +
  973 + for (i = 0; i < _internalLpArray.length; i++) {
  974 + _oLp = _internalLpArray[i];
  975 + if (_oLp.isBxFb()) { // 分班路牌
  976 + // 早高峰部分
  977 + _aMinBcIndex = _oLp.getMinBcObjPosition();
  978 + _qIndex = _aMinBcIndex[0];
  979 + _bIndex = _aMinBcIndex[1];
  980 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  981 + if (_qIsUp) {
  982 + _ccsj = _bIndex == 0 ?
  983 + _paramObj.getUpOutTime() :
  984 + _paramObj.getDownOutTime();
  985 + } else {
  986 + _ccsj = _bIndex == 0 ?
  987 + _paramObj.getDownOutTime() :
  988 + _paramObj.getUpOutTime();
  989 + }
  990 + if (_zgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  991 + _fnGenerateBcAndSetBc(
  992 + i,
  993 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  994 + _bIndex == 0 ? 1 : 0
  995 + )
  996 + }
  997 +
  998 + // 晚高峰部分
  999 + _aMaxBcIndex = _oLp.getMaxBcObjPosition();
  1000 + _qIndex = _aMaxBcIndex[0];
  1001 + _bIndex = _aMaxBcIndex[1];
  1002 + _oBc = _oLp.getBc(
  1003 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  1004 + _bIndex == 0 ? 1 : 0
  1005 + );
  1006 + if (!_oBc) { // 前一个班次不存在,再判定加不加
  1007 + _oBc = _oLp.getBc(_qIndex, _bIndex);
  1008 + if (_qIsUp) {
  1009 + _ccsj = _bIndex == 0 ?
  1010 + _paramObj.getUpOutTime() :
  1011 + _paramObj.getDownOutTime();
  1012 + } else {
  1013 + _ccsj = _bIndex == 0 ?
  1014 + _paramObj.getDownOutTime() :
  1015 + _paramObj.getUpOutTime();
  1016 + }
  1017 + if (_wgfCDate.isBefore(_paramObj.addMinute(_oBc.getFcTimeObj(), -_ccsj))) {
  1018 + _fnGenerateBcAndSetBc(
  1019 + i,
  1020 + _bIndex == 0 ? _qIndex - 1 : _qIndex,
  1021 + _bIndex == 0 ? 1 : 0
  1022 + )
  1023 + }
  1024 + }
  1025 + }
  1026 + }
  1027 + },
  1028 +
  1029 + /**
  1030 + * 补充做5休2的班型班次。
  1031 + * 1、确认5_2班型大致多少圈(小数点过.7进位)
  1032 + * 2、获取当前5_2两端车次链的信息,每段的班次数目,还差几个班次没加
  1033 + * 3、如果前面的车次链班次少,则从前面的车次链开始加
  1034 + * 4、如果车次链班次数一样,从从后面的车次链开始加
  1035 + * 5、加班次时都是往车次链前方加
  1036 + * 6、如果前面车次链不能再加班次了,从后面车次链加
  1037 + */
  1038 + fnCalcuLpBx_5_2: function() {
  1039 + // 计算做5休2班型所需的班次数
  1040 + var iBxBcount = _aBxDesc[6].fBcCount;
  1041 + if (iBxBcount - Math.floor(iBxBcount) > 0.7) {
  1042 + iBxBcount = Math.floor(iBxBcount) + 1;
  1043 + } else {
  1044 + iBxBcount = Math.floor(iBxBcount);
  1045 + }
  1046 +
  1047 + var i;
  1048 + var j;
  1049 + var oLp;
  1050 + var iAddBcCount;
  1051 + var oBcChain1;
  1052 + var oBcChain2;
  1053 + var iQindex;
  1054 + var iBindex;
  1055 +
  1056 + for (i = 0; i < _internalLpArray.length; i++) {
  1057 + oLp = _internalLpArray[i];
  1058 + if (oLp.isBxFb5_2()) {
  1059 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  1060 + for (j = 1; j <= iAddBcCount; j++) {
  1061 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  1062 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  1063 +
  1064 + if (oBcChain1.bcount < oBcChain2.bcount) {
  1065 + iQindex = oBcChain1.s_b == 0 ? oBcChain1.s_q - 1 : oBcChain1.s_q;
  1066 + iBindex = oBcChain1.s_b == 0 ? 1 : 0;
  1067 + // 往车次链往前不能加,就往后加
  1068 + if (_fnGenerateBc(i, iQindex, iBindex)) {
  1069 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1070 + } else {
  1071 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  1072 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  1073 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1074 + }
  1075 +
  1076 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  1077 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  1078 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  1079 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1080 + } else {
  1081 + iQindex = oBcChain2.s_b == 0 ? oBcChain2.s_q - 1 : oBcChain2.s_q;
  1082 + iBindex = oBcChain2.s_b == 0 ? 1 : 0;
  1083 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1084 + }
  1085 + }
  1086 + }
  1087 + }
  1088 +
  1089 + },
  1090 +
  1091 + /**
  1092 + * 补其他分班班型班次。
  1093 + * 从车次链的后面开始加
  1094 + */
  1095 + fnCalcuLpBx_other: function() {
  1096 + // TODO:根据上标线的首班时间确定班型,小于05:59的做一休一,否则做二休一
  1097 + var oSt = _qIsUp ? _paramObj.getUpFirstDTimeObj() : _paramObj.getDownFirstDTimeObj();
  1098 + var iBxIndex = 4;
  1099 + if (oSt.isBefore(_paramObj.toTimeObj("05:59"))) {
  1100 + iBxIndex = 5;
  1101 + }
  1102 + // 计算做5休2班型所需的班次数
  1103 + var iQBcount = _aBxDesc[iBxIndex].fQCount;
  1104 + var iBxBcount = Math.round(iQBcount) * 2;
  1105 +
  1106 + var i;
  1107 + var j;
  1108 + var oLp;
  1109 + var iAddBcCount;
  1110 + var oBcChain1;
  1111 + var oBcChain2;
  1112 + var iQindex;
  1113 + var iBindex;
  1114 +
  1115 + for (i = 0; i < _internalLpArray.length; i++) {
  1116 + oLp = _internalLpArray[i];
  1117 + if (oLp.isBxFb() && !oLp.isBxFb5_2()) {
  1118 + iAddBcCount = iBxBcount - oLp.getBcArray().length; // 需要添加的班次数
  1119 + for (j = 1; j <= iAddBcCount; j++) {
  1120 + oBcChain1 = oLp.fnGetBcChainInfo(0);
  1121 + oBcChain2 = oLp.fnGetBcChainInfo(1);
  1122 +
  1123 + if (oBcChain1.bcount < oBcChain2.bcount) {
  1124 + iQindex = oBcChain1.e_b == 0 ? oBcChain1.e_q : oBcChain1.e_q + 1;
  1125 + iBindex = oBcChain1.e_b == 0 ? 1 : 0;
  1126 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1127 + } else if (oBcChain1.bcount > oBcChain2.bcount) {
  1128 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  1129 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  1130 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1131 + } else {
  1132 + iQindex = oBcChain2.e_b == 0 ? oBcChain2.e_q : oBcChain2.e_q + 1;
  1133 + iBindex = oBcChain2.e_b == 0 ? 1 : 0;
  1134 + _fnGenerateBcAndSetBc(i, iQindex, iBindex);
  1135 + }
  1136 + }
  1137 + }
  1138 + }
  1139 +
  1140 + },
  1141 +
  1142 + /**
  1143 + * 补充连班路牌班次。
  1144 + * 1、上标线,中标线中间的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向上标线起始班次靠拢
  1145 + * 2、中标线以下的连班路牌班次从早高峰班次一直拉到底,从早高峰班次向中标线起始班次靠拢
  1146 + */
  1147 + fnCalcuLpBx_lb: function() {
  1148 + // 补充连班的班次,参照上标线,中标线补充不足的班次
  1149 +
  1150 + var aLbLpindexes = []; // 除上标线,中标线的连班路牌索引
  1151 + var i;
  1152 + for (i = 0; i < _internalLpArray.length; i++) {
  1153 + if (_internalLpArray[i].isBxLb() && i != 0 && i != _iZbx_lpIndex) {
  1154 + aLbLpindexes.push(i);
  1155 + }
  1156 + }
  1157 +
  1158 + var oEndsj = // 结束时间
  1159 + _paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj()) ?
  1160 + _paramObj.getDownLastDTimeObj() :
  1161 + _paramObj.getUpLastDtimeObj();
  1162 +
  1163 + var oLp;
  1164 + var aMinbcPos;
  1165 + var oBc;
  1166 + var j;
  1167 + var iTempBcIndex;
  1168 +
  1169 + // 1、从最小班次开始,往后补充班次
  1170 + for (i = 0; i < aLbLpindexes.length; i++) {
  1171 + oLp = _internalLpArray[aLbLpindexes[i]];
  1172 +
  1173 + // 最小班次索引
  1174 + aMinbcPos = oLp.getMinBcObjPosition();
  1175 + // 使用纵向分隔补充班次,从最小班次向后补
  1176 + iTempBcIndex = aMinbcPos[1] == 0 ? 1 : 0;
  1177 + j = iTempBcIndex == 0 ? aMinbcPos[0] + 1 : aMinbcPos[0];
  1178 +
  1179 + while (j < _qCount) {
  1180 + while (iTempBcIndex <= 1) {
  1181 + oBc = _fnGenerateBc(aLbLpindexes[i], j, iTempBcIndex);
  1182 + if (oBc &&
  1183 + oBc.getFcTimeObj().isBefore(oEndsj) ) {
  1184 + oLp.setBc(j, iTempBcIndex, oBc);
  1185 + }
  1186 + iTempBcIndex++;
  1187 + }
  1188 + iTempBcIndex = 0;
  1189 + j++;
  1190 + }
  1191 +
  1192 + }
  1193 +
  1194 + // 2、上标线中标线之间的路牌,从最小的班次往前补充班次
  1195 +
  1196 + // 还要补充缺失的班次,差上标线几个班次要往前补上
  1197 + var iBccount;
  1198 + var iQindex;
  1199 + var iBindex;
  1200 + // 补上标线到中标线之间的连班路牌的班次
  1201 + for (i = 0; i < aLbLpindexes.length; i++) {
  1202 + if (aLbLpindexes[i] > 0 && aLbLpindexes[i] < _iZbx_lpIndex) {
  1203 + oLp = _internalLpArray[aLbLpindexes[i]];
  1204 + aMinbcPos = oLp.getMinBcObjPosition();
  1205 + iQindex = aMinbcPos[0];
  1206 + iBindex = aMinbcPos[1];
  1207 + iBccount = (iQindex - 1) * 2 + iBindex; // 距离上标线起始站点差几个班次
  1208 + for (j = 0; j < iBccount; j++) {
  1209 + if (iBindex == 0) {
  1210 + iQindex --;
  1211 + iBindex = 1;
  1212 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1213 + } else if (iBindex == 1) {
  1214 + iBindex --;
  1215 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1216 + }
  1217 + }
  1218 +
  1219 + }
  1220 +
  1221 + }
  1222 +
  1223 + // 3、中标线之后的路牌,从最小的班次往前补充班次
  1224 +
  1225 + // 补中标线以下的连班路牌的班次
  1226 + for (i = 0; i < aLbLpindexes.length; i++) {
  1227 + if (aLbLpindexes[i] > _iZbx_lpIndex) {
  1228 + oLp = _internalLpArray[aLbLpindexes[i]];
  1229 + aMinbcPos = oLp.getMinBcObjPosition();
  1230 + iQindex = aMinbcPos[0];
  1231 + iBindex = aMinbcPos[1];
  1232 + iBccount = (iQindex - 0) * 2 + iBindex - 1; // 距离上标线起始站点差几个班次
  1233 + for (j = 0; j < iBccount; j++) {
  1234 + if (iBindex == 0) {
  1235 + iQindex --;
  1236 + iBindex = 1;
  1237 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1238 + } else if (iBindex == 1) {
  1239 + iBindex --;
  1240 + _fnGenerateBcAndSetBc(aLbLpindexes[i], iQindex, iBindex);
  1241 + }
  1242 + }
  1243 + }
  1244 + }
  1245 +
  1246 + },
  1247 +
  1248 + /**
  1249 + * 计算末班车。
  1250 + * 1、将上下行拉成上下行两个班次列表(包括标记班次)
  1251 + * 2、分别找出离末班车发车时间最近的班次,并替换时间
  1252 + * 3、删除之后的班次
  1253 + */
  1254 + fnCalcuLastBc: function() {
  1255 + var i;
  1256 + var iTimeDiff;
  1257 + var iTempTime;
  1258 + var aBc;
  1259 + var oLastBcTime;
  1260 + var oLastBcIsUp;
  1261 + var iModifyIndex;
  1262 +
  1263 + // 查找末班车早的末班车时间和方向
  1264 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1265 + oLastBcTime = _paramObj.getUpLastDtimeObj();
  1266 + oLastBcIsUp = true;
  1267 + } else {
  1268 + oLastBcTime = _paramObj.getDownLastDTimeObj();
  1269 + oLastBcIsUp = false;
  1270 + }
  1271 +
  1272 + // 确定早的末班车时间
  1273 + aBc = _fnGetBcList(oLastBcIsUp);
  1274 + for (i = 0; i < aBc.length; i++) {
  1275 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1276 + if (iTimeDiff == undefined) {
  1277 + iTimeDiff = iTempTime;
  1278 + iModifyIndex = i;
  1279 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1280 + iTimeDiff = iTempTime;
  1281 + iModifyIndex = i;
  1282 + }
  1283 + }
  1284 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1285 + aBc[iModifyIndex].fnSetDelFlag(false);
  1286 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1287 + _qIsUp == oLastBcIsUp ?
  1288 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1289 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1290 + }
  1291 +
  1292 + // 查找末班车晚的末班车时间和方向
  1293 + if (_paramObj.getUpLastDtimeObj().isBefore(_paramObj.getDownLastDTimeObj())) {
  1294 + oLastBcTime = _paramObj.getDownLastDTimeObj();
  1295 + oLastBcIsUp = false;
  1296 + } else {
  1297 + oLastBcTime = _paramObj.getUpLastDtimeObj();
  1298 + oLastBcIsUp = true;
  1299 + }
  1300 + // 确定晚的末班车时间
  1301 + aBc = _fnGetBcList(oLastBcIsUp);
  1302 + var oBc;
  1303 + var aBcIndex;
  1304 + var iLpIndex;
  1305 + var iQIndex;
  1306 + var iBcIndex;
  1307 +
  1308 + iTimeDiff = undefined;
  1309 + for (i = 0; i < aBc.length; i++) {
  1310 + oBc = aBc[i];
  1311 + aBcIndex = _fnGetBcIndex(oBc);
  1312 +
  1313 + iLpIndex = aBcIndex[0];
  1314 + iQIndex = aBcIndex[2] == 0 ? aBcIndex[1] -1 : aBcIndex[1];
  1315 + iBcIndex = aBcIndex[2] == 0 ? 1 : 0;
  1316 +
  1317 + if (!_internalLpArray[iLpIndex].getBc(iQIndex, iBcIndex)) {
  1318 + continue;
  1319 + }
  1320 +
  1321 + iTempTime = oLastBcTime.diff(aBc[i].getFcTimeObj(), "m");
  1322 + if (iTimeDiff == undefined) {
  1323 + iTimeDiff = iTempTime;
  1324 + iModifyIndex = i;
  1325 + } else if (Math.abs(iTempTime) <= Math.abs(iTimeDiff)) {
  1326 + iTimeDiff = iTempTime;
  1327 + iModifyIndex = i;
  1328 + }
  1329 + }
  1330 + aBc[iModifyIndex].addMinuteToFcsj(iTimeDiff); // 替换成末班车时间
  1331 + aBc[iModifyIndex].fnSetDelFlag(false);
  1332 + for (i = iModifyIndex + 1; i < aBc.length; i++) { // 删除多余班次
  1333 + _qIsUp == oLastBcIsUp ?
  1334 + aBc[i]._$$_internal_group_obj.setBc1(undefined) :
  1335 + aBc[i]._$$_internal_group_obj.setBc2(undefined);
  1336 + }
  1337 +
  1338 + },
  1339 +
  1340 + /**
  1341 + * 添加吃饭班次。
  1342 + */
  1343 + fnCalcuEatBc: function() {
  1344 + // 吃午饭时间范围,10:15 到 12:15
  1345 + // 吃晚饭时间范围,18:00 到 19:00
  1346 +
  1347 + if (!_paramObj.fnIsEat()) {
  1348 + return;
  1349 + }
  1350 +
  1351 + // 午饭index
  1352 + var aLEIndex;
  1353 + // 晚饭index
  1354 + var aDEIndex;
  1355 +
  1356 + // 所有吃饭都默认在一个方向,两个方向暂时不考虑
  1357 + if (_paramObj.fnIsUpEat()) {
  1358 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), true, false);
  1359 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), true, false);
  1360 + } else {
  1361 + aLEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("10:15"), false, true);
  1362 + aDEIndex = _internalLpArray[0].getQBcIndexWithFcTime(_paramObj.toTimeObj("18:00"), false, true);
  1363 + }
  1364 +
  1365 + // 午饭第几圈,第几个班次
  1366 + var iLEQIndex = aLEIndex[0];
  1367 + var iLEBIndex = aLEIndex[1];
  1368 + // 晚饭第几圈,第几个班次
  1369 + var iDEQIndex = aDEIndex[0];
  1370 + var iDEBIndex = aDEIndex[1];
  1371 +
  1372 + // 注意,本模型只有连班才有吃饭
  1373 +
  1374 + var i;
  1375 + var oLp;
  1376 + var aLbIndex = []; // 连班班型的路牌索引
  1377 + for (i = 0; i < _internalLpArray.length; i++) {
  1378 + oLp = _internalLpArray[i];
  1379 + if (oLp.isBxLb()) {
  1380 + aLbIndex.push(i);
  1381 + }
  1382 + }
  1383 +
  1384 + var iLTime;
  1385 + var iDtime;
  1386 + var j;
  1387 + for (i = 0; i < aLbIndex.length; i++) {
  1388 + oLp = _internalLpArray[aLbIndex[i]];
  1389 +
  1390 + // 午饭
  1391 + iLTime = oLp.fnAddEatBc(iLEQIndex, iLEBIndex, _factory, _paramObj);
  1392 + // 晚饭
  1393 + iDtime = oLp.fnAddEatBc(iDEQIndex, iDEBIndex, _factory, _paramObj);
  1394 +
  1395 + if (i == aLbIndex.length - 1) {
  1396 + for (j = aLbIndex[i]; j < _internalLpArray.length; j++) {
  1397 + oLp = _internalLpArray[j];
  1398 + if (oLp.isBxFb()) { // 5休2班型不调整
  1399 + // 修正午饭之后路牌班次的发车时间
  1400 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1401 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1402 + }
  1403 + }
  1404 + } else {
  1405 + for (j = aLbIndex[i]; j < aLbIndex[i + 1]; j++) {
  1406 + oLp = _internalLpArray[j];
  1407 + if (oLp.isBxFb()) {
  1408 + // 修正午饭之后路牌班次的发车时间
  1409 + oLp.fnAddMinuteToBcFcsj(iLEQIndex, iLEBIndex, iLTime);
  1410 + oLp.fnAddMinuteToBcFcsj(iDEQIndex, iDEBIndex, iDtime);
  1411 + }
  1412 + }
  1413 + }
  1414 + }
  1415 +
  1416 + },
  1417 +
  1418 + /**
  1419 + * 补每个路牌的其他班次(进出场,例保班次)。
  1420 + */
  1421 + fnCalcuOtherBc: function() {
  1422 + var i;
  1423 + var _lpObj;
  1424 + var _minBcIndex;
  1425 + var _maxBcIndex;
  1426 + var _minBc;
  1427 + var _maxBc;
  1428 + var _otherbc = [];
  1429 + var _oFbbc;
  1430 +
  1431 + for (i = 0; i < _internalLpArray.length; i++) {
  1432 + _lpObj = _internalLpArray[i];
  1433 + _minBcIndex = _lpObj.getMinBcObjPosition();
  1434 + _maxBcIndex = _lpObj.getMaxBcObjPosition();
  1435 + _minBc = _lpObj.getBc(_minBcIndex[0], _minBcIndex[1]);
  1436 + _maxBc = _lpObj.getBc(_maxBcIndex[0], _maxBcIndex[1]);
  1437 +
  1438 + _otherbc = [];
  1439 + _otherbc.push(_factory.createBcObj(
  1440 + _lpObj, "bd", true, 1,
  1441 + _minBc.getFcTimeObj(),
  1442 + _paramObj
  1443 + ));
  1444 + _otherbc.push(_factory.createBcObj(
  1445 + _lpObj, "out", true, 1,
  1446 + _minBc.getFcTimeObj(),
  1447 + _paramObj
  1448 + ));
  1449 +
  1450 + _maxBc.setArrTimeObj(_paramObj.addMinute(_maxBc.getFcTimeObj(), _maxBc.getBcTime()));
  1451 + _maxBc.setStopTime(0);
  1452 + _otherbc.push(_factory.createBcObj(
  1453 + _lpObj, "in", true, 1,
  1454 + _maxBc.getArrTimeObj(),
  1455 + _paramObj
  1456 + ));
  1457 + _otherbc.push(_factory.createBcObj(
  1458 + _lpObj, "lc", true, 1,
  1459 + _maxBc.getArrTimeObj(),
  1460 + _paramObj
  1461 + ));
  1462 +
  1463 + // 5休2分班出场例保班次
  1464 + if (_lpObj.isBxFb5_2()) {
  1465 + _oFbbc = _lpObj.getBc(
  1466 + _lpObj.fnGetBcChainInfo(1)["s_q"],
  1467 + _lpObj.fnGetBcChainInfo(1)["s_b"]
  1468 + );
  1469 +
  1470 + _otherbc.push(_factory.createBcObj(
  1471 + _lpObj, "bd", true, 1,
  1472 + _oFbbc.getFcTimeObj(),
  1473 + _paramObj
  1474 + ));
  1475 + _otherbc.push(_factory.createBcObj(
  1476 + _lpObj, "out", true, 1,
  1477 + _oFbbc.getFcTimeObj(),
  1478 + _paramObj
  1479 + ));
  1480 + }
  1481 +
  1482 + _lpObj.addOtherBcArray(_otherbc);
  1483 + }
  1484 +
  1485 + },
  1486 +
  1487 + /**
  1488 + * 祛除上标线开头的删除标记的班次。
  1489 + */
  1490 + fnRemoveDelFirstFlagBc: function() {
  1491 + var oLp = _internalLpArray[0];
  1492 + var aMinBcIndex = oLp.getMinBcObjPosition();
  1493 + oLp.removeBc(aMinBcIndex[0], aMinBcIndex[1]);
  1494 + },
  1495 + /**
  1496 + * 祛除上标线结尾的删除标记的班次。
  1497 + */
  1498 + fnRemoveDelLastFlagBc: function() {
  1499 + var oLp = _internalLpArray[0];
  1500 + var aMaxBcIndex = oLp.getMaxBcObjPosition();
  1501 + if (oLp.getBc(aMaxBcIndex[0], aMaxBcIndex[1]).fnIsDelFlag()) {
  1502 + oLp.removeBc(aMaxBcIndex[0], aMaxBcIndex[1]);
  1503 + }
  1504 + },
  1505 +
  1506 + /**
  1507 + * 调整路牌班次间隔(核准周转时间,停站时间)。
  1508 + * @param iFre int 迭代次数
  1509 + */
  1510 + fnAdjustLpBcInterval: function(iFre) {
  1511 + if (iFre > 0) {
  1512 + for (var i = 0; i < _internalLpArray.length; i++) {
  1513 + _internalLpArray[i].fnAdjustBcInterval(
  1514 + this.fnCalcuAverPeakStopTime(),
  1515 + this.fnCalcuAverTroughStopTime(),
  1516 + _paramObj);
  1517 + }
  1518 +
  1519 + this.fnAdjustLpBcInterval(iFre - 1);
  1520 + }
  1521 + },
  1522 +
  1523 + /**
  1524 + * 调整班次间隔。
  1525 + * @param bIsUp 是否上行
  1526 + * @param oStartTime 开始时间对象
  1527 + * @param iFre 迭代次数
  1528 + */
  1529 + fnAdjustBcInterval2_: function(bIsUp, oStartTime, iFre) {
  1530 + if (iFre > 0) {
  1531 + var aBc = _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表
  1532 + aBc.sort(function(o1, o2) {
  1533 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1534 + return -1;
  1535 + } else {
  1536 + return 1;
  1537 + }
  1538 + });
  1539 + var i;
  1540 + var j;
  1541 +
  1542 + var iBcCountOfGroup = 3; // 3个班次取一次计算
  1543 + var aBcOfGroup; // 3个班次列表
  1544 + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔
  1545 +
  1546 + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) {
  1547 + aBcOfGroup = [];
  1548 + aBcIntervalOfGroup = [];
  1549 + for (j = i; j < i + iBcCountOfGroup; j++) {
  1550 + aBcOfGroup.push(aBc[j]);
  1551 + }
  1552 +
  1553 + for (j = 0; j < aBcOfGroup.length; j++) {
  1554 + if (j < aBcOfGroup.length - 1) {
  1555 + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff(
  1556 + aBcOfGroup[j].getFcTimeObj(), "m"));
  1557 + }
  1558 + }
  1559 +
  1560 + if (aBcIntervalOfGroup[0] < 19) {
  1561 + aBcOfGroup[1].addMinuteToFcsj(1);
  1562 + } else if (aBcIntervalOfGroup[0] > 20) {
  1563 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1564 + } else {
  1565 + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1566 + //continue;
  1567 + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1568 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1569 + } else {
  1570 + aBcOfGroup[1].addMinuteToFcsj(1);
  1571 + }
  1572 + }
  1573 +
  1574 + }
  1575 +
  1576 + this.fnAdjustBcInterval2(bIsUp, oStartTime, iFre - 1);
  1577 + }
  1578 + },
  1579 +
  1580 + /**
  1581 + * 调整班次间隔。
  1582 + * @param boolean isUp 是否上行
  1583 + * @param oStartTime 开始时间对象
  1584 + * @param fre int 迭代次数
  1585 + */
  1586 + fnAdjustBcInterval: function(isUp, oStartTime, fre) {
  1587 + if (fre > 0) {
  1588 + var aBc = !oStartTime ? _fnGetBcList(isUp) : _fnGetBcList2(isUp, oStartTime); // 指定方向的班次列表
  1589 +
  1590 + aBc.sort(function(o1, o2) {
  1591 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1592 + return -1;
  1593 + } else {
  1594 + return 1;
  1595 + }
  1596 + });
  1597 +
  1598 + var i;
  1599 + var j;
  1600 +
  1601 + var iBcCountOfGroup = 3; // 3个班次取一次计算
  1602 + var aBcOfGroup; // 3个班次列表
  1603 + var aBcIntervalOfGroup; // 班次间隔列表,如:3个班次,2个间隔
  1604 + var oBcFcTime; // 班次发车时间
  1605 +
  1606 + for (i = 0; i <= aBc.length - iBcCountOfGroup; i++) {
  1607 + aBcOfGroup = [];
  1608 + aBcIntervalOfGroup = [];
  1609 + for (j = i; j < i + iBcCountOfGroup; j++) {
  1610 + aBcOfGroup.push(aBc[j]);
  1611 + }
  1612 +
  1613 + for (j = 0; j < aBcOfGroup.length; j++) {
  1614 + if (j < aBcOfGroup.length - 1) {
  1615 + aBcIntervalOfGroup.push(aBcOfGroup[j + 1].getFcTimeObj().diff(
  1616 + aBcOfGroup[j].getFcTimeObj(), "m"));
  1617 + }
  1618 + }
  1619 +
  1620 + // 判定规则
  1621 + oBcFcTime = aBcOfGroup[1].getFcTimeObj();
  1622 +
  1623 + // 第一个班次发车时间不动,根据间隔,调整中间一个班次
  1624 + // 如果3个班次2个间隔时间差1分钟,不调整
  1625 + // 如果第一个间隔大,调整第二个班次往前1分钟
  1626 + // 如果第二个间隔大,调整第二个班次往后1分钟
  1627 +
  1628 + if (_paramObj.isTroughBc(oBcFcTime) &&
  1629 + aBcIntervalOfGroup[0] > _paramObj.getTroughMaxFcjx()) {
  1630 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1631 + }
  1632 +
  1633 + //else if (_paramObj.isMPeakBc(oBcFcTime) &&
  1634 + // aBcIntervalOfGroup[0] < _paramObj.getMPeakMinFcjx()) {
  1635 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1636 + //} else if (_paramObj.isMPeakBc(oBcFcTime) &&
  1637 + // aBcIntervalOfGroup[0] > _paramObj.getMPeakMaxFcjx()) {
  1638 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1639 + //} else if (_paramObj.isEPeakBc(oBcFcTime) &&
  1640 + // aBcIntervalOfGroup[0] < _paramObj.getEPeakMinFcjx()) {
  1641 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1642 + //} else if (_paramObj.isEPeakBc(oBcFcTime) &&
  1643 + // aBcIntervalOfGroup[0] > _paramObj.getEPeakMaxFcjx()) {
  1644 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1645 + //}
  1646 +
  1647 +
  1648 + else {
  1649 + if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1650 + //continue;
  1651 + } else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1652 + aBcOfGroup[1].addMinuteToFcsj(-1);
  1653 + } else {
  1654 + aBcOfGroup[1].addMinuteToFcsj(1);
  1655 + }
  1656 + }
  1657 +
  1658 + //if (Math.abs(aBcIntervalOfGroup[0] - aBcIntervalOfGroup[1]) <= 1) {
  1659 + // //continue;
  1660 + //} else if (aBcIntervalOfGroup[0] > aBcIntervalOfGroup[1]) {
  1661 + // aBcOfGroup[1].addMinuteToFcsj(-1);
  1662 + //} else {
  1663 + // aBcOfGroup[1].addMinuteToFcsj(1);
  1664 + //}
  1665 +
  1666 +
  1667 + }
  1668 +
  1669 + this.fnAdjustBcInterval(isUp, oStartTime, fre - 1);
  1670 + }
  1671 +
  1672 + },
  1673 +
  1674 + /**
  1675 + * 调整班次间隔(平均间隔)。
  1676 + * @param bIsUp 是否上行
  1677 + * @param oStartTime 开始时间对象
  1678 + */
  1679 + fnAdjustBcInterval2_avg: function(bIsUp, oStartTime) {
  1680 + var aBc = !oStartTime ? _fnGetBcList(bIsUp) : _fnGetBcList2(bIsUp, oStartTime); // 指定方向的班次列表
  1681 + aBc.sort(function(o1, o2) {
  1682 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1683 + return -1;
  1684 + } else {
  1685 + return 1;
  1686 + }
  1687 + });
  1688 +
  1689 + var j;
  1690 + var iCount = aBc.length - 1;
  1691 + var iC1 = Math.floor(aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") / iCount);
  1692 + var iC2 = aBc[aBc.length - 1].getFcTimeObj().diff(aBc[0].getFcTimeObj(), "m") % iCount;
  1693 + var iTempTime;
  1694 +
  1695 + for (j = 0; j < iCount - iC2; j++) {
  1696 + iTempTime = aBc[j + 1].getFcTimeObj().diff(aBc[j].getFcTimeObj(), "m");
  1697 + aBc[j + 1].addMinuteToFcsj(iC1 - iTempTime);
  1698 + }
  1699 + for (j = 0; j < iC2; j++) {
  1700 + iTempTime = aBc[iCount - iC2 + j + 1].getFcTimeObj().diff(aBc[iCount - iC2 + j].getFcTimeObj(), "m");
  1701 + aBc[iCount - iC2 + j + 1].addMinuteToFcsj(iC1 + 1 - iTempTime);
  1702 + }
  1703 +
  1704 + },
  1705 +
  1706 + /**
  1707 + * 计算高峰平均停站时间。
  1708 + */
  1709 + fnCalcuAverPeakStopTime: function() {
  1710 + var i;
  1711 + var j;
  1712 + var aBc;
  1713 + var iBcCount = 0;
  1714 + var iSum = 0;
  1715 + for (i = 0; i < _internalLpArray.length; i++) {
  1716 + aBc = _internalLpArray[i].getBcArray();
  1717 +
  1718 + for (j = 0; j < aBc.length; j++) {
  1719 + if (!_paramObj.isTroughBc(aBc[j].getArrTimeObj())) {
  1720 + iBcCount ++;
  1721 + iSum += aBc[j].getStopTime();
  1722 + }
  1723 + }
  1724 + }
  1725 +
  1726 + return Math.floor(iSum / iBcCount);
  1727 + },
  1728 +
  1729 + /**
  1730 + * 计算低谷平均停站时间。
  1731 + */
  1732 + fnCalcuAverTroughStopTime: function() {
  1733 + var i;
  1734 + var j;
  1735 + var aBc;
  1736 + var iBcCount = 0;
  1737 + var iSum = 0;
  1738 + for (i = 0; i < _internalLpArray.length; i++) {
  1739 + aBc = _internalLpArray[i].getBcArray();
  1740 + for (j = 0; j < aBc.length; j++) {
  1741 + if (_paramObj.isTroughBc(aBc[j].getArrTimeObj())) {
  1742 + iBcCount ++;
  1743 + iSum += aBc[j].getStopTime();
  1744 + }
  1745 + }
  1746 + }
  1747 +
  1748 + return Math.floor(iSum / iBcCount);
  1749 + },
  1750 +
  1751 + //------------- 其他方法 -------------//
  1752 + /**
  1753 + * 内部数据转化成显示用的班次数组。
  1754 + */
  1755 + fnToGanttBcArray: function() {
  1756 + var aAllBc = [];
  1757 + var aLpBc = [];
  1758 + var aEatBc = [];
  1759 + var oLp;
  1760 + var i;
  1761 + var j;
  1762 +
  1763 + for (i = 0; i < _internalLpArray.length; i++) {
  1764 + oLp = _internalLpArray[i];
  1765 + aLpBc = [];
  1766 + aLpBc = aLpBc.concat(oLp.getOtherBcArray(), oLp.getBcArray());
  1767 +
  1768 + aEatBc = [];
  1769 + // 根据班次的吃饭时间添加吃饭班次
  1770 + for (j = 0; j < aLpBc.length; j++) {
  1771 + if (aLpBc[j].fnGetEatTime() > 0) {
  1772 + aEatBc.push(_factory.createBcObj(
  1773 + oLp,
  1774 + "cf",
  1775 + !aLpBc[j].isUp(), // 和上一个班次方向相反
  1776 + 1,
  1777 + _paramObj.addMinute(aLpBc[j].getArrTimeObj(), aLpBc[j].getStopTime()), // 使用上一个班次的到达时间作为开始时间
  1778 + _paramObj
  1779 + ));
  1780 + }
  1781 + }
  1782 + aLpBc = aLpBc.concat(aEatBc);
  1783 +
  1784 + // 按照发车时间排序
  1785 + aLpBc.sort(function(o1, o2) {
  1786 + if (o1.getFcTimeObj().isBefore(o2.getFcTimeObj())) {
  1787 + return -1;
  1788 + } else {
  1789 + return 1;
  1790 + }
  1791 + });
  1792 +
  1793 + // 重新赋值fcno
  1794 + for (j = 0; j < aLpBc.length; j++) {
  1795 + aLpBc[j].fnSetFcno(j + 1);
  1796 + }
  1797 +
  1798 + aAllBc = aAllBc.concat(aLpBc);
  1799 + }
  1800 +
  1801 + var aGanttBc = [];
  1802 + for (i = 0; i < aAllBc.length; i++) {
  1803 + aGanttBc.push(aAllBc[i].toGanttBcObj());
  1804 + }
  1805 +
  1806 + return aGanttBc;
  1807 + }
  1808 +
  1809 + };
1630 }; 1810 };
1631 \ No newline at end of file 1811 \ No newline at end of file
src/main/resources/static/pages/base/timesmodel/js/v2/main_v2.js
1 -/**  
2 - * 主类。  
3 - */  
4 -var Main_v2 = function() {  
5 -  
6 - // 内部工厂类  
7 - var _factoryFun = function() {  
8 - return {  
9 - // 创建参数  
10 - createParameterObj: function(formMap, dataMap) {  
11 - var paramObj = ParameterObj();  
12 - paramObj.wrap(formMap, dataMap);  
13 - return paramObj;  
14 - },  
15 - // 创建班次对象  
16 - createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {  
17 - var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);  
18 - var _fcsj = fcTimeObj;  
19 - var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);  
20 - var _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
21 - var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);  
22 - var _tccid = paramObj.getTTinfoId();  
23 - var _ttinfoid = paramObj.getTTinfoId();  
24 - var _xl = paramObj.getXlId();  
25 - var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;  
26 - var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;  
27 -  
28 - if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间  
29 - if (isUp) { // 上行  
30 - _fcsj = paramObj.addMinute(  
31 - _fcsj,  
32 - -(paramObj.getUpOutTime() + paramObj.getLbTime()));  
33 - _bcsj = paramObj.getLbTime();  
34 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
35 - _stoptime = 0;  
36 - } else { // 下行  
37 - _fcsj = paramObj.addMinute(  
38 - _fcsj,  
39 - -(paramObj.getDownOutTime() + paramObj.getLbTime()));  
40 - _bcsj = paramObj.getLbTime();  
41 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
42 - _stoptime = 0;  
43 - }  
44 - } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间  
45 - if (isUp) { // 上行  
46 - _fcsj = paramObj.addMinute(  
47 - _fcsj,  
48 - paramObj.getUpInTime());  
49 - _bcsj = paramObj.getLbTime();  
50 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
51 - _stoptime = 0;  
52 - } else { // 下行  
53 - _fcsj = paramObj.addMinute(  
54 - _fcsj,  
55 - paramObj.getDownInTime());  
56 - _bcsj = paramObj.getLbTime();  
57 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
58 - _stoptime = 0;  
59 - }  
60 - } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间  
61 - if (isUp) { // 上行  
62 - _fcsj = paramObj.addMinute(  
63 - _fcsj,  
64 - -paramObj.getUpOutTime());  
65 - _bcsj = paramObj.getUpOutTime();  
66 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
67 - _stoptime = 0;  
68 - } else { // 下行  
69 - _fcsj = paramObj.addMinute(  
70 - _fcsj,  
71 - -paramObj.getDownOutTime());  
72 - _bcsj = paramObj.getDownOutTime();  
73 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
74 - _stoptime = 0;  
75 - }  
76 - } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间  
77 - if (isUp) { // 上行  
78 - _bcsj = paramObj.getUpInTime();  
79 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
80 - _stoptime = 0;  
81 - } else { // 下行  
82 - _bcsj = paramObj.getDownInTime();  
83 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
84 - _stoptime = 0;  
85 - }  
86 - } else if (bcType == "cf") { // 吃饭班次  
87 - // 以13:00为分界,之前的为午饭,之后的为晚饭  
88 - if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {  
89 - _bcsj = paramObj.fnGetLunchTime();  
90 - } else {  
91 - _bcsj = paramObj.fnGetDinnerTime();  
92 - }  
93 - _arrsj = paramObj.addMinute(_fcsj, _bcsj);  
94 - _stoptime = 0;  
95 - }  
96 -  
97 - var bcParamObj = {};  
98 - bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)  
99 - bcParamObj.isUp = isUp; // boolean是否上下行  
100 - bcParamObj.fcno = fcno; // 发车顺序号  
101 - bcParamObj.fcTimeObj = _fcsj; // 发车时间对象  
102 - bcParamObj.bclc = _bclc; // 班次里程  
103 - bcParamObj.bcsj = _bcsj; // 班次历时  
104 - bcParamObj.arrtime = _arrsj; // 到达时间对象  
105 - bcParamObj.stoptime = _stoptime; // 停站时间  
106 - bcParamObj.tccid = _tccid; // 停车场id  
107 - bcParamObj.ttinfoid = _ttinfoid; // 时刻表id  
108 - bcParamObj.xl = _xl; // 线路id  
109 - bcParamObj.qdzid = _qdz; // 起点站id  
110 - bcParamObj.zdzid = _zdz; // 终点站id  
111 -  
112 - return new InternalBcObj(lpObj, bcParamObj);  
113 - }  
114 - };  
115 - };  
116 - var _factory = _factoryFun();  
117 -  
118 - // 所有的时间使用moment.js计算  
119 -  
120 - var _paramObj; // 参数对象  
121 -  
122 - var _bxDesc = [ // 班型描述  
123 - {'type':'六工一休','hoursV':6.66, 'minueV':'6:40', 'qcount': 0, 'avertime': 0},  
124 - {'type':'五工一休','hoursV':6.85, 'minueV':'6:51', 'qcount': 0, 'avertime': 0},  
125 - {'type':'四工一休','hoursV':7.14, 'minueV':'7:08', 'qcount': 0, 'avertime': 0},  
126 - {'type':'三工一休','hoursV':7.61, 'minueV':'7:37', 'qcount': 0, 'avertime': 0},  
127 - {'type':'二工一休','hoursV':8.57, 'minueV':'8:34', 'qcount': 0, 'avertime': 0},  
128 - {'type':'一工一休','hoursV':11.42, 'minueV':'11:25', 'qcount': 0, 'avertime': 0},  
129 - {'type':'五工二休','hoursV':7.99, 'minueV':'8:00', 'qcount': 0, 'avertime': 0},  
130 - {'type':'无工休', 'hoursV':5.43, 'minueV':'5:43', 'qcount': 0, 'avertime': 0}  
131 - ];  
132 -  
133 - return {  
134 - /**  
135 - * 工厂对象,创建不同的对象。  
136 - * @returns {{createParameterObj, createBcObj}}  
137 - */  
138 - getFactory: function() {  
139 - return _factory;  
140 - },  
141 -  
142 - /**  
143 - * 使用发车间隔策略生成时刻表。  
144 - * @param paramObj 参数对象  
145 - * @param lpArray 路牌数组  
146 - * @constructor  
147 - */  
148 - BXPplaceClassesTime03 : function(paramObj, lpArray) {  
149 - // 参数对象  
150 - _paramObj = paramObj;  
151 -  
152 - // 1、初始化行车计划  
153 - var schedule = new InternalScheduleObj(_paramObj, lpArray, _factory);  
154 - schedule.fnInitDataWithBxLayout();  
155 - // 2、将连班路牌的班次补足  
156 - schedule.fnCalcuLpBx_lb();  
157 -  
158 - // 3、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除  
159 - schedule.fnAdjustGfbc(true, true); // 修正上行早高峰  
160 - schedule.fnAdjustGfbc(true, false); // 修正下行早高峰  
161 - schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰  
162 - schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰  
163 -  
164 - // 4、按照车辆投入运营要求补充班次  
165 - schedule.fnCalcuLpBc_yy();  
166 -  
167 - // 5、根据班型补充所有的不足班次  
168 - schedule.fnCalcuLpBx_5_2();  
169 - schedule.fnCalcuLpBx_other();  
170 -  
171 - // 6、补吃饭班次  
172 - schedule.fnCalcuEatBc();  
173 -  
174 - // 7、祛除有删除标记的班次  
175 - schedule.fnRemoveDelFlagBc();  
176 -  
177 - // 8、调整纵向班次间隔  
178 - schedule.fnAdjust_vertical_bc_interval();  
179 - // TODO:横向调整  
180 -  
181 - // 9、确定末班车  
182 - schedule.fnCalcuLastBc();  
183 -  
184 - // 10、补进出场例保班次  
185 - schedule.fnCalcuOtherBc();  
186 -  
187 - //-------------------- 输出ganut图上的班次,班型描述 ----------------------//  
188 - var gBcData = schedule.fnToGanttBcArray();  
189 - // TODO:班型再议  
190 - return {'json':gBcData,'bxrcgs':null};  
191 -  
192 - }  
193 -  
194 - };  
195 - 1 +/**
  2 + * 主类。
  3 + */
  4 +var Main_v2 = function() {
  5 +
  6 + // 内部工厂类
  7 + var _factoryFun = function() {
  8 + return {
  9 + // 创建参数
  10 + createParameterObj: function(formMap, dataMap) {
  11 + var paramObj = ParameterObj();
  12 + paramObj.wrap(formMap, dataMap);
  13 + return paramObj;
  14 + },
  15 + // 创建班次对象
  16 + createBcObj: function(lpObj, bcType, isUp, fcno, fcTimeObj, paramObj) {
  17 + var _bclc = paramObj.calcuTravelLcNumber(isUp, bcType);
  18 + var _fcsj = fcTimeObj;
  19 + var _bcsj = paramObj.calcuTravelTime(_fcsj, isUp);
  20 + var _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  21 + //var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, _bcsj);
  22 + var _stoptime = paramObj.fnCalcuFixedStopNumber(_arrsj, !isUp, undefined);
  23 + var _tccid = paramObj.getTTinfoId();
  24 + var _ttinfoid = paramObj.getTTinfoId();
  25 + var _xl = paramObj.getXlId();
  26 + var _qdz = isUp ? paramObj.getUpQdzObj().id : paramObj.getDownQdzObj().id;
  27 + var _zdz = isUp ? paramObj.getUpZdzObj().id : paramObj.getDownZdzObj().id;
  28 +
  29 + if (bcType == "bd") { // 早例保,传过来的发车时间是第一个班次的发车时间
  30 + if (isUp) { // 上行
  31 + _fcsj = paramObj.addMinute(
  32 + _fcsj,
  33 + -(paramObj.getUpOutTime() + paramObj.getLbTime()));
  34 + _bcsj = paramObj.getLbTime();
  35 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  36 + _stoptime = 0;
  37 + } else { // 下行
  38 + _fcsj = paramObj.addMinute(
  39 + _fcsj,
  40 + -(paramObj.getDownOutTime() + paramObj.getLbTime()));
  41 + _bcsj = paramObj.getLbTime();
  42 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  43 + _stoptime = 0;
  44 + }
  45 + } else if (bcType == "lc") { // 晚例保,传过来的发车时间是最后一个班次的到达时间
  46 + if (isUp) { // 上行
  47 + _fcsj = paramObj.addMinute(
  48 + _fcsj,
  49 + paramObj.getUpInTime());
  50 + _bcsj = paramObj.getLbTime();
  51 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  52 + _stoptime = 0;
  53 + } else { // 下行
  54 + _fcsj = paramObj.addMinute(
  55 + _fcsj,
  56 + paramObj.getDownInTime());
  57 + _bcsj = paramObj.getLbTime();
  58 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  59 + _stoptime = 0;
  60 + }
  61 + } else if (bcType == "out") { // 出场,传过来的发车时间是第一个班次的发车时间
  62 + if (isUp) { // 上行
  63 + _fcsj = paramObj.addMinute(
  64 + _fcsj,
  65 + -paramObj.getUpOutTime());
  66 + _bcsj = paramObj.getUpOutTime();
  67 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  68 + _stoptime = 0;
  69 + } else { // 下行
  70 + _fcsj = paramObj.addMinute(
  71 + _fcsj,
  72 + -paramObj.getDownOutTime());
  73 + _bcsj = paramObj.getDownOutTime();
  74 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  75 + _stoptime = 0;
  76 + }
  77 + } else if (bcType == "in") { // 进场,传过来的发车时间是最后一个班次的到达时间
  78 + if (isUp) { // 上行
  79 + _bcsj = paramObj.getUpInTime();
  80 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  81 + _stoptime = 0;
  82 + } else { // 下行
  83 + _bcsj = paramObj.getDownInTime();
  84 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  85 + _stoptime = 0;
  86 + }
  87 + } else if (bcType == "cf") { // 吃饭班次
  88 + // 以13:00为分界,之前的为午饭,之后的为晚饭
  89 + if (fcTimeObj.isBefore(paramObj.toTimeObj("13:00"))) {
  90 + _bcsj = paramObj.fnGetLunchTime();
  91 + } else {
  92 + _bcsj = paramObj.fnGetDinnerTime();
  93 + }
  94 + _arrsj = paramObj.addMinute(_fcsj, _bcsj);
  95 + _stoptime = 0;
  96 + }
  97 +
  98 + var bcParamObj = {};
  99 + bcParamObj.bcType = bcType; // 班次类型(normal,in_,out, bd, lc, cf等)
  100 + bcParamObj.isUp = isUp; // boolean是否上下行
  101 + bcParamObj.fcno = fcno; // 发车顺序号
  102 + bcParamObj.fcTimeObj = _fcsj; // 发车时间对象
  103 + bcParamObj.bclc = _bclc; // 班次里程
  104 + bcParamObj.bcsj = _bcsj; // 班次历时
  105 + bcParamObj.arrtime = _arrsj; // 到达时间对象
  106 + bcParamObj.stoptime = _stoptime; // 停站时间
  107 + bcParamObj.tccid = _tccid; // 停车场id
  108 + bcParamObj.ttinfoid = _ttinfoid; // 时刻表id
  109 + bcParamObj.xl = _xl; // 线路id
  110 + bcParamObj.qdzid = _qdz; // 起点站id
  111 + bcParamObj.zdzid = _zdz; // 终点站id
  112 +
  113 + return new InternalBcObj(lpObj, bcParamObj);
  114 + }
  115 + };
  116 + };
  117 + var _factory = _factoryFun();
  118 +
  119 + // 所有的时间使用moment.js计算
  120 +
  121 + var _paramObj; // 参数对象
  122 +
  123 + var _bxDesc = [ // 班型描述
  124 + {'type':'六工一休','hoursV':6.66, 'minueV':'6:40', 'qcount': 0, 'avertime': 0},
  125 + {'type':'五工一休','hoursV':6.85, 'minueV':'6:51', 'qcount': 0, 'avertime': 0},
  126 + {'type':'四工一休','hoursV':7.14, 'minueV':'7:08', 'qcount': 0, 'avertime': 0},
  127 + {'type':'三工一休','hoursV':7.61, 'minueV':'7:37', 'qcount': 0, 'avertime': 0},
  128 + {'type':'二工一休','hoursV':8.57, 'minueV':'8:34', 'qcount': 0, 'avertime': 0},
  129 + {'type':'一工一休','hoursV':11.42, 'minueV':'11:25', 'qcount': 0, 'avertime': 0},
  130 + {'type':'五工二休','hoursV':7.99, 'minueV':'8:00', 'qcount': 0, 'avertime': 0},
  131 + {'type':'无工休', 'hoursV':5.43, 'minueV':'5:43', 'qcount': 0, 'avertime': 0}
  132 + ];
  133 +
  134 + return {
  135 + /**
  136 + * 工厂对象,创建不同的对象。
  137 + * @returns {{createParameterObj, createBcObj}}
  138 + */
  139 + getFactory: function() {
  140 + return _factory;
  141 + },
  142 +
  143 + /**
  144 + * 使用发车间隔策略生成时刻表。
  145 + * @param paramObj 参数对象
  146 + * @param lpArray 路牌数组
  147 + * @constructor
  148 + */
  149 + BXPplaceClassesTime03 : function(paramObj, lpArray) {
  150 + // 参数对象
  151 + _paramObj = paramObj;
  152 +
  153 + // 1、初始化行车计划
  154 + var schedule = new InternalScheduleObj(_paramObj, lpArray, _factory);
  155 + schedule.fnInitDataWithBxLayout();
  156 + // 2、将连班路牌的班次补足
  157 + schedule.fnCalcuLpBx_lb();
  158 +
  159 + // 3、修正针对初始化时生成的高峰班次,之前不足的补上,多余的删除
  160 + schedule.fnAdjustGfbc(true, true); // 修正上行早高峰
  161 + schedule.fnAdjustGfbc(true, false); // 修正下行早高峰
  162 + schedule.fnAdjustGfbc(false, true); // 修正上行晚高峰
  163 + schedule.fnAdjustGfbc(false, false); // 修正下行晚高峰
  164 +
  165 + // 6、补吃饭班次
  166 + schedule.fnCalcuEatBc();
  167 +
  168 + // 4、按照车辆投入运营要求补充班次
  169 + schedule.fnCalcuLpBc_yy();
  170 +
  171 + // 5、根据班型补充所有的不足班次
  172 + schedule.fnCalcuLpBx_5_2();
  173 + schedule.fnCalcuLpBx_other();
  174 +
  175 + // 7、祛除上标线开头有删除标记的班次
  176 + schedule.fnRemoveDelFirstFlagBc();
  177 +
  178 + // TODO:8、调整路牌班次间隔
  179 + schedule.fnAdjustLpBcInterval(1);
  180 +
  181 + // TODO:9、调整纵向班次间隔
  182 + schedule.fnAdjustBcInterval(true, false, 10);
  183 + schedule.fnAdjustBcInterval(false, false, 10);
  184 +
  185 + // 10、确定末班车
  186 + schedule.fnCalcuLastBc();
  187 +
  188 + // 11、祛除上标线结尾有删除标记的班次
  189 + schedule.fnRemoveDelLastFlagBc();
  190 +
  191 + // TODO:12、平均化指定时间后的班次列表间隔
  192 + schedule.fnAdjustBcInterval2_avg(true, _paramObj.toTimeObj("19:50"));
  193 + schedule.fnAdjustBcInterval2_avg(false, _paramObj.toTimeObj("19:50"));
  194 +
  195 + // 10、补进出场例保班次
  196 + schedule.fnCalcuOtherBc();
  197 +
  198 + //-------------------- 输出ganut图上的班次,班型描述 ----------------------//
  199 + var gBcData = schedule.fnToGanttBcArray();
  200 + // TODO:班型再议
  201 + return {'json':gBcData,'bxrcgs':null};
  202 +
  203 + }
  204 +
  205 + };
  206 +
196 }(); 207 }();
197 \ No newline at end of file 208 \ No newline at end of file
src/main/resources/static/pages/forms/mould/oilListMonth.xls
No preview for this file type
src/main/resources/static/pages/forms/mould/onlinelist.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/statement/busInterval.html
@@ -412,6 +412,32 @@ @@ -412,6 +412,32 @@
412 }); 412 });
413 } 413 }
414 414
  415 + /**
  416 + * 将模块List 转换为树结构
  417 + * @param arr
  418 + * @returns {Array}
  419 + */
  420 + function createTreeData(arr){
  421 + var treeData = [];
  422 + var len = arr.length;
  423 + for(var i = 0; i < len; i ++){
  424 + var pId = arr[i].pId;
  425 + arr[i].text = arr[i].name;
  426 + if(!pId){
  427 + treeData.push(arr[i]);
  428 + }
  429 +
  430 + for(var j = 0; j < len; j ++){
  431 + if(pId == arr[j].id){
  432 + if(!arr[j].children)
  433 + arr[j].children = [];
  434 + arr[j].children.push(arr[i]);
  435 + break;
  436 + }
  437 + }
  438 + }
  439 + return treeData;
  440 + }
415 441
416 function _w_table_rowspan(_w_table_id, _w_table_colnum){ 442 function _w_table_rowspan(_w_table_id, _w_table_colnum){
417 _w_table_firsttd = ""; 443 _w_table_firsttd = "";
src/main/resources/static/pages/forms/statement/lbStatuAnaly.html
@@ -438,6 +438,32 @@ @@ -438,6 +438,32 @@
438 }); 438 });
439 } 439 }
440 440
  441 + /**
  442 + * 将模块List 转换为树结构
  443 + * @param arr
  444 + * @returns {Array}
  445 + */
  446 + function createTreeData(arr){
  447 + var treeData = [];
  448 + var len = arr.length;
  449 + for(var i = 0; i < len; i ++){
  450 + var pId = arr[i].pId;
  451 + arr[i].text = arr[i].name;
  452 + if(!pId){
  453 + treeData.push(arr[i]);
  454 + }
  455 +
  456 + for(var j = 0; j < len; j ++){
  457 + if(pId == arr[j].id){
  458 + if(!arr[j].children)
  459 + arr[j].children = [];
  460 + arr[j].children.push(arr[i]);
  461 + break;
  462 + }
  463 + }
  464 + }
  465 + return treeData;
  466 + }
441 467
442 function _w_table_rowspan(_w_table_id, _w_table_colnum){ 468 function _w_table_rowspan(_w_table_id, _w_table_colnum){
443 _w_table_firsttd = ""; 469 _w_table_firsttd = "";
src/main/resources/static/pages/forms/statement/lineTimeAnaly.html
@@ -478,6 +478,32 @@ @@ -478,6 +478,32 @@
478 }); 478 });
479 } 479 }
480 480
  481 + /**
  482 + * 将模块List 转换为树结构
  483 + * @param arr
  484 + * @returns {Array}
  485 + */
  486 + function createTreeData(arr){
  487 + var treeData = [];
  488 + var len = arr.length;
  489 + for(var i = 0; i < len; i ++){
  490 + var pId = arr[i].pId;
  491 + arr[i].text = arr[i].name;
  492 + if(!pId){
  493 + treeData.push(arr[i]);
  494 + }
  495 +
  496 + for(var j = 0; j < len; j ++){
  497 + if(pId == arr[j].id){
  498 + if(!arr[j].children)
  499 + arr[j].children = [];
  500 + arr[j].children.push(arr[i]);
  501 + break;
  502 + }
  503 + }
  504 + }
  505 + return treeData;
  506 + }
481 507
482 }); 508 });
483 509
src/main/resources/static/pages/forms/statement/scheduleAnaly.html
@@ -327,6 +327,32 @@ @@ -327,6 +327,32 @@
327 }); 327 });
328 } 328 }
329 329
  330 + /**
  331 + * 将模块List 转换为树结构
  332 + * @param arr
  333 + * @returns {Array}
  334 + */
  335 + function createTreeData(arr){
  336 + var treeData = [];
  337 + var len = arr.length;
  338 + for(var i = 0; i < len; i ++){
  339 + var pId = arr[i].pId;
  340 + arr[i].text = arr[i].name;
  341 + if(!pId){
  342 + treeData.push(arr[i]);
  343 + }
  344 +
  345 + for(var j = 0; j < len; j ++){
  346 + if(pId == arr[j].id){
  347 + if(!arr[j].children)
  348 + arr[j].children = [];
  349 + arr[j].children.push(arr[i]);
  350 + break;
  351 + }
  352 + }
  353 + }
  354 + return treeData;
  355 + }
330 356
331 function showPagination(data){ 357 function showPagination(data){
332 //分页 358 //分页
src/main/resources/static/pages/forms/statement/scheduleAnaly_sum.html
@@ -335,6 +335,33 @@ @@ -335,6 +335,33 @@
335 }); 335 });
336 } 336 }
337 337
  338 + /**
  339 + * 将模块List 转换为树结构
  340 + * @param arr
  341 + * @returns {Array}
  342 + */
  343 + function createTreeData(arr){
  344 + var treeData = [];
  345 + var len = arr.length;
  346 + for(var i = 0; i < len; i ++){
  347 + var pId = arr[i].pId;
  348 + arr[i].text = arr[i].name;
  349 + if(!pId){
  350 + treeData.push(arr[i]);
  351 + }
  352 +
  353 + for(var j = 0; j < len; j ++){
  354 + if(pId == arr[j].id){
  355 + if(!arr[j].children)
  356 + arr[j].children = [];
  357 + arr[j].children.push(arr[i]);
  358 + break;
  359 + }
  360 + }
  361 + }
  362 + return treeData;
  363 + }
  364 +
338 function initCl(){ 365 function initCl(){
339 $('#nbbm').select2({ 366 $('#nbbm').select2({
340 placeholder: '搜索车辆...', 367 placeholder: '搜索车辆...',
src/main/resources/static/pages/forms/statement/timeAndSpeed.html
@@ -480,6 +480,33 @@ @@ -480,6 +480,33 @@
480 }); 480 });
481 } 481 }
482 482
  483 + /**
  484 + * 将模块List 转换为树结构
  485 + * @param arr
  486 + * @returns {Array}
  487 + */
  488 + function createTreeData(arr){
  489 + var treeData = [];
  490 + var len = arr.length;
  491 + for(var i = 0; i < len; i ++){
  492 + var pId = arr[i].pId;
  493 + arr[i].text = arr[i].name;
  494 + if(!pId){
  495 + treeData.push(arr[i]);
  496 + }
  497 +
  498 + for(var j = 0; j < len; j ++){
  499 + if(pId == arr[j].id){
  500 + if(!arr[j].children)
  501 + arr[j].children = [];
  502 + arr[j].children.push(arr[i]);
  503 + break;
  504 + }
  505 + }
  506 + }
  507 + return treeData;
  508 + }
  509 +
483 function _w_table_rowspan(_w_table_id, _w_table_colnum){ 510 function _w_table_rowspan(_w_table_id, _w_table_colnum){
484 _w_table_firsttd = ""; 511 _w_table_firsttd = "";
485 _w_table_currenttd = ""; 512 _w_table_currenttd = "";
src/main/resources/static/pages/forms/statement/waybill.html
@@ -359,7 +359,8 @@ @@ -359,7 +359,8 @@
359 }); 359 });
360 }); 360 });
361 $get('/realSchedule/exportWaybillMore',{date:date,line:line,strs:JSON.stringify(param)},function(result){ 361 $get('/realSchedule/exportWaybillMore',{date:date,line:line,strs:JSON.stringify(param)},function(result){
362 - window.open("/downloadFile/downloadList?fileName="+result.fileName); 362 +// window.open("/downloadFile/downloadList?fileName="+result.fileName); //下载压缩包
  363 + window.open("/downloadFile/download?fileName="+result.fileName);
363 }); 364 });
364 }); 365 });
365 366
src/main/resources/static/pages/mforms/online/online.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px;
  14 + text-align: center;}
  15 +
  16 + .table > tbody + tbody {
  17 + border-top: 1px solid; }
  18 + .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{ text-align: center; }
  19 +.table-checkable tr > th:first-child, .table-checkable tr > td:first-child {
  20 + text-align: center;
  21 + max-width: initial;
  22 + min-width: 40px;
  23 + padding-left: 0;
  24 + padding-right: 0;
  25 +}
  26 +
  27 +</style>
  28 +
  29 +<div class="page-head">
  30 + <div class="page-title">
  31 + <h1>车辆在线率统计表</h1>
  32 + </div>
  33 +</div>
  34 +
  35 +<div class="row">
  36 + <div class="col-md-12">
  37 + <div class="portlet light porttlet-fit bordered">
  38 + <div class="portlet-title">
  39 + <form class="form-inline" action="" method="post">
  40 + <div style="display: inline-block; margin-left: 20px;" id="gsdmDiv_turn">
  41 + <span class="item-label" style="width: 80px;">公司: </span>
  42 + <select class="form-control" name="company" id="gsdmTurn" style="width: 140px;"></select>
  43 + </div>
  44 + <div style="display: inline-block; margin-left: 20px;" id="fgsdmDiv_turn">
  45 + <span class="item-label" style="width: 80px;">分公司: </span>
  46 + <select class="form-control" name="subCompany" id="fgsdmTurn" style="width: 140px;"></select>
  47 + </div>
  48 + <div style="display: inline-block; margin-left: 15px;">
  49 + <span class="item-label" style="width: 80px;">线路: </span>
  50 + <select class="form-control" name="line" id="line" style="width: 120px;"></select>
  51 + </div>
  52 + <div style="display: inline-block;margin-left: 15px;">
  53 + <span class="item-label" style="width: 80px;">日期: </span>
  54 + <input class="form-control" type="text" id="date" style="width: 120px;"/>
  55 + </div>
  56 +
  57 + <div class="form-group">
  58 + <input class="btn btn-default" type="button" id="query" value="筛选"/>
  59 + <input class="btn btn-default" type="button" id="export" value="导出"/>
  60 + </div>
  61 + </form>
  62 + </div>
  63 + <div class="portlet-body">
  64 + <div class="table-container" style="margin-top: 20px;overflow:auto;min-width: 1000px">
  65 + <table class="table table-bordered table-hover table-checkable" id="forms1">
  66 + <thead>
  67 + <tr>
  68 + <th colspan="6">车辆在线率统计表</th>
  69 + </tr>
  70 + <tr>
  71 + <td>日期</td>
  72 + <td>线路</td>
  73 + <td>权证配车数</td>
  74 + <td>实际出车数</td>
  75 + <td>在线车辆数</td>
  76 + <td>在线率</td>
  77 + </tr>
  78 + </thead>
  79 + <tbody id="tbody">
  80 +
  81 + </tbody>
  82 + </table>
  83 + </div>
  84 + </div>
  85 + </div>
  86 + </div>
  87 +</div>
  88 +
  89 +<script>
  90 + $(function(){
  91 + // 关闭左侧栏
  92 + if (!$('body').hasClass('page-sidebar-closed'))
  93 + $('.menu-toggler.sidebar-toggler').click();
  94 +
  95 + $("#date").datetimepicker({
  96 + format : 'YYYY-MM-DD',
  97 + locale : 'zh-cn'
  98 + });
  99 +
  100 + var d = new Date();
  101 + var year = d.getFullYear();
  102 + var month = d.getMonth() + 1;
  103 + var day = d.getDate();
  104 + if(month < 10)
  105 + month = "0" + month;
  106 + if(day < 10)
  107 + day = "0" + day;
  108 + $("#date").val(year + "-" + month + "-" + day);
  109 +
  110 + var fage=false;
  111 + var xlList;
  112 + var obj = [];
  113 +
  114 + $.get('/report/lineList',function(result){
  115 + xlList=result;
  116 + $.get('/user/companyData', function(result){
  117 + obj = result;
  118 + var options = '';
  119 + for(var i = 0; i < obj.length; i++){
  120 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  121 + }
  122 +
  123 + if(obj.length ==0){
  124 + $("#gsdmDiv_turn").css('display','none');
  125 + }else if(obj.length ==1){
  126 + $("#gsdmDiv_turn").css('display','none');
  127 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  128 + $('#fgsdmDiv_turn').css('display','none');
  129 + }
  130 + $('#gsdmTurn').html(options);
  131 + updateCompany();
  132 + });
  133 + })
  134 + $("#gsdmTurn").on("change",updateCompany);
  135 + function updateCompany(){
  136 + var company = $('#gsdmTurn').val();
  137 + var options = '';
  138 + for(var i = 0; i < obj.length; i++){
  139 + if(obj[i].companyCode == company){
  140 + var children = obj[i].children;
  141 + for(var j = 0; j < children.length; j++){
  142 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  143 + }
  144 + }
  145 + }
  146 + $('#fgsdmTurn').html(options);
  147 + }
  148 +
  149 + var tempData = {};
  150 + $.get('/report/lineList',function(xlList){
  151 + var data = [];
  152 +// data.push({id: " ", text: "全部线路"});
  153 + $.get('/user/companyData', function(result){
  154 + for(var i = 0; i < result.length; i++){
  155 + var companyCode = result[i].companyCode;
  156 + var children = result[i].children;
  157 + for(var j = 0; j < children.length; j++){
  158 + var code = children[j].code;
  159 + for(var k=0;k < xlList.length;k++ ){
  160 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  161 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  162 + tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
  163 + }
  164 + }
  165 + }
  166 + }
  167 + initPinYinSelect2('#line',data,'');
  168 +
  169 + });
  170 + });
  171 +
  172 + $("#line").on("change", function(){
  173 + if($("#line").val() == " "){
  174 + $("#gsdmTurn").attr("disabled", false);
  175 + $("#fgsdmTurn").attr("disabled", false);
  176 + } else {
  177 + var temp = tempData[$("#line").val()].split(":");
  178 + $("#gsdmTurn").val(temp[0]);
  179 + updateCompany();
  180 + $("#fgsdmTurn").val(temp[1]);
  181 + $("#gsdmTurn").attr("disabled", true);
  182 + $("#fgsdmTurn").attr("disabled", true);
  183 + }
  184 + });
  185 +
  186 + var line;
  187 + var date;
  188 + $("#query").on("click",function(){
  189 + line = $("#line").val();
  190 + date=$("#date").val();
  191 + if(date!=''){
  192 + $get('/report/online',
  193 + { line:line,date:date,type:'query'},function(result){
  194 + // 把数据填充到模版中
  195 + var tbodyHtml = template('online',result);
  196 + // 把渲染好的模版html文本追加到表格中
  197 + $('#tbody').html(tbodyHtml);
  198 + });
  199 +
  200 + }else{
  201 + layer.msg("请选择时间!");
  202 + }
  203 + });
  204 +
  205 + $("#export").on("click",function(){
  206 + line = $("#line").val();
  207 + date=$("#date").val();
  208 + $get('/report/online',{line:line,date:date,type:'export'},function(result){
  209 + window.open("/downloadFile/download?fileName=车辆在线率统计");
  210 + });
  211 + });
  212 + });
  213 +</script>
  214 +<script type="text/html" id="online">
  215 + <tr>
  216 + <td>{{date}}</td>
  217 + <td>{{xlName}}</td>
  218 + <td>{{qzpcs}}</td>
  219 + <td>{{ccs}}</td>
  220 + <td>{{zxcl}}</td>
  221 + <td>{{zxl}}</td>
  222 + </tr>
  223 +</script>
src/main/resources/static/pages/oil/history/history.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px; }
  14 +
  15 + .table > tbody + tbody {
  16 + border-top: 1px solid; }
  17 +</style>
  18 +
  19 +<div class="page-head">
  20 + <div class="page-title">
  21 + <h1>重新统计</h1>
  22 + </div>
  23 +</div>
  24 +
  25 +<div class="row">
  26 + <div class="col-md-12">
  27 + <div class="portlet light porttlet-fit bordered">
  28 + <div class="portlet-title">
  29 + <form class="form-inline" action="">
  30 + <div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily">
  31 + <span class="item-label" style="width: 80px;">公司: </span>
  32 + <select class="form-control" name="company" id="gsdmDaily" style="width: 180px;"></select>
  33 + </div>
  34 + <div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_daily">
  35 + <span class="item-label" style="width: 80px;">分公司: </span>
  36 + <select class="form-control" name="subCompany" id="fgsdmDaily" style="width: 180px;"></select>
  37 + </div>
  38 + <div style="margin-top: 2px"></div>
  39 + <div style="display: inline-block;margin-left: 33px;">
  40 + <span class="item-label" style="width: 80px;">线路: </span>
  41 + <select class="form-control" name="line" id="line" style="width: 180px;"></select>
  42 + </div>
  43 + <div style="display: inline-block;margin-left: 24px;">
  44 + <span class="item-label" style="width: 80px;">&nbsp;时间: </span>
  45 + <select class="form-control" id="date" style="width: 180px;">
  46 + <option value="2017-11-07">2017-11-07</option>
  47 + </select>
  48 + </div>
  49 + <div class="form-group">
  50 + <input class="btn btn-default" type="button" id="query" value="重新统计"/>
  51 + </div>
  52 + </form>
  53 + </div>
  54 + </div>
  55 + </div>
  56 +</div>
  57 +
  58 +<script>
  59 + $(function(){
  60 +
  61 + // 关闭左侧栏
  62 + if (!$('body').hasClass('page-sidebar-closed'))
  63 + $('.menu-toggler.sidebar-toggler').click();
  64 +
  65 + function GetDateStr(AddDayCount) {
  66 + var dd = new Date();
  67 + dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
  68 + var y = dd.getFullYear();
  69 + var m = dd.getMonth()+1;//获取当前月份的日期
  70 + if(m<10){
  71 + m="0" + m;
  72 + }
  73 +
  74 + var d = dd.getDate();
  75 + if(d<10){
  76 + d="0" +d;
  77 + }
  78 + return y+"-"+m+"-"+d;
  79 + }
  80 +// var optionsDate = '';
  81 +// for(var i = -1; i > -4; i--){
  82 +// optionsDate += '<option value="2017-11-01">'+2017-11-01+'</option>';
  83 +// }
  84 +// $('#date').html(optionsDate);
  85 + var fage=false;
  86 + var xlList;
  87 + var obj = [];
  88 +
  89 +
  90 + $.get('/report/lineList',function(result){
  91 + xlList=result;
  92 + $.get('/user/companyData', function(result){
  93 + obj = result;
  94 + var options = '';
  95 + for(var i = 0; i < obj.length; i++){
  96 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  97 + }
  98 +
  99 + if(obj.length ==0){
  100 + $("#gsdmDiv_daily").css('display','none');
  101 + }else if(obj.length ==1){
  102 + $("#gsdmDiv_daily").css('display','none');
  103 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  104 + $('#fgsdmDiv_daily').css('display','none');
  105 + }
  106 + $('#gsdmDaily').html(options);
  107 + updateCompany();
  108 + });
  109 + })
  110 + $("#gsdmDaily").on("change",updateCompany);
  111 + function updateCompany(){
  112 + var company = $('#gsdmDaily').val();
  113 + var options = '';
  114 + for(var i = 0; i < obj.length; i++){
  115 + if(obj[i].companyCode == company){
  116 + var children = obj[i].children;
  117 + for(var j = 0; j < children.length; j++){
  118 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  119 + }
  120 + }
  121 + }
  122 + $('#fgsdmDaily').html(options);
  123 +// initXl();
  124 + }
  125 +
  126 +
  127 + var tempData = {};
  128 + $.get('/report/lineList',function(xlList){
  129 + var data = [];
  130 +// data.push({id: " ", text: "全部线路"});
  131 + $.get('/user/companyData', function(result){
  132 + for(var i = 0; i < result.length; i++){
  133 + var companyCode = result[i].companyCode;
  134 + var children = result[i].children;
  135 + for(var j = 0; j < children.length; j++){
  136 + var code = children[j].code;
  137 + for(var k=0;k < xlList.length;k++ ){
  138 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  139 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  140 + tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
  141 + }
  142 + }
  143 + }
  144 + }
  145 + initPinYinSelect2('#line',data,'');
  146 +
  147 + });
  148 + });
  149 +
  150 + $("#line").on("change", function(){
  151 + if($("#line").val() == " "){
  152 + $("#gsdmDaily").attr("disabled", false);
  153 + $("#fgsdmDaily").attr("disabled", false);
  154 + } else {
  155 + var temp = tempData[$("#line").val()].split(":");
  156 + $("#gsdmDaily").val(temp[0]);
  157 + updateCompany();
  158 + $("#fgsdmDaily").val(temp[1]);
  159 + $("#gsdmDaily").attr("disabled", true);
  160 + $("#fgsdmDaily").attr("disabled", true);
  161 + }
  162 + });
  163 +
  164 +
  165 + var line;
  166 + var date;
  167 + var gsdmDaily;
  168 + var fgsdmDaily;
  169 + $("#query").on("click",function(){
  170 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  171 + layer.msg("请选择时间");
  172 + return;
  173 + }
  174 + line = $("#line").val();
  175 + date = $("#date").val();
  176 + gsdmDaily=$("#gsdmDaily").val();
  177 + fgsdmDaily = $("#fgsdmDaily").val();
  178 + $post('/ylb/updateHistory', {date:date,line:line,gsdm:gsdmDaily,fgsdm:fgsdmDaily},
  179 + function (result) {
  180 + layer.msg("重新统计成功");
  181 + });
  182 + });
  183 +
  184 +});
  185 +</script>
src/main/resources/static/pages/oil/list_ph.html
@@ -58,6 +58,11 @@ @@ -58,6 +58,11 @@
58 <li><a href="javascript:;" data-action="3" class="tool-action" 58 <li><a href="javascript:;" data-action="3" class="tool-action"
59 id="export"> <i class="fa fa-file-excel-o"></i> 导出Excel 59 id="export"> <i class="fa fa-file-excel-o"></i> 导出Excel
60 </a></li> 60 </a></li>
  61 +
  62 + <li class="divider"></li>
  63 + <li><a href="javascript:;" data-action="3" class="tool-action"
  64 + id="cxtj"> <i class="fa fa-file-excel-o"></i> 重新统计
  65 + </a></li>
61 </ul> 66 </ul>
62 </div> 67 </div>
63 </div> 68 </div>
@@ -214,6 +219,9 @@ @@ -214,6 +219,9 @@
214 <button type="button" class="btn btn-circle saveButton" > 219 <button type="button" class="btn btn-circle saveButton" >
215 <i class="fa fa-check-circle"></i> 保存 220 <i class="fa fa-check-circle"></i> 保存
216 </button> 221 </button>
  222 + <button type="button" class="btn btn-circle saveButton" >
  223 + <i class="fa fa-check-circle"></i> 保存
  224 + </button>
217 </div> 225 </div>
218 </div> 226 </div>
219 227
@@ -963,6 +971,17 @@ onkeyup=&quot;this.value=this.value.replace(/[^(\d||/.)]/g,&#39;&#39;).replace(&#39;.&#39;,&#39;$#$&#39;).rep @@ -963,6 +971,17 @@ onkeyup=&quot;this.value=this.value.replace(/[^(\d||/.)]/g,&#39;&#39;).replace(&#39;.&#39;,&#39;$#$&#39;).rep
963 971
964 } 972 }
965 // } 973 // }
  974 +
  975 + $("#cxtj").on("click", function () {
  976 + if ($("#rq").val() != "") {
  977 +// var params=getParamsList();
  978 + $post('/ylb/updateHistory', {date:'2017-11-07',line:'10708',gsdm:'26',fgsdm:'1'}, function (result) {
  979 + window.open("/downloadFile/download?fileName="+$("#rq").val()+"进出场存油量" );
  980 + });
  981 + } else {
  982 + layer.msg('请选择日期.');
  983 + }
  984 + });
966 985
967 //导出 986 //导出
968 987
src/main/resources/static/pages/permission/module/list.html
@@ -192,4 +192,31 @@ function getTreeData(cb){ @@ -192,4 +192,31 @@ function getTreeData(cb){
192 }); 192 });
193 } 193 }
194 194
  195 +/**
  196 + * 将模块List 转换为树结构
  197 + * @param arr
  198 + * @returns {Array}
  199 + */
  200 +function createTreeData(arr){
  201 + var treeData = [];
  202 + var len = arr.length;
  203 + for(var i = 0; i < len; i ++){
  204 + var pId = arr[i].pId;
  205 + arr[i].text = arr[i].name;
  206 + if(!pId){
  207 + treeData.push(arr[i]);
  208 + }
  209 +
  210 + for(var j = 0; j < len; j ++){
  211 + if(pId == arr[j].id){
  212 + if(!arr[j].children)
  213 + arr[j].children = [];
  214 + arr[j].children.push(arr[i]);
  215 + break;
  216 + }
  217 + }
  218 + }
  219 + return treeData;
  220 +}
  221 +
195 </script> 222 </script>
196 \ No newline at end of file 223 \ No newline at end of file
src/main/resources/static/pages/permission/resource/add.html
@@ -169,5 +169,33 @@ $(function(){ @@ -169,5 +169,33 @@ $(function(){
169 cb && cb(treeData) 169 cb && cb(treeData)
170 }); 170 });
171 } 171 }
  172 +
  173 + /**
  174 + * 将模块List 转换为树结构
  175 + * @param arr
  176 + * @returns {Array}
  177 + */
  178 + function createTreeData(arr){
  179 + var treeData = [];
  180 + var len = arr.length;
  181 + for(var i = 0; i < len; i ++){
  182 + var pId = arr[i].pId;
  183 + arr[i].text = arr[i].name;
  184 + if(!pId){
  185 + treeData.push(arr[i]);
  186 + }
  187 +
  188 + for(var j = 0; j < len; j ++){
  189 + if(pId == arr[j].id){
  190 + if(!arr[j].children)
  191 + arr[j].children = [];
  192 + arr[j].children.push(arr[i]);
  193 + break;
  194 + }
  195 + }
  196 + }
  197 + return treeData;
  198 + }
  199 +
172 }); 200 });
173 </script> 201 </script>
174 \ No newline at end of file 202 \ No newline at end of file
src/main/resources/static/pages/permission/resource/edit.html
@@ -187,5 +187,33 @@ $(function(){ @@ -187,5 +187,33 @@ $(function(){
187 cb && cb(treeData) 187 cb && cb(treeData)
188 }); 188 });
189 } 189 }
  190 +
  191 + /**
  192 + * 将模块List 转换为树结构
  193 + * @param arr
  194 + * @returns {Array}
  195 + */
  196 + function createTreeData(arr){
  197 + var treeData = [];
  198 + var len = arr.length;
  199 + for(var i = 0; i < len; i ++){
  200 + var pId = arr[i].pId;
  201 + arr[i].text = arr[i].name;
  202 + if(!pId){
  203 + treeData.push(arr[i]);
  204 + }
  205 +
  206 + for(var j = 0; j < len; j ++){
  207 + if(pId == arr[j].id){
  208 + if(!arr[j].children)
  209 + arr[j].children = [];
  210 + arr[j].children.push(arr[i]);
  211 + break;
  212 + }
  213 + }
  214 + }
  215 + return treeData;
  216 + }
  217 +
190 }); 218 });
191 </script> 219 </script>
192 \ No newline at end of file 220 \ No newline at end of file
src/main/resources/static/pages/permission/resource/list.html
@@ -281,6 +281,33 @@ $(function(){ @@ -281,6 +281,33 @@ $(function(){
281 }); 281 });
282 } 282 }
283 283
  284 + /**
  285 + * 将模块List 转换为树结构
  286 + * @param arr
  287 + * @returns {Array}
  288 + */
  289 + function createTreeData(arr){
  290 + var treeData = [];
  291 + var len = arr.length;
  292 + for(var i = 0; i < len; i ++){
  293 + var pId = arr[i].pId;
  294 + arr[i].text = arr[i].name;
  295 + if(!pId){
  296 + treeData.push(arr[i]);
  297 + }
  298 +
  299 + for(var j = 0; j < len; j ++){
  300 + if(pId == arr[j].id){
  301 + if(!arr[j].children)
  302 + arr[j].children = [];
  303 + arr[j].children.push(arr[i]);
  304 + break;
  305 + }
  306 + }
  307 + }
  308 + return treeData;
  309 + }
  310 +
284 //删除 311 //删除
285 $('#removeButton').on('click', function(){ 312 $('#removeButton').on('click', function(){
286 if($(this).attr('disabled')) 313 if($(this).attr('disabled'))
src/main/resources/static/pages/permission/role/settings.html
@@ -215,5 +215,33 @@ $(function(){ @@ -215,5 +215,33 @@ $(function(){
215 cb && cb(treeData) 215 cb && cb(treeData)
216 }); 216 });
217 } 217 }
  218 +
  219 + /**
  220 + * 将模块List 转换为树结构
  221 + * @param arr
  222 + * @returns {Array}
  223 + */
  224 + function createTreeData(arr){
  225 + var treeData = [];
  226 + var len = arr.length;
  227 + for(var i = 0; i < len; i ++){
  228 + var pId = arr[i].pId;
  229 + arr[i].text = arr[i].name;
  230 + if(!pId){
  231 + treeData.push(arr[i]);
  232 + }
  233 +
  234 + for(var j = 0; j < len; j ++){
  235 + if(pId == arr[j].id){
  236 + if(!arr[j].children)
  237 + arr[j].children = [];
  238 + arr[j].children.push(arr[i]);
  239 + break;
  240 + }
  241 + }
  242 + }
  243 + return treeData;
  244 + }
  245 +
218 }); 246 });
219 </script> 247 </script>
src/main/resources/static/pages/report/countMileage/countBus/company/countBusMileage.html
@@ -155,7 +155,7 @@ @@ -155,7 +155,7 @@
155 var tempData = {}; 155 var tempData = {};
156 $.get('/report/lineList',function(xlList){ 156 $.get('/report/lineList',function(xlList){
157 var data = []; 157 var data = [];
158 - data.push({id: " ", text: "全部线路"}); 158 +// data.push({id: " ", text: "全部线路"});
159 $.get('/user/companyData', function(result){ 159 $.get('/user/companyData', function(result){
160 for(var i = 0; i < result.length; i++){ 160 for(var i = 0; i < result.length; i++){
161 var companyCode = result[i].companyCode; 161 var companyCode = result[i].companyCode;
src/main/resources/static/pages/report/countMileage/countBus/countBusMileage.html
@@ -155,7 +155,7 @@ @@ -155,7 +155,7 @@
155 var tempData = {}; 155 var tempData = {};
156 $.get('/report/lineList',function(xlList){ 156 $.get('/report/lineList',function(xlList){
157 var data = []; 157 var data = [];
158 - data.push({id: " ", text: "全部线路"}); 158 +// data.push({id: " ", text: "全部线路"});
159 $.get('/user/companyData', function(result){ 159 $.get('/user/companyData', function(result){
160 for(var i = 0; i < result.length; i++){ 160 for(var i = 0; i < result.length; i++){
161 var companyCode = result[i].companyCode; 161 var companyCode = result[i].companyCode;
src/main/resources/static/pages/report/countMileage/countLine/countLineMileage.html
@@ -263,7 +263,7 @@ @@ -263,7 +263,7 @@
263 params['xlName'] = xlName; 263 params['xlName'] = xlName;
264 params['type'] = "query"; 264 params['type'] = "query";
265 var i = layer.load(2); 265 var i = layer.load(2);
266 - $get('/report/countLineMileage',params,function(result){ 266 + $get('/report/countLineMileage2',params,function(result){
267 $("#datetodate").html(date+"至"+date2); 267 $("#datetodate").html(date+"至"+date2);
268 layer.close(i); 268 layer.close(i);
269 // 把数据填充到模版中 269 // 把数据填充到模版中
@@ -290,7 +290,7 @@ @@ -290,7 +290,7 @@
290 params['xlName'] = xlName; 290 params['xlName'] = xlName;
291 params['type'] = "export"; 291 params['type'] = "export";
292 params['by']='sj'; 292 params['by']='sj';
293 - $get('/report/countLineMileage',params,function(result){ 293 + $get('/report/countLineMileage2',params,function(result){
294 window.open("/downloadFile/download?fileName=线路公里统计表"); 294 window.open("/downloadFile/download?fileName=线路公里统计表");
295 }); 295 });
296 }); 296 });
src/main/resources/static/pages/report/oil/oilListMonth.html
@@ -69,15 +69,6 @@ @@ -69,15 +69,6 @@
69 <td>日期</td> 69 <td>日期</td>
70 <td>存油</td> 70 <td>存油</td>
71 71
72 - <td>序号</td>  
73 - <td>车号</td>  
74 - <td>日期</td>  
75 - <td>存油</td>  
76 -  
77 - <td>序号</td>  
78 - <td>车号</td>  
79 - <td>日期</td>  
80 - <td>存油</td>  
81 </tr> 72 </tr>
82 </thead> 73 </thead>
83 74
@@ -139,10 +130,8 @@ @@ -139,10 +130,8 @@
139 var xlList; 130 var xlList;
140 $.get('/report/lineList',function(result){ 131 $.get('/report/lineList',function(result){
141 xlList=result; 132 xlList=result;
142 -  
143 $.get('/user/companyData', function(result){ 133 $.get('/user/companyData', function(result){
144 obj = result; 134 obj = result;
145 - console.log(obj);  
146 var options = ''; 135 var options = '';
147 for(var i = 0; i < obj.length; i++){ 136 for(var i = 0; i < obj.length; i++){
148 options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>'; 137 options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
@@ -226,9 +215,6 @@ @@ -226,9 +215,6 @@
226 var gsdm = $("#gsdm").val(); 215 var gsdm = $("#gsdm").val();
227 var fgsdm = $("#fgsdm").val(); 216 var fgsdm = $("#fgsdm").val();
228 $get('/ylb/oilListMonth',{line:line,date:date,gsdm:gsdm,fgsdm,fgsdm,type:'query'},function(result){ 217 $get('/ylb/oilListMonth',{line:line,date:date,gsdm:gsdm,fgsdm,fgsdm,type:'query'},function(result){
229 -// $.each(result, function(i, obj) {  
230 -// obj.rq = moment(obj.rq).format("DD");  
231 -// });  
232 var oilListMonth = template('oilListMonth',{list:result}); 218 var oilListMonth = template('oilListMonth',{list:result});
233 $('#forms tbody').html(oilListMonth); 219 $('#forms tbody').html(oilListMonth);
234 }); 220 });
@@ -252,16 +238,29 @@ @@ -252,16 +238,29 @@
252 </script> 238 </script>
253 <script type="text/html" id="oilListMonth"> 239 <script type="text/html" id="oilListMonth">
254 {{each list as obj i}} 240 {{each list as obj i}}
255 - {{if i%5 == 0}} 241 +
256 <tr> 242 <tr>
257 - {{/if}}  
258 - <td>{{i+1}}</td>  
259 - <td>{{obj.nbbm}}</td>  
260 - <td>{{obj.rq}}</td>  
261 - <td>{{obj.jzyl}}</td>  
262 - {{if (i+1)%5 == 0}} 243 + {{if obj.xh0==99}}
  244 + <td colspan="12">
  245 + {{obj.nbbm0}}
  246 + </td>
  247 + {{else}}
  248 + <td>{{obj.xh0}}</td>
  249 + <td>{{obj.nbbm0}}</td>
  250 + <td>{{obj.rq0}}</td>
  251 + <td>{{obj.jzyl0}}</td>
  252 + <td>{{obj.xh1}}</td>
  253 + <td>{{obj.nbbm1}}</td>
  254 + <td>{{obj.rq1}}</td>
  255 + <td>{{obj.jzyl1}}</td>
  256 + <td>{{obj.xh2}}</td>
  257 + <td>{{obj.nbbm2}}</td>
  258 + <td>{{obj.rq2}}</td>
  259 + <td>{{obj.jzyl2}}</td>
  260 + {{/if}}
  261 +
263 </tr> 262 </tr>
264 - {{/if}} 263 +
265 {{/each}} 264 {{/each}}
266 {{if list.length == 0}} 265 {{if list.length == 0}}
267 <tr> 266 <tr>
src/main/resources/static/pages/report/timetable/timetable.html
@@ -298,6 +298,33 @@ @@ -298,6 +298,33 @@
298 }); 298 });
299 } 299 }
300 300
  301 + /**
  302 + * 将模块List 转换为树结构
  303 + * @param arr
  304 + * @returns {Array}
  305 + */
  306 + function createTreeData(arr){
  307 + var treeData = [];
  308 + var len = arr.length;
  309 + for(var i = 0; i < len; i ++){
  310 + var pId = arr[i].pId;
  311 + arr[i].text = arr[i].name;
  312 + if(!pId){
  313 + treeData.push(arr[i]);
  314 + }
  315 +
  316 + for(var j = 0; j < len; j ++){
  317 + if(pId == arr[j].id){
  318 + if(!arr[j].children)
  319 + arr[j].children = [];
  320 + arr[j].children.push(arr[i]);
  321 + break;
  322 + }
  323 + }
  324 + }
  325 + return treeData;
  326 + }
  327 +
301 $("#line").on("change", function(){ 328 $("#line").on("change", function(){
302 line = $("#line").val(); 329 line = $("#line").val();
303 updateTtinfo(); 330 updateTtinfo();
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch/h_add_temp_sch.html
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 <div class="uk-form-row"> 30 <div class="uk-form-row">
31 <label class="uk-form-label">班次类型</label> 31 <label class="uk-form-label">班次类型</label>
32 <div class="uk-form-controls"> 32 <div class="uk-form-controls">
33 - <select class="form-control nt-dictionary" name="bcType" data-code="{{bcType}}" 33 + <select class="form-control nt-dictionary" required name="bcType" data-code="{{bcType}}"
34 data-group=ScheduleType></select> 34 data-group=ScheduleType></select>
35 </div> 35 </div>
36 </div> 36 </div>
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch_maintain.html
@@ -37,6 +37,8 @@ @@ -37,6 +37,8 @@
37 </div> 37 </div>
38 <button class="uk-button">检索</button> 38 <button class="uk-button">检索</button>
39 <a class="add_lp_link" ><i class="uk-icon-plus"></i> 临加路牌</a> 39 <a class="add_lp_link" ><i class="uk-icon-plus"></i> 临加路牌</a>
  40 + <button id="reCountBtn" class="uk-button uk-button-danger uk-button-mini" style="position: absolute;right: 12px;bottom: 14px;">
  41 + 重新统计</button>
40 </fieldset> 42 </fieldset>
41 </form> 43 </form>
42 </div> 44 </div>
@@ -414,6 +416,39 @@ @@ -414,6 +416,39 @@
414 416
415 return true; 417 return true;
416 } 418 }
  419 +
  420 + /**
  421 + * 重新统计
  422 + */
  423 + $('#reCountBtn', modal).on('click', function () {
  424 + $(this).attr('disabled', 'disabled');
  425 + $(this).prepend('<i class="uk-icon-spinner uk-icon-spin"></i>');
  426 +
  427 + var rq = $('.h-s-time li.uk-active', modal).text(),
  428 + lineName = $('.h-s-line li.uk-active', modal).text(),
  429 + lineCode = $('.h-s-line li.uk-active', modal).data('id');
  430 +
  431 + var that = this;
  432 + alt_confirm('确定要重新统计 ' + lineName + '('+rq+')的数据吗?',function () {
  433 +
  434 + var reCountEp = EventProxy.create('calcWaybill', 'ylbUpdate', function () {
  435 + $('i.uk-icon-spin', that).remove();
  436 + $(this).removeAttr('disabled');
  437 + notify_succ('重新统计成功!');
  438 + });
  439 +
  440 + //统计路单 -娄高峰
  441 + gb_common.$get('/calcWaybill/generateNew', {date:rq, line: lineCode}, function () {
  442 + reCountEp.emitLater('calcWaybill');
  443 + });
  444 +
  445 + //统计油 -廖磊
  446 + gb_common.$post('/ylb/updateHistory', {date:rq, line: lineCode}, function () {
  447 + reCountEp.emitLater('ylbUpdate');
  448 + });
  449 +
  450 + }, '我确定');
  451 + });
417 })(); 452 })();
418 </script> 453 </script>
419 </div> 454 </div>
420 \ No newline at end of file 455 \ No newline at end of file
src/main/resources/static/real_control_v2/js/forms/wrap.html
@@ -100,9 +100,13 @@ @@ -100,9 +100,13 @@
100 //ed=d.format(f), 100 //ed=d.format(f),
101 //sd=d.subtract(3, 'days').format(f); 101 //sd=d.subtract(3, 'days').format(f);
102 102
103 - $('#date', '.form-page-content').data('DateTimePicker')  
104 - .defaultDate(d.format(f));  
105 - //.maxDate(ed).minDate(sd); 103 + try{
  104 + $('#date', '.form-page-content').data('DateTimePicker')
  105 + .defaultDate(d.format(f));
  106 + //.maxDate(ed).minDate(sd);
  107 + }catch (e){
  108 + console.log(e);
  109 + }
106 110
107 if($("#ddrbBody").length > 0){ 111 if($("#ddrbBody").length > 0){
108 $("#ddrbBody").height("620px"); 112 $("#ddrbBody").height("620px");