Commit 6d8c8a5b998f1c89f4481156d814380b07433c0c
Merge branch 'minhang' of http://192.168.168.201:8888/panzhaov5/bsth_control into minhang
Showing
54 changed files
with
2349 additions
and
559 deletions
Too many changes to show.
To preserve performance only 54 of 1818 files are displayed.
src/main/java/com/bsth/WebAppConfiguration.java
| 1 | 1 | package com.bsth; |
| 2 | 2 | |
| 3 | -import javax.servlet.Filter; | |
| 4 | - | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 3 | +import com.bsth.filter.ResourceFilter; | |
| 4 | +import com.bsth.websocket.WebSocketHandshakeInterceptor; | |
| 5 | +import com.bsth.websocket.handler.RealControlSocketHandler; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 6 | 8 | import org.springframework.boot.context.embedded.FilterRegistrationBean; |
| 7 | 9 | import org.springframework.context.annotation.Bean; |
| 8 | 10 | import org.springframework.context.annotation.ComponentScan; |
| 9 | 11 | import org.springframework.context.annotation.Configuration; |
| 10 | 12 | import org.springframework.web.filter.CharacterEncodingFilter; |
| 11 | 13 | import org.springframework.web.filter.HttpPutFormContentFilter; |
| 12 | -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | |
| 13 | 14 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; |
| 14 | 15 | import org.springframework.web.socket.config.annotation.EnableWebSocket; |
| 15 | 16 | import org.springframework.web.socket.config.annotation.WebSocketConfigurer; |
| 16 | 17 | import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; |
| 18 | +import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; | |
| 17 | 19 | |
| 18 | -import com.bsth.filter.ResourceFilter; | |
| 19 | -import com.bsth.oplog.http.HttpOpLogInterceptor; | |
| 20 | -import com.bsth.websocket.WebSocketHandshakeInterceptor; | |
| 21 | -import com.bsth.websocket.handler.RealControlSocketHandler; | |
| 20 | +import javax.servlet.Filter; | |
| 22 | 21 | |
| 23 | 22 | @Configuration |
| 24 | 23 | @EnableWebSocket |
| ... | ... | @@ -27,6 +26,8 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS |
| 27 | 26 | |
| 28 | 27 | // @Autowired |
| 29 | 28 | // HttpOpLogInterceptor httpOpLogInterceptor; |
| 29 | + | |
| 30 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * @Title: httpPutFormContentFilter |
| ... | ... | @@ -75,4 +76,17 @@ public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebS |
| 75 | 76 | registry.addHandler(new RealControlSocketHandler(), "/sockjs/realcontrol").addInterceptors(new WebSocketHandshakeInterceptor()) |
| 76 | 77 | .withSockJS(); |
| 77 | 78 | } |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 增加websocket的输出缓冲区 | |
| 82 | + * @return | |
| 83 | + */ | |
| 84 | + @Bean | |
| 85 | + public ServletServerContainerFactoryBean createServletServerContainerFactoryBean() { | |
| 86 | + ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean(); | |
| 87 | + container.setMaxTextMessageBufferSize(52768); | |
| 88 | + container.setMaxBinaryMessageBufferSize(52768); | |
| 89 | + logger.info("Websocket factory returned"); | |
| 90 | + return container; | |
| 91 | + } | |
| 78 | 92 | } | ... | ... |
src/main/java/com/bsth/controller/SectionRouteController.java
| ... | ... | @@ -35,6 +35,17 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer |
| 35 | 35 | @Autowired |
| 36 | 36 | SectionRouteService routeService; |
| 37 | 37 | |
| 38 | + /** | |
| 39 | + * @param @param map | |
| 40 | + * @throws | |
| 41 | + * @Title: list | |
| 42 | + * @Description: TODO(多条件查询) | |
| 43 | + */ | |
| 44 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | |
| 45 | + public Iterable<SectionRoute> list(@RequestParam Map<String, Object> map) { | |
| 46 | + return routeService.list(map); | |
| 47 | + } | |
| 48 | + | |
| 38 | 49 | /** |
| 39 | 50 | * @Description :TODO(查询路段信息) |
| 40 | 51 | * |
| ... | ... | @@ -67,7 +78,7 @@ public class SectionRouteController extends BaseController<SectionRoute, Integer |
| 67 | 78 | * |
| 68 | 79 | * @return List<Map<String, Object>> |
| 69 | 80 | */ |
| 70 | - @RequestMapping(value = "/findUpStationRouteCode" , method = RequestMethod.GET) | |
| 81 | + @RequestMapping(value = "/findUpSectionRouteCode" , method = RequestMethod.GET) | |
| 71 | 82 | public List<Map<String, Object>> findUpStationRouteCode(@RequestParam Map<String, Object> map) { |
| 72 | 83 | return routeService.findUpSectionRouteCode(map); |
| 73 | 84 | } | ... | ... |
src/main/java/com/bsth/controller/StationController.java
| ... | ... | @@ -107,13 +107,9 @@ public class StationController extends BaseController<Station, Integer> { |
| 107 | 107 | */ |
| 108 | 108 | @RequestMapping(value="stationUpdate" , method = RequestMethod.POST) |
| 109 | 109 | public Map<String, Object> stationUpdate(@RequestParam Map<String, Object> map) { |
| 110 | - | |
| 111 | 110 | map.put("updateBy", ""); |
| 112 | - | |
| 113 | 111 | return service.stationUpdate(map); |
| 114 | - | |
| 115 | 112 | } |
| 116 | - | |
| 117 | 113 | /** |
| 118 | 114 | * @Description :TODO(查询站点编码) |
| 119 | 115 | * | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ChildTaskPlanController.java
| 1 | 1 | package com.bsth.controller.realcontrol; |
| 2 | 2 | |
| 3 | +import com.bsth.controller.BaseController; | |
| 4 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 5 | +import com.bsth.service.realcontrol.ChildTaskPlanService; | |
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 7 | +import org.springframework.web.bind.annotation.PathVariable; | |
| 3 | 8 | import org.springframework.web.bind.annotation.RequestMapping; |
| 9 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 4 | 10 | import org.springframework.web.bind.annotation.RestController; |
| 5 | 11 | |
| 6 | -import com.bsth.controller.BaseController; | |
| 7 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 12 | +import java.util.Map; | |
| 8 | 13 | |
| 9 | 14 | @RestController |
| 10 | 15 | @RequestMapping("/childTask") |
| 11 | 16 | public class ChildTaskPlanController extends BaseController<ChildTaskPlan, Long>{ |
| 12 | 17 | |
| 18 | + @Autowired | |
| 19 | + ChildTaskPlanService childTaskPlanService; | |
| 20 | + | |
| 21 | + @RequestMapping(value = "history", method = RequestMethod.POST) | |
| 22 | + public Map<String, Object> saveHistory(ChildTaskPlan childTask){ | |
| 23 | + return childTaskPlanService.saveHistory(childTask); | |
| 24 | + } | |
| 25 | + | |
| 26 | + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE) | |
| 27 | + public Map<String, Object> delHistory(@PathVariable("id") Long id){ | |
| 28 | + return childTaskPlanService.delHistory(id); | |
| 29 | + } | |
| 13 | 30 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
| ... | ... | @@ -45,8 +45,8 @@ public class RealMapController { |
| 45 | 45 | * @Description: TODO(获取线路的站点,路段路由) |
| 46 | 46 | */ |
| 47 | 47 | @RequestMapping(value = "/findRouteByLine") |
| 48 | - public Map<String, Object> findRouteByLine(@RequestParam String lineCode) { | |
| 49 | - return realMapService.findRouteByLine(lineCode); | |
| 48 | + public Map<String, Object> findRouteByLine(@RequestParam String idx) { | |
| 49 | + return realMapService.findRouteByLine(idx); | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | @RequestMapping(value = "/multiRouteByLine") | ... | ... |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -419,10 +419,10 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 419 | 419 | return scheduleRealInfoService.changeBcType(id, bcType, remarks); |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | -/* @RequestMapping(value="/history", method=RequestMethod.POST) | |
| 422 | + @RequestMapping(value="/history", method=RequestMethod.POST) | |
| 423 | 423 | public Map<String,Object> historySave(ScheduleRealInfo sch){ |
| 424 | 424 | return scheduleRealInfoService.historySave(sch); |
| 425 | - }*/ | |
| 425 | + } | |
| 426 | 426 | |
| 427 | 427 | |
| 428 | 428 | private static DateTimeFormatter fmtyyyyMMdd = DateTimeFormat.forPattern("yyyy-MM-dd"); |
| ... | ... | @@ -435,7 +435,7 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 435 | 435 | public List<String> dateArray(){ |
| 436 | 436 | List<String> rs = new ArrayList<>(); |
| 437 | 437 | |
| 438 | - long t = new Date().getTime() - ONE_DAY; | |
| 438 | + long t = new Date().getTime() - ONE_DAY - (1000 * 60 * 60 * 2); | |
| 439 | 439 | for(int i = 0; i < 5; i ++){ |
| 440 | 440 | rs.add(fmtyyyyMMdd.print(t)); |
| 441 | 441 | t -= ONE_DAY; |
| ... | ... | @@ -536,4 +536,24 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, |
| 536 | 536 | public List<ScheduleRealInfo> allLate2(@RequestParam String idx){ |
| 537 | 537 | return scheduleRealInfoService.allLate2(idx); |
| 538 | 538 | } |
| 539 | + | |
| 540 | + /** | |
| 541 | + * 添加一个临加到历史库 | |
| 542 | + * @param sch | |
| 543 | + * @return | |
| 544 | + */ | |
| 545 | + @RequestMapping(value = "history/add", method = RequestMethod.POST) | |
| 546 | + public Map<String, Object> addToHistory(ScheduleRealInfo sch){ | |
| 547 | + return scheduleRealInfoService.addToHistory(sch); | |
| 548 | + } | |
| 549 | + | |
| 550 | + /** | |
| 551 | + * 从历史库里删除临加班次 | |
| 552 | + * @param sch | |
| 553 | + * @return | |
| 554 | + */ | |
| 555 | + @RequestMapping(value = "history/{id}", method = RequestMethod.DELETE) | |
| 556 | + public Map<String, Object> deleteToHistory(@PathVariable("id") Long id){ | |
| 557 | + return scheduleRealInfoService.deleteToHistory(id); | |
| 558 | + } | |
| 539 | 559 | } | ... | ... |
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
| ... | ... | @@ -10,9 +10,9 @@ import org.springframework.web.bind.annotation.RequestMethod; |
| 10 | 10 | import org.springframework.web.bind.annotation.RequestParam; |
| 11 | 11 | import org.springframework.web.bind.annotation.RestController; |
| 12 | 12 | |
| 13 | -import java.util.HashSet; | |
| 13 | +import java.util.HashMap; | |
| 14 | 14 | import java.util.List; |
| 15 | -import java.util.Set; | |
| 15 | +import java.util.Map; | |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * 相关数据异常检测 |
| ... | ... | @@ -35,16 +35,19 @@ public class anomalyCheckController { |
| 35 | 35 | public void schRepeat(@RequestParam String nbbm){ |
| 36 | 36 | logger.info("前端通知,车辆 " + nbbm + "出现重复班次,开始检测..."); |
| 37 | 37 | List<ScheduleRealInfo> list = dayOfSchedule.findByNbbm(nbbm); |
| 38 | + logger.info("检测前,车辆班次数量:" + list.size()); | |
| 38 | 39 | |
| 39 | - Set<ScheduleRealInfo> set = new HashSet<>(); | |
| 40 | + Map<Long, ScheduleRealInfo> map = new HashMap<>(); | |
| 40 | 41 | for(ScheduleRealInfo sch : list){ |
| 41 | - if(!set.add(sch)){ | |
| 42 | - logger.info("出现一次重复班次,班次ID:" + sch.getId()); | |
| 42 | + if(map.containsKey(sch.getId())){ | |
| 43 | + logger.info("检测到重复ID: " + sch.getId()); | |
| 43 | 44 | } |
| 45 | + map.put(sch.getId(), sch); | |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | - if(set.size() > 0){ | |
| 47 | - dayOfSchedule.replaceByNbbm(nbbm, set); | |
| 48 | + logger.info("检测后,车辆班次数量:" + list.size()); | |
| 49 | + if(map.values().size() > 0){ | |
| 50 | + dayOfSchedule.replaceByNbbm(nbbm, map.values()); | |
| 48 | 51 | } |
| 49 | 52 | } |
| 50 | 53 | } | ... | ... |
src/main/java/com/bsth/controller/schedule/SchedulePlanInfoController.java renamed to src/main/java/com/bsth/controller/schedule/core/SchedulePlanInfoController.java
| 1 | -package com.bsth.controller.schedule; | |
| 2 | - | |
| 3 | -import com.bsth.common.ResponseCode; | |
| 4 | -import com.bsth.controller.BaseController; | |
| 5 | -import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 6 | -import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 7 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | -import org.springframework.web.bind.annotation.*; | |
| 9 | - | |
| 10 | -import java.util.Date; | |
| 11 | -import java.util.HashMap; | |
| 12 | -import java.util.List; | |
| 13 | -import java.util.Map; | |
| 14 | - | |
| 15 | -/** | |
| 16 | - * Created by xu on 16/6/16. | |
| 17 | - */ | |
| 18 | -@RestController | |
| 19 | -@RequestMapping("spic") | |
| 20 | -public class SchedulePlanInfoController extends BaseController<SchedulePlanInfo, Long> { | |
| 21 | - @Autowired | |
| 22 | - private SchedulePlanInfoService schedulePlanInfoService; | |
| 23 | - | |
| 24 | - @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET) | |
| 25 | - public List<SchedulePlanInfoService.GroupInfo> findGroupInfo( | |
| 26 | - @PathVariable(value = "xlid") Integer xlid, | |
| 27 | - @PathVariable(value = "date") Date scheduleDate) { | |
| 28 | - return schedulePlanInfoService.findGroupInfo(xlid, scheduleDate); | |
| 29 | - } | |
| 30 | - | |
| 31 | - @RequestMapping(value = "/groupinfos/update", method = RequestMethod.POST) | |
| 32 | - public Map<String, Object> updateGroupInfo(@RequestBody SchedulePlanInfoService.GroupInfoUpdate groupInfoUpdate) { | |
| 33 | - Map<String, Object> resultMap = new HashMap<>(); | |
| 34 | - try { | |
| 35 | - schedulePlanInfoService.updateGroupInfo(groupInfoUpdate); | |
| 36 | - | |
| 37 | - resultMap.put("status", ResponseCode.SUCCESS); | |
| 38 | - resultMap.put("msg", "更新成功"); | |
| 39 | - } catch (Exception exp) { | |
| 40 | - exp.printStackTrace(); | |
| 41 | - resultMap.put("status", ResponseCode.ERROR); | |
| 42 | - resultMap.put("msg", exp.getLocalizedMessage()); | |
| 43 | - } | |
| 44 | - | |
| 45 | - return resultMap; | |
| 46 | - } | |
| 47 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.bsth.common.ResponseCode; | |
| 4 | +import com.bsth.controller.schedule.BController; | |
| 5 | +import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 6 | +import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 8 | +import org.springframework.web.bind.annotation.*; | |
| 9 | + | |
| 10 | +import java.util.Date; | |
| 11 | +import java.util.HashMap; | |
| 12 | +import java.util.List; | |
| 13 | +import java.util.Map; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Created by xu on 17/5/1. | |
| 17 | + */ | |
| 18 | +@RestController | |
| 19 | +@RequestMapping("spic") | |
| 20 | +public class SchedulePlanInfoController extends BController<SchedulePlanInfo, Long> { | |
| 21 | + @Autowired | |
| 22 | + private SchedulePlanInfoService schedulePlanInfoService; | |
| 23 | + | |
| 24 | + @RequestMapping(value = "/groupextinfos/{xlid}/{date}", method = RequestMethod.GET) | |
| 25 | + public Map<String, Object> findGroupInfoExt( | |
| 26 | + @PathVariable(value = "xlid") Integer xlid, | |
| 27 | + @PathVariable(value = "date") Date scheduleDate) { | |
| 28 | + Map<String, Object> resultMap = new HashMap<>(); | |
| 29 | + try { | |
| 30 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 31 | + resultMap.put("data", schedulePlanInfoService.findSchedulePlanGroupInfo(xlid, scheduleDate)); | |
| 32 | + | |
| 33 | + } catch (Exception exp) { | |
| 34 | + exp.printStackTrace(); | |
| 35 | + resultMap.put("status", ResponseCode.ERROR); | |
| 36 | + resultMap.put("msg", exp.getLocalizedMessage()); | |
| 37 | + } | |
| 38 | + | |
| 39 | + return resultMap; | |
| 40 | + } | |
| 41 | + | |
| 42 | + | |
| 43 | +// ------------------------ 老版本 ----------------------// | |
| 44 | + @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET) | |
| 45 | + public List<SchedulePlanInfoService.GroupInfo> findGroupInfo( | |
| 46 | + @PathVariable(value = "xlid") Integer xlid, | |
| 47 | + @PathVariable(value = "date") Date scheduleDate) { | |
| 48 | + return schedulePlanInfoService.findGroupInfo(xlid, scheduleDate); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @RequestMapping(value = "/groupinfos/update", method = RequestMethod.POST) | |
| 52 | + public Map<String, Object> updateGroupInfo(@RequestBody SchedulePlanInfoService.GroupInfoUpdate groupInfoUpdate) { | |
| 53 | + Map<String, Object> resultMap = new HashMap<>(); | |
| 54 | + try { | |
| 55 | + schedulePlanInfoService.updateGroupInfo(groupInfoUpdate); | |
| 56 | + | |
| 57 | + resultMap.put("status", ResponseCode.SUCCESS); | |
| 58 | + resultMap.put("msg", "更新成功"); | |
| 59 | + } catch (Exception exp) { | |
| 60 | + exp.printStackTrace(); | |
| 61 | + resultMap.put("status", ResponseCode.ERROR); | |
| 62 | + resultMap.put("msg", exp.getLocalizedMessage()); | |
| 63 | + } | |
| 64 | + | |
| 65 | + return resultMap; | |
| 66 | + } | |
| 67 | +} | ... | ... |
src/main/java/com/bsth/data/BasicData.java
| ... | ... | @@ -31,7 +31,7 @@ public class BasicData implements CommandLineRunner { |
| 31 | 31 | //公司代码和公司名对照(K: 公司编码,V:公司名) |
| 32 | 32 | public static Map<String, String> businessCodeNameMap; |
| 33 | 33 | |
| 34 | - //分公司公司代码和分公司公司名对照(K: 公司编码+分公司编码,V:分公司公司名) | |
| 34 | + //分公司公司代码和分公司公司名对照(K: 公司编码_分公司编码,V:分公司公司名) | |
| 35 | 35 | public static Map<String, String> businessFgsCodeNameMap; |
| 36 | 36 | |
| 37 | 37 | //设备号和车辆自编号 (K: 设备编码 ,V:车辆自编号) |
| ... | ... | @@ -333,7 +333,7 @@ public class BasicData implements CommandLineRunner { |
| 333 | 333 | |
| 334 | 334 | perTempMap.put(jobCode, p); |
| 335 | 335 | |
| 336 | - allPersonMap.put(jobCode.substring(jobCode.indexOf("-")+1), p.getPersonnelName()); | |
| 336 | + allPersonMap.put(jobCode, p.getPersonnelName()); | |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | jsyMap = jsyTempMap; | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
| ... | ... | @@ -270,7 +270,7 @@ public class InOutStationSignalHandle extends SignalHandle{ |
| 270 | 270 | |
| 271 | 271 | //通知客户端 |
| 272 | 272 | sendUtils.sendZdsj(sch, lpNext, doneSum); |
| 273 | - | |
| 273 | + logger.info("车辆:" + sch.getClZbh() + " 班次:" + sch.getDfsj() + "到终点, 时间:" + sch.getZdsjActual()); | |
| 274 | 274 | //准备执行下一个班次 |
| 275 | 275 | if (next != null) { |
| 276 | 276 | //将gps转换为下一个班次走向的站内信号 | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
| ... | ... | @@ -96,7 +96,10 @@ public class GeoUtils { |
| 96 | 96 | public static double getDistanceFromLine(LineString line, Point p){ |
| 97 | 97 | Point s = line.getStartPoint(); |
| 98 | 98 | Point e = line.getEndPoint(); |
| 99 | + return getDistanceFromLine(s, e, p); | |
| 100 | + } | |
| 99 | 101 | |
| 102 | + public static double getDistanceFromLine(Point s, Point e, Point p){ | |
| 100 | 103 | double d1 = getDistance(s, p); |
| 101 | 104 | double d2 = getDistance(p, e); |
| 102 | 105 | double d3 = getDistance(s, e); |
| ... | ... | @@ -147,4 +150,92 @@ public class GeoUtils { |
| 147 | 150 | public static boolean overdue(GpsEntity prevGps, GpsEntity gps) { |
| 148 | 151 | return gps.getTimestamp() - prevGps.getTimestamp() < 120000; |
| 149 | 152 | } |
| 153 | + | |
| 154 | + /** | |
| 155 | + * 计算2条直线的最短距离 | |
| 156 | + * @param p1 | |
| 157 | + * @param p2 | |
| 158 | + * @param p3 | |
| 159 | + * @param p4 | |
| 160 | + * @return | |
| 161 | + */ | |
| 162 | + public static double getDistanceLineToLine(Point p1, Point p2, Point p3, Point p4){ | |
| 163 | + double distance; | |
| 164 | + double x1 = p1.getX(); //A点坐标(x1,y1,z1) | |
| 165 | + double y1 = p1.getY(); | |
| 166 | + double z1 = 0; | |
| 167 | + double x2 = p2.getX(); //B点坐标(x2,y2,z2) | |
| 168 | + double y2 = p2.getY(); | |
| 169 | + double z2 = 0; | |
| 170 | + double x3 = p3.getX(); //C点坐标(x3,y3,z3) | |
| 171 | + double y3 = p3.getY(); | |
| 172 | + double z3 = 0; | |
| 173 | + double x4 = p4.getX(); //D点坐标(x4,y4,z4) | |
| 174 | + double y4 = p4.getY(); | |
| 175 | + double z4 = 0; | |
| 176 | + | |
| 177 | + double a = (x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1); | |
| 178 | + double b = -((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3)+(z2-z1)*(z4-z3)); | |
| 179 | + double c = -((x1-x2)*(x1-x3)+(y1-y2)*(y1-y3)+(z1-z2)*(z1-z3)); | |
| 180 | + | |
| 181 | + double d = -((x2-x1)*(x4-x3)+(y2-y1)*(y4-y3)+(z2-z1)*(z4-z3)); | |
| 182 | + double e = (x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)+(z4-z3)*(z4-z3); | |
| 183 | + double f = -((x1-x3)*(x4-x3)+(y1-y3)*(y4-y3)+(z1-z3)*(z4-z3)); | |
| 184 | + | |
| 185 | + //平行 | |
| 186 | + if ((a*e-b*d)==0&&(b*d-a*e)==0) | |
| 187 | + { | |
| 188 | + double d1 = getDistance(p1, p3); | |
| 189 | + double d2 = getDistance(p1, p4); | |
| 190 | + distance = (d1<d2)?d1:d2; | |
| 191 | + return distance; | |
| 192 | + } | |
| 193 | + | |
| 194 | + double s = (b*f-e*c)/(a*e-b*d); | |
| 195 | + double t = (a*f-d*c)/(b*d-a*e); | |
| 196 | + | |
| 197 | + //说明P点落在线段AB上,Q点落在线段CD上 | |
| 198 | + if(0<=s&&s<=1&&0<=t&&t<=1) | |
| 199 | + { | |
| 200 | + //2条线段的公垂线段PQ; | |
| 201 | + //P点坐标 | |
| 202 | + double X = x1+s*(x2-x1); | |
| 203 | + double Y = y1+s*(y2-y1); | |
| 204 | + double Z = z1+s*(z2-z1); | |
| 205 | + //Q点坐标 | |
| 206 | + double U = x3+t*(x4-x3); | |
| 207 | + double V = y3+t*(y4-y3); | |
| 208 | + double W = z3+t*(z4-z3); | |
| 209 | + Point p = geometryFactory.createPoint(new Coordinate(X, Y, Z)); | |
| 210 | + Point q = geometryFactory.createPoint(new Coordinate(U, V, W)); | |
| 211 | + distance = getDistance(p, q); | |
| 212 | + } | |
| 213 | + else | |
| 214 | + { | |
| 215 | + double d1 = getDistanceFromLine(p3,p4,p1); | |
| 216 | + double d2 = getDistanceFromLine(p3,p4,p2); | |
| 217 | + double d3 = getDistanceFromLine(p1,p2,p3); | |
| 218 | + double d4 = getDistanceFromLine(p1,p2,p4); | |
| 219 | + distance = (d1<d2)?d1:d2; | |
| 220 | + distance = (distance<d3)?distance:d3; | |
| 221 | + distance = (distance<d4)?distance:d4; | |
| 222 | + } | |
| 223 | + | |
| 224 | + return distance; | |
| 225 | + } | |
| 226 | + | |
| 227 | + /** | |
| 228 | + * 计算点 到 线的垂直交点 | |
| 229 | + * @param lp1 | |
| 230 | + * @param lp2 | |
| 231 | + * @param p | |
| 232 | + * @return | |
| 233 | + */ | |
| 234 | + public static Point perpendularPoint(Point lp1, Point lp2, Point p){ | |
| 235 | + double a = lp1.getX() - lp2.getX(), b = lp2.getY() - lp1.getY(), c = lp1.getY() * lp2.getX() - lp2.getY() * lp1.getX(); | |
| 236 | + double lon = (Math.pow(b, 2) * p.getY() - a * b * p.getX() - a * c) / (Math.pow(a, 2) + Math.pow(b, 2)); | |
| 237 | + double lat = (Math.pow(a, 2) * p.getX() - a * b * p.getY() - b * c) / (Math.pow(a, 2) + Math.pow(b, 2)); | |
| 238 | + | |
| 239 | + return geometryFactory.createPoint(new Coordinate(lat, lon)); | |
| 240 | + } | |
| 150 | 241 | } | ... | ... |
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
src/main/java/com/bsth/data/gpsdata/thread/GpsDataLoaderThread.java
| ... | ... | @@ -10,6 +10,7 @@ import com.bsth.data.gpsdata.recovery.GpsDataRecovery; |
| 10 | 10 | import com.bsth.util.ConfigUtil; |
| 11 | 11 | import org.apache.commons.lang3.StringUtils; |
| 12 | 12 | import org.apache.http.HttpEntity; |
| 13 | +import org.apache.http.client.config.RequestConfig; | |
| 13 | 14 | import org.apache.http.client.methods.CloseableHttpResponse; |
| 14 | 15 | import org.apache.http.client.methods.HttpGet; |
| 15 | 16 | import org.apache.http.impl.client.CloseableHttpClient; |
| ... | ... | @@ -69,6 +70,11 @@ public class GpsDataLoaderThread extends Thread { |
| 69 | 70 | try { |
| 70 | 71 | httpClient = HttpClients.createDefault(); |
| 71 | 72 | HttpGet get = new HttpGet(url); |
| 73 | + //超时时间 | |
| 74 | + RequestConfig requestConfig = RequestConfig.custom() | |
| 75 | + .setConnectTimeout(2000).setConnectionRequestTimeout(1000) | |
| 76 | + .setSocketTimeout(2000).build(); | |
| 77 | + get.setConfig(requestConfig); | |
| 72 | 78 | |
| 73 | 79 | response = httpClient.execute(get); |
| 74 | 80 | |
| ... | ... | @@ -108,6 +114,7 @@ public class GpsDataLoaderThread extends Thread { |
| 108 | 114 | //有更新的点位 |
| 109 | 115 | updateList.add(gps); |
| 110 | 116 | } |
| 117 | + logger.info("全量点:"+ list.size() +",更新点" + updateList.size()); | |
| 111 | 118 | //分析数据 |
| 112 | 119 | gpsRealAnalyse.analyse(updateList); |
| 113 | 120 | } else | ... | ... |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| ... | ... | @@ -480,7 +480,7 @@ public class DayOfSchedule implements CommandLineRunner { |
| 480 | 480 | public List<ScheduleRealInfo> findByLineCode(String lineCode) { |
| 481 | 481 | List<ScheduleRealInfo> rs = new ArrayList<>(); |
| 482 | 482 | |
| 483 | - Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 483 | + Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 484 | 484 | for (ScheduleRealInfo sch : schs) { |
| 485 | 485 | if (sch.getXlBm().equals(lineCode)) |
| 486 | 486 | rs.add(sch); |
| ... | ... | @@ -489,6 +489,22 @@ public class DayOfSchedule implements CommandLineRunner { |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
| 492 | + * @Title: findByLineCode | |
| 493 | + * @Description: TODO(lineList 获取班次) | |
| 494 | + */ | |
| 495 | + public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { | |
| 496 | + ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | |
| 497 | + | |
| 498 | + Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 499 | + for (ScheduleRealInfo sch : schs) { | |
| 500 | + if(lineList.contains(sch.getXlBm())){ | |
| 501 | + mMap.put(sch.getXlBm(), sch); | |
| 502 | + } | |
| 503 | + } | |
| 504 | + return mMap.asMap(); | |
| 505 | + } | |
| 506 | + | |
| 507 | + /** | |
| 492 | 508 | * @Title: findCarByLineCode |
| 493 | 509 | * @Description: TODO(线路下运营的车辆) |
| 494 | 510 | */ |
| ... | ... | @@ -870,16 +886,14 @@ public class DayOfSchedule implements CommandLineRunner { |
| 870 | 886 | */ |
| 871 | 887 | public List<ScheduleRealInfo> changeCar(ScheduleRealInfo sch, String newClZbh) { |
| 872 | 888 | List<ScheduleRealInfo> ups = new ArrayList<>(); |
| 873 | - /*String oldClzbh = sch.getClZbh(); | |
| 874 | - if (oldClzbh.equals(newClZbh)) | |
| 875 | - return ups;*/ | |
| 876 | - | |
| 877 | 889 | |
| 878 | 890 | //变更相关映射信息 |
| 879 | 891 | nbbmScheduleMap.remove(sch.getClZbh(), sch); |
| 880 | 892 | |
| 881 | 893 | sch.setClZbh(newClZbh); |
| 882 | - nbbmScheduleMap.put(newClZbh, sch); | |
| 894 | + if(!nbbmScheduleMap.containsEntry(newClZbh, sch)){ | |
| 895 | + nbbmScheduleMap.put(newClZbh, sch); | |
| 896 | + } | |
| 883 | 897 | |
| 884 | 898 | //重新计算班次应到时间 |
| 885 | 899 | //ups.addAll(updateQdzTimePlan(oldClzbh)); |
| ... | ... | @@ -996,11 +1010,9 @@ public class DayOfSchedule implements CommandLineRunner { |
| 996 | 1010 | * @param nbbm |
| 997 | 1011 | * @param sets |
| 998 | 1012 | */ |
| 999 | - public void replaceByNbbm(String nbbm, Set<ScheduleRealInfo> sets){ | |
| 1013 | + public void replaceByNbbm(String nbbm, Collection<ScheduleRealInfo> sets){ | |
| 1000 | 1014 | nbbmScheduleMap.removeAll(nbbm); |
| 1001 | 1015 | nbbmScheduleMap.putAll(nbbm, sets); |
| 1002 | - //重新计算班次应到时间 | |
| 1003 | - updateQdzTimePlan(nbbm); | |
| 1004 | 1016 | } |
| 1005 | 1017 | |
| 1006 | 1018 | /** | ... | ... |
src/main/java/com/bsth/entity/schedule/SchedulePlanInfo.java
| ... | ... | @@ -2,6 +2,7 @@ package com.bsth.entity.schedule; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.Line; |
| 4 | 4 | import com.bsth.entity.sys.SysUser; |
| 5 | +import com.bsth.service.schedule.rules.rerun.RerunRule_input; | |
| 5 | 6 | import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output; |
| 6 | 7 | import org.apache.commons.lang3.StringUtils; |
| 7 | 8 | |
| ... | ... | @@ -164,6 +165,114 @@ public class SchedulePlanInfo { |
| 164 | 165 | |
| 165 | 166 | public SchedulePlanInfo() {} |
| 166 | 167 | |
| 168 | + // 对应班车套跑 | |
| 169 | + public void setRerunInfoDybc(RerunRule_input rerunRule_input) { | |
| 170 | + this.cl = rerunRule_input.getCl(); | |
| 171 | + this.clZbh = rerunRule_input.getZbh(); | |
| 172 | + this.j = rerunRule_input.getJ(); | |
| 173 | + this.jGh = rerunRule_input.getJgh(); | |
| 174 | + this.jName = rerunRule_input.getJname(); | |
| 175 | + this.s = rerunRule_input.getS(); | |
| 176 | + this.sGh = rerunRule_input.getSgh(); | |
| 177 | + this.sName = rerunRule_input.getSname(); | |
| 178 | + } | |
| 179 | + | |
| 180 | + // 对应路牌套跑 | |
| 181 | + public void setRerunInfoDylp(CarConfigInfo cc, List ec, String useType, String useHrType) { | |
| 182 | + if ("hr".equals(useType)) { | |
| 183 | + // 关联的驾驶员 | |
| 184 | + EmployeeConfigInfo employeeConfigInfo = null; | |
| 185 | + if ("all".equals(useHrType)) { | |
| 186 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 187 | + } else if ("zb".equals(useHrType)) { | |
| 188 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 189 | + } else if ("wb".equals(useHrType)) { | |
| 190 | + if (ec.size() > 1) { | |
| 191 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(1); | |
| 192 | + } else { | |
| 193 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 194 | + } | |
| 195 | + } | |
| 196 | + | |
| 197 | + this.j = employeeConfigInfo.getJsy().getId(); | |
| 198 | +// this.jGh = employeeConfigInfo.getJsy().getJobCode(); | |
| 199 | + if (StringUtils.isNotEmpty(employeeConfigInfo.getJsy().getJobCode())) { | |
| 200 | + String[] jsy_temp = employeeConfigInfo.getJsy().getJobCode().split("-"); | |
| 201 | + if (jsy_temp.length > 1) { | |
| 202 | + this.jGh = jsy_temp[1]; | |
| 203 | + } else { | |
| 204 | + this.jGh = jsy_temp[0]; | |
| 205 | + } | |
| 206 | + } | |
| 207 | + this.jName = employeeConfigInfo.getJsy().getPersonnelName(); | |
| 208 | + // 关联的售票员 | |
| 209 | + if (employeeConfigInfo.getSpy() != null) { | |
| 210 | + this.s = employeeConfigInfo.getSpy().getId(); | |
| 211 | +// this.sGh = employeeConfigInfo.getSpy().getJobCode(); | |
| 212 | + if (StringUtils.isNotEmpty(employeeConfigInfo.getSpy().getJobCode())) { | |
| 213 | + String[] spy_temp = employeeConfigInfo.getSpy().getJobCode().split("-"); | |
| 214 | + if (spy_temp.length > 1) { | |
| 215 | + this.sGh = spy_temp[1]; | |
| 216 | + } else { | |
| 217 | + this.sGh = spy_temp[0]; | |
| 218 | + } | |
| 219 | + } | |
| 220 | + | |
| 221 | + this.sName = employeeConfigInfo.getSpy().getPersonnelName(); | |
| 222 | + } | |
| 223 | + } else if ("hc".equals(useType)) { | |
| 224 | + // 关联的车辆信息 | |
| 225 | + this.cl = cc.getCl().getId(); // 车辆id | |
| 226 | + this.clZbh = cc.getCl().getInsideCode(); // 自编号/内部编号 | |
| 227 | + } else { // 所有的 | |
| 228 | + // 关联的车辆信息 | |
| 229 | + this.cl = cc.getCl().getId(); // 车辆id | |
| 230 | + this.clZbh = cc.getCl().getInsideCode(); // 自编号/内部编号 | |
| 231 | + | |
| 232 | + // 关联的驾驶员 | |
| 233 | + EmployeeConfigInfo employeeConfigInfo = null; | |
| 234 | + if ("all".equals(useHrType)) { | |
| 235 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 236 | + } else if ("zb".equals(useHrType)) { | |
| 237 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 238 | + } else if ("wb".equals(useHrType)) { | |
| 239 | + if (ec.size() > 1) { | |
| 240 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(1); | |
| 241 | + } else { | |
| 242 | + employeeConfigInfo = (EmployeeConfigInfo) ec.get(0); | |
| 243 | + } | |
| 244 | + } | |
| 245 | + | |
| 246 | + this.j = employeeConfigInfo.getJsy().getId(); | |
| 247 | +// this.jGh = employeeConfigInfo.getJsy().getJobCode(); | |
| 248 | + if (StringUtils.isNotEmpty(employeeConfigInfo.getJsy().getJobCode())) { | |
| 249 | + String[] jsy_temp = employeeConfigInfo.getJsy().getJobCode().split("-"); | |
| 250 | + if (jsy_temp.length > 1) { | |
| 251 | + this.jGh = jsy_temp[1]; | |
| 252 | + } else { | |
| 253 | + this.jGh = jsy_temp[0]; | |
| 254 | + } | |
| 255 | + } | |
| 256 | + this.jName = employeeConfigInfo.getJsy().getPersonnelName(); | |
| 257 | + // 关联的售票员 | |
| 258 | + if (employeeConfigInfo.getSpy() != null) { | |
| 259 | + this.s = employeeConfigInfo.getSpy().getId(); | |
| 260 | +// this.sGh = employeeConfigInfo.getSpy().getJobCode(); | |
| 261 | + if (StringUtils.isNotEmpty(employeeConfigInfo.getSpy().getJobCode())) { | |
| 262 | + String[] spy_temp = employeeConfigInfo.getSpy().getJobCode().split("-"); | |
| 263 | + if (spy_temp.length > 1) { | |
| 264 | + this.sGh = spy_temp[1]; | |
| 265 | + } else { | |
| 266 | + this.sGh = spy_temp[0]; | |
| 267 | + } | |
| 268 | + } | |
| 269 | + | |
| 270 | + this.sName = employeeConfigInfo.getSpy().getPersonnelName(); | |
| 271 | + } | |
| 272 | + } | |
| 273 | + | |
| 274 | + } | |
| 275 | + | |
| 167 | 276 | public SchedulePlanInfo( |
| 168 | 277 | Line xl, |
| 169 | 278 | ScheduleResult_output scheduleResult_output, | ... | ... |
src/main/java/com/bsth/entity/schedule/rule/RerunRule.java
| ... | ... | @@ -53,7 +53,7 @@ public class RerunRule extends BEntity { |
| 53 | 53 | private GuideboardInfo rerunLp; |
| 54 | 54 | /** 套跑班次(时刻表明细ids,使用逗号连接) */ |
| 55 | 55 | private String rerunTtinfodetailIds; |
| 56 | - /** 套跑班次(对应具体班次的发车时间,使用逗号连接,重复的时间会去除) */ | |
| 56 | + /** 套跑班次(对应具体班次的发车时间,使用逗号连接) */ | |
| 57 | 57 | private String rerunTtinfodetailFcsjs; |
| 58 | 58 | |
| 59 | 59 | |
| ... | ... | @@ -68,15 +68,30 @@ public class RerunRule extends BEntity { |
| 68 | 68 | /** 使用路牌 */ |
| 69 | 69 | @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) |
| 70 | 70 | private GuideboardInfo useLp; |
| 71 | + /** 对应路牌替换类型,hr;换人,hc:换车,all:换人换车 */ | |
| 72 | + private String useType; | |
| 73 | + /** 使用换人类型(zb:早班的人,wb:晚班的人,all:不分早晚班) */ | |
| 74 | + private String useHrtype; | |
| 71 | 75 | |
| 72 | 76 | //--------- 对应班车 ----------/ |
| 73 | 77 | /** 车辆配置 */ |
| 74 | 78 | @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) |
| 75 | 79 | private CarConfigInfo useCarConfig; |
| 80 | + | |
| 81 | + private Integer cl; // 冗余字段(车辆id) | |
| 82 | + private String clZbh; // 冗余字段(车辆自编号) | |
| 83 | + | |
| 76 | 84 | /** 人员配置 */ |
| 77 | 85 | @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) |
| 78 | 86 | private EmployeeConfigInfo useEmployeeConfig; |
| 79 | 87 | |
| 88 | + private Integer j; // 冗余字段(驾驶员Id) | |
| 89 | + private String jGh; // 冗余字段(驾驶员工号) | |
| 90 | + private String jName; // 冗余字段(驾驶员姓名) | |
| 91 | + private Integer s; // 冗余字段(售票员Id) | |
| 92 | + private String sGh; // 冗余字段(售票员工号) | |
| 93 | + private String sName; // 冗余字段(售票员姓名) | |
| 94 | + | |
| 80 | 95 | /** 是否删除(标记) */ |
| 81 | 96 | @Column(nullable = false) |
| 82 | 97 | private Boolean isCancel = false; |
| ... | ... | @@ -176,4 +191,84 @@ public class RerunRule extends BEntity { |
| 176 | 191 | public void setRerunTtinfodetailFcsjs(String rerunTtinfodetailFcsjs) { |
| 177 | 192 | this.rerunTtinfodetailFcsjs = rerunTtinfodetailFcsjs; |
| 178 | 193 | } |
| 194 | + | |
| 195 | + public Integer getCl() { | |
| 196 | + return cl; | |
| 197 | + } | |
| 198 | + | |
| 199 | + public void setCl(Integer cl) { | |
| 200 | + this.cl = cl; | |
| 201 | + } | |
| 202 | + | |
| 203 | + public String getClZbh() { | |
| 204 | + return clZbh; | |
| 205 | + } | |
| 206 | + | |
| 207 | + public void setClZbh(String clZbh) { | |
| 208 | + this.clZbh = clZbh; | |
| 209 | + } | |
| 210 | + | |
| 211 | + public Integer getJ() { | |
| 212 | + return j; | |
| 213 | + } | |
| 214 | + | |
| 215 | + public void setJ(Integer j) { | |
| 216 | + this.j = j; | |
| 217 | + } | |
| 218 | + | |
| 219 | + public String getjGh() { | |
| 220 | + return jGh; | |
| 221 | + } | |
| 222 | + | |
| 223 | + public void setjGh(String jGh) { | |
| 224 | + this.jGh = jGh; | |
| 225 | + } | |
| 226 | + | |
| 227 | + public String getjName() { | |
| 228 | + return jName; | |
| 229 | + } | |
| 230 | + | |
| 231 | + public void setjName(String jName) { | |
| 232 | + this.jName = jName; | |
| 233 | + } | |
| 234 | + | |
| 235 | + public Integer getS() { | |
| 236 | + return s; | |
| 237 | + } | |
| 238 | + | |
| 239 | + public void setS(Integer s) { | |
| 240 | + this.s = s; | |
| 241 | + } | |
| 242 | + | |
| 243 | + public String getsGh() { | |
| 244 | + return sGh; | |
| 245 | + } | |
| 246 | + | |
| 247 | + public void setsGh(String sGh) { | |
| 248 | + this.sGh = sGh; | |
| 249 | + } | |
| 250 | + | |
| 251 | + public String getsName() { | |
| 252 | + return sName; | |
| 253 | + } | |
| 254 | + | |
| 255 | + public void setsName(String sName) { | |
| 256 | + this.sName = sName; | |
| 257 | + } | |
| 258 | + | |
| 259 | + public String getUseType() { | |
| 260 | + return useType; | |
| 261 | + } | |
| 262 | + | |
| 263 | + public void setUseType(String useType) { | |
| 264 | + this.useType = useType; | |
| 265 | + } | |
| 266 | + | |
| 267 | + public String getUseHrtype() { | |
| 268 | + return useHrtype; | |
| 269 | + } | |
| 270 | + | |
| 271 | + public void setUseHrtype(String useHrtype) { | |
| 272 | + this.useHrtype = useHrtype; | |
| 273 | + } | |
| 179 | 274 | } | ... | ... |
src/main/java/com/bsth/entity/schedule/rule/ScheduleRule1Flat.java
| ... | ... | @@ -76,6 +76,10 @@ public class ScheduleRule1Flat extends BEntity { |
| 76 | 76 | /** 翻班格式(类似格式:1110011)*/ |
| 77 | 77 | private String fbgs; |
| 78 | 78 | |
| 79 | + /** 备注 */ | |
| 80 | + @Column(length = 1000) | |
| 81 | + private String remark; | |
| 82 | + | |
| 79 | 83 | public Long getId() { |
| 80 | 84 | return id; |
| 81 | 85 | } |
| ... | ... | @@ -164,4 +168,11 @@ public class ScheduleRule1Flat extends BEntity { |
| 164 | 168 | this.fbgs = fbgs; |
| 165 | 169 | } |
| 166 | 170 | |
| 171 | + public String getRemark() { | |
| 172 | + return remark; | |
| 173 | + } | |
| 174 | + | |
| 175 | + public void setRemark(String remark) { | |
| 176 | + this.remark = remark; | |
| 177 | + } | |
| 167 | 178 | } | ... | ... |
src/main/java/com/bsth/entity/schedule/temp/SchedulePlanRuleResult.java
| ... | ... | @@ -3,6 +3,8 @@ package com.bsth.entity.schedule.temp; |
| 3 | 3 | import com.bsth.entity.schedule.SchedulePlan; |
| 4 | 4 | |
| 5 | 5 | import javax.persistence.*; |
| 6 | +import java.sql.PreparedStatement; | |
| 7 | +import java.sql.SQLException; | |
| 6 | 8 | import java.util.Date; |
| 7 | 9 | |
| 8 | 10 | /** |
| ... | ... | @@ -72,6 +74,38 @@ public class SchedulePlanRuleResult { |
| 72 | 74 | this.createDate = new Date(); |
| 73 | 75 | } |
| 74 | 76 | |
| 77 | + public static String generateInsertSql() { | |
| 78 | + String sql = "insert into bsth_c_s_sp_rule_rst" + | |
| 79 | + "(xl_id,xl_name,rule_id,cc_id,cc_zbh," + | |
| 80 | + "gids,gnames,gidindex,ecids,ecdbbms,ecindex," + | |
| 81 | + "ttinfo_id,ttinfo_name,schedule_date," + | |
| 82 | + "sysuser_id,sysuser_name,create_date) " + | |
| 83 | + "values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; | |
| 84 | + | |
| 85 | + return sql; | |
| 86 | + } | |
| 87 | + | |
| 88 | + public void preparedStatementSet(PreparedStatement ps) throws SQLException { | |
| 89 | + ps.setInt(1, this.getXlId()); | |
| 90 | + ps.setString(2, this.getXlName()); | |
| 91 | + ps.setString(3, this.getRuleId()); | |
| 92 | + ps.setString(4, this.getCcId()); | |
| 93 | + ps.setString(5, this.getCcZbh()); | |
| 94 | + ps.setString(6, this.getGids()); | |
| 95 | + ps.setString(7, this.getGnames()); | |
| 96 | + ps.setString(8, this.getGidindex()); | |
| 97 | + ps.setString(9, this.getEcids()); | |
| 98 | + ps.setString(10, this.getEcdbbms()); | |
| 99 | + ps.setString(11, this.getEcindex()); | |
| 100 | + ps.setString(12, this.getTtinfoId()); | |
| 101 | + ps.setString(13, this.getTtinfoName()); | |
| 102 | + ps.setDate(14, new java.sql.Date(this.getScheduleDate().getTime())); | |
| 103 | + ps.setString(15, this.getSysuserId()); | |
| 104 | + ps.setString(16, this.getSysuserName()); | |
| 105 | + ps.setTimestamp(17, new java.sql.Timestamp(this.getCreateDate().getTime())); | |
| 106 | + | |
| 107 | + } | |
| 108 | + | |
| 75 | 109 | public Long getId() { |
| 76 | 110 | return id; |
| 77 | 111 | } | ... | ... |
src/main/java/com/bsth/repository/SectionRouteRepository.java
| ... | ... | @@ -65,7 +65,7 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int |
| 65 | 65 | " b.section_distance AS sectionDistance," + |
| 66 | 66 | " b.section_time AS sectionTime," + |
| 67 | 67 | " b.db_type AS sectiondbType," + |
| 68 | - " b.speed_limit AS sectionSpeedLimet ,a.destroy,a.versions,a.descriptions FROM (" + | |
| 68 | + " b.speed_limit AS sectionSpeedLimet ,a.destroy,a.versions,a.descriptions,a.isRoadeSpeed FROM (" + | |
| 69 | 69 | "SELECT r.id AS sectionrouteId," + |
| 70 | 70 | "r.line AS sectionrouteLine," + |
| 71 | 71 | "r.line_code AS sectionrouteLineCode," + |
| ... | ... | @@ -75,7 +75,7 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int |
| 75 | 75 | "r.directions AS sectionrouteDirections," + |
| 76 | 76 | "r.destroy AS destroy," + |
| 77 | 77 | "r.versions AS versions," + |
| 78 | - "r.descriptions AS descriptions" + | |
| 78 | + "r.descriptions AS descriptions, r.is_roade_speed AS isRoadeSpeed" + | |
| 79 | 79 | " FROM bsth_c_sectionroute r where r.line = ?1 and r.directions = ?2 and r.destroy=0 ) a " + |
| 80 | 80 | " LEFT JOIN bsth_c_section b ON a.sectionrouteSection = b.id order by a.sectionrouteCode asc", nativeQuery=true) |
| 81 | 81 | List<Object[]> getSectionRoute(int lineId, int directions); |
| ... | ... | @@ -147,7 +147,7 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int |
| 147 | 147 | * |
| 148 | 148 | * @return List<Map<String, Object>> |
| 149 | 149 | */ |
| 150 | - @Query(value = " select MAX(r.sectionroute_code) as sectionrouteCode from bsth_c_sectionroute r WHERE r.line=?1 and r.directions =?2 and r.sectionroute_code< ?3", nativeQuery=true) | |
| 150 | + @Query(value = " select MAX(r.sectionroute_code) as sectionrouteCode from bsth_c_sectionroute r WHERE r.line=?1 and r.directions =?2 and r.sectionroute_code< ?3 and r.destroy = 0", nativeQuery=true) | |
| 151 | 151 | List<Object[]> findUpSectionRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); |
| 152 | 152 | |
| 153 | 153 | /** | ... | ... |
src/main/java/com/bsth/repository/StationRepository.java
| ... | ... | @@ -37,9 +37,15 @@ public interface StationRepository extends BaseRepository<Station, Integer> { |
| 37 | 37 | , nativeQuery=true) |
| 38 | 38 | long stationMaxId(); |
| 39 | 39 | |
| 40 | - @Query(value = "SELECT s.b_jwpoints,s.id FROM bsth_c_station s where s.station_name like ?1" | |
| 40 | + /*@Query(value = "SELECT s.b_jwpoints,s.id FROM bsth_c_station s where s.station_name like ?1" | |
| 41 | 41 | , nativeQuery=true) |
| 42 | - List<Object[]> findStationName(String stationName); | |
| 42 | + List<Object[]> findStationName(String stationName);*/ | |
| 43 | + @Query(value = " SELECT t.b_jwpoints,t.id FROM (" + | |
| 44 | + " SELECT b.id,b.b_jwpoints,b.station_name,a.directions FROM (" + | |
| 45 | + " SELECT s.station,s.station_name,s.directions FROM bsth_c_stationroute s where s.destroy = 0 and s.directions = ?1) a " + | |
| 46 | + " LEFT JOIN bsth_c_station b on a.station = b. id) t where t.station_name LIKE ?2" | |
| 47 | + , nativeQuery=true) | |
| 48 | + List<Object[]> findStationName(Integer dir , String stationName); | |
| 43 | 49 | |
| 44 | 50 | /** |
| 45 | 51 | * @Description :TODO(站点保存) | ... | ... |
src/main/java/com/bsth/repository/StationRouteRepository.java
| ... | ... | @@ -99,7 +99,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 99 | 99 | @Query(value = "select t.station_route_code,t.station_mark from bsth_c_stationroute t where " + |
| 100 | 100 | " t.station_route_code =(" + |
| 101 | 101 | "select MAX(station_route_code) as stationRouteCode from bsth_c_stationroute r WHERE " + |
| 102 | - "r.line=?1 and r.directions =?2 and station_route_code< ?3 ) and t.line=?1 and t.directions = ?2", nativeQuery=true) | |
| 102 | + "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) | |
| 103 | 103 | List<Object[]> findUpStationRouteCode(Integer lineId,Integer direction,Integer stationRouteCode); |
| 104 | 104 | |
| 105 | 105 | |
| ... | ... | @@ -206,7 +206,7 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 206 | 206 | " b.create_date AS stationCreateDate," + |
| 207 | 207 | " b.update_by AS stationUpdateBy," + |
| 208 | 208 | " b.update_date AS stationUpdateDate," + |
| 209 | - " a.stationRouteId"+ | |
| 209 | + " a.stationRouteId,b.station_name as zdmc "+ | |
| 210 | 210 | " FROM ( SELECT s.id AS stationRouteId," + |
| 211 | 211 | " s.line AS stationRouteLine," + |
| 212 | 212 | " s.station as stationRouteStation," + |
| ... | ... | @@ -276,4 +276,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 276 | 276 | @Modifying |
| 277 | 277 | @Query(value="update bsth_c_stationroute set distances =?2 where id = ?1 ", nativeQuery=true) |
| 278 | 278 | public void upddis(Integer id,Double dis); |
| 279 | + | |
| 280 | + @Modifying | |
| 281 | + @Query(value="UPDATE bsth_c_stationroute set station_route_code = (station_route_code+10) where line = ?1 and directions = ?2 and station_route_code >=?3 and destroy = 0", nativeQuery=true) | |
| 282 | + public void stationUpdStationRouteCode(Integer line,Integer dir,Integer routeCod); | |
| 279 | 283 | } | ... | ... |
src/main/java/com/bsth/repository/oil/YlbRepository.java
| ... | ... | @@ -27,6 +27,29 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 27 | 27 | + " xlbm like %?4% and nbbm like %?5% ",nativeQuery=true) |
| 28 | 28 | List<Ylb> obtainYlbefore(String rq,String gsbm,String fgsbm,String xlbm,String nbbm); |
| 29 | 29 | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 获取当天日期前的最大的日期中最大进出顺序的数据 | |
| 33 | + * | |
| 34 | + */ | |
| 35 | + @Transactional | |
| 36 | + @Modifying | |
| 37 | + @Query(value="select y.* from (select max(d.id) as id ,d.nbbm from (" | |
| 38 | + + " select b.rq,b.nbbm,max(b.jcsx) as jcsx from (" | |
| 39 | + + " select max(t.rq) as rq ,t.nbbm from bsth_c_ylb t " | |
| 40 | + + " where to_days(t.rq)< to_days(?1) " | |
| 41 | + + " and t.ssgsdm like %?2% and t.fgsdm like %?3% " | |
| 42 | + + " and t.xlbm like %?4% and t.nbbm like %?5% group by nbbm ) a " | |
| 43 | + + " left join bsth_c_ylb b on a.rq=b.rq and a.nbbm=b.nbbm " | |
| 44 | + + " where b.ssgsdm like %?2% and b.fgsdm like %?3% and " | |
| 45 | + + " b.xlbm like %?4% and b.nbbm like %?5% group by b.rq,b.nbbm) c" | |
| 46 | + + " left join bsth_c_ylb d on c.rq=d.rq and c.nbbm=d.nbbm and c.jcsx=d.jcsx " | |
| 47 | + + " where d.ssgsdm like %?2% and d.fgsdm like %?3% and d.xlbm like %?4% " | |
| 48 | + + " and d.nbbm like %?5% group by d.nbbm) x left join " | |
| 49 | + + " bsth_c_ylb y on x.id=y.id where y.ssgsdm like %?2% and y.fgsdm like %?3% " | |
| 50 | + + " and y.xlbm like %?4% and y.nbbm like %?5%",nativeQuery=true) | |
| 51 | + List<Ylb> listMaxRqJcsx(String rq,String gsbm,String fgsbm,String xlbm,String nbbm); | |
| 52 | + | |
| 30 | 53 | /** |
| 31 | 54 | * 当天YLB信息 |
| 32 | 55 | * @param rq |
| ... | ... | @@ -56,8 +79,8 @@ public interface YlbRepository extends BaseRepository<Ylb, Integer>{ |
| 56 | 79 | */ |
| 57 | 80 | @Transactional |
| 58 | 81 | @Modifying |
| 59 | - @Query(value="select ifnull(jzl,0),ifnull(zlc,0),ifnull(sh,0) from bsth_c_ylb where nbbm=?1 and rq=?2 and xlbm like %?3%",nativeQuery=true) | |
| 60 | - List<Object[]> sumLcYl(String nbbm,Date rq,String xlbm); | |
| 82 | + @Query(value="select ifnull(jzl,0),ifnull(zlc,0),ifnull(sh,0) from bsth_c_ylb where nbbm=?1 and rq=?2 and xlbm like %?3% and ssgsdm like %?4% and fgsdm like %?5%",nativeQuery=true) | |
| 83 | + List<Object[]> sumLcYl(String nbbm,Date rq,String xlbm,String fgsbm,String gsbm); | |
| 61 | 84 | |
| 62 | 85 | /** |
| 63 | 86 | * | ... | ... |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| ... | ... | @@ -133,7 +133,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 133 | 133 | |
| 134 | 134 | //去掉了 xlBm is not null |
| 135 | 135 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| 136 | - @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.realExecDate,s.dfsj, (s.lpName+1)") | |
| 136 | + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlDir,s.realExecDate,s.dfsj, (s.lpName+1)") | |
| 137 | 137 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); |
| 138 | 138 | |
| 139 | 139 | @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) |
| ... | ... | @@ -164,8 +164,8 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI |
| 164 | 164 | List<ScheduleRealInfo> scheduleByDateAndLineYbb(String line,String date,String date2); |
| 165 | 165 | |
| 166 | 166 | |
| 167 | - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj") | |
| 168 | - List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm); | |
| 167 | + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% and s.clZbh like %?5% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj") | |
| 168 | + List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm,String nbbm); | |
| 169 | 169 | |
| 170 | 170 | @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") |
| 171 | 171 | List<ScheduleRealInfo> setLD(String date); | ... | ... |
src/main/java/com/bsth/security/WebSecurityConfig.java
| ... | ... | @@ -36,7 +36,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { |
| 36 | 36 | public void configure(WebSecurity web) throws Exception { |
| 37 | 37 | // 白名单 |
| 38 | 38 | web.ignoring().antMatchers(Constants.LOGIN_PAGE, Constants.LOGIN, Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.CAPTCHA, |
| 39 | - Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES, Constants.XD_REAL_GPS); | |
| 39 | + Constants.SERVICE_INTERFACE, Constants.METRONIC_URL, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | @Override | ... | ... |
src/main/java/com/bsth/security/filter/LoginInterceptor.java
| ... | ... | @@ -3,10 +3,11 @@ package com.bsth.security.filter; |
| 3 | 3 | import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.bsth.common.Constants; |
| 5 | 5 | import com.bsth.common.ResponseCode; |
| 6 | -import com.bsth.filter.BaseFilter; | |
| 7 | 6 | import com.bsth.util.RequestUtils; |
| 8 | 7 | import org.springframework.security.core.Authentication; |
| 9 | 8 | import org.springframework.security.core.context.SecurityContextHolder; |
| 9 | +import org.springframework.util.AntPathMatcher; | |
| 10 | +import org.springframework.util.PathMatcher; | |
| 10 | 11 | |
| 11 | 12 | import javax.servlet.*; |
| 12 | 13 | import javax.servlet.http.HttpServletRequest; |
| ... | ... | @@ -23,40 +24,67 @@ import java.util.Map; |
| 23 | 24 | * @date 2016年3月24日 上午11:49:20 |
| 24 | 25 | * |
| 25 | 26 | */ |
| 26 | -public class LoginInterceptor extends BaseFilter { | |
| 27 | +public class LoginInterceptor implements Filter { | |
| 28 | + | |
| 29 | + private final PathMatcher pathMatcher = new AntPathMatcher(); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 白名单 | |
| 33 | + * 相比于 BaseFilter,此处对线调GPS请求进行了拦截验证 | |
| 34 | + */ | |
| 35 | + private String[] whiteListURLs = { Constants.LOGIN_PAGE,Constants.CAPTCHA, Constants.SERVICE_INTERFACE, | |
| 36 | + Constants.ASSETS_URL, Constants.FAVICON_URL, Constants.METRONIC_URL, Constants.LOGIN, Constants.LOGIN_FAILURE, Constants.UPSTREAM_URL, Constants.XD_CHILD_PAGES }; | |
| 37 | + | |
| 27 | 38 | |
| 28 | 39 | @Override |
| 29 | 40 | public void destroy() { |
| 30 | 41 | |
| 31 | 42 | } |
| 32 | 43 | |
| 44 | + | |
| 33 | 45 | @Override |
| 34 | 46 | public void init(FilterConfig filterConfig) throws ServletException { |
| 35 | 47 | |
| 36 | 48 | } |
| 37 | 49 | |
| 38 | 50 | @Override |
| 39 | - public void doFilter(HttpServletRequest request, | |
| 40 | - HttpServletResponse response, FilterChain chain) | |
| 41 | - throws IOException, ServletException { | |
| 42 | - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | |
| 43 | - | |
| 44 | - if(null == authentication){ | |
| 45 | - //没有登录 | |
| 46 | - | |
| 47 | - if(RequestUtils.isAjaxRequest(request)){ | |
| 48 | - Map<String, Object> map = new HashMap<>(); | |
| 49 | - map.put("status", | |
| 50 | - ResponseCode.NO_AUTHENTICATION); | |
| 51 | - response.getWriter().print(JSON.toJSONString(map)); | |
| 52 | - } | |
| 53 | - else | |
| 54 | - response.sendRedirect(Constants.LOGIN_PAGE); | |
| 51 | + public void doFilter(ServletRequest request, ServletResponse response, | |
| 52 | + FilterChain chain) throws IOException, ServletException { | |
| 53 | + | |
| 54 | + HttpServletRequest httpRequest = (HttpServletRequest) request; | |
| 55 | + HttpServletResponse httpResponse = (HttpServletResponse) response; | |
| 56 | + | |
| 57 | + String currentURL = httpRequest.getServletPath(); | |
| 58 | + | |
| 59 | + if (!isWhiteURL(currentURL)) { | |
| 60 | + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | |
| 55 | 61 | |
| 56 | - return; | |
| 62 | + if(null == authentication){ | |
| 63 | + //没有登录 | |
| 64 | + | |
| 65 | + if(RequestUtils.isAjaxRequest(httpRequest)){ | |
| 66 | + Map<String, Object> map = new HashMap<>(); | |
| 67 | + map.put("status", | |
| 68 | + ResponseCode.NO_AUTHENTICATION); | |
| 69 | + response.getWriter().print(JSON.toJSONString(map)); | |
| 70 | + } | |
| 71 | + else | |
| 72 | + httpResponse.sendRedirect(Constants.LOGIN_PAGE); | |
| 73 | + | |
| 74 | + return; | |
| 75 | + } | |
| 57 | 76 | } |
| 58 | 77 | |
| 59 | 78 | chain.doFilter(request, response); |
| 60 | 79 | } |
| 61 | 80 | |
| 81 | + private boolean isWhiteURL(String currentURL) { | |
| 82 | + for (String whiteURL : whiteListURLs) { | |
| 83 | + if (pathMatcher.match(whiteURL, currentURL)) { | |
| 84 | + return true; | |
| 85 | + } | |
| 86 | + } | |
| 87 | + return false; | |
| 88 | + } | |
| 89 | + | |
| 62 | 90 | } | ... | ... |
src/main/java/com/bsth/service/SectionRouteService.java
| ... | ... | @@ -22,6 +22,14 @@ import com.bsth.entity.SectionRoute; |
| 22 | 22 | */ |
| 23 | 23 | public interface SectionRouteService extends BaseService<SectionRoute, Integer> { |
| 24 | 24 | |
| 25 | + /** | |
| 26 | + * | |
| 27 | + * @Title: list | |
| 28 | + * @Description: TODO(多条件查询) | |
| 29 | + * @throws | |
| 30 | + */ | |
| 31 | + Iterable<SectionRoute> list(Map<String, Object> map); | |
| 32 | + | |
| 25 | 33 | List<Map<String, Object>> getSectionRoute(Map<String, Object> map); |
| 26 | 34 | |
| 27 | 35 | /** | ... | ... |
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
| ... | ... | @@ -766,7 +766,7 @@ public class FormsServiceImpl implements FormsService { |
| 766 | 766 | + map.get("endDate").toString() + "' and xl_bm='" + map.get("line").toString() |
| 767 | 767 | + "' AND gs_bm is not null " |
| 768 | 768 | + " AND bc_type NOT IN ('in', 'out')" |
| 769 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm) b on " | |
| 769 | + + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 770 | 770 | + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; |
| 771 | 771 | List<Turnoutrate> list = jdbcTemplate.query(sql, new RowMapper<Turnoutrate>() { |
| 772 | 772 | |
| ... | ... | @@ -775,21 +775,24 @@ public class FormsServiceImpl implements FormsService { |
| 775 | 775 | Turnoutrate tu = new Turnoutrate(); |
| 776 | 776 | NumberFormat numberFormat = NumberFormat.getInstance(); |
| 777 | 777 | numberFormat.setMaximumFractionDigits(2); |
| 778 | - String result1 = numberFormat.format((float) Integer.parseInt(arg0.getString("scl")) | |
| 779 | - / (float) Integer.parseInt(arg0.getString("jcl")) * 100); | |
| 780 | - String result2 = numberFormat.format((float) Integer.parseInt(arg0.getString("sbc")) | |
| 781 | - / (float) Integer.parseInt(arg0.getString("jbc")) * 100); | |
| 778 | + int scl = arg0.getString("scl")!=null&&arg0.getString("scl").trim().length()!=0?Integer.parseInt(arg0.getString("scl")):0; | |
| 779 | + int jcl = arg0.getString("jcl")!=null&&arg0.getString("jcl").trim().length()!=0?Integer.parseInt(arg0.getString("jcl")):0; | |
| 780 | + int sbc = arg0.getString("sbc")!=null&&arg0.getString("sbc").trim().length()!=0?Integer.parseInt(arg0.getString("sbc")):0; | |
| 781 | + int jbc = arg0.getString("jbc")!=null&&arg0.getString("jbc").trim().length()!=0?Integer.parseInt(arg0.getString("jbc")):0; | |
| 782 | + String result1 = numberFormat.format((float) scl / (float) jcl * 100); | |
| 783 | + String result2 = numberFormat.format((float) sbc / (float) jbc * 100); | |
| 782 | 784 | tu.setRq(rq); |
| 783 | 785 | tu.setGs(arg0.getString("gs_name").toString()); |
| 784 | 786 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 785 | - tu.setXl(arg0.getString("xlgs")); | |
| 786 | - tu.setXlmc(arg0.getString("sxl")); | |
| 787 | - tu.setCchjh(arg0.getString("jcl").toString()); | |
| 788 | - tu.setCchsj(arg0.getString("scl").toString()); | |
| 789 | - tu.setCchqz(arg0.getString("sxl").toString()); | |
| 787 | +// tu.setXl(arg0.getString("xlgs")!=null&&arg0.getString("xlgs").trim().length()!=0?arg0.getString("xlgs"):"0"); | |
| 788 | + tu.setXl(arg0.getString("jxl")!=null&&arg0.getString("jxl").trim().length()!=0?arg0.getString("jxl"):"0"); | |
| 789 | + tu.setXlmc(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 790 | + tu.setCchjh("" + jcl); | |
| 791 | + tu.setCchsj("" + scl); | |
| 792 | + tu.setCchqz(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 790 | 793 | tu.setChl(result1 + "%");// 出车率 |
| 791 | - tu.setBcjh(arg0.getString("jbc").toString()); | |
| 792 | - tu.setBcsj(arg0.getString("sbc").toString()); | |
| 794 | + tu.setBcjh("" + jbc); | |
| 795 | + tu.setBcsj("" + sbc); | |
| 793 | 796 | tu.setBbzxl(result2 + "%");// 班次执行率 |
| 794 | 797 | tu.setSm(arg0.getString("gs_name").toString()); |
| 795 | 798 | tu.setGsgs(arg0.getString("gslsbm").toString()); |
| ... | ... | @@ -799,7 +802,6 @@ public class FormsServiceImpl implements FormsService { |
| 799 | 802 | |
| 800 | 803 | }); |
| 801 | 804 | |
| 802 | - | |
| 803 | 805 | return list; |
| 804 | 806 | } |
| 805 | 807 | |
| ... | ... | @@ -836,7 +838,7 @@ public class FormsServiceImpl implements FormsService { |
| 836 | 838 | + "where DATE_FORMAT(schedule_date,'%Y-%m-%d') BETWEEN '" + map.get("startDate").toString() + "' and '" |
| 837 | 839 | + map.get("endDate").toString() + "' and xl_bm='" + map.get("line").toString() |
| 838 | 840 | + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out') " |
| 839 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm) b on " | |
| 841 | + + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 840 | 842 | + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; |
| 841 | 843 | List<Executionrate> list = jdbcTemplate.query(sql, new RowMapper<Executionrate>() { |
| 842 | 844 | |
| ... | ... | @@ -845,24 +847,27 @@ public class FormsServiceImpl implements FormsService { |
| 845 | 847 | Executionrate tu = new Executionrate(); |
| 846 | 848 | NumberFormat numberFormat = NumberFormat.getInstance(); |
| 847 | 849 | numberFormat.setMaximumFractionDigits(2); |
| 848 | - String result1 = numberFormat.format((float) Integer.parseInt(arg0.getString("scl")) | |
| 849 | - / (float) Integer.parseInt(arg0.getString("jcl")) * 100); | |
| 850 | - String result2 = numberFormat.format((float) Integer.parseInt(arg0.getString("sbc")) | |
| 851 | - / (float) Integer.parseInt(arg0.getString("jbc")) * 100); | |
| 850 | + int scl = arg0.getString("scl")!=null&&arg0.getString("scl").trim().length()!=0?Integer.parseInt(arg0.getString("scl")):0; | |
| 851 | + int jcl = arg0.getString("jcl")!=null&&arg0.getString("jcl").trim().length()!=0?Integer.parseInt(arg0.getString("jcl")):0; | |
| 852 | + int sbc = arg0.getString("sbc")!=null&&arg0.getString("sbc").trim().length()!=0?Integer.parseInt(arg0.getString("sbc")):0; | |
| 853 | + int jbc = arg0.getString("jbc")!=null&&arg0.getString("jbc").trim().length()!=0?Integer.parseInt(arg0.getString("jbc")):0; | |
| 854 | + String result1 = numberFormat.format((float) scl / (float) jcl * 100); | |
| 855 | + String result2 = numberFormat.format((float) sbc / (float) jbc * 100); | |
| 852 | 856 | tu.setRq(rq); |
| 853 | 857 | tu.setGs(arg0.getString("gs_name").toString()); |
| 854 | 858 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 855 | - tu.setXl(arg0.getString("xlgs"));//这个是根据公司判断线路有几条 | |
| 859 | +// tu.setXl(arg0.getString("xlgs")!=null&&arg0.getString("xlgs").trim().length()!=0?arg0.getString("xlgs"):"0");//这个是根据公司判断线路有几条 | |
| 860 | + tu.setXl(arg0.getString("jxl")!=null&&arg0.getString("jxl").trim().length()!=0?arg0.getString("jxl"):"0"); | |
| 856 | 861 | //tu.setXl(arg0.getString("sxl")); |
| 857 | - tu.setXlmc(arg0.getString("sxl")); | |
| 858 | - tu.setCchjh(arg0.getString("jcl").toString()); | |
| 859 | - tu.setCchsj(arg0.getString("scl").toString()); | |
| 860 | - tu.setCchqz(arg0.getString("sxl").toString()); | |
| 862 | + tu.setXlmc(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 863 | + tu.setCchjh("" + jcl); | |
| 864 | + tu.setCchsj("" + scl); | |
| 865 | + tu.setCchqz(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 861 | 866 | tu.setChl(result1 + "%");// 出车率 |
| 862 | - tu.setBcjh(arg0.getString("jbc").toString()); | |
| 863 | - tu.setBcsj(arg0.getString("sbc").toString()); | |
| 867 | + tu.setBcjh("" + jbc); | |
| 868 | + tu.setBcsj("" + sbc); | |
| 864 | 869 | tu.setBbzxl(result2 + "%");// 班次执行率 |
| 865 | - tu.setSm(arg0.getString("xl_name").toString()); | |
| 870 | + tu.setSm(arg0.getString("xl_name")); | |
| 866 | 871 | tu.setGsgs(arg0.getString("gslsbm").toString()); |
| 867 | 872 | tu.setFgsgs(arg0.getString("fgsbm").toString()); |
| 868 | 873 | return tu; |
| ... | ... | @@ -910,8 +915,9 @@ public class FormsServiceImpl implements FormsService { |
| 910 | 915 | + map.get("endDate").toString() + "' and xl_bm='" + map.get |
| 911 | 916 | ("line").toString() |
| 912 | 917 | + "' AND gs_bm is not null AND bc_type NOT IN ('in', 'out')" |
| 913 | - + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm) b on " | |
| 918 | + + "GROUP BY gs_bm,fgs_bm,xl_bm,gs_name,fgs_name,bc_type) b ON t.company=b.gs_bm and t.branche_company = b.fgs_bm) b on " | |
| 914 | 919 | + " a.gs_bm=b.gs_bm and a.fgs_bm=b.fgs_bm and a.xl_bm=b.xl_bm "; |
| 920 | + System.out.println(sql); | |
| 915 | 921 | List<Allline> list = jdbcTemplate.query(sql, new RowMapper<Allline>() { |
| 916 | 922 | |
| 917 | 923 | @Override |
| ... | ... | @@ -919,28 +925,30 @@ public class FormsServiceImpl implements FormsService { |
| 919 | 925 | Allline tu = new Allline(); |
| 920 | 926 | NumberFormat numberFormat = NumberFormat.getInstance(); |
| 921 | 927 | numberFormat.setMaximumFractionDigits(2); |
| 922 | - String result1 = numberFormat.format((float) Integer.parseInt(arg0.getString("scl")) | |
| 923 | - / (float) Integer.parseInt(arg0.getString("jcl")) * 100); | |
| 924 | - String result2 = numberFormat.format((float) Integer.parseInt(arg0.getString("sbc")) | |
| 925 | - / (float) Integer.parseInt(arg0.getString("jbc")) * 100); | |
| 928 | + int scl = arg0.getString("scl")!=null&&arg0.getString("scl").trim().length()!=0?Integer.parseInt(arg0.getString("scl")):0; | |
| 929 | + int jcl = arg0.getString("jcl")!=null&&arg0.getString("jcl").trim().length()!=0?Integer.parseInt(arg0.getString("jcl")):0; | |
| 930 | + int sbc = arg0.getString("sbc")!=null&&arg0.getString("sbc").trim().length()!=0?Integer.parseInt(arg0.getString("sbc")):0; | |
| 931 | + int jbc = arg0.getString("jbc")!=null&&arg0.getString("jbc").trim().length()!=0?Integer.parseInt(arg0.getString("jbc")):0; | |
| 932 | + String result1 = numberFormat.format((float) scl / (float) jcl * 100); | |
| 933 | + String result2 = numberFormat.format((float) sbc / (float) jbc * 100); | |
| 926 | 934 | tu.setRq(rq); |
| 927 | 935 | tu.setGs(arg0.getString("gs_name").toString()); |
| 928 | 936 | tu.setZhgs(arg0.getString("fgs_name").toString()); |
| 929 | 937 | tu.setXl(arg0.getString("xl_name")); |
| 930 | - tu.setXlmc(arg0.getString("sxl")); | |
| 931 | - tu.setCchjh(arg0.getString("jcl").toString()); | |
| 932 | - tu.setCchsj(arg0.getString("scl").toString()); | |
| 933 | - tu.setCchqz(arg0.getString("sxl").toString()); | |
| 938 | + tu.setXlmc(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 939 | + tu.setCchjh("" + jcl); | |
| 940 | + tu.setCchsj("" + scl); | |
| 941 | + tu.setCchqz(arg0.getString("sxl")!=null&&arg0.getString("sxl").trim().length()!=0?arg0.getString("sxl"):"0"); | |
| 934 | 942 | tu.setChl(result1 + "%");// 出车率 |
| 935 | - tu.setBcjh(arg0.getString("jbc").toString()); | |
| 936 | - tu.setBcsj(arg0.getString("sbc").toString()); | |
| 943 | + tu.setBcjh("" + jbc); | |
| 944 | + tu.setBcsj("" + sbc); | |
| 937 | 945 | tu.setBbzxl(result2 + "%");// 班次执行率 |
| 938 | 946 | |
| 939 | - tu.setSm(arg0.getString("xl_name").toString()); | |
| 947 | + tu.setSm(arg0.getString("xl_name")); | |
| 940 | 948 | tu.setGsgs(arg0.getString("gslsbm").toString()); |
| 941 | 949 | tu.setFgsgs(arg0.getString("fgsbm").toString()); |
| 942 | 950 | return tu; |
| 943 | - } | |
| 951 | + } | |
| 944 | 952 | }); |
| 945 | 953 | |
| 946 | 954 | return list; |
| ... | ... | @@ -960,13 +968,13 @@ public class FormsServiceImpl implements FormsService { |
| 960 | 968 | } |
| 961 | 969 | |
| 962 | 970 | String sql="select t.schedule_date_str," |
| 963 | - + " t.cl_zbh,t.j_gh,t.j_name,x.yh from (select r.schedule_date_str,r.xl_bm,r.xl_name," | |
| 971 | + + " t.cl_zbh,t.j_gh,t.j_name,x.yh from (select r.schedule_date_str,r.xl_bm," | |
| 964 | 972 | + " r.cl_zbh,r.j_gh,r.j_name from bsth_c_s_sp_info_real r WHERE " |
| 965 | 973 | + " r.xl_bm='" + map.get("line").toString() + "' " |
| 966 | 974 | + " and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"') " |
| 967 | 975 | + " and r.gs_bm like '%"+gsbm+"%' " |
| 968 | 976 | + " and r.fgs_bm like '%"+fgsbm+"%' " |
| 969 | - + " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name) t" | |
| 977 | + + " GROUP BY r.schedule_date_str,r.xl_bm,r.cl_zbh,r.j_gh,r.j_name) t" | |
| 970 | 978 | + " left join (select * from bsth_c_ylb y where " |
| 971 | 979 | + " to_days(y.rq)=to_days('"+map.get("date").toString()+"') " |
| 972 | 980 | + " and y.xlbm= '" + map.get("line").toString() + "'" | ... | ... |
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| ... | ... | @@ -73,7 +73,6 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 73 | 73 | if(normal){ |
| 74 | 74 | sql += " and bc_type != 'in' and bc_type != 'out'"; |
| 75 | 75 | } |
| 76 | - System.out.println(sql); | |
| 77 | 76 | |
| 78 | 77 | list = jdbcTemplate.query(sql, |
| 79 | 78 | new RowMapper<ScheduleRealInfo>(){ |
| ... | ... | @@ -238,6 +237,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 238 | 237 | |
| 239 | 238 | String sql = "select start_station_name, end_station_name from bsth_c_line where line_code = '"+line+"'"; |
| 240 | 239 | |
| 240 | + System.out.println(sql); | |
| 241 | 241 | list = jdbcTemplate.query(sql, |
| 242 | 242 | new RowMapper<Map<String, Object>>(){ |
| 243 | 243 | @Override |
| ... | ... | @@ -315,8 +315,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 315 | 315 | String endDate = map.get("endDate").toString(); |
| 316 | 316 | String model = map.get("model").toString(); |
| 317 | 317 | String statu = map.get("statu").toString(); |
| 318 | -// String times = map.get("times").toString(); | |
| 318 | + String times1 = map.get("times1").toString(); | |
| 319 | + String times2 = map.get("times2").toString(); | |
| 319 | 320 | String type = map.get("type").toString(); |
| 321 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 320 | 322 | |
| 321 | 323 | if(startDate.length() == 0){ |
| 322 | 324 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -327,12 +329,18 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 327 | 329 | if(statu.equals("0")){ |
| 328 | 330 | line = ""; |
| 329 | 331 | } |
| 330 | -// if(times.length() == 0){ | |
| 331 | -// times = "06:00-07:00"; | |
| 332 | -// } | |
| 333 | 332 | |
| 334 | - List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, startDate, endDate, model, "", true); | |
| 333 | + List<ScheduleRealInfo> list = this.getSchedule(company, subCompany, line, | |
| 334 | + startDate, endDate, model, sfqr==1?times1+"-"+times2:"", true); | |
| 335 | 335 | |
| 336 | + long time1 = 0; | |
| 337 | + long time2 = 0; | |
| 338 | + if(sfqr == 1){ | |
| 339 | + String[] split1 = times1.split(":"); | |
| 340 | + String[] split2 = times2.split(":"); | |
| 341 | + time1 = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 342 | + time2 = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 343 | + } | |
| 336 | 344 | String[] date1 = startDate.split("-"); |
| 337 | 345 | String[] date2 = endDate.split("-"); |
| 338 | 346 | // startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| ... | ... | @@ -349,6 +357,15 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 349 | 357 | // int endTime = Integer.valueOf(split[1].split(":")[0])*60 + Integer.valueOf(split[1].split(":")[1]); |
| 350 | 358 | |
| 351 | 359 | for(ScheduleRealInfo schedule : list){ |
| 360 | + String[] split1 = schedule.getFcsj().split(":"); | |
| 361 | + String[] split2 = schedule.getZdsj().split(":"); | |
| 362 | + long fcsj = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 363 | + long zdsj = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 364 | + if(sfqr == 1 && (zdsj < time1 || fcsj > time2)){ | |
| 365 | + continue; | |
| 366 | + } | |
| 367 | + if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0) | |
| 368 | + continue; | |
| 352 | 369 | String key = schedule.getXlBm() + "/" + schedule.getXlName() + "/" + schedule.getQdzName(); |
| 353 | 370 | if(!keyMap.containsKey(key)) |
| 354 | 371 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| ... | ... | @@ -566,8 +583,11 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 566 | 583 | String statu = map.get("statu").toString(); |
| 567 | 584 | String startDate = map.get("startDate").toString(); |
| 568 | 585 | String endDate = map.get("endDate").toString(); |
| 586 | + String times1 = map.get("times1").toString(); | |
| 587 | + String times2 = map.get("times2").toString(); | |
| 569 | 588 | String model = map.get("model").toString(); |
| 570 | 589 | String type = map.get("type").toString(); |
| 590 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 571 | 591 | |
| 572 | 592 | if(startDate.length() == 0){ |
| 573 | 593 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -588,6 +608,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 588 | 608 | if(company.length() != 0){ |
| 589 | 609 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; |
| 590 | 610 | } |
| 611 | + if(sfqr == 1){ | |
| 612 | + sql += " and zdsj >= '"+times1+"' and fcsj <= '"+times2+"'"; | |
| 613 | + } | |
| 591 | 614 | sql += " and bc_type != 'in' and bc_type != 'out' order by fcsj"; |
| 592 | 615 | |
| 593 | 616 | list = jdbcTemplate.query(sql, |
| ... | ... | @@ -698,7 +721,9 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 698 | 721 | e.printStackTrace(); |
| 699 | 722 | } |
| 700 | 723 | |
| 701 | - | |
| 724 | + | |
| 725 | + long time1 = 0; | |
| 726 | + long time2 = 0; | |
| 702 | 727 | String[] date1 = startDate.split("-"); |
| 703 | 728 | String[] date2 = endDate.split("-"); |
| 704 | 729 | String date = ""; |
| ... | ... | @@ -710,6 +735,12 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 710 | 735 | date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日--" + |
| 711 | 736 | date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; |
| 712 | 737 | } |
| 738 | + if(sfqr == 1){ | |
| 739 | + String[] split1 = times1.split(":"); | |
| 740 | + String[] split2 = times2.split(":"); | |
| 741 | + time1 = Long.valueOf(split1[0])*60 + Long.valueOf(split1[1]); | |
| 742 | + time2 = Long.valueOf(split2[0])*60 + Long.valueOf(split2[1]); | |
| 743 | + } | |
| 713 | 744 | |
| 714 | 745 | for(ChildTaskPlan cTask : cList){ |
| 715 | 746 | String key = cTask.getRemarks(); |
| ... | ... | @@ -719,6 +750,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 719 | 750 | } |
| 720 | 751 | |
| 721 | 752 | for(ScheduleRealInfo schedule : list){ |
| 753 | + if(schedule.getXlName()==null || schedule.getXlName().trim().length()==0) | |
| 754 | + continue; | |
| 722 | 755 | if(model.length() != 0){ |
| 723 | 756 | for(Long tt : ttList) |
| 724 | 757 | if((long) tt == (long)schedule.getSpId()){ |
| ... | ... | @@ -744,6 +777,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 744 | 777 | List<ScheduleRealInfo> list2 = keyMap.get(key); |
| 745 | 778 | long jhyysj = 0, sjyysj = 0; |
| 746 | 779 | long jhyssj = 0, sjyssj = 0; |
| 780 | + long jhyysj1 = 0, sjyysj1 = 0; | |
| 781 | + long jhyssj1 = 0, sjyssj1 = 0; | |
| 747 | 782 | double jhlc = 0, sjlc = 0; |
| 748 | 783 | for(ScheduleRealInfo schedule : list2){ |
| 749 | 784 | if(companyName.length() == 0 && schedule.getGsName() != null){ |
| ... | ... | @@ -766,20 +801,40 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 766 | 801 | for(int i = 1; i < keyList.size(); i++){ |
| 767 | 802 | ScheduleRealInfo schedule1 = sortMap.get(keyList.get(i - 1)); |
| 768 | 803 | ScheduleRealInfo schedule2 = sortMap.get(keyList.get(i)); |
| 769 | - jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 770 | - | |
| 804 | + if(sfqr == 1 && time1 > schedule1.getFcsjT()){ | |
| 805 | + jhyysj += schedule2.getFcsjT() - time1; | |
| 806 | + }else if(sfqr == 1 && time2 < schedule2.getFcsjT()){ | |
| 807 | + jhyysj += time2 - schedule1.getFcsjT(); | |
| 808 | + }else{ | |
| 809 | + jhyysj += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 810 | + } | |
| 811 | + jhyysj1 += schedule2.getFcsjT() - schedule1.getFcsjT(); | |
| 771 | 812 | long zdsj2 = schedule2.getZdsjT(); |
| 772 | 813 | long fcsj2 = schedule2.getFcsjT(); |
| 773 | 814 | if(fcsj2 > zdsj2) |
| 774 | 815 | zdsj2 += 1440l; |
| 775 | - jhyssj += zdsj2 - fcsj2; | |
| 816 | + if(sfqr == 1 && time1 > fcsj2){ | |
| 817 | + jhyssj += zdsj2 - time1; | |
| 818 | + }else if(sfqr == 1 && time2 < zdsj2){ | |
| 819 | + jhyssj += time2 - fcsj2; | |
| 820 | + }else{ | |
| 821 | + jhyssj += zdsj2 - fcsj2; | |
| 822 | + } | |
| 823 | + jhyssj1 += zdsj2 - fcsj2; | |
| 776 | 824 | jhlc += schedule2.getJhlc()==null?0:schedule2.getJhlc(); |
| 777 | 825 | if(i == 1){ |
| 778 | 826 | long zdsj1 = schedule1.getZdsjT(); |
| 779 | 827 | long fcsj1 = schedule1.getFcsjT(); |
| 780 | 828 | if(fcsj1 > zdsj1) |
| 781 | 829 | zdsj1 += 1440l; |
| 782 | - jhyssj += zdsj1 - fcsj1; | |
| 830 | + if(sfqr == 1 && time1 > fcsj1){ | |
| 831 | + jhyssj += zdsj1 - time1; | |
| 832 | + }else if(sfqr == 1 && time2 < zdsj1){ | |
| 833 | + jhyssj += time1 - fcsj1; | |
| 834 | + }else{ | |
| 835 | + jhyssj += zdsj1 - fcsj1; | |
| 836 | + } | |
| 837 | + jhyssj1 += zdsj1 - fcsj1; | |
| 783 | 838 | jhlc += schedule1.getJhlc()==null?0:schedule1.getJhlc(); |
| 784 | 839 | } |
| 785 | 840 | } |
| ... | ... | @@ -834,22 +889,45 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 834 | 889 | Map<String, Object> m1 = mapList.get(i - 1); |
| 835 | 890 | Map<String, Object> m2 = mapList.get(i); |
| 836 | 891 | if(m1.get("fcsj") != null && m2.get("fcsj") != null){ |
| 837 | - sjyysj += Long.valueOf(m2.get("fcsj").toString()) - Long.valueOf(m1.get("fcsj").toString()); | |
| 892 | + long fcsj2 = Long.valueOf(m2.get("fcsj").toString()); | |
| 893 | + long fcsj1 = Long.valueOf(m1.get("fcsj").toString()); | |
| 894 | + if(sfqr == 1 && time1 > fcsj1){ | |
| 895 | + sjyysj += fcsj2 - time1; | |
| 896 | + }else if(sfqr == 1 && time2 < fcsj2){ | |
| 897 | + sjyysj += time2 - fcsj1; | |
| 898 | + }else{ | |
| 899 | + sjyysj += fcsj2 - fcsj1; | |
| 900 | + } | |
| 901 | + sjyysj1 += fcsj2 - fcsj1; | |
| 838 | 902 | } |
| 839 | - if(m2.get("fcsj") != null){ | |
| 903 | + if(m2.get("fcsj") != null && m2.get("zdsj") != null){ | |
| 840 | 904 | long zdsj = Long.valueOf(m2.get("zdsj").toString()); |
| 841 | 905 | long fcsj = Long.valueOf(m2.get("fcsj").toString()); |
| 842 | 906 | if(fcsj > zdsj) |
| 843 | 907 | zdsj += 1440l; |
| 844 | - sjyssj += zdsj - fcsj; | |
| 908 | + if(sfqr == 1 && time1 > fcsj){ | |
| 909 | + sjyssj += zdsj - time1; | |
| 910 | + }else if(sfqr == 1 && time2 < zdsj){ | |
| 911 | + sjyssj += zdsj - fcsj; | |
| 912 | + }else{ | |
| 913 | + sjyssj += zdsj - fcsj; | |
| 914 | + } | |
| 915 | + sjyssj1 += zdsj - fcsj; | |
| 845 | 916 | sjlc += Double.valueOf(m2.get("lc").toString()); |
| 846 | 917 | } |
| 847 | - if(i == 1 && m1.get("fcsj") != null){ | |
| 918 | + if(i == 1 && m1.get("fcsj") != null && m1.get("zdsj") != null){ | |
| 848 | 919 | long zdsj = Long.valueOf(m1.get("zdsj").toString()); |
| 849 | 920 | long fcsj = Long.valueOf(m1.get("fcsj").toString()); |
| 850 | 921 | if(fcsj > zdsj) |
| 851 | 922 | zdsj += 1440l; |
| 852 | - sjyssj += zdsj - fcsj; | |
| 923 | + if(sfqr == 1 && time1 > fcsj){ | |
| 924 | + sjyssj += zdsj - time1; | |
| 925 | + }else if(sfqr == 1 && time2 < zdsj){ | |
| 926 | + sjyssj += time2 - fcsj; | |
| 927 | + }else{ | |
| 928 | + sjyssj += zdsj - fcsj; | |
| 929 | + } | |
| 930 | + sjyssj1 += zdsj - fcsj; | |
| 853 | 931 | sjlc += Double.valueOf(m1.get("lc").toString()); |
| 854 | 932 | } |
| 855 | 933 | } |
| ... | ... | @@ -867,7 +945,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 867 | 945 | tempMap.put("jhyycs", "0"); |
| 868 | 946 | } else { |
| 869 | 947 | tempMap.put("jhyysj", df.format((float)jhyysj / 60)); |
| 870 | - tempMap.put("jhyycs", df.format(jhlc == 0 ? 0 : jhlc / jhyysj * 60)); | |
| 948 | + tempMap.put("jhyycs", df.format(jhlc == 0 ? 0 : jhlc / jhyysj1 * 60)); | |
| 871 | 949 | } |
| 872 | 950 | |
| 873 | 951 | if(jhyssj == 0){ |
| ... | ... | @@ -875,7 +953,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 875 | 953 | tempMap.put("jhyscs", "0"); |
| 876 | 954 | } else { |
| 877 | 955 | tempMap.put("jhyssj", df.format((float)jhyssj / 60)); |
| 878 | - tempMap.put("jhyscs", df.format(jhlc == 0 ? 0 : jhlc / jhyssj * 60)); | |
| 956 | + tempMap.put("jhyscs", df.format(jhlc == 0 ? 0 : jhlc / jhyssj1 * 60)); | |
| 879 | 957 | } |
| 880 | 958 | |
| 881 | 959 | if(sjyysj == 0){ |
| ... | ... | @@ -883,7 +961,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 883 | 961 | tempMap.put("sjyycs", "0"); |
| 884 | 962 | } else { |
| 885 | 963 | tempMap.put("sjyysj", df.format((float)sjyysj / 60)); |
| 886 | - tempMap.put("sjyycs", df.format(sjlc == 0 ? 0 : sjlc / sjyysj * 60)); | |
| 964 | + tempMap.put("sjyycs", df.format(sjlc == 0 ? 0 : sjlc / sjyysj1 * 60)); | |
| 887 | 965 | } |
| 888 | 966 | |
| 889 | 967 | if(sjyssj == 0){ |
| ... | ... | @@ -891,8 +969,16 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 891 | 969 | tempMap.put("sjyscs", "0"); |
| 892 | 970 | } else { |
| 893 | 971 | tempMap.put("sjyssj", df.format((float)sjyssj / 60)); |
| 894 | - tempMap.put("sjyscs", df.format(sjlc == 0 ? 0 : sjlc / sjyssj * 60)); | |
| 972 | + tempMap.put("sjyscs", df.format(sjlc == 0 ? 0 : sjlc / sjyssj1 * 60)); | |
| 895 | 973 | } |
| 974 | + if(!tempMap.get("jhyysj").equals("0")) | |
| 975 | + if(!tempMap.get("jhyycs").equals("0")) | |
| 976 | + if(!tempMap.get("jhyssj").equals("0")) | |
| 977 | + if(!tempMap.get("jhyscs").equals("0")) | |
| 978 | + if(!tempMap.get("sjyysj").equals("0")) | |
| 979 | + if(!tempMap.get("sjyycs").equals("0")) | |
| 980 | + if(!tempMap.get("sjyssj").equals("0")) | |
| 981 | + if(!tempMap.get("sjyscs").equals("0")) | |
| 896 | 982 | resList.add(tempMap); |
| 897 | 983 | } |
| 898 | 984 | Map<String, List<Map<String, Object>>> keyMap2 = new HashMap<String, List<Map<String, Object>>>(); |
| ... | ... | @@ -1124,7 +1210,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1124 | 1210 | endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| 1125 | 1211 | } |
| 1126 | 1212 | if(times.length() == 0){ |
| 1127 | - times = "06:00-07:00"; | |
| 1213 | + times = "05:00-23:00"; | |
| 1128 | 1214 | } |
| 1129 | 1215 | |
| 1130 | 1216 | list = getSchedule(company, subCompany, line, startDate, endDate, model, times, true); |
| ... | ... | @@ -1387,6 +1473,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1387 | 1473 | String model = map.get("model").toString(); |
| 1388 | 1474 | String times = map.get("times").toString(); |
| 1389 | 1475 | String type = map.get("type").toString(); |
| 1476 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 1390 | 1477 | |
| 1391 | 1478 | if(startDate.length() == 0){ |
| 1392 | 1479 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -1395,10 +1482,10 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1395 | 1482 | endDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| 1396 | 1483 | } |
| 1397 | 1484 | if(times.length() == 0){ |
| 1398 | - times = "06:00-07:00"; | |
| 1485 | + times = "05:00-23:00"; | |
| 1399 | 1486 | } |
| 1400 | 1487 | |
| 1401 | - list = getSchedule(company, subCompany, line, startDate, endDate, model, times, true); | |
| 1488 | + list = getSchedule(company, subCompany, line, startDate, endDate, model, sfqr==1?times:"", true); | |
| 1402 | 1489 | |
| 1403 | 1490 | String[] date1 = startDate.split("-"); |
| 1404 | 1491 | String[] date2 = endDate.split("-"); |
| ... | ... | @@ -1417,7 +1504,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1417 | 1504 | |
| 1418 | 1505 | for(ScheduleRealInfo schedule : list){ |
| 1419 | 1506 | Long fcsj = schedule.getFcsjT(); |
| 1420 | - if(!(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){ | |
| 1507 | + if(sfqr == 1 && !(endTime!=0?fcsj>=startTime&&fcsj<endTime:fcsj>=startTime)){ | |
| 1421 | 1508 | continue; |
| 1422 | 1509 | } |
| 1423 | 1510 | String key = schedule.getXlName(); |
| ... | ... | @@ -1571,6 +1658,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1571 | 1658 | String endDate = map.get("endDate").toString(); |
| 1572 | 1659 | String times = map.get("times").toString(); |
| 1573 | 1660 | String type = map.get("type").toString(); |
| 1661 | + int sfqr = Integer.valueOf(map.get("sfqr").toString()); | |
| 1574 | 1662 | |
| 1575 | 1663 | if(startDate.length() == 0){ |
| 1576 | 1664 | startDate = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| ... | ... | @@ -1584,7 +1672,7 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1584 | 1672 | if(line.length() != 0){ |
| 1585 | 1673 | sql += " and xl_bm = '"+line+"'"; |
| 1586 | 1674 | } |
| 1587 | - if(times.length() != 0){ | |
| 1675 | + if(sfqr == 1 && times.length() != 0){ | |
| 1588 | 1676 | String[] split = times.split("-"); |
| 1589 | 1677 | String[] split0 = split[0].split(":"); |
| 1590 | 1678 | String[] split1 = split[1].split(":"); |
| ... | ... | @@ -1651,6 +1739,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { |
| 1651 | 1739 | date = startDate + "--" + endDate; |
| 1652 | 1740 | |
| 1653 | 1741 | for(ScheduleRealInfo schedule : list){ |
| 1742 | + if(schedule.getXlName() == null || schedule.getXlName().trim().length() == 0) | |
| 1743 | + continue; | |
| 1654 | 1744 | String key = schedule.getGsName() + "/" + schedule.getFgsName() + "/" + schedule.getXlName(); |
| 1655 | 1745 | if(!keyMap.containsKey(key)) |
| 1656 | 1746 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); | ... | ... |
src/main/java/com/bsth/service/impl/SectionRouteServiceImpl.java
| ... | ... | @@ -6,12 +6,15 @@ import java.util.List; |
| 6 | 6 | import java.util.Map; |
| 7 | 7 | |
| 8 | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | +import org.springframework.data.domain.Sort; | |
| 10 | +import org.springframework.data.domain.Sort.Direction; | |
| 9 | 11 | import org.springframework.stereotype.Service; |
| 10 | 12 | |
| 11 | 13 | import com.bsth.common.ResponseCode; |
| 12 | 14 | import com.bsth.entity.Line; |
| 13 | 15 | import com.bsth.entity.Section; |
| 14 | 16 | import com.bsth.entity.SectionRoute; |
| 17 | +import com.bsth.entity.search.CustomerSpecs; | |
| 15 | 18 | import com.bsth.repository.LineRepository; |
| 16 | 19 | import com.bsth.repository.SectionRepository; |
| 17 | 20 | import com.bsth.repository.SectionRouteRepository; |
| ... | ... | @@ -46,6 +49,14 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 46 | 49 | @Autowired |
| 47 | 50 | LineRepository lineRepository; |
| 48 | 51 | |
| 52 | + @Override | |
| 53 | + public Iterable<SectionRoute> list(Map<String, Object> map) { | |
| 54 | + List<Sort.Order> orderList = new ArrayList<>(); | |
| 55 | + orderList.add(new Sort.Order(Direction.ASC, "directions")); | |
| 56 | + orderList.add(new Sort.Order(Direction.ASC, "sectionrouteCode")); | |
| 57 | + return repository.findAll(new CustomerSpecs<SectionRoute>(map), new Sort(orderList)); | |
| 58 | + } | |
| 59 | + | |
| 49 | 60 | /** |
| 50 | 61 | * @Description :TODO(查询路段信息) |
| 51 | 62 | * |
| ... | ... | @@ -88,6 +99,7 @@ public class SectionRouteServiceImpl extends BaseServiceImpl<SectionRoute, Integ |
| 88 | 99 | tempM.put("destroy",listObjArray.get(i)[23]); |
| 89 | 100 | tempM.put("versions",listObjArray.get(i)[24]); |
| 90 | 101 | tempM.put("descriptions",listObjArray.get(i)[25]); |
| 102 | + tempM.put("isRoadeSpeed",listObjArray.get(i)[26]); | |
| 91 | 103 | resultList.add(tempM); |
| 92 | 104 | } |
| 93 | 105 | } | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -201,9 +201,9 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 201 | 201 | // 站点说明 |
| 202 | 202 | tempM.put("stationDescriptions", stationList.get(i)[31]); |
| 203 | 203 | |
| 204 | - tempM.put("name", stationList.get(i)[17]); | |
| 204 | + tempM.put("name", stationList.get(i)[3]); | |
| 205 | 205 | |
| 206 | - tempM.put("text", stationList.get(i)[17]); | |
| 206 | + tempM.put("text", stationList.get(i)[3]); | |
| 207 | 207 | |
| 208 | 208 | tempM.put("icon", "fa fa-bus"); |
| 209 | 209 | |
| ... | ... | @@ -305,6 +305,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 305 | 305 | |
| 306 | 306 | // 说明 |
| 307 | 307 | tempM.put("descriptions",sectionList.get(i)[25]); |
| 308 | + // 说明 | |
| 309 | + tempM.put("isRoadeSpeed",sectionList.get(i)[26]); | |
| 308 | 310 | |
| 309 | 311 | tempM.put("name", sectionList.get(i)[9]); |
| 310 | 312 | |
| ... | ... | @@ -413,34 +415,22 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 413 | 415 | */ |
| 414 | 416 | @Override |
| 415 | 417 | public List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map) { |
| 416 | - | |
| 417 | 418 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 418 | - | |
| 419 | 419 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 420 | - | |
| 421 | 420 | Integer stationRouteCode = map.get("stationRouteCode").equals("") ? null : Integer.parseInt(map.get("stationRouteCode").toString()); |
| 422 | - | |
| 423 | 421 | List<Object[]> reslutList = repository.findUpStationRouteCode(lineId, direction, stationRouteCode); |
| 424 | - | |
| 425 | 422 | List<Map<String, Object>> list = new ArrayList<Map<String,Object>>(); |
| 426 | - | |
| 427 | 423 | if(reslutList.size()>0) { |
| 428 | - | |
| 429 | 424 | for(int i = 0 ; i <reslutList.size() ;i++){ |
| 430 | 425 | Map<String, Object> tempM = new HashMap<String, Object>(); |
| 431 | 426 | tempM.put("stationRouteCode", reslutList.get(i)[0]); |
| 432 | 427 | tempM.put("stationRouteMarke", reslutList.get(i)[1]); |
| 433 | - | |
| 434 | 428 | list.add(tempM); |
| 435 | - | |
| 436 | 429 | } |
| 437 | - | |
| 438 | 430 | } |
| 439 | - | |
| 440 | 431 | return list; |
| 441 | 432 | } |
| 442 | 433 | |
| 443 | - | |
| 444 | 434 | /** |
| 445 | 435 | * @Description :TODO(查询线路某方向下所有站点的中心百度坐标) |
| 446 | 436 | * |
| ... | ... | @@ -1042,6 +1032,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1042 | 1032 | tempM.put("stationUpdateDate", objects.get(i)[38]); |
| 1043 | 1033 | |
| 1044 | 1034 | tempM.put("stationRouteId", objects.get(i)[39]); |
| 1035 | + tempM.put("zdmc", objects.get(i)[40]); | |
| 1045 | 1036 | |
| 1046 | 1037 | resultList.add(tempM); |
| 1047 | 1038 | } | ... | ... |
src/main/java/com/bsth/service/impl/StationServiceImpl.java
| ... | ... | @@ -9,6 +9,7 @@ import org.slf4j.Logger; |
| 9 | 9 | import org.slf4j.LoggerFactory; |
| 10 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | 11 | import org.springframework.stereotype.Service; |
| 12 | +import org.springframework.transaction.annotation.Transactional; | |
| 12 | 13 | |
| 13 | 14 | |
| 14 | 15 | |
| ... | ... | @@ -267,7 +268,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 267 | 268 | // 百度坐标纬度 |
| 268 | 269 | String bLatx = JSONObject.parseObject(stationsArray.getJSONObject(i).get("potion").toString()).get("lat").toString(); |
| 269 | 270 | bLatx = bLatx==null || bLatx.equals("") ? "0" : bLatx; |
| 270 | - List<Object[]> stationNameList = repository.findStationName(stationName); | |
| 271 | + List<Object[]> stationNameList = repository.findStationName(directions,stationName); | |
| 271 | 272 | Map<String, Object> isHaveMap = isHaveStationname(bLonx,bLatx,stationNameList); |
| 272 | 273 | // 初始化站点对象 |
| 273 | 274 | Station arg0 = new Station(); |
| ... | ... | @@ -699,76 +700,103 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 699 | 700 | * |
| 700 | 701 | * @return Map<String, Object> <SUCCESS ; ERROR> |
| 701 | 702 | */ |
| 703 | + @Transactional | |
| 702 | 704 | @Override |
| 703 | 705 | public Map<String, Object> stationSaveMap(Map<String, Object> map) { |
| 704 | 706 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 705 | 707 | try { |
| 706 | 708 | // 站点编码 |
| 707 | - String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); | |
| 709 | + String stationCod = ""; | |
| 708 | 710 | // 站点ID |
| 709 | - int stationId = Integer.valueOf(stationCod); | |
| 711 | + Integer stationId = null; | |
| 710 | 712 | // 站点名称 |
| 711 | - String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); | |
| 712 | - // 道路编码 | |
| 713 | - String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); | |
| 714 | - // 原坐标类型 | |
| 715 | - String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); | |
| 713 | + String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString(); | |
| 714 | + // 方向 | |
| 715 | + Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString()); | |
| 716 | 716 | // 原坐标点 |
| 717 | 717 | String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString(); |
| 718 | 718 | String bJwpointsArray[] = null; |
| 719 | 719 | if(bJwpoints!=null) { |
| 720 | 720 | bJwpointsArray = bJwpoints.split(" "); |
| 721 | 721 | } |
| 722 | - // WGS经纬度 | |
| 723 | - Float gLonx = null; | |
| 724 | - // WGS纬度 | |
| 725 | - Float gLaty = null; | |
| 726 | - if(bJwpointsArray.length>0) { | |
| 727 | - Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); | |
| 728 | - gLonx = (float)resultPoint.getLng(); | |
| 729 | - gLaty = (float)resultPoint.getLat(); | |
| 730 | - } | |
| 731 | - // 方向 | |
| 732 | - Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString()); | |
| 733 | - // 距离 | |
| 734 | - Double distances = map.get("distances").equals("") ? null : Double.parseDouble(map.get("distances").toString()); | |
| 735 | - // 时间 | |
| 736 | - Double toTime = map.get("toTime").equals("") ? null : Double.parseDouble(map.get("toTime").toString()); | |
| 737 | - // 城建坐标经度 | |
| 738 | - Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString()); | |
| 739 | - // 城建坐标纬度 | |
| 740 | - Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString()); | |
| 741 | - // 多边形原坐标点集合 | |
| 742 | - String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString(); | |
| 743 | - // 多边形WGS坐标点集合 | |
| 744 | - String gPloygonGrid =""; | |
| 745 | - if(!bPloygonGrid.equals("")) { | |
| 746 | - String bPloygonGridArray[] = bPloygonGrid.split(","); | |
| 747 | - int bLen_ = bPloygonGridArray.length; | |
| 748 | - for(int b = 0 ;b<bLen_;b++) { | |
| 749 | - String tempArray[]= bPloygonGridArray[b].split(" "); | |
| 750 | - Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); | |
| 751 | - if(b==0) { | |
| 752 | - gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | |
| 753 | - }else { | |
| 754 | - gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | |
| 755 | - } | |
| 756 | - } | |
| 757 | - } | |
| 722 | + List<Object[]> stationNameList = repository.findStationName(directions,zdmc); | |
| 723 | + Map<String, Object> isHaveMap = isHaveStationname(bJwpointsArray[0],bJwpointsArray[1],stationNameList); | |
| 758 | 724 | // 是否撤销 |
| 759 | 725 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 760 | - // 圆半径 | |
| 761 | - Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); | |
| 762 | - // 图形类型 | |
| 763 | - String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); | |
| 764 | 726 | // 版本 |
| 765 | 727 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 766 | 728 | // 说明 |
| 767 | 729 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 768 | - // 创建人 | |
| 769 | - Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); | |
| 770 | - // 修改人 | |
| 771 | - Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); | |
| 730 | + if(Boolean.parseBoolean(isHaveMap.get("isHave").toString())) { | |
| 731 | + stationId = Integer.parseInt(isHaveMap.get("id").toString()); | |
| 732 | + }else { | |
| 733 | + // 站点编码 | |
| 734 | + stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); | |
| 735 | + // 站点ID | |
| 736 | + stationId = Integer.valueOf(stationCod); | |
| 737 | + // 圆半径 | |
| 738 | + Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); | |
| 739 | + // 图形类型 | |
| 740 | + String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); | |
| 741 | + // 创建人 | |
| 742 | + Integer createBy = map.get("createBy").equals("") ? null : Integer.parseInt(map.get("createBy").toString()); | |
| 743 | + // 修改人 | |
| 744 | + Integer updateBy = map.get("updateBy").equals("") ? null : Integer.parseInt(map.get("updateBy").toString()); | |
| 745 | + // 城建坐标经度 | |
| 746 | + Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString()); | |
| 747 | + // 城建坐标纬度 | |
| 748 | + Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString()); | |
| 749 | + // 道路编码 | |
| 750 | + String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); | |
| 751 | + // 原坐标类型 | |
| 752 | + String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); | |
| 753 | + // WGS经纬度 | |
| 754 | + Float gLonx = null; | |
| 755 | + // WGS纬度 | |
| 756 | + Float gLaty = null; | |
| 757 | + if(bJwpointsArray.length>0) { | |
| 758 | + Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); | |
| 759 | + gLonx = (float)resultPoint.getLng(); | |
| 760 | + gLaty = (float)resultPoint.getLat(); | |
| 761 | + } | |
| 762 | + // 多边形原坐标点集合 | |
| 763 | + String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString(); | |
| 764 | + // 多边形WGS坐标点集合 | |
| 765 | + String gPloygonGrid =""; | |
| 766 | + if(!bPloygonGrid.equals("")) { | |
| 767 | + String bPloygonGridArray[] = bPloygonGrid.split(","); | |
| 768 | + int bLen_ = bPloygonGridArray.length; | |
| 769 | + for(int b = 0 ;b<bLen_;b++) { | |
| 770 | + String tempArray[]= bPloygonGridArray[b].split(" "); | |
| 771 | + Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); | |
| 772 | + if(b==0) { | |
| 773 | + gPloygonGrid = String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | |
| 774 | + }else { | |
| 775 | + gPloygonGrid = gPloygonGrid + ',' + String.valueOf(resultPoint.getLng()) + " " + String.valueOf(resultPoint.getLat()); | |
| 776 | + } | |
| 777 | + } | |
| 778 | + } | |
| 779 | + if(bPloygonGrid.equals("")) | |
| 780 | + bPloygonGrid = null; | |
| 781 | + else | |
| 782 | + bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | |
| 783 | + if(gPloygonGrid.equals("")) | |
| 784 | + gPloygonGrid = null; | |
| 785 | + else | |
| 786 | + gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | |
| 787 | + // 保存站点 | |
| 788 | + repository.stationSave(stationCod, zdmc, roadCoding, dbType, bJwpoints, | |
| 789 | + gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius, | |
| 790 | + shapesType, versions, descriptions, createBy, updateBy,stationId); | |
| 791 | + } | |
| 792 | + Station station = repository.findOne(stationId); | |
| 793 | + StationRoute arg0 = new StationRoute(); | |
| 794 | + // 距离 | |
| 795 | + Double distances = map.get("distances").equals("") ? null : Double.parseDouble(map.get("distances").toString()); | |
| 796 | + // 时间 | |
| 797 | + Double toTime = map.get("toTime").equals("") ? null : Double.parseDouble(map.get("toTime").toString()); | |
| 798 | + // 站点路由名称 | |
| 799 | + String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); | |
| 772 | 800 | // 线路ID |
| 773 | 801 | int line = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 774 | 802 | // 线路信息 |
| ... | ... | @@ -784,20 +812,6 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 784 | 812 | }else { |
| 785 | 813 | stationRouteCode = 100; |
| 786 | 814 | } |
| 787 | - if(bPloygonGrid.equals("")) | |
| 788 | - bPloygonGrid = null; | |
| 789 | - else | |
| 790 | - bPloygonGrid = "POLYGON((" + bPloygonGrid +"))"; | |
| 791 | - if(gPloygonGrid.equals("")) | |
| 792 | - gPloygonGrid = null; | |
| 793 | - else | |
| 794 | - gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; | |
| 795 | - // 保存站点 | |
| 796 | - repository.stationSave(stationCod, stationName, roadCoding, dbType, bJwpoints, | |
| 797 | - gLonx, gLaty, x, y, gPloygonGrid,bPloygonGrid, destroy, radius, | |
| 798 | - shapesType, versions, descriptions, createBy, updateBy,stationId); | |
| 799 | - Station station = repository.findOne(stationId); | |
| 800 | - StationRoute arg0 = new StationRoute(); | |
| 801 | 815 | // 线路 |
| 802 | 816 | arg0.setLine(resultLine); |
| 803 | 817 | arg0.setLineCode(resultLine.getLineCode()); |
| ... | ... | @@ -806,7 +820,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 806 | 820 | // 站点路由名称 |
| 807 | 821 | arg0.setStationName(stationName); |
| 808 | 822 | // 站点路由编码 |
| 809 | - arg0.setStationCode(stationCod); | |
| 823 | + arg0.setStationCode(station.getStationCod()); | |
| 810 | 824 | // 站点路由序号 |
| 811 | 825 | arg0.setStationRouteCode(stationRouteCode); |
| 812 | 826 | // 站点路由类型 |
| ... | ... | @@ -823,6 +837,7 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 823 | 837 | arg0.setDestroy(destroy); |
| 824 | 838 | // 站点路由说明 |
| 825 | 839 | arg0.setDescriptions(descriptions); |
| 840 | + routeRepository.stationUpdStationRouteCode(line, directions, stationRouteCode); | |
| 826 | 841 | routeRepository.save(arg0); |
| 827 | 842 | resultMap.put("status", ResponseCode.SUCCESS); |
| 828 | 843 | } catch (Exception e) { |
| ... | ... | @@ -849,112 +864,54 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 849 | 864 | */ |
| 850 | 865 | @Override |
| 851 | 866 | public Map<String, Object> stationUpdate(Map<String, Object> map) { |
| 852 | - | |
| 853 | 867 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 854 | - | |
| 855 | 868 | try { |
| 856 | - | |
| 857 | 869 | // 站点Id |
| 858 | 870 | Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString()); |
| 859 | - | |
| 860 | 871 | String stationCod = map.get("stationCod").equals("") ? "" : map.get("stationCod").toString(); |
| 861 | - | |
| 872 | + String zdmc = map.get("zdmc").equals("") ? "" : map.get("zdmc").toString(); | |
| 862 | 873 | // 站点名称 |
| 863 | 874 | String stationName = map.get("stationName").equals("") ? "" : map.get("stationName").toString(); |
| 864 | - | |
| 865 | 875 | // 所在道路编码 |
| 866 | 876 | String roadCoding = map.get("roadCoding").equals("") ? "" : map.get("roadCoding").toString(); |
| 867 | - | |
| 868 | 877 | // 经纬坐标类型 |
| 869 | 878 | String dbType = map.get("dbType").equals("") ? "" : map.get("dbType").toString(); |
| 870 | - | |
| 871 | 879 | // 百度经纬度坐标 |
| 872 | 880 | String bJwpoints = map.get("bJwpoints").equals("") ? "" : map.get("bJwpoints").toString(); |
| 873 | - | |
| 874 | - // WGS经纬度坐标 | |
| 875 | - // String gJwpoints = map.get("gJwpoints").equals("") ? "" : map.get("gJwpoints").toString(); | |
| 876 | - | |
| 877 | 881 | String bJwpointsArray[] =null; |
| 878 | - | |
| 879 | 882 | if(bJwpoints!=null) { |
| 880 | - | |
| 881 | 883 | bJwpointsArray = bJwpoints.split(" "); |
| 882 | - | |
| 883 | 884 | } |
| 884 | - | |
| 885 | 885 | // WGS经纬度 |
| 886 | 886 | Float gLonx = null; |
| 887 | - | |
| 888 | 887 | // WGS纬度 |
| 889 | 888 | Float gLaty = null; |
| 890 | - | |
| 891 | 889 | if(bJwpointsArray.length>0) { |
| 892 | - | |
| 893 | 890 | Location resultPoint = FromBDPointToWGSPoint(bJwpointsArray[0],bJwpointsArray[1]); |
| 894 | - | |
| 895 | 891 | gLonx = (float)resultPoint.getLng(); |
| 896 | - | |
| 897 | 892 | gLaty = (float)resultPoint.getLat(); |
| 898 | - | |
| 899 | 893 | } |
| 900 | - | |
| 901 | - /*// 站点地理位置WGS坐标经度 | |
| 902 | - String gLonx = ""; | |
| 903 | - | |
| 904 | - // 站点地理位置WGS坐标纬度 | |
| 905 | - String gLaty = ""; | |
| 906 | - | |
| 907 | - if(gJwpoints!=null) { | |
| 908 | - | |
| 909 | - String gJwpointsArray[] = gJwpoints.split(" "); | |
| 910 | - | |
| 911 | - gLonx = gJwpointsArray[0]; | |
| 912 | - | |
| 913 | - gLaty = gJwpointsArray[1]; | |
| 914 | - | |
| 915 | - }*/ | |
| 916 | - | |
| 917 | 894 | // 图形类型 |
| 918 | 895 | String shapesType = map.get("shapesType").equals("") ? "" : map.get("shapesType").toString(); |
| 919 | - | |
| 920 | 896 | // 圆形半径 |
| 921 | 897 | Integer radius = map.get("radius").equals("") ? null : Integer.parseInt(map.get("radius").toString()); |
| 922 | - | |
| 923 | - // 多边形空间WGS坐标点集合 | |
| 924 | - /*String gPolygonGrid = map.get("gPolygonGrid").equals("") ? "" : map.get("gPolygonGrid").toString();*/ | |
| 925 | - | |
| 926 | 898 | // 多边形空间原坐标坐标点集合 |
| 927 | 899 | String bPloygonGrid = map.get("bPolygonGrid").equals("") ? "" : map.get("bPolygonGrid").toString(); |
| 928 | - | |
| 929 | 900 | // 多边形WGS坐标点集合 |
| 930 | 901 | String gPloygonGrid =""; |
| 931 | - | |
| 932 | 902 | if(!bPloygonGrid.equals("")) { |
| 933 | - | |
| 934 | 903 | String bPloygonGridArray[] = bPloygonGrid.split(","); |
| 935 | - | |
| 936 | 904 | int bLen_ = bPloygonGridArray.length; |
| 937 | - | |
| 938 | 905 | for(int b = 0 ;b<bLen_;b++) { |
| 939 | - | |
| 940 | 906 | String tempArray[]= bPloygonGridArray[b].split(" "); |
| 941 | - | |
| 942 | 907 | Location resultPoint = FromBDPointToWGSPoint(tempArray[0],tempArray[1]); |
| 943 | - | |
| 944 | 908 | if(b==0) { |
| 945 | - | |
| 946 | 909 | gPloygonGrid = resultPoint.getLng() + " " + resultPoint.getLat(); |
| 947 | - | |
| 948 | 910 | }else { |
| 949 | - | |
| 950 | 911 | gPloygonGrid = gPloygonGrid + ',' + resultPoint.getLng() + " " + resultPoint.getLat(); |
| 951 | - | |
| 952 | 912 | } |
| 953 | - | |
| 954 | 913 | } |
| 955 | - | |
| 956 | 914 | } |
| 957 | - | |
| 958 | 915 | if(bPloygonGrid.equals("")) |
| 959 | 916 | bPloygonGrid = null; |
| 960 | 917 | else |
| ... | ... | @@ -964,116 +921,62 @@ public class StationServiceImpl extends BaseServiceImpl<Station, Integer> implem |
| 964 | 921 | gPloygonGrid = null; |
| 965 | 922 | else |
| 966 | 923 | gPloygonGrid = "POLYGON((" + gPloygonGrid +"))"; |
| 967 | - | |
| 968 | - | |
| 969 | 924 | // 是否撤销 |
| 970 | 925 | Integer destroy = map.get("destroy").equals("") ? null : Integer.parseInt(map.get("destroy").toString()); |
| 971 | - | |
| 972 | 926 | // 版本号 |
| 973 | 927 | Integer versions = map.get("versions").equals("") ? null : Integer.parseInt(map.get("versions").toString()); |
| 974 | - | |
| 975 | 928 | // 描述与说明 |
| 976 | 929 | String descriptions = map.get("descriptions").equals("") ? "" : map.get("descriptions").toString(); |
| 977 | - | |
| 978 | 930 | Float x = map.get("x").equals("") ? null : Float.parseFloat(map.get("x").toString()); |
| 979 | - | |
| 980 | 931 | Float y = map.get("y").equals("") ? null : Float.parseFloat(map.get("y").toString()); |
| 981 | - | |
| 982 | 932 | // 更新 |
| 983 | - repository.stationUpdate(stationCod, stationName, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid, gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId); | |
| 984 | - | |
| 985 | - | |
| 933 | + repository.stationUpdate(stationCod, zdmc, roadCoding, dbType, bJwpoints, gLonx, gLaty, x, y, bPloygonGrid, gPloygonGrid, destroy, radius, shapesType, versions, descriptions, stationId); | |
| 986 | 934 | // 站点路由Id |
| 987 | 935 | Integer stationRouteId = map.get("stationRouteId").equals("") ? null : Integer.parseInt(map.get("stationRouteId").toString()); |
| 988 | - | |
| 989 | 936 | StationRoute resultS = routeRepository.findOne(stationRouteId); |
| 990 | - | |
| 991 | 937 | // 站点路由序号 |
| 992 | 938 | String stationRouteCodeStr = map.get("stationRouteCode").equals("") ? null : map.get("stationRouteCode").toString(); |
| 993 | - | |
| 994 | 939 | Integer stationRouteCode = null; |
| 995 | - | |
| 996 | 940 | if(stationRouteCodeStr!=null) { |
| 997 | - | |
| 998 | 941 | String stationRouteCodeAraay[] = stationRouteCodeStr.split("_"); |
| 999 | - | |
| 1000 | 942 | int old_code = resultS.getStationRouteCode(); |
| 1001 | - | |
| 1002 | 943 | int new_code = Integer.parseInt(stationRouteCodeAraay[0].toString())+100; |
| 1003 | - | |
| 1004 | 944 | if(new_code==old_code){ |
| 1005 | - | |
| 1006 | 945 | stationRouteCode = new_code; |
| 1007 | - | |
| 1008 | 946 | }else { |
| 1009 | - | |
| 1010 | 947 | stationRouteCode = new_code-100+1; |
| 1011 | - | |
| 1012 | 948 | } |
| 1013 | - | |
| 1014 | 949 | }else { |
| 1015 | - | |
| 1016 | 950 | stationRouteCode = resultS.getStationRouteCode(); |
| 1017 | - | |
| 1018 | 951 | } |
| 1019 | - | |
| 1020 | 952 | stationRouteCode = stationRouteCode == null ? 100 : stationRouteCode; |
| 1021 | - | |
| 1022 | 953 | Integer LineId = map.get("stationRouteLine").equals("") ? null : Integer.parseInt(map.get("stationRouteLine").toString()); |
| 1023 | - | |
| 1024 | 954 | String stationMark = map.get("stationMark").equals("") ? null : map.get("stationMark").toString(); |
| 1025 | - | |
| 1026 | 955 | Double distances = map.get("distances").equals("") ? null : Double.parseDouble(map.get("distances").toString()); |
| 1027 | - | |
| 1028 | 956 | Double toTime = map.get("toTime").equals("") ? null : Double.parseDouble(map.get("toTime").toString()); |
| 1029 | - | |
| 1030 | 957 | Integer directions = map.get("directions").equals("") ? null : Integer.parseInt(map.get("directions").toString()); |
| 1031 | - | |
| 1032 | 958 | Station station = repository.findOne(stationId); |
| 1033 | - | |
| 1034 | 959 | Line line = lineRepository.findOne(LineId); |
| 1035 | - | |
| 1036 | - | |
| 1037 | 960 | StationRoute stationRoute = new StationRoute(); |
| 1038 | - | |
| 1039 | 961 | stationRoute.setStationName(stationName); |
| 1040 | - | |
| 1041 | 962 | stationRoute.setId(stationRouteId); |
| 1042 | - | |
| 1043 | 963 | stationRoute.setStationRouteCode(stationRouteCode); |
| 1044 | - | |
| 1045 | 964 | stationRoute.setStation(station); |
| 1046 | - | |
| 1047 | 965 | stationRoute.setStationCode(station.getStationCod()); |
| 1048 | - | |
| 1049 | 966 | stationRoute.setLine(line); |
| 1050 | - | |
| 1051 | 967 | stationRoute.setLineCode(line.getLineCode()); |
| 1052 | - | |
| 1053 | 968 | stationRoute.setStationMark(stationMark); |
| 1054 | - | |
| 1055 | 969 | stationRoute.setDistances(distances); |
| 1056 | - | |
| 1057 | 970 | stationRoute.setToTime(toTime); |
| 1058 | - | |
| 1059 | 971 | stationRoute.setDirections(directions); |
| 1060 | - | |
| 1061 | 972 | stationRoute.setVersions(versions); |
| 1062 | - | |
| 1063 | 973 | stationRoute.setDestroy(destroy); |
| 1064 | - | |
| 1065 | 974 | stationRoute.setDescriptions(descriptions); |
| 1066 | - | |
| 1067 | 975 | routeRepository.save(stationRoute); |
| 1068 | - | |
| 1069 | 976 | resultMap.put("status", ResponseCode.SUCCESS); |
| 1070 | - | |
| 1071 | 977 | } catch (Exception e) { |
| 1072 | - | |
| 1073 | 978 | resultMap.put("status", ResponseCode.ERROR); |
| 1074 | - | |
| 1075 | 979 | logger.error("save erro.", e); |
| 1076 | - | |
| 1077 | 980 | } |
| 1078 | 981 | return resultMap; |
| 1079 | 982 | } | ... | ... |
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java
| ... | ... | @@ -276,17 +276,22 @@ public class CwjyServiceImpl extends BaseServiceImpl<Cwjy,Integer> implements Cw |
| 276 | 276 | // TODO Auto-generated method stub |
| 277 | 277 | String rq=map.get("rq").toString(); |
| 278 | 278 | String nbbm=map.get("nbbh").toString(); |
| 279 | + String gsdm=map.get("gsdm_like").toString(); | |
| 280 | + | |
| 281 | + String fgsdm=map.get("fgsdm_like").toString(); | |
| 279 | 282 | String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm," |
| 280 | 283 | + "b.jyggh as jyggh,b.jzl as jzl ,b.stationid as stationid,b.jsy as jsy," |
| 281 | 284 | + "b.nylx as nylx,b.yj as yj,b.bz as bz,b.id as id ,c.jsy as ldgh FROM bsth_c_cwjy a "+ |
| 282 | 285 | " left join (" |
| 283 | 286 | + " select * from bsth_c_ylxxb b " |
| 284 | - + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " + | |
| 287 | + + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1 " | |
| 288 | + + " and gsdm = '"+gsdm+"') b " + | |
| 285 | 289 | " on a.nbbm=b.nbbm " |
| 286 | 290 | + "left join (select nbbm,group_concat(jsy) as jsy " |
| 287 | - + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+ | |
| 291 | + + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) " | |
| 292 | + + " and ssgsdm='"+gsdm+"' and fgsdm ='"+fgsdm+"' group by nbbm "+ | |
| 288 | 293 | " ) c on a.nbbm=c.nbbm " |
| 289 | - + "where a.nbbm like '%"+nbbm+"%'"; | |
| 294 | + + "where a.nbbm like '%"+nbbm+"%' and a.gsdm='"+gsdm+"' and a.fgsdm ='"+fgsdm+"'"; | |
| 290 | 295 | |
| 291 | 296 | List<Ylxxb> yList= jdbcTemplate.query(sql, |
| 292 | 297 | new RowMapper<Ylxxb>(){ | ... | ... |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| ... | ... | @@ -102,7 +102,8 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 102 | 102 | //当天YLXXB信息 |
| 103 | 103 | // List<Ylxxb> ylxxList=ylxxbRepository.obtainYlxx(rq); |
| 104 | 104 | //前一天所有车辆最后进场班次信息 |
| 105 | - List<Ylb> ylListBe=repository.obtainYlbefore(rq,"","","",""); | |
| 105 | +// List<Ylb> ylListBe=repository.obtainYlbefore(rq,"","","",""); | |
| 106 | + List<Ylb> ylListBe=repository.listMaxRqJcsx(rq, "", "", "", ""); | |
| 106 | 107 | List<Cyl> clyList=cylRepository.obtainCyl("",""); |
| 107 | 108 | //从排班表中计算出行驶的总里程 |
| 108 | 109 | List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList("", rq, "", "", "", ""); |
| ... | ... | @@ -180,7 +181,10 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 180 | 181 | t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString()); |
| 181 | 182 | t.setRq(sdf.parse(rq)); |
| 182 | 183 | t.setCreatetime(dNow); |
| 183 | - repository.save(t); | |
| 184 | + if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){ | |
| 185 | + repository.save(t); | |
| 186 | + } | |
| 187 | + | |
| 184 | 188 | |
| 185 | 189 | } |
| 186 | 190 | result = "success"; |
| ... | ... | @@ -237,7 +241,8 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 237 | 241 | // 当天YLXXB信息 |
| 238 | 242 | List<Ylxxb> ylxxList = ylxxbRepository.obtainYlxx(rq, 0,gsbm); |
| 239 | 243 | // 前一天所有车辆最后进场班次信息 |
| 240 | - List<Ylb> ylListBe = repository.obtainYlbefore(rq, gsbm, fgsbm, line, nbbm); | |
| 244 | +// List<Ylb> ylListBe = repository.obtainYlbefore(rq, gsbm, fgsbm, line, nbbm); | |
| 245 | + List<Ylb> ylListBe =repository.listMaxRqJcsx(rq, gsbm, fgsbm, line, nbbm); | |
| 241 | 246 | List<Cyl> clyList = cylRepository.obtainCyl(nbbm,gsbm); |
| 242 | 247 | // 从排班表中计算出行驶的总里程 |
| 243 | 248 | List<Map<String, Object>> listpb = scheduleRealInfoService.yesterdayDataList(line, rq, gsbm, fgsbm, "", nbbm); |
| ... | ... | @@ -322,7 +327,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 322 | 327 | t.setNbbm(map.get("clZbh").toString()); |
| 323 | 328 | t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString()); |
| 324 | 329 | t.setZlc(map.get("totalKilometers") == null ? 0.0 |
| 325 | - : Double.parseDouble(df.format(Double.parseDouble(map.get("totalKilometers").toString())))); | |
| 330 | + : Double.parseDouble(map.get("totalKilometers").toString())); | |
| 326 | 331 | t.setXlbm(map.get("xlBm") == null ? "" : map.get("xlBm").toString()); |
| 327 | 332 | t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); |
| 328 | 333 | t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString()); |
| ... | ... | @@ -330,12 +335,14 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 330 | 335 | t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString()); |
| 331 | 336 | t.setRq(sdf.parse(rq)); |
| 332 | 337 | t.setCreatetime(date); |
| 333 | - if(type.equals("add")){ | |
| 334 | - addList.add(t); | |
| 335 | - }else{ | |
| 336 | - updateList.add(t); | |
| 337 | - ins += t.getId().toString()+","; | |
| 338 | - } | |
| 338 | + if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){ | |
| 339 | + if(type.equals("add")){ | |
| 340 | + addList.add(t); | |
| 341 | + }else{ | |
| 342 | + updateList.add(t); | |
| 343 | + ins += t.getId().toString()+","; | |
| 344 | + } | |
| 345 | + } | |
| 339 | 346 | // repository.save(t); |
| 340 | 347 | newMap.put("status", ResponseCode.SUCCESS); |
| 341 | 348 | |
| ... | ... | @@ -405,7 +412,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 405 | 412 | String nbbm_eq = ylb.getNbbm(); |
| 406 | 413 | Date rq_eq = ylb.getRq(); |
| 407 | 414 | // 得到一天总的加油和里程(根据车,时间) |
| 408 | - List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); | |
| 415 | + List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm(),gsbm,fgsbm); | |
| 409 | 416 | // 保存总的加油量 |
| 410 | 417 | Double jzl = 0.0; |
| 411 | 418 | // 保存总的里程 |
| ... | ... | @@ -436,40 +443,53 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 436 | 443 | if(t.getNbbm().equals(ylb.getNbbm())){ |
| 437 | 444 | if (t.getJcsx() == 1) { |
| 438 | 445 | // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量 |
| 439 | - Double yl = t.getCzyl(); | |
| 440 | - Double jcyl = t.getCzyl(); | |
| 441 | - zyl =Arith.sub( Arith.add(jcyl, jzl),yl); | |
| 446 | +// Double yl = t.getCzyl(); | |
| 447 | +// Double jcyl = t.getCzyl(); | |
| 448 | + zyl =jzl; | |
| 442 | 449 | Double yh=0.0; |
| 443 | 450 | if(zlc>0){ |
| 444 | 451 | yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 445 | 452 | } |
| 446 | - nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh); | |
| 453 | + nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()), t.getCzyl()),yh); | |
| 447 | 454 | //把进场油量的小数和整数分别取出 |
| 448 | 455 | // int ylxs=(int) nextJzyl; 10.6--11 10.3--10 |
| 449 | - long l=Math.round(nextJzyl); | |
| 450 | - double ylxs=l*100/100; | |
| 451 | -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 452 | - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 453 | - t.setYh(yh); | |
| 454 | - t.setJzyl(ylxs); | |
| 455 | - nextJzyl=ylxs; | |
| 456 | + if(zlc>0){ | |
| 457 | + long l=Math.round(nextJzyl); | |
| 458 | + double ylxs=l*100/100; | |
| 459 | +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 460 | + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 461 | + t.setYh(yh); | |
| 462 | + t.setJzyl(ylxs); | |
| 463 | + nextJzyl=ylxs; | |
| 464 | + }else{ | |
| 465 | + t.setYh(yh); | |
| 466 | + t.setJzyl(nextJzyl); | |
| 467 | + } | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 456 | 471 | } else { |
| 457 | 472 | t.setCzyl(nextJzyl); |
| 458 | 473 | Double yh=0.0; |
| 459 | 474 | if(zlc>0){ |
| 460 | 475 | yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 461 | 476 | } |
| 462 | - nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh); | |
| 463 | - long l=Math.round(nextJzyl); | |
| 464 | - double ylxs=l*100/100; | |
| 465 | -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 466 | - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 467 | - t.setYh(yh); | |
| 468 | - t.setJzyl(ylxs); | |
| 469 | - nextJzyl= ylxs; | |
| 477 | + nextJzyl =Arith.sub( Arith.add(Arith.sub(t.getJzl(),t.getSh()),nextJzyl),yh); | |
| 478 | + if(zlc>0){ | |
| 479 | + long l=Math.round(nextJzyl); | |
| 480 | + double ylxs=l*100/100; | |
| 481 | +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 482 | + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 483 | + t.setYh(yh); | |
| 484 | + t.setJzyl(ylxs); | |
| 485 | + nextJzyl=ylxs; | |
| 486 | + }else{ | |
| 487 | + t.setYh(yh); | |
| 488 | + t.setJzyl(nextJzyl); | |
| 489 | + } | |
| 470 | 490 | } |
| 471 | 491 | repository.save(t); |
| 472 | - for (int z = 0; z < cylList.size(); z++) { | |
| 492 | + /*for (int z = 0; z < cylList.size(); z++) { | |
| 473 | 493 | Cyl cyl = cylList.get(z); |
| 474 | 494 | if (t.getNbbm().equals(cyl.getNbbm())) { |
| 475 | 495 | cyl.setCyl(t.getJzyl()); |
| ... | ... | @@ -477,7 +497,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 477 | 497 | break; |
| 478 | 498 | } |
| 479 | 499 | cylRepository.save(cyl); |
| 480 | - } | |
| 500 | + }*/ | |
| 481 | 501 | } |
| 482 | 502 | map2.put("status", ResponseCode.SUCCESS); |
| 483 | 503 | } |
| ... | ... | @@ -682,7 +702,8 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 682 | 702 | if(map.get("nbbm_eq")!=null){ |
| 683 | 703 | nbbm=map.get("nbbm_eq").toString(); |
| 684 | 704 | } |
| 685 | - List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm); | |
| 705 | +// List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm); | |
| 706 | + List<Ylb> ylListBe=repository.listMaxRqJcsx(rq, gsbm, fgsbm, xlbm, nbbm); | |
| 686 | 707 | List<Cyl> cylList=cylRepository.obtainCyl(nbbm, gsbm); |
| 687 | 708 | List<Ylb> ylbList=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm"); |
| 688 | 709 | List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,0,gsbm); |
| ... | ... | @@ -744,12 +765,13 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 744 | 765 | // double jzyl=Arith.add(t.getJzl(), t.getCzyl()); |
| 745 | 766 | t.setJzyl(Arith.add(t.getJzl(), t.getCzyl())); |
| 746 | 767 | t.setYh(0.0); |
| 747 | - if(fgsdm.equals(fgsbm)){ | |
| 768 | + if(!(t.getSsgsdm().equals("") || t.getFgsdm().equals(""))){ | |
| 748 | 769 | repository.save(t); |
| 749 | - if(null!=cyl){ | |
| 770 | + /*if(null!=cyl){ | |
| 750 | 771 | cyl.setCyl(Arith.add(t.getJzl(), t.getCzyl())); |
| 772 | + cyl.setUpdatetime(y1.getYyrq()); | |
| 751 | 773 | cylRepository.save(cyl); |
| 752 | - } | |
| 774 | + }*/ | |
| 753 | 775 | } |
| 754 | 776 | } |
| 755 | 777 | } |
| ... | ... | @@ -1042,7 +1064,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1042 | 1064 | t.setRylx(rylx); |
| 1043 | 1065 | t.setId(jsonObject.getInteger("id"));*/ |
| 1044 | 1066 | repository.ylbUpdate(id, czyl, jzyl, yh, sh, shyy, ns, rylx,yhlx); |
| 1045 | - for (int z = 0; z < cylList.size(); z++) { | |
| 1067 | + /*for (int z = 0; z < cylList.size(); z++) { | |
| 1046 | 1068 | Cyl cyl = cylList.get(z); |
| 1047 | 1069 | if (nbbm.equals(cyl.getNbbm())) { |
| 1048 | 1070 | cyl.setCyl(jzyl); |
| ... | ... | @@ -1050,7 +1072,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1050 | 1072 | break; |
| 1051 | 1073 | } |
| 1052 | 1074 | cylRepository.save(cyl); |
| 1053 | - } | |
| 1075 | + }*/ | |
| 1054 | 1076 | } |
| 1055 | 1077 | // List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList"); |
| 1056 | 1078 | |
| ... | ... | @@ -1090,7 +1112,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1090 | 1112 | String nbbm_eq = ylb.getNbbm(); |
| 1091 | 1113 | Date rq_eq = ylb.getRq(); |
| 1092 | 1114 | // 得到一天总的加油和里程(根据车,时间) |
| 1093 | - List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm()); | |
| 1115 | + List<Object[]> sumList = repository.sumLcYl(nbbm_eq, rq_eq,ylb.getXlbm(),ylb.getSsgsdm(),ylb.getFgsdm()); | |
| 1094 | 1116 | // 保存总的加油量 |
| 1095 | 1117 | Double jzl = 0.0; |
| 1096 | 1118 | // 保存总的里程 |
| ... | ... | @@ -1102,7 +1124,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1102 | 1124 | zlc = Arith.add(zlc, Double.valueOf(sumList.get(j)[1].toString())); |
| 1103 | 1125 | zsh = Arith.add(zsh, Double.valueOf(sumList.get(j)[2].toString())); |
| 1104 | 1126 | } |
| 1105 | - jzl = Arith.sub(jzl, zsh); | |
| 1127 | +// jzl = Arith.sub(jzl, zsh); | |
| 1106 | 1128 | //新的 损耗不等于 旧的损耗 总损耗从新算 |
| 1107 | 1129 | if(Arith.sub(ylb.getSh(),sh )!=0){ |
| 1108 | 1130 | zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh); |
| ... | ... | @@ -1126,20 +1148,25 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1126 | 1148 | t.setSh(sh); |
| 1127 | 1149 | t.setShyy(shyy); |
| 1128 | 1150 | } |
| 1129 | - Double jcyl = t.getCzyl(); | |
| 1130 | - zyl = Arith.sub(Arith.add(jcyl, jzl), yl); | |
| 1151 | +// Double jcyl = t.getCzyl(); | |
| 1152 | + zyl = jzl; | |
| 1131 | 1153 | Double yh = 0.0; |
| 1132 | 1154 | if (zlc > 0 && t.getZlc() > 0) { |
| 1133 | 1155 | yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 1134 | 1156 | } |
| 1135 | 1157 | nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh())); |
| 1136 | - long l=Math.round(nextJzyl); | |
| 1137 | - double ylxs=l*100/100; | |
| 1138 | -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 1139 | - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 1140 | - t.setJzyl(ylxs); | |
| 1141 | - t.setYh(yh); | |
| 1142 | - nextJzyl=ylxs; | |
| 1158 | + if(zlc>0){ | |
| 1159 | + long l=Math.round(nextJzyl); | |
| 1160 | + double ylxs=l*100/100; | |
| 1161 | +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 1162 | + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 1163 | + t.setYh(yh); | |
| 1164 | + t.setJzyl(ylxs); | |
| 1165 | + nextJzyl=ylxs; | |
| 1166 | + }else{ | |
| 1167 | + t.setYh(yh); | |
| 1168 | + t.setJzyl(nextJzyl); | |
| 1169 | + } | |
| 1143 | 1170 | } else { |
| 1144 | 1171 | if(t.getId()==id){ |
| 1145 | 1172 | t.setSh(sh); |
| ... | ... | @@ -1151,16 +1178,21 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1151 | 1178 | yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); |
| 1152 | 1179 | } |
| 1153 | 1180 | nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh())); |
| 1154 | - long l=Math.round(nextJzyl); | |
| 1155 | - double ylxs=l*100/100; | |
| 1156 | -// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 1157 | - yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 1158 | - t.setJzyl(ylxs); | |
| 1159 | - t.setYh(yh); | |
| 1160 | - nextJzyl=ylxs; | |
| 1181 | + if(zlc>0){ | |
| 1182 | + long l=Math.round(nextJzyl); | |
| 1183 | + double ylxs=l*100/100; | |
| 1184 | +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs)); | |
| 1185 | + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl)); | |
| 1186 | + t.setYh(yh); | |
| 1187 | + t.setJzyl(ylxs); | |
| 1188 | + nextJzyl=ylxs; | |
| 1189 | + }else{ | |
| 1190 | + t.setYh(yh); | |
| 1191 | + t.setJzyl(nextJzyl); | |
| 1192 | + } | |
| 1161 | 1193 | } |
| 1162 | 1194 | repository.save(t); |
| 1163 | - for (int z = 0; z < cylList.size(); z++) { | |
| 1195 | + /*for (int z = 0; z < cylList.size(); z++) { | |
| 1164 | 1196 | Cyl cyl = cylList.get(z); |
| 1165 | 1197 | if (t.getNbbm().equals(cyl.getNbbm())) { |
| 1166 | 1198 | cyl.setCyl(t.getJzyl()); |
| ... | ... | @@ -1168,7 +1200,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS |
| 1168 | 1200 | break; |
| 1169 | 1201 | } |
| 1170 | 1202 | cylRepository.save(cyl); |
| 1171 | - } | |
| 1203 | + }*/ | |
| 1172 | 1204 | } |
| 1173 | 1205 | newMap.put("status", ResponseCode.SUCCESS); |
| 1174 | 1206 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/ChildTaskPlanService.java
| ... | ... | @@ -3,6 +3,11 @@ package com.bsth.service.realcontrol; |
| 3 | 3 | import com.bsth.entity.realcontrol.ChildTaskPlan; |
| 4 | 4 | import com.bsth.service.BaseService; |
| 5 | 5 | |
| 6 | +import java.util.Map; | |
| 7 | + | |
| 6 | 8 | public interface ChildTaskPlanService extends BaseService<ChildTaskPlan, Long>{ |
| 7 | 9 | |
| 10 | + Map<String,Object> saveHistory(ChildTaskPlan childTask); | |
| 11 | + | |
| 12 | + Map<String,Object> delHistory(Long id); | |
| 8 | 13 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/RealMapService.java
| ... | ... | @@ -10,7 +10,7 @@ public interface RealMapService { |
| 10 | 10 | |
| 11 | 11 | Map<String,Object> carParkSpatialData(); |
| 12 | 12 | |
| 13 | - Map<String,Object> findRouteByLine(String lineCode); | |
| 13 | + Map<String, Object> findRouteByLine(String idx); | |
| 14 | 14 | |
| 15 | 15 | Map<String,Object> findRouteAndStationByLine(String lineCode); |
| 16 | 16 | ... | ... |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| ... | ... | @@ -138,7 +138,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 138 | 138 | |
| 139 | 139 | Map<String,Object> changeBcType(Long id, String bcType, String remarks); |
| 140 | 140 | |
| 141 | - //Map<String,Object> historySave(ScheduleRealInfo sch); | |
| 141 | + Map<String,Object> historySave(ScheduleRealInfo sch); | |
| 142 | 142 | |
| 143 | 143 | Map<String, Object> MapById(Long id) ; |
| 144 | 144 | |
| ... | ... | @@ -165,4 +165,8 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L |
| 165 | 165 | Map<String,Object> lateAdjust(String idx, float minute); |
| 166 | 166 | |
| 167 | 167 | List<ScheduleRealInfo> allLate2(String idx); |
| 168 | + | |
| 169 | + Map<String,Object> addToHistory(ScheduleRealInfo sch); | |
| 170 | + | |
| 171 | + Map<String, Object> deleteToHistory(Long id); | |
| 168 | 172 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ChildTaskPlanServiceImpl.java
| ... | ... | @@ -86,4 +86,33 @@ public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Lon |
| 86 | 86 | rs.put("t", sch); |
| 87 | 87 | return rs; |
| 88 | 88 | } |
| 89 | + | |
| 90 | + @Override | |
| 91 | + public Map<String, Object> saveHistory(ChildTaskPlan t) { | |
| 92 | + Map<String, Object> rs = new HashMap(); | |
| 93 | + try { | |
| 94 | + ScheduleRealInfo sch = t.getSchedule(); | |
| 95 | + //保存起终点名称 | |
| 96 | + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | |
| 97 | + if(StringUtils.isEmpty(t.getStartStationName())) | |
| 98 | + t.setStartStationName(BasicData.getStationNameByCode(t.getStartStation(), prefix)); | |
| 99 | + | |
| 100 | + if(StringUtils.isEmpty(t.getEndStationName())) | |
| 101 | + t.setEndStationName(BasicData.getStationNameByCode(t.getEndStation(), prefix)); | |
| 102 | + //先持久化子任务 | |
| 103 | + rs = super.save(t); | |
| 104 | + | |
| 105 | + rs.put("status", ResponseCode.SUCCESS); | |
| 106 | + }catch (Exception e){ | |
| 107 | + logger.error("", e); | |
| 108 | + rs.put("status", ResponseCode.ERROR); | |
| 109 | + rs.put("msg", e.getMessage()); | |
| 110 | + } | |
| 111 | + return rs; | |
| 112 | + } | |
| 113 | + | |
| 114 | + @Override | |
| 115 | + public Map<String, Object> delHistory(Long id) { | |
| 116 | + return super.delete(id); | |
| 117 | + } | |
| 89 | 118 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java
| ... | ... | @@ -2,11 +2,15 @@ package com.bsth.service.realcontrol.impl; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.common.ResponseCode; |
| 4 | 4 | import com.bsth.controller.realcontrol.dto.StationSpatialData; |
| 5 | +import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | |
| 5 | 6 | import com.bsth.entity.CarPark; |
| 6 | 7 | import com.bsth.service.realcontrol.RealMapService; |
| 7 | 8 | import com.bsth.service.realcontrol.dto.SectionRouteCoords; |
| 8 | 9 | import com.bsth.util.TransGPS; |
| 10 | +import com.google.common.base.Joiner; | |
| 9 | 11 | import com.google.common.base.Splitter; |
| 12 | +import com.google.common.collect.ArrayListMultimap; | |
| 13 | +import com.vividsolutions.jts.geom.*; | |
| 10 | 14 | import org.slf4j.Logger; |
| 11 | 15 | import org.slf4j.LoggerFactory; |
| 12 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -74,10 +78,17 @@ public class RealMapServiceImpl implements RealMapService { |
| 74 | 78 | } |
| 75 | 79 | |
| 76 | 80 | @Override |
| 77 | - public Map<String, Object> findRouteByLine(String lineCode) { | |
| 81 | + public Map<String, Object> findRouteByLine(String idx) { | |
| 78 | 82 | Map<String, Object> rs = new HashMap<>(); |
| 79 | - String sql = "SELECT r.ID,r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,r.DIRECTIONS,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) GSECTION_VECTOR,s.SECTION_DISTANCE,s.SECTION_TIME FROM bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section_code=s.section_code WHERE r.line_code=? and r.destroy=0 order by sectionroute_code"; | |
| 80 | - List<SectionRouteCoords> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(SectionRouteCoords.class), lineCode); | |
| 83 | + StringBuilder inCond = new StringBuilder("("); | |
| 84 | + List<String> codeList = Splitter.on(",").splitToList(idx); | |
| 85 | + for(String lineCode : codeList){ | |
| 86 | + inCond.append("'" + lineCode + "',"); | |
| 87 | + } | |
| 88 | + inCond.deleteCharAt(inCond.length() - 1).append(")"); | |
| 89 | + | |
| 90 | + String sql = "SELECT r.ID,r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,r.DIRECTIONS,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) GSECTION_VECTOR,s.SECTION_DISTANCE,s.SECTION_TIME FROM bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section_code=s.section_code WHERE r.line_code in "+inCond.toString()+" and r.destroy=0 order by sectionroute_code"; | |
| 91 | + List<SectionRouteCoords> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(SectionRouteCoords.class)); | |
| 81 | 92 | |
| 82 | 93 | //排序 |
| 83 | 94 | Collections.sort(list, new Comparator<SectionRouteCoords>() { |
| ... | ... | @@ -87,28 +98,40 @@ public class RealMapServiceImpl implements RealMapService { |
| 87 | 98 | } |
| 88 | 99 | }); |
| 89 | 100 | |
| 90 | - List<String> upList = new ArrayList<>(), | |
| 91 | - downList = new ArrayList<>(); | |
| 92 | - | |
| 93 | - String vectorStr = ""; | |
| 101 | + ArrayListMultimap<String, SectionRouteCoords> listMultimap = ArrayListMultimap.create(); | |
| 94 | 102 | for (SectionRouteCoords sr : list) { |
| 95 | - vectorStr = sr.getGsectionVector(); | |
| 96 | - vectorStr = vectorStr.substring(11, vectorStr.length() - 2); | |
| 97 | - | |
| 98 | - if (sr.getDirections() == 0) | |
| 99 | - upList.add(vectorStr); | |
| 100 | - else | |
| 101 | - downList.add(vectorStr); | |
| 103 | + //按lineCode 分组 | |
| 104 | + listMultimap.put(sr.getLineCode(), sr); | |
| 105 | + } | |
| 106 | + //坐标转换 | |
| 107 | + Map<String, Object> subMap; | |
| 108 | + Set<String> ks = listMultimap.keySet(); | |
| 109 | + List<SectionRouteCoords> sublist; | |
| 110 | + List<String> upList,downList; | |
| 111 | + String vectorStr = ""; | |
| 112 | + for(String k : ks){ | |
| 113 | + subMap = new HashMap<>(); | |
| 114 | + sublist = listMultimap.get(k); | |
| 115 | + upList = new ArrayList<>(); | |
| 116 | + downList = new ArrayList<>(); | |
| 117 | + for(SectionRouteCoords sr : sublist){ | |
| 118 | + vectorStr = sr.getGsectionVector(); | |
| 119 | + vectorStr = vectorStr.substring(11, vectorStr.length() - 2); | |
| 120 | + if (sr.getDirections() == 0) | |
| 121 | + upList.add(vectorStr); | |
| 122 | + else | |
| 123 | + downList.add(vectorStr); | |
| 124 | + } | |
| 125 | + subMap.put("up", upList); | |
| 126 | + //subMap.put("upJoins", jointCoords(upList)); | |
| 127 | + subMap.put("down", downList); | |
| 128 | + subMap.put("up_bd", multiWgsToBd(upList)); | |
| 129 | + subMap.put("down_bd", multiWgsToBd(downList)); | |
| 130 | + subMap.put("up_gcj", multiWgsToGcj(upList)); | |
| 131 | + subMap.put("down_gcj", multiWgsToGcj(downList)); | |
| 132 | + | |
| 133 | + rs.put(k, subMap); | |
| 102 | 134 | } |
| 103 | - | |
| 104 | - rs.put("up", upList); | |
| 105 | - rs.put("down", downList); | |
| 106 | - rs.put("up_bd", multiWgsToBd(upList)); | |
| 107 | - rs.put("down_bd", multiWgsToBd(downList)); | |
| 108 | - rs.put("up_gcj", multiWgsToGcj(upList)); | |
| 109 | - rs.put("down_gcj", multiWgsToGcj(downList)); | |
| 110 | - | |
| 111 | - rs.put("lineId", lineCode); | |
| 112 | 135 | return rs; |
| 113 | 136 | } |
| 114 | 137 | |
| ... | ... | @@ -227,4 +250,171 @@ public class RealMapServiceImpl implements RealMapService { |
| 227 | 250 | } |
| 228 | 251 | return gcjList; |
| 229 | 252 | } |
| 253 | + | |
| 254 | + /** | |
| 255 | + * 将相连的路段拼接起来,去掉接口覆盖区域。 | |
| 256 | + * 主要因为前端地图绘制时,过多的路段会带来性能消耗。在这里提前拼接好以减少路段数量 | |
| 257 | + * @param list | |
| 258 | + * @return | |
| 259 | + */ | |
| 260 | + private List<String> jointCoords(List<String> list){ | |
| 261 | + List<String> rs = new ArrayList<>(); | |
| 262 | + int len = list.size(); | |
| 263 | + if(len == 0) | |
| 264 | + return rs; | |
| 265 | + | |
| 266 | + String joinstr = list.get(0); | |
| 267 | + String str; | |
| 268 | + for(int i = 1; i < len; i ++){ | |
| 269 | + str = jointCoords(joinstr.toString(), list.get(i)); | |
| 270 | + if(str != null) | |
| 271 | + joinstr = str; | |
| 272 | + else{ | |
| 273 | + rs.add(joinstr.toString()); | |
| 274 | + joinstr = list.get(i); | |
| 275 | + } | |
| 276 | + } | |
| 277 | + rs.add(joinstr); | |
| 278 | + return rs; | |
| 279 | + } | |
| 280 | + | |
| 281 | + static GeometryFactory geometryFactory = new GeometryFactory(); | |
| 282 | + private String jointCoords(String c1, String c2){ | |
| 283 | + String rs=null; | |
| 284 | + LineString s1 = createLineString(c1); | |
| 285 | + LineString s2 = createLineString(c2); | |
| 286 | + | |
| 287 | + | |
| 288 | + /*if(s1.intersects(s2)){ | |
| 289 | + //2条线相交 | |
| 290 | + Geometry g = s1.intersection(s2); | |
| 291 | + Point inPoint = geometryFactory.createPoint(g.getCoordinates()[0]); | |
| 292 | + //s1 = replacePoint(s1, s1.getCoordinates().length - 1, inPoint); | |
| 293 | + //s2 = replacePoint(s2, 0, inPoint); | |
| 294 | + | |
| 295 | + //rs = toString(s1); | |
| 296 | + //rs += ("," + toString(s2)); | |
| 297 | + rs = replacePoint(c1, s1.getCoordinates().length - 1, inPoint); | |
| 298 | + rs += ("," + replacePoint(c2, 0, null)); | |
| 299 | + } | |
| 300 | + else {*/ | |
| 301 | + //距离10米内的点直接连起来 | |
| 302 | + double distance = GeoUtils.getDistanceLineToLine(s1.getStartPoint(), s1.getEndPoint(), s2.getStartPoint(), s2.getEndPoint()); | |
| 303 | + if(distance < 10){ | |
| 304 | + //s2 = replacePoint(s2, 0, s1.getEndPoint()); | |
| 305 | + rs = c1; | |
| 306 | + | |
| 307 | + //获取c1终点到 c2 的垂直交点 | |
| 308 | + //s1.getEndPoint() | |
| 309 | + //rs += ("," + replacePoint(c2, 0, null)); | |
| 310 | + //rs = toString(s1); | |
| 311 | + //rs += ("," + toString(s2)); | |
| 312 | + } | |
| 313 | + //} | |
| 314 | + return rs; | |
| 315 | + } | |
| 316 | + | |
| 317 | + /** | |
| 318 | + * 替换线段中指定的一个点位 | |
| 319 | + * @param index | |
| 320 | + * @param p | |
| 321 | + | |
| 322 | + private LineString replacePoint(LineString line, int index, Point p){ | |
| 323 | + Coordinate[] array = line.getCoordinates(); | |
| 324 | + array[index] = p.getCoordinate(); | |
| 325 | + | |
| 326 | + return geometryFactory.createLineString(array); | |
| 327 | + }*/ | |
| 328 | + | |
| 329 | + private String replacePoint(String lineStr, int index, Point p){ | |
| 330 | + List<String> list = new ArrayList<>(Splitter.on(",").splitToList(lineStr)); | |
| 331 | + list.remove(index); | |
| 332 | + if(p != null){ | |
| 333 | + list.add(index, p.getX() + " " + p.getY()); | |
| 334 | + } | |
| 335 | + return Joiner.on(",").join(list); | |
| 336 | + } | |
| 337 | + | |
| 338 | + private LineString createLineString(String c){ | |
| 339 | + List<String> list = Splitter.on(",").splitToList(c); | |
| 340 | + | |
| 341 | + Coordinate[] cds = new Coordinate[list.size()]; | |
| 342 | + String[] strs; | |
| 343 | + for(int i = 0; i < list.size(); i ++){ | |
| 344 | + strs = list.get(i).split(" "); | |
| 345 | + cds[i] = new Coordinate(Float.parseFloat(strs[1]), Float.parseFloat(strs[0])); | |
| 346 | + } | |
| 347 | + return geometryFactory.createLineString(cds); | |
| 348 | + } | |
| 349 | + | |
| 350 | + private String toString(LineString line){ | |
| 351 | + Coordinate[] all = line.getCoordinates(); | |
| 352 | + | |
| 353 | + Coordinate[] cs; | |
| 354 | + StringBuilder sb = new StringBuilder(""); | |
| 355 | + for(int i = 0; i < all.length - 1; i ++){ | |
| 356 | + cs = new Coordinate[2]; | |
| 357 | + cs[0] = all[i]; | |
| 358 | + cs[1] = all[i + 1]; | |
| 359 | + | |
| 360 | + sb.append("," + cs[0].y + " " + cs[0].x); | |
| 361 | + sb.append("," + cs[1].y + " " + cs[1].x); | |
| 362 | + } | |
| 363 | + sb.deleteCharAt(0); | |
| 364 | + return sb.toString(); | |
| 365 | + } | |
| 366 | + | |
| 367 | +/* private String truncationEnd(LineString lineString, Point p){ | |
| 368 | + Coordinate[] all = lineString.getCoordinates(); | |
| 369 | + LineString sl; | |
| 370 | + | |
| 371 | + Coordinate[] cs; | |
| 372 | + StringBuilder sb = new StringBuilder(""); | |
| 373 | + double threshold = 0.1,distance; | |
| 374 | + for(int i = 0; i < all.length - 1; i ++){ | |
| 375 | + cs = new Coordinate[2]; | |
| 376 | + cs[0] = all[i]; | |
| 377 | + cs[1] = all[i + 1]; | |
| 378 | + sl = geometryFactory.createLineString(cs); | |
| 379 | + | |
| 380 | + sb.append("," + cs[0].y + " " + cs[0].x); | |
| 381 | + distance = GeoUtils.getDistanceFromLine(sl, p); | |
| 382 | + if(distance < threshold){ | |
| 383 | + sb.append("," + p.getY() + " " + p.getX()); | |
| 384 | + break; | |
| 385 | + } | |
| 386 | + else | |
| 387 | + sb.append("," + cs[1].y + " " + cs[1].x); | |
| 388 | + } | |
| 389 | + sb.deleteCharAt(0); | |
| 390 | + return sb.toString(); | |
| 391 | + } | |
| 392 | + | |
| 393 | + private String truncationStart(LineString lineString, Point p){ | |
| 394 | + Coordinate[] all = lineString.getCoordinates(); | |
| 395 | + LineString sl; | |
| 396 | + | |
| 397 | + Coordinate[] cs; | |
| 398 | + StringBuilder sb = new StringBuilder(""); | |
| 399 | + double threshold = 0.1,distance; | |
| 400 | + for(int i = 0; i < all.length - 1; i ++){ | |
| 401 | + cs = new Coordinate[2]; | |
| 402 | + cs[0] = all[i]; | |
| 403 | + cs[1] = all[i + 1]; | |
| 404 | + sl = geometryFactory.createLineString(cs); | |
| 405 | + | |
| 406 | + distance = GeoUtils.getDistanceFromLine(sl, p); | |
| 407 | + if(distance < threshold){ | |
| 408 | + sb.append("," + p.getY() + " " + p.getX()); | |
| 409 | + sb.append("," + cs[1].y + " " + cs[1].x); | |
| 410 | + break; | |
| 411 | + } | |
| 412 | + else{ | |
| 413 | + sb.append("," + cs[0].y + " " + cs[0].x); | |
| 414 | + sb.append("," + cs[1].y + " " + cs[1].x); | |
| 415 | + } | |
| 416 | + } | |
| 417 | + sb.deleteCharAt(0); | |
| 418 | + return sb.toString(); | |
| 419 | + }*/ | |
| 230 | 420 | } | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -49,10 +49,7 @@ import com.bsth.service.sys.DutyEmployeeService; |
| 49 | 49 | import com.bsth.util.*; |
| 50 | 50 | import com.bsth.websocket.handler.SendUtils; |
| 51 | 51 | import com.google.common.base.Splitter; |
| 52 | -import com.google.common.collect.ArrayListMultimap; | |
| 53 | -import com.google.common.collect.BiMap; | |
| 54 | 52 | import com.google.common.collect.Lists; |
| 55 | -import com.google.common.collect.Multimap; | |
| 56 | 53 | import org.apache.commons.lang3.StringEscapeUtils; |
| 57 | 54 | import org.apache.commons.lang3.StringUtils; |
| 58 | 55 | import org.joda.time.format.DateTimeFormat; |
| ... | ... | @@ -137,19 +134,60 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 137 | 134 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 138 | 135 | |
| 139 | 136 | SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), |
| 140 | - sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"), | |
| 141 | 137 | sdfSimple = new SimpleDateFormat("yyyyMMdd"); |
| 142 | 138 | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * 车辆是否存在 | |
| 142 | + * @param gsbm 公司编码 | |
| 143 | + * @param nbbm 车辆自编号 | |
| 144 | + * @return | |
| 145 | + */ | |
| 146 | + private boolean carExist(String gsbm, String nbbm){ | |
| 147 | + return BasicData.deviceId2NbbmMap.inverse().containsKey(nbbm); | |
| 148 | + } | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * 获取人员姓名 | |
| 152 | + * @param gsbm 公司编码 | |
| 153 | + * @param gh 人员工号 | |
| 154 | + * @return | |
| 155 | + */ | |
| 156 | + private String getPersonName(String gsbm, String gh){ | |
| 157 | + return BasicData.allPerson.get(gsbm + '-' + gh); | |
| 158 | + } | |
| 159 | + | |
| 160 | + @Override | |
| 161 | + public Iterable<ScheduleRealInfo> list(Map<String, Object> map) { | |
| 162 | + Iterator<ScheduleRealInfo> iterator = super.list(map).iterator(); | |
| 163 | + Set<ScheduleRealInfo> set = new HashSet<>(100); | |
| 164 | + | |
| 165 | + DateTimeFormatter fmtyyyyMMddHHmm = DateTimeFormat.forPattern("yyyy-MM-ddHH:mm"); | |
| 166 | + //计算时间戳 | |
| 167 | + ScheduleRealInfo sch; | |
| 168 | + while(iterator.hasNext()){ | |
| 169 | + sch = iterator.next(); | |
| 170 | + //待发时间戳 | |
| 171 | + sch.setDfsjT(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getDfsj())); | |
| 172 | + //实发时间戳 | |
| 173 | + if(StringUtils.isNotEmpty(sch.getFcsjActual())){ | |
| 174 | + sch.setFcsjActualTime(fmtyyyyMMddHHmm.parseMillis(sch.getRealExecDate() + sch.getFcsjActual())); | |
| 175 | + } | |
| 176 | + set.add(sch); | |
| 177 | + } | |
| 178 | + return set; | |
| 179 | + } | |
| 180 | + | |
| 143 | 181 | @Override |
| 144 | 182 | public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) { |
| 145 | 183 | List<String> lineList = Lists.newArrayList(Splitter.on(',').trimResults().omitEmptyStrings().split(lines)); |
| 146 | 184 | |
| 147 | - Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | |
| 185 | + /*Multimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); | |
| 148 | 186 | |
| 149 | 187 | for (String lineCode : lineList) { |
| 150 | 188 | mMap.putAll(lineCode, dayOfSchedule.findByLineCode(lineCode)); |
| 151 | - } | |
| 152 | - return mMap.asMap(); | |
| 189 | + }*/ | |
| 190 | + return dayOfSchedule.findByLineCodes(lineList); | |
| 153 | 191 | } |
| 154 | 192 | |
| 155 | 193 | private final static long DAY_TIME = 1000 * 60 * 60 * 24L; |
| ... | ... | @@ -317,6 +355,97 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 317 | 355 | return rsList; |
| 318 | 356 | } |
| 319 | 357 | |
| 358 | + /** | |
| 359 | + * 添加到历史库 | |
| 360 | + * @param t | |
| 361 | + * @return | |
| 362 | + */ | |
| 363 | + @Override | |
| 364 | + public Map<String, Object> addToHistory(ScheduleRealInfo t) { | |
| 365 | + Map<String, Object> rs = new HashMap<>(); | |
| 366 | + try { | |
| 367 | + if (!carExist(t.getGsBm(), t.getClZbh())) { | |
| 368 | + rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); | |
| 369 | + rs.put("status", ResponseCode.ERROR); | |
| 370 | + return rs; | |
| 371 | + } | |
| 372 | + | |
| 373 | + SysUser user = SecurityUtils.getCurrentUser(); | |
| 374 | + //String schDate = DayOfSchedule.currSchDateMap.get(t.getXlBm()); | |
| 375 | + | |
| 376 | + SimpleDateFormat sdfyyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"), sdfyyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-ddHH:mm"); | |
| 377 | + | |
| 378 | + if (StringUtils.isEmpty(t.getjGh())) { | |
| 379 | + rs.put("status", ResponseCode.ERROR); | |
| 380 | + rs.put("msg", "驾驶员工号不能为空!"); | |
| 381 | + return rs; | |
| 382 | + } | |
| 383 | + //截取驾驶员工号 | |
| 384 | + if (t.getjGh().indexOf("-") != -1) { | |
| 385 | + t.setjGh(t.getjGh().split("-")[1]); | |
| 386 | + } | |
| 387 | + //检查驾驶员工号 | |
| 388 | + String jName = getPersonName(t.getGsBm() ,t.getjGh()); | |
| 389 | + if(StringUtils.isEmpty(jName)){ | |
| 390 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员"); | |
| 391 | + rs.put("status", ResponseCode.ERROR); | |
| 392 | + return rs; | |
| 393 | + } | |
| 394 | + else if(StringUtils.isEmpty(t.getjName())){ | |
| 395 | + t.setjName(jName);//补上驾驶员名称 | |
| 396 | + } | |
| 397 | + | |
| 398 | + //有售票员 | |
| 399 | + if(StringUtils.isNotEmpty(t.getsGh())){ | |
| 400 | + String sName = getPersonName(t.getGsBm() , t.getsGh()); | |
| 401 | + if(StringUtils.isEmpty(sName)){ | |
| 402 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员"); | |
| 403 | + rs.put("status", ResponseCode.ERROR); | |
| 404 | + return rs; | |
| 405 | + }else if(StringUtils.isEmpty(t.getsName())){ | |
| 406 | + t.setsName(sName);//补上售票员名称 | |
| 407 | + } | |
| 408 | + } | |
| 409 | + | |
| 410 | + //公司 和 分公司名称 | |
| 411 | + t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm())); | |
| 412 | + t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getGsBm() + "_" + t.getFgsBm())); | |
| 413 | + | |
| 414 | + //t.setScheduleDateStr(schDate); | |
| 415 | + t.setScheduleDate(sdfyyyyMMdd.parse(t.getScheduleDateStr())); | |
| 416 | + t.setRealExecDate(t.getScheduleDateStr()); | |
| 417 | + t.setCreateBy(user); | |
| 418 | + t.setSflj(true); | |
| 419 | + t.setLate(false); | |
| 420 | + t.setDfsj(t.getFcsj()); | |
| 421 | + t.setZdsjT(sdfyyyyMMddHHmm.parse(t.getScheduleDateStr() + t.getZdsj()).getTime()); | |
| 422 | + t.setJhlcOrig(t.getJhlc()); | |
| 423 | + | |
| 424 | + //班次历时 | |
| 425 | + t.setBcsj(DateUtils.calcHHmmDiff(t.getFcsj(), t.getZdsj()) / 1000 / 60); | |
| 426 | + | |
| 427 | + //起终点名称 | |
| 428 | + String prefix = t.getXlBm() + "_" + t.getXlDir() + "_"; | |
| 429 | + t.setQdzName(BasicData.getStationNameByCode(t.getQdzCode(), prefix)); | |
| 430 | + t.setZdzName(BasicData.getStationNameByCode(t.getZdzCode(), prefix)); | |
| 431 | + | |
| 432 | + //计算班次实际执行时间 | |
| 433 | + schAttrCalculator.calcRealDate(t).calcAllTimeByFcsj(t); | |
| 434 | + if (t.getZdsjT() < t.getFcsjT()) { | |
| 435 | + rs.put("status", ResponseCode.ERROR); | |
| 436 | + rs.put("msg", "起终点时间异常!"); | |
| 437 | + return rs; | |
| 438 | + } | |
| 439 | + | |
| 440 | + //实时入库 | |
| 441 | + rs = super.save(t); | |
| 442 | + } catch (Exception e) { | |
| 443 | + logger.error("", e); | |
| 444 | + rs.put("status", ResponseCode.ERROR); | |
| 445 | + } | |
| 446 | + return rs; | |
| 447 | + } | |
| 448 | + | |
| 320 | 449 | |
| 321 | 450 | /** |
| 322 | 451 | * 临加班次 |
| ... | ... | @@ -325,7 +454,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 325 | 454 | public Map<String, Object> save(ScheduleRealInfo t) { |
| 326 | 455 | Map<String, Object> rs = new HashMap<>(); |
| 327 | 456 | try { |
| 328 | - if (BasicData.deviceId2NbbmMap.inverse().get(t.getClZbh()) == null) { | |
| 457 | + if (!carExist(t.getGsBm(), t.getClZbh())) { | |
| 329 | 458 | rs.put("msg", "车辆 " + t.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); |
| 330 | 459 | rs.put("status", ResponseCode.ERROR); |
| 331 | 460 | return rs; |
| ... | ... | @@ -341,10 +470,36 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 341 | 470 | rs.put("msg", "驾驶员工号不能为空!"); |
| 342 | 471 | return rs; |
| 343 | 472 | } |
| 344 | - //截取工号 | |
| 473 | + //截取驾驶员工号 | |
| 345 | 474 | if (t.getjGh().indexOf("-") != -1) { |
| 346 | 475 | t.setjGh(t.getjGh().split("-")[1]); |
| 347 | 476 | } |
| 477 | + //检查驾驶员工号 | |
| 478 | + String jName = getPersonName(t.getGsBm() ,t.getjGh()); | |
| 479 | + if(StringUtils.isEmpty(jName)){ | |
| 480 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的驾驶员"); | |
| 481 | + rs.put("status", ResponseCode.ERROR); | |
| 482 | + return rs; | |
| 483 | + } | |
| 484 | + else if(StringUtils.isEmpty(t.getjName())){ | |
| 485 | + t.setjName(jName);//补上驾驶员名称 | |
| 486 | + } | |
| 487 | + | |
| 488 | + //有售票员 | |
| 489 | + if(StringUtils.isNotEmpty(t.getsGh())){ | |
| 490 | + String sName = getPersonName(t.getGsBm() , t.getsGh()); | |
| 491 | + if(StringUtils.isEmpty(sName)){ | |
| 492 | + rs.put("msg", t.getXlName() + "所属的公司编码下找不到工号为【" + t.getjGh() + "】的售票员"); | |
| 493 | + rs.put("status", ResponseCode.ERROR); | |
| 494 | + return rs; | |
| 495 | + }else if(StringUtils.isEmpty(t.getsName())){ | |
| 496 | + t.setsName(sName);//补上售票员名称 | |
| 497 | + } | |
| 498 | + } | |
| 499 | + | |
| 500 | + //公司 和 分公司名称 | |
| 501 | + t.setGsName(BasicData.businessCodeNameMap.get(t.getGsBm())); | |
| 502 | + t.setFgsName(BasicData.businessFgsCodeNameMap.get(t.getGsBm() + "_" + t.getFgsBm())); | |
| 348 | 503 | |
| 349 | 504 | t.setScheduleDateStr(schDate); |
| 350 | 505 | t.setScheduleDate(sdfyyyyMMdd.parse(schDate)); |
| ... | ... | @@ -385,7 +540,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 385 | 540 | dayOfSchedule.reCalcExecPlan(t.getClZbh()); |
| 386 | 541 | |
| 387 | 542 | |
| 388 | - rs.put("ts", ts); | |
| 543 | + rs.put("ts", ts); | |
| 389 | 544 | rs.put("t", t); |
| 390 | 545 | } catch (Exception e) { |
| 391 | 546 | logger.error("", e); |
| ... | ... | @@ -394,6 +549,41 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 394 | 549 | return rs; |
| 395 | 550 | } |
| 396 | 551 | |
| 552 | + /** | |
| 553 | + * 删除历史表临加班次 | |
| 554 | + * @param id | |
| 555 | + * @return | |
| 556 | + */ | |
| 557 | + @Override | |
| 558 | + public Map<String, Object> deleteToHistory(Long id) { | |
| 559 | + Map<String, Object> rs = new HashMap<>(); | |
| 560 | + rs.put("status", ResponseCode.ERROR); | |
| 561 | + | |
| 562 | + try { | |
| 563 | + ScheduleRealInfo sch = super.findById(id); | |
| 564 | + if (sch == null) { | |
| 565 | + rs.put("msg", "无效的id号"); | |
| 566 | + return rs; | |
| 567 | + } | |
| 568 | + | |
| 569 | + if (!sch.isSflj()) { | |
| 570 | + rs.put("msg", "你只能删除临加班次"); | |
| 571 | + return rs; | |
| 572 | + } | |
| 573 | + | |
| 574 | + //解除和调度指令的外键约束 | |
| 575 | + jdbcTemplate.update(Constants.REMOVE_DIRECTIVE_SCH_FK, id); | |
| 576 | + | |
| 577 | + //数据库删除 | |
| 578 | + rs = super.delete(id); | |
| 579 | + }catch (Exception e){ | |
| 580 | + logger.error("", e); | |
| 581 | + rs.put("msg", e.getMessage()); | |
| 582 | + } | |
| 583 | + | |
| 584 | + return rs; | |
| 585 | + } | |
| 586 | + | |
| 397 | 587 | @Override |
| 398 | 588 | public Map<String, Object> delete(Long id) { |
| 399 | 589 | Map<String, Object> rs = new HashMap<>(); |
| ... | ... | @@ -975,7 +1165,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 975 | 1165 | String clZbh = map.get("clZbh"); |
| 976 | 1166 | if (StringUtils.isNotEmpty(clZbh)) { |
| 977 | 1167 | //换车 |
| 978 | - if (!BasicData.deviceId2NbbmMap.inverse().containsKey(clZbh)) { | |
| 1168 | + if (!carExist(sch.getGsBm(), clZbh)) { | |
| 979 | 1169 | rs.put("status", ResponseCode.ERROR); |
| 980 | 1170 | rs.put("msg", "车辆 " + clZbh + " 不存在!"); |
| 981 | 1171 | return rs; |
| ... | ... | @@ -989,7 +1179,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 989 | 1179 | */ |
| 990 | 1180 | String jsy = map.get("jsy"); |
| 991 | 1181 | if (StringUtils.isNotEmpty(jsy) && jsy.indexOf("/") != -1) { |
| 992 | - persoChange(sch, jsy.split("/")[0]); | |
| 1182 | + String jGh = jsy.split("/")[0]; | |
| 1183 | + String jName = getPersonName(sch.getGsBm(), jGh); | |
| 1184 | + if(StringUtils.isEmpty(jName)){ | |
| 1185 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | |
| 1186 | + rs.put("status", ResponseCode.ERROR); | |
| 1187 | + return rs; | |
| 1188 | + } | |
| 1189 | + persoChange(sch, jGh); | |
| 993 | 1190 | } |
| 994 | 1191 | |
| 995 | 1192 | /** |
| ... | ... | @@ -997,7 +1194,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 997 | 1194 | */ |
| 998 | 1195 | String spy = map.get("spy"); |
| 999 | 1196 | if (StringUtils.isNotEmpty(spy) && spy.indexOf("/") != -1 && !spy.equals("/")) { |
| 1000 | - persoChangeSPY(sch, spy.split("/")[0]); | |
| 1197 | + String sGh = spy.split("/")[0]; | |
| 1198 | + String sName = getPersonName(sch.getGsBm(), sGh); | |
| 1199 | + if(StringUtils.isEmpty(sName)){ | |
| 1200 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | |
| 1201 | + rs.put("status", ResponseCode.ERROR); | |
| 1202 | + return rs; | |
| 1203 | + } | |
| 1204 | + persoChangeSPY(sch, sGh); | |
| 1001 | 1205 | } |
| 1002 | 1206 | else{ |
| 1003 | 1207 | sch.setsGh(""); |
| ... | ... | @@ -2585,7 +2789,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2585 | 2789 | list.add(t); |
| 2586 | 2790 | } |
| 2587 | 2791 | |
| 2588 | - List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLineQp(line, date); | |
| 2792 | + List<ScheduleRealInfo> listInfo2 = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); | |
| 2589 | 2793 | List<ScheduleRealInfo> xList = new ArrayList<ScheduleRealInfo>(); |
| 2590 | 2794 | List<ScheduleRealInfo> yList = new ArrayList<ScheduleRealInfo>(); |
| 2591 | 2795 | List<ScheduleRealInfo> zList = new ArrayList<ScheduleRealInfo>(); |
| ... | ... | @@ -2702,12 +2906,13 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2702 | 2906 | // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1)); |
| 2703 | 2907 | // String date = "2016-09-20"; |
| 2704 | 2908 | // System.out.println("shijian1:"+new Date()); |
| 2705 | - List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm); | |
| 2909 | + List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm,nbbm); | |
| 2706 | 2910 | // System.out.println("shijian2:"+new Date()); |
| 2707 | 2911 | // List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); |
| 2708 | 2912 | List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date,gsbm,fgsbm); |
| 2709 | 2913 | // System.out.println("shijian3:"+new Date()); |
| 2710 | 2914 | for (int x = 0; x < yesterdayDataList.size(); x++) { |
| 2915 | + | |
| 2711 | 2916 | String jName = yesterdayDataList.get(x).get("jGh").toString(); |
| 2712 | 2917 | String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); |
| 2713 | 2918 | |
| ... | ... | @@ -2827,28 +3032,49 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2827 | 3032 | Set<ScheduleRealInfo> set = new HashSet<>(); |
| 2828 | 3033 | |
| 2829 | 3034 | ScheduleRealInfo sch; |
| 2830 | - BiMap<String, String> map = BasicData.deviceId2NbbmMap.inverse(); | |
| 3035 | + //BiMap<String, String> map = BasicData.deviceId2NbbmMap.inverse(); | |
| 2831 | 3036 | |
| 3037 | + String jGh,jName,sGh,sName; | |
| 2832 | 3038 | for (ChangePersonCar cpc : cpcs) { |
| 2833 | 3039 | |
| 2834 | - if (cpc.getClZbh() != null && map.get(cpc.getClZbh()) == null) { | |
| 3040 | + sch = dayOfSchedule.get(cpc.getSchId()); | |
| 3041 | + if (sch == null) | |
| 3042 | + continue; | |
| 3043 | + | |
| 3044 | + if (cpc.getClZbh() != null && !carExist(sch.getGsBm(), cpc.getClZbh())) { | |
| 2835 | 3045 | rs.put("msg", "车辆 " + cpc.getClZbh() + " <a href=\"/#/busInfoManage\" target=_blank>车辆基础信息</a> 里找不到!"); |
| 2836 | 3046 | rs.put("status", ResponseCode.ERROR); |
| 2837 | 3047 | return rs; |
| 2838 | 3048 | } |
| 2839 | 3049 | |
| 2840 | - sch = dayOfSchedule.get(cpc.getSchId()); | |
| 2841 | - if (sch == null) | |
| 2842 | - continue; | |
| 2843 | - | |
| 2844 | 3050 | if (StringUtils.isNotEmpty(cpc.getJsy())) { |
| 3051 | + jGh = cpc.getJsy().split("/")[0]; | |
| 3052 | + jName = getPersonName(sch.getGsBm(), jGh); | |
| 3053 | + if(StringUtils.isEmpty(jName)){ | |
| 3054 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + jGh + "】的驾驶员"); | |
| 3055 | + rs.put("status", ResponseCode.ERROR); | |
| 3056 | + return rs; | |
| 3057 | + } | |
| 2845 | 3058 | //换驾驶员 |
| 2846 | - persoChange(sch, cpc.getJsy().split("/")[0]); | |
| 3059 | + persoChange(sch, jGh); | |
| 3060 | + set.add(sch); | |
| 2847 | 3061 | } |
| 2848 | 3062 | |
| 2849 | 3063 | //换售票员 |
| 2850 | 3064 | if (StringUtils.isNotEmpty(cpc.getSpy())) { |
| 2851 | - persoChangeSPY(sch, cpc.getSpy().split("/")[0]); | |
| 3065 | + sGh = cpc.getSpy().split("/")[0]; | |
| 3066 | + sName = getPersonName(sch.getGsBm(), sGh); | |
| 3067 | + if(StringUtils.isEmpty(sName)){ | |
| 3068 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sGh + "】的售票员"); | |
| 3069 | + rs.put("status", ResponseCode.ERROR); | |
| 3070 | + return rs; | |
| 3071 | + } | |
| 3072 | + persoChangeSPY(sch, sGh); | |
| 3073 | + set.add(sch); | |
| 3074 | + } | |
| 3075 | + else if(StringUtils.isNotEmpty(sch.getsGh())){ | |
| 3076 | + sch.setsGh(""); | |
| 3077 | + sch.setsName(""); | |
| 2852 | 3078 | } |
| 2853 | 3079 | |
| 2854 | 3080 | //换车 |
| ... | ... | @@ -2872,7 +3098,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2872 | 3098 | public void persoChange(ScheduleRealInfo sch, String jGh) { |
| 2873 | 3099 | if (sch.getjGh().equals(jGh)) |
| 2874 | 3100 | return; |
| 2875 | - String jName = BasicData.allPerson.get(jGh); | |
| 3101 | + String jName = getPersonName(sch.getGsBm() , jGh); | |
| 2876 | 3102 | if (StringUtils.isNotEmpty(jName)) { |
| 2877 | 3103 | |
| 2878 | 3104 | if (jGh.indexOf("-") != -1) |
| ... | ... | @@ -2891,7 +3117,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 2891 | 3117 | public void persoChangeSPY(ScheduleRealInfo sch, String sGh) { |
| 2892 | 3118 | if (sch.getsGh().equals(sGh)) |
| 2893 | 3119 | return; |
| 2894 | - String sName = BasicData.allPerson.get(sGh); | |
| 3120 | + String sName = getPersonName(sch.getGsBm() , sGh); | |
| 2895 | 3121 | if (StringUtils.isNotEmpty(sName)) { |
| 2896 | 3122 | if (sGh.indexOf("-") != -1) |
| 2897 | 3123 | sch.setsGh(sGh.substring(sGh.indexOf("-") + 1)); |
| ... | ... | @@ -3018,31 +3244,69 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3018 | 3244 | return rs; |
| 3019 | 3245 | } |
| 3020 | 3246 | |
| 3021 | - /* @Override | |
| 3247 | + @Override | |
| 3022 | 3248 | public Map<String, Object> historySave(ScheduleRealInfo sch) { |
| 3023 | 3249 | Map<String, Object> rs = new HashMap<>(); |
| 3024 | 3250 | rs.put("status", ResponseCode.ERROR); |
| 3025 | 3251 | |
| 3026 | 3252 | ScheduleRealInfo oldSch = super.findById(sch.getId()); |
| 3027 | - //修改车辆 | |
| 3028 | - if (!oldSch.getClZbh().equals(sch.getClZbh())) { | |
| 3029 | - Set<String> allCar = BasicData.deviceId2NbbmMap.values(); | |
| 3030 | - if (!allCar.contains(sch.getClZbh())) { | |
| 3031 | - rs.put("msg", "无效的车辆自编号"); | |
| 3253 | + | |
| 3254 | + //换车 | |
| 3255 | + if (StringUtils.isNotEmpty(sch.getClZbh()) && !oldSch.getClZbh().equals(sch.getClZbh())) { | |
| 3256 | + if (!carExist(oldSch.getGsBm(),sch.getClZbh())) { | |
| 3257 | + rs.put("msg", "车辆 " + sch.getClZbh() + " 不存在!"); | |
| 3032 | 3258 | return rs; |
| 3033 | 3259 | } else |
| 3034 | 3260 | oldSch.setClZbh(sch.getClZbh()); |
| 3035 | 3261 | } |
| 3036 | 3262 | |
| 3037 | - //修改驾驶员 | |
| 3038 | - if (!oldSch.getjGh().equals(sch.getjGh())) { | |
| 3039 | - Map<String, String> allPer = BasicData.allPerson; | |
| 3040 | - if (!allPer.containsKey(sch.getjGh())) { | |
| 3041 | - rs.put("msg", "无效的驾驶员"); | |
| 3263 | + //换驾驶员 | |
| 3264 | + if (StringUtils.isNotEmpty(sch.getjGh()) && !oldSch.getjGh().equals(sch.getjGh())) { | |
| 3265 | + String jName = getPersonName(oldSch.getGsBm(), sch.getjGh()); | |
| 3266 | + if(StringUtils.isEmpty(jName)){ | |
| 3267 | + rs.put("msg", oldSch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getjGh() + "】的驾驶员"); | |
| 3042 | 3268 | return rs; |
| 3043 | - } else { | |
| 3044 | - oldSch.setjGh(sch.getjGh()); | |
| 3045 | - oldSch.setjName(allPer.get(oldSch.getjGh())); | |
| 3269 | + } | |
| 3270 | + persoChange(oldSch, sch.getjGh()); | |
| 3271 | + } | |
| 3272 | + | |
| 3273 | + //换售票员 | |
| 3274 | + if (StringUtils.isNotEmpty(sch.getsGh()) && !oldSch.getsGh().equals(sch.getsGh())) { | |
| 3275 | + String sName = getPersonName(oldSch.getGsBm(), sch.getsGh()); | |
| 3276 | + if(StringUtils.isEmpty(sName)){ | |
| 3277 | + rs.put("msg", sch.getXlName() + "所属的公司编码下找不到工号为【" + sch.getsGh() + "】的售票员"); | |
| 3278 | + return rs; | |
| 3279 | + } | |
| 3280 | + persoChangeSPY(oldSch, sch.getsGh()); | |
| 3281 | + } | |
| 3282 | + | |
| 3283 | + //烂班 | |
| 3284 | + boolean dest1 = oldSch.getStatus() == -1; | |
| 3285 | + boolean dest2 = sch.getStatus() == -1; | |
| 3286 | + if (!dest1 && dest2) { | |
| 3287 | + oldSch.destroy(); | |
| 3288 | + } | |
| 3289 | + else if(dest1 && !dest2){ | |
| 3290 | + //撤销烂班 | |
| 3291 | + oldSch.setJhlc(oldSch.getJhlcOrig()); | |
| 3292 | + oldSch.setStatus(0); | |
| 3293 | + oldSch.calcStatus(); | |
| 3294 | + } | |
| 3295 | + | |
| 3296 | + | |
| 3297 | + /** | |
| 3298 | + * 修改班次里程 | |
| 3299 | + */ | |
| 3300 | + if (!oldSch.getJhlc().equals(sch.getJhlc())) { | |
| 3301 | + double jhlcNum = sch.getJhlc(); | |
| 3302 | + //烂班 | |
| 3303 | + if(jhlcNum == 0 && oldSch.getJhlcOrig() != 0) | |
| 3304 | + oldSch.destroy(); | |
| 3305 | + else { | |
| 3306 | + oldSch.setJhlc(jhlcNum); | |
| 3307 | + //临加班次,实际计划一起改 | |
| 3308 | + if(oldSch.isSflj()) | |
| 3309 | + oldSch.setJhlcOrig(jhlcNum); | |
| 3046 | 3310 | } |
| 3047 | 3311 | } |
| 3048 | 3312 | |
| ... | ... | @@ -3058,7 +3322,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3058 | 3322 | scheduleRealInfoRepository.save(oldSch); |
| 3059 | 3323 | rs.put("status", ResponseCode.SUCCESS); |
| 3060 | 3324 | return rs; |
| 3061 | - }*/ | |
| 3325 | + } | |
| 3062 | 3326 | |
| 3063 | 3327 | @Autowired |
| 3064 | 3328 | SvgAttributeRepository svgAttributeRepository; | ... | ... |
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
| ... | ... | @@ -1374,7 +1374,10 @@ public class ReportServiceImpl implements ReportService{ |
| 1374 | 1374 | // TODO Auto-generated method stub |
| 1375 | 1375 | // 转大写 |
| 1376 | 1376 | String nbbm =maps.get("nbbm").toString().toUpperCase(); |
| 1377 | - String gsbm=maps.get("gsbm").toString().trim(); | |
| 1377 | + String gsbm=""; | |
| 1378 | + | |
| 1379 | + if(maps.get("gsbm")!=null) | |
| 1380 | + gsbm= maps.get("gsbm").toString().trim(); | |
| 1378 | 1381 | // String fgsbm=maps.get("fgsbm").toString().trim(); |
| 1379 | 1382 | String xlbm=maps.get("xlbm").toString().trim(); |
| 1380 | 1383 | List<Map<String, String>> list = new ArrayList<Map<String, String>>(); |
| ... | ... | @@ -1430,7 +1433,9 @@ public class ReportServiceImpl implements ReportService{ |
| 1430 | 1433 | // TODO Auto-generated method stub |
| 1431 | 1434 | // 转大写 |
| 1432 | 1435 | String jsy =maps.get("jsy").toString().toUpperCase(); |
| 1433 | - String gsbm=maps.get("gsbm").toString().trim(); | |
| 1436 | + String gsbm=""; | |
| 1437 | + if(maps.get("gsbm")!=null) | |
| 1438 | + gsbm=maps.get("gsbm").toString().trim(); | |
| 1434 | 1439 | // String fgsbm=maps.get("fgsbm").toString().trim(); |
| 1435 | 1440 | List<Map<String, String>> list = new ArrayList<Map<String, String>>(); |
| 1436 | 1441 | Map<String, String> map; | ... | ... |
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| ... | ... | @@ -141,7 +141,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 141 | 141 | List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); |
| 142 | 142 | List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>(); |
| 143 | 143 | |
| 144 | - /*String company = ""; | |
| 144 | + String company = ""; | |
| 145 | 145 | String subCompany =""; |
| 146 | 146 | if(map.get("company")!=null){ |
| 147 | 147 | company = map.get("company").toString(); |
| ... | ... | @@ -149,7 +149,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 149 | 149 | |
| 150 | 150 | if(map.get("subCompany")!=null){ |
| 151 | 151 | subCompany=map.get("subCompany").toString(); |
| 152 | - }*/ | |
| 152 | + } | |
| 153 | 153 | String line = map.get("line").toString(); |
| 154 | 154 | String date = map.get("date").toString(); |
| 155 | 155 | String type = map.get("type").toString(); |
| ... | ... | @@ -164,9 +164,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 164 | 164 | if(line.length() != 0){ |
| 165 | 165 | sql += " and xl_bm = '"+line+"'"; |
| 166 | 166 | } |
| 167 | - /*if(company.length() != 0){ | |
| 167 | + if(company.length() != 0){ | |
| 168 | 168 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; |
| 169 | - }*/ | |
| 169 | + } | |
| 170 | 170 | |
| 171 | 171 | list = jdbcTemplate.query(sql, |
| 172 | 172 | new RowMapper<SchedulePlanInfo>(){ |
| ... | ... | @@ -298,6 +298,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 298 | 298 | Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); |
| 299 | 299 | for(ScheduleRealInfo schedule : list){ |
| 300 | 300 | String key = schedule.getXlName(); |
| 301 | + if(key == null || key.trim().equals("")) | |
| 302 | + continue; | |
| 301 | 303 | if(!keyMap.containsKey(key)){ |
| 302 | 304 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 303 | 305 | } |
| ... | ... | @@ -493,8 +495,12 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 493 | 495 | Map<String, List<ScheduleRealInfo>> keyMap = new HashMap<String, List<ScheduleRealInfo>>(); |
| 494 | 496 | Map<String, Object> modelMap = new HashMap<String, Object>(); |
| 495 | 497 | |
| 496 | - String company = map.get("company").toString(); | |
| 497 | - String subCompany = map.get("subCompany").toString(); | |
| 498 | + String company = ""; | |
| 499 | + if(map.get("company")!=null) | |
| 500 | + company=map.get("company").toString(); | |
| 501 | + String subCompany = ""; | |
| 502 | + if(map.get("subCompany")!=null) | |
| 503 | + subCompany=map.get("subCompany").toString(); | |
| 498 | 504 | String page = map.get("page").toString(); |
| 499 | 505 | String line = map.get("line").toString(); |
| 500 | 506 | String startDate = map.get("startDate").toString(); |
| ... | ... | @@ -514,9 +520,9 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 514 | 520 | if(line.length() != 0){ |
| 515 | 521 | sql += " and xl_bm = '"+line+"'"; |
| 516 | 522 | } |
| 517 | - if(company.length() != 0){ | |
| 518 | - sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | |
| 519 | - } | |
| 523 | +// if(company.length() != 0){ | |
| 524 | + sql += " and gs_bm like %'"+company+"'% and fgs_bm like %'"+subCompany+"%'"; | |
| 525 | +// } | |
| 520 | 526 | sql += " and bc_type != 'in' and bc_type != 'out'"; |
| 521 | 527 | |
| 522 | 528 | list = jdbcTemplate.query(sql, |
| ... | ... | @@ -888,6 +894,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 888 | 894 | if(schedule.getBcType().equals("in") || schedule.getBcType().equals("out")) |
| 889 | 895 | continue; |
| 890 | 896 | String key = schedule.getXlName(); |
| 897 | + if(key == null || key.trim().length() == 0) | |
| 898 | + continue; | |
| 891 | 899 | if(!keyMap.containsKey(key)) |
| 892 | 900 | keyMap.put(key, new ArrayList<ScheduleRealInfo>()); |
| 893 | 901 | keyMap.get(key).add(schedule); |
| ... | ... | @@ -1092,16 +1100,16 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { |
| 1092 | 1100 | keyMap.put(key, new ArrayList<Map<String, Object>>()); |
| 1093 | 1101 | keyMap.get(key).add(m); |
| 1094 | 1102 | } |
| 1103 | + String companyName = "", subCompanyName = ""; | |
| 1095 | 1104 | for(String key : keyMap.keySet()){ |
| 1096 | 1105 | Map<String, Object> tempMap = new HashMap<String, Object>(); |
| 1097 | 1106 | Set<String> tempSet = new HashSet<String>(); |
| 1098 | 1107 | int sjf = 0; |
| 1099 | 1108 | int wqr = 0; |
| 1100 | - String companyName = "", subCompanyName = ""; | |
| 1101 | 1109 | for(Map<String, Object> m : keyMap.get(key)){ |
| 1102 | - if(m.containsKey("company") && m.get("company").toString().length()!=0 && companyName.length()==0) | |
| 1110 | + if(m.containsKey("company") && m.get("company")!=null && m.get("company").toString().length()!=0 && companyName.length()==0) | |
| 1103 | 1111 | companyName = m.get("company").toString(); |
| 1104 | - if(m.containsKey("subCompany") && m.get("subCompany").toString().length()!=0 && subCompanyName.length()==0) | |
| 1112 | + if(m.containsKey("subCompany") && m.get("subCompany")!=null && m.get("subCompany").toString().length()!=0 && subCompanyName.length()==0) | |
| 1105 | 1113 | subCompanyName = m.get("subCompany").toString(); |
| 1106 | 1114 | tempSet.add(m.get("id").toString()); |
| 1107 | 1115 | if(m.get("timestamp") != null){ | ... | ... |
src/main/java/com/bsth/service/schedule/SchedulePlanInfoService.java
| 1 | 1 | package com.bsth.service.schedule; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 4 | -import com.bsth.service.BaseService; | |
| 4 | +import org.apache.commons.lang3.StringUtils; | |
| 5 | 5 | import org.joda.time.DateTime; |
| 6 | 6 | |
| 7 | +import java.sql.ResultSet; | |
| 8 | +import java.sql.SQLException; | |
| 7 | 9 | import java.util.ArrayList; |
| 10 | +import java.util.Arrays; | |
| 8 | 11 | import java.util.Date; |
| 9 | 12 | import java.util.List; |
| 10 | 13 | |
| 11 | 14 | /** |
| 12 | 15 | * Created by xu on 16/6/16. |
| 13 | 16 | */ |
| 14 | -public interface SchedulePlanInfoService extends BaseService<SchedulePlanInfo, Long> { | |
| 17 | +public interface SchedulePlanInfoService extends BService<SchedulePlanInfo, Long> { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 查找排班计划汇总数据。 | |
| 21 | + * @param xlId 线路Id | |
| 22 | + * @param scheduleDate 排班时间 | |
| 23 | + * @return | |
| 24 | + */ | |
| 25 | + List<SchedulePlanGroupInfo> findSchedulePlanGroupInfo(Integer xlId, Date scheduleDate); | |
| 26 | + | |
| 15 | 27 | /** |
| 28 | + * 排班计划分组信息。 | |
| 29 | + */ | |
| 30 | + static class SchedulePlanGroupInfo implements Comparable<SchedulePlanGroupInfo> { | |
| 31 | + //------------------ 分组字段 ----------------// | |
| 32 | + /** 线路Id */ | |
| 33 | + private Integer xlId; | |
| 34 | + /** 线路名字 */ | |
| 35 | + private String xlName; | |
| 36 | + /** 排班时间 */ | |
| 37 | + private Date scheduleDate; | |
| 38 | + /** 路牌Id */ | |
| 39 | + private Long lpId; | |
| 40 | + /** 路牌名字 */ | |
| 41 | + private String lpName; | |
| 42 | + | |
| 43 | + //------------------ 聚合数据(按照发车顺序号排序的 asc) ----------------// | |
| 44 | + /** 车辆自编号s */ | |
| 45 | + private List<String> clZbhs; | |
| 46 | + /** 出场时间s */ | |
| 47 | + private List<String> ccsjs; | |
| 48 | + /** 进场时间s */ | |
| 49 | + private List<String> jcsjs; | |
| 50 | + /** 驾驶员名字s */ | |
| 51 | + private List<String> jsyNames; | |
| 52 | + /** 驾驶员工号s */ | |
| 53 | + private List<String> jsyGhs; | |
| 54 | + /** 售票员名字s */ | |
| 55 | + private List<String> spyNames; | |
| 56 | + /** 售票员工号s */ | |
| 57 | + private List<String> spyGhs; | |
| 58 | + | |
| 59 | + /** 修改时间 */ | |
| 60 | + private Date updateDate; | |
| 61 | + /** 修改人名 */ | |
| 62 | + private String updateByName; | |
| 63 | + /** 时刻表名字 */ | |
| 64 | + private String ttInfoName; | |
| 65 | + | |
| 66 | + @Override | |
| 67 | + public int compareTo(SchedulePlanGroupInfo o) { | |
| 68 | + // 路牌名字排序,数字路牌名在前,非数字在后 | |
| 69 | + // 数字按照从小到大排序,非数字按照字符串从小到大排列 | |
| 70 | + | |
| 71 | + if (StringUtils.isNumeric(this.lpName)) { | |
| 72 | + if (StringUtils.isNumeric(o.lpName)) { | |
| 73 | + return Long.valueOf(this.lpName).compareTo(Long.valueOf(o.lpName)); | |
| 74 | + } else { | |
| 75 | + return -1; | |
| 76 | + } | |
| 77 | + } else { | |
| 78 | + if (StringUtils.isNumeric(o.lpName)) { | |
| 79 | + return 1; | |
| 80 | + } else { | |
| 81 | + return this.lpName.compareTo(o.lpName); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + public static String generateSelectSql() { | |
| 87 | + return "select " + | |
| 88 | + "info.xl as xlId " + | |
| 89 | + ", info.xl_name as xlName " + | |
| 90 | + ", info.schedule_date as scheduleDate " + | |
| 91 | + ", gbi.id as lpId " + | |
| 92 | + ", info.lp_name as lpName " + | |
| 93 | + ", GROUP_CONCAT(distinct info.cl_zbh order by info.fcno) as clzbhs " + | |
| 94 | + ", GROUP_CONCAT(info.fcsj order by info.fcno) as fcsjs " + | |
| 95 | + ", GROUP_CONCAT(info.bc_type order by info.fcno) as bctypes " + | |
| 96 | + ", GROUP_CONCAT(distinct info.j_name order by info.fcno) as jsyNames " + | |
| 97 | + ", GROUP_CONCAT(distinct info.j_gh order by info.fcno) as jsyGhs " + | |
| 98 | + ", GROUP_CONCAT(distinct info.s_name order by info.fcno) as spyNames " + | |
| 99 | + ", GROUP_CONCAT(distinct info.s_gh order by info.fcno) as spyGhs " + | |
| 100 | + ", max(info.update_date) as updateDate " + | |
| 101 | + ", max(user.user_name) as updateUserName " + | |
| 102 | + ", max(info.tt_info_name) as ttInfoName " + | |
| 103 | + "from bsth_c_s_sp_info info left join bsth_c_sys_user user on info.update_by = user.id " + | |
| 104 | + "left join bsth_c_s_gbi gbi on info.lp = gbi.id " + | |
| 105 | + "where info.xl = ? and info.schedule_date = ? " + | |
| 106 | + "group by info.xl, info.xl_name, info.schedule_date, info.lp, info.lp_name " + | |
| 107 | + "order by info.xl, info.schedule_date, gbi.lp_no "; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public void setFromResult(ResultSet rs) throws SQLException { | |
| 111 | + this.xlId = rs.getInt("xlId"); | |
| 112 | + this.xlName = rs.getString("xlName"); | |
| 113 | + this.scheduleDate = new Date(rs.getDate("scheduleDate").getTime()); | |
| 114 | + this.lpId = rs.getLong("lpId"); | |
| 115 | + this.lpName = rs.getString("lpName"); | |
| 116 | + | |
| 117 | + // 车辆自编号 | |
| 118 | + this.clZbhs = new ArrayList<>(); | |
| 119 | + String clzbhs_temp = rs.getString("clzbhs"); | |
| 120 | + if (StringUtils.isNotEmpty(clzbhs_temp)) { | |
| 121 | + this.clZbhs.addAll(Arrays.asList(clzbhs_temp.split(","))); | |
| 122 | + } | |
| 123 | + | |
| 124 | + // 出场,进场时间 | |
| 125 | + this.ccsjs = new ArrayList<>(); | |
| 126 | + this.jcsjs = new ArrayList<>(); | |
| 127 | + String fcsjs_temp = rs.getString("fcsjs"); | |
| 128 | + String bctype_temp = rs.getString("bctypes"); | |
| 129 | + if (StringUtils.isNotEmpty(fcsjs_temp) && StringUtils.isNotEmpty(bctype_temp)) { | |
| 130 | + String[] fcsjs_array = fcsjs_temp.split(","); | |
| 131 | + String[] bctype_array = bctype_temp.split(","); | |
| 132 | + if (fcsjs_array.length == bctype_array.length) { | |
| 133 | + for (int i = 0; i < fcsjs_array.length; i++) { | |
| 134 | + if ("out".equals(bctype_array[i])) { | |
| 135 | + this.ccsjs.add(fcsjs_array[i]); | |
| 136 | + } else if ("in".equals(bctype_array[i])) { | |
| 137 | + this.jcsjs.add(fcsjs_array[i]); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | + // 驾驶员 | |
| 144 | + this.jsyNames = new ArrayList<>(); | |
| 145 | + String jsyNames_temp = rs.getString("jsyNames"); | |
| 146 | + if (StringUtils.isNotEmpty(jsyNames_temp)) { | |
| 147 | + this.jsyNames.addAll(Arrays.asList(jsyNames_temp.split(","))); | |
| 148 | + } | |
| 149 | + this.jsyGhs = new ArrayList<>(); | |
| 150 | + String jsyGhs_temp = rs.getString("jsyGhs"); | |
| 151 | + if (StringUtils.isNotEmpty(jsyGhs_temp)) { | |
| 152 | + this.jsyGhs.addAll(Arrays.asList(jsyGhs_temp.split(","))); | |
| 153 | + } | |
| 154 | + | |
| 155 | + // 售票员 | |
| 156 | + this.spyNames = new ArrayList<>(); | |
| 157 | + String spyNames_temp = rs.getString("spyNames"); | |
| 158 | + if (StringUtils.isNotEmpty(spyNames_temp)) { | |
| 159 | + this.spyNames.addAll(Arrays.asList(spyNames_temp.split(","))); | |
| 160 | + } | |
| 161 | + this.spyGhs = new ArrayList<>(); | |
| 162 | + String spyGhs_temp = rs.getString("spyGhs"); | |
| 163 | + if (StringUtils.isNotEmpty(spyGhs_temp)) { | |
| 164 | + this.spyGhs.addAll(Arrays.asList(spyGhs_temp.split(","))); | |
| 165 | + } | |
| 166 | + | |
| 167 | + this.updateDate = new Date(rs.getDate("updateDate").getTime()); | |
| 168 | + this.updateByName = rs.getString("updateUserName"); | |
| 169 | + this.ttInfoName = rs.getString("ttInfoName"); | |
| 170 | + | |
| 171 | + } | |
| 172 | + | |
| 173 | + public Integer getXlId() { | |
| 174 | + return xlId; | |
| 175 | + } | |
| 176 | + | |
| 177 | + public void setXlId(Integer xlId) { | |
| 178 | + this.xlId = xlId; | |
| 179 | + } | |
| 180 | + | |
| 181 | + public String getXlName() { | |
| 182 | + return xlName; | |
| 183 | + } | |
| 184 | + | |
| 185 | + public void setXlName(String xlName) { | |
| 186 | + this.xlName = xlName; | |
| 187 | + } | |
| 188 | + | |
| 189 | + public Date getScheduleDate() { | |
| 190 | + return scheduleDate; | |
| 191 | + } | |
| 192 | + | |
| 193 | + public void setScheduleDate(Date scheduleDate) { | |
| 194 | + this.scheduleDate = scheduleDate; | |
| 195 | + } | |
| 196 | + | |
| 197 | + public Long getLpId() { | |
| 198 | + return lpId; | |
| 199 | + } | |
| 200 | + | |
| 201 | + public void setLpId(Long lpId) { | |
| 202 | + this.lpId = lpId; | |
| 203 | + } | |
| 204 | + | |
| 205 | + public String getLpName() { | |
| 206 | + return lpName; | |
| 207 | + } | |
| 208 | + | |
| 209 | + public void setLpName(String lpName) { | |
| 210 | + this.lpName = lpName; | |
| 211 | + } | |
| 212 | + | |
| 213 | + public List<String> getClZbhs() { | |
| 214 | + return clZbhs; | |
| 215 | + } | |
| 216 | + | |
| 217 | + public void setClZbhs(List<String> clZbhs) { | |
| 218 | + this.clZbhs = clZbhs; | |
| 219 | + } | |
| 220 | + | |
| 221 | + public List<String> getCcsjs() { | |
| 222 | + return ccsjs; | |
| 223 | + } | |
| 224 | + | |
| 225 | + public void setCcsjs(List<String> ccsjs) { | |
| 226 | + this.ccsjs = ccsjs; | |
| 227 | + } | |
| 228 | + | |
| 229 | + public List<String> getJcsjs() { | |
| 230 | + return jcsjs; | |
| 231 | + } | |
| 232 | + | |
| 233 | + public void setJcsjs(List<String> jcsjs) { | |
| 234 | + this.jcsjs = jcsjs; | |
| 235 | + } | |
| 236 | + | |
| 237 | + public List<String> getJsyNames() { | |
| 238 | + return jsyNames; | |
| 239 | + } | |
| 240 | + | |
| 241 | + public void setJsyNames(List<String> jsyNames) { | |
| 242 | + this.jsyNames = jsyNames; | |
| 243 | + } | |
| 244 | + | |
| 245 | + public List<String> getJsyGhs() { | |
| 246 | + return jsyGhs; | |
| 247 | + } | |
| 248 | + | |
| 249 | + public void setJsyGhs(List<String> jsyGhs) { | |
| 250 | + this.jsyGhs = jsyGhs; | |
| 251 | + } | |
| 252 | + | |
| 253 | + public List<String> getSpyNames() { | |
| 254 | + return spyNames; | |
| 255 | + } | |
| 256 | + | |
| 257 | + public void setSpyNames(List<String> spyNames) { | |
| 258 | + this.spyNames = spyNames; | |
| 259 | + } | |
| 260 | + | |
| 261 | + public List<String> getSpyGhs() { | |
| 262 | + return spyGhs; | |
| 263 | + } | |
| 264 | + | |
| 265 | + public void setSpyGhs(List<String> spyGhs) { | |
| 266 | + this.spyGhs = spyGhs; | |
| 267 | + } | |
| 268 | + | |
| 269 | + public Date getUpdateDate() { | |
| 270 | + return updateDate; | |
| 271 | + } | |
| 272 | + | |
| 273 | + public void setUpdateDate(Date updateDate) { | |
| 274 | + this.updateDate = updateDate; | |
| 275 | + } | |
| 276 | + | |
| 277 | + public String getUpdateByName() { | |
| 278 | + return updateByName; | |
| 279 | + } | |
| 280 | + | |
| 281 | + public void setUpdateByName(String updateByName) { | |
| 282 | + this.updateByName = updateByName; | |
| 283 | + } | |
| 284 | + | |
| 285 | + public String getTtInfoName() { | |
| 286 | + return ttInfoName; | |
| 287 | + } | |
| 288 | + | |
| 289 | + public void setTtInfoName(String ttInfoName) { | |
| 290 | + this.ttInfoName = ttInfoName; | |
| 291 | + } | |
| 292 | + } | |
| 293 | + | |
| 294 | + //---------------------------- 以下是过去版本 -------------------------------// | |
| 295 | + /** | |
| 16 | 296 | * 查找分组排班信息。 |
| 17 | 297 | * @param xlid 线路Id |
| 18 | 298 | * @param scheduleDate 排班日期 | ... | ... |
src/main/java/com/bsth/service/schedule/SchedulePlanInfoServiceImpl.java renamed to src/main/java/com/bsth/service/schedule/impl/SchedulePlanInfoServiceImpl.java
| 1 | -package com.bsth.service.schedule; | |
| 1 | +package com.bsth.service.schedule.impl; | |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 4 | 4 | import com.bsth.repository.schedule.SchedulePlanInfoRepository; |
| 5 | -import com.bsth.service.impl.BaseServiceImpl; | |
| 5 | +import com.bsth.service.schedule.SchedulePlanInfoService; | |
| 6 | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 7 | +import org.springframework.jdbc.core.JdbcTemplate; | |
| 8 | +import org.springframework.jdbc.core.RowMapper; | |
| 7 | 9 | import org.springframework.stereotype.Service; |
| 8 | 10 | import org.springframework.transaction.annotation.Transactional; |
| 9 | 11 | |
| 12 | +import java.sql.ResultSet; | |
| 13 | +import java.sql.SQLException; | |
| 10 | 14 | import java.util.ArrayList; |
| 15 | +import java.util.Collections; | |
| 11 | 16 | import java.util.Date; |
| 12 | 17 | import java.util.List; |
| 13 | 18 | |
| ... | ... | @@ -15,7 +20,28 @@ import java.util.List; |
| 15 | 20 | * Created by xu on 16/6/16. |
| 16 | 21 | */ |
| 17 | 22 | @Service |
| 18 | -public class SchedulePlanInfoServiceImpl extends BaseServiceImpl<SchedulePlanInfo, Long> implements SchedulePlanInfoService { | |
| 23 | +public class SchedulePlanInfoServiceImpl extends BServiceImpl<SchedulePlanInfo, Long> implements SchedulePlanInfoService { | |
| 24 | + @Autowired | |
| 25 | + private JdbcTemplate jdbcTemplate; | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public List<SchedulePlanGroupInfo> findSchedulePlanGroupInfo(Integer xlId, Date scheduleDate) { | |
| 29 | + String sql = SchedulePlanGroupInfo.generateSelectSql(); | |
| 30 | + List<SchedulePlanGroupInfo> schedulePlanGroupInfos = jdbcTemplate.query(sql, new Object[]{xlId, scheduleDate}, new RowMapper<SchedulePlanGroupInfo>() { | |
| 31 | + @Override | |
| 32 | + public SchedulePlanGroupInfo mapRow(ResultSet resultSet, int i) throws SQLException { | |
| 33 | + SchedulePlanGroupInfo schedulePlanGroupInfo = new SchedulePlanGroupInfo(); | |
| 34 | + schedulePlanGroupInfo.setFromResult(resultSet); | |
| 35 | + return schedulePlanGroupInfo; | |
| 36 | + } | |
| 37 | + }); | |
| 38 | + | |
| 39 | + // 排序 | |
| 40 | + Collections.sort(schedulePlanGroupInfos); | |
| 41 | + | |
| 42 | + return schedulePlanGroupInfos; | |
| 43 | + } | |
| 44 | + | |
| 19 | 45 | @Autowired |
| 20 | 46 | private SchedulePlanInfoRepository schedulePlanInfoRepository; |
| 21 | 47 | ... | ... |
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
| 1 | 1 | package com.bsth.service.schedule.impl; |
| 2 | 2 | |
| 3 | +import com.bsth.entity.Line; | |
| 3 | 4 | import com.bsth.entity.schedule.SchedulePlan; |
| 5 | +import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 4 | 6 | import com.bsth.entity.schedule.TTInfo; |
| 5 | 7 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 6 | 8 | import com.bsth.repository.BusinessRepository; |
| 7 | 9 | import com.bsth.repository.LineRepository; |
| 8 | 10 | import com.bsth.repository.schedule.*; |
| 9 | -import com.bsth.service.schedule.SchedulePlanRuleResultService; | |
| 10 | 11 | import com.bsth.service.schedule.SchedulePlanService; |
| 11 | 12 | import com.bsth.service.schedule.exception.ScheduleException; |
| 12 | 13 | import com.bsth.service.schedule.rules.ScheduleRuleService; |
| 13 | 14 | import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input; |
| 14 | 15 | import com.bsth.service.schedule.rules.plan.PlanResult; |
| 16 | +import com.bsth.service.schedule.rules.rerun.RerunRule_input; | |
| 17 | +import com.bsth.service.schedule.rules.rerun.RerunRule_param; | |
| 15 | 18 | import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; |
| 16 | 19 | import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; |
| 17 | 20 | import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; |
| ... | ... | @@ -36,8 +39,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 36 | 39 | @Autowired |
| 37 | 40 | private KieBase kieBase; |
| 38 | 41 | @Autowired |
| 39 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 40 | - @Autowired | |
| 41 | 42 | private ScheduleRule1FlatRepository scheduleRule1FlatRepository; |
| 42 | 43 | @Autowired |
| 43 | 44 | private TTInfoRepository ttInfoRepository; |
| ... | ... | @@ -52,8 +53,6 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 52 | 53 | @Autowired |
| 53 | 54 | private BusinessRepository businessRepository; |
| 54 | 55 | @Autowired |
| 55 | - private SchedulePlanRuleResultService schedulePlanRuleResultService; | |
| 56 | - @Autowired | |
| 57 | 56 | private ScheduleRuleService scheduleRuleService; |
| 58 | 57 | |
| 59 | 58 | /** 日志记录器 */ |
| ... | ... | @@ -64,7 +63,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 64 | 63 | * @param schedulePlan 排班计划对象 |
| 65 | 64 | * @param lpInfoResults_output 时刻表每日路牌的情况 |
| 66 | 65 | */ |
| 67 | - public ScheduleResults_output loopRuleOutput( | |
| 66 | + private ScheduleResults_output loopRuleOutput( | |
| 68 | 67 | SchedulePlan schedulePlan, |
| 69 | 68 | LpInfoResults_output lpInfoResults_output) { |
| 70 | 69 | // 1-1、构造drools规则输入数据,输出数据 |
| ... | ... | @@ -105,7 +104,10 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 105 | 104 | // 执行完毕销毁,有日志的也要关闭 |
| 106 | 105 | session.dispose(); |
| 107 | 106 | |
| 108 | - logger.info("循环规则输出={}", scheduleResults_output.showGuideboardDesc1()); | |
| 107 | + // 保存循环规则结果数据 | |
| 108 | + scheduleRuleService.generateRuleResult(scheduleResults_output.getSchedulePlanRuleResults()); | |
| 109 | + | |
| 110 | +// logger.info("循环规则输出={}", scheduleResults_output.showGuideboardDesc1()); | |
| 109 | 111 | |
| 110 | 112 | return scheduleResults_output; |
| 111 | 113 | } |
| ... | ... | @@ -115,7 +117,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 115 | 117 | * @param schedulePlan 排班计划对象 |
| 116 | 118 | * @return TTInfoResults_output, LpInfoResults_output |
| 117 | 119 | */ |
| 118 | - public Object[] ttInfoOutput(SchedulePlan schedulePlan) { | |
| 120 | + private Object[] ttInfoOutput(SchedulePlan schedulePlan) { | |
| 119 | 121 | // 获取线路的所有未作废的时刻表 |
| 120 | 122 | List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl()); |
| 121 | 123 | |
| ... | ... | @@ -173,7 +175,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 173 | 175 | * @param ttInfoResults_output ttInfoOutput方法规则输出 |
| 174 | 176 | * @return PlanResult |
| 175 | 177 | */ |
| 176 | - public PlanResult planResultOutput( | |
| 178 | + private PlanResult planResultOutput( | |
| 177 | 179 | SchedulePlan schedulePlan, |
| 178 | 180 | ScheduleResults_output scheduleResults_output, |
| 179 | 181 | TTInfoResults_output ttInfoResults_output) { |
| ... | ... | @@ -186,6 +188,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 186 | 188 | ); |
| 187 | 189 | // 规则输出数据 |
| 188 | 190 | PlanResult planResult = new PlanResult(); |
| 191 | + planResult.setXlId(schedulePlan.getXl().getId().toString()); | |
| 189 | 192 | |
| 190 | 193 | // 1-2、构造drools session->载入数据->启动规则->计算->销毁session |
| 191 | 194 | // 创建session,内部配置的是stateful |
| ... | ... | @@ -214,15 +217,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 214 | 217 | |
| 215 | 218 | } |
| 216 | 219 | |
| 217 | - public SchedulePlan save(SchedulePlan schedulePlan) { | |
| 218 | - // pre、如果排班的数据之前已经有了,删除之前的数据 | |
| 219 | - Date startpre = new Date(); | |
| 220 | - scheduleRuleService.deelteSchedulePlanInfo( | |
| 221 | - schedulePlan.getXl().getId(), | |
| 222 | - schedulePlan.getScheduleFromTime(), | |
| 223 | - schedulePlan.getScheduleToTime()); | |
| 224 | - Date endpre = new Date(); | |
| 225 | - | |
| 220 | + /** | |
| 221 | + * 生成线路排班(不含套跑规则)。 | |
| 222 | + * @param schedulePlan | |
| 223 | + * @return | |
| 224 | + */ | |
| 225 | + private PlanResult schedulePlanWithOutRerun(SchedulePlan schedulePlan) { | |
| 226 | 226 | // 1、时刻表数据及每日路牌数据计算 |
| 227 | 227 | Date start1 = new Date(); |
| 228 | 228 | Object[] ttInfoRets = ttInfoOutput(schedulePlan); |
| ... | ... | @@ -238,21 +238,115 @@ public class SchedulePlanServiceImpl extends BServiceImpl<SchedulePlan, Long> im |
| 238 | 238 | PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); |
| 239 | 239 | Date end3 = new Date(); |
| 240 | 240 | |
| 241 | + logger.info("drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms", | |
| 242 | + end1.getTime() - start1.getTime(), | |
| 243 | + end2.getTime() - start2.getTime(), | |
| 244 | + end3.getTime() - start3.getTime()); | |
| 245 | + | |
| 246 | + return planResult; | |
| 247 | + } | |
| 248 | + | |
| 249 | + /** | |
| 250 | + * 套跑计划排班数据。 | |
| 251 | + * @param planResult | |
| 252 | + */ | |
| 253 | + private void rerunPlanResult(PlanResult planResult, SchedulePlan schedulePlan) { | |
| 254 | + List<RerunRule_input> rerunRule_inputs = scheduleRuleService.findRerunrule(Integer.parseInt(planResult.getXlId())); | |
| 255 | + logger.info("套跑数量 {} 组", rerunRule_inputs.size()); | |
| 256 | + | |
| 257 | + // 主线路id | |
| 258 | + Integer mainXlId = schedulePlan.getXl().getId(); | |
| 259 | + | |
| 260 | + if (rerunRule_inputs.size() > 0) { | |
| 261 | + // 找出是对应路牌类型的线路,计算循环规则输出 | |
| 262 | + Set<String> xlids = new HashSet<>(); | |
| 263 | + for (RerunRule_input rerunRule_input: rerunRule_inputs) { | |
| 264 | + if ("dylp".equals(rerunRule_input.getType())) { | |
| 265 | + xlids.add(rerunRule_input.getS_xl()); // 参与套跑的线路 | |
| 266 | + } | |
| 267 | + } | |
| 268 | + | |
| 269 | + List<ScheduleResults_output> scheduleResults_outputs = new ArrayList<>(); | |
| 270 | + Date start1 = new Date(); | |
| 271 | + for (String xlid: xlids) { | |
| 272 | + schedulePlan.getXl().setId(Integer.parseInt(xlid)); // 套跑的线路默认跟着主线路设定走 | |
| 273 | + // 获取套跑线路的循环规则计算输出 | |
| 274 | + Object[] ttInfoRets = ttInfoOutput(schedulePlan); | |
| 275 | + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; | |
| 276 | + ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); | |
| 277 | + scheduleResults_outputs.add(scheduleResults_output); | |
| 278 | + } | |
| 279 | + | |
| 280 | + // 1-2、构造drools session->载入数据->启动规则->计算->销毁session | |
| 281 | + // 创建session,内部配置的是stateful | |
| 282 | + KieSession session = kieBase.newKieSession(); | |
| 283 | + | |
| 284 | + // 设置gloable对象,在drl中通过别名使用 | |
| 285 | + session.setGlobal("planResult", planResult); | |
| 286 | + session.setGlobal("log", logger); // 设置日志 | |
| 287 | + | |
| 288 | + session.setGlobal("carConfigInfoRepository", carConfigInfoRepository); | |
| 289 | + session.setGlobal("employeeConfigInfoRepository", employeeConfigInfoRepository); | |
| 290 | + | |
| 291 | + // 载入数据 | |
| 292 | + RerunRule_param rerunRule_param = new RerunRule_param(); | |
| 293 | + rerunRule_param.setMxlid(planResult.getXlId()); | |
| 294 | + rerunRule_param.setXlIds_dylp(xlids); | |
| 295 | + session.insert(rerunRule_param); | |
| 296 | + for (RerunRule_input rri: rerunRule_inputs) { | |
| 297 | + session.insert(rri); | |
| 298 | + } | |
| 299 | + for (SchedulePlanInfo spi: planResult.getSchedulePlanInfos()) { | |
| 300 | + session.insert(spi); | |
| 301 | + } | |
| 302 | + for (ScheduleResults_output sro: scheduleResults_outputs) { | |
| 303 | + session.insert(sro); | |
| 304 | + } | |
| 305 | + | |
| 306 | + // 执行rule | |
| 307 | + session.fireAllRules(); | |
| 308 | + | |
| 309 | + // 执行完毕销毁,有日志的也要关闭 | |
| 310 | + session.dispose(); | |
| 311 | + | |
| 312 | + Date end1 = new Date(); | |
| 313 | + logger.info("套跑规则计算,耗时 {} ms", end1.getTime() - start1.getTime()); | |
| 314 | + | |
| 315 | + schedulePlan.getXl().setId(mainXlId); | |
| 316 | + | |
| 317 | + } | |
| 318 | + | |
| 319 | + } | |
| 320 | + | |
| 321 | + public SchedulePlan save(SchedulePlan schedulePlan) { | |
| 322 | + // pre、如果排班的数据之前已经有了,删除之前的数据 | |
| 323 | + Date startpre = new Date(); | |
| 324 | + scheduleRuleService.deelteSchedulePlanInfo( | |
| 325 | + schedulePlan.getXl().getId(), | |
| 326 | + schedulePlan.getScheduleFromTime(), | |
| 327 | + schedulePlan.getScheduleToTime()); | |
| 328 | + Date endpre = new Date(); | |
| 329 | + | |
| 330 | + // 1、查找线路,这是主线路 | |
| 331 | + Line xl = lineRepository.findOne(schedulePlan.getXl().getId()); | |
| 332 | + logger.info("<--- 排班master线路 id={}, name={}, 开始排班", xl.getId(), xl.getName()); | |
| 333 | + | |
| 334 | + // 2、确定主线路排班(无套跑规则) | |
| 335 | + PlanResult planResult = schedulePlanWithOutRerun(schedulePlan); | |
| 336 | + | |
| 337 | + // 3、确定套跑规则 | |
| 338 | + rerunPlanResult(planResult, schedulePlan); | |
| 339 | + | |
| 241 | 340 | // 4、保存数据(jdbcTemplate 批量插入) |
| 242 | 341 | Date start4 = new Date(); |
| 243 | 342 | scheduleRuleService.generateSchedulePlan(schedulePlan, planResult.getSchedulePlanInfos()); |
| 244 | 343 | Date end4 = new Date(); |
| 245 | 344 | |
| 246 | - | |
| 247 | - logger.info("删除数据 {} ms,drool时刻表每日路牌计算 {} ms,drool循环规则计算 {} ms,drool计划数据 {} ms,插入数据 {} 条 耗时 {} ms", | |
| 345 | + logger.info("删除数据 {} ms,保存主线路数据 {} 条 耗时 {} ms --->", | |
| 248 | 346 | endpre.getTime() - startpre.getTime(), |
| 249 | - end1.getTime() - start1.getTime(), | |
| 250 | - end2.getTime() - start2.getTime(), | |
| 251 | - end3.getTime() - start3.getTime(), | |
| 252 | 347 | planResult.getSchedulePlanInfos().size(), |
| 253 | 348 | end4.getTime() - start4.getTime()); |
| 254 | 349 | |
| 255 | - | |
| 256 | 350 | return new SchedulePlan(); |
| 257 | 351 | } |
| 258 | 352 | ... | ... |
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
| ... | ... | @@ -98,10 +98,10 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im |
| 98 | 98 | public List<Map<String, Object>> findZdAndTcc(int lineid, int xldir) { |
| 99 | 99 | String sql = "select * from " + |
| 100 | 100 | "(" + |
| 101 | - "select station_code as zcode, station_name as zname from bsth_c_stationroute " + | |
| 101 | + "select station_code as zcode, station_name as zname, concat(station_name, '(站点)') as aname from bsth_c_stationroute " + | |
| 102 | 102 | "where destroy = 0 and line = ? and directions = ? " + |
| 103 | 103 | "union all " + |
| 104 | - "select park_code as zcode, park_name as zname from bsth_c_car_park " + | |
| 104 | + "select park_code as zcode, park_name as zname, concat(park_name, '(停车场)') as aname from bsth_c_car_park " + | |
| 105 | 105 | "where destroy = 0 " + |
| 106 | 106 | ") a "; |
| 107 | 107 | |
| ... | ... | @@ -349,7 +349,7 @@ public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> im |
| 349 | 349 | |
| 350 | 350 | // 计算班次里程 |
| 351 | 351 | if (StringUtils.isNotEmpty(jhlc)) { |
| 352 | - if ("in".equals(bctype) || "out".equals(bctype)) { | |
| 352 | + if ("in".equals(bctype) || "out".equals(bctype) || "ldks".equals(bctype)) { | |
| 353 | 353 | bc_ks += 1; |
| 354 | 354 | lc_ks += Double.valueOf(jhlc); |
| 355 | 355 | ... | ... |
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
| ... | ... | @@ -71,6 +71,9 @@ public class MyDroolsConfiguration { |
| 71 | 71 | kfs.write("src/main/resources/plan.drl", kieServices.getResources() |
| 72 | 72 | .newInputStreamResource(this.getClass().getResourceAsStream( |
| 73 | 73 | "/rules/plan.drl"), "UTF-8")); |
| 74 | + kfs.write("src/main/resources/rerun.drl", kieServices.getResources() | |
| 75 | + .newInputStreamResource(this.getClass().getResourceAsStream( | |
| 76 | + "/rules/rerun.drl"), "UTF-8")); | |
| 74 | 77 | // TODO:还有其他drl.... |
| 75 | 78 | |
| 76 | 79 | // 4、创建KieBuilder,使用KieFileSystem构建 | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleService.java
| ... | ... | @@ -3,6 +3,7 @@ package com.bsth.service.schedule.rules; |
| 3 | 3 | import com.bsth.entity.schedule.SchedulePlan; |
| 4 | 4 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 5 | 5 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; |
| 6 | +import com.bsth.service.schedule.rules.rerun.RerunRule_input; | |
| 6 | 7 | |
| 7 | 8 | import java.util.Date; |
| 8 | 9 | import java.util.List; |
| ... | ... | @@ -30,6 +31,12 @@ public interface ScheduleRuleService { |
| 30 | 31 | void generateSchedulePlan(SchedulePlan schedulePlan, List<SchedulePlanInfo> schedulePlanInfos); |
| 31 | 32 | |
| 32 | 33 | /** |
| 34 | + * 生成排班规则结果。 | |
| 35 | + * @param schedulePlanRuleResults | |
| 36 | + */ | |
| 37 | + void generateRuleResult(List<SchedulePlanRuleResult> schedulePlanRuleResults); | |
| 38 | + | |
| 39 | + /** | |
| 33 | 40 | * 删除排班计划。 |
| 34 | 41 | * @param id 排班计划id |
| 35 | 42 | */ |
| ... | ... | @@ -42,5 +49,13 @@ public interface ScheduleRuleService { |
| 42 | 49 | * @param dateto 结束日期 |
| 43 | 50 | */ |
| 44 | 51 | void deelteSchedulePlanInfo(Integer xlid, Date datefrom, Date dateto); |
| 52 | + | |
| 53 | + /** | |
| 54 | + * 查找线路的套跑规则,并封装成规则输入对象。 | |
| 55 | + * @param xlid | |
| 56 | + * @return | |
| 57 | + */ | |
| 58 | + List<RerunRule_input> findRerunrule(Integer xlid); | |
| 59 | + | |
| 45 | 60 | } |
| 46 | 61 | ... | ... |
src/main/java/com/bsth/service/schedule/rules/ScheduleRuleServiceImpl.java
| ... | ... | @@ -3,13 +3,11 @@ package com.bsth.service.schedule.rules; |
| 3 | 3 | import com.bsth.entity.schedule.SchedulePlan; |
| 4 | 4 | import com.bsth.entity.schedule.SchedulePlanInfo; |
| 5 | 5 | import com.bsth.entity.schedule.temp.SchedulePlanRuleResult; |
| 6 | +import com.bsth.service.schedule.rules.rerun.RerunRule_input; | |
| 6 | 7 | import org.slf4j.Logger; |
| 7 | 8 | import org.slf4j.LoggerFactory; |
| 8 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | -import org.springframework.jdbc.core.BatchPreparedStatementSetter; | |
| 10 | -import org.springframework.jdbc.core.JdbcTemplate; | |
| 11 | -import org.springframework.jdbc.core.PreparedStatementCreator; | |
| 12 | -import org.springframework.jdbc.core.RowMapper; | |
| 10 | +import org.springframework.jdbc.core.*; | |
| 13 | 11 | import org.springframework.jdbc.support.GeneratedKeyHolder; |
| 14 | 12 | import org.springframework.jdbc.support.KeyHolder; |
| 15 | 13 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -37,6 +35,70 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { |
| 37 | 35 | private JdbcTemplate jdbcTemplate; |
| 38 | 36 | |
| 39 | 37 | @Override |
| 38 | + public List<RerunRule_input> findRerunrule(Integer xlid) { | |
| 39 | + String sql = "select " + | |
| 40 | + "rerun_type as type " + | |
| 41 | + ", rerun_xl as m_xl " + | |
| 42 | + ", rerun_ttinfo as m_ttinfo " + | |
| 43 | + ", rerun_lp as m_lp " + | |
| 44 | + ", rerun_ttinfodetail_fcsjs as m_fcsjs " + | |
| 45 | + ", use_xl as s_dylp_xl " + | |
| 46 | + ", use_lp as s_dylp_lp " + | |
| 47 | + ", use_type as s_dylp_type " + | |
| 48 | + ", use_hrtype as s_dylp_hrtype " + | |
| 49 | + ", cl as s_dybc_cl " + | |
| 50 | + ", cl_zbh as s_dybc_clzbh " + | |
| 51 | + ", j as s_dybc_j " + | |
| 52 | + ", j_gh as s_dybc_jgh " + | |
| 53 | + ", j_name as s_dybc_jname " + | |
| 54 | + ", s as s_dybc_s " + | |
| 55 | + ", s_gh as s_dybc_sgh " + | |
| 56 | + ", s_name as s_dybc_sname " + | |
| 57 | + "from bsth_c_s_rerun_rule " + | |
| 58 | + "where is_cancel = 0 and rerun_xl = ? "; | |
| 59 | + | |
| 60 | + final List<RerunRule_input> rerunRule_inputs = new ArrayList<>(); | |
| 61 | + | |
| 62 | + jdbcTemplate.query(sql, new Object[]{xlid}, new RowCallbackHandler() { | |
| 63 | + @Override | |
| 64 | + public void processRow(ResultSet resultSet) throws SQLException { | |
| 65 | + // 发车时间 | |
| 66 | + String[] fcsjs = resultSet.getString("m_fcsjs").split(","); | |
| 67 | + for (String fcsj: fcsjs) { | |
| 68 | + RerunRule_input rerunRule_input = new RerunRule_input(); | |
| 69 | + rerunRule_input.setXl(String.valueOf(resultSet.getInt("m_xl"))); | |
| 70 | + rerunRule_input.setTtinfo(String.valueOf(resultSet.getLong("m_ttinfo"))); | |
| 71 | + rerunRule_input.setLp(String.valueOf(resultSet.getLong("m_lp"))); | |
| 72 | + rerunRule_input.setFcsj(fcsj); | |
| 73 | + | |
| 74 | + rerunRule_input.setType(resultSet.getString("type")); | |
| 75 | + // 对应班次类型 | |
| 76 | + if ("dylp".equals(resultSet.getString("type"))) { | |
| 77 | + rerunRule_input.setS_xl(String.valueOf(resultSet.getInt("s_dylp_xl"))); | |
| 78 | + rerunRule_input.setS_lp(String.valueOf(resultSet.getLong("s_dylp_lp"))); | |
| 79 | + rerunRule_input.setUsetype(resultSet.getString("s_dylp_type")); | |
| 80 | + rerunRule_input.setUserhrtype(resultSet.getString("s_dylp_hrtype")); | |
| 81 | + } else if ("dybc".equals(resultSet.getString("type"))) { | |
| 82 | + rerunRule_input.setCl(resultSet.getInt("s_dybc_cl")); | |
| 83 | + rerunRule_input.setZbh(resultSet.getString("s_dybc_clzbh")); | |
| 84 | + rerunRule_input.setJ(resultSet.getInt("s_dybc_j")); | |
| 85 | + rerunRule_input.setJgh(resultSet.getString("s_dybc_jgh")); | |
| 86 | + rerunRule_input.setJname(resultSet.getString("s_dybc_jname")); | |
| 87 | + rerunRule_input.setS(resultSet.getInt("s_dybc_s")); | |
| 88 | + rerunRule_input.setSgh(resultSet.getString("s_dybc_sgh")); | |
| 89 | + rerunRule_input.setSname(resultSet.getString("s_dybc_sname")); | |
| 90 | + } | |
| 91 | + | |
| 92 | + rerunRule_inputs.add(rerunRule_input); | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + }); | |
| 97 | + | |
| 98 | + return rerunRule_inputs; | |
| 99 | + } | |
| 100 | + | |
| 101 | + @Override | |
| 40 | 102 | public List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from) { |
| 41 | 103 | String sql = "select * from bsth_c_s_sp_rule_rst a " + |
| 42 | 104 | "where exists (select 1 from " + |
| ... | ... | @@ -75,6 +137,35 @@ public class ScheduleRuleServiceImpl implements ScheduleRuleService { |
| 75 | 137 | jdbcTemplate.update(sql, xlid, datefrom, dateto); |
| 76 | 138 | } |
| 77 | 139 | |
| 140 | + @Override | |
| 141 | + public void generateRuleResult(List<SchedulePlanRuleResult> schedulePlanRuleResults) { | |
| 142 | + // 、批量插入排班规则结果 | |
| 143 | + List<List<SchedulePlanRuleResult>> lists = new ArrayList<>(); | |
| 144 | + int batchSize = 2000; | |
| 145 | + int loopCount = schedulePlanRuleResults.size() / batchSize; | |
| 146 | + int otherCount = schedulePlanRuleResults.size() % batchSize; | |
| 147 | + for (int i = 0; i < loopCount; i++) { | |
| 148 | + lists.add(schedulePlanRuleResults.subList(i * batchSize, i * batchSize + batchSize)); | |
| 149 | + } | |
| 150 | + if (otherCount > 0) { | |
| 151 | + lists.add(schedulePlanRuleResults.subList(loopCount * batchSize, loopCount * batchSize + otherCount)); | |
| 152 | + } | |
| 153 | + | |
| 154 | + for (final List<SchedulePlanRuleResult> list : lists) { | |
| 155 | + jdbcTemplate.batchUpdate(SchedulePlanRuleResult.generateInsertSql(), new BatchPreparedStatementSetter() { | |
| 156 | + @Override | |
| 157 | + public void setValues(PreparedStatement preparedStatement, int i) throws SQLException { | |
| 158 | + SchedulePlanRuleResult schedulePlanRuleResult = list.get(i); | |
| 159 | + schedulePlanRuleResult.preparedStatementSet(preparedStatement); | |
| 160 | + } | |
| 161 | + @Override | |
| 162 | + public int getBatchSize() { | |
| 163 | + return list.size(); | |
| 164 | + } | |
| 165 | + }); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 78 | 169 | @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) |
| 79 | 170 | @Override |
| 80 | 171 | public void generateSchedulePlan(final SchedulePlan schedulePlan, final List<SchedulePlanInfo> schedulePlanInfos) { | ... | ... |
src/main/java/com/bsth/service/schedule/rules/plan/PlanResult.java
| ... | ... | @@ -9,6 +9,7 @@ import java.util.List; |
| 9 | 9 | * 计划输出。 |
| 10 | 10 | */ |
| 11 | 11 | public class PlanResult { |
| 12 | + private String xlId; | |
| 12 | 13 | private List<SchedulePlanInfo> schedulePlanInfos = new ArrayList<>(); |
| 13 | 14 | |
| 14 | 15 | public PlanResult() { |
| ... | ... | @@ -25,4 +26,12 @@ public class PlanResult { |
| 25 | 26 | public void setSchedulePlanInfos(List<SchedulePlanInfo> schedulePlanInfos) { |
| 26 | 27 | this.schedulePlanInfos = schedulePlanInfos; |
| 27 | 28 | } |
| 29 | + | |
| 30 | + public String getXlId() { | |
| 31 | + return xlId; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setXlId(String xlId) { | |
| 35 | + this.xlId = xlId; | |
| 36 | + } | |
| 28 | 37 | } | ... | ... |
src/main/java/com/bsth/service/schedule/rules/rerun/RerunRule_input.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.rerun; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Created by xu on 17/4/26. | |
| 5 | + */ | |
| 6 | +public class RerunRule_input { | |
| 7 | + private String xl; // 主线路Id | |
| 8 | + private String ttinfo; // 时刻表Id | |
| 9 | + private String lp; // 路牌 | |
| 10 | + private String fcsj; // 发车时间 | |
| 11 | + | |
| 12 | + private String type; // 套跑类型(dylp-对应路牌, dybc-对应班车) | |
| 13 | + private String s_xl; // 对应路牌,线路Id | |
| 14 | + private String s_lp; // 对应路牌,路牌Id | |
| 15 | + private String usetype; // 对应路牌替换类型 | |
| 16 | + private String userhrtype; // 对应路牌换人类型 | |
| 17 | + | |
| 18 | + private Integer cl; // 对应班车,车辆Id | |
| 19 | + private String zbh; // 对应班车,车辆自编号 | |
| 20 | + private Integer j; // 对应班车,驾驶员Id | |
| 21 | + private String jgh; // 对应班车,驾驶员工号 | |
| 22 | + private String jname; // 对应班车,驾驶员姓名 | |
| 23 | + private Integer s; // 对应班车,售票员Id | |
| 24 | + private String sgh; // 对应班车,售票员工号 | |
| 25 | + private String sname; // 对应班车,售票员姓名 | |
| 26 | + | |
| 27 | + public String getXl() { | |
| 28 | + return xl; | |
| 29 | + } | |
| 30 | + | |
| 31 | + public void setXl(String xl) { | |
| 32 | + this.xl = xl; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public String getTtinfo() { | |
| 36 | + return ttinfo; | |
| 37 | + } | |
| 38 | + | |
| 39 | + public void setTtinfo(String ttinfo) { | |
| 40 | + this.ttinfo = ttinfo; | |
| 41 | + } | |
| 42 | + | |
| 43 | + public String getLp() { | |
| 44 | + return lp; | |
| 45 | + } | |
| 46 | + | |
| 47 | + public void setLp(String lp) { | |
| 48 | + this.lp = lp; | |
| 49 | + } | |
| 50 | + | |
| 51 | + public String getFcsj() { | |
| 52 | + return fcsj; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setFcsj(String fcsj) { | |
| 56 | + this.fcsj = fcsj; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public String getType() { | |
| 60 | + return type; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setType(String type) { | |
| 64 | + this.type = type; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getS_xl() { | |
| 68 | + return s_xl; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setS_xl(String s_xl) { | |
| 72 | + this.s_xl = s_xl; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public String getS_lp() { | |
| 76 | + return s_lp; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void setS_lp(String s_lp) { | |
| 80 | + this.s_lp = s_lp; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public Integer getCl() { | |
| 84 | + return cl; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void setCl(Integer cl) { | |
| 88 | + this.cl = cl; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public String getZbh() { | |
| 92 | + return zbh; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public void setZbh(String zbh) { | |
| 96 | + this.zbh = zbh; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public Integer getJ() { | |
| 100 | + return j; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public void setJ(Integer j) { | |
| 104 | + this.j = j; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public String getJgh() { | |
| 108 | + return jgh; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public void setJgh(String jgh) { | |
| 112 | + this.jgh = jgh; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public String getJname() { | |
| 116 | + return jname; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public void setJname(String jname) { | |
| 120 | + this.jname = jname; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public Integer getS() { | |
| 124 | + return s; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void setS(Integer s) { | |
| 128 | + this.s = s; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public String getSgh() { | |
| 132 | + return sgh; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public void setSgh(String sgh) { | |
| 136 | + this.sgh = sgh; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public String getSname() { | |
| 140 | + return sname; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public void setSname(String sname) { | |
| 144 | + this.sname = sname; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public String getUsetype() { | |
| 148 | + return usetype; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public void setUsetype(String usetype) { | |
| 152 | + this.usetype = usetype; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public String getUserhrtype() { | |
| 156 | + return userhrtype; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public void setUserhrtype(String userhrtype) { | |
| 160 | + this.userhrtype = userhrtype; | |
| 161 | + } | |
| 162 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/rerun/RerunRule_param.java
0 → 100644
| 1 | +package com.bsth.service.schedule.rules.rerun; | |
| 2 | + | |
| 3 | +import java.util.Set; | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * Created by xu on 17/4/27. | |
| 7 | + */ | |
| 8 | +public class RerunRule_param { | |
| 9 | + /** 主线路id */ | |
| 10 | + private String mxlid; | |
| 11 | + | |
| 12 | + /** 对应路牌的套跑线路 */ | |
| 13 | + private Set<String> xlIds_dylp; | |
| 14 | + | |
| 15 | + // TODO: | |
| 16 | + | |
| 17 | + | |
| 18 | + public Set<String> getXlIds_dylp() { | |
| 19 | + return xlIds_dylp; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public void setXlIds_dylp(Set<String> xlIds_dylp) { | |
| 23 | + this.xlIds_dylp = xlIds_dylp; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public String getMxlid() { | |
| 27 | + return mxlid; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public void setMxlid(String mxlid) { | |
| 31 | + this.mxlid = mxlid; | |
| 32 | + } | |
| 33 | +} | ... | ... |
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleResult_output.java
| ... | ... | @@ -17,6 +17,9 @@ public class ScheduleResult_output { |
| 17 | 17 | /** 车辆配置id */ |
| 18 | 18 | private String carConfigId; |
| 19 | 19 | |
| 20 | + /** 线路id */ | |
| 21 | + private String xlId; | |
| 22 | + | |
| 20 | 23 | public DateTime getSd() { |
| 21 | 24 | return sd; |
| 22 | 25 | } |
| ... | ... | @@ -56,4 +59,12 @@ public class ScheduleResult_output { |
| 56 | 59 | public void setCarConfigId(String carConfigId) { |
| 57 | 60 | this.carConfigId = carConfigId; |
| 58 | 61 | } |
| 62 | + | |
| 63 | + public String getXlId() { | |
| 64 | + return xlId; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public void setXlId(String xlId) { | |
| 68 | + this.xlId = xlId; | |
| 69 | + } | |
| 59 | 70 | } | ... | ... |
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleResults_output.java
| ... | ... | @@ -9,6 +9,9 @@ import java.util.*; |
| 9 | 9 | * 输出结果集合。 |
| 10 | 10 | */ |
| 11 | 11 | public class ScheduleResults_output { |
| 12 | + /** 线路Id */ | |
| 13 | + private String xlid; | |
| 14 | + | |
| 12 | 15 | /** 输出列表 */ |
| 13 | 16 | private List<ScheduleResult_output> results = new ArrayList<>(); |
| 14 | 17 | |
| ... | ... | @@ -71,5 +74,13 @@ public class ScheduleResults_output { |
| 71 | 74 | return stringBuilder.toString(); |
| 72 | 75 | } |
| 73 | 76 | |
| 74 | - // TODO:人员输出 | |
| 77 | + public String getXlid() { | |
| 78 | + return xlid; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setXlid(String xlid) { | |
| 82 | + this.xlid = xlid; | |
| 83 | + } | |
| 84 | + | |
| 85 | +// TODO:人员输出 | |
| 75 | 86 | } | ... | ... |
src/main/java/com/bsth/websocket/handler/RealControlSocketHandler.java
| ... | ... | @@ -47,7 +47,7 @@ public class RealControlSocketHandler implements WebSocketHandler { |
| 47 | 47 | listenMap.remove(k, remMap.get(k)); |
| 48 | 48 | logger.info("web socket close, remove listen K: "+ k); |
| 49 | 49 | } |
| 50 | - logger.info("listen values size: " + listenMap.values().size()); | |
| 50 | + logger.info("listen values size: " + listenMap.values().size() + " -CloseStatus:" + arg1); | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | @Override | ... | ... |