Commit 7631c99fb297e10c63dc50bf4ee33aae77efc59b
Merge branch 'pudong' into jiading
Showing
69 changed files
with
2533 additions
and
629 deletions
Too many changes to show.
To preserve performance only 69 of 172 files are displayed.
src/main/java/com/bsth/XDApplication.java
| @@ -139,17 +139,17 @@ public class XDApplication implements CommandLineRunner { | @@ -139,17 +139,17 @@ public class XDApplication implements CommandLineRunner { | ||
| 139 | 139 | ||
| 140 | /** 线调业务 */ | 140 | /** 线调业务 */ |
| 141 | sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 | 141 | sexec.scheduleWithFixedDelay(scheduleRefreshThread, 10, 120, TimeUnit.SECONDS);//班次更新线程 |
| 142 | - sexec.scheduleWithFixedDelay(scheduleLateThread, 70, 30, TimeUnit.SECONDS);//检查班次误点 | 142 | + sexec.scheduleWithFixedDelay(scheduleLateThread, 140, 30, TimeUnit.SECONDS);//检查班次误点 |
| 143 | sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 | 143 | sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 |
| 144 | 144 | ||
| 145 | sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线 | 145 | sexec.scheduleWithFixedDelay(offlineMonitorThread, 120, 60, TimeUnit.SECONDS);//GPS设备掉离线 |
| 146 | - sexec.scheduleWithFixedDelay(schedulePstThread, 120, 10, TimeUnit.SECONDS);//班次延迟入库线程 | ||
| 147 | - sexec.scheduleWithFixedDelay(seiPstThread, 160, 60, TimeUnit.SECONDS);//班次修正日志入库 | 146 | + sexec.scheduleWithFixedDelay(schedulePstThread, 180, 10, TimeUnit.SECONDS);//班次延迟入库线程 |
| 147 | + sexec.scheduleWithFixedDelay(seiPstThread, 180, 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, 180, 50, TimeUnit.SECONDS);//班次自动执行 |
| 153 | DirectivePushQueue.start();//消息队列 -指令,系统下发的 | 153 | DirectivePushQueue.start();//消息队列 -指令,系统下发的 |
| 154 | WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 | 154 | WebSocketPushQueue.start();//消息队列 -webSocket ,推送至线调web页面的 |
| 155 | 155 |
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/LineController.java
| @@ -90,7 +90,7 @@ public class LineController extends BaseController<Line, Integer> { | @@ -90,7 +90,7 @@ public class LineController extends BaseController<Line, Integer> { | ||
| 90 | lineVersions.setName("原始版本"); | 90 | lineVersions.setName("原始版本"); |
| 91 | lineVersions.setLine(t); | 91 | lineVersions.setLine(t); |
| 92 | lineVersions.setLineCode(t.getLineCode()); | 92 | lineVersions.setLineCode(t.getLineCode()); |
| 93 | - lineVersions.setStartDate(t.getCreateDate()); | 93 | + lineVersions.setStartDate(new java.sql.Date(new Date().getTime())); |
| 94 | lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00 | 94 | lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00 |
| 95 | lineVersions.setVersions(1); | 95 | lineVersions.setVersions(1); |
| 96 | lineVersions.setStatus(1); | 96 | lineVersions.setStatus(1); |
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,21 @@ public class LineVersionsController extends BaseController<LineVersions, Integer | @@ -80,4 +76,21 @@ 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 | + | ||
| 88 | + /** | ||
| 89 | + * 根据id发布版本号(修改isupdate字段) | ||
| 90 | + */ | ||
| 91 | + @RequestMapping(value = "issueVersion", method = RequestMethod.POST) | ||
| 92 | + public Map<String, Object> issueVersion(@RequestParam(defaultValue = "id") int id) { | ||
| 93 | + return service.issueVersion(id); | ||
| 94 | + } | ||
| 95 | + | ||
| 83 | } | 96 | } |
src/main/java/com/bsth/controller/SectionRouteController.java
| @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; | @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam; | ||
| 10 | import org.springframework.web.bind.annotation.RestController; | 10 | import org.springframework.web.bind.annotation.RestController; |
| 11 | 11 | ||
| 12 | import com.bsth.entity.SectionRoute; | 12 | import com.bsth.entity.SectionRoute; |
| 13 | +import com.bsth.entity.StationRouteCache; | ||
| 13 | import com.bsth.service.SectionRouteService; | 14 | import com.bsth.service.SectionRouteService; |
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| @@ -55,6 +56,12 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | @@ -55,6 +56,12 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | ||
| 55 | public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) { | 56 | public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) { |
| 56 | return routeService.list(map); | 57 | return routeService.list(map); |
| 57 | } | 58 | } |
| 59 | + | ||
| 60 | + @RequestMapping(value = "/cacheList", method = RequestMethod.GET) | ||
| 61 | + public List<StationRouteCache> cacheList(@RequestParam Map<String, Object> map) { | ||
| 62 | +// routeService.cacheList(map) | ||
| 63 | + return null; | ||
| 64 | + } | ||
| 58 | 65 | ||
| 59 | /** | 66 | /** |
| 60 | * @Description :TODO(查询路段信息) | 67 | * @Description :TODO(查询路段信息) |
| @@ -76,8 +83,8 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | @@ -76,8 +83,8 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | ||
| 76 | * | 83 | * |
| 77 | * @return Map<String, Object> | 84 | * @return Map<String, Object> |
| 78 | */ | 85 | */ |
| 79 | - @RequestMapping(value = "/findSectionCache" , method = RequestMethod.GET) | ||
| 80 | - public List<Map<String, Object>> findPointsCache(@RequestParam Map<String, Object> map) { | 86 | + @RequestMapping(value = "/findCacheSection" , method = RequestMethod.GET) |
| 87 | + public List<Map<String, Object>> getSectionRouteCache(@RequestParam Map<String, Object> map) { | ||
| 81 | return routeService.getSectionRouteCache(map); | 88 | return routeService.getSectionRouteCache(map); |
| 82 | } | 89 | } |
| 83 | 90 | ||
| @@ -105,6 +112,11 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | @@ -105,6 +112,11 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer | ||
| 105 | return routeService.findUpSectionRouteCode(map); | 112 | return routeService.findUpSectionRouteCode(map); |
| 106 | } | 113 | } |
| 107 | 114 | ||
| 115 | + @RequestMapping(value = "/findCacheUpSectionRouteCode" , method = RequestMethod.GET) | ||
| 116 | + public List<Map<String, Object>> findCacheUpSectionRouteCode(@RequestParam Map<String, Object> map) { | ||
| 117 | + return routeService.findCacheUpSectionRouteCode(map); | ||
| 118 | + } | ||
| 119 | + | ||
| 108 | /** | 120 | /** |
| 109 | * @Description :TODO(引用路段) | 121 | * @Description :TODO(引用路段) |
| 110 | * | 122 | * |
src/main/java/com/bsth/controller/StationController.java
| @@ -157,4 +157,15 @@ public class StationController extends BaseController<Station, Integer> { | @@ -157,4 +157,15 @@ public class StationController extends BaseController<Station, Integer> { | ||
| 157 | return GetUIDAndCode.getStationId(); | 157 | return GetUIDAndCode.getStationId(); |
| 158 | 158 | ||
| 159 | } | 159 | } |
| 160 | + /** | ||
| 161 | + * @Description :TODO(查询站点编码) | ||
| 162 | + * | ||
| 163 | + * @return int <stationCode站点编码> | ||
| 164 | + */ | ||
| 165 | + @RequestMapping(value="stationCacheSave" , method = RequestMethod.POST) | ||
| 166 | + public Map<String, Object> stationCacheSave(@RequestParam Map<String, Object> map) { | ||
| 167 | + map.put("createBy", ""); | ||
| 168 | + map.put("updateBy", ""); | ||
| 169 | + return service.stationCacheSave(map); | ||
| 170 | + } | ||
| 160 | } | 171 | } |
src/main/java/com/bsth/controller/forms/ExportController.java
| @@ -214,7 +214,47 @@ public class ExportController { | @@ -214,7 +214,47 @@ public class ExportController { | ||
| 214 | 214 | ||
| 215 | return resList; | 215 | return resList; |
| 216 | } | 216 | } |
| 217 | + @RequestMapping(value = "/singledataExportTj", method = RequestMethod.GET) | ||
| 218 | + public List<Map<String, Object>> singledataExportTj(@RequestParam Map<String, Object> map) { | ||
| 219 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 220 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 221 | + ReportUtils ee = new ReportUtils(); | ||
| 222 | + List<Singledata> singledata = formsService.singledatatj(map); | ||
| 223 | + List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | ||
| 224 | + int i = 1; | ||
| 225 | + for (Singledata l : singledata) { | ||
| 226 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 227 | + m.put("i", i); | ||
| 228 | + m.put("rQ", l.getrQ()); | ||
| 229 | + m.put("gS", l.getgS()); | ||
| 230 | + m.put("xL", l.getXlmc()); | ||
| 231 | + m.put("clzbh", l.getClzbh()); | ||
| 232 | + m.put("jsy", l.getJsy()); | ||
| 233 | + m.put("jName", l.getjName()); | ||
| 234 | + m.put("sgh", l.getSgh()); | ||
| 235 | + m.put("sName", l.getsName()); | ||
| 236 | + m.put("jhlc", l.getJhlc()); | ||
| 237 | + m.put("emptMileage", l.getEmptMileage()); | ||
| 238 | + m.put("hyl", l.getHyl()); | ||
| 239 | + m.put("jzl", l.getJzl()); | ||
| 240 | + m.put("unyyyl", l.getUnyyyl()); | ||
| 241 | + m.put("jhjl", l.getJhjl()); | ||
| 242 | + resList.add(m); | ||
| 243 | + | ||
| 244 | + i++; | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + try { | ||
| 248 | + listI.add(resList.iterator()); | ||
| 249 | + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/"; | ||
| 250 | + ee.excelReplace(listI, new Object[] { map }, path + "mould/singledata.xls", | ||
| 251 | + path + "export/路单数据" + sdfSimple.format(sdfMonth.parse(map.get("startDate").toString())) + ".xls"); | ||
| 252 | + } catch (Exception e) { | ||
| 253 | + e.printStackTrace(); | ||
| 254 | + } | ||
| 217 | 255 | ||
| 256 | + return resList; | ||
| 257 | + } | ||
| 218 | // 车辆加注 | 258 | // 车辆加注 |
| 219 | @RequestMapping(value = "/vehicleloadingExport", method = RequestMethod.GET) | 259 | @RequestMapping(value = "/vehicleloadingExport", method = RequestMethod.GET) |
| 220 | public List<Map<String, Object>> vehicleloadingExport(@RequestParam Map<String, Object> map) { | 260 | public List<Map<String, Object>> vehicleloadingExport(@RequestParam Map<String, Object> map) { |
src/main/java/com/bsth/controller/forms/MCY_FormsController.java
| @@ -83,9 +83,15 @@ public class MCY_FormsController { | @@ -83,9 +83,15 @@ public class MCY_FormsController { | ||
| 83 | @RequestMapping(value = "/singledatanew", method = RequestMethod.GET) | 83 | @RequestMapping(value = "/singledatanew", method = RequestMethod.GET) |
| 84 | public List<Singledata> singledatanew(@RequestParam Map<String, Object> map) { | 84 | public List<Singledata> singledatanew(@RequestParam Map<String, Object> map) { |
| 85 | 85 | ||
| 86 | - return formsService.singledata(map); | 86 | + return formsService.singledatanew(map); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | + @RequestMapping(value = "/singledatatj", method = RequestMethod.GET) | ||
| 90 | + public List<Singledata> singledatatj(@RequestParam Map<String, Object> map) { | ||
| 91 | + | ||
| 92 | + return formsService.singledatatj(map); | ||
| 93 | + } | ||
| 94 | + | ||
| 89 | // 车辆加注 | 95 | // 车辆加注 |
| 90 | @RequestMapping(value = "/vehicleloading", method = RequestMethod.GET) | 96 | @RequestMapping(value = "/vehicleloading", method = RequestMethod.GET) |
| 91 | public List<Vehicleloading> vehicleloading(@RequestParam String line, @RequestParam String data) { | 97 | public List<Vehicleloading> vehicleloading(@RequestParam String line, @RequestParam String data) { |
src/main/java/com/bsth/controller/geo_data/GeoDataController.java
0 → 100644
| 1 | +package com.bsth.controller.geo_data; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.geo_data.GeoStation; | ||
| 4 | +import com.bsth.service.geo_data.GeoDataService; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/12/7. | ||
| 15 | + */ | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("/_geo_data") | ||
| 18 | +public class GeoDataController { | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + GeoDataService geoDataService; | ||
| 22 | + | ||
| 23 | + @RequestMapping("findGeoStations") | ||
| 24 | + public Map<String, Object> findGeoStations(@RequestParam String lineCode){ | ||
| 25 | + return geoDataService.findGeoStations(lineCode); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + @RequestMapping("findGeoRoad") | ||
| 30 | + public Map<String, Object> findGeoRoad(@RequestParam String lineCode){ | ||
| 31 | + return geoDataService.findGeoRoad(lineCode); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + @RequestMapping(value = "updateBufferInfo",method = RequestMethod.POST) | ||
| 35 | + public Map<String, Object> updateBufferInfo(GeoStation station){ | ||
| 36 | + return geoDataService.updateBufferInfo(station); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @RequestMapping(value = "updateStationName",method = RequestMethod.POST) | ||
| 40 | + public Map<String, Object> updateStationName(@RequestParam Map<String, Object> map){ | ||
| 41 | + return geoDataService.updateStationName(map); | ||
| 42 | + } | ||
| 43 | +} | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
src/main/java/com/bsth/controller/oil/DlbController.java
| @@ -224,4 +224,9 @@ public class DlbController extends BaseController<Dlb, Integer>{ | @@ -224,4 +224,9 @@ public class DlbController extends BaseController<Dlb, Integer>{ | ||
| 224 | // Ylb t=new Ylb(); | 224 | // Ylb t=new Ylb(); |
| 225 | return service.saveDlb(t); | 225 | return service.saveDlb(t); |
| 226 | } | 226 | } |
| 227 | + | ||
| 228 | + @RequestMapping(value = "/updateJsy",method = RequestMethod.GET) | ||
| 229 | + public Map<String, Object> updateJsy(@RequestParam Map<String, Object> map){ | ||
| 230 | + return service.update(map); | ||
| 231 | + } | ||
| 227 | } | 232 | } |
src/main/java/com/bsth/controller/oil/YlbController.java
| @@ -11,6 +11,8 @@ import java.util.Iterator; | @@ -11,6 +11,8 @@ import java.util.Iterator; | ||
| 11 | import java.util.List; | 11 | import java.util.List; |
| 12 | import java.util.Map; | 12 | import java.util.Map; |
| 13 | 13 | ||
| 14 | +import javax.servlet.http.HttpServletRequest; | ||
| 15 | + | ||
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.data.domain.Page; | 17 | import org.springframework.data.domain.Page; |
| 16 | import org.springframework.data.domain.PageRequest; | 18 | import org.springframework.data.domain.PageRequest; |
| @@ -35,14 +37,19 @@ import com.google.common.base.Splitter; | @@ -35,14 +37,19 @@ import com.google.common.base.Splitter; | ||
| 35 | @RequestMapping("ylb") | 37 | @RequestMapping("ylb") |
| 36 | public class YlbController extends BaseController<Ylb, Integer>{ | 38 | public class YlbController extends BaseController<Ylb, Integer>{ |
| 37 | @Autowired | 39 | @Autowired |
| 38 | - YlbService yblService; | 40 | + YlbService ylbService; |
| 39 | 41 | ||
| 40 | @RequestMapping(value = "/saveYlb",method = RequestMethod.POST) | 42 | @RequestMapping(value = "/saveYlb",method = RequestMethod.POST) |
| 41 | public Map<String, Object> saveYlb(Ylb t){ | 43 | public Map<String, Object> saveYlb(Ylb t){ |
| 42 | // SysUser user = SecurityUtils.getCurrentUser(); | 44 | // SysUser user = SecurityUtils.getCurrentUser(); |
| 43 | t.setCreatetime(new Date()); | 45 | t.setCreatetime(new Date()); |
| 44 | // Ylb t=new Ylb(); | 46 | // Ylb t=new Ylb(); |
| 45 | - return yblService.saveYlb(t); | 47 | + return ylbService.saveYlb(t); |
| 48 | + } | ||
| 49 | + | ||
| 50 | + @RequestMapping(value = "/updateJsy",method = RequestMethod.GET) | ||
| 51 | + public Map<String, Object> updateJsy(@RequestParam Map<String, Object> map){ | ||
| 52 | + return ylbService.update(map); | ||
| 46 | } | 53 | } |
| 47 | 54 | ||
| 48 | 55 | ||
| @@ -55,7 +62,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -55,7 +62,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 55 | public Map<String, Object> obtain(@RequestParam Map<String, Object> map) throws Exception{ | 62 | public Map<String, Object> obtain(@RequestParam Map<String, Object> map) throws Exception{ |
| 56 | Map<String, Object> list =new HashMap<String, Object>(); | 63 | Map<String, Object> list =new HashMap<String, Object>(); |
| 57 | try { | 64 | try { |
| 58 | - list = yblService.obtain(map); | 65 | + |
| 66 | + list = ylbService.obtain(map); | ||
| 59 | } catch (Exception e) { | 67 | } catch (Exception e) { |
| 60 | // TODO Auto-generated catch block | 68 | // TODO Auto-generated catch block |
| 61 | throw e; | 69 | throw e; |
| @@ -69,7 +77,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -69,7 +77,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 69 | public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){ | 77 | public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){ |
| 70 | Map<String, Object> list=new HashMap<String, Object>(); | 78 | Map<String, Object> list=new HashMap<String, Object>(); |
| 71 | try { | 79 | try { |
| 72 | - list = yblService.saveYlbList(map); | 80 | + list = ylbService.saveYlbList(map); |
| 73 | } catch (Exception e) { | 81 | } catch (Exception e) { |
| 74 | // TODO Auto-generated catch block | 82 | // TODO Auto-generated catch block |
| 75 | e.printStackTrace(); | 83 | e.printStackTrace(); |
| @@ -85,7 +93,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -85,7 +93,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 85 | public Map<String, Object> sort(@RequestParam Map<String, Object> map){ | 93 | public Map<String, Object> sort(@RequestParam Map<String, Object> map){ |
| 86 | Map<String, Object> list=new HashMap<String, Object>(); | 94 | Map<String, Object> list=new HashMap<String, Object>(); |
| 87 | try { | 95 | try { |
| 88 | - list=yblService.sort(map); | 96 | + list=ylbService.sort(map); |
| 89 | } catch (Exception e) { | 97 | } catch (Exception e) { |
| 90 | // TODO: handle exception | 98 | // TODO: handle exception |
| 91 | } | 99 | } |
| @@ -101,7 +109,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -101,7 +109,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 101 | public Map<String, Object> outAndIn(@RequestParam Map<String, Object> map) throws Exception{ | 109 | public Map<String, Object> outAndIn(@RequestParam Map<String, Object> map) throws Exception{ |
| 102 | Map<String, Object> list=new HashMap<String, Object>(); | 110 | Map<String, Object> list=new HashMap<String, Object>(); |
| 103 | try { | 111 | try { |
| 104 | - list=yblService.outAndIn(map); | 112 | + |
| 113 | + list=ylbService.outAndIn(map); | ||
| 105 | } catch (Exception e) { | 114 | } catch (Exception e) { |
| 106 | // TODO: handle exception | 115 | // TODO: handle exception |
| 107 | } | 116 | } |
| @@ -118,7 +127,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -118,7 +127,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 118 | public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ | 127 | public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ |
| 119 | Map<String, Object> list=new HashMap<String, Object>(); | 128 | Map<String, Object> list=new HashMap<String, Object>(); |
| 120 | try { | 129 | try { |
| 121 | - list=yblService.checkYl(map); | 130 | + list=ylbService.checkYl(map); |
| 122 | } catch (Exception e) { | 131 | } catch (Exception e) { |
| 123 | // TODO: handle exception | 132 | // TODO: handle exception |
| 124 | } | 133 | } |
| @@ -146,7 +155,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -146,7 +155,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 146 | String rq=map.get("rq").toString(); | 155 | String rq=map.get("rq").toString(); |
| 147 | int lx=Integer.parseInt(map.get("sxtj").toString().trim()); | 156 | int lx=Integer.parseInt(map.get("sxtj").toString().trim()); |
| 148 | if(lx>0){ | 157 | if(lx>0){ |
| 149 | - map.put("nbbm_in", yblService.checkNbmmNum(rq, map.get("ssgsdm_like").toString(), | 158 | + map.put("nbbm_in", ylbService.checkNbmmNum(rq, map.get("ssgsdm_like").toString(), |
| 150 | map.get("fgsdm_like").toString(), map.get("xlbm_like").toString(), | 159 | map.get("fgsdm_like").toString(), map.get("xlbm_like").toString(), |
| 151 | map.get("nbbm_eq").toString(),lx)); | 160 | map.get("nbbm_eq").toString(),lx)); |
| 152 | } | 161 | } |
| @@ -194,7 +203,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -194,7 +203,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 194 | */ | 203 | */ |
| 195 | @RequestMapping(value = "/ylbList",method = RequestMethod.GET) | 204 | @RequestMapping(value = "/ylbList",method = RequestMethod.GET) |
| 196 | public List<Ylb> ylbList(@RequestParam Map<String, Object> map){ | 205 | public List<Ylb> ylbList(@RequestParam Map<String, Object> map){ |
| 197 | - List<Ylb> ylbList=yblService.listYlb(map); | 206 | + List<Ylb> ylbList=ylbService.listYlb(map); |
| 198 | return ylbList; | 207 | return ylbList; |
| 199 | } | 208 | } |
| 200 | 209 | ||
| @@ -202,7 +211,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -202,7 +211,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 202 | public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) { | 211 | public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) { |
| 203 | Map<String, Object> maps=new HashMap<String, Object>(); | 212 | Map<String, Object> maps=new HashMap<String, Object>(); |
| 204 | try { | 213 | try { |
| 205 | - maps= yblService.deleteIds(map); | 214 | + maps= ylbService.deleteIds(map); |
| 206 | } catch (Exception e) { | 215 | } catch (Exception e) { |
| 207 | // TODO Auto-generated catch block | 216 | // TODO Auto-generated catch block |
| 208 | e.printStackTrace(); | 217 | e.printStackTrace(); |
| @@ -210,19 +219,19 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -210,19 +219,19 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 210 | return maps; | 219 | return maps; |
| 211 | } | 220 | } |
| 212 | @RequestMapping(value="/oilListMonth") | 221 | @RequestMapping(value="/oilListMonth") |
| 213 | - public List<Ylb> oilListMonth(@RequestParam Map<String, Object> map){ | ||
| 214 | - return yblService.oilListMonth(map); | 222 | + public List<Map<String, Object>> oilListMonth(@RequestParam Map<String, Object> map){ |
| 223 | + return ylbService.oilListMonth(map); | ||
| 215 | } | 224 | } |
| 216 | 225 | ||
| 217 | @RequestMapping(value = "/checkJsy",method = RequestMethod.GET) | 226 | @RequestMapping(value = "/checkJsy",method = RequestMethod.GET) |
| 218 | public String checkJsy(@RequestParam Map<String, Object> map){ | 227 | public String checkJsy(@RequestParam Map<String, Object> map){ |
| 219 | - String list=yblService.checkJsy(map); | 228 | + String list=ylbService.checkJsy(map); |
| 220 | return list; | 229 | return list; |
| 221 | } | 230 | } |
| 222 | 231 | ||
| 223 | @RequestMapping(value = "/sumYlb",method = RequestMethod.GET) | 232 | @RequestMapping(value = "/sumYlb",method = RequestMethod.GET) |
| 224 | public Map<String, Object> sumYlb(@RequestParam Map<String, Object> map){ | 233 | public Map<String, Object> sumYlb(@RequestParam Map<String, Object> map){ |
| 225 | - Map<String, Object> list=yblService.sumYlb(map); | 234 | + Map<String, Object> list=ylbService.sumYlb(map); |
| 226 | return list; | 235 | return list; |
| 227 | } | 236 | } |
| 228 | 237 | ||
| @@ -232,7 +241,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -232,7 +241,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 232 | sdfSimple = new SimpleDateFormat("yyyyMMdd"); | 241 | sdfSimple = new SimpleDateFormat("yyyyMMdd"); |
| 233 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | 242 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); |
| 234 | ReportUtils ee = new ReportUtils(); | 243 | ReportUtils ee = new ReportUtils(); |
| 235 | - List<Ylb> ylb= yblService.listYlb(map); | 244 | + List<Ylb> ylb= ylbService.listYlb(map); |
| 236 | // (new CustomerSpecs<Ylb>(map)).iterator(); | 245 | // (new CustomerSpecs<Ylb>(map)).iterator(); |
| 237 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); | 246 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 238 | for (Ylb y : ylb) { | 247 | for (Ylb y : ylb) { |
| @@ -299,7 +308,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -299,7 +308,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 299 | public Map<String, Object> updateHistory(@RequestParam Map<String, Object> map) throws Exception{ | 308 | public Map<String, Object> updateHistory(@RequestParam Map<String, Object> map) throws Exception{ |
| 300 | Map<String, Object> list =new HashMap<String, Object>(); | 309 | Map<String, Object> list =new HashMap<String, Object>(); |
| 301 | try { | 310 | try { |
| 302 | - list = yblService.updateHistory(map); | 311 | + list = ylbService.updateHistory(map); |
| 303 | } catch (Exception e) { | 312 | } catch (Exception e) { |
| 304 | // TODO Auto-generated catch block | 313 | // TODO Auto-generated catch block |
| 305 | throw e; | 314 | throw e; |
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
| @@ -4,18 +4,14 @@ import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | @@ -4,18 +4,14 @@ import com.bsth.data.gpsdata_v2.cache.GpsCacheData; | ||
| 4 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; | 4 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 5 | import com.bsth.data.gpsdata_v2.handlers.*; | 5 | import com.bsth.data.gpsdata_v2.handlers.*; |
| 6 | import com.google.common.collect.ArrayListMultimap; | 6 | import com.google.common.collect.ArrayListMultimap; |
| 7 | +import org.apache.commons.lang3.StringUtils; | ||
| 7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.stereotype.Component; | 11 | import org.springframework.stereotype.Component; |
| 11 | 12 | ||
| 12 | -import java.util.ArrayList; | ||
| 13 | -import java.util.List; | ||
| 14 | -import java.util.Set; | ||
| 15 | -import java.util.concurrent.CountDownLatch; | ||
| 16 | -import java.util.concurrent.ExecutorService; | ||
| 17 | -import java.util.concurrent.Executors; | ||
| 18 | -import java.util.concurrent.ThreadFactory; | 13 | +import java.util.*; |
| 14 | +import java.util.concurrent.*; | ||
| 19 | 15 | ||
| 20 | /** | 16 | /** |
| 21 | * 实时信号数据处理 | 17 | * 实时信号数据处理 |
| @@ -24,12 +20,6 @@ import java.util.concurrent.ThreadFactory; | @@ -24,12 +20,6 @@ import java.util.concurrent.ThreadFactory; | ||
| 24 | @Component | 20 | @Component |
| 25 | public class DataHandleProcess { | 21 | public class DataHandleProcess { |
| 26 | 22 | ||
| 27 | - static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class); | ||
| 28 | - final static int POOL_SIZE = 25; | ||
| 29 | - | ||
| 30 | - static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1, new HandlerThreadFactory()); | ||
| 31 | - public static CountDownLatch count; | ||
| 32 | - | ||
| 33 | @Autowired | 23 | @Autowired |
| 34 | GpsStateProcess gpsStateProcess; | 24 | GpsStateProcess gpsStateProcess; |
| 35 | @Autowired | 25 | @Autowired |
| @@ -42,12 +32,28 @@ public class DataHandleProcess { | @@ -42,12 +32,28 @@ public class DataHandleProcess { | ||
| 42 | OutStationProcess outStationProcess; | 32 | OutStationProcess outStationProcess; |
| 43 | @Autowired | 33 | @Autowired |
| 44 | ReverseRouteProcess reverseRouteProcess; | 34 | ReverseRouteProcess reverseRouteProcess; |
| 45 | - | ||
| 46 | @Autowired | 35 | @Autowired |
| 47 | GpsRealData gpsRealData; | 36 | GpsRealData gpsRealData; |
| 48 | 37 | ||
| 38 | + | ||
| 39 | + static Logger logger = LoggerFactory.getLogger(DataHandleProcess.class); | ||
| 40 | + | ||
| 41 | + final static int POOL_SIZE = 25; | ||
| 42 | + | ||
| 43 | + static ExecutorService threadPool = Executors.newFixedThreadPool(POOL_SIZE + 1); | ||
| 44 | + public static CountDownLatch count; | ||
| 45 | + | ||
| 46 | + static long lastTime; | ||
| 47 | + | ||
| 48 | + public static boolean isBlock() { | ||
| 49 | + return System.currentTimeMillis() - lastTime > 1000 * 30; | ||
| 50 | + } | ||
| 51 | + | ||
| 49 | public void handle(List<GpsEntity> list) { | 52 | public void handle(List<GpsEntity> list) { |
| 50 | try { | 53 | try { |
| 54 | + if (list.size() == 0) | ||
| 55 | + return; | ||
| 56 | + lastTime = System.currentTimeMillis(); | ||
| 51 | //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑) | 57 | //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑) |
| 52 | ArrayListMultimap multimap = ArrayListMultimap.create(); | 58 | ArrayListMultimap multimap = ArrayListMultimap.create(); |
| 53 | for (GpsEntity gps : list) { | 59 | for (GpsEntity gps : list) { |
| @@ -67,21 +73,50 @@ public class DataHandleProcess { | @@ -67,21 +73,50 @@ public class DataHandleProcess { | ||
| 67 | logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size()); | 73 | logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size()); |
| 68 | count = new CountDownLatch(ks.size()); | 74 | count = new CountDownLatch(ks.size()); |
| 69 | 75 | ||
| 76 | + List<Future> fRs = new ArrayList<>(ks.size()); | ||
| 70 | for (Integer index : ks) { | 77 | for (Integer index : ks) { |
| 71 | - threadPool.execute(new SignalHandleThread(dataListMap.get(index), count)); | 78 | + fRs.add(threadPool.submit(new SignalHandleThread(dataListMap.get(index), count))); |
| 79 | + } | ||
| 80 | + | ||
| 81 | + //按线路分组gps | ||
| 82 | + /*ArrayListMultimap multimap = ArrayListMultimap.create(); | ||
| 83 | + for (GpsEntity gps : list) { | ||
| 84 | + multimap.put(gps.getLineId(), gps); | ||
| 72 | } | 85 | } |
| 73 | 86 | ||
| 87 | + Set<String> ks = multimap.keySet(); | ||
| 88 | + | ||
| 89 | + logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size()); | ||
| 90 | + count = new CountDownLatch(ks.size()); | ||
| 91 | + | ||
| 92 | + for (String lineCode : ks) { | ||
| 93 | + threadPool.execute(new SignalHandleThread(multimap.get(lineCode), count)); | ||
| 94 | + }*/ | ||
| 95 | + | ||
| 74 | //等待子线程结束 | 96 | //等待子线程结束 |
| 75 | count.await(); | 97 | count.await(); |
| 76 | 98 | ||
| 99 | + for (Future f : fRs) { | ||
| 100 | + try { | ||
| 101 | + f.get(); | ||
| 102 | + } catch (InterruptedException e) { | ||
| 103 | + } catch (ExecutionException e) { | ||
| 104 | + logger.error(e.getCause().getMessage()); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + | ||
| 77 | //加入实时gps对照 | 108 | //加入实时gps对照 |
| 78 | for (GpsEntity gps : list) | 109 | for (GpsEntity gps : list) |
| 79 | gpsRealData.put(gps); | 110 | gpsRealData.put(gps); |
| 111 | + | ||
| 112 | + logger.info("time , " + (System.currentTimeMillis() - lastTime)); | ||
| 80 | } catch (Exception e) { | 113 | } catch (Exception e) { |
| 81 | logger.error("", e); | 114 | logger.error("", e); |
| 82 | } | 115 | } |
| 83 | } | 116 | } |
| 84 | 117 | ||
| 118 | + static GpsComp comp = new GpsComp(); | ||
| 119 | + | ||
| 85 | public class SignalHandleThread implements Runnable { | 120 | public class SignalHandleThread implements Runnable { |
| 86 | 121 | ||
| 87 | List<GpsEntity> list; | 122 | List<GpsEntity> list; |
| @@ -94,45 +129,44 @@ public class DataHandleProcess { | @@ -94,45 +129,44 @@ public class DataHandleProcess { | ||
| 94 | 129 | ||
| 95 | @Override | 130 | @Override |
| 96 | public void run() { | 131 | public void run() { |
| 97 | - try { | ||
| 98 | - for (GpsEntity gps : list) { | ||
| 99 | - try{ | ||
| 100 | - if(Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20) | ||
| 101 | - continue; | ||
| 102 | - | ||
| 103 | - gpsStateProcess.process(gps);//状态处理 | ||
| 104 | - stationInsideProcess.process(gps);//场站内外判定 | ||
| 105 | - reverseRouteProcess.process(gps);//反向路由处理 | ||
| 106 | - abnormalStateProcess.process(gps);//超速越界 | ||
| 107 | - | ||
| 108 | - inStationProcess.process(gps);//进站 | ||
| 109 | - outStationProcess.process(gps);//出站 | ||
| 110 | - | ||
| 111 | - GpsCacheData.putGps(gps);//历史gps缓存 | ||
| 112 | - }catch (Exception e){ | ||
| 113 | - logger.error("", e); | ||
| 114 | - } | 132 | + //try { |
| 133 | + Collections.sort(list, comp); | ||
| 134 | + for (GpsEntity gps : list) { | ||
| 135 | + try { | ||
| 136 | + if(StringUtils.isEmpty(gps.getNbbm())) | ||
| 137 | + continue; | ||
| 138 | + if (Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) > 1000 * 60 * 20) | ||
| 139 | + continue; | ||
| 140 | + | ||
| 141 | + gpsStateProcess.process(gps);//状态处理 | ||
| 142 | + stationInsideProcess.process(gps);//场站内外判定 | ||
| 143 | + reverseRouteProcess.process(gps);//反向路由处理 | ||
| 144 | + abnormalStateProcess.process(gps);//超速越界 | ||
| 145 | + | ||
| 146 | + inStationProcess.process(gps);//进站 | ||
| 147 | + outStationProcess.process(gps);//出站 | ||
| 148 | + | ||
| 149 | + GpsCacheData.putGps(gps);//历史gps缓存 | ||
| 150 | + } catch (Exception e) { | ||
| 151 | + logger.error("", e); | ||
| 115 | } | 152 | } |
| 116 | - } finally { | 153 | + } |
| 154 | + | ||
| 155 | + logger.info(Thread.currentThread().getName() + " -countDown : " + count.getCount()); | ||
| 156 | + count.countDown(); | ||
| 157 | + /*} finally { | ||
| 117 | if (count != null) | 158 | if (count != null) |
| 118 | count.countDown(); | 159 | count.countDown(); |
| 119 | - } | 160 | + logger.info(Thread.currentThread().getName() + " -countDown : " + count.getCount()); |
| 161 | + }*/ | ||
| 120 | } | 162 | } |
| 121 | } | 163 | } |
| 122 | 164 | ||
| 123 | - static class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler { | ||
| 124 | - @Override | ||
| 125 | - public void uncaughtException(Thread t, Throwable e) { | ||
| 126 | - logger.error("caught " , e); | ||
| 127 | - } | ||
| 128 | - } | 165 | + public static class GpsComp implements Comparator<GpsEntity> { |
| 129 | 166 | ||
| 130 | - static class HandlerThreadFactory implements ThreadFactory { | ||
| 131 | @Override | 167 | @Override |
| 132 | - public Thread newThread(Runnable r) { | ||
| 133 | - Thread t = new Thread(r); | ||
| 134 | - t.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler()); | ||
| 135 | - return t; | 168 | + public int compare(GpsEntity g1, GpsEntity g2) { |
| 169 | + return g1.getTimestamp().compareTo(g2.getTimestamp()); | ||
| 136 | } | 170 | } |
| 137 | } | 171 | } |
| 138 | } | 172 | } |
| 139 | \ No newline at end of file | 173 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata_v2/GpsRealData.java
| @@ -97,7 +97,7 @@ public class GpsRealData { | @@ -97,7 +97,7 @@ public class GpsRealData { | ||
| 97 | /** | 97 | /** |
| 98 | * @Title: get @Description: TODO(设备号获取GPS) | 98 | * @Title: get @Description: TODO(设备号获取GPS) |
| 99 | */ | 99 | */ |
| 100 | - public GpsEntity get(String deviceId) { | 100 | + public static GpsEntity get(String deviceId) { |
| 101 | return gpsMap.get(deviceId); | 101 | return gpsMap.get(deviceId); |
| 102 | } | 102 | } |
| 103 | 103 |
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/handlers/AbnormalStateProcess.java
| @@ -25,34 +25,34 @@ public class AbnormalStateProcess { | @@ -25,34 +25,34 @@ public class AbnormalStateProcess { | ||
| 25 | */ | 25 | */ |
| 26 | private static final double OUT_BOUNDS_THRESHOLD = 100; | 26 | private static final double OUT_BOUNDS_THRESHOLD = 100; |
| 27 | 27 | ||
| 28 | - | ||
| 29 | public void process(GpsEntity gps) { | 28 | public void process(GpsEntity gps) { |
| 30 | - if(isOffline(gps)) | 29 | + if (isOffline(gps)) |
| 31 | return; | 30 | return; |
| 32 | 31 | ||
| 33 | - if(overspeed(gps)) | 32 | + if (overspeed(gps)) |
| 34 | return; | 33 | return; |
| 35 | 34 | ||
| 36 | - if(outOfBounds((gps))) | 35 | + if (outOfBounds((gps))) |
| 37 | return; | 36 | return; |
| 38 | } | 37 | } |
| 39 | 38 | ||
| 40 | - private boolean isOffline(GpsEntity gps){ | 39 | + private boolean isOffline(GpsEntity gps) { |
| 41 | return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline"); | 40 | return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline"); |
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | 43 | ||
| 45 | /** | 44 | /** |
| 46 | * 是否超速 | 45 | * 是否超速 |
| 46 | + * | ||
| 47 | * @param gps | 47 | * @param gps |
| 48 | * @return | 48 | * @return |
| 49 | */ | 49 | */ |
| 50 | - private boolean overspeed(GpsEntity gps){ | 50 | + private boolean overspeed(GpsEntity gps) { |
| 51 | double maxSpeed = DEFAULT_SPEED_LIMIT; | 51 | double maxSpeed = DEFAULT_SPEED_LIMIT; |
| 52 | - if(GeoCacheData.speedLimit(gps.getLineId()) != null) | 52 | + if (GeoCacheData.speedLimit(gps.getLineId()) != null) |
| 53 | maxSpeed = GeoCacheData.speedLimit(gps.getLineId()); | 53 | maxSpeed = GeoCacheData.speedLimit(gps.getLineId()); |
| 54 | 54 | ||
| 55 | - if(gps.getSpeed() > maxSpeed){ | 55 | + if (gps.getSpeed() > maxSpeed) { |
| 56 | gps.setAbnormalStatus("overspeed"); | 56 | gps.setAbnormalStatus("overspeed"); |
| 57 | return true; | 57 | return true; |
| 58 | } | 58 | } |
| @@ -62,12 +62,13 @@ public class AbnormalStateProcess { | @@ -62,12 +62,13 @@ public class AbnormalStateProcess { | ||
| 62 | 62 | ||
| 63 | /** | 63 | /** |
| 64 | * 是否越界 | 64 | * 是否越界 |
| 65 | + * | ||
| 65 | * @param gps | 66 | * @param gps |
| 66 | * @return | 67 | * @return |
| 67 | */ | 68 | */ |
| 68 | - public boolean outOfBounds(GpsEntity gps){ | 69 | + public boolean outOfBounds(GpsEntity gps) { |
| 69 | //只处理场站外的车 | 70 | //只处理场站外的车 |
| 70 | - if(gps.getInstation() != 0){ | 71 | + if (gps.getInstation() != 0) { |
| 71 | return false; | 72 | return false; |
| 72 | } | 73 | } |
| 73 | 74 | ||
| @@ -76,15 +77,15 @@ public class AbnormalStateProcess { | @@ -76,15 +77,15 @@ public class AbnormalStateProcess { | ||
| 76 | 77 | ||
| 77 | double min = -1, distance; | 78 | double min = -1, distance; |
| 78 | 79 | ||
| 79 | - for(CtLineString lineString : list){ | ||
| 80 | - distance = GeoUtils.getDistanceFromLine(lineString.getS(),lineString.getE(), point); | 80 | + for (CtLineString lineString : list) { |
| 81 | + distance = GeoUtils.getDistanceFromLine(lineString.getS(), lineString.getE(), point); | ||
| 81 | 82 | ||
| 82 | - if(min == -1 || min > distance) | 83 | + if (min == -1 || min > distance) |
| 83 | min = distance; | 84 | min = distance; |
| 84 | } | 85 | } |
| 85 | 86 | ||
| 86 | gps.setOutOfBoundDistance(min); | 87 | gps.setOutOfBoundDistance(min); |
| 87 | - if(min > OUT_BOUNDS_THRESHOLD){ | 88 | + if (min > OUT_BOUNDS_THRESHOLD) { |
| 88 | gps.setAbnormalStatus("outBounds"); | 89 | gps.setAbnormalStatus("outBounds"); |
| 89 | return true; | 90 | return true; |
| 90 | } | 91 | } |
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
| @@ -20,26 +20,26 @@ public class GpsStateProcess { | @@ -20,26 +20,26 @@ public class GpsStateProcess { | ||
| 20 | @Autowired | 20 | @Autowired |
| 21 | GpsStatusManager gpsStatusManager; | 21 | GpsStatusManager gpsStatusManager; |
| 22 | 22 | ||
| 23 | - public void process(GpsEntity gps){ | 23 | + public void process(GpsEntity gps) { |
| 24 | //在执行的任务 | 24 | //在执行的任务 |
| 25 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | 25 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 26 | 26 | ||
| 27 | - if(null == sch) | 27 | + if (null == sch) |
| 28 | return; | 28 | return; |
| 29 | 29 | ||
| 30 | byte upDown = Byte.parseByte(sch.getXlDir()); | 30 | byte upDown = Byte.parseByte(sch.getXlDir()); |
| 31 | 31 | ||
| 32 | - if(gps.getUpDown() != upDown){ | 32 | + if (gps.getUpDown() != upDown) { |
| 33 | gps.setUpDown(upDown);//修正走向 | 33 | gps.setUpDown(upDown);//修正走向 |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | - if((!gps.isService() || gps.getUpDown() != upDown) && | ||
| 37 | - !dayOfSchedule.emptyService(sch)){ | 36 | + if ((!gps.isService() || gps.getUpDown() != upDown) && |
| 37 | + !dayOfSchedule.emptyService(sch)) { | ||
| 38 | //下发指令纠正车载的 营运状态 和 走向 | 38 | //下发指令纠正车载的 营运状态 和 走向 |
| 39 | gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, 0, "同步@系统"); | 39 | gpsStatusManager.changeServiceState(gps.getNbbm(), upDown, 0, "同步@系统"); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | - if(!sch.getXlBm().equals(gps.getLineId())){ | 42 | + if (!sch.getXlBm().equals(gps.getLineId())) { |
| 43 | //切换车载的 线路编码 | 43 | //切换车载的 线路编码 |
| 44 | gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统"); | 44 | gpsStatusManager.changeLine(gps.getNbbm(), sch.getXlBm(), "同步@系统"); |
| 45 | } | 45 | } |
src/main/java/com/bsth/data/gpsdata_v2/handlers/InStationProcess.java
| @@ -45,32 +45,32 @@ public class InStationProcess { | @@ -45,32 +45,32 @@ public class InStationProcess { | ||
| 45 | public void process(GpsEntity gps) { | 45 | public void process(GpsEntity gps) { |
| 46 | //自动执行的班次信号,滚蛋 | 46 | //自动执行的班次信号,滚蛋 |
| 47 | LineConfig config = lineConfigData.get(gps.getLineId()); | 47 | LineConfig config = lineConfigData.get(gps.getLineId()); |
| 48 | - if(null != config && config.isAutoExec()) | 48 | + if (null != config && config.isAutoExec()) |
| 49 | return; | 49 | return; |
| 50 | 50 | ||
| 51 | GpsEntity prev = GpsCacheData.getPrev(gps); | 51 | GpsEntity prev = GpsCacheData.getPrev(gps); |
| 52 | 52 | ||
| 53 | - if(null == prev) | 53 | + if (null == prev) |
| 54 | return; | 54 | return; |
| 55 | 55 | ||
| 56 | //从站外到站内 | 56 | //从站外到站内 |
| 57 | - if(prev.getInstation() == 0 && gps.getInstation() > 0){ | 57 | + if (prev.getInstation() == 0 && gps.getInstation() > 0) { |
| 58 | inStation(gps, prev); | 58 | inStation(gps, prev); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | //从站内到另一个站内 | 61 | //从站内到另一个站内 |
| 62 | - if(prev.getInstation() == 1 && gps.getInstation() == 1 | 62 | + if (prev.getInstation() == 1 && gps.getInstation() == 1 |
| 63 | && !prev.getStopNo().equals(gps.getStopNo()) | 63 | && !prev.getStopNo().equals(gps.getStopNo()) |
| 64 | && !prev.getStation().getName().equals(gps.getStation().getName())) | 64 | && !prev.getStation().getName().equals(gps.getStation().getName())) |
| 65 | inStation(gps, prev); | 65 | inStation(gps, prev); |
| 66 | 66 | ||
| 67 | //从场内到站内 | 67 | //从场内到站内 |
| 68 | - if(prev.getInstation() == 2 && gps.getInstation() == 1){ | 68 | + if (prev.getInstation() == 2 && gps.getInstation() == 1) { |
| 69 | inStation(gps, prev); | 69 | inStation(gps, prev); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | //被起点站覆盖的情况下进场 | 72 | //被起点站覆盖的情况下进场 |
| 73 | - if(isInPark(gps, prev)) | 73 | + if (isInPark(gps, prev)) |
| 74 | inStation(gps, prev); | 74 | inStation(gps, prev); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -96,7 +96,7 @@ public class InStationProcess { | @@ -96,7 +96,7 @@ public class InStationProcess { | ||
| 96 | 96 | ||
| 97 | //进终点 | 97 | //进终点 |
| 98 | if (flow && null != sch && | 98 | if (flow && null != sch && |
| 99 | - ((sch.getZdzCode().equals(gps.getStopNo()) && gps.getInstation()>0) || sch.getZdzCode().equals(gps.getCarparkNo()))) { | 99 | + ((sch.getZdzCode().equals(gps.getStopNo()) && gps.getInstation() > 0) || sch.getZdzCode().equals(gps.getCarparkNo()))) { |
| 100 | inEndStation(sch, gps); | 100 | inEndStation(sch, gps); |
| 101 | isEnd = true; | 101 | isEnd = true; |
| 102 | } | 102 | } |
| @@ -267,8 +267,8 @@ public class InStationProcess { | @@ -267,8 +267,8 @@ public class InStationProcess { | ||
| 267 | } | 267 | } |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | - private boolean isInPark(GpsEntity gps, GpsEntity prve){ | ||
| 271 | - if(StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo())) | 270 | + private boolean isInPark(GpsEntity gps, GpsEntity prve) { |
| 271 | + if (StringUtils.isNotEmpty(gps.getCarparkNo()) && StringUtils.isEmpty(prve.getCarparkNo())) | ||
| 272 | return true; | 272 | return true; |
| 273 | return false; | 273 | return false; |
| 274 | } | 274 | } |
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
| @@ -42,7 +42,7 @@ public class OutStationProcess { | @@ -42,7 +42,7 @@ public class OutStationProcess { | ||
| 42 | private final static int MAX_BEFORE_TIME = 1000 * 60 * 120; | 42 | private final static int MAX_BEFORE_TIME = 1000 * 60 * 120; |
| 43 | 43 | ||
| 44 | public void process(GpsEntity gps) { | 44 | public void process(GpsEntity gps) { |
| 45 | - //自动执行的班次信号,滚蛋 | 45 | + //自动执行的线路,滚蛋 |
| 46 | LineConfig config = lineConfigData.get(gps.getLineId()); | 46 | LineConfig config = lineConfigData.get(gps.getLineId()); |
| 47 | if (null != config && config.isAutoExec()) | 47 | if (null != config && config.isAutoExec()) |
| 48 | return; | 48 | return; |
src/main/java/com/bsth/data/gpsdata_v2/handlers/ReverseRouteProcess.java
| @@ -8,6 +8,8 @@ import com.bsth.data.gpsdata_v2.entity.StationRoute; | @@ -8,6 +8,8 @@ import com.bsth.data.gpsdata_v2.entity.StationRoute; | ||
| 8 | import com.bsth.data.schedule.DayOfSchedule; | 8 | import com.bsth.data.schedule.DayOfSchedule; |
| 9 | import com.bsth.entity.realcontrol.LineConfig; | 9 | import com.bsth.entity.realcontrol.LineConfig; |
| 10 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 10 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Component; | 14 | import org.springframework.stereotype.Component; |
| 13 | 15 | ||
| @@ -30,54 +32,58 @@ public class ReverseRouteProcess { | @@ -30,54 +32,58 @@ public class ReverseRouteProcess { | ||
| 30 | @Autowired | 32 | @Autowired |
| 31 | LineConfigData lineConfigData; | 33 | LineConfigData lineConfigData; |
| 32 | 34 | ||
| 33 | - public void process(GpsEntity gps){ | 35 | + Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 34 | 36 | ||
| 37 | + public void process(GpsEntity gps) { | ||
| 35 | LineConfig config = lineConfigData.get(gps.getLineId()); | 38 | LineConfig config = lineConfigData.get(gps.getLineId()); |
| 36 | - if(null != config && config.isReadReverse() && | ||
| 37 | - reversRoute(gps) && !GeoCacheData.isLoopLine(gps.getLineId())){ | 39 | + if (null != config && config.isReadReverse() && |
| 40 | + reversRoute(gps) && !GeoCacheData.isLoopLine(gps.getLineId())) { | ||
| 38 | 41 | ||
| 39 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); | 42 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 40 | - if(isInOut(sch) || !sch.getXlBm().equals(gps.getLineId())) | 43 | + |
| 44 | + if (null == sch) | ||
| 45 | + return; | ||
| 46 | + if (isInOut(sch) || !sch.getXlBm().equals(gps.getLineId())) | ||
| 41 | return; | 47 | return; |
| 42 | 48 | ||
| 43 | //next | 49 | //next |
| 44 | ScheduleRealInfo next = dayOfSchedule.next(sch); | 50 | ScheduleRealInfo next = dayOfSchedule.next(sch); |
| 45 | - if(isInOut(next)) | 51 | + if (isInOut(next)) |
| 46 | return; | 52 | return; |
| 47 | 53 | ||
| 48 | //跳下一个班次 | 54 | //跳下一个班次 |
| 49 | - if(Math.abs(next.getDfsjT() - gps.getTimestamp()) < TIME_THRESHOLD) | 55 | + if (Math.abs(next.getDfsjT() - gps.getTimestamp()) < TIME_THRESHOLD) |
| 50 | dayOfSchedule.addExecPlan(next); | 56 | dayOfSchedule.addExecPlan(next); |
| 51 | } | 57 | } |
| 52 | } | 58 | } |
| 53 | 59 | ||
| 54 | private boolean reversRoute(GpsEntity gps) { | 60 | private boolean reversRoute(GpsEntity gps) { |
| 55 | - if(gps.getInstation() != 1) | 61 | + if (gps.getInstation() != 1) |
| 56 | return false; | 62 | return false; |
| 57 | 63 | ||
| 58 | int sortNo = gps.getStation().getRouteSort(); | 64 | int sortNo = gps.getStation().getRouteSort(); |
| 59 | - StationRoute prev = GpsCacheData.prevStation(gps); | 65 | + StationRoute prev = GpsCacheData.prevStation(gps); |
| 60 | //和上一个站点是反向 | 66 | //和上一个站点是反向 |
| 61 | - if(null != prev && sortNo < prev.getRouteSort()){ | 67 | + if (null != prev && sortNo < prev.getRouteSort()) { |
| 62 | 68 | ||
| 63 | //满足3个进站反向信号 | 69 | //满足3个进站反向信号 |
| 64 | List<StationRoute> prevs = GpsCacheData.prevMultiStation(gps); | 70 | List<StationRoute> prevs = GpsCacheData.prevMultiStation(gps); |
| 65 | 71 | ||
| 66 | int count = 0; | 72 | int count = 0; |
| 67 | - for(StationRoute s : prevs){ | ||
| 68 | - if(sortNo < s.getRouteSort()) | ||
| 69 | - count ++; | 73 | + for (StationRoute s : prevs) { |
| 74 | + if (sortNo < s.getRouteSort()) | ||
| 75 | + count++; | ||
| 70 | sortNo = s.getRouteSort(); | 76 | sortNo = s.getRouteSort(); |
| 71 | } | 77 | } |
| 72 | 78 | ||
| 73 | - if(count >= REVER_THRESHOLD) | 79 | + if (count >= REVER_THRESHOLD) |
| 74 | return true; | 80 | return true; |
| 75 | } | 81 | } |
| 76 | 82 | ||
| 77 | return false; | 83 | return false; |
| 78 | } | 84 | } |
| 79 | 85 | ||
| 80 | - private boolean isInOut(ScheduleRealInfo sch){ | 86 | + private boolean isInOut(ScheduleRealInfo sch) { |
| 81 | return sch.getBcType().equals("in") || sch.getBcType().equals("out"); | 87 | return sch.getBcType().equals("in") || sch.getBcType().equals("out"); |
| 82 | } | 88 | } |
| 83 | } | 89 | } |
src/main/java/com/bsth/data/gpsdata_v2/handlers/StationInsideProcess.java
| @@ -16,7 +16,7 @@ import java.util.List; | @@ -16,7 +16,7 @@ import java.util.List; | ||
| 16 | @Component | 16 | @Component |
| 17 | public class StationInsideProcess { | 17 | public class StationInsideProcess { |
| 18 | 18 | ||
| 19 | - public void process(GpsEntity gps){ | 19 | + public void process(GpsEntity gps) { |
| 20 | //是否在场内 | 20 | //是否在场内 |
| 21 | String parkCode = GeoUtils.gpsInCarpark(gps); | 21 | String parkCode = GeoUtils.gpsInCarpark(gps); |
| 22 | 22 | ||
| @@ -42,13 +42,13 @@ public class StationInsideProcess { | @@ -42,13 +42,13 @@ public class StationInsideProcess { | ||
| 42 | //上一个点位 | 42 | //上一个点位 |
| 43 | GpsEntity prev = GpsCacheData.getPrev(gps); | 43 | GpsEntity prev = GpsCacheData.getPrev(gps); |
| 44 | 44 | ||
| 45 | - if(null != prev){ | 45 | + if (null != prev) { |
| 46 | //继承前置围栏状态 | 46 | //继承前置围栏状态 |
| 47 | - if(null == premiseCode && null != prev.getPremiseCode()) | 47 | + if (null == premiseCode && null != prev.getPremiseCode()) |
| 48 | gps.setPremiseCode(prev.getPremiseCode()); | 48 | gps.setPremiseCode(prev.getPremiseCode()); |
| 49 | 49 | ||
| 50 | //在场,站外 | 50 | //在场,站外 |
| 51 | - if(gps.getInstation() == 0){ | 51 | + if (gps.getInstation() == 0) { |
| 52 | gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码 | 52 | gps.setStopNo(prev.getStopNo());//继承上一个点的站点编码 |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
src/main/java/com/bsth/data/gpsdata_v2/load/SocketClientLoader.java
| @@ -67,10 +67,10 @@ public class SocketClientLoader { | @@ -67,10 +67,10 @@ public class SocketClientLoader { | ||
| 67 | 67 | ||
| 68 | list = JSON.parseArray(sb.toString(), GpsEntity.class); | 68 | list = JSON.parseArray(sb.toString(), GpsEntity.class); |
| 69 | 69 | ||
| 70 | + logger.info("load end ! size: " + list.size()); | ||
| 70 | //过滤掉无效的点位 | 71 | //过滤掉无效的点位 |
| 71 | list = GpsDataUtils.clearInvalid(list); | 72 | list = GpsDataUtils.clearInvalid(list); |
| 72 | 73 | ||
| 73 | - logger.info("load end!"); | ||
| 74 | for (GpsEntity gps : list) { | 74 | for (GpsEntity gps : list) { |
| 75 | gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); | 75 | gps.setNbbm(BasicData.deviceId2NbbmMap.get(gps.getDeviceId())); |
| 76 | } | 76 | } |
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataRecovery.java
| @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -84,7 +84,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 84 | Calendar calendar = Calendar.getInstance(); | 84 | Calendar calendar = Calendar.getInstance(); |
| 85 | int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); | 85 | int dayOfYear = calendar.get(Calendar.DAY_OF_YEAR); |
| 86 | 86 | ||
| 87 | - String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE,SERVER_TS from bsth_c_gps_info where days_year=329"; //+ dayOfYear; | 87 | + String sql = "select DEVICE_ID,LAT,LON,TS,SPEED_GPS,LINE_ID,SERVICE_STATE,SERVER_TS from bsth_c_gps_info where days_year=346"; //+ dayOfYear; |
| 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); | 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); |
| 89 | 89 | ||
| 90 | List<GpsEntity> list = | 90 | List<GpsEntity> list = |
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataUtils.java
| 1 | package com.bsth.data.gpsdata_v2.utils; | 1 | package com.bsth.data.gpsdata_v2.utils; |
| 2 | 2 | ||
| 3 | +import com.bsth.data.gpsdata_v2.GpsRealData; | ||
| 3 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; | 4 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 4 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
| @@ -24,7 +25,22 @@ public class GpsDataUtils { | @@ -24,7 +25,22 @@ public class GpsDataUtils { | ||
| 24 | List<GpsEntity> rs = new ArrayList<>(); | 25 | List<GpsEntity> rs = new ArrayList<>(); |
| 25 | 26 | ||
| 26 | try { | 27 | try { |
| 28 | + GpsEntity prev; | ||
| 27 | for (GpsEntity gps : list) { | 29 | for (GpsEntity gps : list) { |
| 30 | + prev = GpsRealData.get(gps.getDeviceId()); | ||
| 31 | + | ||
| 32 | + //不接收过期数据 | ||
| 33 | + if(prev != null){ | ||
| 34 | + | ||
| 35 | + if(gps.getTimestamp().longValue() < prev.getTimestamp().longValue()) | ||
| 36 | + continue; | ||
| 37 | + | ||
| 38 | + if(prev.getTimestamp().equals(gps.getTimestamp())&& | ||
| 39 | + prev.getLat().equals(gps.getLat()) && | ||
| 40 | + prev.getLon().equals(gps.getLon())) | ||
| 41 | + continue; | ||
| 42 | + } | ||
| 43 | + | ||
| 28 | if (gps.getValid() == 0 && Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) < 1000 * 60 * 20) | 44 | if (gps.getValid() == 0 && Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) < 1000 * 60 * 20) |
| 29 | rs.add(gps); | 45 | rs.add(gps); |
| 30 | } | 46 | } |
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,10 @@ public class DayOfSchedule { | @@ -65,6 +70,10 @@ public class DayOfSchedule { | ||
| 65 | // 排序器 | 70 | // 排序器 |
| 66 | private static ScheduleComparator.FCSJ schFCSJComparator; | 71 | private static ScheduleComparator.FCSJ schFCSJComparator; |
| 67 | 72 | ||
| 73 | + private static ScheduleComparator.DFSJ schDFSJComparator; | ||
| 74 | + | ||
| 75 | + private static Long sch_max_id=-1L; | ||
| 76 | + | ||
| 68 | @Autowired | 77 | @Autowired |
| 69 | LineConfigData lineConfigData; | 78 | LineConfigData lineConfigData; |
| 70 | 79 | ||
| @@ -92,11 +101,12 @@ public class DayOfSchedule { | @@ -92,11 +101,12 @@ public class DayOfSchedule { | ||
| 92 | nbbmScheduleMap = ArrayListMultimap.create(); | 101 | nbbmScheduleMap = ArrayListMultimap.create(); |
| 93 | lpScheduleMap = ArrayListMultimap.create(); | 102 | lpScheduleMap = ArrayListMultimap.create(); |
| 94 | 103 | ||
| 95 | - id2SchedulMap = new HashMap<>(); | 104 | + id2SchedulMap = new ConcurrentHashMap<>(); |
| 96 | pstBuffer = new ConcurrentLinkedQueue<>(); | 105 | pstBuffer = new ConcurrentLinkedQueue<>(); |
| 97 | schFCSJComparator = new ScheduleComparator.FCSJ(); | 106 | schFCSJComparator = new ScheduleComparator.FCSJ(); |
| 107 | + schDFSJComparator = new ScheduleComparator.DFSJ(); | ||
| 98 | currSchDateMap = new HashMap<>(); | 108 | currSchDateMap = new HashMap<>(); |
| 99 | - carExecutePlanMap = new HashMap<>(); | 109 | + carExecutePlanMap = new ConcurrentHashMap<>(); |
| 100 | 110 | ||
| 101 | schedulePlanMap = new HashMap<>(); | 111 | schedulePlanMap = new HashMap<>(); |
| 102 | } | 112 | } |
| @@ -258,7 +268,7 @@ public class DayOfSchedule { | @@ -258,7 +268,7 @@ public class DayOfSchedule { | ||
| 258 | public void clearRAMData(String lineCode) { | 268 | public void clearRAMData(String lineCode) { |
| 259 | int count = 0; | 269 | int count = 0; |
| 260 | List<ScheduleRealInfo> remList = new ArrayList<>(); | 270 | List<ScheduleRealInfo> remList = new ArrayList<>(); |
| 261 | - Collection<ScheduleRealInfo> all = id2SchedulMap.values(); | 271 | + Collection<ScheduleRealInfo> all = nbbmScheduleMap.values(); |
| 262 | for (ScheduleRealInfo sch : all) { | 272 | for (ScheduleRealInfo sch : all) { |
| 263 | if (sch.getXlBm().equals(lineCode)) | 273 | if (sch.getXlBm().equals(lineCode)) |
| 264 | remList.add(sch); | 274 | remList.add(sch); |
| @@ -324,11 +334,13 @@ public class DayOfSchedule { | @@ -324,11 +334,13 @@ public class DayOfSchedule { | ||
| 324 | // 转换为实际排班 | 334 | // 转换为实际排班 |
| 325 | realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); | 335 | realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); |
| 326 | 336 | ||
| 337 | + Date d = new Date(); | ||
| 327 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); | 338 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| 328 | String fcsj; | 339 | String fcsj; |
| 329 | for (ScheduleRealInfo sch : realList) { | 340 | for (ScheduleRealInfo sch : realList) { |
| 330 | sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); | 341 | sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); |
| 331 | sch.setRealExecDate(sch.getScheduleDateStr()); | 342 | sch.setRealExecDate(sch.getScheduleDateStr()); |
| 343 | + sch.setCreateDate(d); | ||
| 332 | 344 | ||
| 333 | if (StringUtils.isEmpty(sch.getFcsj())) | 345 | if (StringUtils.isEmpty(sch.getFcsj())) |
| 334 | sch.setFcsj("00:00"); | 346 | sch.setFcsj("00:00"); |
| @@ -377,26 +389,108 @@ public class DayOfSchedule { | @@ -377,26 +389,108 @@ public class DayOfSchedule { | ||
| 377 | return realList; | 389 | return realList; |
| 378 | } | 390 | } |
| 379 | 391 | ||
| 392 | + | ||
| 393 | + public synchronized long getId(){ | ||
| 394 | + if(sch_max_id==-1){ | ||
| 395 | + sch_max_id = schRepository.getMaxId(); | ||
| 396 | + if(null == sch_max_id) | ||
| 397 | + sch_max_id = 3000L;//留一点空间补数据用 | ||
| 398 | + sch_max_id += 5; | ||
| 399 | + } | ||
| 400 | + else | ||
| 401 | + sch_max_id ++; | ||
| 402 | + return sch_max_id; | ||
| 403 | + } | ||
| 404 | + | ||
| 380 | /** | 405 | /** |
| 381 | * @Title: batchSave | 406 | * @Title: batchSave |
| 382 | * @Description: TODO(批量入库) | 407 | * @Description: TODO(批量入库) |
| 383 | */ | 408 | */ |
| 384 | private void batchSave(List<ScheduleRealInfo> list) { | 409 | 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"); | 410 | SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); |
| 392 | for (ScheduleRealInfo item : list) { | 411 | for (ScheduleRealInfo item : list) { |
| 393 | item.setSpId(item.getId());// 保留原始的计划ID | 412 | item.setSpId(item.getId());// 保留原始的计划ID |
| 394 | - item.setId(id++);// 设置ID | 413 | + item.setId(getId());// 设置ID |
| 395 | item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); | 414 | item.setScheduleDateStr(sdfyyyyMMdd.format(item.getScheduleDate())); |
| 396 | } | 415 | } |
| 397 | 416 | ||
| 417 | + //编程式事务 | ||
| 418 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 419 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 420 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 421 | + TransactionStatus status = tran.getTransaction(def); | ||
| 422 | + | ||
| 423 | + try{ | ||
| 424 | + final List<ScheduleRealInfo> pstList = list; | ||
| 425 | + //写入 | ||
| 426 | + 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)" + | ||
| 427 | + " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | ||
| 428 | + @Override | ||
| 429 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
| 430 | + ScheduleRealInfo sch = pstList.get(i); | ||
| 431 | + ps.setLong(1, sch.getId()); | ||
| 432 | + ps.setString(2, sch.getBcType()); | ||
| 433 | + ps.setInt(3, sch.getBcs()==null?0:sch.getBcs()); | ||
| 434 | + ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj()); | ||
| 435 | + ps.setString(5, sch.getClZbh()); | ||
| 436 | + ps.setTimestamp(6, new java.sql.Timestamp(sch.getCreateDate().getTime())); | ||
| 437 | + ps.setString(7, sch.getDfsj()); | ||
| 438 | + ps.setInt(8, sch.getDirectiveState()); | ||
| 439 | + ps.setInt(9, sch.getFcno()==null?0:sch.getFcno()); | ||
| 440 | + ps.setString(10, sch.getFcsj()); | ||
| 441 | + ps.setString(11, sch.getFcsjActual()); | ||
| 442 | + ps.setString(12, sch.getjGh()); | ||
| 443 | + ps.setString(13, sch.getjName()); | ||
| 444 | + ps.setDouble(14, sch.getJhlc()); | ||
| 445 | + ps.setString(15, sch.getLpName()); | ||
| 446 | + ps.setString(16, sch.getQdzCode()); | ||
| 447 | + ps.setString(17, sch.getQdzName()); | ||
| 448 | + ps.setString(18, sch.getRealExecDate()); | ||
| 449 | + ps.setString(19, sch.getRemarks()); | ||
| 450 | + ps.setString(20, sch.getsGh()); | ||
| 451 | + ps.setString(21, sch.getsName()); | ||
| 452 | + ps.setTimestamp(22, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | ||
| 453 | + ps.setString(23, sch.getScheduleDateStr()); | ||
| 454 | + ps.setBoolean(24, sch.isSflj()); | ||
| 455 | + ps.setLong(25, sch.getSpId()); | ||
| 456 | + ps.setInt(26, sch.getStatus()); | ||
| 457 | + ps.setTimestamp(27, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | ||
| 458 | + ps.setString(28, sch.getXlBm()); | ||
| 459 | + ps.setString(29, sch.getXlDir()); | ||
| 460 | + ps.setString(30, sch.getXlName()); | ||
| 461 | + ps.setString(31, sch.getZdsj()); | ||
| 462 | + ps.setString(32, sch.getZdsjActual()); | ||
| 463 | + ps.setString(33, sch.getZdzCode()); | ||
| 464 | + ps.setString(34, sch.getZdzName()); | ||
| 465 | + ps.setInt(35, sch.getCcno()==null?0:sch.getCcno()); | ||
| 466 | + ps.setBoolean(36, sch.isDfAuto()); | ||
| 467 | + ps.setString(37, sch.getFgsBm()); | ||
| 468 | + ps.setString(38, sch.getFgsName()); | ||
| 469 | + ps.setString(39, sch.getGsBm()); | ||
| 470 | + ps.setString(40, sch.getGsName()); | ||
| 471 | + ps.setBoolean(41, sch.isOnline()); | ||
| 472 | + ps.setString(42, sch.getAdjustExps()); | ||
| 473 | + ps.setBoolean(43, sch.isReissue()); | ||
| 474 | + ps.setDouble(44, sch.getJhlcOrig()); | ||
| 475 | + ps.setInt(45, sch.getSiginCompate()); | ||
| 476 | + ps.setInt(46, sch.getDriftStatus()); | ||
| 477 | + ps.setBoolean(47, sch.isCcService()); | ||
| 478 | + ps.setString(48, sch.getMajorStationName()); | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + @Override | ||
| 482 | + public int getBatchSize() { | ||
| 483 | + return pstList.size(); | ||
| 484 | + } | ||
| 485 | + }); | ||
| 486 | + | ||
| 487 | + tran.commit(status); | ||
| 488 | + }catch (Exception e){ | ||
| 489 | + tran.rollback(status); | ||
| 490 | + logger.error("real schedule batchSave error...", e); | ||
| 491 | + } | ||
| 398 | // 入库 | 492 | // 入库 |
| 399 | - new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); | 493 | + //new BatchSaveUtils<ScheduleRealInfo>().saveList(list, ScheduleRealInfo.class); |
| 400 | } | 494 | } |
| 401 | 495 | ||
| 402 | public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { | 496 | public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { |
| @@ -420,7 +514,7 @@ public class DayOfSchedule { | @@ -420,7 +514,7 @@ public class DayOfSchedule { | ||
| 420 | public List<ScheduleRealInfo> findByLineCode(String lineCode) { | 514 | public List<ScheduleRealInfo> findByLineCode(String lineCode) { |
| 421 | List<ScheduleRealInfo> rs = new ArrayList<>(); | 515 | List<ScheduleRealInfo> rs = new ArrayList<>(); |
| 422 | 516 | ||
| 423 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | 517 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); |
| 424 | for (ScheduleRealInfo sch : schs) { | 518 | for (ScheduleRealInfo sch : schs) { |
| 425 | if (sch.getXlBm().equals(lineCode)) | 519 | if (sch.getXlBm().equals(lineCode)) |
| 426 | rs.add(sch); | 520 | rs.add(sch); |
| @@ -435,7 +529,7 @@ public class DayOfSchedule { | @@ -435,7 +529,7 @@ public class DayOfSchedule { | ||
| 435 | public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { | 529 | public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { |
| 436 | ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | 530 | ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); |
| 437 | 531 | ||
| 438 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | 532 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); |
| 439 | for (ScheduleRealInfo sch : schs) { | 533 | for (ScheduleRealInfo sch : schs) { |
| 440 | if (lineList.contains(sch.getXlBm())) { | 534 | if (lineList.contains(sch.getXlBm())) { |
| 441 | mMap.put(sch.getXlBm(), sch); | 535 | mMap.put(sch.getXlBm(), sch); |
| @@ -489,27 +583,11 @@ public class DayOfSchedule { | @@ -489,27 +583,11 @@ public class DayOfSchedule { | ||
| 489 | */ | 583 | */ |
| 490 | public ScheduleRealInfo next(ScheduleRealInfo sch) { | 584 | public ScheduleRealInfo next(ScheduleRealInfo sch) { |
| 491 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | 585 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); |
| 586 | + //排序 | ||
| 587 | + Collections.sort(list, schDFSJComparator); | ||
| 492 | return next(list, sch); | 588 | return next(list, sch); |
| 493 | } | 589 | } |
| 494 | 590 | ||
| 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 | 591 | ||
| 514 | /** | 592 | /** |
| 515 | * 下一个班次 | 593 | * 下一个班次 |
| @@ -657,8 +735,7 @@ public class DayOfSchedule { | @@ -657,8 +735,7 @@ public class DayOfSchedule { | ||
| 657 | .calcRealDate(sch) | 735 | .calcRealDate(sch) |
| 658 | .calcAllTimeByFcsj(sch); | 736 | .calcAllTimeByFcsj(sch); |
| 659 | 737 | ||
| 660 | - String nbbm = sch.getClZbh(); | ||
| 661 | - nbbmScheduleMap.put(nbbm, sch); | 738 | + nbbmScheduleMap.put(sch.getClZbh(), sch); |
| 662 | 739 | ||
| 663 | //主键索引 | 740 | //主键索引 |
| 664 | id2SchedulMap.put(sch.getId(), sch); | 741 | id2SchedulMap.put(sch.getId(), sch); |
| @@ -675,7 +752,6 @@ public class DayOfSchedule { | @@ -675,7 +752,6 @@ public class DayOfSchedule { | ||
| 675 | } | 752 | } |
| 676 | 753 | ||
| 677 | public void delete(ScheduleRealInfo sch) { | 754 | public void delete(ScheduleRealInfo sch) { |
| 678 | - //ScheduleRealInfo sch = id2SchedulMap.get(id); | ||
| 679 | if (!sch.isSflj()) | 755 | if (!sch.isSflj()) |
| 680 | return; | 756 | return; |
| 681 | 757 | ||
| @@ -715,36 +791,6 @@ public class DayOfSchedule { | @@ -715,36 +791,6 @@ public class DayOfSchedule { | ||
| 715 | return rs; | 791 | return rs; |
| 716 | } | 792 | } |
| 717 | 793 | ||
| 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) { | 794 | public void save(ScheduleRealInfo sch) { |
| 749 | sch.setUpdateDate(new Date()); | 795 | sch.setUpdateDate(new Date()); |
| 750 | pstBuffer.add(sch); | 796 | pstBuffer.add(sch); |
| @@ -768,26 +814,6 @@ public class DayOfSchedule { | @@ -768,26 +814,6 @@ public class DayOfSchedule { | ||
| 768 | return sch; | 814 | return sch; |
| 769 | } | 815 | } |
| 770 | 816 | ||
| 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 | 817 | ||
| 792 | /** | 818 | /** |
| 793 | * 搜索离当前时间最近的一个指定类型的班次 | 819 | * 搜索离当前时间最近的一个指定类型的班次 |
| @@ -857,6 +883,8 @@ public class DayOfSchedule { | @@ -857,6 +883,8 @@ public class DayOfSchedule { | ||
| 857 | * @return | 883 | * @return |
| 858 | */ | 884 | */ |
| 859 | public ScheduleRealInfo executeCurr(String nbbm) { | 885 | public ScheduleRealInfo executeCurr(String nbbm) { |
| 886 | + if(StringUtils.isEmpty(nbbm)) | ||
| 887 | + return null; | ||
| 860 | return carExecutePlanMap.get(nbbm); | 888 | return carExecutePlanMap.get(nbbm); |
| 861 | } | 889 | } |
| 862 | 890 | ||
| @@ -892,12 +920,12 @@ public class DayOfSchedule { | @@ -892,12 +920,12 @@ public class DayOfSchedule { | ||
| 892 | } | 920 | } |
| 893 | 921 | ||
| 894 | public void reCalcExecPlan(String nbbm) { | 922 | public void reCalcExecPlan(String nbbm) { |
| 895 | - logger.info("reCalcExecPlan...: " + nbbm); | ||
| 896 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); | 923 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); |
| 897 | - Collections.sort(list, schFCSJComparator); | 924 | + Collections.sort(list, schDFSJComparator); |
| 898 | 925 | ||
| 899 | ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list); | 926 | ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list); |
| 900 | - carExecutePlanMap.put(nbbm, sch); | 927 | + if(null != sch) |
| 928 | + carExecutePlanMap.put(nbbm, sch); | ||
| 901 | } | 929 | } |
| 902 | 930 | ||
| 903 | /** | 931 | /** |
| @@ -1026,4 +1054,36 @@ public class DayOfSchedule { | @@ -1026,4 +1054,36 @@ public class DayOfSchedule { | ||
| 1026 | schAttrCalculator.calcQdzTimePlan(new ArrayList<ScheduleRealInfo>(map.get(k))); | 1054 | schAttrCalculator.calcQdzTimePlan(new ArrayList<ScheduleRealInfo>(map.get(k))); |
| 1027 | } | 1055 | } |
| 1028 | } | 1056 | } |
| 1057 | + | ||
| 1058 | + public int dbCount(String lineCode, String currSchDate) { | ||
| 1059 | + int count = -1; | ||
| 1060 | + | ||
| 1061 | + try{ | ||
| 1062 | + count = jdbcTemplate.queryForObject("select count(*) from bsth_c_s_sp_info_real where schedule_date='"+currSchDate+"' and xl_bm='"+lineCode+"'", java.lang.Integer.class); | ||
| 1063 | + | ||
| 1064 | + }catch (Exception e){ | ||
| 1065 | + logger.error("", e); | ||
| 1066 | + } | ||
| 1067 | + return count; | ||
| 1068 | + } | ||
| 1069 | + | ||
| 1070 | + /** | ||
| 1071 | + * 重新计算ID对照map | ||
| 1072 | + */ | ||
| 1073 | + public int reCalcIdMaps(){ | ||
| 1074 | + Collection<ScheduleRealInfo> all = findAll(); | ||
| 1075 | + Map<Long, ScheduleRealInfo> id2SchedulMapCopy = new ConcurrentHashMap<>(); | ||
| 1076 | + | ||
| 1077 | + for(ScheduleRealInfo sch : all){ | ||
| 1078 | + id2SchedulMapCopy.put(sch.getId(), sch); | ||
| 1079 | + } | ||
| 1080 | + | ||
| 1081 | + id2SchedulMap = id2SchedulMapCopy; | ||
| 1082 | + | ||
| 1083 | + return id2SchedulMap.size(); | ||
| 1084 | + } | ||
| 1085 | + | ||
| 1086 | + public String sizeString(){ | ||
| 1087 | + return id2SchedulMap.size() + "/" + nbbmScheduleMap.size(); | ||
| 1088 | + } | ||
| 1029 | } | 1089 | } |
| 1030 | \ No newline at end of file | 1090 | \ 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/late_adjust/LateAdjustHandle.java
| @@ -68,10 +68,17 @@ public class LateAdjustHandle implements ApplicationContextAware{ | @@ -68,10 +68,17 @@ public class LateAdjustHandle implements ApplicationContextAware{ | ||
| 68 | ScheduleRealInfo cancel = null; | 68 | ScheduleRealInfo cancel = null; |
| 69 | //之前存在误点班次没有发出 | 69 | //之前存在误点班次没有发出 |
| 70 | ScheduleRealInfo old = lateSchMap.get(sch.getClZbh()); | 70 | ScheduleRealInfo old = lateSchMap.get(sch.getClZbh()); |
| 71 | + | ||
| 71 | if(old != null && old.getDfsjT() < sch.getDfsjT()){ | 72 | if(old != null && old.getDfsjT() < sch.getDfsjT()){ |
| 72 | - remove(old); | ||
| 73 | - cancel = old; | ||
| 74 | - logger.info("【应发未到】old 班次 " + old.getId() + " -被覆盖!"); | 73 | + //如果之前班次的 待发应到时间已经过了 3 分钟 |
| 74 | + long t = System.currentTimeMillis(); | ||
| 75 | + long dfEndTime = old.getDfsjT() + (old.getBcsj() * 60 * 1000); | ||
| 76 | + if((t - dfEndTime) > 1000 * 60 * 3){ | ||
| 77 | + | ||
| 78 | + remove(old); | ||
| 79 | + cancel = old; | ||
| 80 | + logger.info("【应发未到】old 班次 " + old.getId() + " -被覆盖!"); | ||
| 81 | + } | ||
| 75 | } | 82 | } |
| 76 | 83 | ||
| 77 | lateSchMap.put(sch.getClZbh(), sch); | 84 | lateSchMap.put(sch.getClZbh(), sch); |
| @@ -164,7 +171,7 @@ public class LateAdjustHandle implements ApplicationContextAware{ | @@ -164,7 +171,7 @@ public class LateAdjustHandle implements ApplicationContextAware{ | ||
| 164 | } | 171 | } |
| 165 | }catch (Exception e){ | 172 | }catch (Exception e){ |
| 166 | e.printStackTrace(); | 173 | e.printStackTrace(); |
| 167 | - logger.error("", e); | 174 | + logger.error("late2 car arrive", e); |
| 168 | } | 175 | } |
| 169 | } | 176 | } |
| 170 | 177 |
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
| 1 | package com.bsth.data.schedule.thread; | 1 | package com.bsth.data.schedule.thread; |
| 2 | 2 | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | import com.bsth.data.schedule.DayOfSchedule; | 3 | import com.bsth.data.schedule.DayOfSchedule; |
| 5 | import com.bsth.entity.realcontrol.ScheduleRealInfo; | 4 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 6 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | 5 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 7 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | -import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource; | ||
| 11 | -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; | 9 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; |
| 10 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 11 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
| 12 | import org.springframework.stereotype.Component; | 12 | import org.springframework.stereotype.Component; |
| 13 | +import org.springframework.transaction.TransactionDefinition; | ||
| 14 | +import org.springframework.transaction.TransactionStatus; | ||
| 15 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
| 16 | + | ||
| 17 | +import java.sql.PreparedStatement; | ||
| 18 | +import java.sql.SQLException; | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.List; | ||
| 13 | 21 | ||
| 14 | /** | 22 | /** |
| 15 | * @author PanZhao | 23 | * @author PanZhao |
| @@ -24,67 +32,145 @@ public class SchedulePstThread extends Thread { | @@ -24,67 +32,145 @@ public class SchedulePstThread extends Thread { | ||
| 24 | ScheduleRealInfoRepository scheduleRepository; | 32 | ScheduleRealInfoRepository scheduleRepository; |
| 25 | 33 | ||
| 26 | @Autowired | 34 | @Autowired |
| 27 | - NamedParameterJdbcTemplate jdbcTemplate; | 35 | + JdbcTemplate jdbcTemplate; |
| 28 | 36 | ||
| 29 | @Autowired | 37 | @Autowired |
| 30 | DayOfSchedule dayOfSchedule; | 38 | DayOfSchedule dayOfSchedule; |
| 31 | 39 | ||
| 32 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 40 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 33 | 41 | ||
| 42 | + static List<ScheduleRealInfo> saveList = new ArrayList<>(); | ||
| 43 | + | ||
| 34 | @Override | 44 | @Override |
| 35 | public void run() { | 45 | public void run() { |
| 36 | 46 | ||
| 37 | - ScheduleRealInfo schedule; | ||
| 38 | - for (int i = 0; i < 1000; i++) { | ||
| 39 | - schedule = DayOfSchedule.pstBuffer.poll(); | ||
| 40 | - if (null == schedule) | ||
| 41 | - break; | 47 | + try{ |
| 48 | + ScheduleRealInfo schedule; | ||
| 49 | + for (int i = 0; i < 500; i++) { | ||
| 50 | + schedule = DayOfSchedule.pstBuffer.poll(); | ||
| 51 | + if (null == schedule) | ||
| 52 | + break; | ||
| 42 | 53 | ||
| 43 | - if (schedule.isDeleted()) { | ||
| 44 | - logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | ||
| 45 | - continue; | 54 | + if (schedule.isDeleted()) { |
| 55 | + logger.error("save 发现 deleted=true 的班次,id: " + schedule.getId()); | ||
| 56 | + continue; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + saveList.add(schedule); | ||
| 46 | } | 60 | } |
| 47 | 61 | ||
| 48 | - save(schedule); | 62 | + //写入数据库 |
| 63 | + save(); | ||
| 64 | + }catch (Exception e){ | ||
| 65 | + logger.error("", e); | ||
| 49 | } | 66 | } |
| 50 | } | 67 | } |
| 51 | 68 | ||
| 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; | 69 | +/* PropertyFilter filter = new PropertyFilter() { |
| 70 | + //过滤不需要的字段 | ||
| 71 | + public boolean apply(Object source, String name, Object value) { | ||
| 72 | + if("cTasks".equals(name)||"createBy".equals(name)||"updateBy".equals(name)){ | ||
| 73 | + return false; | ||
| 74 | + } | ||
| 75 | + return true; | ||
| 61 | } | 76 | } |
| 77 | + };*/ | ||
| 62 | 78 | ||
| 63 | - if(sch.getSaveFailCount() > 5){ | ||
| 64 | - logger.error("入库失败上限, " + JSON.toJSONString(sch)); | 79 | + private void save(){ |
| 80 | + if(saveList.size() == 0) | ||
| 65 | return; | 81 | return; |
| 66 | - } | 82 | + //记录同步数据 |
| 83 | + logger.info("real schedule update size: " + saveList.size()); | ||
| 84 | + //logger.info(JSON.toJSONString(saveList, filter)); | ||
| 67 | 85 | ||
| 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); | 86 | + //批量入库 |
| 87 | + update2Db(); | ||
| 88 | + | ||
| 89 | + //清空容器 | ||
| 90 | + saveList.clear(); | ||
| 91 | + logger.info("update end! "); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + private void update2Db(){ | ||
| 95 | + final List<ScheduleRealInfo> pstList = saveList; | ||
| 96 | + //编程式事务 | ||
| 97 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 98 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 99 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 100 | + TransactionStatus status = tran.getTransaction(def); | ||
| 101 | + | ||
| 102 | + try{ | ||
| 103 | + //更新 | ||
| 104 | + jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" + | ||
| 105 | + ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" + | ||
| 106 | + ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" + | ||
| 107 | + ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" + | ||
| 108 | + ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" + | ||
| 109 | + ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=? where id=?", new BatchPreparedStatementSetter() { | ||
| 110 | + @Override | ||
| 111 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
| 112 | + ScheduleRealInfo sch = pstList.get(i); | ||
| 113 | + ps.setString(1, sch.getBcType()); | ||
| 114 | + ps.setInt(2, sch.getBcs()==null?0:sch.getBcs()); | ||
| 115 | + ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj()); | ||
| 116 | + ps.setString(4, sch.getClZbh()); | ||
| 117 | + ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime())); | ||
| 118 | + ps.setString(6, sch.getDfsj()); | ||
| 119 | + ps.setInt(7, sch.getDirectiveState()); | ||
| 120 | + ps.setInt(8, sch.getFcno()==null?0:sch.getFcno()); | ||
| 121 | + ps.setString(9, sch.getFcsj()); | ||
| 122 | + ps.setString(10, sch.getFcsjActual()); | ||
| 123 | + ps.setString(11, sch.getjGh()); | ||
| 124 | + ps.setString(12, sch.getjName()); | ||
| 125 | + ps.setDouble(13, sch.getJhlc()); | ||
| 126 | + ps.setString(14, sch.getLpName()); | ||
| 127 | + ps.setString(15, sch.getQdzCode()); | ||
| 128 | + ps.setString(16, sch.getQdzName()); | ||
| 129 | + ps.setString(17, sch.getRealExecDate()); | ||
| 130 | + ps.setString(18, sch.getRemarks()); | ||
| 131 | + ps.setString(19, sch.getsGh()); | ||
| 132 | + ps.setString(20, sch.getsName()); | ||
| 133 | + ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime())); | ||
| 134 | + ps.setString(22, sch.getScheduleDateStr()); | ||
| 135 | + ps.setBoolean(23, sch.isSflj()); | ||
| 136 | + ps.setLong(24, sch.getSpId()); | ||
| 137 | + ps.setInt(25, sch.getStatus()); | ||
| 138 | + ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime())); | ||
| 139 | + ps.setString(27, sch.getXlBm()); | ||
| 140 | + ps.setString(28, sch.getXlDir()); | ||
| 141 | + ps.setString(29, sch.getXlName()); | ||
| 142 | + ps.setString(30, sch.getZdsj()); | ||
| 143 | + ps.setString(31, sch.getZdsjActual()); | ||
| 144 | + ps.setString(32, sch.getZdzCode()); | ||
| 145 | + ps.setString(33, sch.getZdzName()); | ||
| 146 | + ps.setInt(34, sch.getCcno()==null?0:sch.getCcno()); | ||
| 147 | + ps.setBoolean(35, sch.isDfAuto()); | ||
| 148 | + ps.setString(36, sch.getFgsBm()); | ||
| 149 | + ps.setString(37, sch.getFgsName()); | ||
| 150 | + ps.setString(38, sch.getGsBm()); | ||
| 151 | + ps.setString(39, sch.getGsName()); | ||
| 152 | + ps.setBoolean(40, sch.isOnline()); | ||
| 153 | + ps.setString(41, sch.getAdjustExps()); | ||
| 154 | + ps.setBoolean(42, sch.isReissue()); | ||
| 155 | + ps.setDouble(43, sch.getJhlcOrig()); | ||
| 156 | + ps.setInt(44, sch.getSiginCompate()); | ||
| 157 | + ps.setInt(45, sch.getDriftStatus()); | ||
| 158 | + ps.setBoolean(46, sch.isCcService()); | ||
| 159 | + ps.setString(47, sch.getMajorStationName()); | ||
| 160 | + | ||
| 161 | + ps.setLong(48, sch.getId()); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @Override | ||
| 165 | + public int getBatchSize() { | ||
| 166 | + return pstList.size(); | ||
| 167 | + } | ||
| 168 | + }); | ||
| 169 | + | ||
| 170 | + tran.commit(status); | ||
| 171 | + }catch (Exception e){ | ||
| 172 | + tran.rollback(status); | ||
| 173 | + logger.error("同步数据库失败," , e); | ||
| 88 | } | 174 | } |
| 89 | } | 175 | } |
| 90 | } | 176 | } |
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/LineVersions.java
| @@ -69,6 +69,12 @@ public class LineVersions{ | @@ -69,6 +69,12 @@ public class LineVersions{ | ||
| 69 | */ | 69 | */ |
| 70 | private int status; | 70 | private int status; |
| 71 | 71 | ||
| 72 | + /** | ||
| 73 | + * 是否发布 int length(1) | ||
| 74 | + * 0(没有),1(发布) | ||
| 75 | + */ | ||
| 76 | + private int isupdate; | ||
| 77 | + | ||
| 72 | public Integer getId() { | 78 | public Integer getId() { |
| 73 | return id; | 79 | return id; |
| 74 | } | 80 | } |
| @@ -156,5 +162,13 @@ public class LineVersions{ | @@ -156,5 +162,13 @@ public class LineVersions{ | ||
| 156 | public void setStatus(int status) { | 162 | public void setStatus(int status) { |
| 157 | this.status = status; | 163 | this.status = status; |
| 158 | } | 164 | } |
| 165 | + | ||
| 166 | + public int getIsupdate() { | ||
| 167 | + return isupdate; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public void setIsupdate(int isupdate) { | ||
| 171 | + this.isupdate = isupdate; | ||
| 172 | + } | ||
| 159 | 173 | ||
| 160 | } | 174 | } |
| 161 | \ No newline at end of file | 175 | \ No newline at end of file |
src/main/java/com/bsth/entity/geo_data/GeoRoad.java
0 → 100644
| 1 | +package com.bsth.entity.geo_data; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by panzhao on 2017/12/8. | ||
| 9 | + */ | ||
| 10 | +public class GeoRoad { | ||
| 11 | + | ||
| 12 | + private int id; | ||
| 13 | + | ||
| 14 | + private Integer sectionrouteCode; | ||
| 15 | + | ||
| 16 | + private Integer directions; | ||
| 17 | + | ||
| 18 | + private String lineCode; | ||
| 19 | + | ||
| 20 | + private String sectionCode; | ||
| 21 | + | ||
| 22 | + private Integer versions; | ||
| 23 | + | ||
| 24 | + private String sectionName; | ||
| 25 | + | ||
| 26 | + private String crosesRoad; | ||
| 27 | + | ||
| 28 | + @JsonIgnore | ||
| 29 | + private String gsectionVector; | ||
| 30 | + | ||
| 31 | + private List<String> bdCoords; | ||
| 32 | + | ||
| 33 | + public int getId() { | ||
| 34 | + return id; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public void setId(int id) { | ||
| 38 | + this.id = id; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public Integer getSectionrouteCode() { | ||
| 42 | + return sectionrouteCode; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setSectionrouteCode(Integer sectionrouteCode) { | ||
| 46 | + this.sectionrouteCode = sectionrouteCode; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public Integer getDirections() { | ||
| 50 | + return directions; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public void setDirections(Integer directions) { | ||
| 54 | + this.directions = directions; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public String getLineCode() { | ||
| 58 | + return lineCode; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void setLineCode(String lineCode) { | ||
| 62 | + this.lineCode = lineCode; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public String getSectionCode() { | ||
| 66 | + return sectionCode; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void setSectionCode(String sectionCode) { | ||
| 70 | + this.sectionCode = sectionCode; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public Integer getVersions() { | ||
| 74 | + return versions; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setVersions(Integer versions) { | ||
| 78 | + this.versions = versions; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public String getSectionName() { | ||
| 82 | + return sectionName; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setSectionName(String sectionName) { | ||
| 86 | + this.sectionName = sectionName; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public String getCrosesRoad() { | ||
| 90 | + return crosesRoad; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setCrosesRoad(String crosesRoad) { | ||
| 94 | + this.crosesRoad = crosesRoad; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public String getGsectionVector() { | ||
| 98 | + return gsectionVector; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setGsectionVector(String gsectionVector) { | ||
| 102 | + this.gsectionVector = gsectionVector; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public List<String> getBdCoords() { | ||
| 106 | + return bdCoords; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setBdCoords(List<String> bdCoords) { | ||
| 110 | + this.bdCoords = bdCoords; | ||
| 111 | + } | ||
| 112 | +} |
src/main/java/com/bsth/entity/geo_data/GeoStation.java
0 → 100644
| 1 | +package com.bsth.entity.geo_data; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonIgnore; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by panzhao on 2017/12/7. | ||
| 9 | + */ | ||
| 10 | +public class GeoStation { | ||
| 11 | + | ||
| 12 | + private int id; | ||
| 13 | + | ||
| 14 | + private String stationName; | ||
| 15 | + | ||
| 16 | + private String stationRouteCode; | ||
| 17 | + | ||
| 18 | + private String lineCode; | ||
| 19 | + | ||
| 20 | + private Integer directions; | ||
| 21 | + | ||
| 22 | + private String stationCode; | ||
| 23 | + | ||
| 24 | + private String stationMark; | ||
| 25 | + | ||
| 26 | + private Integer version; | ||
| 27 | + | ||
| 28 | + private Float gLonx; | ||
| 29 | + | ||
| 30 | + private Float gLaty; | ||
| 31 | + | ||
| 32 | + @JsonIgnore | ||
| 33 | + private String gPolygonGrid; | ||
| 34 | + | ||
| 35 | + private List<String> bdCoords; | ||
| 36 | + | ||
| 37 | + private Integer radius; | ||
| 38 | + | ||
| 39 | + private String shapesType; | ||
| 40 | + | ||
| 41 | + public int getId() { | ||
| 42 | + return id; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setId(int id) { | ||
| 46 | + this.id = id; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public String getStationName() { | ||
| 50 | + return stationName; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public void setStationName(String stationName) { | ||
| 54 | + this.stationName = stationName; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public String getStationRouteCode() { | ||
| 58 | + return stationRouteCode; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public void setStationRouteCode(String stationRouteCode) { | ||
| 62 | + this.stationRouteCode = stationRouteCode; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public String getLineCode() { | ||
| 66 | + return lineCode; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public void setLineCode(String lineCode) { | ||
| 70 | + this.lineCode = lineCode; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public Integer getDirections() { | ||
| 74 | + return directions; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public void setDirections(Integer directions) { | ||
| 78 | + this.directions = directions; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public String getStationCode() { | ||
| 82 | + return stationCode; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void setStationCode(String stationCode) { | ||
| 86 | + this.stationCode = stationCode; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public String getStationMark() { | ||
| 90 | + return stationMark; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public void setStationMark(String stationMark) { | ||
| 94 | + this.stationMark = stationMark; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public Integer getVersion() { | ||
| 98 | + return version; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public void setVersion(Integer version) { | ||
| 102 | + this.version = version; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public Float getgLonx() { | ||
| 106 | + return gLonx; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void setgLonx(Float gLonx) { | ||
| 110 | + this.gLonx = gLonx; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public Float getgLaty() { | ||
| 114 | + return gLaty; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public void setgLaty(Float gLaty) { | ||
| 118 | + this.gLaty = gLaty; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public String getgPolygonGrid() { | ||
| 122 | + return gPolygonGrid; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setgPolygonGrid(String gPolygonGrid) { | ||
| 126 | + this.gPolygonGrid = gPolygonGrid; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public Integer getRadius() { | ||
| 130 | + return radius; | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + public void setRadius(Integer radius) { | ||
| 134 | + this.radius = radius; | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + public String getShapesType() { | ||
| 138 | + return shapesType; | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + public void setShapesType(String shapesType) { | ||
| 142 | + this.shapesType = shapesType; | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + public List<String> getBdCoords() { | ||
| 146 | + return bdCoords; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + public void setBdCoords(List<String> bdCoords) { | ||
| 150 | + this.bdCoords = bdCoords; | ||
| 151 | + } | ||
| 152 | +} | ||
| 0 | \ No newline at end of file | 153 | \ No newline at end of file |
src/main/java/com/bsth/entity/oil/Dlb.java
src/main/java/com/bsth/entity/oil/Nylog.java
0 → 100644
| 1 | +package com.bsth.entity.oil; | ||
| 2 | + | ||
| 3 | +import java.util.Date; | ||
| 4 | + | ||
| 5 | +import javax.persistence.Entity; | ||
| 6 | +import javax.persistence.GeneratedValue; | ||
| 7 | +import javax.persistence.Id; | ||
| 8 | +import javax.persistence.Table; | ||
| 9 | + | ||
| 10 | +@Entity | ||
| 11 | +@Table(name = "bsth_c_nylog") | ||
| 12 | +public class Nylog { | ||
| 13 | + @Id | ||
| 14 | + @GeneratedValue | ||
| 15 | + private Integer id; | ||
| 16 | + | ||
| 17 | + private String nylx; | ||
| 18 | + | ||
| 19 | + private String czmc; | ||
| 20 | + | ||
| 21 | + private String userid; | ||
| 22 | + | ||
| 23 | + private String username; | ||
| 24 | + | ||
| 25 | + private Date createdate; | ||
| 26 | + | ||
| 27 | + private String cxtj; | ||
| 28 | + | ||
| 29 | + private String fwdz; | ||
| 30 | + | ||
| 31 | + public Integer getId() { | ||
| 32 | + return id; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public void setId(Integer id) { | ||
| 36 | + this.id = id; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public String getNylx() { | ||
| 40 | + return nylx; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public void setNylx(String nylx) { | ||
| 44 | + this.nylx = nylx; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public String getCzmc() { | ||
| 48 | + return czmc; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public void setCzmc(String czmc) { | ||
| 52 | + this.czmc = czmc; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public String getUserid() { | ||
| 56 | + return userid; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setUserid(String userid) { | ||
| 60 | + this.userid = userid; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public String getUsername() { | ||
| 64 | + return username; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setUsername(String username) { | ||
| 68 | + this.username = username; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public Date getCreatedate() { | ||
| 72 | + return createdate; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setCreatedate(Date createdate) { | ||
| 76 | + this.createdate = createdate; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public String getCxtj() { | ||
| 80 | + return cxtj; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public void setCxtj(String cxtj) { | ||
| 84 | + this.cxtj = cxtj; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public String getFwdz() { | ||
| 88 | + return fwdz; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public void setFwdz(String fwdz) { | ||
| 92 | + this.fwdz = fwdz; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + | ||
| 97 | +} |
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,18 @@ public interface LineVersionsRepository extends BaseRepository<LineVersions, Int | @@ -73,4 +73,18 @@ 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); | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 发布版本 | ||
| 85 | + */ | ||
| 86 | + @Transactional | ||
| 87 | + @Modifying | ||
| 88 | + @Query(value = "UPDATE LineVersions lv set lv.isupdate=1 where lv.id=?1 ") | ||
| 89 | + public int issueVersion(int id); | ||
| 76 | } | 90 | } |
src/main/java/com/bsth/repository/LsSectionRouteRepository.java
| @@ -37,4 +37,11 @@ public interface LsSectionRouteRepository extends BaseRepository<LsSectionRoute, | @@ -37,4 +37,11 @@ public interface LsSectionRouteRepository extends BaseRepository<LsSectionRoute, | ||
| 37 | @Modifying | 37 | @Modifying |
| 38 | @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true) | 38 | @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true) |
| 39 | public void batchDelete(Integer line, Integer dir, Integer versions); | 39 | public void batchDelete(Integer line, Integer dir, Integer versions); |
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 更新路线前撤销线路版本下历史原有路段路由 | ||
| 43 | + */ | ||
| 44 | + @Modifying | ||
| 45 | + @Query(value="UPDATE bsth_c_ls_sectionroute set destroy = 1 where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true) | ||
| 46 | + public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions); | ||
| 40 | } | 47 | } |
src/main/java/com/bsth/repository/LsStationRouteRepository.java
| @@ -42,4 +42,14 @@ public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, | @@ -42,4 +42,14 @@ public interface LsStationRouteRepository extends BaseRepository<LsStationRoute, | ||
| 42 | @Modifying | 42 | @Modifying |
| 43 | @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) | 43 | @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) |
| 44 | public void batchDelete(Integer line,Integer dir, Integer versions); | 44 | public void batchDelete(Integer line,Integer dir, Integer versions); |
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 更新路线前撤销线路版本号历史原有站点路由 | ||
| 48 | + * | ||
| 49 | + * @param line | ||
| 50 | + * @param dir | ||
| 51 | + */ | ||
| 52 | + @Modifying | ||
| 53 | + @Query(value="UPDATE bsth_c_ls_stationroute set destroy = 1 where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) | ||
| 54 | + public void batchDestroy(Integer sectionRouteLine, Integer directions, Integer versions); | ||
| 45 | } | 55 | } |
src/main/java/com/bsth/repository/SectionRouteCacheRepository.java
| @@ -139,4 +139,18 @@ public interface SectionRouteCacheRepository extends BaseRepository<SectionRoute | @@ -139,4 +139,18 @@ public interface SectionRouteCacheRepository extends BaseRepository<SectionRoute | ||
| 139 | @Modifying | 139 | @Modifying |
| 140 | @Query(value="delete from bsth_c_sectionroute_cache where line_code = ?1 and directions = ?2", nativeQuery=true) | 140 | @Query(value="delete from bsth_c_sectionroute_cache where line_code = ?1 and directions = ?2", nativeQuery=true) |
| 141 | public void sectionRouteCacheDel(String lineCode,Integer dir); | 141 | public void sectionRouteCacheDel(String lineCode,Integer dir); |
| 142 | -} | 142 | + |
| 143 | + @Modifying | ||
| 144 | + @Query(value="delete from bsth_c_sectionroute_cache where line = ?1 and directions = ?2", nativeQuery=true) | ||
| 145 | + public void sectionRouteCacheDel(Integer lineId,Integer dir); | ||
| 146 | + | ||
| 147 | + /** | ||
| 148 | + * @Description :TODO(查询线路某方向下的上一个路段序号) | ||
| 149 | + * | ||
| 150 | + * @param map <lineId:线路ID; direction:方向;sectionRouteCode:路段编码> | ||
| 151 | + * | ||
| 152 | + * @return List<Map<String, Object>> | ||
| 153 | + */ | ||
| 154 | + @Query(value = " select MAX(r.sectionroute_code) as sectionrouteCode from bsth_c_sectionroute_cache r WHERE r.line=?1 and r.directions =?2 and r.sectionroute_code< ?3 and r.destroy = 0", nativeQuery=true) | ||
| 155 | + List<Object[]> findCacheUpSectionRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); | ||
| 156 | +} | ||
| 143 | \ No newline at end of file | 157 | \ No newline at end of file |
src/main/java/com/bsth/repository/SectionRouteRepository.java
| @@ -202,4 +202,7 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | @@ -202,4 +202,7 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int | ||
| 202 | @Modifying | 202 | @Modifying |
| 203 | @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") | 203 | @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") |
| 204 | public void batchDelete(Integer lineId, String lineCode); | 204 | public void batchDelete(Integer lineId, String lineCode); |
| 205 | + | ||
| 206 | + @Query("select r from SectionRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.sectionrouteCode") | ||
| 207 | + public List<SectionRoute> findByLine(Integer lineId, Integer dir); | ||
| 205 | } | 208 | } |
src/main/java/com/bsth/repository/StationRouteCacheRepository.java
| 1 | package com.bsth.repository; | 1 | package com.bsth.repository; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | -import java.util.Map; | ||
| 5 | 4 | ||
| 6 | -import org.springframework.data.domain.Sort; | ||
| 7 | -import org.springframework.data.jpa.domain.Specification; | ||
| 8 | import org.springframework.data.jpa.repository.EntityGraph; | 5 | import org.springframework.data.jpa.repository.EntityGraph; |
| 9 | import org.springframework.data.jpa.repository.Modifying; | 6 | import org.springframework.data.jpa.repository.Modifying; |
| 10 | import org.springframework.data.jpa.repository.Query; | 7 | import org.springframework.data.jpa.repository.Query; |
| 11 | import org.springframework.stereotype.Repository; | 8 | import org.springframework.stereotype.Repository; |
| 12 | 9 | ||
| 13 | -import com.bsth.entity.StationRoute; | ||
| 14 | import com.bsth.entity.StationRouteCache; | 10 | import com.bsth.entity.StationRouteCache; |
| 15 | -import com.bsth.entity.search.CustomerSpecs; | ||
| 16 | 11 | ||
| 17 | /** | 12 | /** |
| 18 | * | 13 | * |
| @@ -57,12 +52,16 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute | @@ -57,12 +52,16 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute | ||
| 57 | /** | 52 | /** |
| 58 | * 更新路线删除线路缓存站点 | 53 | * 更新路线删除线路缓存站点 |
| 59 | * | 54 | * |
| 60 | - * @param line | 55 | + * @param lineCode |
| 61 | * @param dir | 56 | * @param dir |
| 62 | */ | 57 | */ |
| 63 | @Modifying | 58 | @Modifying |
| 64 | @Query(value="delete from bsth_c_stationroute_cache where line_code = ?1 and directions = ?2 ", nativeQuery=true) | 59 | @Query(value="delete from bsth_c_stationroute_cache where line_code = ?1 and directions = ?2 ", nativeQuery=true) |
| 65 | public void stationRouteCacheDel(String lineCode,Integer dir); | 60 | public void stationRouteCacheDel(String lineCode,Integer dir); |
| 61 | + | ||
| 62 | + @Modifying | ||
| 63 | + @Query(value="delete from bsth_c_stationroute_cache where line = ?1 and directions = ?2 ", nativeQuery=true) | ||
| 64 | + public void stationRouteCacheDel(Integer lineId,Integer dir); | ||
| 66 | 65 | ||
| 67 | 66 | ||
| 68 | @Query(value = "SELECT a.`stationRoute.id`," + | 67 | @Query(value = "SELECT a.`stationRoute.id`," + |
| @@ -137,4 +136,7 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute | @@ -137,4 +136,7 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute | ||
| 137 | "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true) | 136 | "r.line=?1 and r.directions =?2 and station_route_code< ?3 and r.destroy = 0 ) and t.line=?1 and t.directions = ?2 AND t.destroy = 0", nativeQuery=true) |
| 138 | List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); | 137 | List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); |
| 139 | 138 | ||
| 139 | + @Modifying | ||
| 140 | + @Query(value="UPDATE bsth_c_stationroute_cache set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true) | ||
| 141 | + public void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod); | ||
| 140 | } | 142 | } |
src/main/java/com/bsth/repository/StationRouteRepository.java
| @@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; | @@ -15,7 +15,6 @@ import org.springframework.transaction.annotation.Transactional; | ||
| 15 | 15 | ||
| 16 | import com.bsth.entity.Line; | 16 | import com.bsth.entity.Line; |
| 17 | import com.bsth.entity.StationRoute; | 17 | import com.bsth.entity.StationRoute; |
| 18 | -import com.bsth.entity.StationRouteCache; | ||
| 19 | 18 | ||
| 20 | /** | 19 | /** |
| 21 | * | 20 | * |
| @@ -189,7 +188,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -189,7 +188,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 189 | " a.stationRouteUpdateDate," + | 188 | " a.stationRouteUpdateDate," + |
| 190 | " b.id AS stationId," + | 189 | " b.id AS stationId," + |
| 191 | " b.station_cod AS stationCode," + | 190 | " b.station_cod AS stationCode," + |
| 192 | - " b.station_name AS stationName," + | 191 | + " a.stationRouteName," + |
| 193 | " b.road_coding AS stationRoadCoding," + | 192 | " b.road_coding AS stationRoadCoding," + |
| 194 | " b.db_type AS stationDbType," + | 193 | " b.db_type AS stationDbType," + |
| 195 | " b.b_jwpoints AS stationJwpoints," + | 194 | " b.b_jwpoints AS stationJwpoints," + |
| @@ -212,6 +211,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -212,6 +211,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 212 | " FROM ( SELECT s.id AS stationRouteId," + | 211 | " FROM ( SELECT s.id AS stationRouteId," + |
| 213 | " s.line AS stationRouteLine," + | 212 | " s.line AS stationRouteLine," + |
| 214 | " s.station as stationRouteStation," + | 213 | " s.station as stationRouteStation," + |
| 214 | + " s.station_name AS stationRouteName," + | ||
| 215 | " s.station_route_code as stationRouteCode," + | 215 | " s.station_route_code as stationRouteCode," + |
| 216 | " s.line_code AS stationRouteLIneCode," + | 216 | " s.line_code AS stationRouteLIneCode," + |
| 217 | " s.station_mark AS stationRouteStationMark," + | 217 | " s.station_mark AS stationRouteStationMark," + |
| @@ -259,6 +259,9 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -259,6 +259,9 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 259 | @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | 259 | @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") |
| 260 | List<StationRoute> findByLine(String lineCode, int updown); | 260 | List<StationRoute> findByLine(String lineCode, int updown); |
| 261 | 261 | ||
| 262 | + @Query("select r from StationRoute r where r.line.id=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") | ||
| 263 | + List<StationRoute> findByLine(Integer lineId, Integer dir); | ||
| 264 | + | ||
| 262 | @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) | 265 | @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) |
| 263 | @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1") | 266 | @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1") |
| 264 | List<StationRoute> findByLineCode(String lineCode); | 267 | List<StationRoute> findByLineCode(String lineCode); |
| @@ -285,6 +288,17 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | @@ -285,6 +288,17 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int | ||
| 285 | "ORDER BY " + | 288 | "ORDER BY " + |
| 286 | "lineCode,directions,stationRouteCode") | 289 | "lineCode,directions,stationRouteCode") |
| 287 | List<Map<String, String>> findAllLineWithYgc(); | 290 | List<Map<String, String>> findAllLineWithYgc(); |
| 291 | + | ||
| 292 | + @Query("SELECT new map(" + | ||
| 293 | + "lineCode as lineCode,directions as directions,stationName as stationName,stationCode as stationCode," + | ||
| 294 | + "line.linePlayType as linePlayType,s.stationMark as stationMark) " + | ||
| 295 | + "FROM " + | ||
| 296 | + "StationRoute s " + | ||
| 297 | + "WHERE " + | ||
| 298 | + "s.destroy = 0 and s.lineCode = ?1 " + | ||
| 299 | + "ORDER BY " + | ||
| 300 | + "lineCode,directions,stationRouteCode") | ||
| 301 | + List<Map<String, String>> findLineWithYgcByLine(String lineCode); | ||
| 288 | 302 | ||
| 289 | @Modifying | 303 | @Modifying |
| 290 | @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true) | 304 | @Query(value="update bsth_c_stationroute set directions = case directions when 1 then 0 when 0 then 1 end where line = ?1 ", nativeQuery=true) |
src/main/java/com/bsth/repository/oil/NylogRepository.java
0 → 100644
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信息 |
| @@ -67,6 +71,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ | @@ -67,6 +71,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ | ||
| 67 | @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " | 71 | @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " |
| 68 | + " and fgsdm like %?3%" | 72 | + " and fgsdm like %?3%" |
| 69 | + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc ",nativeQuery=true) | 73 | + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc ",nativeQuery=true) |
| 74 | + List<Ylb> obtainYlEq(String rq,String gsdm,String fgsdm,String xlbm,String nbbm,String px); | ||
| 75 | + | ||
| 76 | + @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " | ||
| 77 | + + " and fgsdm like %?3%" | ||
| 78 | + + " and xlbm = ?4 and nbbm like %?5% order by ?6 asc ",nativeQuery=true) | ||
| 70 | List<Ylb> obtainYl_eq(String rq,String gsdm,String fgsdm,String xlbm,String nbbm,String px); | 79 | List<Ylb> obtainYl_eq(String rq,String gsdm,String fgsdm,String xlbm,String nbbm,String px); |
| 71 | 80 | ||
| 72 | 81 | ||
| @@ -153,4 +162,6 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ | @@ -153,4 +162,6 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ | ||
| 153 | " yhlx = ?9"+ | 162 | " yhlx = ?9"+ |
| 154 | " WHERE id = ?1", nativeQuery=true) | 163 | " WHERE id = ?1", nativeQuery=true) |
| 155 | public void ylbUpdate(Integer id,double czyl,double jzyl,double yh, double sh,String shyy,double ns,String rylx,int yhlx); | 164 | public void ylbUpdate(Integer id,double czyl,double jzyl,double yh, double sh,String shyy,double ns,String rylx,int yhlx); |
| 165 | + | ||
| 166 | + | ||
| 156 | } | 167 | } |
src/main/java/com/bsth/service/LineVersionsService.java
| @@ -33,7 +33,12 @@ public interface LineVersionsService extends BaseService<LineVersions, Integer> | @@ -33,7 +33,12 @@ 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 | ||
| 42 | + Map<String, Object> issueVersion(int id); | ||
| 43 | + | ||
| 39 | } | 44 | } |
src/main/java/com/bsth/service/SectionRouteService.java
| @@ -61,8 +61,11 @@ public interface SectionRouteService extends BaseService<SectionRoute, Integer> | @@ -61,8 +61,11 @@ public interface SectionRouteService extends BaseService<SectionRoute, Integer> | ||
| 61 | */ | 61 | */ |
| 62 | List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map); | 62 | List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map); |
| 63 | 63 | ||
| 64 | + List<Map<String, Object>> findCacheUpSectionRouteCode(Map<String, Object> map); | ||
| 65 | + | ||
| 64 | Map<String, Object> quoteSection(Map<String, Object> map); | 66 | Map<String, Object> quoteSection(Map<String, Object> map); |
| 65 | 67 | ||
| 66 | void batchUpdate(Integer lineId, String lineCode); | 68 | void batchUpdate(Integer lineId, String lineCode); |
| 69 | + | ||
| 67 | 70 | ||
| 68 | } | 71 | } |
src/main/java/com/bsth/service/StationService.java
| @@ -52,6 +52,8 @@ public interface StationService extends BaseService<Station, Integer> { | @@ -52,6 +52,8 @@ public interface StationService extends BaseService<Station, Integer> { | ||
| 52 | */ | 52 | */ |
| 53 | Map<String, Object> stationSaveMap(Map<String, Object> map); | 53 | Map<String, Object> stationSaveMap(Map<String, Object> map); |
| 54 | 54 | ||
| 55 | + Map<String, Object> stationCacheSave(Map<String, Object> map); | ||
| 56 | + | ||
| 55 | /** | 57 | /** |
| 56 | * @Description :TODO(更新站点保存) | 58 | * @Description :TODO(更新站点保存) |
| 57 | * | 59 | * |
| @@ -83,5 +85,8 @@ public interface StationService extends BaseService<Station, Integer> { | @@ -83,5 +85,8 @@ public interface StationService extends BaseService<Station, Integer> { | ||
| 83 | Map<String, Object> cacheSave(Map<String, Object> map); | 85 | Map<String, Object> cacheSave(Map<String, Object> map); |
| 84 | 86 | ||
| 85 | Map<String, Object> stationCacheUpdate(Map<String, Object> map); | 87 | Map<String, Object> stationCacheUpdate(Map<String, Object> map); |
| 88 | + | ||
| 89 | + Map<String, Object> referenceCurrentVersion(Map<String, Object> map); | ||
| 90 | + | ||
| 86 | 91 | ||
| 87 | } | 92 | } |
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/FormsService.java
| @@ -31,6 +31,7 @@ public interface FormsService { | @@ -31,6 +31,7 @@ public interface FormsService { | ||
| 31 | 31 | ||
| 32 | public List<Singledata> singledata(Map<String, Object> map); | 32 | public List<Singledata> singledata(Map<String, Object> map); |
| 33 | public List<Singledata> singledatanew(Map<String, Object> map); | 33 | public List<Singledata> singledatanew(Map<String, Object> map); |
| 34 | + public List<Singledata> singledatatj(Map<String, Object> map); | ||
| 34 | 35 | ||
| 35 | public List<Vehicleloading> vehicleloading(String line,String data); | 36 | public List<Vehicleloading> vehicleloading(String line,String data); |
| 36 | 37 |
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, " |
| @@ -473,7 +473,8 @@ public class FormsServiceImpl implements FormsService { | @@ -473,7 +473,8 @@ public class FormsServiceImpl implements FormsService { | ||
| 473 | Shifday d=list.get(i); | 473 | Shifday d=list.get(i); |
| 474 | for (int j = 0; j < lists.size(); j++) { | 474 | for (int j = 0; j < lists.size(); j++) { |
| 475 | ScheduleRealInfo s=lists.get(j); | 475 | ScheduleRealInfo s=lists.get(j); |
| 476 | - if(d.getJgh().equals(s.getjGh()) && d.getCarPlate().equals(s.getClZbh())){ | 476 | + if(d.getJgh().equals(s.getjGh()) && d.getCarPlate().equals(s.getClZbh()) |
| 477 | + &&d.getLpName().equals(s.getLpName())){ | ||
| 477 | sList.add(s); | 478 | sList.add(s); |
| 478 | Set<ChildTaskPlan> cts = s.getcTasks(); | 479 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 479 | if(cts != null && cts.size() > 0){ | 480 | if(cts != null && cts.size() > 0){ |
| @@ -492,7 +493,10 @@ public class FormsServiceImpl implements FormsService { | @@ -492,7 +493,10 @@ public class FormsServiceImpl implements FormsService { | ||
| 492 | double ljgl=culateMileageService.culateLjgl(list_s); | 493 | double ljgl=culateMileageService.culateLjgl(list_s); |
| 493 | double sjgl=culateMileageService.culateSjgl(list_s); | 494 | double sjgl=culateMileageService.culateSjgl(list_s); |
| 494 | double zyygl=Arith.add(ljgl, sjgl); | 495 | double zyygl=Arith.add(ljgl, sjgl); |
| 495 | - double jhgl=culateMileageService.culateJhgl(sList); | 496 | + double jhyygl=culateMileageService.culateJhgl(sList); |
| 497 | + double jhjccgl=culateMileageService.culateJhJccgl(sList); | ||
| 498 | + double jhzgl=Arith.add(jhyygl, jhjccgl); | ||
| 499 | + | ||
| 496 | double cjgl=culateMileageService.culateLbgl(sList); | 500 | double cjgl=culateMileageService.culateLbgl(sList); |
| 497 | int jhbc=culateMileageService.culateJhbc(sList,""); | 501 | int jhbc=culateMileageService.culateJhbc(sList,""); |
| 498 | int cjbc=culateMileageService.culateLbbc(sList); | 502 | int cjbc=culateMileageService.culateLbbc(sList); |
| @@ -502,9 +506,9 @@ public class FormsServiceImpl implements FormsService { | @@ -502,9 +506,9 @@ public class FormsServiceImpl implements FormsService { | ||
| 502 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 | 506 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 |
| 503 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 | 507 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 |
| 504 | d.setSjbc(String.valueOf(sjbc+ljbc)); | 508 | d.setSjbc(String.valueOf(sjbc+ljbc)); |
| 505 | - d.setJhlc(String.valueOf(jhgl));//计划里程 | 509 | + d.setJhlc(String.valueOf(jhzgl));//计划里程 |
| 506 | d.setYygl(String.valueOf(zyygl));//运营公里 | 510 | d.setYygl(String.valueOf(zyygl));//运营公里 |
| 507 | - d.setSjjhlc(String.valueOf(sjgl));//实际计划里程 | 511 | + d.setSjjhlc(String.valueOf(jhyygl));//实际计划里程 |
| 508 | d.setRemMileage(String.valueOf(cjgl));//抽减里程 | 512 | d.setRemMileage(String.valueOf(cjgl));//抽减里程 |
| 509 | d.setJhbc(String.valueOf(jhbc));//计划班次 | 513 | d.setJhbc(String.valueOf(jhbc));//计划班次 |
| 510 | d.setCjbc(String.valueOf(cjbc));//抽检班次 | 514 | d.setCjbc(String.valueOf(cjbc));//抽检班次 |
| @@ -629,6 +633,532 @@ public class FormsServiceImpl implements FormsService { | @@ -629,6 +633,532 @@ public class FormsServiceImpl implements FormsService { | ||
| 629 | 633 | ||
| 630 | 634 | ||
| 631 | // 路单数据 | 635 | // 路单数据 |
| 636 | + @Override | ||
| 637 | + public List<Singledata> singledatatj(Map<String, Object> map) { | ||
| 638 | + String gsdm=""; | ||
| 639 | + if(map.get("gsdmSing")!=null){ | ||
| 640 | + gsdm=map.get("gsdmSing").toString(); | ||
| 641 | + } | ||
| 642 | + String fgsdm=""; | ||
| 643 | + if(map.get("fgsdmSing")!=null){ | ||
| 644 | + fgsdm=map.get("fgsdmSing").toString(); | ||
| 645 | + } | ||
| 646 | + | ||
| 647 | + String tjtype=map.get("tjtype").toString(); | ||
| 648 | + String xlbm=map.get("line").toString().trim(); | ||
| 649 | + startDate = map.get("startDate").toString(); | ||
| 650 | + | ||
| 651 | + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>(); | ||
| 652 | + if(xlbm.equals("")){ | ||
| 653 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm, startDate); | ||
| 654 | + }else{ | ||
| 655 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, startDate); | ||
| 656 | + } | ||
| 657 | + List<Singledata> list=new ArrayList<Singledata>(); | ||
| 658 | + List<Singledata> list_=new ArrayList<Singledata>(); | ||
| 659 | + if(tjtype.equals("jsy")){ | ||
| 660 | + //油统计 | ||
| 661 | + String sql="select r.j_gh, r.xl_bm,r.cl_zbh" | ||
| 662 | + + " from bsth_c_s_sp_info_real r where " | ||
| 663 | + + " r.schedule_date_str = '"+startDate+"'"; | ||
| 664 | + if(xlbm.equals("")){ | ||
| 665 | + sql +="and r.gs_bm='"+gsdm+"' " | ||
| 666 | + + " and r.fgs_bm='"+fgsdm+"'"; | ||
| 667 | + }else{ | ||
| 668 | + sql += " and r.xl_bm = '"+xlbm+"'"; | ||
| 669 | + } | ||
| 670 | + sql += " group by r.j_gh,r.xl_bm,r.cl_zbh order by r.xl_bm,r.cl_zbh"; | ||
| 671 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | ||
| 672 | + @Override | ||
| 673 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 674 | + Singledata sin = new Singledata(); | ||
| 675 | + sin.setxL(arg0.getString("xl_bm")); | ||
| 676 | + sin.setJsy(arg0.getString("j_gh")); | ||
| 677 | + sin.setClzbh(arg0.getString("cl_zbh")); | ||
| 678 | + return sin; | ||
| 679 | + } | ||
| 680 | + }); | ||
| 681 | + String linesql=""; | ||
| 682 | + if(!xlbm.equals("")){ | ||
| 683 | + linesql +=" and xlbm ='"+xlbm+"' "; | ||
| 684 | + } | ||
| 685 | + String nysql="SELECT id,xlbm,nbbm, jsy,jzl as jzl,yh as yh,sh as sh FROM bsth_c_ylb " | ||
| 686 | + + " WHERE rq = '"+startDate+"'" | ||
| 687 | + + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'" +linesql | ||
| 688 | + + " union" | ||
| 689 | + + " SELECT id,xlbm,nbbm,jsy,cdl as jzl,hd as yh,sh as sh FROM bsth_c_dlb" | ||
| 690 | + + " WHERE rq = '"+startDate+"'" | ||
| 691 | + + " AND ssgsdm = '"+gsdm+"' AND fgsdm = '"+fgsdm+"'"+linesql; | ||
| 692 | + List<Singledata> listNy = jdbcTemplate.query(nysql, new RowMapper<Singledata>() { | ||
| 693 | + @Override | ||
| 694 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 695 | + Singledata sin = new Singledata(); | ||
| 696 | + sin.setxL(arg0.getString("xlbm")); | ||
| 697 | + sin.setJsy(arg0.getString("jsy")); | ||
| 698 | + sin.setClzbh(arg0.getString("nbbm")); | ||
| 699 | + sin.setJzl(arg0.getString("jzl")); | ||
| 700 | + sin.setHyl(arg0.getString("yh")); | ||
| 701 | + sin.setUnyyyl(arg0.getString("sh")); | ||
| 702 | + return sin; | ||
| 703 | + } | ||
| 704 | + }); | ||
| 705 | + //统计油,电表中手动添加的或者有加注没里程的数据 | ||
| 706 | + for (int i = 0; i < listNy.size(); i++) { | ||
| 707 | + Singledata sin_=listNy.get(i); | ||
| 708 | + String jsy=sin_.getJsy(); | ||
| 709 | + String line=sin_.getxL(); | ||
| 710 | + String clzbh=sin_.getClzbh(); | ||
| 711 | + boolean fages=true; | ||
| 712 | + for (int j = 0; j < list.size(); j++) { | ||
| 713 | + Singledata sin=list.get(j); | ||
| 714 | + String jsy_=sin.getJsy(); | ||
| 715 | + String line_=sin.getxL(); | ||
| 716 | + String clzbh_=sin.getClzbh(); | ||
| 717 | + if(jsy.equals(jsy_) | ||
| 718 | + &&line.equals(line_) | ||
| 719 | + &&clzbh.equals(clzbh_)){ | ||
| 720 | + fages=false; | ||
| 721 | + } | ||
| 722 | + } | ||
| 723 | + if(fages){ | ||
| 724 | + Singledata s=new Singledata(); | ||
| 725 | + s.setJsy(jsy); | ||
| 726 | + s.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 727 | + s.setClzbh(clzbh); | ||
| 728 | + s.setSgh(""); | ||
| 729 | + s.setsName(""); | ||
| 730 | + s.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 731 | + s.setxL(line); | ||
| 732 | + s.setXlmc(BasicData.lineCode2NameMap.get(line)); | ||
| 733 | + s.setJzl(sin_.getJzl()); | ||
| 734 | + s.setHyl(sin_.getHyl()); | ||
| 735 | + s.setUnyyyl(sin_.getUnyyyl()); | ||
| 736 | + s.setJhlc("0.0"); | ||
| 737 | + s.setEmptMileage("0.0"); | ||
| 738 | + s.setJhjl("0.0"); | ||
| 739 | + s.setrQ(startDate); | ||
| 740 | + list_.add(s); | ||
| 741 | + } | ||
| 742 | + } | ||
| 743 | + for (int i= 0; i < list.size(); i++) { | ||
| 744 | + Singledata sin=list.get(i); | ||
| 745 | + String jsy=sin.getJsy(); | ||
| 746 | + String line=sin.getxL(); | ||
| 747 | + String clzbh=sin.getClzbh(); | ||
| 748 | + double jzl=0.0; | ||
| 749 | + double yh=0.0; | ||
| 750 | + double sh=0.0; | ||
| 751 | + for (int j = 0; j < listNy.size(); j++) { | ||
| 752 | + Singledata y=listNy.get(j); | ||
| 753 | + if(y.getJsy().equals(jsy) | ||
| 754 | + &&y.getClzbh().equals(clzbh) | ||
| 755 | + &&y.getxL().equals(line)){ | ||
| 756 | + jzl=Arith.add(jzl, y.getJzl()); | ||
| 757 | + yh=Arith.add(yh, y.getHyl()); | ||
| 758 | + sh=Arith.add(sh, y.getUnyyyl()); | ||
| 759 | + } | ||
| 760 | + } | ||
| 761 | + sin.setHyl(String.valueOf(yh)); | ||
| 762 | + sin.setJzl(String.valueOf(jzl)); | ||
| 763 | + sin.setUnyyyl(String.valueOf(sh)); | ||
| 764 | + | ||
| 765 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 766 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 767 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 768 | + ScheduleRealInfo s=listReal.get(j); | ||
| 769 | + if(s.getjGh().equals(jsy) | ||
| 770 | + && s.getClZbh().equals(clzbh) | ||
| 771 | + &&s.getXlBm().equals(line)){ | ||
| 772 | + newList.add(s); | ||
| 773 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 774 | + if(cts != null && cts.size() > 0){ | ||
| 775 | + newList_.add(s); | ||
| 776 | + }else{ | ||
| 777 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 778 | + newList_.add(s); | ||
| 779 | + } | ||
| 780 | + } | ||
| 781 | + } | ||
| 782 | + } | ||
| 783 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 784 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 785 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 786 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 787 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 788 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 789 | + | ||
| 790 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 791 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 792 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 793 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 794 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 795 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | ||
| 796 | + sin.setrQ(startDate); | ||
| 797 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 798 | + sin.setSgh(""); | ||
| 799 | + sin.setsName(""); | ||
| 800 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 801 | + list_.add(sin); | ||
| 802 | + | ||
| 803 | + } | ||
| 804 | + Collections.sort(list_,new SingledataByXlbm()); | ||
| 805 | + }else{ | ||
| 806 | + String sql="select r.s_gh,r.s_name, " | ||
| 807 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm" | ||
| 808 | + + " from bsth_c_s_sp_info_real r where " | ||
| 809 | + + " r.schedule_date_str = '"+startDate+"'" | ||
| 810 | + + " and r.s_gh !='' and r.s_gh is not null "; | ||
| 811 | + if(xlbm.equals("")){ | ||
| 812 | + sql +="and r.gs_bm='"+gsdm+"' " | ||
| 813 | + + " and r.fgs_bm='"+fgsdm+"'"; | ||
| 814 | + }else{ | ||
| 815 | + sql += " and r.xl_bm = '"+xlbm+"'"; | ||
| 816 | + } | ||
| 817 | + sql += " group by r.s_gh,r.s_name," | ||
| 818 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh"; | ||
| 819 | + | ||
| 820 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | ||
| 821 | + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 822 | + @Override | ||
| 823 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 824 | + Singledata sin = new Singledata(); | ||
| 825 | + sin.setrQ(startDate); | ||
| 826 | + sin.setxL(arg0.getString("xl_bm")); | ||
| 827 | + sin.setClzbh(arg0.getString("cl_zbh")); | ||
| 828 | + sin.setSgh(arg0.getString("s_gh")); | ||
| 829 | + sin.setsName(arg0.getString("s_name")); | ||
| 830 | + return sin; | ||
| 831 | + } | ||
| 832 | + }); | ||
| 833 | + | ||
| 834 | + for (int i = 0; i < list.size(); i++) { | ||
| 835 | + Singledata sin=list.get(i); | ||
| 836 | + String jsy=sin.getSgh(); | ||
| 837 | + String line=sin.getxL(); | ||
| 838 | + String clzbh=sin.getClzbh(); | ||
| 839 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 840 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 841 | + | ||
| 842 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 843 | + ScheduleRealInfo s=listReal.get(j); | ||
| 844 | + if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh) | ||
| 845 | + &&s.getXlBm().equals(line)){ | ||
| 846 | + newList.add(s); | ||
| 847 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 848 | + if(cts != null && cts.size() > 0){ | ||
| 849 | + newList_.add(s); | ||
| 850 | + }else{ | ||
| 851 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 852 | + newList_.add(s); | ||
| 853 | + } | ||
| 854 | + } | ||
| 855 | + } | ||
| 856 | + } | ||
| 857 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 858 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 859 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 860 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 861 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 862 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 863 | + | ||
| 864 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 865 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 866 | + | ||
| 867 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 868 | + | ||
| 869 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 870 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 871 | + sin.setxL(BasicData.lineCode2NameMap.get(line)); | ||
| 872 | + sin.setClzbh(clzbh); | ||
| 873 | + sin.setJsy(""); | ||
| 874 | + sin.setjName(""); | ||
| 875 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 876 | + sin.setHyl(""); | ||
| 877 | + sin.setJzl(""); | ||
| 878 | + sin.setUnyyyl(""); | ||
| 879 | + } | ||
| 880 | + Collections.sort(list,new SingledataByXlbm()); | ||
| 881 | + } | ||
| 882 | + return list_; | ||
| 883 | + } | ||
| 884 | + | ||
| 885 | + /*// 路单数据 | ||
| 886 | + @Override | ||
| 887 | + public List<Singledata> singledatatj(Map<String, Object> map) { | ||
| 888 | + | ||
| 889 | + String gsdm=""; | ||
| 890 | + if(map.get("gsdmSing")!=null){ | ||
| 891 | + gsdm=map.get("gsdmSing").toString(); | ||
| 892 | + } | ||
| 893 | + String fgsdm=""; | ||
| 894 | + if(map.get("fgsdmSing")!=null){ | ||
| 895 | + fgsdm=map.get("fgsdmSing").toString(); | ||
| 896 | + } | ||
| 897 | + | ||
| 898 | + String tjtype=map.get("tjtype").toString(); | ||
| 899 | + String xlbm=map.get("line").toString().trim(); | ||
| 900 | + startDate = map.get("startDate").toString(); | ||
| 901 | + | ||
| 902 | + List<ScheduleRealInfo> listReal=new ArrayList<ScheduleRealInfo>(); | ||
| 903 | + if(xlbm.equals("")){ | ||
| 904 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineByGs_(gsdm, fgsdm, startDate); | ||
| 905 | + }else{ | ||
| 906 | + listReal=scheduleRealInfoRepository.scheduleByDateAndLineQp(xlbm, startDate); | ||
| 907 | + } | ||
| 908 | + List<Singledata> list=new ArrayList<Singledata>(); | ||
| 909 | + List<Singledata> listY=new ArrayList<Singledata>(); | ||
| 910 | + List<Singledata> listD=new ArrayList<Singledata>(); | ||
| 911 | + | ||
| 912 | + if(tjtype.equals("jsy")){ | ||
| 913 | + //油统计 | ||
| 914 | + String sql="select xlbm,nbbm,jsy from bsth_c_ylb where rq='"+startDate+"'"; | ||
| 915 | + if(xlbm.equals("")){ | ||
| 916 | + sql += " and ssgsdm= '"+gsdm+"' and fgsdm= '"+fgsdm+"'"; | ||
| 917 | + }else{ | ||
| 918 | + sql +=" and xlbm= '"+xlbm+"'"; | ||
| 919 | + } | ||
| 920 | + sql += " group by xlbm,nbbm,jsy"; | ||
| 921 | + listY = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | ||
| 922 | + @Override | ||
| 923 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 924 | + Singledata sin = new Singledata(); | ||
| 925 | + sin.setxL(arg0.getString("xlbm")); | ||
| 926 | + sin.setJsy(arg0.getString("jsy")); | ||
| 927 | + sin.setClzbh(arg0.getString("nbbm")); | ||
| 928 | + return sin; | ||
| 929 | + } | ||
| 930 | + }); | ||
| 931 | + | ||
| 932 | + List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | ||
| 933 | + for (int i = 0; i < listY.size(); i++) { | ||
| 934 | + Singledata sin=listY.get(i); | ||
| 935 | + String jsy=sin.getJsy(); | ||
| 936 | + String line=sin.getxL(); | ||
| 937 | + String clzbh=sin.getClzbh(); | ||
| 938 | + | ||
| 939 | + double jzl=0.0; | ||
| 940 | + double yh=0.0; | ||
| 941 | + double sh=0.0; | ||
| 942 | + for (int j = 0; j < listYlb.size(); j++) { | ||
| 943 | + Ylb y=listYlb.get(j); | ||
| 944 | + if(y.getJsy().equals(jsy) | ||
| 945 | + &&y.getNbbm().equals(clzbh) | ||
| 946 | + &&y.getXlbm().equals(line)){ | ||
| 947 | + jzl=Arith.add(jzl, y.getJzl()); | ||
| 948 | + yh=Arith.add(yh, y.getYh()); | ||
| 949 | + sh=Arith.add(sh, y.getSh()); | ||
| 950 | + } | ||
| 951 | + } | ||
| 952 | + sin.setHyl(String.valueOf(yh)); | ||
| 953 | + sin.setJzl(String.valueOf(jzl)); | ||
| 954 | + sin.setUnyyyl(String.valueOf(sh)); | ||
| 955 | + | ||
| 956 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 957 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 958 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 959 | + ScheduleRealInfo s=listReal.get(j); | ||
| 960 | + if(s.getjGh().equals(jsy) | ||
| 961 | + && s.getClZbh().equals(clzbh) | ||
| 962 | + &&s.getXlBm().equals(line)){ | ||
| 963 | + newList.add(s); | ||
| 964 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 965 | + if(cts != null && cts.size() > 0){ | ||
| 966 | + newList_.add(s); | ||
| 967 | + }else{ | ||
| 968 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 969 | + newList_.add(s); | ||
| 970 | + } | ||
| 971 | + } | ||
| 972 | + } | ||
| 973 | + } | ||
| 974 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 975 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 976 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 977 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 978 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 979 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 980 | + | ||
| 981 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 982 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 983 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 984 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 985 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 986 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | ||
| 987 | + sin.setrQ(startDate); | ||
| 988 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 989 | + sin.setSgh(""); | ||
| 990 | + sin.setsName(""); | ||
| 991 | + } | ||
| 992 | + | ||
| 993 | + | ||
| 994 | + //电量计算 | ||
| 995 | + String sqldl="select xlbm,nbbm,jsy from bsth_c_dlb where rq='"+startDate+"'"; | ||
| 996 | + if(xlbm.equals("")){ | ||
| 997 | + sqldl += " and ssgsdm= '"+gsdm+"' and fgsdm= '"+fgsdm+"'"; | ||
| 998 | + }else{ | ||
| 999 | + sqldl +=" and xlbm= '"+xlbm+"'"; | ||
| 1000 | + } | ||
| 1001 | + sqldl += " group by xlbm,nbbm,jsy"; | ||
| 1002 | + listD = jdbcTemplate.query(sqldl, new RowMapper<Singledata>() { | ||
| 1003 | + @Override | ||
| 1004 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 1005 | + Singledata sin = new Singledata(); | ||
| 1006 | + sin.setxL(arg0.getString("xlbm")); | ||
| 1007 | + sin.setJsy(arg0.getString("jsy")); | ||
| 1008 | + sin.setClzbh(arg0.getString("nbbm")); | ||
| 1009 | + return sin; | ||
| 1010 | + } | ||
| 1011 | + }); | ||
| 1012 | + List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | ||
| 1013 | + | ||
| 1014 | + for (int i = 0; i < listD.size(); i++) { | ||
| 1015 | + Singledata sin=listD.get(i); | ||
| 1016 | + String jsy=sin.getJsy(); | ||
| 1017 | + String line=sin.getxL(); | ||
| 1018 | + String clzbh=sin.getClzbh(); | ||
| 1019 | + | ||
| 1020 | + double jzl=0.0; | ||
| 1021 | + double yh=0.0; | ||
| 1022 | + double sh=0.0; | ||
| 1023 | + for (int j = 0; j < listDlb.size(); j++) { | ||
| 1024 | + Dlb d=listDlb.get(j); | ||
| 1025 | + if(d.getJsy().equals(jsy) | ||
| 1026 | + &&d.getNbbm().equals(clzbh) | ||
| 1027 | + &&d.getXlbm().equals(line)){ | ||
| 1028 | + jzl=Arith.add(jzl, d.getCdl()); | ||
| 1029 | + yh=Arith.add(yh, d.getHd()); | ||
| 1030 | + sh=Arith.add(sh, d.getSh()); | ||
| 1031 | + } | ||
| 1032 | + } | ||
| 1033 | + sin.setHyl(String.valueOf(yh)); | ||
| 1034 | + sin.setJzl(String.valueOf(jzl)); | ||
| 1035 | + sin.setUnyyyl(String.valueOf(sh)); | ||
| 1036 | + | ||
| 1037 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 1038 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 1039 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 1040 | + ScheduleRealInfo s=listReal.get(j); | ||
| 1041 | + if(s.getjGh().equals(jsy) | ||
| 1042 | + && s.getClZbh().equals(clzbh) | ||
| 1043 | + &&s.getXlBm().equals(line)){ | ||
| 1044 | + newList.add(s); | ||
| 1045 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1046 | + if(cts != null && cts.size() > 0){ | ||
| 1047 | + newList_.add(s); | ||
| 1048 | + }else{ | ||
| 1049 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 1050 | + newList_.add(s); | ||
| 1051 | + } | ||
| 1052 | + } | ||
| 1053 | + } | ||
| 1054 | + } | ||
| 1055 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 1056 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 1057 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 1058 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 1059 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 1060 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 1061 | + | ||
| 1062 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 1063 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 1064 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 1065 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 1066 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 1067 | + sin.setXlmc(BasicData.lineCode2NameMap.get(line)); | ||
| 1068 | + sin.setrQ(startDate); | ||
| 1069 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 1070 | + sin.setSgh(""); | ||
| 1071 | + sin.setsName(""); | ||
| 1072 | + } | ||
| 1073 | + | ||
| 1074 | + | ||
| 1075 | + Collections.sort(listY,new SingledataByXlbm()); | ||
| 1076 | + Collections.sort(listD,new SingledataByXlbm()); | ||
| 1077 | + list.addAll(listY); | ||
| 1078 | + list.addAll(listD); | ||
| 1079 | + }else{ | ||
| 1080 | + String sql="select r.s_gh,r.s_name, " | ||
| 1081 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm" | ||
| 1082 | + + " from bsth_c_s_sp_info_real r where " | ||
| 1083 | + + " r.schedule_date_str = '"+startDate+"'" | ||
| 1084 | + + " and r.s_gh !='' and r.s_gh is not null "; | ||
| 1085 | + if(xlbm.equals("")){ | ||
| 1086 | + sql +="and r.gs_bm='"+gsdm+"' " | ||
| 1087 | + + " and r.fgs_bm='"+fgsdm+"'"; | ||
| 1088 | + }else{ | ||
| 1089 | + sql += " and r.xl_bm = '"+xlbm+"'"; | ||
| 1090 | + } | ||
| 1091 | + sql += " group by r.s_gh,r.s_name," | ||
| 1092 | + + " r.xl_bm,r.cl_zbh,r.gs_bm,r.fgs_bm order by r.xl_bm,r.cl_zbh"; | ||
| 1093 | + | ||
| 1094 | + list = jdbcTemplate.query(sql, new RowMapper<Singledata>() { | ||
| 1095 | + //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 1096 | + @Override | ||
| 1097 | + public Singledata mapRow(ResultSet arg0, int arg1) throws SQLException { | ||
| 1098 | + Singledata sin = new Singledata(); | ||
| 1099 | + sin.setrQ(startDate); | ||
| 1100 | + sin.setxL(arg0.getString("xl_bm")); | ||
| 1101 | + sin.setClzbh(arg0.getString("cl_zbh")); | ||
| 1102 | + sin.setSgh(arg0.getString("s_gh")); | ||
| 1103 | + sin.setsName(arg0.getString("s_name")); | ||
| 1104 | + return sin; | ||
| 1105 | + } | ||
| 1106 | + }); | ||
| 1107 | + | ||
| 1108 | + for (int i = 0; i < list.size(); i++) { | ||
| 1109 | + Singledata sin=list.get(i); | ||
| 1110 | + String jsy=sin.getSgh(); | ||
| 1111 | + String line=sin.getxL(); | ||
| 1112 | + String clzbh=sin.getClzbh(); | ||
| 1113 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 1114 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 1115 | + | ||
| 1116 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 1117 | + ScheduleRealInfo s=listReal.get(j); | ||
| 1118 | + if(s.getsGh().equals(jsy) && s.getClZbh().equals(clzbh) | ||
| 1119 | + &&s.getXlBm().equals(line)){ | ||
| 1120 | + newList.add(s); | ||
| 1121 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1122 | + if(cts != null && cts.size() > 0){ | ||
| 1123 | + newList_.add(s); | ||
| 1124 | + }else{ | ||
| 1125 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 1126 | + newList_.add(s); | ||
| 1127 | + } | ||
| 1128 | + } | ||
| 1129 | + } | ||
| 1130 | + } | ||
| 1131 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 1132 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 1133 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 1134 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 1135 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 1136 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 1137 | + | ||
| 1138 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 1139 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 1140 | + | ||
| 1141 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 1142 | + | ||
| 1143 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 1144 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 1145 | + sin.setxL(BasicData.lineCode2NameMap.get(line)); | ||
| 1146 | + sin.setClzbh(clzbh); | ||
| 1147 | + sin.setJsy(""); | ||
| 1148 | + sin.setjName(""); | ||
| 1149 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 1150 | + sin.setHyl(""); | ||
| 1151 | + sin.setJzl(""); | ||
| 1152 | + sin.setUnyyyl(""); | ||
| 1153 | + } | ||
| 1154 | + Collections.sort(list,new SingledataByXlbm()); | ||
| 1155 | + } | ||
| 1156 | + | ||
| 1157 | + return list; | ||
| 1158 | + | ||
| 1159 | + }*/ | ||
| 1160 | + | ||
| 1161 | + // 路单数据 | ||
| 632 | @Override | 1162 | @Override |
| 633 | public List<Singledata> singledatanew(Map<String, Object> map) { | 1163 | public List<Singledata> singledatanew(Map<String, Object> map) { |
| 634 | 1164 | ||
| @@ -787,27 +1317,25 @@ public class FormsServiceImpl implements FormsService { | @@ -787,27 +1317,25 @@ public class FormsServiceImpl implements FormsService { | ||
| 787 | List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | 1317 | List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); |
| 788 | for (int i = 0; i < listYlb.size(); i++) { | 1318 | for (int i = 0; i < listYlb.size(); i++) { |
| 789 | Ylb y=listYlb.get(i); | 1319 | 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())){ | 1320 | + boolean fage=false; |
| 1321 | + if(xlbm.equals("")){ | ||
| 1322 | + fage=true; | ||
| 1323 | + }else{ | ||
| 1324 | + if(xlbm.equals(y.getXlbm())){ | ||
| 1325 | + fage=true; | ||
| 1326 | + } | ||
| 1327 | + } | ||
| 1328 | + if(fage){ | ||
| 1329 | + String jsy=y.getJsy(); | ||
| 1330 | + String line=y.getXlbm(); | ||
| 1331 | + String clzbh=y.getNbbm(); | ||
| 1332 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 1333 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 1334 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 1335 | + ScheduleRealInfo s=listReal.get(j); | ||
| 1336 | + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh) | ||
| 1337 | + &&s.getXlBm().equals(line)){ | ||
| 1338 | + if(y.getLp()==null){ | ||
| 811 | newList.add(s); | 1339 | newList.add(s); |
| 812 | Set<ChildTaskPlan> cts = s.getcTasks(); | 1340 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 813 | if(cts != null && cts.size() > 0){ | 1341 | if(cts != null && cts.size() > 0){ |
| @@ -817,65 +1345,75 @@ public class FormsServiceImpl implements FormsService { | @@ -817,65 +1345,75 @@ public class FormsServiceImpl implements FormsService { | ||
| 817 | newList_.add(s); | 1345 | newList_.add(s); |
| 818 | } | 1346 | } |
| 819 | } | 1347 | } |
| 1348 | + }else{ | ||
| 1349 | + if(y.getLp().equals(s.getLpName())){ | ||
| 1350 | + newList.add(s); | ||
| 1351 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1352 | + if(cts != null && cts.size() > 0){ | ||
| 1353 | + newList_.add(s); | ||
| 1354 | + }else{ | ||
| 1355 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 1356 | + newList_.add(s); | ||
| 1357 | + } | ||
| 1358 | + } | ||
| 1359 | + } | ||
| 820 | } | 1360 | } |
| 821 | } | 1361 | } |
| 822 | } | 1362 | } |
| 1363 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 1364 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 1365 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 1366 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 1367 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 1368 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 1369 | + | ||
| 1370 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 1371 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 1372 | + | ||
| 1373 | + Singledata sin=new Singledata(); | ||
| 1374 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 1375 | + | ||
| 1376 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 1377 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 1378 | + sin.setxL(y.getXlbm()); | ||
| 1379 | + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm())); | ||
| 1380 | + sin.setClzbh(clzbh); | ||
| 1381 | + sin.setJsy(jsy); | ||
| 1382 | + sin.setrQ(startDate); | ||
| 1383 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 1384 | + sin.setSgh(""); | ||
| 1385 | + sin.setsName(""); | ||
| 1386 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 1387 | + sin.setHyl(df.format(y.getYh())); | ||
| 1388 | + sin.setJzl(df.format(y.getJzl())); | ||
| 1389 | + sin.setUnyyyl(df.format(y.getSh())); | ||
| 1390 | + listY.add(sin); | ||
| 823 | } | 1391 | } |
| 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 | 1392 | ||
| 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 | } | 1393 | } |
| 853 | 1394 | ||
| 854 | List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); | 1395 | List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); |
| 855 | for (int i = 0; i < listDlb.size(); i++) { | 1396 | for (int i = 0; i < listDlb.size(); i++) { |
| 856 | - | ||
| 857 | Dlb y=listDlb.get(i); | 1397 | 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())){ | 1398 | + boolean fage=false; |
| 1399 | + if(xlbm.equals("")){ | ||
| 1400 | + fage=true; | ||
| 1401 | + }else{ | ||
| 1402 | + if(xlbm.equals(y.getXlbm())){ | ||
| 1403 | + fage=true; | ||
| 1404 | + } | ||
| 1405 | + } | ||
| 1406 | + if(fage){ | ||
| 1407 | + String jsy=y.getJsy(); | ||
| 1408 | + String line=y.getXlbm(); | ||
| 1409 | + String clzbh=y.getNbbm(); | ||
| 1410 | + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>(); | ||
| 1411 | + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>(); | ||
| 1412 | + for (int j = 0; j < listReal.size(); j++) { | ||
| 1413 | + ScheduleRealInfo s=listReal.get(j); | ||
| 1414 | + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh) | ||
| 1415 | + &&s.getXlBm().equals(line)){ | ||
| 1416 | + if(y.getLp()==null){ | ||
| 879 | newList.add(s); | 1417 | newList.add(s); |
| 880 | Set<ChildTaskPlan> cts = s.getcTasks(); | 1418 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 881 | if(cts != null && cts.size() > 0){ | 1419 | if(cts != null && cts.size() > 0){ |
| @@ -885,38 +1423,50 @@ public class FormsServiceImpl implements FormsService { | @@ -885,38 +1423,50 @@ public class FormsServiceImpl implements FormsService { | ||
| 885 | newList_.add(s); | 1423 | newList_.add(s); |
| 886 | } | 1424 | } |
| 887 | } | 1425 | } |
| 1426 | + }else{ | ||
| 1427 | + if(y.getLp().equals(s.getLpName())){ | ||
| 1428 | + newList.add(s); | ||
| 1429 | + Set<ChildTaskPlan> cts = s.getcTasks(); | ||
| 1430 | + if(cts != null && cts.size() > 0){ | ||
| 1431 | + newList_.add(s); | ||
| 1432 | + }else{ | ||
| 1433 | + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){ | ||
| 1434 | + newList_.add(s); | ||
| 1435 | + } | ||
| 1436 | + } | ||
| 1437 | + } | ||
| 888 | } | 1438 | } |
| 889 | } | 1439 | } |
| 890 | } | 1440 | } |
| 1441 | + double jhgl=culateMileageService.culateJhgl(newList); | ||
| 1442 | + double jhjcc=culateMileageService.culateJhJccgl(newList); | ||
| 1443 | + double yygl=culateMileageService.culateSjgl(newList_); | ||
| 1444 | + double ljgl=culateMileageService.culateLjgl(newList_); | ||
| 1445 | + double ksgl=culateMileageService.culateKsgl(newList_); | ||
| 1446 | + double jcgl=culateMileageService.culateJccgl(newList_); | ||
| 1447 | + | ||
| 1448 | + double zyygl=Arith.add(yygl, ljgl); | ||
| 1449 | + double zksgl=Arith.add(ksgl, jcgl); | ||
| 1450 | + | ||
| 1451 | + Singledata sin=new Singledata(); | ||
| 1452 | + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl))); | ||
| 1453 | + | ||
| 1454 | + sin.setEmptMileage(String.valueOf(zksgl)); | ||
| 1455 | + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc))); | ||
| 1456 | + sin.setxL(y.getXlbm()); | ||
| 1457 | + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm())); | ||
| 1458 | + sin.setClzbh(clzbh); | ||
| 1459 | + sin.setJsy(jsy); | ||
| 1460 | + sin.setrQ(startDate); | ||
| 1461 | + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy)); | ||
| 1462 | + sin.setSgh(""); | ||
| 1463 | + sin.setsName(""); | ||
| 1464 | + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm)); | ||
| 1465 | + sin.setHyl(df.format(y.getHd())); | ||
| 1466 | + sin.setJzl(df.format(y.getCdl())); | ||
| 1467 | + sin.setUnyyyl(df.format(y.getSh())); | ||
| 1468 | + listD.add(sin); | ||
| 891 | } | 1469 | } |
| 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 | } | 1470 | } |
| 921 | 1471 | ||
| 922 | Collections.sort(listY,new SingledataByXlbm()); | 1472 | Collections.sort(listY,new SingledataByXlbm()); |
src/main/java/com/bsth/service/geo_data/GeoDataService.java
0 → 100644
| 1 | +package com.bsth.service.geo_data; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.geo_data.GeoStation; | ||
| 4 | + | ||
| 5 | +import java.util.Map; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by panzhao on 2017/12/7. | ||
| 9 | + */ | ||
| 10 | +public interface GeoDataService { | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + Map<String, Object> findGeoStations(String lineCode); | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + Map<String, Object> findGeoRoad(String lineCode); | ||
| 17 | + | ||
| 18 | + Map<String, Object> updateBufferInfo(GeoStation station); | ||
| 19 | + | ||
| 20 | + Map<String, Object> updateStationName(Map<String, Object> map); | ||
| 21 | +} |
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.geo_data.impl; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 4 | +import com.bsth.entity.geo_data.GeoRoad; | ||
| 5 | +import com.bsth.entity.geo_data.GeoStation; | ||
| 6 | +import com.bsth.service.geo_data.GeoDataService; | ||
| 7 | +import com.bsth.util.TransGPS; | ||
| 8 | +import com.google.common.base.Splitter; | ||
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 13 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 14 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | +import org.springframework.transaction.TransactionDefinition; | ||
| 17 | +import org.springframework.transaction.TransactionStatus; | ||
| 18 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
| 19 | + | ||
| 20 | +import java.util.ArrayList; | ||
| 21 | +import java.util.HashMap; | ||
| 22 | +import java.util.List; | ||
| 23 | +import java.util.Map; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * Created by panzhao on 2017/12/8. | ||
| 27 | + */ | ||
| 28 | +@Service | ||
| 29 | +public class GeoDataServiceImpl implements GeoDataService { | ||
| 30 | + | ||
| 31 | + @Autowired | ||
| 32 | + JdbcTemplate jdbcTemplate; | ||
| 33 | + | ||
| 34 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public Map<String, Object> findGeoStations(String lineCode) { | ||
| 38 | + | ||
| 39 | + Map<String, Object> map = new HashMap(); | ||
| 40 | + try { | ||
| 41 | + String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and destroy=0 and versions in (select DISTINCT versions from bsth_c_stationroute where line=" + lineCode + " and destroy=0)) t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod"; | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class)); | ||
| 45 | + | ||
| 46 | + for (GeoStation station : list) { | ||
| 47 | + if (station.getShapesType().equals("d")) | ||
| 48 | + station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3)); | ||
| 49 | + } | ||
| 50 | + map.put("status", ResponseCode.SUCCESS); | ||
| 51 | + map.put("list", list); | ||
| 52 | + } catch (Exception e) { | ||
| 53 | + logger.error("", e); | ||
| 54 | + map.put("status", ResponseCode.ERROR); | ||
| 55 | + map.put("msg", "服务器出现异常"); | ||
| 56 | + } | ||
| 57 | + return map; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public Map<String, Object> findGeoRoad(String lineCode) { | ||
| 62 | + Map<String, Object> map = new HashMap(); | ||
| 63 | + try { | ||
| 64 | + String sql = "select t1.*,t2.section_name,t2.croses_road,ST_AsText(t2.gsection_vector) as gsection_vector from (select id,sectionroute_code,directions,line_code,section_code,versions from bsth_c_ls_sectionroute where line=" + lineCode + " and destroy=0 and versions in (select DISTINCT versions from bsth_c_sectionroute where line=" + lineCode + " and destroy=0)) t1 LEFT JOIN bsth_c_section t2 on t1.section_code=t2.section_code"; | ||
| 65 | + | ||
| 66 | + | ||
| 67 | + List<GeoRoad> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoRoad.class)); | ||
| 68 | + | ||
| 69 | + for (GeoRoad road : list) { | ||
| 70 | + road.setBdCoords(multiWgsToBd(road.getGsectionVector(), 11, 2)); | ||
| 71 | + } | ||
| 72 | + map.put("status", ResponseCode.SUCCESS); | ||
| 73 | + map.put("list", list); | ||
| 74 | + } catch (Exception e) { | ||
| 75 | + logger.error("", e); | ||
| 76 | + map.put("status", ResponseCode.ERROR); | ||
| 77 | + map.put("msg", "服务器出现异常"); | ||
| 78 | + } | ||
| 79 | + return map; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 编辑缓冲区信息 | ||
| 84 | + * | ||
| 85 | + * @param station | ||
| 86 | + * @return | ||
| 87 | + */ | ||
| 88 | + @Override | ||
| 89 | + public Map<String, Object> updateBufferInfo(GeoStation station) { | ||
| 90 | + Map<String, Object> rs = new HashMap<>(); | ||
| 91 | + try { | ||
| 92 | + //坐标转换 | ||
| 93 | + TransGPS.Location loc = TransGPS.LocationMake(station.getgLonx(), station.getgLaty()); | ||
| 94 | + loc = TransGPS.bd_decrypt(loc); | ||
| 95 | + loc = TransGPS.transformFromGCJToWGS(loc); | ||
| 96 | + station.setgLaty(Float.parseFloat(String.valueOf(loc.getLat()))); | ||
| 97 | + station.setgLonx(Float.parseFloat(String.valueOf(loc.getLng()))); | ||
| 98 | + | ||
| 99 | + String sql; | ||
| 100 | + String shapesType = station.getShapesType(); | ||
| 101 | + int rsCount = -1; | ||
| 102 | + if (shapesType.equals("r")) { | ||
| 103 | + sql = "update bsth_c_station set g_lonx=?, g_laty=?, radius=?,shapes_type='r' where station_cod=?"; | ||
| 104 | + rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getRadius(), station.getStationCode()); | ||
| 105 | + } else if (shapesType.equals("d")) { | ||
| 106 | + //多边形坐标转换 | ||
| 107 | + String bdPolygon = "POLYGON((" + station.getgPolygonGrid() + "))"; | ||
| 108 | + String wgsPolygon = "POLYGON((" + bdPolygon2Wgs(station.getgPolygonGrid()) + "))"; | ||
| 109 | + sql = "update bsth_c_station set g_lonx=?, g_laty=?,shapes_type='d', radius=null,b_polygon_grid=ST_GeomFromText('" + bdPolygon + "'),g_polygon_grid=ST_GeomFromText('" + wgsPolygon + "') where station_cod=?"; | ||
| 110 | + | ||
| 111 | + rsCount = jdbcTemplate.update(sql, station.getgLonx(), station.getgLaty(), station.getStationCode()); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + //从数据库里重新查询对象 | ||
| 115 | + if (rsCount > 0) { | ||
| 116 | + rs.put("station", findOne(station.getId())); | ||
| 117 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + } catch (Exception e) { | ||
| 121 | + logger.error("", e); | ||
| 122 | + rs.put("status", ResponseCode.ERROR); | ||
| 123 | + rs.put("msg", "服务器出现异常"); | ||
| 124 | + } | ||
| 125 | + return rs; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * 修改站点路由和站点名称 | ||
| 130 | + * | ||
| 131 | + * @param map | ||
| 132 | + * @return | ||
| 133 | + */ | ||
| 134 | + @Override | ||
| 135 | + public Map<String, Object> updateStationName(Map<String, Object> map) { | ||
| 136 | + Map<String, Object> rs = new HashMap<>(); | ||
| 137 | + | ||
| 138 | + //编程式事务 | ||
| 139 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 140 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 141 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 142 | + TransactionStatus status = tran.getTransaction(def); | ||
| 143 | + try { | ||
| 144 | + | ||
| 145 | + int id = Integer.parseInt(map.get("id").toString()); | ||
| 146 | + String name = map.get("stationName").toString(); | ||
| 147 | + String code = map.get("stationCode").toString(); | ||
| 148 | + //String lineCode = map.get("lineCode").toString(); | ||
| 149 | + //String stationMark = map.get("stationMark").toString(); | ||
| 150 | + | ||
| 151 | + //更新历史站点路由 | ||
| 152 | + jdbcTemplate.update("update bsth_c_ls_stationroute set station_name=? where id=?", name, id); | ||
| 153 | + //更新站点 | ||
| 154 | + jdbcTemplate.update("update bsth_c_station set station_name=? where station_cod=?", name, code); | ||
| 155 | + | ||
| 156 | + tran.commit(status); | ||
| 157 | + | ||
| 158 | + rs.put("station", findOne(id)); | ||
| 159 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 160 | + } catch (Exception e) { | ||
| 161 | + tran.rollback(status); | ||
| 162 | + logger.error("", e); | ||
| 163 | + rs.put("status", ResponseCode.ERROR); | ||
| 164 | + rs.put("msg", "服务器出现异常"); | ||
| 165 | + } | ||
| 166 | + return rs; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * 根据路由ID 获取站点 | ||
| 172 | + * | ||
| 173 | + * @param id | ||
| 174 | + * @return | ||
| 175 | + */ | ||
| 176 | + private GeoStation findOne(int id) { | ||
| 177 | + String sql = "SELECT t1.*, t2.g_lonx,g_laty,ST_AsText (g_polygon_grid) AS g_polygon_grid,radius,shapes_type FROM (SELECT id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions FROM bsth_c_ls_stationroute WHERE id=" + id + " AND destroy = 0) t1 LEFT JOIN bsth_c_station t2 ON t1.station_code = t2.station_cod"; | ||
| 178 | + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class)); | ||
| 179 | + | ||
| 180 | + GeoStation s = list.get(0); | ||
| 181 | + if (s.getShapesType().equals("d")) | ||
| 182 | + s.setBdCoords(multiWgsToBd(s.getgPolygonGrid(), 9, 3)); | ||
| 183 | + | ||
| 184 | + return s; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + private String bdPolygon2Wgs(String bdPolygon) { | ||
| 188 | + StringBuilder wgsPolygon = new StringBuilder(); | ||
| 189 | + List<String> list = Splitter.on(",").splitToList(bdPolygon); | ||
| 190 | + String[] array; | ||
| 191 | + | ||
| 192 | + TransGPS.Location location; | ||
| 193 | + for (String p : list) { | ||
| 194 | + array = p.split(" "); | ||
| 195 | + location = TransGPS.transformFromGCJToWGS(TransGPS.bd_decrypt(TransGPS.LocationMake(Double.parseDouble(array[0]), Double.parseDouble(array[1])))); | ||
| 196 | + | ||
| 197 | + wgsPolygon.append(location.getLng() + " " + location.getLat() + ","); | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + if (wgsPolygon.length() > 0) { | ||
| 201 | + wgsPolygon.deleteCharAt(wgsPolygon.length() - 1); | ||
| 202 | + } | ||
| 203 | + return wgsPolygon.toString(); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + /** | ||
| 207 | + * wgs 坐标数组转 百度 | ||
| 208 | + * | ||
| 209 | + * @return | ||
| 210 | + */ | ||
| 211 | + private List<String> multiWgsToBd(String crdStr, int si, int ei) { | ||
| 212 | + List<String> bdList = new ArrayList<>(); | ||
| 213 | + | ||
| 214 | + List<String> gList = Splitter.on(",").splitToList(crdStr.substring(si, crdStr.length() - ei)); | ||
| 215 | + TransGPS.Location location; | ||
| 216 | + String[] cds; | ||
| 217 | + for (String gs : gList) { | ||
| 218 | + cds = gs.split(" "); | ||
| 219 | + location = TransGPS.bd_encrypt(TransGPS.transformFromWGSToGCJ(TransGPS.LocationMake(Double.parseDouble(cds[0]), Double.parseDouble(cds[1])))); | ||
| 220 | + | ||
| 221 | + bdList.add(location.getLng() + " " + location.getLat()); | ||
| 222 | + } | ||
| 223 | + return bdList; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | +} | ||
| 0 | \ No newline at end of file | 227 | \ No newline at end of file |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| @@ -250,5 +250,24 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | @@ -250,5 +250,24 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ | ||
| 250 | } | 250 | } |
| 251 | return resultMap; | 251 | return resultMap; |
| 252 | } | 252 | } |
| 253 | - | 253 | + |
| 254 | + /** | ||
| 255 | + * 获取当前线路版本号 | ||
| 256 | + */ | ||
| 257 | + @Override | ||
| 258 | + public Integer findCurrentVersion(int lineId) { | ||
| 259 | + return repository.findCurrentVersion(lineId); | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + @Override | ||
| 263 | + public Map<String, Object> issueVersion(int id) { | ||
| 264 | + Map<String, Object> resultMap = new HashMap<>(); | ||
| 265 | + | ||
| 266 | + int statu = repository.issueVersion(id); | ||
| 267 | + if (statu == 1) | ||
| 268 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 269 | + else | ||
| 270 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 271 | + return resultMap; | ||
| 272 | + } | ||
| 254 | } | 273 | } |
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
| @@ -131,8 +131,8 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ | @@ -131,8 +131,8 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ | ||
| 131 | @Transactional | 131 | @Transactional |
| 132 | @Override | 132 | @Override |
| 133 | public List<Map<String, Object>> getSectionRouteCache(Map<String, Object> map) { | 133 | public List<Map<String, Object>> getSectionRouteCache(Map<String, Object> map) { |
| 134 | - int lineId = map.get("line.id_eq").equals("") ? 0 : Integer.parseInt(map.get("line.id_eq").toString()); | ||
| 135 | - int directions = map.get("directions_eq").equals("") ? 0 : Integer.parseInt(map.get("directions_eq").toString()); | 134 | + int lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 135 | + int directions = map.get("dir").equals("") ? 0 : Integer.parseInt(map.get("dir").toString()); | ||
| 136 | List<Object[]> listObjArray = Cacherepository.getSectionRouteCache(lineId, directions); | 136 | List<Object[]> listObjArray = Cacherepository.getSectionRouteCache(lineId, directions); |
| 137 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | 137 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 138 | if(listObjArray.size()>0) { | 138 | if(listObjArray.size()>0) { |
| @@ -297,6 +297,23 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ | @@ -297,6 +297,23 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ | ||
| 297 | } | 297 | } |
| 298 | return list; | 298 | return list; |
| 299 | } | 299 | } |
| 300 | + | ||
| 301 | + @Override | ||
| 302 | + public List<Map<String, Object>> findCacheUpSectionRouteCode(Map<String, Object> map) { | ||
| 303 | + Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); | ||
| 304 | + Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); | ||
| 305 | + Integer stationRouteCode = map.get("sectionRouteCode").equals("") ? null : Integer.parseInt(map.get("sectionRouteCode").toString()); | ||
| 306 | + List<Object[]> reslutList = Cacherepository.findCacheUpSectionRouteCode(lineId, direction, stationRouteCode); | ||
| 307 | + List<Map<String, Object>> list = new ArrayList<Map<String,Object>>(); | ||
| 308 | + if(reslutList.get(0)!=null) { | ||
| 309 | + for(int i = 0 ; i <reslutList.size() ;i++){ | ||
| 310 | + Map<String, Object> tempM = new HashMap<String, Object>(); | ||
| 311 | + tempM.put("sectionrouteCode", reslutList.get(i)); | ||
| 312 | + list.add(tempM); | ||
| 313 | + } | ||
| 314 | + } | ||
| 315 | + return list; | ||
| 316 | + } | ||
| 300 | 317 | ||
| 301 | @Override | 318 | @Override |
| 302 | public Map<String, Object> quoteSection(Map<String, Object> map) { | 319 | public Map<String, Object> quoteSection(Map<String, Object> map) { |
src/main/java/com/bsth/service/impl/SectionServiceImpl.java
| @@ -7,9 +7,7 @@ import java.util.HashMap; | @@ -7,9 +7,7 @@ import java.util.HashMap; | ||
| 7 | import java.util.List; | 7 | import java.util.List; |
| 8 | import java.util.Map; | 8 | import java.util.Map; |
| 9 | 9 | ||
| 10 | -import org.mozilla.javascript.ObjArray; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | -import org.springframework.data.jpa.domain.Specification; | ||
| 13 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 14 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| 15 | 13 | ||
| @@ -17,7 +15,6 @@ import com.alibaba.fastjson.JSONArray; | @@ -17,7 +15,6 @@ import com.alibaba.fastjson.JSONArray; | ||
| 17 | import com.alibaba.fastjson.JSONObject; | 15 | import com.alibaba.fastjson.JSONObject; |
| 18 | import com.bsth.common.ResponseCode; | 16 | import com.bsth.common.ResponseCode; |
| 19 | import com.bsth.entity.Line; | 17 | import com.bsth.entity.Line; |
| 20 | -import com.bsth.entity.LineVersions; | ||
| 21 | import com.bsth.entity.LsSectionRoute; | 18 | import com.bsth.entity.LsSectionRoute; |
| 22 | import com.bsth.entity.LsStationRoute; | 19 | import com.bsth.entity.LsStationRoute; |
| 23 | import com.bsth.entity.Section; | 20 | import com.bsth.entity.Section; |
| @@ -40,7 +37,6 @@ import com.bsth.util.TransGPS; | @@ -40,7 +37,6 @@ import com.bsth.util.TransGPS; | ||
| 40 | import com.bsth.util.TransGPS.Location; | 37 | import com.bsth.util.TransGPS.Location; |
| 41 | import com.bsth.util.Geo.GeoUtils; | 38 | import com.bsth.util.Geo.GeoUtils; |
| 42 | import com.bsth.util.Geo.Point; | 39 | import com.bsth.util.Geo.Point; |
| 43 | -import com.google.gson.JsonObject; | ||
| 44 | 40 | ||
| 45 | /** | 41 | /** |
| 46 | * | 42 | * |
| @@ -171,7 +167,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem | @@ -171,7 +167,7 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem | ||
| 171 | String bsectionVectorS = null; | 167 | String bsectionVectorS = null; |
| 172 | if(!sectionsBpoints.equals("")) | 168 | if(!sectionsBpoints.equals("")) |
| 173 | bsectionVectorS = "LINESTRING(" + sectionsBpoints + ")"; | 169 | bsectionVectorS = "LINESTRING(" + sectionsBpoints + ")"; |
| 174 | - repository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, gsectionVector, bsectionVectorS, sectionType, csectionVector, roadCoding, sectionDistance, sectionTime, dbType, speedLimit, descriptions, versions, sectionId); | 170 | + repository.systemSave(sectionCode, sectionName, crosesRoad, endNode, startNode, middleNode, gsectionVector, bsectionVectorS, sectionType, csectionVector, roadCoding, sectionDistance, sectionTime, dbType, speedLimit, descriptions, 1, sectionId); |
| 175 | SectionRoute route = new SectionRoute(); | 171 | SectionRoute route = new SectionRoute(); |
| 176 | Line line = lineRepository.findOne(sectionRouteLine); | 172 | Line line = lineRepository.findOne(sectionRouteLine); |
| 177 | Section section = repository.findOne(sectionId); | 173 | Section section = repository.findOne(sectionId); |
| @@ -663,7 +659,8 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem | @@ -663,7 +659,8 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem | ||
| 663 | // 路段时长 | 659 | // 路段时长 |
| 664 | Double sectionTime = map.get("sectionTime").equals("") ? null : Double.valueOf(map.get("sectionTime").toString()); | 660 | Double sectionTime = map.get("sectionTime").equals("") ? null : Double.valueOf(map.get("sectionTime").toString()); |
| 665 | // 路段路由 | 661 | // 路段路由 |
| 666 | - Integer sectionrouteCode = map.get("sectionrouteCode").equals("") ? null : Integer.valueOf(map.get("sectionrouteCode").toString()); | 662 | +// Integer sectionrouteCode = map.get("sectionrouteCode").equals("") ? null : Integer.valueOf(map.get("sectionrouteCode").toString()); |
| 663 | + Integer sectionrouteCode = 100; | ||
| 667 | SectionRouteCache resultS = routeCacheRepository.findOne(sectionRouteId); | 664 | SectionRouteCache resultS = routeCacheRepository.findOne(sectionRouteId); |
| 668 | int old_code = resultS.getSectionrouteCode(); | 665 | int old_code = resultS.getSectionrouteCode(); |
| 669 | if(sectionrouteCode!=null) { | 666 | if(sectionrouteCode!=null) { |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| @@ -1172,7 +1172,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1172,7 +1172,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1172 | 1172 | ||
| 1173 | tempM.put("stationCode", objects.get(i)[19]); | 1173 | tempM.put("stationCode", objects.get(i)[19]); |
| 1174 | 1174 | ||
| 1175 | - tempM.put("stationName", objects.get(i)[20]); | 1175 | + tempM.put("stationRouteName", objects.get(i)[20]); |
| 1176 | 1176 | ||
| 1177 | tempM.put("stationRoadCoding", objects.get(i)[21]); | 1177 | tempM.put("stationRoadCoding", objects.get(i)[21]); |
| 1178 | 1178 |
src/main/java/com/bsth/service/impl/StationServiceImpl.java
| @@ -26,6 +26,7 @@ import com.bsth.entity.StationRoute; | @@ -26,6 +26,7 @@ import com.bsth.entity.StationRoute; | ||
| 26 | import com.bsth.entity.StationRouteCache; | 26 | import com.bsth.entity.StationRouteCache; |
| 27 | import com.bsth.repository.LineInformationRepository; | 27 | import com.bsth.repository.LineInformationRepository; |
| 28 | import com.bsth.repository.LineRepository; | 28 | import com.bsth.repository.LineRepository; |
| 29 | +import com.bsth.repository.LineVersionsRepository; | ||
| 29 | import com.bsth.repository.SectionRepository; | 30 | import com.bsth.repository.SectionRepository; |
| 30 | import com.bsth.repository.SectionRouteCacheRepository; | 31 | import com.bsth.repository.SectionRouteCacheRepository; |
| 31 | import com.bsth.repository.SectionRouteRepository; | 32 | import com.bsth.repository.SectionRouteRepository; |
| @@ -83,8 +84,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -83,8 +84,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 83 | @Autowired | 84 | @Autowired |
| 84 | private SectionRouteCacheRepository sectionRouteCacheRepository; | 85 | private SectionRouteCacheRepository sectionRouteCacheRepository; |
| 85 | 86 | ||
| 86 | - private GeoUtils geoUtils; | ||
| 87 | - | 87 | + @Autowired |
| 88 | + LineVersionsRepository lineVersionsRepository; | ||
| 89 | + | ||
| 88 | Logger logger = LoggerFactory.getLogger(this.getClass()); | 90 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 89 | 91 | ||
| 90 | /** | 92 | /** |
| @@ -293,20 +295,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -293,20 +295,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 293 | Integer stationId = Integer.parseInt(isHaveMap.get("id").toString()); | 295 | Integer stationId = Integer.parseInt(isHaveMap.get("id").toString()); |
| 294 | arg0 = repository.findOne(stationId); | 296 | arg0 = repository.findOne(stationId); |
| 295 | 297 | ||
| 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) {// 环线终点和起点引用同一个站 | 298 | + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 |
| 299 | + arg0 = loopStartStation; | ||
| 300 | + } else { | ||
| 310 | List<Station> list = new ArrayList<>(); | 301 | List<Station> list = new ArrayList<>(); |
| 311 | list.add(arg0); | 302 | list.add(arg0); |
| 312 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); | 303 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); |
| @@ -318,12 +309,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -318,12 +309,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 318 | station.setCreateDate(null); | 309 | station.setCreateDate(null); |
| 319 | station.setUpdateDate(null); | 310 | station.setUpdateDate(null); |
| 320 | repository.save(station); | 311 | 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 | - } | 312 | + arg0 = station; |
| 313 | + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 | ||
| 314 | + loopStartStation = arg0; | ||
| 315 | + } | ||
| 316 | + } | ||
| 327 | }else { | 317 | }else { |
| 328 | // 站点编码 | 318 | // 站点编码 |
| 329 | long stationCode = GetUIDAndCode.getStationId(); | 319 | long stationCode = GetUIDAndCode.getStationId(); |
| @@ -417,8 +407,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -417,8 +407,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 417 | // 中途站 | 407 | // 中途站 |
| 418 | route.setStationMark("Z"); | 408 | route.setStationMark("Z"); |
| 419 | } | 409 | } |
| 420 | - // 版本号 | ||
| 421 | - route.setVersions(versions); | 410 | + // 版本号(获取线路当前版本) |
| 411 | + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId()); | ||
| 412 | + route.setVersions(version); | ||
| 422 | // 站点ID | 413 | // 站点ID |
| 423 | route.setStation(arg0); | 414 | route.setStation(arg0); |
| 424 | // 方向 | 415 | // 方向 |
| @@ -782,6 +773,153 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -782,6 +773,153 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 782 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); | 773 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 783 | // 说明 | 774 | // 说明 |
| 784 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); | 775 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 776 | + // 站点编码 | ||
| 777 | + stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); | ||
| 778 | + // 站点ID | ||
| 779 | + stationId = Integer.valueOf(stationCod); | ||
| 780 | + // 圆半径 | ||
| 781 | + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); | ||
| 782 | + // 图形类型 | ||
| 783 | + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); | ||
| 784 | + // 创建人 | ||
| 785 | + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); | ||
| 786 | + // 修改人 | ||
| 787 | + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); | ||
| 788 | + // 城建坐标经度 | ||
| 789 | + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString()); | ||
| 790 | + // 城建坐标纬度 | ||
| 791 | + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString()); | ||
| 792 | + // 道路编码 | ||
| 793 | + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); | ||
| 794 | + // 原坐标类型 | ||
| 795 | + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); | ||
| 796 | + // WGS经纬度 | ||
| 797 | + Float gLonx = null; | ||
| 798 | + // WGS纬度 | ||
| 799 | + Float gLaty = null; | ||
| 800 | + if(bJwpointsArray.length>0) { | ||
| 801 | + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); | ||
| 802 | + gLonx = (float)resultPoint.getLng(); | ||
| 803 | + gLaty = (float)resultPoint.getLat(); | ||
| 804 | + } | ||
| 805 | + // 多边形原坐标点集合 | ||
| 806 | + String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString(); | ||
| 807 | + // 多边形WGS坐标点集合 | ||
| 808 | + String gPloygonGrid =""; | ||
| 809 | + if(!bPloygonGrid.equals("")) { | ||
| 810 | + String bPloygonGridArray[] = bPloygonGrid.split(","); | ||
| 811 | + int bLen_ = bPloygonGridArray.length; | ||
| 812 | + for(int b = 0 ;b<bLen_;b++) { | ||
| 813 | + String tempArray[]= bPloygonGridArray[b].split(" "); | ||
| 814 | + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); | ||
| 815 | + if(b==0) { | ||
| 816 | + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | ||
| 817 | + }else { | ||
| 818 | + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | ||
| 819 | + } | ||
| 820 | + } | ||
| 821 | + } | ||
| 822 | + if(bPloygonGrid.equals("")) | ||
| 823 | + bPloygonGrid = null; | ||
| 824 | + else | ||
| 825 | + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | ||
| 826 | + if(gPloygonGrid.equals("")) | ||
| 827 | + gPloygonGrid = null; | ||
| 828 | + else | ||
| 829 | + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | ||
| 830 | + // 保存站点 | ||
| 831 | + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints, | ||
| 832 | + gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius, | ||
| 833 | + shapesType, versions, descriptions, createBy, updateBy,stationId); | ||
| 834 | + | ||
| 835 | + Station station = repository.findOne(stationId); | ||
| 836 | + StationRoute arg0 = new StationRoute(); | ||
| 837 | + // 距离 | ||
| 838 | + Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString()); | ||
| 839 | + // 时间 | ||
| 840 | + Double toTime = map.get("toTime").equals("") ? 0.0d : Double.parseDouble(map.get("toTime").toString()); | ||
| 841 | + // 站点路由名称 | ||
| 842 | + String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); | ||
| 843 | + // 线路ID | ||
| 844 | + int line = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); | ||
| 845 | + // 线路信息 | ||
| 846 | + Line resultLine = lineRepository.findOne(line); | ||
| 847 | + // 站点路由序号 | ||
| 848 | + String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? "" : map.get("stationRouteCode").toString(); | ||
| 849 | + // 站点类型 | ||
| 850 | + String stationMark = map.get("stationMark").equals("") ? "" : map.get("stationMark").toString(); | ||
| 851 | + Integer stationRouteCode = null; | ||
| 852 | + if(stationRouteCodeStr!="") { | ||
| 853 | + String stationRouteCodeArray [] = stationRouteCodeStr.split("_"); | ||
| 854 | + stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString())+1; | ||
| 855 | + }else { | ||
| 856 | + stationRouteCode = 100; | ||
| 857 | + } | ||
| 858 | + // 线路 | ||
| 859 | + arg0.setLine(resultLine); | ||
| 860 | + arg0.setLineCode(resultLine.getLineCode()); | ||
| 861 | + // 站点 | ||
| 862 | + arg0.setStation(station); | ||
| 863 | + // 站点路由名称 | ||
| 864 | + arg0.setStationName(stationName); | ||
| 865 | + // 站点路由编码 | ||
| 866 | + arg0.setStationCode(station.getStationCod()); | ||
| 867 | + // 站点路由序号 | ||
| 868 | + arg0.setStationRouteCode(stationRouteCode); | ||
| 869 | + // 站点路由类型 | ||
| 870 | + arg0.setStationMark(stationMark); | ||
| 871 | + // 站点路由站点方向 | ||
| 872 | + arg0.setDirections(directions); | ||
| 873 | + // 站点路由到站距离 | ||
| 874 | + arg0.setDistances(distances); | ||
| 875 | + // 站点路由到站时间 | ||
| 876 | + arg0.setToTime(toTime); | ||
| 877 | + // 站点版本号 | ||
| 878 | + arg0.setVersions(versions); | ||
| 879 | + // 是否撤销 | ||
| 880 | + arg0.setDestroy(destroy); | ||
| 881 | + // 站点路由说明 | ||
| 882 | + arg0.setDescriptions(descriptions); | ||
| 883 | + routeRepository.stationUpdStationRouteCode(line, directions, stationRouteCode); | ||
| 884 | + routeRepository.save(arg0); | ||
| 885 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 886 | + } catch (Exception e) { | ||
| 887 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 888 | + logger.error("save erro.", e); | ||
| 889 | + } | ||
| 890 | + return resultMap; | ||
| 891 | + } | ||
| 892 | + | ||
| 893 | + /** | ||
| 894 | + * @Description :TODO(新增缓存站点保存) | ||
| 895 | + */ | ||
| 896 | + @Transactional | ||
| 897 | + @Override | ||
| 898 | + public Map<String, Object> stationCacheSave(Map<String, Object> map) { | ||
| 899 | + Map<String, Object> resultMap = new HashMap<String, Object>(); | ||
| 900 | + try { | ||
| 901 | + // 站点编码 | ||
| 902 | + String stationCod = ""; | ||
| 903 | + // 站点ID | ||
| 904 | + Integer stationId = null; | ||
| 905 | + // 站点名称 | ||
| 906 | + String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString(); | ||
| 907 | + // 方向 | ||
| 908 | + Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString()); | ||
| 909 | + // 原坐标点 | ||
| 910 | + String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString(); | ||
| 911 | + String bJwpointsArray[] = null; | ||
| 912 | + if(bJwpoints!=null) { | ||
| 913 | + bJwpointsArray = bJwpoints.split(" "); | ||
| 914 | + } | ||
| 915 | + List<Object[]> stationNameList = repository.findStationName(directions,zdmc); | ||
| 916 | + Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0],bJwpointsArray[1],stationNameList); | ||
| 917 | + // 是否撤销 | ||
| 918 | + Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); | ||
| 919 | + // 版本 | ||
| 920 | + Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); | ||
| 921 | + // 说明 | ||
| 922 | + String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); | ||
| 785 | if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) { | 923 | if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) { |
| 786 | stationId = Integer.parseInt(isHaveMap.get("id").toString()); | 924 | stationId = Integer.parseInt(isHaveMap.get("id").toString()); |
| 787 | }else { | 925 | }else { |
| @@ -845,7 +983,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -845,7 +983,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 845 | shapesType, versions, descriptions, createBy, updateBy,stationId); | 983 | shapesType, versions, descriptions, createBy, updateBy,stationId); |
| 846 | } | 984 | } |
| 847 | Station station = repository.findOne(stationId); | 985 | Station station = repository.findOne(stationId); |
| 848 | - StationRoute arg0 = new StationRoute(); | 986 | + StationRouteCache arg0 = new StationRouteCache(); |
| 849 | // 距离 | 987 | // 距离 |
| 850 | Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString()); | 988 | Double distances = map.get("distances").equals("") ? 0.0d : Double.parseDouble(map.get("distances").toString()); |
| 851 | // 时间 | 989 | // 时间 |
| @@ -892,8 +1030,8 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -892,8 +1030,8 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 892 | arg0.setDestroy(destroy); | 1030 | arg0.setDestroy(destroy); |
| 893 | // 站点路由说明 | 1031 | // 站点路由说明 |
| 894 | arg0.setDescriptions(descriptions); | 1032 | arg0.setDescriptions(descriptions); |
| 895 | - routeRepository.stationUpdStationRouteCode(line, directions, stationRouteCode); | ||
| 896 | - routeRepository.save(arg0); | 1033 | + routeCacheRepository.stationUpdStationRouteCode(line, directions, stationRouteCode); |
| 1034 | + routeCacheRepository.save(arg0); | ||
| 897 | resultMap.put("status", ResponseCode.SUCCESS); | 1035 | resultMap.put("status", ResponseCode.SUCCESS); |
| 898 | } catch (Exception e) { | 1036 | } catch (Exception e) { |
| 899 | resultMap.put("status", ResponseCode.ERROR); | 1037 | resultMap.put("status", ResponseCode.ERROR); |
| @@ -926,7 +1064,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -926,7 +1064,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 926 | String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); | 1064 | String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); |
| 927 | String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString(); | 1065 | String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString(); |
| 928 | // 站点名称 | 1066 | // 站点名称 |
| 929 | - String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); | 1067 | + String stationRouteName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); |
| 930 | // 所在道路编码 | 1068 | // 所在道路编码 |
| 931 | String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); | 1069 | String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); |
| 932 | // 经纬坐标类型 | 1070 | // 经纬坐标类型 |
| @@ -1013,7 +1151,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1013,7 +1151,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1013 | Station station = repository.findOne(stationId); | 1151 | Station station = repository.findOne(stationId); |
| 1014 | Line line = lineRepository.findOne(LineId); | 1152 | Line line = lineRepository.findOne(LineId); |
| 1015 | StationRoute stationRoute = new StationRoute(); | 1153 | StationRoute stationRoute = new StationRoute(); |
| 1016 | - stationRoute.setStationName(stationName); | 1154 | + stationRoute.setStationName(stationRouteName); |
| 1017 | stationRoute.setId(stationRouteId); | 1155 | stationRoute.setId(stationRouteId); |
| 1018 | stationRoute.setStationRouteCode(stationRouteCode); | 1156 | stationRoute.setStationRouteCode(stationRouteCode); |
| 1019 | stationRoute.setStation(station); | 1157 | stationRoute.setStation(station); |
| @@ -1200,15 +1338,15 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1200,15 +1338,15 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1200 | sectionRoute.setLine(resultLine); | 1338 | sectionRoute.setLine(resultLine); |
| 1201 | // 路段编码 | 1339 | // 路段编码 |
| 1202 | sectionRoute.setSectionCode(sectionCode); | 1340 | sectionRoute.setSectionCode(sectionCode); |
| 1203 | - // 版本 | ||
| 1204 | - sectionRoute.setVersions(versions); | 1341 | + // 版本号(获取线路当前版本) |
| 1342 | + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId()); | ||
| 1343 | + sectionRoute.setVersions(version); | ||
| 1205 | sectionRoute.setDestroy(destroy); | 1344 | sectionRoute.setDestroy(destroy); |
| 1206 | // 方向 | 1345 | // 方向 |
| 1207 | sectionRoute.setDirections(directions); | 1346 | sectionRoute.setDirections(directions); |
| 1208 | // 保存路段 | 1347 | // 保存路段 |
| 1209 | sectionRouteRepository.save(sectionRoute); | 1348 | sectionRouteRepository.save(sectionRoute); |
| 1210 | } | 1349 | } |
| 1211 | - | ||
| 1212 | } | 1350 | } |
| 1213 | 1351 | ||
| 1214 | /** | 1352 | /** |
| @@ -1229,10 +1367,10 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1229,10 +1367,10 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1229 | String libraryPointstr = s.getbJwpoints(); | 1367 | String libraryPointstr = s.getbJwpoints(); |
| 1230 | String points[] = libraryPointstr.toString().split(" "); | 1368 | String points[] = libraryPointstr.toString().split(" "); |
| 1231 | Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1])); | 1369 | Point center = new Point(Double.parseDouble(points[0]), Double.parseDouble(points[1])); |
| 1232 | - // 在100m内认为是同一个站点 | ||
| 1233 | - Circle circle = new Circle(center, 100); | 1370 | + // 在60m内认为是同一个站点 |
| 1371 | + Circle circle = new Circle(center, 60); | ||
| 1234 | // 匹配到了用数据库中的点替换 | 1372 | // 匹配到了用数据库中的点替换 |
| 1235 | - if (geoUtils.isPointInCircle(point, circle)) { | 1373 | + if (GeoUtils.isPointInCircle(point, circle)) { |
| 1236 | map.put("name", s.getStationName().toString()); | 1374 | map.put("name", s.getStationName().toString()); |
| 1237 | map.put("potion_lng", points[0]); | 1375 | map.put("potion_lng", points[0]); |
| 1238 | map.put("potion_lat", points[1]); | 1376 | map.put("potion_lat", points[1]); |
| @@ -1372,20 +1510,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1372,20 +1510,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1372 | Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString()); | 1510 | Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString()); |
| 1373 | arg0 = repository.findOne(stationId); | 1511 | arg0 = repository.findOne(stationId); |
| 1374 | 1512 | ||
| 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) {// 环线终点和起点引用同一个站 | 1513 | + if (i==stationsArray.size()-1 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 |
| 1514 | + arg0 = loopStartStation; | ||
| 1515 | + } else { | ||
| 1389 | List<Station> list = new ArrayList<>(); | 1516 | List<Station> list = new ArrayList<>(); |
| 1390 | list.add(arg0); | 1517 | list.add(arg0); |
| 1391 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); | 1518 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); |
| @@ -1397,12 +1524,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1397,12 +1524,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1397 | station.setCreateDate(null); | 1524 | station.setCreateDate(null); |
| 1398 | station.setUpdateDate(null); | 1525 | station.setUpdateDate(null); |
| 1399 | repository.save(station); | 1526 | 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 | - } | 1527 | + arg0 = station; |
| 1528 | + if (i==0 && resultLine.getLinePlayType() == 1) {// 环线终点和起点引用同一个站 | ||
| 1529 | + loopStartStation = arg0; | ||
| 1530 | + } | ||
| 1531 | + } | ||
| 1406 | }else { | 1532 | }else { |
| 1407 | // 站点编码 | 1533 | // 站点编码 |
| 1408 | long stationCode = GetUIDAndCode.getStationId(); | 1534 | long stationCode = GetUIDAndCode.getStationId(); |
| @@ -1735,4 +1861,36 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | @@ -1735,4 +1861,36 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem | ||
| 1735 | } | 1861 | } |
| 1736 | return resultMap; | 1862 | return resultMap; |
| 1737 | } | 1863 | } |
| 1864 | + | ||
| 1865 | + /** | ||
| 1866 | + * @Description :TODO(引用当前版本) | ||
| 1867 | + */ | ||
| 1868 | + @Override | ||
| 1869 | + @Transactional | ||
| 1870 | + public Map<String, Object> referenceCurrentVersion(Map<String, Object> map) { | ||
| 1871 | + Map<String, Object> resultMap = new HashMap<String, Object>(); | ||
| 1872 | + try { | ||
| 1873 | + Integer lineId = Integer.parseInt(map.get("lineId").toString()); | ||
| 1874 | + Integer dir = Integer.parseInt(map.get("directions").toString()); | ||
| 1875 | + List<StationRoute> stationRoutes = routeRepository.findByLine(lineId, dir); | ||
| 1876 | + List<SectionRoute> sectionRoutes = sectionRouteRepository.findByLine(lineId, dir); | ||
| 1877 | + // 删除缓存路由数据 | ||
| 1878 | + routeCacheRepository.stationRouteCacheDel(lineId, dir); | ||
| 1879 | + sectionRouteCacheRepository.sectionRouteCacheDel(lineId, dir); | ||
| 1880 | + // 当前版本路由保存到缓存路由 | ||
| 1881 | + List<StationRouteCache> stationRouteCaches = JSONArray.parseArray(JSON.toJSONString(stationRoutes), StationRouteCache.class); | ||
| 1882 | + List<SectionRouteCache> sectionRouteCaches = JSONArray.parseArray(JSON.toJSONString(sectionRoutes), SectionRouteCache.class); | ||
| 1883 | + for(StationRouteCache sr:stationRouteCaches) { | ||
| 1884 | + routeCacheRepository.save(sr); | ||
| 1885 | + } | ||
| 1886 | + for(SectionRouteCache sr:sectionRouteCaches) { | ||
| 1887 | + sectionRouteCacheRepository.save(sr); | ||
| 1888 | + } | ||
| 1889 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 1890 | + } catch (Exception e) { | ||
| 1891 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 1892 | + logger.error("save erro.", e); | ||
| 1893 | + } | ||
| 1894 | + return resultMap; | ||
| 1895 | + } | ||
| 1738 | } | 1896 | } |
| 1739 | \ No newline at end of file | 1897 | \ No newline at end of file |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| @@ -200,13 +200,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -200,13 +200,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 200 | 200 | ||
| 201 | // 先查上行 | 201 | // 先查上行 |
| 202 | upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); | 202 | upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); |
| 203 | + Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | ||
| 203 | int startId = 1; | 204 | int startId = 1; |
| 204 | - startId = packagStationXml(upStationsList, sBuffer, startId); | 205 | + startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); |
| 205 | // 环线不查下行 | 206 | // 环线不查下行 |
| 206 | if(line.getLinePlayType() != 1){ | 207 | if(line.getLinePlayType() != 1){ |
| 207 | // 再查下行 | 208 | // 再查下行 |
| 208 | downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); | 209 | downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); |
| 209 | - packagStationXml(downStationsList, sBuffer, startId); | 210 | + packagStationXml(downStationsList, sBuffer, startId,stationNumMap); |
| 210 | } | 211 | } |
| 211 | sBuffer.append("</StationList>"); | 212 | sBuffer.append("</StationList>"); |
| 212 | 213 | ||
| @@ -223,6 +224,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -223,6 +224,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 223 | sBuffer.append("</LinePointList>"); | 224 | sBuffer.append("</LinePointList>"); |
| 224 | sBuffer.append("</XL>"); | 225 | sBuffer.append("</XL>"); |
| 225 | sBuffer.append("</XLs>"); | 226 | sBuffer.append("</XLs>"); |
| 227 | + // 临时添加,后面删除 | ||
| 228 | + if(sBuffer.indexOf("<ZDXH>0</ZDXH>") != -1){ | ||
| 229 | + return "0"; | ||
| 230 | + } | ||
| 226 | // 调用上传方法 | 231 | // 调用上传方法 |
| 227 | if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,sBuffer.toString()).isSuccess()){ | 232 | if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,sBuffer.toString()).isSuccess()){ |
| 228 | result = "success"; | 233 | result = "success"; |
| @@ -240,6 +245,28 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -240,6 +245,28 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 240 | } | 245 | } |
| 241 | 246 | ||
| 242 | /** | 247 | /** |
| 248 | + * 加载运管处的站点及序号 | ||
| 249 | + * 上行从1开始,下行顺序续编 | ||
| 250 | + */ | ||
| 251 | + private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | ||
| 252 | + Map<String, Integer> resultMap = new HashMap<>(); | ||
| 253 | + List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | ||
| 254 | + if(ygcLines != null && ygcLines.size() > 0){ | ||
| 255 | + int size = ygcLines.size(); | ||
| 256 | + Map<String, String> tempMap ; | ||
| 257 | + int num = 1; | ||
| 258 | + String key; | ||
| 259 | + for (int i = 0; i < size; i ++){ | ||
| 260 | + tempMap = ygcLines.get(i); | ||
| 261 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | ||
| 262 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | ||
| 263 | + resultMap.put(key,num++); | ||
| 264 | + } | ||
| 265 | + } | ||
| 266 | + return resultMap; | ||
| 267 | + } | ||
| 268 | + | ||
| 269 | + /** | ||
| 243 | * 上传线路信息(按in_use上传) | 270 | * 上传线路信息(按in_use上传) |
| 244 | */ | 271 | */ |
| 245 | @Override | 272 | @Override |
| @@ -431,7 +458,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -431,7 +458,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 431 | // 起点站的参数 | 458 | // 起点站的参数 |
| 432 | otherMap.put("stationMark","B"); | 459 | otherMap.put("stationMark","B"); |
| 433 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | 460 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 434 | - sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) + "</FCZDXH>"); | 461 | + sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) + "</FCZDXH>"); |
| 435 | sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); | 462 | sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); |
| 436 | sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); | 463 | sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); |
| 437 | sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); | 464 | sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); |
| @@ -441,7 +468,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -441,7 +468,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 441 | // 终点站的参数 | 468 | // 终点站的参数 |
| 442 | otherMap.put("stationMark","E"); | 469 | otherMap.put("stationMark","E"); |
| 443 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | 470 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 444 | - sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) +"</DDZDXH>"); | 471 | + sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) +"</DDZDXH>"); |
| 445 | sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); | 472 | sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); |
| 446 | sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); | 473 | sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); |
| 447 | sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); | 474 | sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); |
| @@ -768,13 +795,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -768,13 +795,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 768 | // 起点站的参数 | 795 | // 起点站的参数 |
| 769 | otherMap.put("stationMark","B"); | 796 | otherMap.put("stationMark","B"); |
| 770 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | 797 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); |
| 771 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | 798 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); |
| 772 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | 799 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); |
| 773 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | 800 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 774 | // 起点站的参数 | 801 | // 起点站的参数 |
| 775 | otherMap.put("stationMark","E"); | 802 | otherMap.put("stationMark","E"); |
| 776 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | 803 | paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); |
| 777 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | 804 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); |
| 778 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | 805 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 779 | .append("</JHDDSJ>"); | 806 | .append("</JHDDSJ>"); |
| 780 | sBuffer.append("</BC>"); | 807 | sBuffer.append("</BC>"); |
| @@ -883,14 +910,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -883,14 +910,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 883 | // 起点站的参数 | 910 | // 起点站的参数 |
| 884 | otherMap.put("stationMark","B"); | 911 | otherMap.put("stationMark","B"); |
| 885 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 912 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 886 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</ZDXH>"); | 913 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); |
| 887 | sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | 914 | sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); |
| 888 | sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() | 915 | sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() |
| 889 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); | 916 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 890 | // 起点站的参数 | 917 | // 起点站的参数 |
| 891 | otherMap.put("stationMark","E"); | 918 | otherMap.put("stationMark","E"); |
| 892 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | 919 | paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); |
| 893 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap)).append("</DDXH>"); | 920 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); |
| 894 | sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | 921 | sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); |
| 895 | sBuffer.append("</BC>"); | 922 | sBuffer.append("</BC>"); |
| 896 | } | 923 | } |
| @@ -1214,7 +1241,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1214,7 +1241,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1214 | * | 1241 | * |
| 1215 | * @return 站点序号累加后的ID | 1242 | * @return 站点序号累加后的ID |
| 1216 | */ | 1243 | */ |
| 1217 | - private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId){ | 1244 | + private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ |
| 1218 | int size = stationsList.size(); | 1245 | int size = stationsList.size(); |
| 1219 | StationRoute srRoute; | 1246 | StationRoute srRoute; |
| 1220 | HashMap<String,String> paraMap; | 1247 | HashMap<String,String> paraMap; |
| @@ -1231,7 +1258,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1231,7 +1258,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1231 | } | 1258 | } |
| 1232 | paraMap = packageYgcStationNumParam(srRoute,null); | 1259 | paraMap = packageYgcStationNumParam(srRoute,null); |
| 1233 | sBuffer.append("<Station>"); | 1260 | sBuffer.append("<Station>"); |
| 1234 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap)).append("</ZDXH>"); | 1261 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); |
| 1235 | sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); | 1262 | sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); |
| 1236 | sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); | 1263 | sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); |
| 1237 | sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); | 1264 | sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); |
| @@ -1287,7 +1314,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1287,7 +1314,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1287 | * @param map | 1314 | * @param map |
| 1288 | * @return 运管处站点序号 | 1315 | * @return 运管处站点序号 |
| 1289 | */ | 1316 | */ |
| 1290 | - private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map){ | 1317 | + private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ |
| 1291 | // 线路编码 | 1318 | // 线路编码 |
| 1292 | String lineCode = map.get("lineCode"); | 1319 | String lineCode = map.get("lineCode"); |
| 1293 | // 线路走向 0:上行 1:下行 | 1320 | // 线路走向 0:上行 1:下行 |
| @@ -1305,9 +1332,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -1305,9 +1332,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 1305 | }else if(stationMark.equals("Z")){ | 1332 | }else if(stationMark.equals("Z")){ |
| 1306 | marks= new String[]{"Z"}; | 1333 | marks= new String[]{"Z"}; |
| 1307 | } | 1334 | } |
| 1335 | + // 默认从缓存BasicData.stationName2YgcNumber | ||
| 1336 | + Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | ||
| 1337 | + // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | ||
| 1338 | + if(stationNumMap != null){ | ||
| 1339 | + tempMap = stationNumMap; | ||
| 1340 | + } | ||
| 1308 | Integer number = null; | 1341 | Integer number = null; |
| 1309 | for (int i = 0 ;i < marks.length ; i ++){ | 1342 | for (int i = 0 ;i < marks.length ; i ++){ |
| 1310 | - number = BasicData.stationName2YgcNumber.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | 1343 | + number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); |
| 1311 | if(number != null){ | 1344 | if(number != null){ |
| 1312 | break; | 1345 | break; |
| 1313 | } | 1346 | } |
src/main/java/com/bsth/service/oil/DlbService.java
| @@ -29,5 +29,8 @@ public interface DlbService extends BaseService<Dlb, Integer>{ | @@ -29,5 +29,8 @@ public interface DlbService extends BaseService<Dlb, Integer>{ | ||
| 29 | 29 | ||
| 30 | Map<String, List<Dlb>> updeteHistory(List<Map<String, Object>> list,String date, | 30 | Map<String, List<Dlb>> updeteHistory(List<Map<String, Object>> list,String date, |
| 31 | String gsdm,String fgsdm,String line) ; | 31 | String gsdm,String fgsdm,String line) ; |
| 32 | + | ||
| 33 | + Map<String, Object> update(Map<String, Object> map); | ||
| 34 | + | ||
| 32 | 35 | ||
| 33 | } | 36 | } |
src/main/java/com/bsth/service/oil/YlbService.java
| @@ -19,13 +19,16 @@ public interface YlbService extends BaseService<Ylb, Integer>{ | @@ -19,13 +19,16 @@ 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 | ||
| 26 | Map<String, Object> deleteIds(Map<String, Object> map) throws Exception; | 26 | Map<String, Object> deleteIds(Map<String, Object> map) throws Exception; |
| 27 | 27 | ||
| 28 | Map<String, Object> updateHistory(Map<String, Object> map) throws Exception; | 28 | Map<String, Object> updateHistory(Map<String, Object> map) throws Exception; |
| 29 | + | ||
| 30 | + Map<String, Object> update(Map<String, Object> map); | ||
| 31 | + | ||
| 29 | 32 | ||
| 30 | 33 | ||
| 31 | } | 34 | } |
src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java
| @@ -39,16 +39,19 @@ import com.bsth.entity.oil.Cdl; | @@ -39,16 +39,19 @@ import com.bsth.entity.oil.Cdl; | ||
| 39 | import com.bsth.entity.oil.Cyl; | 39 | import com.bsth.entity.oil.Cyl; |
| 40 | import com.bsth.entity.oil.Dlb; | 40 | import com.bsth.entity.oil.Dlb; |
| 41 | import com.bsth.entity.oil.Jdl; | 41 | import com.bsth.entity.oil.Jdl; |
| 42 | -import com.bsth.entity.oil.Ylb; | 42 | +import com.bsth.entity.oil.Nylog; |
| 43 | import com.bsth.entity.oil.Ylxxb; | 43 | import com.bsth.entity.oil.Ylxxb; |
| 44 | import com.bsth.entity.search.CustomerSpecs; | 44 | import com.bsth.entity.search.CustomerSpecs; |
| 45 | +import com.bsth.entity.sys.SysUser; | ||
| 45 | import com.bsth.repository.CarsRepository; | 46 | import com.bsth.repository.CarsRepository; |
| 46 | import com.bsth.repository.oil.CdlRepository; | 47 | import com.bsth.repository.oil.CdlRepository; |
| 47 | import com.bsth.repository.oil.CylRepository; | 48 | import com.bsth.repository.oil.CylRepository; |
| 48 | import com.bsth.repository.oil.DlbRepository; | 49 | import com.bsth.repository.oil.DlbRepository; |
| 49 | import com.bsth.repository.oil.JdlRepository; | 50 | import com.bsth.repository.oil.JdlRepository; |
| 51 | +import com.bsth.repository.oil.NylogRepository; | ||
| 50 | import com.bsth.repository.oil.YlbRepository; | 52 | import com.bsth.repository.oil.YlbRepository; |
| 51 | import com.bsth.repository.oil.YlxxbRepository; | 53 | import com.bsth.repository.oil.YlxxbRepository; |
| 54 | +import com.bsth.security.util.SecurityUtils; | ||
| 52 | import com.bsth.service.impl.BaseServiceImpl; | 55 | import com.bsth.service.impl.BaseServiceImpl; |
| 53 | import com.bsth.service.oil.DlbService; | 56 | import com.bsth.service.oil.DlbService; |
| 54 | import com.bsth.service.realcontrol.ScheduleRealInfoService; | 57 | import com.bsth.service.realcontrol.ScheduleRealInfoService; |
| @@ -59,7 +62,8 @@ import com.bsth.util.BatchSaveUtils; | @@ -59,7 +62,8 @@ import com.bsth.util.BatchSaveUtils; | ||
| 59 | public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{ | 62 | public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{ |
| 60 | @Autowired | 63 | @Autowired |
| 61 | DlbRepository repository; | 64 | DlbRepository repository; |
| 62 | - | 65 | + @Autowired |
| 66 | + NylogRepository nylogRepository; | ||
| 63 | @Autowired | 67 | @Autowired |
| 64 | YlxxbRepository ylxxbRepository; | 68 | YlxxbRepository ylxxbRepository; |
| 65 | 69 | ||
| @@ -96,6 +100,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -96,6 +100,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 96 | calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 | 100 | calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 |
| 97 | dBefore = calendar.getTime(); //得到前一天的时间 | 101 | dBefore = calendar.getTime(); //得到前一天的时间 |
| 98 | String rq=sdf.format(dBefore); | 102 | String rq=sdf.format(dBefore); |
| 103 | +// String rq="2017-11-02"; | ||
| 99 | String line=""; | 104 | String line=""; |
| 100 | //保留两位小数 | 105 | //保留两位小数 |
| 101 | DecimalFormat df = new DecimalFormat("#.00"); | 106 | DecimalFormat df = new DecimalFormat("#.00"); |
| @@ -108,7 +113,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -108,7 +113,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 108 | //当天加电信息表 | 113 | //当天加电信息表 |
| 109 | List<Jdl> jdlList=jdlRepository.JdlList(rq); | 114 | List<Jdl> jdlList=jdlRepository.JdlList(rq); |
| 110 | //前一天所有车辆最后进场班次信息 | 115 | //前一天所有车辆最后进场班次信息 |
| 111 | - List<Dlb> dlListBe=repository.obtainYlbefore(rq, "", "", "", ""); | 116 | +// List<Dlb> dlListBe=repository.obtainYlbefore(rq, "", "", "", ""); |
| 112 | List<Cdl> cdyList=cdlRepository.obtainCdl(); | 117 | List<Cdl> cdyList=cdlRepository.obtainCdl(); |
| 113 | //从排班表中计算出行驶的总里程 | 118 | //从排班表中计算出行驶的总里程 |
| 114 | List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","",""); | 119 | List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","",""); |
| @@ -140,14 +145,14 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -140,14 +145,14 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 140 | Double jzl=0.0; | 145 | Double jzl=0.0; |
| 141 | if(map.get("seqNumber").toString().equals("1")){ | 146 | if(map.get("seqNumber").toString().equals("1")){ |
| 142 | boolean fage=true; | 147 | boolean fage=true; |
| 143 | - for (int i = 0; i < dlListBe.size(); i++) { | ||
| 144 | - Dlb dlb=dlListBe.get(i); | ||
| 145 | - if(map.get("clZbh").toString().equals(dlb.getNbbm())){ | ||
| 146 | - t.setCzcd(dlb.getJzcd()); | ||
| 147 | - fage=false; | ||
| 148 | - break; | ||
| 149 | - } | ||
| 150 | - } | 148 | +// for (int i = 0; i < dlListBe.size(); i++) { |
| 149 | +// Dlb dlb=dlListBe.get(i); | ||
| 150 | +// if(map.get("clZbh").toString().equals(dlb.getNbbm())){ | ||
| 151 | +// t.setCzcd(dlb.getJzcd()); | ||
| 152 | +// fage=false; | ||
| 153 | +// break; | ||
| 154 | +// } | ||
| 155 | +// } | ||
| 151 | if(fage){ | 156 | if(fage){ |
| 152 | for (int y = 0; y < cdyList.size(); y++) { | 157 | for (int y = 0; y < cdyList.size(); y++) { |
| 153 | Cdl cdl=cdyList.get(y); | 158 | Cdl cdl=cdyList.get(y); |
| @@ -391,8 +396,6 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -391,8 +396,6 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 391 | 396 | ||
| 392 | } | 397 | } |
| 393 | } | 398 | } |
| 394 | - | ||
| 395 | - | ||
| 396 | } | 399 | } |
| 397 | Double lc= Double.parseDouble(map.get("totalKilometers").toString()); | 400 | Double lc= Double.parseDouble(map.get("totalKilometers").toString()); |
| 398 | if(map.get("seqNumber").toString().equals("1")){ | 401 | if(map.get("seqNumber").toString().equals("1")){ |
| @@ -485,7 +488,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -485,7 +488,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 485 | new BatchSaveUtils<Dlb>().saveList2(addList, Dlb.class); | 488 | new BatchSaveUtils<Dlb>().saveList2(addList, Dlb.class); |
| 486 | } catch (Exception e) { | 489 | } catch (Exception e) { |
| 487 | // TODO: handle exception | 490 | // TODO: handle exception |
| 488 | - if(e.getMessage().indexOf("PK_YLB_UK")>0){ | 491 | + if(e.getMessage().indexOf("PK_DLB_UK")>0){ |
| 489 | newMap.put("fage", "存在相同数据,数据已经过滤"); | 492 | newMap.put("fage", "存在相同数据,数据已经过滤"); |
| 490 | logger.info("获取:存在相同数据,数据已经过滤"); | 493 | logger.info("获取:存在相同数据,数据已经过滤"); |
| 491 | } | 494 | } |
| @@ -498,6 +501,15 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -498,6 +501,15 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 498 | repository.save(updateList.get(i)); | 501 | repository.save(updateList.get(i)); |
| 499 | } | 502 | } |
| 500 | } | 503 | } |
| 504 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 505 | + Nylog nylog=new Nylog(); | ||
| 506 | + nylog.setCreatedate(new Date()); | ||
| 507 | + nylog.setCzmc("获取"); | ||
| 508 | + nylog.setNylx("电"); | ||
| 509 | + nylog.setUserid(user.getUserName()); | ||
| 510 | + nylog.setUsername(user.getName()); | ||
| 511 | + nylog.setCxtj(line+"-"+ date+"-"+gsbm+"-"+fgsbm); | ||
| 512 | + nylogRepository.save(nylog); | ||
| 501 | newMap.put("status", ResponseCode.SUCCESS); | 513 | newMap.put("status", ResponseCode.SUCCESS); |
| 502 | } catch (Exception e) { | 514 | } catch (Exception e) { |
| 503 | // TODO Auto-generated catch block | 515 | // TODO Auto-generated catch block |
| @@ -576,57 +588,56 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -576,57 +588,56 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 576 | if(map.get("nbbm_eq")!=null){ | 588 | if(map.get("nbbm_eq")!=null){ |
| 577 | nbbm=map.get("nbbm_eq").toString(); | 589 | nbbm=map.get("nbbm_eq").toString(); |
| 578 | } | 590 | } |
| 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 | - } | 591 | + |
| 592 | + String sql="select * from bsth_c_jdl j where j.gs_bm ='"+gsbm+"' " | ||
| 593 | + + " and j.fgs_bm ='"+fgsbm+"' and rq ='"+rq+"' " | ||
| 594 | + + "and nbbm not in (select nbbm from bsth_c_dlb d" | ||
| 595 | + + " where ssgsdm ='"+gsbm+"' and fgsdm ='"+fgsbm+"'" | ||
| 596 | + + " and rq='"+rq+"')"; | ||
| 597 | + List<Jdl> listJdl=jdbcTemplate.query(sql, | ||
| 598 | + new RowMapper<Jdl>(){ | ||
| 599 | + @Override | ||
| 600 | + public Jdl mapRow(ResultSet rs, int rowNum) throws SQLException { | ||
| 601 | + Jdl s = new Jdl(); | ||
| 602 | + s.setNbbm(rs.getString("nbbm")); | ||
| 603 | + s.setGsBm(rs.getString("gs_bm")); | ||
| 604 | + s.setFgsBm(rs.getString("fgs_bm")); | ||
| 605 | + s.setJdl(rs.getDouble("jdl")); | ||
| 606 | + s.setRq(rs.getDate("rq")); | ||
| 607 | + return s; | ||
| 592 | } | 608 | } |
| 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); | 609 | + }); |
| 610 | + for (int i = 0; i < listJdl.size(); i++) { | ||
| 611 | + Jdl j=listJdl.get(i); | ||
| 612 | + Dlb t=new Dlb(); | ||
| 613 | + Line line= BasicData.nbbm2LineMap.get(j.getNbbm()); | ||
| 614 | + if(null !=line){ | ||
| 615 | + t.setCdl(j.getJdl()); | ||
| 616 | + t.setNbbm(j.getNbbm()); | ||
| 617 | + t.setRq(j.getRq()); | ||
| 618 | + t.setJsy(""); | ||
| 619 | + t.setCdl(j.getJdl()); | ||
| 620 | + t.setSsgsdm(j.getGsBm()); | ||
| 621 | + t.setFgsdm(j.getFgsBm()); | ||
| 622 | + t.setJzcd(100.0); | ||
| 623 | + t.setCzcd(100.0); | ||
| 624 | + t.setHd(0.0); | ||
| 606 | t.setJcsx(1); | 625 | 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 | - } | 626 | + t.setXlbm(line.getLineCode()); |
| 627 | + t.setLp(""); | ||
| 628 | + repository.save(t); | ||
| 628 | } | 629 | } |
| 629 | } | 630 | } |
| 631 | + | ||
| 632 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 633 | + Nylog nylog=new Nylog(); | ||
| 634 | + nylog.setCreatedate(new Date()); | ||
| 635 | + nylog.setCzmc("核对"); | ||
| 636 | + nylog.setNylx("电"); | ||
| 637 | + nylog.setUserid(user.getUserName()); | ||
| 638 | + nylog.setUsername(user.getName()); | ||
| 639 | + nylog.setCxtj(xlbm+"-"+ rq+"-"+gsbm+"-"+fgsbm); | ||
| 640 | + nylogRepository.save(nylog); | ||
| 630 | newMap.put("status", ResponseCode.SUCCESS); | 641 | newMap.put("status", ResponseCode.SUCCESS); |
| 631 | }catch(Exception e){ | 642 | }catch(Exception e){ |
| 632 | newMap.put("status", ResponseCode.ERROR); | 643 | newMap.put("status", ResponseCode.ERROR); |
| @@ -840,6 +851,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -840,6 +851,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 840 | repository.dlbUpdate(id, czcd, jzcd, hd, sh, shyy, yhlx); | 851 | repository.dlbUpdate(id, czcd, jzcd, hd, sh, shyy, yhlx); |
| 841 | 852 | ||
| 842 | } | 853 | } |
| 854 | + | ||
| 855 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 856 | + Nylog nylog=new Nylog(); | ||
| 857 | + nylog.setCreatedate(new Date()); | ||
| 858 | + nylog.setCzmc("保存全部"); | ||
| 859 | + nylog.setNylx("电"); | ||
| 860 | + nylog.setUserid(user.getUserName()); | ||
| 861 | + nylog.setUsername(user.getName()); | ||
| 862 | + nylog.setCxtj(""); | ||
| 863 | + nylogRepository.save(nylog); | ||
| 843 | newMap.put("status", ResponseCode.SUCCESS); | 864 | newMap.put("status", ResponseCode.SUCCESS); |
| 844 | }catch(Exception e){ | 865 | }catch(Exception e){ |
| 845 | newMap.put("status", ResponseCode.ERROR); | 866 | newMap.put("status", ResponseCode.ERROR); |
| @@ -940,6 +961,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -940,6 +961,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 940 | } | 961 | } |
| 941 | t.setJcsx(jcsx); | 962 | t.setJcsx(jcsx); |
| 942 | repository.save(t); | 963 | repository.save(t); |
| 964 | + | ||
| 965 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 966 | + Nylog nylog=new Nylog(); | ||
| 967 | + nylog.setCreatedate(new Date()); | ||
| 968 | + nylog.setCzmc("手动添加"); | ||
| 969 | + nylog.setNylx("电"); | ||
| 970 | + nylog.setUserid(user.getUserName()); | ||
| 971 | + nylog.setUsername(user.getName()); | ||
| 972 | + nylog.setCxtj(""); | ||
| 973 | + nylogRepository.save(nylog); | ||
| 943 | map.put("status", ResponseCode.SUCCESS); | 974 | map.put("status", ResponseCode.SUCCESS); |
| 944 | map.put("t", t); | 975 | map.put("t", t); |
| 945 | return map; | 976 | return map; |
| @@ -959,6 +990,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -959,6 +990,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 959 | Integer id =jsonObject.getInteger("id"); | 990 | Integer id =jsonObject.getInteger("id"); |
| 960 | repository.delete(id); | 991 | repository.delete(id); |
| 961 | } | 992 | } |
| 993 | + | ||
| 994 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 995 | + Nylog nylog=new Nylog(); | ||
| 996 | + nylog.setCreatedate(new Date()); | ||
| 997 | + nylog.setCzmc("删除"); | ||
| 998 | + nylog.setNylx("电"); | ||
| 999 | + nylog.setUserid(user.getUserName()); | ||
| 1000 | + nylog.setUsername(user.getName()); | ||
| 1001 | + nylog.setCxtj(""); | ||
| 1002 | + nylogRepository.save(nylog); | ||
| 962 | maps.put("status", ResponseCode.SUCCESS); | 1003 | maps.put("status", ResponseCode.SUCCESS); |
| 963 | } catch (Exception e) { | 1004 | } catch (Exception e) { |
| 964 | maps.put("status", ResponseCode.ERROR); | 1005 | maps.put("status", ResponseCode.ERROR); |
| @@ -983,17 +1024,22 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -983,17 +1024,22 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 983 | for (int j = 0; j < dlbList.size(); j++) { | 1024 | for (int j = 0; j < dlbList.size(); j++) { |
| 984 | Dlb t=dlbList.get(j); | 1025 | Dlb t=dlbList.get(j); |
| 985 | boolean fage=true; | 1026 | 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); | 1027 | + if(t.getLp().isEmpty()){ |
| 1028 | + fage=false; | ||
| 1029 | + }else{ | ||
| 1030 | + for (int i = 0; i < listpbDc.size(); i++) { | ||
| 1031 | + Map<String, Object> m = listpbDc.get(i); | ||
| 1032 | + if(t.getNbbm().equals(m.get("clZbh").toString()) | ||
| 1033 | + &&t.getJsy().equals(m.get("jGh").toString()) | ||
| 1034 | + &&t.getXlbm().equals(m.get("xlBm").toString()) | ||
| 1035 | + &&t.getLp().equals(m.get("lpName").toString())){ | ||
| 1036 | + //该条记录不用删除 | ||
| 1037 | + fage =false; | ||
| 1038 | + dlbList_upd.add(t); | ||
| 1039 | + } | ||
| 995 | } | 1040 | } |
| 996 | } | 1041 | } |
| 1042 | + | ||
| 997 | if(fage){ | 1043 | if(fage){ |
| 998 | dlbList_del.add(t); | 1044 | dlbList_del.add(t); |
| 999 | } | 1045 | } |
| @@ -1170,6 +1216,21 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | @@ -1170,6 +1216,21 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS | ||
| 1170 | return mapList; | 1216 | return mapList; |
| 1171 | } | 1217 | } |
| 1172 | 1218 | ||
| 1219 | + @Override | ||
| 1220 | + public Map<String, Object> update(Map<String, Object> map) { | ||
| 1221 | + if(map.get("id")!=null){ | ||
| 1222 | + if(map.get("id").toString().length()>0){ | ||
| 1223 | + Integer id=Integer.parseInt(map.get("id").toString()); | ||
| 1224 | + String jsy=map.get("jsy").toString(); | ||
| 1225 | + Dlb t=repository.findOne(id); | ||
| 1226 | + t.setJsy(jsy); | ||
| 1227 | + repository.save(t); | ||
| 1228 | + map.put("status", ResponseCode.SUCCESS); | ||
| 1229 | + } | ||
| 1230 | + } | ||
| 1231 | + return map; | ||
| 1232 | + } | ||
| 1233 | + | ||
| 1173 | } | 1234 | } |
| 1174 | 1235 | ||
| 1175 | class NbbmJcsxMap implements Comparator<Map<String, Object>>{ | 1236 | class NbbmJcsxMap implements Comparator<Map<String, Object>>{ |