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 | 139 | |
| 140 | 140 | /** 线调业务 */ |
| 141 | 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 | 143 | sexec.scheduleWithFixedDelay(gpsDataLoader, 100, 2, TimeUnit.SECONDS);//抓取GPS数据 |
| 144 | 144 | |
| 145 | 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 | 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 | 150 | sexec.scheduleWithFixedDelay(sampleTimeDataLoader, 140, 120 * 60, TimeUnit.SECONDS);//到离站预测需要的站点间耗时数据 |
| 151 | 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 | 153 | DirectivePushQueue.start();//消息队列 -指令,系统下发的 |
| 154 | 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 | 19 | import org.springframework.http.ResponseEntity; |
| 20 | 20 | import org.springframework.stereotype.Component; |
| 21 | 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 | 52 | headers, HttpStatus.CREATED); |
| 56 | 53 | } |
| 57 | 54 | |
| 58 | - @RequestMapping("download") | |
| 55 | + @RequestMapping("download") | |
| 59 | 56 | public void download(HttpServletResponse response,String fileName) |
| 60 | 57 | throws IOException { |
| 61 | 58 | // String fileNames=URLDecoder.decode(fileName,"UTF-8"); |
| 62 | - fileName =fileName + ".xls"; | |
| 59 | + if(!fileName.contains(".xls")) | |
| 60 | + fileName =fileName + ".xls"; | |
| 63 | 61 | String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName; |
| 64 | 62 | File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的 |
| 65 | 63 | // String filename = file.getName();// 获取日志文件名称 |
| ... | ... | @@ -82,6 +80,7 @@ public class DownloadController |
| 82 | 80 | public void downloadList(HttpServletResponse response,String fileName) |
| 83 | 81 | throws IOException { |
| 84 | 82 | // String fileNames=URLDecoder.decode(fileName,"UTF-8"); |
| 83 | + File files = new File(this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName);// | |
| 85 | 84 | fileName = fileName + ".zip"; |
| 86 | 85 | String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName; |
| 87 | 86 | File file = new File(moudelPath);// path是根据日志路径和文件名拼接出来的 |
| ... | ... | @@ -99,7 +98,8 @@ public class DownloadController |
| 99 | 98 | os.flush(); |
| 100 | 99 | os.close(); |
| 101 | 100 | file.delete(); |
| 102 | - } | |
| 101 | + deleteFiles(files); | |
| 102 | + } | |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | @RequestMapping("downloadModel") |
| ... | ... | @@ -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 | 90 | lineVersions.setName("原始版本"); |
| 91 | 91 | lineVersions.setLine(t); |
| 92 | 92 | lineVersions.setLineCode(t.getLineCode()); |
| 93 | - lineVersions.setStartDate(t.getCreateDate()); | |
| 93 | + lineVersions.setStartDate(new java.sql.Date(new Date().getTime())); | |
| 94 | 94 | lineVersions.setEndDate(new java.sql.Date(endDate.getTime()));// 2088-8-8 00:00:00 |
| 95 | 95 | lineVersions.setVersions(1); |
| 96 | 96 | lineVersions.setStatus(1); | ... | ... |
src/main/java/com/bsth/controller/LineVersionsController.java
| 1 | 1 | package com.bsth.controller; |
| 2 | 2 | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.Date; | |
| 6 | 3 | import java.util.List; |
| 7 | 4 | import java.util.Map; |
| 8 | 5 | |
| ... | ... | @@ -12,7 +9,6 @@ import org.springframework.web.bind.annotation.RequestMethod; |
| 12 | 9 | import org.springframework.web.bind.annotation.RequestParam; |
| 13 | 10 | import org.springframework.web.bind.annotation.RestController; |
| 14 | 11 | |
| 15 | -import com.bsth.entity.Line; | |
| 16 | 12 | import com.bsth.entity.LineVersions; |
| 17 | 13 | import com.bsth.repository.LineRepository; |
| 18 | 14 | import com.bsth.service.LineVersionsService; |
| ... | ... | @@ -80,4 +76,21 @@ public class LineVersionsController extends BaseController<LineVersions, Integer |
| 80 | 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 | 10 | import org.springframework.web.bind.annotation.RestController; |
| 11 | 11 | |
| 12 | 12 | import com.bsth.entity.SectionRoute; |
| 13 | +import com.bsth.entity.StationRouteCache; | |
| 13 | 14 | import com.bsth.service.SectionRouteService; |
| 14 | 15 | |
| 15 | 16 | /** |
| ... | ... | @@ -55,6 +56,12 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer |
| 55 | 56 | public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) { |
| 56 | 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 | 67 | * @Description :TODO(查询路段信息) |
| ... | ... | @@ -76,8 +83,8 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer |
| 76 | 83 | * |
| 77 | 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 | 88 | return routeService.getSectionRouteCache(map); |
| 82 | 89 | } |
| 83 | 90 | |
| ... | ... | @@ -105,6 +112,11 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer |
| 105 | 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 | 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 | 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 | 214 | |
| 215 | 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 | 259 | @RequestMapping(value = "/vehicleloadingExport", method = RequestMethod.GET) |
| 220 | 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 | 83 | @RequestMapping(value = "/singledatanew", method = RequestMethod.GET) |
| 84 | 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 | 96 | @RequestMapping(value = "/vehicleloading", method = RequestMethod.GET) |
| 91 | 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 | 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 | 224 | // Ylb t=new Ylb(); |
| 225 | 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 | 11 | import java.util.List; |
| 12 | 12 | import java.util.Map; |
| 13 | 13 | |
| 14 | +import javax.servlet.http.HttpServletRequest; | |
| 15 | + | |
| 14 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 17 | import org.springframework.data.domain.Page; |
| 16 | 18 | import org.springframework.data.domain.PageRequest; |
| ... | ... | @@ -35,14 +37,19 @@ import com.google.common.base.Splitter; |
| 35 | 37 | @RequestMapping("ylb") |
| 36 | 38 | public class YlbController extends BaseController<Ylb, Integer>{ |
| 37 | 39 | @Autowired |
| 38 | - YlbService yblService; | |
| 40 | + YlbService ylbService; | |
| 39 | 41 | |
| 40 | 42 | @RequestMapping(value = "/saveYlb",method = RequestMethod.POST) |
| 41 | 43 | public Map<String, Object> saveYlb(Ylb t){ |
| 42 | 44 | // SysUser user = SecurityUtils.getCurrentUser(); |
| 43 | 45 | t.setCreatetime(new Date()); |
| 44 | 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 | 62 | public Map<String, Object> obtain(@RequestParam Map<String, Object> map) throws Exception{ |
| 56 | 63 | Map<String, Object> list =new HashMap<String, Object>(); |
| 57 | 64 | try { |
| 58 | - list = yblService.obtain(map); | |
| 65 | + | |
| 66 | + list = ylbService.obtain(map); | |
| 59 | 67 | } catch (Exception e) { |
| 60 | 68 | // TODO Auto-generated catch block |
| 61 | 69 | throw e; |
| ... | ... | @@ -69,7 +77,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 69 | 77 | public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){ |
| 70 | 78 | Map<String, Object> list=new HashMap<String, Object>(); |
| 71 | 79 | try { |
| 72 | - list = yblService.saveYlbList(map); | |
| 80 | + list = ylbService.saveYlbList(map); | |
| 73 | 81 | } catch (Exception e) { |
| 74 | 82 | // TODO Auto-generated catch block |
| 75 | 83 | e.printStackTrace(); |
| ... | ... | @@ -85,7 +93,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 85 | 93 | public Map<String, Object> sort(@RequestParam Map<String, Object> map){ |
| 86 | 94 | Map<String, Object> list=new HashMap<String, Object>(); |
| 87 | 95 | try { |
| 88 | - list=yblService.sort(map); | |
| 96 | + list=ylbService.sort(map); | |
| 89 | 97 | } catch (Exception e) { |
| 90 | 98 | // TODO: handle exception |
| 91 | 99 | } |
| ... | ... | @@ -101,7 +109,8 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 101 | 109 | public Map<String, Object> outAndIn(@RequestParam Map<String, Object> map) throws Exception{ |
| 102 | 110 | Map<String, Object> list=new HashMap<String, Object>(); |
| 103 | 111 | try { |
| 104 | - list=yblService.outAndIn(map); | |
| 112 | + | |
| 113 | + list=ylbService.outAndIn(map); | |
| 105 | 114 | } catch (Exception e) { |
| 106 | 115 | // TODO: handle exception |
| 107 | 116 | } |
| ... | ... | @@ -118,7 +127,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 118 | 127 | public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ |
| 119 | 128 | Map<String, Object> list=new HashMap<String, Object>(); |
| 120 | 129 | try { |
| 121 | - list=yblService.checkYl(map); | |
| 130 | + list=ylbService.checkYl(map); | |
| 122 | 131 | } catch (Exception e) { |
| 123 | 132 | // TODO: handle exception |
| 124 | 133 | } |
| ... | ... | @@ -146,7 +155,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 146 | 155 | String rq=map.get("rq").toString(); |
| 147 | 156 | int lx=Integer.parseInt(map.get("sxtj").toString().trim()); |
| 148 | 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 | 159 | map.get("fgsdm_like").toString(), map.get("xlbm_like").toString(), |
| 151 | 160 | map.get("nbbm_eq").toString(),lx)); |
| 152 | 161 | } |
| ... | ... | @@ -194,7 +203,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 194 | 203 | */ |
| 195 | 204 | @RequestMapping(value = "/ylbList",method = RequestMethod.GET) |
| 196 | 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 | 207 | return ylbList; |
| 199 | 208 | } |
| 200 | 209 | |
| ... | ... | @@ -202,7 +211,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 202 | 211 | public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) { |
| 203 | 212 | Map<String, Object> maps=new HashMap<String, Object>(); |
| 204 | 213 | try { |
| 205 | - maps= yblService.deleteIds(map); | |
| 214 | + maps= ylbService.deleteIds(map); | |
| 206 | 215 | } catch (Exception e) { |
| 207 | 216 | // TODO Auto-generated catch block |
| 208 | 217 | e.printStackTrace(); |
| ... | ... | @@ -210,19 +219,19 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 210 | 219 | return maps; |
| 211 | 220 | } |
| 212 | 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 | 226 | @RequestMapping(value = "/checkJsy",method = RequestMethod.GET) |
| 218 | 227 | public String checkJsy(@RequestParam Map<String, Object> map){ |
| 219 | - String list=yblService.checkJsy(map); | |
| 228 | + String list=ylbService.checkJsy(map); | |
| 220 | 229 | return list; |
| 221 | 230 | } |
| 222 | 231 | |
| 223 | 232 | @RequestMapping(value = "/sumYlb",method = RequestMethod.GET) |
| 224 | 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 | 235 | return list; |
| 227 | 236 | } |
| 228 | 237 | |
| ... | ... | @@ -232,7 +241,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 232 | 241 | sdfSimple = new SimpleDateFormat("yyyyMMdd"); |
| 233 | 242 | List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); |
| 234 | 243 | ReportUtils ee = new ReportUtils(); |
| 235 | - List<Ylb> ylb= yblService.listYlb(map); | |
| 244 | + List<Ylb> ylb= ylbService.listYlb(map); | |
| 236 | 245 | // (new CustomerSpecs<Ylb>(map)).iterator(); |
| 237 | 246 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 238 | 247 | for (Ylb y : ylb) { |
| ... | ... | @@ -299,7 +308,7 @@ public class YlbController extends BaseController<Ylb, Integer>{ |
| 299 | 308 | public Map<String, Object> updateHistory(@RequestParam Map<String, Object> map) throws Exception{ |
| 300 | 309 | Map<String, Object> list =new HashMap<String, Object>(); |
| 301 | 310 | try { |
| 302 | - list = yblService.updateHistory(map); | |
| 311 | + list = ylbService.updateHistory(map); | |
| 303 | 312 | } catch (Exception e) { |
| 304 | 313 | // TODO Auto-generated catch block |
| 305 | 314 | throw e; | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -23,9 +23,6 @@ import java.util.*; |
| 23 | 23 | @RequestMapping("/realSchedule") |
| 24 | 24 | public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> { |
| 25 | 25 | |
| 26 | - /*@Autowired | |
| 27 | - GetSchedulePlanThread getSchedulePlanThread;*/ | |
| 28 | - | |
| 29 | 26 | @Autowired |
| 30 | 27 | ScheduleRealInfoService scheduleRealInfoService; |
| 31 | 28 | ... | ... |
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
| ... | ... | @@ -110,4 +110,14 @@ public class anomalyCheckController { |
| 110 | 110 | dayOfSchedule.removeExecPlan(nbbm); |
| 111 | 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 | 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 | 287 | @RequestMapping(value="/countBusMileage") |
| 282 | 288 | public List<Map<String,Object>> countBusMileage(@RequestParam Map<String, Object> map){ |
| 283 | 289 | return service.countByBusList(map); |
| ... | ... | @@ -325,4 +331,10 @@ public class ReportController { |
| 325 | 331 | |
| 326 | 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 | 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 | 5 | import org.springframework.stereotype.Component; |
| 6 | 6 | |
| 7 | 7 | /** |
| ... | ... | @@ -10,32 +10,10 @@ import org.springframework.stereotype.Component; |
| 10 | 10 | @Component |
| 11 | 11 | public class ThreadMonotor extends Thread{ |
| 12 | 12 | |
| 13 | - Logger log = LoggerFactory.getLogger(this.getClass()); | |
| 14 | - | |
| 15 | 13 | @Override |
| 16 | 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 | 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 | 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 | 50 | |
| 51 | 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 | 60 | try{ |
| 58 | 61 | //将班次按线路分组 |
| 59 | 62 | List<ScheduleRealInfo> all = new ArrayList<>(dayOfSchedule.findAll()); |
| 60 | - ArrayListMultimap<String, ScheduleRealInfo> xlMaps = ArrayListMultimap.create(); | |
| 61 | 63 | for(ScheduleRealInfo sch : all){ |
| 62 | 64 | xlMaps.put(sch.getXlBm(), sch); |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | Set<String> ks = xlMaps.keySet(); |
| 66 | 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 | 76 | }catch (Exception e){ |
| 70 | 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 | 82 | if (list.size() == 0) |
| 76 | - return; | |
| 77 | - String lineCode = list.get(0).getXlBm(); | |
| 83 | + return new ArrayList<>(); | |
| 78 | 84 | //按上下行分组 |
| 79 | 85 | List<ScheduleRealInfo> ups = new ArrayList<>(), downs = new ArrayList<>(); |
| 80 | 86 | for (ScheduleRealInfo sch : list) { |
| ... | ... | @@ -87,7 +93,12 @@ public class CarOutInfoHandler { |
| 87 | 93 | ScheduleRealInfo[] upArray = nexts(ups), |
| 88 | 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 | 103 | DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); |
| 93 | 104 | DefaultTransactionDefinition def = new DefaultTransactionDefinition(); |
| ... | ... | @@ -96,13 +107,13 @@ public class CarOutInfoHandler { |
| 96 | 107 | |
| 97 | 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 | 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 | 113 | " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new BatchPreparedStatementSetter() { |
| 103 | 114 | @Override |
| 104 | 115 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 105 | - ScheduleRealInfo sch = pstArray.get(i); | |
| 116 | + ScheduleRealInfo sch = pstList.get(i); | |
| 106 | 117 | ps.setString(1, sch.getScheduleDateStr()); |
| 107 | 118 | ps.setString(2, sch.getXlBm()); |
| 108 | 119 | ps.setString(3, sch.getXlName()); |
| ... | ... | @@ -122,7 +133,7 @@ public class CarOutInfoHandler { |
| 122 | 133 | |
| 123 | 134 | @Override |
| 124 | 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 | 170 | ScheduleRealInfo[] array = new ScheduleRealInfo[3]; |
| 160 | 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 | 175 | for (ScheduleRealInfo sch : list) { |
| 165 | 176 | if (count == 3) |
| 166 | 177 | break; |
| ... | ... | @@ -180,8 +191,8 @@ public class CarOutInfoHandler { |
| 180 | 191 | || StringUtils.isNotEmpty(sch.getZdsjActual())) |
| 181 | 192 | continue; |
| 182 | 193 | |
| 183 | - if (t - sch.getDfsjT() > threshold) | |
| 184 | - continue; | |
| 194 | + /*if (t - sch.getDfsjT() > threshold) | |
| 195 | + continue;*/ | |
| 185 | 196 | |
| 186 | 197 | array[count] = sch; |
| 187 | 198 | count++; | ... | ... |
src/main/java/com/bsth/data/directive/DayOfDirectives.java
| ... | ... | @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.stereotype.Component; |
| 16 | 16 | |
| 17 | 17 | import java.util.*; |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * |
| ... | ... | @@ -52,8 +53,8 @@ public class DayOfDirectives { |
| 52 | 53 | |
| 53 | 54 | |
| 54 | 55 | static{ |
| 55 | - d60Map = new HashMap<>(); | |
| 56 | - d64Map = new HashMap<>(); | |
| 56 | + d60Map = new ConcurrentHashMap<>(); | |
| 57 | + d64Map = new ConcurrentHashMap<>(); | |
| 57 | 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 | 51 | logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId()); |
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | - if(dayOfSchedule.get(sch.getId()) == null){ | |
| 55 | - logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。"); | |
| 56 | - continue; | |
| 57 | - } | |
| 58 | 54 | } |
| 59 | 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 | 4 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 5 | 5 | import com.bsth.data.gpsdata_v2.handlers.*; |
| 6 | 6 | import com.google.common.collect.ArrayListMultimap; |
| 7 | +import org.apache.commons.lang3.StringUtils; | |
| 7 | 8 | import org.slf4j.Logger; |
| 8 | 9 | import org.slf4j.LoggerFactory; |
| 9 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 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 | 20 | @Component |
| 25 | 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 | 23 | @Autowired |
| 34 | 24 | GpsStateProcess gpsStateProcess; |
| 35 | 25 | @Autowired |
| ... | ... | @@ -42,12 +32,28 @@ public class DataHandleProcess { |
| 42 | 32 | OutStationProcess outStationProcess; |
| 43 | 33 | @Autowired |
| 44 | 34 | ReverseRouteProcess reverseRouteProcess; |
| 45 | - | |
| 46 | 35 | @Autowired |
| 47 | 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 | 52 | public void handle(List<GpsEntity> list) { |
| 50 | 53 | try { |
| 54 | + if (list.size() == 0) | |
| 55 | + return; | |
| 56 | + lastTime = System.currentTimeMillis(); | |
| 51 | 57 | //按设备号分组数据(一个设备的多条数据,必须在一个线程里跑) |
| 52 | 58 | ArrayListMultimap multimap = ArrayListMultimap.create(); |
| 53 | 59 | for (GpsEntity gps : list) { |
| ... | ... | @@ -67,21 +73,50 @@ public class DataHandleProcess { |
| 67 | 73 | logger.info("analyse gps size: " + list.size() + ", ks: " + ks.size()); |
| 68 | 74 | count = new CountDownLatch(ks.size()); |
| 69 | 75 | |
| 76 | + List<Future> fRs = new ArrayList<>(ks.size()); | |
| 70 | 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 | 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 | 108 | //加入实时gps对照 |
| 78 | 109 | for (GpsEntity gps : list) |
| 79 | 110 | gpsRealData.put(gps); |
| 111 | + | |
| 112 | + logger.info("time , " + (System.currentTimeMillis() - lastTime)); | |
| 80 | 113 | } catch (Exception e) { |
| 81 | 114 | logger.error("", e); |
| 82 | 115 | } |
| 83 | 116 | } |
| 84 | 117 | |
| 118 | + static GpsComp comp = new GpsComp(); | |
| 119 | + | |
| 85 | 120 | public class SignalHandleThread implements Runnable { |
| 86 | 121 | |
| 87 | 122 | List<GpsEntity> list; |
| ... | ... | @@ -94,45 +129,44 @@ public class DataHandleProcess { |
| 94 | 129 | |
| 95 | 130 | @Override |
| 96 | 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 | 158 | if (count != null) |
| 118 | 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 | 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 | 173 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/GpsRealData.java
src/main/java/com/bsth/data/gpsdata_v2/cache/GpsCacheData.java
src/main/java/com/bsth/data/gpsdata_v2/handlers/AbnormalStateProcess.java
| ... | ... | @@ -25,34 +25,34 @@ public class AbnormalStateProcess { |
| 25 | 25 | */ |
| 26 | 26 | private static final double OUT_BOUNDS_THRESHOLD = 100; |
| 27 | 27 | |
| 28 | - | |
| 29 | 28 | public void process(GpsEntity gps) { |
| 30 | - if(isOffline(gps)) | |
| 29 | + if (isOffline(gps)) | |
| 31 | 30 | return; |
| 32 | 31 | |
| 33 | - if(overspeed(gps)) | |
| 32 | + if (overspeed(gps)) | |
| 34 | 33 | return; |
| 35 | 34 | |
| 36 | - if(outOfBounds((gps))) | |
| 35 | + if (outOfBounds((gps))) | |
| 37 | 36 | return; |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | - private boolean isOffline(GpsEntity gps){ | |
| 39 | + private boolean isOffline(GpsEntity gps) { | |
| 41 | 40 | return gps.getAbnormalStatus() != null && gps.getAbnormalStatus().equals("offline"); |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | |
| 45 | 44 | /** |
| 46 | 45 | * 是否超速 |
| 46 | + * | |
| 47 | 47 | * @param gps |
| 48 | 48 | * @return |
| 49 | 49 | */ |
| 50 | - private boolean overspeed(GpsEntity gps){ | |
| 50 | + private boolean overspeed(GpsEntity gps) { | |
| 51 | 51 | double maxSpeed = DEFAULT_SPEED_LIMIT; |
| 52 | - if(GeoCacheData.speedLimit(gps.getLineId()) != null) | |
| 52 | + if (GeoCacheData.speedLimit(gps.getLineId()) != null) | |
| 53 | 53 | maxSpeed = GeoCacheData.speedLimit(gps.getLineId()); |
| 54 | 54 | |
| 55 | - if(gps.getSpeed() > maxSpeed){ | |
| 55 | + if (gps.getSpeed() > maxSpeed) { | |
| 56 | 56 | gps.setAbnormalStatus("overspeed"); |
| 57 | 57 | return true; |
| 58 | 58 | } |
| ... | ... | @@ -62,12 +62,13 @@ public class AbnormalStateProcess { |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * 是否越界 |
| 65 | + * | |
| 65 | 66 | * @param gps |
| 66 | 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 | 72 | return false; |
| 72 | 73 | } |
| 73 | 74 | |
| ... | ... | @@ -76,15 +77,15 @@ public class AbnormalStateProcess { |
| 76 | 77 | |
| 77 | 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 | 84 | min = distance; |
| 84 | 85 | } |
| 85 | 86 | |
| 86 | 87 | gps.setOutOfBoundDistance(min); |
| 87 | - if(min > OUT_BOUNDS_THRESHOLD){ | |
| 88 | + if (min > OUT_BOUNDS_THRESHOLD) { | |
| 88 | 89 | gps.setAbnormalStatus("outBounds"); |
| 89 | 90 | return true; |
| 90 | 91 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
| ... | ... | @@ -20,26 +20,26 @@ public class GpsStateProcess { |
| 20 | 20 | @Autowired |
| 21 | 21 | GpsStatusManager gpsStatusManager; |
| 22 | 22 | |
| 23 | - public void process(GpsEntity gps){ | |
| 23 | + public void process(GpsEntity gps) { | |
| 24 | 24 | //在执行的任务 |
| 25 | 25 | ScheduleRealInfo sch = dayOfSchedule.executeCurr(gps.getNbbm()); |
| 26 | 26 | |
| 27 | - if(null == sch) | |
| 27 | + if (null == sch) | |
| 28 | 28 | return; |
| 29 | 29 | |
| 30 | 30 | byte upDown = Byte.parseByte(sch.getXlDir()); |
| 31 | 31 | |
| 32 | - if(gps.getUpDown() != upDown){ | |
| 32 | + if (gps.getUpDown() != upDown) { | |
| 33 | 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 | 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 | 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 | 45 | public void process(GpsEntity gps) { |
| 46 | 46 | //自动执行的班次信号,滚蛋 |
| 47 | 47 | LineConfig config = lineConfigData.get(gps.getLineId()); |
| 48 | - if(null != config && config.isAutoExec()) | |
| 48 | + if (null != config && config.isAutoExec()) | |
| 49 | 49 | return; |
| 50 | 50 | |
| 51 | 51 | GpsEntity prev = GpsCacheData.getPrev(gps); |
| 52 | 52 | |
| 53 | - if(null == prev) | |
| 53 | + if (null == prev) | |
| 54 | 54 | return; |
| 55 | 55 | |
| 56 | 56 | //从站外到站内 |
| 57 | - if(prev.getInstation() == 0 && gps.getInstation() > 0){ | |
| 57 | + if (prev.getInstation() == 0 && gps.getInstation() > 0) { | |
| 58 | 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 | 63 | && !prev.getStopNo().equals(gps.getStopNo()) |
| 64 | 64 | && !prev.getStation().getName().equals(gps.getStation().getName())) |
| 65 | 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 | 69 | inStation(gps, prev); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | //被起点站覆盖的情况下进场 |
| 73 | - if(isInPark(gps, prev)) | |
| 73 | + if (isInPark(gps, prev)) | |
| 74 | 74 | inStation(gps, prev); |
| 75 | 75 | } |
| 76 | 76 | |
| ... | ... | @@ -96,7 +96,7 @@ public class InStationProcess { |
| 96 | 96 | |
| 97 | 97 | //进终点 |
| 98 | 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 | 100 | inEndStation(sch, gps); |
| 101 | 101 | isEnd = true; |
| 102 | 102 | } |
| ... | ... | @@ -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 | 272 | return true; |
| 273 | 273 | return false; |
| 274 | 274 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/handlers/OutStationProcess.java
| ... | ... | @@ -42,7 +42,7 @@ public class OutStationProcess { |
| 42 | 42 | private final static int MAX_BEFORE_TIME = 1000 * 60 * 120; |
| 43 | 43 | |
| 44 | 44 | public void process(GpsEntity gps) { |
| 45 | - //自动执行的班次信号,滚蛋 | |
| 45 | + //自动执行的线路,滚蛋 | |
| 46 | 46 | LineConfig config = lineConfigData.get(gps.getLineId()); |
| 47 | 47 | if (null != config && config.isAutoExec()) |
| 48 | 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 | 8 | import com.bsth.data.schedule.DayOfSchedule; |
| 9 | 9 | import com.bsth.entity.realcontrol.LineConfig; |
| 10 | 10 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 11 | +import org.slf4j.Logger; | |
| 12 | +import org.slf4j.LoggerFactory; | |
| 11 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 14 | import org.springframework.stereotype.Component; |
| 13 | 15 | |
| ... | ... | @@ -30,54 +32,58 @@ public class ReverseRouteProcess { |
| 30 | 32 | @Autowired |
| 31 | 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 | 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 | 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 | 47 | return; |
| 42 | 48 | |
| 43 | 49 | //next |
| 44 | 50 | ScheduleRealInfo next = dayOfSchedule.next(sch); |
| 45 | - if(isInOut(next)) | |
| 51 | + if (isInOut(next)) | |
| 46 | 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 | 56 | dayOfSchedule.addExecPlan(next); |
| 51 | 57 | } |
| 52 | 58 | } |
| 53 | 59 | |
| 54 | 60 | private boolean reversRoute(GpsEntity gps) { |
| 55 | - if(gps.getInstation() != 1) | |
| 61 | + if (gps.getInstation() != 1) | |
| 56 | 62 | return false; |
| 57 | 63 | |
| 58 | 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 | 69 | //满足3个进站反向信号 |
| 64 | 70 | List<StationRoute> prevs = GpsCacheData.prevMultiStation(gps); |
| 65 | 71 | |
| 66 | 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 | 76 | sortNo = s.getRouteSort(); |
| 71 | 77 | } |
| 72 | 78 | |
| 73 | - if(count >= REVER_THRESHOLD) | |
| 79 | + if (count >= REVER_THRESHOLD) | |
| 74 | 80 | return true; |
| 75 | 81 | } |
| 76 | 82 | |
| 77 | 83 | return false; |
| 78 | 84 | } |
| 79 | 85 | |
| 80 | - private boolean isInOut(ScheduleRealInfo sch){ | |
| 86 | + private boolean isInOut(ScheduleRealInfo sch) { | |
| 81 | 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 | 16 | @Component |
| 17 | 17 | public class StationInsideProcess { |
| 18 | 18 | |
| 19 | - public void process(GpsEntity gps){ | |
| 19 | + public void process(GpsEntity gps) { | |
| 20 | 20 | //是否在场内 |
| 21 | 21 | String parkCode = GeoUtils.gpsInCarpark(gps); |
| 22 | 22 | |
| ... | ... | @@ -42,13 +42,13 @@ public class StationInsideProcess { |
| 42 | 42 | //上一个点位 |
| 43 | 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 | 48 | gps.setPremiseCode(prev.getPremiseCode()); |
| 49 | 49 | |
| 50 | 50 | //在场,站外 |
| 51 | - if(gps.getInstation() == 0){ | |
| 51 | + if (gps.getInstation() == 0) { | |
| 52 | 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 | 67 | |
| 68 | 68 | list = JSON.parseArray(sb.toString(), GpsEntity.class); |
| 69 | 69 | |
| 70 | + logger.info("load end ! size: " + list.size()); | |
| 70 | 71 | //过滤掉无效的点位 |
| 71 | 72 | list = GpsDataUtils.clearInvalid(list); |
| 72 | 73 | |
| 73 | - logger.info("load end!"); | |
| 74 | 74 | for (GpsEntity gps : list) { |
| 75 | 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 | 84 | Calendar calendar = Calendar.getInstance(); |
| 85 | 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 | 88 | JdbcTemplate jdbcTemplate = new JdbcTemplate(DBUtils_MS.getDataSource()); |
| 89 | 89 | |
| 90 | 90 | List<GpsEntity> list = | ... | ... |
src/main/java/com/bsth/data/gpsdata_v2/utils/GpsDataUtils.java
| 1 | 1 | package com.bsth.data.gpsdata_v2.utils; |
| 2 | 2 | |
| 3 | +import com.bsth.data.gpsdata_v2.GpsRealData; | |
| 3 | 4 | import com.bsth.data.gpsdata_v2.entity.GpsEntity; |
| 4 | 5 | import org.slf4j.Logger; |
| 5 | 6 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -24,7 +25,22 @@ public class GpsDataUtils { |
| 24 | 25 | List<GpsEntity> rs = new ArrayList<>(); |
| 25 | 26 | |
| 26 | 27 | try { |
| 28 | + GpsEntity prev; | |
| 27 | 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 | 44 | if (gps.getValid() == 0 && Math.abs(gps.getTimestamp() - gps.getServerTimestamp()) < 1000 * 60 * 20) |
| 29 | 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 | 45 | |
| 46 | 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 | 51 | dayOfSchedule.addExecPlan(near); |
| 51 | 52 | return false; |
| ... | ... | @@ -57,47 +58,6 @@ public class SignalSchPlanMatcher { |
| 57 | 58 | log.error("", e); |
| 58 | 59 | } |
| 59 | 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 | 13 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 14 | 14 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 15 | 15 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 16 | -import com.bsth.util.BatchSaveUtils; | |
| 17 | 16 | import com.bsth.websocket.handler.SendUtils; |
| 18 | -import com.google.common.base.Predicate; | |
| 19 | 17 | import com.google.common.collect.ArrayListMultimap; |
| 20 | -import com.google.common.collect.Collections2; | |
| 21 | 18 | import org.apache.commons.lang3.StringUtils; |
| 22 | 19 | import org.joda.time.format.DateTimeFormat; |
| 23 | 20 | import org.joda.time.format.DateTimeFormatter; |
| ... | ... | @@ -25,12 +22,20 @@ import org.slf4j.Logger; |
| 25 | 22 | import org.slf4j.LoggerFactory; |
| 26 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
| 27 | 24 | import org.springframework.dao.DataIntegrityViolationException; |
| 25 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 28 | 26 | import org.springframework.jdbc.core.JdbcTemplate; |
| 27 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | |
| 29 | 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 | 35 | import java.text.ParseException; |
| 32 | 36 | import java.text.SimpleDateFormat; |
| 33 | 37 | import java.util.*; |
| 38 | +import java.util.concurrent.ConcurrentHashMap; | |
| 34 | 39 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 35 | 40 | |
| 36 | 41 | /** |
| ... | ... | @@ -65,6 +70,10 @@ public class DayOfSchedule { |
| 65 | 70 | // 排序器 |
| 66 | 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 | 77 | @Autowired |
| 69 | 78 | LineConfigData lineConfigData; |
| 70 | 79 | |
| ... | ... | @@ -92,11 +101,12 @@ public class DayOfSchedule { |
| 92 | 101 | nbbmScheduleMap = ArrayListMultimap.create(); |
| 93 | 102 | lpScheduleMap = ArrayListMultimap.create(); |
| 94 | 103 | |
| 95 | - id2SchedulMap = new HashMap<>(); | |
| 104 | + id2SchedulMap = new ConcurrentHashMap<>(); | |
| 96 | 105 | pstBuffer = new ConcurrentLinkedQueue<>(); |
| 97 | 106 | schFCSJComparator = new ScheduleComparator.FCSJ(); |
| 107 | + schDFSJComparator = new ScheduleComparator.DFSJ(); | |
| 98 | 108 | currSchDateMap = new HashMap<>(); |
| 99 | - carExecutePlanMap = new HashMap<>(); | |
| 109 | + carExecutePlanMap = new ConcurrentHashMap<>(); | |
| 100 | 110 | |
| 101 | 111 | schedulePlanMap = new HashMap<>(); |
| 102 | 112 | } |
| ... | ... | @@ -258,7 +268,7 @@ public class DayOfSchedule { |
| 258 | 268 | public void clearRAMData(String lineCode) { |
| 259 | 269 | int count = 0; |
| 260 | 270 | List<ScheduleRealInfo> remList = new ArrayList<>(); |
| 261 | - Collection<ScheduleRealInfo> all = id2SchedulMap.values(); | |
| 271 | + Collection<ScheduleRealInfo> all = nbbmScheduleMap.values(); | |
| 262 | 272 | for (ScheduleRealInfo sch : all) { |
| 263 | 273 | if (sch.getXlBm().equals(lineCode)) |
| 264 | 274 | remList.add(sch); |
| ... | ... | @@ -324,11 +334,13 @@ public class DayOfSchedule { |
| 324 | 334 | // 转换为实际排班 |
| 325 | 335 | realList = JSONArray.parseArray(JSON.toJSONString(planItr), ScheduleRealInfo.class); |
| 326 | 336 | |
| 337 | + Date d = new Date(); | |
| 327 | 338 | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| 328 | 339 | String fcsj; |
| 329 | 340 | for (ScheduleRealInfo sch : realList) { |
| 330 | 341 | sch.setScheduleDateStr(fmtyyyyMMdd.print(sch.getScheduleDate().getTime())); |
| 331 | 342 | sch.setRealExecDate(sch.getScheduleDateStr()); |
| 343 | + sch.setCreateDate(d); | |
| 332 | 344 | |
| 333 | 345 | if (StringUtils.isEmpty(sch.getFcsj())) |
| 334 | 346 | sch.setFcsj("00:00"); |
| ... | ... | @@ -377,26 +389,108 @@ public class DayOfSchedule { |
| 377 | 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 | 406 | * @Title: batchSave |
| 382 | 407 | * @Description: TODO(批量入库) |
| 383 | 408 | */ |
| 384 | 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 | 410 | SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); |
| 392 | 411 | for (ScheduleRealInfo item : list) { |
| 393 | 412 | item.setSpId(item.getId());// 保留原始的计划ID |
| 394 | - item.setId(id++);// 设置ID | |
| 413 | + item.setId(getId());// 设置ID | |
| 395 | 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 | 496 | public List<SchedulePlanInfo> cleanSchPlanItr(Iterator<SchedulePlanInfo> itrab) { |
| ... | ... | @@ -420,7 +514,7 @@ public class DayOfSchedule { |
| 420 | 514 | public List<ScheduleRealInfo> findByLineCode(String lineCode) { |
| 421 | 515 | List<ScheduleRealInfo> rs = new ArrayList<>(); |
| 422 | 516 | |
| 423 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 517 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 424 | 518 | for (ScheduleRealInfo sch : schs) { |
| 425 | 519 | if (sch.getXlBm().equals(lineCode)) |
| 426 | 520 | rs.add(sch); |
| ... | ... | @@ -435,7 +529,7 @@ public class DayOfSchedule { |
| 435 | 529 | public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { |
| 436 | 530 | ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); |
| 437 | 531 | |
| 438 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 532 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 439 | 533 | for (ScheduleRealInfo sch : schs) { |
| 440 | 534 | if (lineList.contains(sch.getXlBm())) { |
| 441 | 535 | mMap.put(sch.getXlBm(), sch); |
| ... | ... | @@ -489,27 +583,11 @@ public class DayOfSchedule { |
| 489 | 583 | */ |
| 490 | 584 | public ScheduleRealInfo next(ScheduleRealInfo sch) { |
| 491 | 585 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); |
| 586 | + //排序 | |
| 587 | + Collections.sort(list, schDFSJComparator); | |
| 492 | 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 | 735 | .calcRealDate(sch) |
| 658 | 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 | 741 | id2SchedulMap.put(sch.getId(), sch); |
| ... | ... | @@ -675,7 +752,6 @@ public class DayOfSchedule { |
| 675 | 752 | } |
| 676 | 753 | |
| 677 | 754 | public void delete(ScheduleRealInfo sch) { |
| 678 | - //ScheduleRealInfo sch = id2SchedulMap.get(id); | |
| 679 | 755 | if (!sch.isSflj()) |
| 680 | 756 | return; |
| 681 | 757 | |
| ... | ... | @@ -715,36 +791,6 @@ public class DayOfSchedule { |
| 715 | 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 | 794 | public void save(ScheduleRealInfo sch) { |
| 749 | 795 | sch.setUpdateDate(new Date()); |
| 750 | 796 | pstBuffer.add(sch); |
| ... | ... | @@ -768,26 +814,6 @@ public class DayOfSchedule { |
| 768 | 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 | 883 | * @return |
| 858 | 884 | */ |
| 859 | 885 | public ScheduleRealInfo executeCurr(String nbbm) { |
| 886 | + if(StringUtils.isEmpty(nbbm)) | |
| 887 | + return null; | |
| 860 | 888 | return carExecutePlanMap.get(nbbm); |
| 861 | 889 | } |
| 862 | 890 | |
| ... | ... | @@ -892,12 +920,12 @@ public class DayOfSchedule { |
| 892 | 920 | } |
| 893 | 921 | |
| 894 | 922 | public void reCalcExecPlan(String nbbm) { |
| 895 | - logger.info("reCalcExecPlan...: " + nbbm); | |
| 896 | 923 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); |
| 897 | - Collections.sort(list, schFCSJComparator); | |
| 924 | + Collections.sort(list, schDFSJComparator); | |
| 898 | 925 | |
| 899 | 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 | 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 | 1090 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
| ... | ... | @@ -206,6 +206,8 @@ public class SchAttrCalculator { |
| 206 | 206 | * @return |
| 207 | 207 | */ |
| 208 | 208 | public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) { |
| 209 | + if(list.size()==0) | |
| 210 | + return null; | |
| 209 | 211 | String lineCode = list.get(0).getXlBm(); |
| 210 | 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 | 68 | ScheduleRealInfo cancel = null; |
| 69 | 69 | //之前存在误点班次没有发出 |
| 70 | 70 | ScheduleRealInfo old = lateSchMap.get(sch.getClZbh()); |
| 71 | + | |
| 71 | 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 | 84 | lateSchMap.put(sch.getClZbh(), sch); |
| ... | ... | @@ -164,7 +171,7 @@ public class LateAdjustHandle implements ApplicationContextAware{ |
| 164 | 171 | } |
| 165 | 172 | }catch (Exception e){ |
| 166 | 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 | 1 | package com.bsth.data.schedule.thread; |
| 2 | 2 | |
| 3 | -import com.alibaba.fastjson.JSON; | |
| 4 | 3 | import com.bsth.data.schedule.DayOfSchedule; |
| 5 | 4 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 6 | 5 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 7 | 6 | import org.slf4j.Logger; |
| 8 | 7 | import org.slf4j.LoggerFactory; |
| 9 | 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 | 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 | 23 | * @author PanZhao |
| ... | ... | @@ -24,67 +32,145 @@ public class SchedulePstThread extends Thread { |
| 24 | 32 | ScheduleRealInfoRepository scheduleRepository; |
| 25 | 33 | |
| 26 | 34 | @Autowired |
| 27 | - NamedParameterJdbcTemplate jdbcTemplate; | |
| 35 | + JdbcTemplate jdbcTemplate; | |
| 28 | 36 | |
| 29 | 37 | @Autowired |
| 30 | 38 | DayOfSchedule dayOfSchedule; |
| 31 | 39 | |
| 32 | 40 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 33 | 41 | |
| 42 | + static List<ScheduleRealInfo> saveList = new ArrayList<>(); | |
| 43 | + | |
| 34 | 44 | @Override |
| 35 | 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 | 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 | 56 | |
| 57 | 57 | if(oldSchDate == null || !oldSchDate.equals(currSchDate)){ |
| 58 | 58 | |
| 59 | - logger.info(lineCode + "开始翻班, " + currSchDate); | |
| 59 | + //logger.info(lineCode + "开始翻班, " + currSchDate); | |
| 60 | 60 | |
| 61 | 61 | try{ |
| 62 | 62 | //清除指令数据 |
| ... | ... | @@ -74,6 +74,14 @@ public class ScheduleRefreshThread extends Thread{ |
| 74 | 74 | //重载排班数据 |
| 75 | 75 | dayOfSchedule.reloadSch(lineCode, currSchDate, false); |
| 76 | 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 | 86 | }catch (Exception e){ |
| 79 | 87 | logger.error("班次更新失败!! -" + lineCode, e); | ... | ... |
src/main/java/com/bsth/entity/LineVersions.java
| ... | ... | @@ -69,6 +69,12 @@ public class LineVersions{ |
| 69 | 69 | */ |
| 70 | 70 | private int status; |
| 71 | 71 | |
| 72 | + /** | |
| 73 | + * 是否发布 int length(1) | |
| 74 | + * 0(没有),1(发布) | |
| 75 | + */ | |
| 76 | + private int isupdate; | |
| 77 | + | |
| 72 | 78 | public Integer getId() { |
| 73 | 79 | return id; |
| 74 | 80 | } |
| ... | ... | @@ -156,5 +162,13 @@ public class LineVersions{ |
| 156 | 162 | public void setStatus(int status) { |
| 157 | 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 | 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 | 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
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 | 73 | @Query(value = " SELECT lv FROM LineVersions lv where lv.line.id = ?1 and lv.versions = (?2 - "+1+")") |
| 74 | 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 | 37 | @Modifying |
| 38 | 38 | @Query(value="DELETE from bsth_c_ls_sectionroute where line = ?1 and directions = ?2 and versions=?3", nativeQuery=true) |
| 39 | 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 | 42 | @Modifying |
| 43 | 43 | @Query(value="DELETE from bsth_c_ls_stationroute where line = ?1 and directions = ?2 and versions = ?3", nativeQuery=true) |
| 44 | 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 | 139 | @Modifying |
| 140 | 140 | @Query(value="delete from bsth_c_sectionroute_cache where line_code = ?1 and directions = ?2", nativeQuery=true) |
| 141 | 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 | 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 | 202 | @Modifying |
| 203 | 203 | @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.lineCode = ?2") |
| 204 | 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 | 1 | package com.bsth.repository; |
| 2 | 2 | |
| 3 | 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 | 5 | import org.springframework.data.jpa.repository.EntityGraph; |
| 9 | 6 | import org.springframework.data.jpa.repository.Modifying; |
| 10 | 7 | import org.springframework.data.jpa.repository.Query; |
| 11 | 8 | import org.springframework.stereotype.Repository; |
| 12 | 9 | |
| 13 | -import com.bsth.entity.StationRoute; | |
| 14 | 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 | 52 | /** |
| 58 | 53 | * 更新路线删除线路缓存站点 |
| 59 | 54 | * |
| 60 | - * @param line | |
| 55 | + * @param lineCode | |
| 61 | 56 | * @param dir |
| 62 | 57 | */ |
| 63 | 58 | @Modifying |
| 64 | 59 | @Query(value="delete from bsth_c_stationroute_cache where line_code = ?1 and directions = ?2 ", nativeQuery=true) |
| 65 | 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 | 67 | @Query(value = "SELECT a.`stationRoute.id`," + |
| ... | ... | @@ -137,4 +136,7 @@ public interface StationRouteCacheRepository extends BaseRepository<StationRoute |
| 137 | 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 | 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 | 15 | |
| 16 | 16 | import com.bsth.entity.Line; |
| 17 | 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 | 188 | " a.stationRouteUpdateDate," + |
| 190 | 189 | " b.id AS stationId," + |
| 191 | 190 | " b.station_cod AS stationCode," + |
| 192 | - " b.station_name AS stationName," + | |
| 191 | + " a.stationRouteName," + | |
| 193 | 192 | " b.road_coding AS stationRoadCoding," + |
| 194 | 193 | " b.db_type AS stationDbType," + |
| 195 | 194 | " b.b_jwpoints AS stationJwpoints," + |
| ... | ... | @@ -212,6 +211,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 212 | 211 | " FROM ( SELECT s.id AS stationRouteId," + |
| 213 | 212 | " s.line AS stationRouteLine," + |
| 214 | 213 | " s.station as stationRouteStation," + |
| 214 | + " s.station_name AS stationRouteName," + | |
| 215 | 215 | " s.station_route_code as stationRouteCode," + |
| 216 | 216 | " s.line_code AS stationRouteLIneCode," + |
| 217 | 217 | " s.station_mark AS stationRouteStationMark," + |
| ... | ... | @@ -259,6 +259,9 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 259 | 259 | @Query("select r from StationRoute r where r.lineCode=?1 and r.directions=?2 and r.destroy=0 order by r.stationRouteCode") |
| 260 | 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 | 265 | @EntityGraph(value = "stationRoute_station", type = EntityGraph.EntityGraphType.FETCH) |
| 263 | 266 | @Query("select s from StationRoute s where s.destroy=0 and s.lineCode=?1") |
| 264 | 267 | List<StationRoute> findByLineCode(String lineCode); |
| ... | ... | @@ -285,6 +288,17 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 285 | 288 | "ORDER BY " + |
| 286 | 289 | "lineCode,directions,stationRouteCode") |
| 287 | 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 | 303 | @Modifying |
| 290 | 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 | 52 | + " order by nbbm , rq desc,jcsx desc",nativeQuery=true) |
| 53 | 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 | 62 | * 当天YLB信息 |
| ... | ... | @@ -67,6 +71,11 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 67 | 71 | @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and ssgsdm like %?2% " |
| 68 | 72 | + " and fgsdm like %?3%" |
| 69 | 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 | 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 | 162 | " yhlx = ?9"+ |
| 154 | 163 | " WHERE id = ?1", nativeQuery=true) |
| 155 | 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 | 33 | List<LineVersions> lineUpdate(); |
| 34 | 34 | |
| 35 | 35 | LineVersions findLineVersionsMax(int lineId); |
| 36 | + | |
| 37 | + // 返回当前线路版本 | |
| 38 | + Integer findCurrentVersion(int lineId); | |
| 36 | 39 | |
| 37 | 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 | 61 | */ |
| 62 | 62 | List<Map<String, Object>> findUpSectionRouteCode(Map<String, Object> map); |
| 63 | 63 | |
| 64 | + List<Map<String, Object>> findCacheUpSectionRouteCode(Map<String, Object> map); | |
| 65 | + | |
| 64 | 66 | Map<String, Object> quoteSection(Map<String, Object> map); |
| 65 | 67 | |
| 66 | 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 | 52 | */ |
| 53 | 53 | Map<String, Object> stationSaveMap(Map<String, Object> map); |
| 54 | 54 | |
| 55 | + Map<String, Object> stationCacheSave(Map<String, Object> map); | |
| 56 | + | |
| 55 | 57 | /** |
| 56 | 58 | * @Description :TODO(更新站点保存) |
| 57 | 59 | * |
| ... | ... | @@ -83,5 +85,8 @@ public interface StationService extends BaseService<Station, Integer> { |
| 83 | 85 | Map<String, Object> cacheSave(Map<String, Object> map); |
| 84 | 86 | |
| 85 | 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 | 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 | 73 | if(line.length() != 0){ |
| 74 | 74 | sql += " where t.line_code = " + line; |
| 75 | 75 | } |
| ... | ... | @@ -82,7 +82,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 82 | 82 | m.put("id", rs.getLong("id")); |
| 83 | 83 | m.put("out_config", rs.getString("out_config")); |
| 84 | 84 | m.put("start_opt", rs.getString("start_opt")); |
| 85 | - m.put("trust", rs.getString("trust")); | |
| 86 | 85 | m.put("line_code", rs.getString("line_code")); |
| 87 | 86 | return m; |
| 88 | 87 | }}); | ... | ... |
src/main/java/com/bsth/service/forms/FormsService.java
| ... | ... | @@ -31,6 +31,7 @@ public interface FormsService { |
| 31 | 31 | |
| 32 | 32 | public List<Singledata> singledata(Map<String, Object> map); |
| 33 | 33 | public List<Singledata> singledatanew(Map<String, Object> map); |
| 34 | + public List<Singledata> singledatatj(Map<String, Object> map); | |
| 34 | 35 | |
| 35 | 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 | 441 | + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name " |
| 442 | 442 | + "FROM bsth_c_s_sp_info_real r where 1=1 " |
| 443 | 443 | + " and r.schedule_date_str='"+date + "' " |
| 444 | - + " and r.xl_bm like '%"+line+"%' " | |
| 444 | + + " and r.xl_bm = '"+line+"' " | |
| 445 | 445 | + " and r.gs_bm like '%"+gsdmShif+"%' " |
| 446 | 446 | + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t" |
| 447 | 447 | + " GROUP BY t.schedule_date,t.j_name,t.s_name, " |
| ... | ... | @@ -473,7 +473,8 @@ public class FormsServiceImpl implements FormsService { |
| 473 | 473 | Shifday d=list.get(i); |
| 474 | 474 | for (int j = 0; j < lists.size(); j++) { |
| 475 | 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 | 478 | sList.add(s); |
| 478 | 479 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 479 | 480 | if(cts != null && cts.size() > 0){ |
| ... | ... | @@ -492,7 +493,10 @@ public class FormsServiceImpl implements FormsService { |
| 492 | 493 | double ljgl=culateMileageService.culateLjgl(list_s); |
| 493 | 494 | double sjgl=culateMileageService.culateSjgl(list_s); |
| 494 | 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 | 500 | double cjgl=culateMileageService.culateLbgl(sList); |
| 497 | 501 | int jhbc=culateMileageService.culateJhbc(sList,""); |
| 498 | 502 | int cjbc=culateMileageService.culateLbbc(sList); |
| ... | ... | @@ -502,9 +506,9 @@ public class FormsServiceImpl implements FormsService { |
| 502 | 506 | d.setEmptMileage(String.valueOf(zksgl));//空驶公里 |
| 503 | 507 | d.setTotalm(String.valueOf(Arith.add(zksgl, zyygl)));//总公里 |
| 504 | 508 | d.setSjbc(String.valueOf(sjbc+ljbc)); |
| 505 | - d.setJhlc(String.valueOf(jhgl));//计划里程 | |
| 509 | + d.setJhlc(String.valueOf(jhzgl));//计划里程 | |
| 506 | 510 | d.setYygl(String.valueOf(zyygl));//运营公里 |
| 507 | - d.setSjjhlc(String.valueOf(sjgl));//实际计划里程 | |
| 511 | + d.setSjjhlc(String.valueOf(jhyygl));//实际计划里程 | |
| 508 | 512 | d.setRemMileage(String.valueOf(cjgl));//抽减里程 |
| 509 | 513 | d.setJhbc(String.valueOf(jhbc));//计划班次 |
| 510 | 514 | d.setCjbc(String.valueOf(cjbc));//抽检班次 |
| ... | ... | @@ -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 | 1162 | @Override |
| 633 | 1163 | public List<Singledata> singledatanew(Map<String, Object> map) { |
| 634 | 1164 | |
| ... | ... | @@ -787,27 +1317,25 @@ public class FormsServiceImpl implements FormsService { |
| 787 | 1317 | List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); |
| 788 | 1318 | for (int i = 0; i < listYlb.size(); i++) { |
| 789 | 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 | 1339 | newList.add(s); |
| 812 | 1340 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 813 | 1341 | if(cts != null && cts.size() > 0){ |
| ... | ... | @@ -817,65 +1345,75 @@ public class FormsServiceImpl implements FormsService { |
| 817 | 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 | 1395 | List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); |
| 855 | 1396 | for (int i = 0; i < listDlb.size(); i++) { |
| 856 | - | |
| 857 | 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 | 1417 | newList.add(s); |
| 880 | 1418 | Set<ChildTaskPlan> cts = s.getcTasks(); |
| 881 | 1419 | if(cts != null && cts.size() > 0){ |
| ... | ... | @@ -885,38 +1423,50 @@ public class FormsServiceImpl implements FormsService { |
| 885 | 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 | 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 | 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 | 250 | } |
| 251 | 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 | 131 | @Transactional |
| 132 | 132 | @Override |
| 133 | 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 | 136 | List<Object[]> listObjArray = Cacherepository.getSectionRouteCache(lineId, directions); |
| 137 | 137 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 138 | 138 | if(listObjArray.size()>0) { |
| ... | ... | @@ -297,6 +297,23 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 297 | 297 | } |
| 298 | 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 | 318 | @Override |
| 302 | 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 | 7 | import java.util.List; |
| 8 | 8 | import java.util.Map; |
| 9 | 9 | |
| 10 | -import org.mozilla.javascript.ObjArray; | |
| 11 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | -import org.springframework.data.jpa.domain.Specification; | |
| 13 | 11 | import org.springframework.stereotype.Service; |
| 14 | 12 | import org.springframework.transaction.annotation.Transactional; |
| 15 | 13 | |
| ... | ... | @@ -17,7 +15,6 @@ import com.alibaba.fastjson.JSONArray; |
| 17 | 15 | import com.alibaba.fastjson.JSONObject; |
| 18 | 16 | import com.bsth.common.ResponseCode; |
| 19 | 17 | import com.bsth.entity.Line; |
| 20 | -import com.bsth.entity.LineVersions; | |
| 21 | 18 | import com.bsth.entity.LsSectionRoute; |
| 22 | 19 | import com.bsth.entity.LsStationRoute; |
| 23 | 20 | import com.bsth.entity.Section; |
| ... | ... | @@ -40,7 +37,6 @@ import com.bsth.util.TransGPS; |
| 40 | 37 | import com.bsth.util.TransGPS.Location; |
| 41 | 38 | import com.bsth.util.Geo.GeoUtils; |
| 42 | 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 | 167 | String bsectionVectorS = null; |
| 172 | 168 | if(!sectionsBpoints.equals("")) |
| 173 | 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 | 171 | SectionRoute route = new SectionRoute(); |
| 176 | 172 | Line line = lineRepository.findOne(sectionRouteLine); |
| 177 | 173 | Section section = repository.findOne(sectionId); |
| ... | ... | @@ -663,7 +659,8 @@ public class SectionServiceImpl extends BaseServiceImpl<Section, Integer> implem |
| 663 | 659 | // 路段时长 |
| 664 | 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 | 664 | SectionRouteCache resultS = routeCacheRepository.findOne(sectionRouteId); |
| 668 | 665 | int old_code = resultS.getSectionrouteCode(); |
| 669 | 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 | 1172 | |
| 1173 | 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 | 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 | 26 | import com.bsth.entity.StationRouteCache; |
| 27 | 27 | import com.bsth.repository.LineInformationRepository; |
| 28 | 28 | import com.bsth.repository.LineRepository; |
| 29 | +import com.bsth.repository.LineVersionsRepository; | |
| 29 | 30 | import com.bsth.repository.SectionRepository; |
| 30 | 31 | import com.bsth.repository.SectionRouteCacheRepository; |
| 31 | 32 | import com.bsth.repository.SectionRouteRepository; |
| ... | ... | @@ -83,8 +84,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 83 | 84 | @Autowired |
| 84 | 85 | private SectionRouteCacheRepository sectionRouteCacheRepository; |
| 85 | 86 | |
| 86 | - private GeoUtils geoUtils; | |
| 87 | - | |
| 87 | + @Autowired | |
| 88 | + LineVersionsRepository lineVersionsRepository; | |
| 89 | + | |
| 88 | 90 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 89 | 91 | |
| 90 | 92 | /** |
| ... | ... | @@ -293,20 +295,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 293 | 295 | Integer stationId = Integer.parseInt(isHaveMap.get("id").toString()); |
| 294 | 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 | 301 | List<Station> list = new ArrayList<>(); |
| 311 | 302 | list.add(arg0); |
| 312 | 303 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); |
| ... | ... | @@ -318,12 +309,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 318 | 309 | station.setCreateDate(null); |
| 319 | 310 | station.setUpdateDate(null); |
| 320 | 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 | 317 | }else { |
| 328 | 318 | // 站点编码 |
| 329 | 319 | long stationCode = GetUIDAndCode.getStationId(); |
| ... | ... | @@ -417,8 +407,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 417 | 407 | // 中途站 |
| 418 | 408 | route.setStationMark("Z"); |
| 419 | 409 | } |
| 420 | - // 版本号 | |
| 421 | - route.setVersions(versions); | |
| 410 | + // 版本号(获取线路当前版本) | |
| 411 | + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId()); | |
| 412 | + route.setVersions(version); | |
| 422 | 413 | // 站点ID |
| 423 | 414 | route.setStation(arg0); |
| 424 | 415 | // 方向 |
| ... | ... | @@ -782,6 +773,153 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 782 | 773 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 783 | 774 | // 说明 |
| 784 | 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 | 923 | if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) { |
| 786 | 924 | stationId = Integer.parseInt(isHaveMap.get("id").toString()); |
| 787 | 925 | }else { |
| ... | ... | @@ -845,7 +983,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 845 | 983 | shapesType, versions, descriptions, createBy, updateBy,stationId); |
| 846 | 984 | } |
| 847 | 985 | Station station = repository.findOne(stationId); |
| 848 | - StationRoute arg0 = new StationRoute(); | |
| 986 | + StationRouteCache arg0 = new StationRouteCache(); | |
| 849 | 987 | // 距离 |
| 850 | 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 | 1030 | arg0.setDestroy(destroy); |
| 893 | 1031 | // 站点路由说明 |
| 894 | 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 | 1035 | resultMap.put("status", ResponseCode.SUCCESS); |
| 898 | 1036 | } catch (Exception e) { |
| 899 | 1037 | resultMap.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -926,7 +1064,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 926 | 1064 | String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); |
| 927 | 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 | 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 | 1151 | Station station = repository.findOne(stationId); |
| 1014 | 1152 | Line line = lineRepository.findOne(LineId); |
| 1015 | 1153 | StationRoute stationRoute = new StationRoute(); |
| 1016 | - stationRoute.setStationName(stationName); | |
| 1154 | + stationRoute.setStationName(stationRouteName); | |
| 1017 | 1155 | stationRoute.setId(stationRouteId); |
| 1018 | 1156 | stationRoute.setStationRouteCode(stationRouteCode); |
| 1019 | 1157 | stationRoute.setStation(station); |
| ... | ... | @@ -1200,15 +1338,15 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1200 | 1338 | sectionRoute.setLine(resultLine); |
| 1201 | 1339 | // 路段编码 |
| 1202 | 1340 | sectionRoute.setSectionCode(sectionCode); |
| 1203 | - // 版本 | |
| 1204 | - sectionRoute.setVersions(versions); | |
| 1341 | + // 版本号(获取线路当前版本) | |
| 1342 | + Integer version = lineVersionsRepository.findCurrentVersion(resultLine.getId()); | |
| 1343 | + sectionRoute.setVersions(version); | |
| 1205 | 1344 | sectionRoute.setDestroy(destroy); |
| 1206 | 1345 | // 方向 |
| 1207 | 1346 | sectionRoute.setDirections(directions); |
| 1208 | 1347 | // 保存路段 |
| 1209 | 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 | 1367 | String libraryPointstr = s.getbJwpoints(); |
| 1230 | 1368 | String points[] = libraryPointstr.toString().split(" "); |
| 1231 | 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 | 1374 | map.put("name", s.getStationName().toString()); |
| 1237 | 1375 | map.put("potion_lng", points[0]); |
| 1238 | 1376 | map.put("potion_lat", points[1]); |
| ... | ... | @@ -1372,20 +1510,9 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1372 | 1510 | Integer stationId = Integer.parseInt(stationsArray.getJSONObject(i).get("id").toString()); |
| 1373 | 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 | 1516 | List<Station> list = new ArrayList<>(); |
| 1390 | 1517 | list.add(arg0); |
| 1391 | 1518 | List<Station> stationlist = JSONArray.parseArray(JSON.toJSONString(list), Station.class); |
| ... | ... | @@ -1397,12 +1524,11 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1397 | 1524 | station.setCreateDate(null); |
| 1398 | 1525 | station.setUpdateDate(null); |
| 1399 | 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 | 1532 | }else { |
| 1407 | 1533 | // 站点编码 |
| 1408 | 1534 | long stationCode = GetUIDAndCode.getStationId(); |
| ... | ... | @@ -1735,4 +1861,36 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 1735 | 1861 | } |
| 1736 | 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 | 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 | 200 | |
| 201 | 201 | // 先查上行 |
| 202 | 202 | upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); |
| 203 | + Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | |
| 203 | 204 | int startId = 1; |
| 204 | - startId = packagStationXml(upStationsList, sBuffer, startId); | |
| 205 | + startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | |
| 205 | 206 | // 环线不查下行 |
| 206 | 207 | if(line.getLinePlayType() != 1){ |
| 207 | 208 | // 再查下行 |
| 208 | 209 | downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); |
| 209 | - packagStationXml(downStationsList, sBuffer, startId); | |
| 210 | + packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | |
| 210 | 211 | } |
| 211 | 212 | sBuffer.append("</StationList>"); |
| 212 | 213 | |
| ... | ... | @@ -223,6 +224,10 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 223 | 224 | sBuffer.append("</LinePointList>"); |
| 224 | 225 | sBuffer.append("</XL>"); |
| 225 | 226 | sBuffer.append("</XLs>"); |
| 227 | + // 临时添加,后面删除 | |
| 228 | + if(sBuffer.indexOf("<ZDXH>0</ZDXH>") != -1){ | |
| 229 | + return "0"; | |
| 230 | + } | |
| 226 | 231 | // 调用上传方法 |
| 227 | 232 | if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,sBuffer.toString()).isSuccess()){ |
| 228 | 233 | result = "success"; |
| ... | ... | @@ -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 | 270 | * 上传线路信息(按in_use上传) |
| 244 | 271 | */ |
| 245 | 272 | @Override |
| ... | ... | @@ -431,7 +458,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 431 | 458 | // 起点站的参数 |
| 432 | 459 | otherMap.put("stationMark","B"); |
| 433 | 460 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 434 | - sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) + "</FCZDXH>"); | |
| 461 | + sf.append("<FCZDXH>" + getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) + "</FCZDXH>"); | |
| 435 | 462 | sf.append("<FCZDBM>"+scheduleRealInfo.getQdzCode()+"</FCZDBM>"); |
| 436 | 463 | sf.append("<JHFCSJ>"+scheduleRealInfo.getFcsj()+"</JHFCSJ>"); |
| 437 | 464 | sf.append("<DFSJ>"+scheduleRealInfo.getDfsj()+"</DFSJ>"); |
| ... | ... | @@ -441,7 +468,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 441 | 468 | // 终点站的参数 |
| 442 | 469 | otherMap.put("stationMark","E"); |
| 443 | 470 | paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); |
| 444 | - sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap) +"</DDZDXH>"); | |
| 471 | + sf.append("<DDZDXH>"+ getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null) +"</DDZDXH>"); | |
| 445 | 472 | sf.append("<DDZDBM>"+scheduleRealInfo.getZdzCode()+"</DDZDBM>"); |
| 446 | 473 | sf.append("<JHDDSJ>"+scheduleRealInfo.getZdsj()+"</JHDDSJ>"); |
| 447 | 474 | sf.append("<SJDDSJ>"+scheduleRealInfo.getZdsjActual()+"</SJDDSJ>"); |
| ... | ... | @@ -768,13 +795,13 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 768 | 795 | // 起点站的参数 |
| 769 | 796 | otherMap.put("stationMark","B"); |
| 770 | 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 | 799 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); |
| 773 | 800 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 774 | 801 | // 起点站的参数 |
| 775 | 802 | otherMap.put("stationMark","E"); |
| 776 | 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 | 805 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 779 | 806 | .append("</JHDDSJ>"); |
| 780 | 807 | sBuffer.append("</BC>"); |
| ... | ... | @@ -883,14 +910,14 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 883 | 910 | // 起点站的参数 |
| 884 | 911 | otherMap.put("stationMark","B"); |
| 885 | 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 | 914 | sBuffer.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); |
| 888 | 915 | sBuffer.append("<DDZDMC>").append(BasicData.stationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir() |
| 889 | 916 | +"_"+ttInfoDetail.getZdzCode())).append("</DDZDMC>"); |
| 890 | 917 | // 起点站的参数 |
| 891 | 918 | otherMap.put("stationMark","E"); |
| 892 | 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 | 921 | sBuffer.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); |
| 895 | 922 | sBuffer.append("</BC>"); |
| 896 | 923 | } |
| ... | ... | @@ -1214,7 +1241,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1214 | 1241 | * |
| 1215 | 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 | 1245 | int size = stationsList.size(); |
| 1219 | 1246 | StationRoute srRoute; |
| 1220 | 1247 | HashMap<String,String> paraMap; |
| ... | ... | @@ -1231,7 +1258,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1231 | 1258 | } |
| 1232 | 1259 | paraMap = packageYgcStationNumParam(srRoute,null); |
| 1233 | 1260 | sBuffer.append("<Station>"); |
| 1234 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap)).append("</ZDXH>"); | |
| 1261 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | |
| 1235 | 1262 | sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); |
| 1236 | 1263 | sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); |
| 1237 | 1264 | sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); |
| ... | ... | @@ -1287,7 +1314,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1287 | 1314 | * @param map |
| 1288 | 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 | 1319 | String lineCode = map.get("lineCode"); |
| 1293 | 1320 | // 线路走向 0:上行 1:下行 |
| ... | ... | @@ -1305,9 +1332,15 @@ public class TrafficManageServiceImpl implements TrafficManageService{ |
| 1305 | 1332 | }else if(stationMark.equals("Z")){ |
| 1306 | 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 | 1341 | Integer number = null; |
| 1309 | 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 | 1344 | if(number != null){ |
| 1312 | 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 | 29 | |
| 30 | 30 | Map<String, List<Dlb>> updeteHistory(List<Map<String, Object>> list,String date, |
| 31 | 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 | 19 | |
| 20 | 20 | Map<String, Object> sumYlb(Map<String, Object> map); |
| 21 | 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 | 23 | List<Ylb> listYlb(Map<String, Object> map); |
| 24 | 24 | StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx); |
| 25 | 25 | |
| 26 | 26 | Map<String, Object> deleteIds(Map<String, Object> map) throws Exception; |
| 27 | 27 | |
| 28 | 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 | 39 | import com.bsth.entity.oil.Cyl; |
| 40 | 40 | import com.bsth.entity.oil.Dlb; |
| 41 | 41 | import com.bsth.entity.oil.Jdl; |
| 42 | -import com.bsth.entity.oil.Ylb; | |
| 42 | +import com.bsth.entity.oil.Nylog; | |
| 43 | 43 | import com.bsth.entity.oil.Ylxxb; |
| 44 | 44 | import com.bsth.entity.search.CustomerSpecs; |
| 45 | +import com.bsth.entity.sys.SysUser; | |
| 45 | 46 | import com.bsth.repository.CarsRepository; |
| 46 | 47 | import com.bsth.repository.oil.CdlRepository; |
| 47 | 48 | import com.bsth.repository.oil.CylRepository; |
| 48 | 49 | import com.bsth.repository.oil.DlbRepository; |
| 49 | 50 | import com.bsth.repository.oil.JdlRepository; |
| 51 | +import com.bsth.repository.oil.NylogRepository; | |
| 50 | 52 | import com.bsth.repository.oil.YlbRepository; |
| 51 | 53 | import com.bsth.repository.oil.YlxxbRepository; |
| 54 | +import com.bsth.security.util.SecurityUtils; | |
| 52 | 55 | import com.bsth.service.impl.BaseServiceImpl; |
| 53 | 56 | import com.bsth.service.oil.DlbService; |
| 54 | 57 | import com.bsth.service.realcontrol.ScheduleRealInfoService; |
| ... | ... | @@ -59,7 +62,8 @@ import com.bsth.util.BatchSaveUtils; |
| 59 | 62 | public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{ |
| 60 | 63 | @Autowired |
| 61 | 64 | DlbRepository repository; |
| 62 | - | |
| 65 | + @Autowired | |
| 66 | + NylogRepository nylogRepository; | |
| 63 | 67 | @Autowired |
| 64 | 68 | YlxxbRepository ylxxbRepository; |
| 65 | 69 | |
| ... | ... | @@ -96,6 +100,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 96 | 100 | calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天 |
| 97 | 101 | dBefore = calendar.getTime(); //得到前一天的时间 |
| 98 | 102 | String rq=sdf.format(dBefore); |
| 103 | +// String rq="2017-11-02"; | |
| 99 | 104 | String line=""; |
| 100 | 105 | //保留两位小数 |
| 101 | 106 | DecimalFormat df = new DecimalFormat("#.00"); |
| ... | ... | @@ -108,7 +113,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 108 | 113 | //当天加电信息表 |
| 109 | 114 | List<Jdl> jdlList=jdlRepository.JdlList(rq); |
| 110 | 115 | //前一天所有车辆最后进场班次信息 |
| 111 | - List<Dlb> dlListBe=repository.obtainYlbefore(rq, "", "", "", ""); | |
| 116 | +// List<Dlb> dlListBe=repository.obtainYlbefore(rq, "", "", "", ""); | |
| 112 | 117 | List<Cdl> cdyList=cdlRepository.obtainCdl(); |
| 113 | 118 | //从排班表中计算出行驶的总里程 |
| 114 | 119 | List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","",""); |
| ... | ... | @@ -140,14 +145,14 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 140 | 145 | Double jzl=0.0; |
| 141 | 146 | if(map.get("seqNumber").toString().equals("1")){ |
| 142 | 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 | 156 | if(fage){ |
| 152 | 157 | for (int y = 0; y < cdyList.size(); y++) { |
| 153 | 158 | Cdl cdl=cdyList.get(y); |
| ... | ... | @@ -391,8 +396,6 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 391 | 396 | |
| 392 | 397 | } |
| 393 | 398 | } |
| 394 | - | |
| 395 | - | |
| 396 | 399 | } |
| 397 | 400 | Double lc= Double.parseDouble(map.get("totalKilometers").toString()); |
| 398 | 401 | if(map.get("seqNumber").toString().equals("1")){ |
| ... | ... | @@ -485,7 +488,7 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 485 | 488 | new BatchSaveUtils<Dlb>().saveList2(addList, Dlb.class); |
| 486 | 489 | } catch (Exception e) { |
| 487 | 490 | // TODO: handle exception |
| 488 | - if(e.getMessage().indexOf("PK_YLB_UK")>0){ | |
| 491 | + if(e.getMessage().indexOf("PK_DLB_UK")>0){ | |
| 489 | 492 | newMap.put("fage", "存在相同数据,数据已经过滤"); |
| 490 | 493 | logger.info("获取:存在相同数据,数据已经过滤"); |
| 491 | 494 | } |
| ... | ... | @@ -498,6 +501,15 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 498 | 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 | 513 | newMap.put("status", ResponseCode.SUCCESS); |
| 502 | 514 | } catch (Exception e) { |
| 503 | 515 | // TODO Auto-generated catch block |
| ... | ... | @@ -576,57 +588,56 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 576 | 588 | if(map.get("nbbm_eq")!=null){ |
| 577 | 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 | 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 | 641 | newMap.put("status", ResponseCode.SUCCESS); |
| 631 | 642 | }catch(Exception e){ |
| 632 | 643 | newMap.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -840,6 +851,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 840 | 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 | 864 | newMap.put("status", ResponseCode.SUCCESS); |
| 844 | 865 | }catch(Exception e){ |
| 845 | 866 | newMap.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -940,6 +961,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 940 | 961 | } |
| 941 | 962 | t.setJcsx(jcsx); |
| 942 | 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 | 974 | map.put("status", ResponseCode.SUCCESS); |
| 944 | 975 | map.put("t", t); |
| 945 | 976 | return map; |
| ... | ... | @@ -959,6 +990,16 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 959 | 990 | Integer id =jsonObject.getInteger("id"); |
| 960 | 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 | 1003 | maps.put("status", ResponseCode.SUCCESS); |
| 963 | 1004 | } catch (Exception e) { |
| 964 | 1005 | maps.put("status", ResponseCode.ERROR); |
| ... | ... | @@ -983,17 +1024,22 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 983 | 1024 | for (int j = 0; j < dlbList.size(); j++) { |
| 984 | 1025 | Dlb t=dlbList.get(j); |
| 985 | 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 | 1043 | if(fage){ |
| 998 | 1044 | dlbList_del.add(t); |
| 999 | 1045 | } |
| ... | ... | @@ -1170,6 +1216,21 @@ public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbS |
| 1170 | 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 | 1236 | class NbbmJcsxMap implements Comparator<Map<String, Object>>{ | ... | ... |