Commit f06d9fa5e846b74c9686bba158f99702585edb8d
Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control into pudong
Showing
51 changed files
with
2449 additions
and
1397 deletions
Too many changes to show.
To preserve performance only 51 of 78 files are displayed.
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<LineVersions, Integer | @@ -80,4 +76,13 @@ public class LineVersionsController extends BaseController<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<Ylb, Integer>{ | @@ -210,7 +210,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 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
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
src/main/java/com/bsth/repository/LineVersionsRepository.java
| @@ -73,4 +73,10 @@ public interface LineVersionsRepository extends BaseRepository<LineVersions, Int | @@ -73,4 +73,10 @@ public interface LineVersionsRepository extends BaseRepository<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<Ylb, Integer>{ | @@ -52,7 +52,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ | ||
| 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<LineVersions, Integer> | @@ -33,6 +33,9 @@ public interface LineVersionsService extends BaseService<LineVersions, Integer> | ||
| 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<CalcWaybill, Integer | @@ -69,7 +69,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<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<CalcWaybill, Integer | @@ -82,7 +82,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<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<LineVersions, Integ | @@ -250,5 +250,13 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<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<Station, Integer> implem | @@ -83,6 +86,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -293,20 +299,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -318,12 +313,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -417,8 +411,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -782,68 +777,65 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -1200,8 +1192,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -1229,8 +1222,8 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -1372,20 +1365,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Station, Integer> implem | @@ -1397,12 +1379,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> 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<Ylb, Integer>{ | @@ -19,7 +19,7 @@ public interface YlbService extends BaseService<Ylb, Integer>{ | ||
| 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<Dlb,Integer> implements DlbS | @@ -576,55 +576,44 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> 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<Dlb,Integer> implements DlbS | @@ -983,17 +972,22 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> 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<Ylb,Integer> implements YlbS | @@ -73,6 +74,10 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -832,7 +837,10 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -840,7 +848,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -868,23 +876,86 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -895,9 +966,15 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1429,8 +1506,14 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1462,15 +1545,22 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1478,7 +1568,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1499,43 +1589,45 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1592,21 +1684,114 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<Ylb,Integer> implements YlbS | @@ -1619,7 +1804,15 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> 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<ChildTaskPlan, Lon | @@ -78,7 +79,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl<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<ChildTaskPlan, Lon | @@ -96,6 +97,7 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -503,6 +501,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -603,6 +602,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -3344,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4336,7 +4338,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4359,7 +4362,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4506,7 +4509,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4514,15 +4516,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4532,16 +4535,19 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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<ScheduleRealInf | @@ -4556,26 +4562,37 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<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
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 @@ $('#add_station_mobal').on('AddStationMobal.show', function(e, addMap,ajaxd,stao | @@ -237,12 +237,8 @@ $('#add_station_mobal').on('AddStationMobal.show', 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 | + |