Commit 8cfc9ba64857f7dd8dded598ca124d88680b6634
1 parent
4878b5a1
1.时刻表上传至灾备时填写灾备对时刻表的启用日期
Showing
6 changed files
with
2459 additions
and
2435 deletions
src/main/java/com/bsth/controller/schedule/TrafficManageController.java
| 1 | -package com.bsth.controller.schedule; | |
| 2 | - | |
| 3 | -import com.bsth.service.TrafficManageService; | |
| 4 | - | |
| 5 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 7 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 8 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 9 | -import org.springframework.web.bind.annotation.RestController; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * | |
| 13 | - * @author BSTH | |
| 14 | - * | |
| 15 | - */ | |
| 16 | -@RestController | |
| 17 | -@RequestMapping("trmg") | |
| 18 | -public class TrafficManageController { | |
| 19 | - | |
| 20 | - @Autowired | |
| 21 | - private TrafficManageService trManageService; | |
| 22 | - | |
| 23 | - | |
| 24 | - @RequestMapping(value = "/setXL", method = RequestMethod.GET) | |
| 25 | - public String setXL(@RequestParam("ids") String ids) throws Exception { | |
| 26 | - try { | |
| 27 | - return trManageService.setXL(ids); | |
| 28 | - } catch (Exception exp) { | |
| 29 | - throw new Exception(exp.getCause()); | |
| 30 | - } | |
| 31 | - } | |
| 32 | - | |
| 33 | - @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET) | |
| 34 | - public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception { | |
| 35 | - try { | |
| 36 | - return trManageService.setXLByInUse(inUse); | |
| 37 | - } catch (Exception exp) { | |
| 38 | - throw new Exception(exp.getCause()); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - | |
| 42 | - @RequestMapping(value = "/setCL", method = RequestMethod.GET) | |
| 43 | - public String setCL() throws Exception { | |
| 44 | - try { | |
| 45 | - return trManageService.setCL(); | |
| 46 | - } catch (Exception exp) { | |
| 47 | - throw new Exception(exp.getCause()); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | - @RequestMapping(value = "/setSJ", method = RequestMethod.GET) | |
| 52 | - public String setSJ() throws Exception { | |
| 53 | - try { | |
| 54 | - return trManageService.setSJ(); | |
| 55 | - } catch (Exception exp) { | |
| 56 | - throw new Exception(exp.getCause()); | |
| 57 | - } | |
| 58 | - } | |
| 59 | - | |
| 60 | - @RequestMapping(value = "/setLD", method = RequestMethod.GET) | |
| 61 | - public String setLD() throws Exception { | |
| 62 | - try { | |
| 63 | - return trManageService.setLD(); | |
| 64 | - } catch (Exception exp) { | |
| 65 | - throw new Exception(exp.getCause()); | |
| 66 | - } | |
| 67 | - } | |
| 68 | - | |
| 69 | - @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET) | |
| 70 | - public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception { | |
| 71 | - try { | |
| 72 | - return trManageService.setLD(theDate); | |
| 73 | - } catch (Exception exp) { | |
| 74 | - throw new Exception(exp.getCause()); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - | |
| 78 | - @RequestMapping(value = "/setLDFile", method = RequestMethod.GET) | |
| 79 | - public String setLDFile() throws Exception { | |
| 80 | - try { | |
| 81 | - return trManageService.setLDFile(); | |
| 82 | - } catch (Exception exp) { | |
| 83 | - throw new Exception(exp.getCause()); | |
| 84 | - } | |
| 85 | - } | |
| 86 | - | |
| 87 | - @RequestMapping(value = "/setLCYH", method = RequestMethod.GET) | |
| 88 | - public String setLCYH() throws Exception { | |
| 89 | - try { | |
| 90 | - return trManageService.setLCYH(); | |
| 91 | - } catch (Exception exp) { | |
| 92 | - throw new Exception(exp.getCause()); | |
| 93 | - } | |
| 94 | - } | |
| 95 | - | |
| 96 | - @RequestMapping(value = "/setDDRB", method = RequestMethod.GET) | |
| 97 | - public String setDDRB() throws Exception { | |
| 98 | - try { | |
| 99 | - return trManageService.setDDRB(); | |
| 100 | - } catch (Exception exp) { | |
| 101 | - throw new Exception(exp.getCause()); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - | |
| 105 | - @RequestMapping(value = "/setJHBC", method = RequestMethod.GET) | |
| 106 | - public String setJHBC() throws Exception { | |
| 107 | - try { | |
| 108 | - return trManageService.setJHBC(); | |
| 109 | - } catch (Exception exp) { | |
| 110 | - throw new Exception(exp.getCause()); | |
| 111 | - } | |
| 112 | - } | |
| 113 | - | |
| 114 | - @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET) | |
| 115 | - public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception { | |
| 116 | - try { | |
| 117 | - return trManageService.setJHBC(theDate); | |
| 118 | - } catch (Exception exp) { | |
| 119 | - throw new Exception(exp.getCause()); | |
| 120 | - } | |
| 121 | - } | |
| 122 | - | |
| 123 | - @RequestMapping(value = "/setSKB", method = RequestMethod.GET) | |
| 124 | - public String setSKB(@RequestParam("ids") String ids) throws Exception { | |
| 125 | - try { | |
| 126 | - return trManageService.setSKB(ids); | |
| 127 | - } catch (Exception exp) { | |
| 128 | - throw new Exception(exp.getCause()); | |
| 129 | - } | |
| 130 | - } | |
| 131 | - | |
| 132 | - @RequestMapping(value = "/setXLPC", method = RequestMethod.GET) | |
| 133 | - public String setXLPC() throws Exception { | |
| 134 | - try { | |
| 135 | - return trManageService.setXLPC(); | |
| 136 | - } catch (Exception exp) { | |
| 137 | - throw new Exception(exp.getCause()); | |
| 138 | - } | |
| 139 | - } | |
| 140 | - | |
| 141 | - @RequestMapping(value = "/setCS", method = RequestMethod.GET) | |
| 142 | - public String setCS() throws Exception { | |
| 143 | - try { | |
| 144 | - return trManageService.setCS(); | |
| 145 | - } catch (Exception exp) { | |
| 146 | - throw new Exception(exp.getCause()); | |
| 147 | - } | |
| 148 | - } | |
| 149 | - | |
| 150 | - @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET) | |
| 151 | - public String getDownLoadAllDataFile() throws Exception { | |
| 152 | - try { | |
| 153 | - return trManageService.getDownLoadAllDataFile(); | |
| 154 | - } catch (Exception exp) { | |
| 155 | - throw new Exception(exp.getCause()); | |
| 156 | - } | |
| 157 | - } | |
| 158 | - | |
| 159 | -} | |
| 1 | +package com.bsth.controller.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.service.TrafficManageService; | |
| 4 | + | |
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 9 | +import org.springframework.web.bind.annotation.RestController; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * | |
| 13 | + * @author BSTH | |
| 14 | + * | |
| 15 | + */ | |
| 16 | +@RestController | |
| 17 | +@RequestMapping("trmg") | |
| 18 | +public class TrafficManageController { | |
| 19 | + | |
| 20 | + @Autowired | |
| 21 | + private TrafficManageService trManageService; | |
| 22 | + | |
| 23 | + | |
| 24 | + @RequestMapping(value = "/setXL", method = RequestMethod.GET) | |
| 25 | + public String setXL(@RequestParam("ids") String ids) throws Exception { | |
| 26 | + try { | |
| 27 | + return trManageService.setXL(ids); | |
| 28 | + } catch (Exception exp) { | |
| 29 | + throw new Exception(exp.getCause()); | |
| 30 | + } | |
| 31 | + } | |
| 32 | + | |
| 33 | + @RequestMapping(value = "/setXLByInUse", method = RequestMethod.GET) | |
| 34 | + public String setXLByInUse(@RequestParam("inUse") String inUse) throws Exception { | |
| 35 | + try { | |
| 36 | + return trManageService.setXLByInUse(inUse); | |
| 37 | + } catch (Exception exp) { | |
| 38 | + throw new Exception(exp.getCause()); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + @RequestMapping(value = "/setCL", method = RequestMethod.GET) | |
| 43 | + public String setCL() throws Exception { | |
| 44 | + try { | |
| 45 | + return trManageService.setCL(); | |
| 46 | + } catch (Exception exp) { | |
| 47 | + throw new Exception(exp.getCause()); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + @RequestMapping(value = "/setSJ", method = RequestMethod.GET) | |
| 52 | + public String setSJ() throws Exception { | |
| 53 | + try { | |
| 54 | + return trManageService.setSJ(); | |
| 55 | + } catch (Exception exp) { | |
| 56 | + throw new Exception(exp.getCause()); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + @RequestMapping(value = "/setLD", method = RequestMethod.GET) | |
| 61 | + public String setLD() throws Exception { | |
| 62 | + try { | |
| 63 | + return trManageService.setLD(); | |
| 64 | + } catch (Exception exp) { | |
| 65 | + throw new Exception(exp.getCause()); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + | |
| 69 | + @RequestMapping(value = "/setLDByDate", method = RequestMethod.GET) | |
| 70 | + public String setLDByDate(@RequestParam("theDate") String theDate) throws Exception { | |
| 71 | + try { | |
| 72 | + return trManageService.setLD(theDate); | |
| 73 | + } catch (Exception exp) { | |
| 74 | + throw new Exception(exp.getCause()); | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + @RequestMapping(value = "/setLDFile", method = RequestMethod.GET) | |
| 79 | + public String setLDFile() throws Exception { | |
| 80 | + try { | |
| 81 | + return trManageService.setLDFile(); | |
| 82 | + } catch (Exception exp) { | |
| 83 | + throw new Exception(exp.getCause()); | |
| 84 | + } | |
| 85 | + } | |
| 86 | + | |
| 87 | + @RequestMapping(value = "/setLCYH", method = RequestMethod.GET) | |
| 88 | + public String setLCYH() throws Exception { | |
| 89 | + try { | |
| 90 | + return trManageService.setLCYH(); | |
| 91 | + } catch (Exception exp) { | |
| 92 | + throw new Exception(exp.getCause()); | |
| 93 | + } | |
| 94 | + } | |
| 95 | + | |
| 96 | + @RequestMapping(value = "/setDDRB", method = RequestMethod.GET) | |
| 97 | + public String setDDRB() throws Exception { | |
| 98 | + try { | |
| 99 | + return trManageService.setDDRB(); | |
| 100 | + } catch (Exception exp) { | |
| 101 | + throw new Exception(exp.getCause()); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + | |
| 105 | + @RequestMapping(value = "/setJHBC", method = RequestMethod.GET) | |
| 106 | + public String setJHBC() throws Exception { | |
| 107 | + try { | |
| 108 | + return trManageService.setJHBC(); | |
| 109 | + } catch (Exception exp) { | |
| 110 | + throw new Exception(exp.getCause()); | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + @RequestMapping(value = "/setJHBCByDate", method = RequestMethod.GET) | |
| 115 | + public String setJHBCByDate(@RequestParam("theDate") String theDate) throws Exception { | |
| 116 | + try { | |
| 117 | + return trManageService.setJHBC(theDate); | |
| 118 | + } catch (Exception exp) { | |
| 119 | + throw new Exception(exp.getCause()); | |
| 120 | + } | |
| 121 | + } | |
| 122 | + | |
| 123 | + @RequestMapping(value = "/setSKB", method = RequestMethod.GET) | |
| 124 | + public String setSKB(@RequestParam("ids") String ids, @RequestParam("qyrqs") String qyrqs) throws Exception { | |
| 125 | + try { | |
| 126 | + return trManageService.setSKB(ids, qyrqs); | |
| 127 | + } catch (Exception exp) { | |
| 128 | + throw new Exception(exp.getCause()); | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + @RequestMapping(value = "/setXLPC", method = RequestMethod.GET) | |
| 133 | + public String setXLPC() throws Exception { | |
| 134 | + try { | |
| 135 | + return trManageService.setXLPC(); | |
| 136 | + } catch (Exception exp) { | |
| 137 | + throw new Exception(exp.getCause()); | |
| 138 | + } | |
| 139 | + } | |
| 140 | + | |
| 141 | + @RequestMapping(value = "/setCS", method = RequestMethod.GET) | |
| 142 | + public String setCS() throws Exception { | |
| 143 | + try { | |
| 144 | + return trManageService.setCS(); | |
| 145 | + } catch (Exception exp) { | |
| 146 | + throw new Exception(exp.getCause()); | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + @RequestMapping(value = "/getDownLoadAllDataFile", method = RequestMethod.GET) | |
| 151 | + public String getDownLoadAllDataFile() throws Exception { | |
| 152 | + try { | |
| 153 | + return trManageService.getDownLoadAllDataFile(); | |
| 154 | + } catch (Exception exp) { | |
| 155 | + throw new Exception(exp.getCause()); | |
| 156 | + } | |
| 157 | + } | |
| 158 | + | |
| 159 | +} | ... | ... |
src/main/java/com/bsth/service/TrafficManageService.java
| 1 | -package com.bsth.service; | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * | |
| 5 | - * @Interface: LineService(线路service业务层实现接口) | |
| 6 | - * | |
| 7 | - * @extends : BaseService | |
| 8 | - * | |
| 9 | - * @Description: TODO(线路service业务层实现接口) | |
| 10 | - * | |
| 11 | - * @Author bsth@lq | |
| 12 | - * | |
| 13 | - * @Date 2016年4月28日 上午9:21:17 | |
| 14 | - * | |
| 15 | - * @Version 公交调度系统BS版 0.1 | |
| 16 | - * | |
| 17 | - */ | |
| 18 | -public interface TrafficManageService { | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * 上传线路信息 | |
| 22 | - * | |
| 23 | - * @return 调用接口返回信息 | |
| 24 | - */ | |
| 25 | - String setXL(String ids); | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * 上传线路信息 | |
| 29 | - * | |
| 30 | - * @return 调用接口返回信息 | |
| 31 | - */ | |
| 32 | - String setXLByInUse(String ids); | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 上传车辆信息 | |
| 36 | - * | |
| 37 | - * @return 调用接口返回信息 | |
| 38 | - */ | |
| 39 | - String setCL(); | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * 上传司机信息 | |
| 43 | - * @return 调用接口返回信息 | |
| 44 | - */ | |
| 45 | - String setSJ(); | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * 上传超速数据 | |
| 49 | - * | |
| 50 | - * @return 调用接口返回信息 | |
| 51 | - */ | |
| 52 | - String setCS(); | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * 上传线路班次时刻表数据 | |
| 56 | - * | |
| 57 | - * @return 调用接口返回信息 | |
| 58 | - */ | |
| 59 | - String setSKB(String ids); | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * 线路人员车辆配置信息 | |
| 63 | - * @return 调用接口返回信息 | |
| 64 | - */ | |
| 65 | - String setXLPC(); | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * 线路计划班次表 | |
| 69 | - * @return 调用接口返回信息 | |
| 70 | - */ | |
| 71 | - String setJHBC(); | |
| 72 | - | |
| 73 | - String setJHBC(String theDate); | |
| 74 | - | |
| 75 | - String setLD(String theDate); | |
| 76 | - | |
| 77 | - String setLD(); | |
| 78 | - | |
| 79 | - String setLDFile(); | |
| 80 | - | |
| 81 | - String setLCYH(); | |
| 82 | - | |
| 83 | - String setDDRB(); | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * 下载全量的公交基础数据 | |
| 87 | - * @return | |
| 88 | - */ | |
| 89 | - String getDownLoadAllDataFile(); | |
| 90 | - | |
| 91 | - /** | |
| 92 | - * 下载增量的公交基础数据 | |
| 93 | - * @return | |
| 94 | - */ | |
| 95 | - String getDownLoadIncreaseDataFile(); | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * 指定线路查询方式公交基础数据下载 | |
| 99 | - * @return | |
| 100 | - */ | |
| 101 | - String getDownLoadWarrantsBusLineStation(); | |
| 102 | -} | |
| 1 | +package com.bsth.service; | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * | |
| 5 | + * @Interface: LineService(线路service业务层实现接口) | |
| 6 | + * | |
| 7 | + * @extends : BaseService | |
| 8 | + * | |
| 9 | + * @Description: TODO(线路service业务层实现接口) | |
| 10 | + * | |
| 11 | + * @Author bsth@lq | |
| 12 | + * | |
| 13 | + * @Date 2016年4月28日 上午9:21:17 | |
| 14 | + * | |
| 15 | + * @Version 公交调度系统BS版 0.1 | |
| 16 | + * | |
| 17 | + */ | |
| 18 | +public interface TrafficManageService { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 上传线路信息 | |
| 22 | + * | |
| 23 | + * @return 调用接口返回信息 | |
| 24 | + */ | |
| 25 | + String setXL(String ids); | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 上传线路信息 | |
| 29 | + * | |
| 30 | + * @return 调用接口返回信息 | |
| 31 | + */ | |
| 32 | + String setXLByInUse(String ids); | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 上传车辆信息 | |
| 36 | + * | |
| 37 | + * @return 调用接口返回信息 | |
| 38 | + */ | |
| 39 | + String setCL(); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 上传司机信息 | |
| 43 | + * @return 调用接口返回信息 | |
| 44 | + */ | |
| 45 | + String setSJ(); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 上传超速数据 | |
| 49 | + * | |
| 50 | + * @return 调用接口返回信息 | |
| 51 | + */ | |
| 52 | + String setCS(); | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * 上传线路班次时刻表数据 | |
| 56 | + * | |
| 57 | + * @return 调用接口返回信息 | |
| 58 | + */ | |
| 59 | + String setSKB(String ids, String qyrqs); | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * 线路人员车辆配置信息 | |
| 63 | + * @return 调用接口返回信息 | |
| 64 | + */ | |
| 65 | + String setXLPC(); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 线路计划班次表 | |
| 69 | + * @return 调用接口返回信息 | |
| 70 | + */ | |
| 71 | + String setJHBC(); | |
| 72 | + | |
| 73 | + String setJHBC(String theDate); | |
| 74 | + | |
| 75 | + String setLD(String theDate); | |
| 76 | + | |
| 77 | + String setLD(); | |
| 78 | + | |
| 79 | + String setLDFile(); | |
| 80 | + | |
| 81 | + String setLCYH(); | |
| 82 | + | |
| 83 | + String setDDRB(); | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * 下载全量的公交基础数据 | |
| 87 | + * @return | |
| 88 | + */ | |
| 89 | + String getDownLoadAllDataFile(); | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * 下载增量的公交基础数据 | |
| 93 | + * @return | |
| 94 | + */ | |
| 95 | + String getDownLoadIncreaseDataFile(); | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * 指定线路查询方式公交基础数据下载 | |
| 99 | + * @return | |
| 100 | + */ | |
| 101 | + String getDownLoadWarrantsBusLineStation(); | |
| 102 | +} | ... | ... |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| 1 | -package com.bsth.service.impl; | |
| 2 | - | |
| 3 | -import com.bsth.data.BasicData; | |
| 4 | -import com.bsth.email.SendEmailController; | |
| 5 | -import com.bsth.email.entity.EmailBean; | |
| 6 | -import com.bsth.entity.*; | |
| 7 | -import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 8 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 9 | -import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 10 | -import com.bsth.entity.schedule.TTInfo; | |
| 11 | -import com.bsth.entity.schedule.TTInfoDetail; | |
| 12 | -import com.bsth.entity.search.CustomerSpecs; | |
| 13 | -import com.bsth.entity.sys.SysUser; | |
| 14 | -import com.bsth.entity.traffic.SKBUploadLogger; | |
| 15 | -import com.bsth.repository.*; | |
| 16 | -import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 17 | -import com.bsth.repository.schedule.*; | |
| 18 | -import com.bsth.repository.traffic.SKBUploadLoggerRepository; | |
| 19 | -import com.bsth.security.util.SecurityUtils; | |
| 20 | -import com.bsth.service.TrafficManageService; | |
| 21 | -import com.bsth.service.traffic.YgcBasicDataService; | |
| 22 | -import com.bsth.util.TimeUtils; | |
| 23 | -import com.bsth.util.db.DBUtils_MS; | |
| 24 | -import com.bsth.webService.trafficManage.org.tempuri.Results; | |
| 25 | -import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | |
| 26 | -import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | |
| 27 | -import org.apache.commons.lang.StringEscapeUtils; | |
| 28 | -import org.apache.commons.lang.StringUtils; | |
| 29 | -import org.apache.commons.lang.time.DateUtils; | |
| 30 | -import org.joda.time.DateTime; | |
| 31 | -import org.slf4j.Logger; | |
| 32 | -import org.slf4j.LoggerFactory; | |
| 33 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 34 | -import org.springframework.data.domain.Sort; | |
| 35 | -import org.springframework.data.domain.Sort.Direction; | |
| 36 | -import org.springframework.security.core.context.SecurityContextHolder; | |
| 37 | -import org.springframework.stereotype.Service; | |
| 38 | - | |
| 39 | -import java.io.*; | |
| 40 | -import java.net.InetAddress; | |
| 41 | -import java.sql.Connection; | |
| 42 | -import java.sql.PreparedStatement; | |
| 43 | -import java.sql.ResultSet; | |
| 44 | -import java.text.DecimalFormat; | |
| 45 | -import java.text.SimpleDateFormat; | |
| 46 | -import java.util.*; | |
| 47 | -import java.util.regex.Matcher; | |
| 48 | -import java.util.regex.Pattern; | |
| 49 | - | |
| 50 | -/** | |
| 51 | - * | |
| 52 | - * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | |
| 53 | - * | |
| 54 | - * @Extends : BaseService | |
| 55 | - * | |
| 56 | - * @Description: TODO(运管处接口service业务层) | |
| 57 | - * | |
| 58 | - * @Author bsth@zq | |
| 59 | - * | |
| 60 | - * @Date 2016年10月28日 上午9:21:17 | |
| 61 | - * | |
| 62 | - * @Version 公交调度系统BS版 0.1 | |
| 63 | - * | |
| 64 | - */ | |
| 65 | - | |
| 66 | -@Service | |
| 67 | -public class TrafficManageServiceImpl implements TrafficManageService{ | |
| 68 | - | |
| 69 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 70 | - // 运管处上传日志类型 | |
| 71 | - public static final String UPLOAD_TYPE_SKB = "1"; | |
| 72 | - public static final String UPLOAD_TYPE_XL = "2"; | |
| 73 | - public static final String UPLOAD_TYPE_LD = "3"; | |
| 74 | - | |
| 75 | - // 线路repository | |
| 76 | - @Autowired | |
| 77 | - private LineRepository lineRepository; | |
| 78 | - | |
| 79 | - @Autowired | |
| 80 | - private LineInformationRepository lineInformationRepository; | |
| 81 | - | |
| 82 | - // 站点路由repository | |
| 83 | - @Autowired | |
| 84 | - private StationRouteRepository stationRouteRepository; | |
| 85 | - | |
| 86 | - // 历史站点路由repository | |
| 87 | - @Autowired | |
| 88 | - private LsStationRouteRepository lsStationRouteRepository; | |
| 89 | - | |
| 90 | - @Autowired | |
| 91 | - private SectionRepository sectionRepository; | |
| 92 | - | |
| 93 | - // 车辆repository | |
| 94 | - @Autowired | |
| 95 | - private CarsRepository carsRepository; | |
| 96 | - | |
| 97 | - // 人员repository | |
| 98 | - @Autowired | |
| 99 | - private PersonnelRepository personnelRepository; | |
| 100 | - | |
| 101 | - // 时刻模板repository | |
| 102 | - @Autowired | |
| 103 | - private TTInfoRepository ttInfoRepository; | |
| 104 | - | |
| 105 | - // 时刻模板明细repository | |
| 106 | - @Autowired | |
| 107 | - private TTInfoDetailRepository ttInfoDetailRepository; | |
| 108 | - | |
| 109 | - // 排班计划明细repository | |
| 110 | - @Autowired | |
| 111 | - private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 112 | - | |
| 113 | - // 实际排班计划明细repository | |
| 114 | - @Autowired | |
| 115 | - private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 116 | - | |
| 117 | - // 时刻表上传记录repository | |
| 118 | - @Autowired | |
| 119 | - private SKBUploadLoggerRepository skbUploadLoggerRepository; | |
| 120 | - | |
| 121 | - // 线路站点repository | |
| 122 | - @Autowired | |
| 123 | - private YgcBasicDataService ygcBasicDataService; | |
| 124 | - | |
| 125 | - // 发送邮件 | |
| 126 | - @Autowired | |
| 127 | - private SendEmailController sendEmailController; | |
| 128 | - | |
| 129 | - /** | |
| 130 | - * 线路版本repository | |
| 131 | - */ | |
| 132 | - @Autowired | |
| 133 | - private LineVersionsRepository lineVersionsRepository; | |
| 134 | - | |
| 135 | - // 运管处上传接口 | |
| 136 | - private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; | |
| 137 | - private WebServiceSoap ssop ; | |
| 138 | - { | |
| 139 | - try { | |
| 140 | - ssop = new WebServiceLocator().getWebServiceSoap(); | |
| 141 | - } catch (Exception e) { | |
| 142 | - e.printStackTrace(); | |
| 143 | - } | |
| 144 | - } | |
| 145 | - // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母 | |
| 146 | - private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 147 | - | |
| 148 | - // 格式化 年月日 | |
| 149 | - private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | |
| 150 | - | |
| 151 | - // 数字格式化 | |
| 152 | - DecimalFormat format = new DecimalFormat("0.00"); | |
| 153 | - | |
| 154 | - // 用户名 | |
| 155 | - private final String userNameOther = "user"; | |
| 156 | - // 密码 | |
| 157 | - private final String passwordOther = "user"; | |
| 158 | - | |
| 159 | - // 用户名 | |
| 160 | - private final String userNameUp = "user"; | |
| 161 | - // 密码 | |
| 162 | - private final String passwordUp = "user"; | |
| 163 | - // 接收邮件人 | |
| 164 | - private final String emailSendToAddress = "113252620@qq.com"; | |
| 165 | - // 记录路单上线的成功、失败线路数 | |
| 166 | - private Integer countSuccess,countFailure; | |
| 167 | - | |
| 168 | - private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ | |
| 169 | - try { | |
| 170 | - if(webServiceSoapUp == null){ | |
| 171 | - webServiceSoapUp = new com.bsth.webService.trafficManage.up.org.tempuri.WebServiceLocator().getWebServiceSoap(); | |
| 172 | - } | |
| 173 | - }catch (Exception e){ | |
| 174 | - e.printStackTrace(); | |
| 175 | - }finally { | |
| 176 | - return webServiceSoapUp; | |
| 177 | - } | |
| 178 | - } | |
| 179 | - /** | |
| 180 | - * 上传线路信息 | |
| 181 | - */ | |
| 182 | - @Override | |
| 183 | - public String setXL(String ids) { | |
| 184 | - String result = "failure"; | |
| 185 | - String xml ; | |
| 186 | - String[] idArray = ids.split(","); | |
| 187 | - try { | |
| 188 | - for (String id : idArray) { | |
| 189 | - if(id == null || id.trim().equals("")){ | |
| 190 | - continue; | |
| 191 | - } | |
| 192 | - Map<String,Object> map = new HashMap<>(); | |
| 193 | - map.put("lineCode_eq", id); | |
| 194 | - Line line ; | |
| 195 | - LineInformation lineInformation; | |
| 196 | - Optional<Line> optionalLine = lineRepository.findOne(new CustomerSpecs<Line>(map)); | |
| 197 | - line = optionalLine.isPresent() ? optionalLine.get() : null; | |
| 198 | - if(line == null){ | |
| 199 | - continue; | |
| 200 | - } | |
| 201 | - if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ | |
| 202 | - return result; | |
| 203 | - } | |
| 204 | - map = new HashMap<>(); | |
| 205 | - map.put("line.id_eq",line.getId()); | |
| 206 | - Optional<LineInformation> optionalLineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(map)); | |
| 207 | - lineInformation = optionalLineInformation.isPresent() ? optionalLineInformation.get() : null; | |
| 208 | - if(lineInformation == null){ | |
| 209 | - continue; | |
| 210 | - } | |
| 211 | - // 取得封装好的xml | |
| 212 | - xml = getSetXlXml(line,lineInformation); | |
| 213 | - // 站点序号不能为0,如果为0,则返回错误 | |
| 214 | - if(xml.indexOf("<ZDXH>0</ZDXH>") != -1){ | |
| 215 | - return "0"; | |
| 216 | - } | |
| 217 | - String state;// 是否上传成功 | |
| 218 | - // 调用上传方法 | |
| 219 | - if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,xml).isSuccess()){ | |
| 220 | - result = "success"; | |
| 221 | - state = "1"; | |
| 222 | - }else{ | |
| 223 | - result = "failure"; | |
| 224 | - state = "0"; | |
| 225 | - } | |
| 226 | - logger.info("setXL:"+xml); | |
| 227 | - logger.info("setXL:"+result); | |
| 228 | - // 保存运管处上传记录 | |
| 229 | - saveYgcUploadLog(line,xml,TrafficManageServiceImpl.UPLOAD_TYPE_XL,state); | |
| 230 | - } | |
| 231 | - } catch (Exception e) { | |
| 232 | - logger.error("setXL:",e); | |
| 233 | - e.printStackTrace(); | |
| 234 | - } | |
| 235 | - return result; | |
| 236 | - } | |
| 237 | - | |
| 238 | - /** | |
| 239 | - * 加载运管处的站点及序号 | |
| 240 | - * 上行从1开始,下行顺序续编 | |
| 241 | - */ | |
| 242 | - private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | |
| 243 | - Map<String, Integer> resultMap = new HashMap<>(); | |
| 244 | - List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | |
| 245 | - if(ygcLines != null && ygcLines.size() > 0){ | |
| 246 | - int size = ygcLines.size(); | |
| 247 | - Map<String, String> tempMap ; | |
| 248 | - int num = 1; | |
| 249 | - String key; | |
| 250 | - for (int i = 0; i < size; i ++){ | |
| 251 | - tempMap = ygcLines.get(i); | |
| 252 | - key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | |
| 253 | - + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | |
| 254 | - resultMap.put(key,num++); | |
| 255 | - } | |
| 256 | - } | |
| 257 | - return resultMap; | |
| 258 | - } | |
| 259 | - | |
| 260 | - /** | |
| 261 | - * 上传线路信息(按in_use上传) | |
| 262 | - */ | |
| 263 | - @Override | |
| 264 | - public String setXLByInUse(String inUse) { | |
| 265 | - StringBuffer result = new StringBuffer(); | |
| 266 | - try { | |
| 267 | - Map<String,Object> map = new HashMap<>(); | |
| 268 | - if(inUse != null && inUse.equals("1")){ | |
| 269 | - map.put("inUse_eq", inUse); | |
| 270 | - } | |
| 271 | - List<Line> lines ; | |
| 272 | - Line line; | |
| 273 | - lines = lineRepository.findAll(new CustomerSpecs<Line>(map)); | |
| 274 | - if(lines != null && lines.size() > 0){ | |
| 275 | - for(int i = 0 ; i < lines.size() ; i ++){ | |
| 276 | - line = lines.get(i); | |
| 277 | - if(line != null && line.getId() != null){ | |
| 278 | - result.append(line.getLineCode()).append(":").append(setXL(line.getLineCode())).append(";"); | |
| 279 | - } | |
| 280 | - } | |
| 281 | - } | |
| 282 | - } catch (Exception e) { | |
| 283 | - result.append("failure"); | |
| 284 | - logger.error("setXLByInUse:",e); | |
| 285 | - e.printStackTrace(); | |
| 286 | - } | |
| 287 | - return result.toString(); | |
| 288 | - } | |
| 289 | - | |
| 290 | - /** | |
| 291 | - * 上传车辆信息 | |
| 292 | - */ | |
| 293 | - @Override | |
| 294 | - public String setCL() { | |
| 295 | - String result = "failure"; | |
| 296 | - StringBuffer sBuffer =new StringBuffer(); | |
| 297 | - try { | |
| 298 | - sBuffer.append("<CLs>"); | |
| 299 | - Cars cars = null; | |
| 300 | - String company; | |
| 301 | - Iterator<Cars> carsIterator = carsRepository.findAll().iterator(); | |
| 302 | - while(carsIterator.hasNext()){ | |
| 303 | - cars = carsIterator.next(); | |
| 304 | - sBuffer.append("<CL>"); | |
| 305 | - company = cars.getCompany(); | |
| 306 | - setCompanyName(company);// 统一公司名称 | |
| 307 | - sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | |
| 308 | - sBuffer.append("<NBH>").append(cars.getInsideCode()).append("</NBH>"); | |
| 309 | - sBuffer.append("<CPH>").append(cars.getCarPlate()).append("</CPH>"); | |
| 310 | - sBuffer.append("<YYZBH>").append(cars.getServiceNo()).append("</YYZBH>"); | |
| 311 | - sBuffer.append("<CZCPH>").append(cars.getCarPlate()).append("</CZCPH>");//******这个数据没有*********** | |
| 312 | - sBuffer.append("<CZZDBH>").append(cars.getEquipmentCode()).append("</CZZDBH>"); | |
| 313 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 314 | - sBuffer.append("</CL>"); | |
| 315 | - } | |
| 316 | - sBuffer.append("</CLs>"); | |
| 317 | - if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 318 | - result = "success"; | |
| 319 | - } | |
| 320 | - } catch (Exception e) { | |
| 321 | - logger.error("setCL:",e); | |
| 322 | - e.printStackTrace(); | |
| 323 | - }finally{ | |
| 324 | - logger.info("setCL:"+sBuffer.toString()); | |
| 325 | - logger.info("setCL:"+result); | |
| 326 | - } | |
| 327 | - return result; | |
| 328 | - } | |
| 329 | - | |
| 330 | - /** | |
| 331 | - * 上传司机信息 | |
| 332 | - */ | |
| 333 | - @Override | |
| 334 | - public String setSJ() { | |
| 335 | - String result = "failure"; | |
| 336 | - StringBuffer sBuffer =new StringBuffer(); | |
| 337 | - try { | |
| 338 | - sBuffer.append("<SJs>"); | |
| 339 | - Personnel personnel = null; | |
| 340 | - String company; | |
| 341 | - Iterator<Personnel> personIterator = personnelRepository.findAll().iterator(); | |
| 342 | - while(personIterator.hasNext()){ | |
| 343 | - personnel = personIterator.next(); | |
| 344 | - sBuffer.append("<SJ>"); | |
| 345 | - company = personnel.getCompany(); | |
| 346 | - setCompanyName(company);// 统一公司名称 | |
| 347 | - sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | |
| 348 | - sBuffer.append("<SJGH>").append(personnel.getJobCode()).append("</SJGH>"); | |
| 349 | - sBuffer.append("<CYZGZH>").append(personnel.getPapersCode()).append("</CYZGZH>");//*********** | |
| 350 | - sBuffer.append("<XM>").append(personnel.getPersonnelName()).append("</XM>"); | |
| 351 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 352 | - sBuffer.append("</SJ>"); | |
| 353 | - } | |
| 354 | - sBuffer.append("</SJs>"); | |
| 355 | - if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 356 | - result = "success"; | |
| 357 | - }; | |
| 358 | - } catch (Exception e) { | |
| 359 | - logger.error("setSJ:",e); | |
| 360 | - e.printStackTrace(); | |
| 361 | - }finally{ | |
| 362 | - logger.info("setSJ:"+sBuffer.toString()); | |
| 363 | - logger.info("setSJ:"+result); | |
| 364 | - } | |
| 365 | - return result; | |
| 366 | - } | |
| 367 | - | |
| 368 | - /** | |
| 369 | - * 上传路单 指定日期 yyyy-MM-dd | |
| 370 | - * @param theDate | |
| 371 | - * @return | |
| 372 | - */ | |
| 373 | - public String setLD(String theDate){ | |
| 374 | - return uploadLD(theDate); | |
| 375 | - } | |
| 376 | - | |
| 377 | - /** | |
| 378 | - * 上传路单 上传前一天的路单 | |
| 379 | - * @return | |
| 380 | - */ | |
| 381 | - public String setLD(){ | |
| 382 | - return uploadLD(null); | |
| 383 | - } | |
| 384 | - /** | |
| 385 | - * 上传路单 | |
| 386 | - * @return 上传成功标识 | |
| 387 | - */ | |
| 388 | - private String uploadLD(String theDate){ | |
| 389 | - // 取昨天 的日期 | |
| 390 | - String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; | |
| 391 | - StringBuffer sf = new StringBuffer(); | |
| 392 | - Results results = null; | |
| 393 | - String str = "", xlbm = null, oldXlbm = null; | |
| 394 | - List<Map<String,Object>> listGroup = null; | |
| 395 | - int scount = 0, ccount = 0; | |
| 396 | - long start = System.currentTimeMillis(); | |
| 397 | - try { | |
| 398 | - // 计数器 | |
| 399 | - int counter = 0; | |
| 400 | - // 每几条线路上传一次路单 | |
| 401 | - int per = 10; | |
| 402 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | |
| 403 | - listGroup = scheduleRealInfoRepository.setLDGroup(date); | |
| 404 | - Map<String,Object> map = new HashMap(); | |
| 405 | - HashMap<String,String> paramMap; | |
| 406 | - HashMap<String,String> otherMap = new HashMap(); | |
| 407 | - | |
| 408 | - // 车辆内部编码和车牌做映射 | |
| 409 | - Map<String, String> inside2plate = new HashMap<>(); | |
| 410 | - Iterable<Cars> cars = carsRepository.findAll(); | |
| 411 | - for (Cars car : cars) { | |
| 412 | - inside2plate.put(car.getInsideCode(), car.getCarPlate()); | |
| 413 | - } | |
| 414 | - | |
| 415 | - // 线路编码和线路信息映射 | |
| 416 | - Map<String, Line> code2line = new HashMap<>(); | |
| 417 | - Iterable<Line> lines = lineRepository.findAll(); | |
| 418 | - for (Line line : lines) { | |
| 419 | - code2line.put(line.getLineCode(), line); | |
| 420 | - } | |
| 421 | - | |
| 422 | - // 线路编码和线路版本映射(电子路单日期) | |
| 423 | - Map<String, Integer> code2version = new HashMap<>(); | |
| 424 | - Iterable<LineVersions> versions = lineVersionsRepository.findLineVersionsByDate((int)(DateTime.parse(date).getMillis() / 1000)); | |
| 425 | - for (LineVersions version : versions) { | |
| 426 | - code2version.put(version.getLineCode(), version.getVersions()); | |
| 427 | - } | |
| 428 | - | |
| 429 | - Map<String, Integer> stationNumMap = null; | |
| 430 | - for(Map<String,Object> schRealInfo:listGroup){ | |
| 431 | - if(schRealInfo != null){ | |
| 432 | - // 获取线路是否使用标识,如果未使用,则不查该线路数据 | |
| 433 | - String lineCode = schRealInfo.get("xlBm")+""; | |
| 434 | - Line line = code2line.get(lineCode); | |
| 435 | - if(line == null || line.getInUse() == null || line.getInUse() == 0){ | |
| 436 | - ccount++; | |
| 437 | - continue; | |
| 438 | - } | |
| 439 | - if(counter % per == 0){ | |
| 440 | - sf = new StringBuffer(); | |
| 441 | - sf.append("<DLDS>"); | |
| 442 | - } | |
| 443 | - counter ++; | |
| 444 | - xlbm = BasicData.lineCode2ShangHaiCodeMap.get(lineCode); | |
| 445 | - if (!xlbm.equals(oldXlbm)) { | |
| 446 | - oldXlbm = xlbm; | |
| 447 | - Integer ver = code2version.get(lineCode); | |
| 448 | - if (ver != null) { | |
| 449 | - stationNumMap = getLsStationRoute(lineCode, ver); | |
| 450 | - } | |
| 451 | - } | |
| 452 | - | |
| 453 | - sf.append("<DLD>"); | |
| 454 | - sf.append("<RQ>").append(date).append("</RQ>"); | |
| 455 | - sf.append("<XLBM>").append(xlbm).append("</XLBM>"); | |
| 456 | - sf.append("<LPBH>").append(schRealInfo.get("lpName")).append("</LPBH>"); | |
| 457 | - sf.append("<CPH>").append(inside2plate.get(schRealInfo.get("clZbh"))).append("</CPH>"); | |
| 458 | - sf.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 459 | - sf.append("<LDList>"); | |
| 460 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 461 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("lpName")+"") | |
| 462 | - .equals(scheduleRealInfo.getLpName()) | |
| 463 | - && (schRealInfo.get("clZbh")+"").equals(scheduleRealInfo.getClZbh())){ | |
| 464 | - | |
| 465 | - if(scheduleRealInfo.isDestroy()){ | |
| 466 | - if(scheduleRealInfo.isReissue()){ | |
| 467 | - scheduleRealInfo.setFcsjActualAll(scheduleRealInfo.getDfsj()); | |
| 468 | - scheduleRealInfo.setZdsjActualAll(scheduleRealInfo.getZdsj()); | |
| 469 | - } | |
| 470 | - else | |
| 471 | - continue; | |
| 472 | - } | |
| 473 | - | |
| 474 | - if(scheduleRealInfo.getBcType().equals("in") | |
| 475 | - || scheduleRealInfo.getBcType().equals("out")){ | |
| 476 | - continue; | |
| 477 | - } | |
| 478 | - | |
| 479 | - sf.append("<LD>"); | |
| 480 | - sf.append("<SJGH>").append(scheduleRealInfo.getjGh()).append("</SJGH>"); | |
| 481 | - sf.append("<SXX>").append(scheduleRealInfo.getXlDir()).append("</SXX>"); | |
| 482 | - sf.append("<FCZDMC>").append(scheduleRealInfo.getQdzName()).append("</FCZDMC>"); | |
| 483 | - // 起点站的参数 | |
| 484 | - otherMap.put("stationMark","B"); | |
| 485 | - paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 486 | - sf.append("<FCZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,stationNumMap)).append("</FCZDXH>"); | |
| 487 | - sf.append("<FCZDBM>").append(scheduleRealInfo.getQdzCode()).append("</FCZDBM>"); | |
| 488 | - sf.append("<JHFCSJ>").append(scheduleRealInfo.getFcsj()).append("</JHFCSJ>"); | |
| 489 | - sf.append("<DFSJ>").append(scheduleRealInfo.getDfsj()).append("</DFSJ>"); | |
| 490 | - sf.append("<SJFCSJ>").append(scheduleRealInfo.getFcsjActual()).append("</SJFCSJ>"); | |
| 491 | - sf.append("<FCZDLX></FCZDLX>"); | |
| 492 | - sf.append("<DDZDMC>").append(scheduleRealInfo.getZdzName()).append("</DDZDMC>"); | |
| 493 | - // 终点站的参数 | |
| 494 | - otherMap.put("stationMark","E"); | |
| 495 | - paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 496 | - sf.append("<DDZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,stationNumMap)).append("</DDZDXH>"); | |
| 497 | - sf.append("<DDZDBM>").append(scheduleRealInfo.getZdzCode()).append("</DDZDBM>"); | |
| 498 | - sf.append("<JHDDSJ>").append(scheduleRealInfo.getZdsj()).append("</JHDDSJ>"); | |
| 499 | - sf.append("<SJDDSJ>").append(scheduleRealInfo.getZdsjActual()).append("</SJDDSJ>"); | |
| 500 | - sf.append("<DDZDLX></DDZDLX>"); | |
| 501 | - sf.append("<LDSCBZ>0</LDSCBZ>"); | |
| 502 | - sf.append("<DDBZ>").append("").append("</DDBZ>"); | |
| 503 | - sf.append("</LD>"); | |
| 504 | - } | |
| 505 | - } | |
| 506 | - sf.append("</LDList>"); | |
| 507 | - sf.append("</DLD>"); | |
| 508 | - } | |
| 509 | - if(counter % per == per - 1){ | |
| 510 | - sf.append("</DLDS>"); | |
| 511 | - // 去掉'号 | |
| 512 | - str = sf.toString().replace("'",""); | |
| 513 | - scount += invokeSetLD(str, counter); | |
| 514 | - counter = 0; | |
| 515 | - } | |
| 516 | - } | |
| 517 | - // 每per条线路上传后剩下的数据再上传 | |
| 518 | - if(counter > 0){ | |
| 519 | - sf.append("</DLDS>"); | |
| 520 | - // 去掉'号 | |
| 521 | - str = sf.toString().replace("'",""); | |
| 522 | - scount += invokeSetLD(str, counter); | |
| 523 | - } | |
| 524 | - } catch (Exception e) { | |
| 525 | - e.printStackTrace(); | |
| 526 | - logger.error("setLD:", e); | |
| 527 | - } finally { | |
| 528 | - try { | |
| 529 | - //发送邮件 | |
| 530 | - EmailBean mail = new EmailBean(); | |
| 531 | - mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); | |
| 532 | - mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | |
| 533 | - sendEmailController.sendMail(emailSendToAddress, mail); | |
| 534 | - logger.info("setLD-sendMail:邮件发送成功!"); | |
| 535 | - } catch (Exception e) { | |
| 536 | - e.printStackTrace(); | |
| 537 | - logger.error("setLD-sendMail:",e); | |
| 538 | - } | |
| 539 | - } | |
| 540 | - return "success"; | |
| 541 | - } | |
| 542 | - | |
| 543 | - /** | |
| 544 | - * 调用运管处电子路单接口,如果上传失败或有网络问题,最多执行10次 | |
| 545 | - * @param xml 拼接的xml字符串 | |
| 546 | - * @param counter 分组数 | |
| 547 | - * @return 成功返回counter 失败返回0 | |
| 548 | - */ | |
| 549 | - private int invokeSetLD(String xml, int counter) { | |
| 550 | - for (int i = 0;i < 10;i++) { | |
| 551 | - try { | |
| 552 | - Results results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(xml)); | |
| 553 | - if (results.isSuccess()) { | |
| 554 | - logger.info("setLD: " + xml); | |
| 555 | - logger.info("setLD: 成功"); | |
| 556 | - return counter; | |
| 557 | - } else if (i == 9) { | |
| 558 | - logger.error("setLD: " + xml); | |
| 559 | - logger.error("setLD: 失败," + results.getMessage()); | |
| 560 | - } | |
| 561 | - Thread.sleep(2000); | |
| 562 | - } catch (Exception e) { | |
| 563 | - logger.error("运管处接口调用异常", e); | |
| 564 | - try { | |
| 565 | - Thread.sleep(2000); | |
| 566 | - } catch (InterruptedException ex) { | |
| 567 | - ex.printStackTrace(); | |
| 568 | - } | |
| 569 | - } | |
| 570 | - } | |
| 571 | - | |
| 572 | - return 0; | |
| 573 | - } | |
| 574 | - | |
| 575 | - /** | |
| 576 | - * 上传路单 xml来自文件 | |
| 577 | - * @return 上传成功标识 | |
| 578 | - */ | |
| 579 | - public String setLDFile(){ | |
| 580 | - String result = "failure"; | |
| 581 | - try { | |
| 582 | - String tmp = readXmlFromFile("E:/ld.txt"); | |
| 583 | - Results rss = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(tmp)); | |
| 584 | - if(rss.isSuccess()){ | |
| 585 | - result = "success"; | |
| 586 | - } | |
| 587 | - } catch (Exception e) { | |
| 588 | - logger.error("setLD:",e); | |
| 589 | - e.printStackTrace(); | |
| 590 | - }finally{ | |
| 591 | - | |
| 592 | - } | |
| 593 | - return result; | |
| 594 | - } | |
| 595 | - | |
| 596 | - /** | |
| 597 | - * 从文件中读取xml | |
| 598 | - * @param fileName 例:D:/test.txt | |
| 599 | - * @return | |
| 600 | - * @throws Exception | |
| 601 | - */ | |
| 602 | - private String readXmlFromFile(String fileName) throws Exception { | |
| 603 | - StringBuffer sf = new StringBuffer(""); | |
| 604 | - File file = new File(fileName); | |
| 605 | - InputStreamReader reader = new InputStreamReader(new FileInputStream(file),"GBK"); | |
| 606 | - BufferedReader bufferedReader = new BufferedReader(reader); | |
| 607 | - String lineTxt = ""; | |
| 608 | - while((lineTxt = bufferedReader.readLine()) != null){ | |
| 609 | - sf.append(lineTxt); | |
| 610 | - } | |
| 611 | - reader.close(); | |
| 612 | - return sf.toString().replaceAll("\t",""); | |
| 613 | - } | |
| 614 | - /** | |
| 615 | - * 上传里程油耗 | |
| 616 | - * @return 上传成功标识 | |
| 617 | - */ | |
| 618 | - public String setLCYH(){ | |
| 619 | - String result = "failure"; | |
| 620 | - // 取昨天 的日期 | |
| 621 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 622 | - StringBuffer sf = new StringBuffer(); | |
| 623 | - try { | |
| 624 | - sf.append("<LCYHS>"); | |
| 625 | - List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | |
| 626 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 627 | - Map<String,Object> map = new HashMap<String,Object>(); | |
| 628 | - for(Map<String,Object> schRealInfo:listGroup){ | |
| 629 | - if(schRealInfo != null){ | |
| 630 | - map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | |
| 631 | - Optional<Cars> optionalCars = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 632 | - Cars car = optionalCars.isPresent() ? optionalCars.get() : null; | |
| 633 | - /** | |
| 634 | - * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | |
| 635 | - * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | |
| 636 | - */ | |
| 637 | - if(car == null){ | |
| 638 | - continue; | |
| 639 | - } | |
| 640 | - //计算总公里和空驶公里,营运公里=总公里-空驶公里 | |
| 641 | - double totalKilometers = 0,emptyKilometers =0; | |
| 642 | - sf.append("<LCYH>"); | |
| 643 | - sf.append("<RQ>"+date+"</RQ>"); | |
| 644 | - sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | |
| 645 | - sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 646 | - if(list != null && list.size() > 0){ | |
| 647 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 648 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | |
| 649 | - .equals(scheduleRealInfo.getClZbh())){ | |
| 650 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 651 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 652 | - if(childTaskPlans.isEmpty()){ | |
| 653 | - if(scheduleRealInfo.getStatus() == 2){ | |
| 654 | - totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 655 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 656 | - || scheduleRealInfo.getBcType().equals("venting")){ | |
| 657 | - emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 658 | - } | |
| 659 | - } | |
| 660 | - }else{ | |
| 661 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 662 | - while(it.hasNext()){ | |
| 663 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 664 | - if(!childTaskPlan.isDestroy()){ | |
| 665 | - totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 666 | - if(childTaskPlan.getMileageType().equals("empty")){ | |
| 667 | - emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 668 | - } | |
| 669 | - } | |
| 670 | - } | |
| 671 | - } | |
| 672 | - } | |
| 673 | - } | |
| 674 | - } | |
| 675 | - sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | |
| 676 | - sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | |
| 677 | - sf.append("<YH>"+""+"</YH>"); | |
| 678 | - sf.append("<JZYL>"+""+"</JZYL>"); | |
| 679 | - sf.append("<DH>"+""+"</DH>"); | |
| 680 | - sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | |
| 681 | - sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | |
| 682 | - sf.append("</LCYH>"); | |
| 683 | - } | |
| 684 | - } | |
| 685 | - sf.append("</LCYHS>"); | |
| 686 | - if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 687 | - result = "success"; | |
| 688 | - } | |
| 689 | - } catch (Exception e) { | |
| 690 | - logger.error("setLCYH:",e); | |
| 691 | - e.printStackTrace(); | |
| 692 | - }finally{ | |
| 693 | - logger.info("setLCYH:"+sf.toString()); | |
| 694 | - logger.info("setLCYH:"+result); | |
| 695 | - } | |
| 696 | - return result; | |
| 697 | - } | |
| 698 | - | |
| 699 | - /** | |
| 700 | - * 上传线路调度日报 | |
| 701 | - * @return | |
| 702 | - */ | |
| 703 | - public String setDDRB(){ | |
| 704 | - String result = "failure"; | |
| 705 | - // 取昨天 的日期 | |
| 706 | - String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 707 | - StringBuffer sf = new StringBuffer(); | |
| 708 | - try { | |
| 709 | - sf.append("<DDRBS>"); | |
| 710 | - List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | |
| 711 | - List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 712 | - for(Map<String,Object> schRealInfo:listGroup){ | |
| 713 | - if(schRealInfo != null){ | |
| 714 | - double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | |
| 715 | - int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | |
| 716 | - sf.append("<DDRB>"); | |
| 717 | - sf.append("<RQ>"+date+"</RQ>"); | |
| 718 | - sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | |
| 719 | - for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 720 | - if(scheduleRealInfo != null){ | |
| 721 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm())){ | |
| 722 | - //计划 | |
| 723 | - if(!scheduleRealInfo.isSflj()){ | |
| 724 | - jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 725 | - //计划空驶 | |
| 726 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | |
| 727 | - jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 728 | - } | |
| 729 | - //计划早高峰,计划晚高峰 | |
| 730 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 731 | - jhzgfbc++; | |
| 732 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 733 | - jhwgfbc++; | |
| 734 | - } | |
| 735 | - } | |
| 736 | - jhbc++; | |
| 737 | - | |
| 738 | - //实际 | |
| 739 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 740 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 741 | - if(childTaskPlans.isEmpty()){ | |
| 742 | - if(scheduleRealInfo.getStatus() == 2){ | |
| 743 | - sjbc++; | |
| 744 | - zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 745 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 746 | - || scheduleRealInfo.getBcType().equals("venting")){ | |
| 747 | - sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 748 | - } | |
| 749 | - } | |
| 750 | - }else{ | |
| 751 | - sjbc++; | |
| 752 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 753 | - while(it.hasNext()){ | |
| 754 | - ChildTaskPlan childTaskPlan = it.next(); | |
| 755 | - if(!childTaskPlan.isDestroy()){ | |
| 756 | - zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 757 | - if(childTaskPlan.getMileageType().equals("empty")){ | |
| 758 | - sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 759 | - } | |
| 760 | - } | |
| 761 | - } | |
| 762 | - } | |
| 763 | - //实际早高峰,计划晚高峰 | |
| 764 | - if(scheduleRealInfo.getFcsjActual() != null){ | |
| 765 | - if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 766 | - sjzgfbc++; | |
| 767 | - } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 768 | - sjwgfbc++; | |
| 769 | - } | |
| 770 | - } | |
| 771 | - } | |
| 772 | - } | |
| 773 | - } | |
| 774 | - sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | |
| 775 | - sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | |
| 776 | - sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | |
| 777 | - sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | |
| 778 | - sf.append("<JHBC>"+jhbc+"</JHBC>"); | |
| 779 | - sf.append("<SJBC>"+sjbc+"</SJBC>"); | |
| 780 | - sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | |
| 781 | - sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | |
| 782 | - sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | |
| 783 | - sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | |
| 784 | - sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | |
| 785 | - sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | |
| 786 | - sf.append("</DDRB>"); | |
| 787 | - } | |
| 788 | - } | |
| 789 | - sf.append("</DDRBS>"); | |
| 790 | - if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 791 | - result = "success"; | |
| 792 | - } | |
| 793 | - } catch (Exception e) { | |
| 794 | - logger.error("setDDRB:",e); | |
| 795 | - e.printStackTrace(); | |
| 796 | - }finally{ | |
| 797 | - logger.info("setDDRB:"+sf.toString()); | |
| 798 | - logger.info("setDDRB:"+result); | |
| 799 | - } | |
| 800 | - return result; | |
| 801 | - } | |
| 802 | - | |
| 803 | - /** | |
| 804 | - * 上传计划班次 指定日期 yyyy-MM-dd | |
| 805 | - * @param theDate | |
| 806 | - * @return | |
| 807 | - */ | |
| 808 | - public String setJHBC(String theDate){ | |
| 809 | - return uploadJHBC(theDate); | |
| 810 | - } | |
| 811 | - | |
| 812 | - /** | |
| 813 | - * 上传计划班次 | |
| 814 | - * @return | |
| 815 | - */ | |
| 816 | - public String setJHBC(){ | |
| 817 | - return uploadJHBC(null); | |
| 818 | - } | |
| 819 | - /** | |
| 820 | - * 上传线路计划班次表 | |
| 821 | - */ | |
| 822 | - | |
| 823 | - private String uploadJHBC(String theDate) { | |
| 824 | - String result = "failure"; | |
| 825 | - Line line; | |
| 826 | - StringBuffer sBuffer =new StringBuffer(); | |
| 827 | - try { | |
| 828 | - sBuffer.append("<JHBCs>"); | |
| 829 | - // 声明变量 | |
| 830 | - SchedulePlanInfo schedulePlanInfo; | |
| 831 | - String xlbm,zbh = ""; | |
| 832 | - Long lp = 0L; | |
| 833 | - // 取得计划班次时间 | |
| 834 | - String tomorrow = theDate == null ? sdfnyr.format(DateUtils.addDays(new Date(), +1)) : theDate; | |
| 835 | - // 查询所有班次 | |
| 836 | - List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); | |
| 837 | - int j = 0; // 初始化标识 | |
| 838 | - if(schedulePlanList != null ){ | |
| 839 | - HashMap<String,String> paramMap; | |
| 840 | - HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 841 | - int size = schedulePlanList.size(); | |
| 842 | - for (int i = 0; i < size; i++) { | |
| 843 | - schedulePlanInfo = schedulePlanList.get(i); | |
| 844 | - xlbm = schedulePlanInfo.getXlBm(); | |
| 845 | - // 获取线路是否使用标识,如果未使用,则不查该线路数据 | |
| 846 | - line = lineRepository.findByLineCode(xlbm); | |
| 847 | - if(line.getInUse() == null || line.getInUse() == 0){ | |
| 848 | - continue; | |
| 849 | - } | |
| 850 | - if(++j == 1){// 第一次,则初始化值 | |
| 851 | - zbh = schedulePlanInfo.getClZbh(); | |
| 852 | - lp = schedulePlanInfo.getLp(); | |
| 853 | - // 拼装XML | |
| 854 | - assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | |
| 855 | - } | |
| 856 | - // 比较是否为同一条线路同一辆车 | |
| 857 | - if(xlbm.equals(schedulePlanInfo.getXlBm()) | |
| 858 | - && zbh.equals(schedulePlanInfo.getClZbh()) | |
| 859 | - && lp == schedulePlanInfo.getLp()){ | |
| 860 | - if(schedulePlanInfo.getBcType().equals("in") || schedulePlanInfo.getBcType().equals("out")){ | |
| 861 | - continue; | |
| 862 | - } | |
| 863 | - sBuffer.append("<BC>"); | |
| 864 | - sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>"); | |
| 865 | - sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>"); | |
| 866 | - sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>"); | |
| 867 | - // 起点站的参数 | |
| 868 | - otherMap.put("stationMark","B"); | |
| 869 | - paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 870 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 871 | - sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | |
| 872 | - sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | |
| 873 | - // 起点站的参数 | |
| 874 | - otherMap.put("stationMark","E"); | |
| 875 | - paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 876 | - sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 877 | - sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | |
| 878 | - .append("</JHDDSJ>"); | |
| 879 | - sBuffer.append("</BC>"); | |
| 880 | - if(i == size -1 ){ | |
| 881 | - sBuffer.append("</BCList>"); | |
| 882 | - sBuffer.append("</JHBC>"); | |
| 883 | - } | |
| 884 | - }else{ | |
| 885 | - zbh = schedulePlanInfo.getClZbh(); | |
| 886 | - lp = schedulePlanInfo.getLp(); | |
| 887 | - sBuffer.append("</BCList>"); | |
| 888 | - sBuffer.append("</JHBC>"); | |
| 889 | - // 拼装XML | |
| 890 | - assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | |
| 891 | - } | |
| 892 | - } | |
| 893 | - } | |
| 894 | - // 判断XML是否以</BCList>结尾,如果不是,则加上 | |
| 895 | - String regex = "^*</JHBC>$"; | |
| 896 | - Pattern p = Pattern.compile(regex); | |
| 897 | - Matcher m = p.matcher(sBuffer); | |
| 898 | - boolean isEndWithTrueFlag = false; | |
| 899 | - while (m.find()) { | |
| 900 | - isEndWithTrueFlag = true; | |
| 901 | - } | |
| 902 | - // 加上缺失的标签 | |
| 903 | - if(!isEndWithTrueFlag){ | |
| 904 | - sBuffer.append("</BCList>"); | |
| 905 | - sBuffer.append("</JHBC>"); | |
| 906 | - } | |
| 907 | - sBuffer.append("</JHBCs>"); | |
| 908 | - if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 909 | - result = "success"; | |
| 910 | - } | |
| 911 | - } catch (Exception e) { | |
| 912 | - logger.error("setJHBC:",e); | |
| 913 | - e.printStackTrace(); | |
| 914 | - }finally{ | |
| 915 | - logger.info("setJHBC:"+sBuffer.toString()); | |
| 916 | - logger.info("setJHBC:"+result); | |
| 917 | - } | |
| 918 | - return result; | |
| 919 | - } | |
| 920 | - | |
| 921 | - /** | |
| 922 | - * 上传线路班次时刻表数据 | |
| 923 | - */ | |
| 924 | - @Override | |
| 925 | - public String setSKB(String ids) { | |
| 926 | - String result = "上传失败,"; | |
| 927 | - StringBuffer sBuffer = new StringBuffer("<SKBs>"); | |
| 928 | - DecimalFormat df = new DecimalFormat("######0.000"); | |
| 929 | - Map<String,String> lsStationCode2NameMap = null; | |
| 930 | - Map<String, Integer> lsStationName2YgcNumber = null; | |
| 931 | - try { | |
| 932 | - String[] idArray = ids.split(","); | |
| 933 | - StringBuffer sBufferA ,sBufferB ,sBufferC ; | |
| 934 | - double zlc,yylc,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | |
| 935 | - String bcType,sxx;// 班次类型、上下行 | |
| 936 | - // 上传的时刻表集合 | |
| 937 | - List<TTInfo> ttinfoList = new ArrayList<>(); | |
| 938 | - TTInfo ttInfo; | |
| 939 | - TTInfoDetail ttInfoDetail; | |
| 940 | - LineInformation lineInformation; | |
| 941 | - Iterator<TTInfoDetail> ttInfoDetailIterator; | |
| 942 | - HashMap<String,Object> param ; | |
| 943 | - HashMap<String,String> paramMap; | |
| 944 | - HashMap<String,String> otherMap = new HashMap<>(); | |
| 945 | - // 线路编码、周几执行、发车站点名称、发车站点序号、到达站点名称、到达站点序号 | |
| 946 | - String xlbm,zjzx,fczdmc,zdxh,ddzdmc,ddxh; | |
| 947 | - // 得到时刻表版本号 | |
| 948 | - int lineVersion; | |
| 949 | - long ttinfoId; | |
| 950 | - // 是否输出站点信息 | |
| 951 | - boolean isLogStation; | |
| 952 | - for (int i = 0; i < idArray.length; i++) { | |
| 953 | - ttinfoId = Long.valueOf(idArray[i]); | |
| 954 | - Optional<TTInfo> optionalTTInfo = ttInfoRepository.findById(ttinfoId); | |
| 955 | - ttInfo = optionalTTInfo.isPresent() ? optionalTTInfo.get() : null; | |
| 956 | - if(ttInfo == null) | |
| 957 | - continue; | |
| 958 | - ttinfoList.add(ttInfo); // 保存时刻表 | |
| 959 | - // 得到时刻表版本号 | |
| 960 | - lineVersion = ttInfo.getLineVersion(); | |
| 961 | - // 查询历史站点路由 | |
| 962 | - lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion); | |
| 963 | - // 查询历史站点路由 | |
| 964 | - lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion); | |
| 965 | - zlc = 0.0f; | |
| 966 | - yylc = 0.0f; | |
| 967 | - // 获得时刻表 | |
| 968 | - param = new HashMap(); | |
| 969 | - param.put("ttinfo.id_eq", ttInfo.getId()); | |
| 970 | - ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | |
| 971 | - new Sort(Direction.ASC, "xlDir")).iterator(); | |
| 972 | - // 获得lineInformation | |
| 973 | - param = new HashMap(); | |
| 974 | - param.put("line.id_eq", ttInfo.getXl().getId()); | |
| 975 | - Optional<LineInformation> optionalLineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | |
| 976 | - lineInformation = optionalLineInformation.isPresent() ? optionalLineInformation.get() : null; | |
| 977 | - // 初始化 | |
| 978 | - isLogStation = true; | |
| 979 | - if(ttInfoDetailIterator.hasNext()){ | |
| 980 | - // 得到线路信息 | |
| 981 | - Optional<Line> optionalLine = lineRepository.findById(ttInfo.getXl().getId()); | |
| 982 | - Line line = optionalLine.isPresent() ? optionalLine.get() : null; | |
| 983 | - if(line == null){ | |
| 984 | - result += "未找到相应的线路信息,请设置线路信息后再上传"; | |
| 985 | - return result; | |
| 986 | - } | |
| 987 | - // 得到上海市线路编码 | |
| 988 | - xlbm = line.getShanghaiLinecode(); | |
| 989 | - if("".equals(xlbm) || "null".equals(xlbm)){ | |
| 990 | - result += "线路编码为空,请设置线路编码后再上传"; | |
| 991 | - return result; | |
| 992 | - } | |
| 993 | - // 拿到周几执行 | |
| 994 | - zjzx = changeRuleDay(ttInfo.getRule_days()); | |
| 995 | - if("".equals(zjzx) || "null".equals(zjzx)){ | |
| 996 | - result += "时刻表执行时间为空,请设置执行时间后再上传"; | |
| 997 | - return result; | |
| 998 | - } | |
| 999 | - sBuffer.append("<SKB>"); | |
| 1000 | - sBuffer.append("<XLBM>").append(xlbm).append("</XLBM>"); | |
| 1001 | - sBufferB = new StringBuffer(); | |
| 1002 | - sBufferC = new StringBuffer(); | |
| 1003 | - sBufferB.append("<KSRQ>").append(sdfnyr.format(ttInfo.getQyrq())).append("</KSRQ>"); | |
| 1004 | - // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | |
| 1005 | - sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | |
| 1006 | - sBufferB.append("<ZJZX>").append(zjzx).append("</ZJZX>"); | |
| 1007 | - sBufferB.append("<TBYY>").append("").append("</TBYY>"); | |
| 1008 | - sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1009 | - sBufferB.append("<BCList>"); | |
| 1010 | - while (ttInfoDetailIterator.hasNext()) { | |
| 1011 | - ttInfoDetail = ttInfoDetailIterator.next(); | |
| 1012 | - bcType = ttInfoDetail.getBcType(); | |
| 1013 | - sxx = ttInfoDetail.getXlDir(); | |
| 1014 | - // 进出场班次的里程,加入总里程 | |
| 1015 | - if(bcType.equals("in") || bcType.equals("out")){ | |
| 1016 | - // 进出班次的计划里程,算空驶里程 | |
| 1017 | - emptyLc = ttInfoDetail.getJhlc(); | |
| 1018 | - // 总里程需要加上空驶里程 | |
| 1019 | - zlc += emptyLc; | |
| 1020 | - continue; | |
| 1021 | - } | |
| 1022 | - // 不是正常班次,不传到运管处 | |
| 1023 | - if(!bcType.equals("normal")){ | |
| 1024 | - continue; | |
| 1025 | - } | |
| 1026 | - // 如果发车时间格式错误,忽略此条 | |
| 1027 | - if(changeTimeFormat(ttInfoDetail) == null){ | |
| 1028 | - continue; | |
| 1029 | - } | |
| 1030 | - // 发生站点名称 | |
| 1031 | - fczdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getQdzCode()); | |
| 1032 | - if("".equals(fczdmc) || "null".equals(fczdmc)){ | |
| 1033 | - result += "发车站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1034 | - return result; | |
| 1035 | - } | |
| 1036 | - sBufferC.append("<BC>"); | |
| 1037 | - sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 1038 | - sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | |
| 1039 | - sBufferC.append("<FCZDMC>").append(fczdmc).append("</FCZDMC>"); | |
| 1040 | - // 起点站的参数 | |
| 1041 | - otherMap.put("stationMark","B"); | |
| 1042 | - paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 1043 | - if(isLogStation){// 输出起点站信息 | |
| 1044 | - logger.info("setSKB:"+"起点站信息:"+paramMap); | |
| 1045 | - } | |
| 1046 | - // 发车站点序号 | |
| 1047 | - zdxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | |
| 1048 | - if("".equals(zdxh) || "null".equals(zdxh) || "0".equals(zdxh)){ | |
| 1049 | - result += "发车站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1050 | - return result; | |
| 1051 | - } | |
| 1052 | - // 到达站点名称 | |
| 1053 | - ddzdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getZdzCode()); | |
| 1054 | - if("".equals(ddzdmc) || "null".equals(ddzdmc)){ | |
| 1055 | - result += "到达站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1056 | - return result; | |
| 1057 | - } | |
| 1058 | - sBufferC.append("<ZDXH>").append(zdxh).append("</ZDXH>"); | |
| 1059 | - sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1060 | - sBufferC.append("<DDZDMC>").append(ddzdmc).append("</DDZDMC>"); | |
| 1061 | - // 终点站的参数 | |
| 1062 | - otherMap.put("stationMark","E"); | |
| 1063 | - paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 1064 | - if(isLogStation){// 输出终点站信息 | |
| 1065 | - logger.info("setSKB:"+"终点站信息:"+paramMap); | |
| 1066 | - } | |
| 1067 | - // 到达站点序号 | |
| 1068 | - ddxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | |
| 1069 | - if("".equals(ddxh) || "null".equals(ddxh) || "0".equals(ddxh)){ | |
| 1070 | - result += "到达站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1071 | - return result; | |
| 1072 | - } | |
| 1073 | - isLogStation = false; // 一条线路只输出一次,后面的不输出了 | |
| 1074 | - sBufferC.append("<DDXH>").append(ddxh).append("</DDXH>"); | |
| 1075 | - sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1076 | - sBufferC.append("</BC>"); | |
| 1077 | - // 0:上行;1:下行 | |
| 1078 | - if("0".equals(sxx)){ | |
| 1079 | - singleLc = lineInformation.getUpMileage(); | |
| 1080 | - }else{ | |
| 1081 | - singleLc = lineInformation.getDownMileage(); | |
| 1082 | - } | |
| 1083 | - zlc += singleLc ; | |
| 1084 | - yylc += singleLc; | |
| 1085 | - } | |
| 1086 | - sBufferC.append("</BCList>"); | |
| 1087 | - sBufferC.append("</SKB>"); | |
| 1088 | - sBufferA = new StringBuffer(); | |
| 1089 | - sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | |
| 1090 | - sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | |
| 1091 | - sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | |
| 1092 | - } | |
| 1093 | - logger.info("setSKB:"+"ttinfoId:"+ttinfoId+";当前站点版本号:"+lineVersion+";查询历史站点路由:"+lsStationCode2NameMap+";查询历史站点编号:"+lsStationName2YgcNumber); | |
| 1094 | - } | |
| 1095 | - sBuffer.append("</SKBs>"); | |
| 1096 | - String state;// 是否上传成功 | |
| 1097 | - if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1098 | - result = "上传成功"; | |
| 1099 | - state = "1"; | |
| 1100 | - }else{// 上传失败 | |
| 1101 | - result = "上传失败"; | |
| 1102 | - state = "0"; | |
| 1103 | - } | |
| 1104 | - // 保存运管处上传记录 | |
| 1105 | - saveYgcUploadLog(ttinfoList,sBuffer.toString(),TrafficManageServiceImpl.UPLOAD_TYPE_SKB,state); | |
| 1106 | - } catch (Exception e) { | |
| 1107 | - logger.error("setSKB:", e); | |
| 1108 | - e.printStackTrace(); | |
| 1109 | - }finally{ | |
| 1110 | - logger.info("setSKB:"+sBuffer.toString()); | |
| 1111 | - logger.info("setSKB:"+result); | |
| 1112 | - } | |
| 1113 | - return result; | |
| 1114 | - } | |
| 1115 | - | |
| 1116 | - /** | |
| 1117 | - * 保存上传运管处的日志 | |
| 1118 | - * @param obj 参数 | |
| 1119 | - * @param type 日志类型 | |
| 1120 | - * @param xml 上传参数 | |
| 1121 | - */ | |
| 1122 | - private void saveYgcUploadLog(Object obj,String xml,String type,String state){ | |
| 1123 | - SKBUploadLogger skbUploadLogger = new SKBUploadLogger(); | |
| 1124 | - SysUser user; | |
| 1125 | - // 如果不是人为上传,SysUser则为空,设置上传人员为管理员 | |
| 1126 | - if(SecurityContextHolder.getContext() == null || SecurityContextHolder.getContext().getAuthentication() == null){ | |
| 1127 | - user = new SysUser(); | |
| 1128 | - user.setId(1); | |
| 1129 | - }else{// 获取上传人员 | |
| 1130 | - user = SecurityUtils.getCurrentUser(); | |
| 1131 | - } | |
| 1132 | - // 最大的字符长度 | |
| 1133 | - int maxLength = 60000; | |
| 1134 | - int cutLength = 50000;// 需要截取的字符长度 | |
| 1135 | - String xml_sub = null; | |
| 1136 | - skbUploadLogger.setType(type);// 设置类型 | |
| 1137 | - // 判断xml是否超长,如果超长,则截取 | |
| 1138 | - if(xml != null && xml.length() > maxLength){ | |
| 1139 | - int xmlLength = xml.length(); | |
| 1140 | - int cutCount = xmlLength / cutLength + (xmlLength % cutLength > 0 ? 1 : 0); | |
| 1141 | - if(cutCount > 2){ | |
| 1142 | - xml = "由于上传参数内容超长,请查看服务器的系统日志"; | |
| 1143 | - }else if(cutCount == 2){ | |
| 1144 | - xml_sub =xml.substring(cutLength); | |
| 1145 | - xml = xml.substring(0,cutLength); | |
| 1146 | - }else{ | |
| 1147 | - // 不做处理 | |
| 1148 | - } | |
| 1149 | - } | |
| 1150 | -// skbUploadLogger.setUploadXml(xml);// 上传的参数 | |
| 1151 | -// skbUploadLogger.setUploadXmlSub(xml_sub); | |
| 1152 | - skbUploadLogger.setState(state);// 状态:是否成功 | |
| 1153 | - skbUploadLogger.setUser(user); | |
| 1154 | - // 时刻表 | |
| 1155 | - if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_SKB)){ | |
| 1156 | - List<TTInfo> ttInfoList = (List<TTInfo>)obj; | |
| 1157 | - String name = ""; | |
| 1158 | - Line line = null; | |
| 1159 | - for(TTInfo ttInfo : ttInfoList){ | |
| 1160 | - name += ttInfo.getName() + " "; | |
| 1161 | - line = ttInfo.getXl(); | |
| 1162 | - } | |
| 1163 | - skbUploadLogger.setLine(line); | |
| 1164 | - skbUploadLogger.setUser(user); | |
| 1165 | - skbUploadLogger.setName(name); | |
| 1166 | - skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1167 | - }else{ | |
| 1168 | - if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_XL)){ | |
| 1169 | - Line line = (Line) obj; | |
| 1170 | - String name = line.getName() + "线路停靠站上传"; | |
| 1171 | - skbUploadLogger.setLine(line); | |
| 1172 | - skbUploadLogger.setName(name); | |
| 1173 | - skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1174 | - }else if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_LD)){ | |
| 1175 | - Map<String ,Line> logLineMap = (Map<String ,Line> )obj; | |
| 1176 | - for (String key : logLineMap.keySet()) { | |
| 1177 | - Line line = logLineMap.get(key); | |
| 1178 | - String name = line.getName() + "路单上传"; | |
| 1179 | - skbUploadLogger = new SKBUploadLogger(); | |
| 1180 | - skbUploadLogger.setType(type);// 设置类型 | |
| 1181 | -// skbUploadLogger.setUploadXml(xml);// 上传的参数 | |
| 1182 | -// skbUploadLogger.setUploadXmlSub(xml_sub); | |
| 1183 | - skbUploadLogger.setState(state);// 状态:是否成功 | |
| 1184 | - skbUploadLogger.setUser(user); | |
| 1185 | - skbUploadLogger.setLine(line); | |
| 1186 | - skbUploadLogger.setName(name); | |
| 1187 | -// skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1188 | - } | |
| 1189 | - } | |
| 1190 | - } | |
| 1191 | - } | |
| 1192 | - /** | |
| 1193 | - * 上传线路人员车辆配置信息 | |
| 1194 | - */ | |
| 1195 | - @Override | |
| 1196 | - public String setXLPC() { | |
| 1197 | - String result = "failure"; | |
| 1198 | - StringBuffer sBuffer =new StringBuffer(); | |
| 1199 | - try { | |
| 1200 | - sBuffer.append("<XLPCs>"); | |
| 1201 | - // 声明变量 | |
| 1202 | - Line line = null; | |
| 1203 | - Cars cars = null; | |
| 1204 | - List<Personnel> personnelList = null; | |
| 1205 | - List<Cars> carsList = null; | |
| 1206 | - int totalPersonnel,totalCar ;// 人员数量。车辆数量 | |
| 1207 | - // 查询所有线路 | |
| 1208 | - Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | |
| 1209 | - // 循环查找线路下的信息 | |
| 1210 | - while(lineIterator.hasNext()){ | |
| 1211 | - line = lineIterator.next(); | |
| 1212 | - sBuffer.append("<XLPC>"); | |
| 1213 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 1214 | - // 查询驾驶员数量 | |
| 1215 | - personnelList = personnelRepository.findJsysByLineId(line.getId()); | |
| 1216 | - totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 1217 | - sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | |
| 1218 | - // 查询售票员人员数量 | |
| 1219 | - personnelList = personnelRepository.findSpysByLineId(line.getId()); | |
| 1220 | - totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 1221 | - sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | |
| 1222 | - // 查询车辆 | |
| 1223 | - carsList = carsRepository.findCarsByLineId(line.getId()); | |
| 1224 | - totalCar = carsList != null ? carsList.size():0; | |
| 1225 | - sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | |
| 1226 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1227 | - int carsNum = 0; | |
| 1228 | - // 取车牌号 | |
| 1229 | - if(carsList != null){ | |
| 1230 | - carsNum = carsList.size(); | |
| 1231 | - sBuffer.append("<CPHList>"); | |
| 1232 | - for (int i = 0; i < carsNum; i++) { | |
| 1233 | - cars = carsList.get(i); | |
| 1234 | - sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | |
| 1235 | - } | |
| 1236 | - sBuffer.append("</CPHList>"); | |
| 1237 | - } | |
| 1238 | - sBuffer.append("</XLPC>"); | |
| 1239 | - } | |
| 1240 | - sBuffer.append("</XLPCs>"); | |
| 1241 | - if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1242 | - result = "success"; | |
| 1243 | - } | |
| 1244 | - } catch (Exception e) { | |
| 1245 | - logger.error("setXLPC:",e); | |
| 1246 | - e.printStackTrace(); | |
| 1247 | - }finally{ | |
| 1248 | - logger.info("setXLPC:"+sBuffer.toString()); | |
| 1249 | - logger.info("setXLPC:"+result); | |
| 1250 | - } | |
| 1251 | - return result; | |
| 1252 | - } | |
| 1253 | - | |
| 1254 | - | |
| 1255 | - /** | |
| 1256 | - * 上传超速数据 | |
| 1257 | - */ | |
| 1258 | - @Override | |
| 1259 | - public String setCS() { | |
| 1260 | - String result = "failure"; | |
| 1261 | - StringBuffer sBuffer =new StringBuffer(); | |
| 1262 | - sBuffer.append("<CSs>"); | |
| 1263 | - String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | |
| 1264 | - Connection conn = null; | |
| 1265 | - PreparedStatement ps = null; | |
| 1266 | - ResultSet rs = null; | |
| 1267 | - // 取昨天 的日期 | |
| 1268 | - String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 1269 | - try { | |
| 1270 | - conn = DBUtils_MS.getConnection(); | |
| 1271 | - ps = conn.prepareStatement(sql); | |
| 1272 | - ps.setString(1, yesterday); | |
| 1273 | - rs = ps.executeQuery(); | |
| 1274 | - Float lon, lat; | |
| 1275 | - String kssk; | |
| 1276 | - String speed; | |
| 1277 | - while (rs.next()) { | |
| 1278 | - kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | |
| 1279 | - speed = rs.getString("SPEED"); | |
| 1280 | - // 经纬度 | |
| 1281 | - lon = rs.getFloat("LON"); | |
| 1282 | - lat = rs.getFloat("LAT"); | |
| 1283 | - sBuffer.append("<CS>"); | |
| 1284 | - sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | |
| 1285 | - sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | |
| 1286 | - sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | |
| 1287 | - sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | |
| 1288 | - sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | |
| 1289 | - sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | |
| 1290 | - sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | |
| 1291 | - sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | |
| 1292 | - sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | |
| 1293 | - sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | |
| 1294 | - sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | |
| 1295 | - sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | |
| 1296 | - sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | |
| 1297 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1298 | - sBuffer.append("</CS>"); | |
| 1299 | - } | |
| 1300 | - sBuffer.append("</CSs>"); | |
| 1301 | - if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1302 | - result = "success"; | |
| 1303 | - } | |
| 1304 | - } catch (Exception e) { | |
| 1305 | - logger.error("setCS:",e); | |
| 1306 | - e.printStackTrace(); | |
| 1307 | - } finally { | |
| 1308 | - logger.info("setCS:"+sBuffer.toString()); | |
| 1309 | - logger.info("setCS:"+result); | |
| 1310 | - DBUtils_MS.close(rs, ps, conn); | |
| 1311 | - } | |
| 1312 | - return result; | |
| 1313 | - } | |
| 1314 | - | |
| 1315 | - | |
| 1316 | - /** | |
| 1317 | - * 下载全量的公交基础数据 | |
| 1318 | - */ | |
| 1319 | - public String getDownLoadAllDataFile() { | |
| 1320 | - String result = "failure"; | |
| 1321 | - try { | |
| 1322 | - try { | |
| 1323 | - if(ygcBasicDataService.download("admin","000000","abc.zip")){ | |
| 1324 | - result = "success"; | |
| 1325 | - } | |
| 1326 | - } catch (Exception e) { | |
| 1327 | - e.printStackTrace(); | |
| 1328 | - } | |
| 1329 | - } catch (Exception e) { | |
| 1330 | - e.printStackTrace(); | |
| 1331 | - } | |
| 1332 | - | |
| 1333 | - return result; | |
| 1334 | - } | |
| 1335 | - | |
| 1336 | - /** | |
| 1337 | - * 下载增量的公交基础数据 | |
| 1338 | - */ | |
| 1339 | - public String getDownLoadIncreaseDataFile() { | |
| 1340 | - String result = "success"; | |
| 1341 | - try { | |
| 1342 | - //System.out.println(portType.downloadIncreaseDataFile(args0, args1, args2)); | |
| 1343 | - } catch (Exception e) { | |
| 1344 | - e.printStackTrace(); | |
| 1345 | - } | |
| 1346 | - | |
| 1347 | - return result; | |
| 1348 | - } | |
| 1349 | - | |
| 1350 | - /** | |
| 1351 | - * 指定线路查询方式公交基础数据下载 | |
| 1352 | - */ | |
| 1353 | - public String getDownLoadWarrantsBusLineStation() { | |
| 1354 | - String result = "success"; | |
| 1355 | - try { | |
| 1356 | - | |
| 1357 | - //portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | |
| 1358 | - } catch (Exception e) { | |
| 1359 | - e.printStackTrace(); | |
| 1360 | - } | |
| 1361 | - | |
| 1362 | - return result; | |
| 1363 | - } | |
| 1364 | - | |
| 1365 | - /** | |
| 1366 | - * 计算结束时间 | |
| 1367 | - * @param fcsj 发车时间 | |
| 1368 | - * @param bcsj 班次历时 | |
| 1369 | - * @return | |
| 1370 | - */ | |
| 1371 | - private String calcDdsj(String fcsj,Integer bcsj){ | |
| 1372 | - String result = ""; | |
| 1373 | - if(fcsj.indexOf(":") != -1){ | |
| 1374 | - if(bcsj == null){ | |
| 1375 | - return fcsj; | |
| 1376 | - } | |
| 1377 | - // 时和分隔开 | |
| 1378 | - String[] fcsjArray = fcsj.split(":"); | |
| 1379 | - // 分和历时时间相加 | |
| 1380 | - Integer fullTime = Integer.valueOf(fcsjArray[1])+ bcsj; | |
| 1381 | - int hour,min,sumHour; | |
| 1382 | - hour = fullTime / 60; | |
| 1383 | - min = fullTime % 60; | |
| 1384 | - sumHour = Integer.valueOf(fcsjArray[0])+hour; | |
| 1385 | - if(sumHour >= 24){ | |
| 1386 | - result = String.format("%02d",sumHour - 24); | |
| 1387 | - }else{ | |
| 1388 | - result = String.format("%02d",sumHour);; | |
| 1389 | - } | |
| 1390 | - result +=":"+String.format("%02d", min); | |
| 1391 | - }else{ | |
| 1392 | - result = fcsj; | |
| 1393 | - } | |
| 1394 | - return result; | |
| 1395 | - } | |
| 1396 | - | |
| 1397 | - /** | |
| 1398 | - * 改变时间格式 | |
| 1399 | - * @param ttInfoDetail 时刻表详细 | |
| 1400 | - * @return xx:yy | |
| 1401 | - */ | |
| 1402 | - private String changeTimeFormat(TTInfoDetail ttInfoDetail){ | |
| 1403 | - String result = "00:00"; | |
| 1404 | - String fcsj = ttInfoDetail.getFcsj(); | |
| 1405 | - if(fcsj.indexOf(":") != -1){ | |
| 1406 | - // 时和分隔开 | |
| 1407 | - String[] fcsjArray = fcsj.split(":"); | |
| 1408 | - result = String.format("%02d", Integer.valueOf(fcsjArray[0]))+":"; | |
| 1409 | - result +=String.format("%02d", Integer.valueOf(fcsjArray[1])); | |
| 1410 | - }else{ | |
| 1411 | - result = null; | |
| 1412 | - logger.info("setSKB:发车时间错误:ttInfoDetail.id="+ttInfoDetail.getId()); | |
| 1413 | - } | |
| 1414 | - return result; | |
| 1415 | - } | |
| 1416 | - | |
| 1417 | - /** | |
| 1418 | - * 拼装线路计划班次表的XML | |
| 1419 | - * @param sBuffer | |
| 1420 | - * @param schedulePlanInfo | |
| 1421 | - * @param xlbm | |
| 1422 | - * @param zbh | |
| 1423 | - * @param lp | |
| 1424 | - */ | |
| 1425 | - private void assembleJHBC(StringBuffer sBuffer,SchedulePlanInfo schedulePlanInfo,String xlbm,String zbh,Long lp){ | |
| 1426 | - sBuffer.append("<JHBC>"); | |
| 1427 | - sBuffer.append("<RQ>").append(sdfnyr.format(schedulePlanInfo.getScheduleDate())).append("</RQ>"); | |
| 1428 | - sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(xlbm)).append("</XLBM>"); | |
| 1429 | - sBuffer.append("<CPH>").append("沪"+zbh).append("</CPH>"); | |
| 1430 | - sBuffer.append("<LPBH>").append(lp).append("</LPBH>"); | |
| 1431 | - sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1432 | - sBuffer.append("<BCList>"); | |
| 1433 | - } | |
| 1434 | - /** | |
| 1435 | - * 转换排班规则 | |
| 1436 | - * @param ruleDay | |
| 1437 | - * @return | |
| 1438 | - */ | |
| 1439 | - private String changeRuleDay(String ruleDay){ | |
| 1440 | - String result = ""; | |
| 1441 | - int flag ; | |
| 1442 | - String[] ruleDayArray = ruleDay.split(","); | |
| 1443 | - for (int i = 0; i < ruleDayArray.length; i++) { | |
| 1444 | - if(ruleDayArray[i].equals("1")){ | |
| 1445 | - flag = i+1; | |
| 1446 | - }else{ | |
| 1447 | - flag = 0; | |
| 1448 | - } | |
| 1449 | - if(flag > 0){ | |
| 1450 | - result += flag + ","; | |
| 1451 | - } | |
| 1452 | - } | |
| 1453 | - // 去掉最后一个字符 | |
| 1454 | - if(StringUtils.endsWith(result,",")){ | |
| 1455 | - result = StringUtils.removeEnd(result,","); | |
| 1456 | - } | |
| 1457 | - return result; | |
| 1458 | - } | |
| 1459 | - /** | |
| 1460 | - * 设置统一的公司名称 | |
| 1461 | - * @param company | |
| 1462 | - */ | |
| 1463 | - private void setCompanyName(String company){ | |
| 1464 | - if(company.equals("闵行公司")){ | |
| 1465 | - company = "浦东闵行公交公司"; | |
| 1466 | - }else if(company.equals("杨高公司")){ | |
| 1467 | - company = "浦东杨高公交公司"; | |
| 1468 | - }else if(company.equals("上南公司")){ | |
| 1469 | - company = "浦东上南公交公司"; | |
| 1470 | - }else if(company.equals("金高公司")){ | |
| 1471 | - company = "浦东金高公交公司"; | |
| 1472 | - }else if(company.equals("南汇公司")){ | |
| 1473 | - company = "浦东南汇公交公司"; | |
| 1474 | - }else if(company.equals("青浦公交")){ | |
| 1475 | - company = "浦东青浦公交公司"; | |
| 1476 | - } | |
| 1477 | - } | |
| 1478 | - /** | |
| 1479 | - * @param stationsList 站点路由集 | |
| 1480 | - * @param sBuffer sBuffer | |
| 1481 | - * @param startId 站点序号起始ID | |
| 1482 | - * | |
| 1483 | - * @return 站点序号累加后的ID | |
| 1484 | - */ | |
| 1485 | - private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ | |
| 1486 | - int size = stationsList.size(); | |
| 1487 | - StationRoute srRoute; | |
| 1488 | - HashMap<String,String> paraMap; | |
| 1489 | - String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 | |
| 1490 | - for (int i = 0; i < size; i++) { | |
| 1491 | - srRoute = stationsList.get(i); | |
| 1492 | - zdlx = srRoute.getStationMark(); | |
| 1493 | - if(zdlx.equals("B")){ | |
| 1494 | - zdlx = "0"; | |
| 1495 | - }else if(zdlx.equals("E")){ | |
| 1496 | - zdlx = "1"; | |
| 1497 | - }else{ | |
| 1498 | - zdlx = "2"; | |
| 1499 | - } | |
| 1500 | - paraMap = packageYgcStationNumParam(srRoute,null); | |
| 1501 | - sBuffer.append("<Station>"); | |
| 1502 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | |
| 1503 | - sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); | |
| 1504 | - sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); | |
| 1505 | - sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); | |
| 1506 | - sBuffer.append("<ZDJD>").append(srRoute.getStation().getgLonx()).append("</ZDJD>"); | |
| 1507 | - sBuffer.append("<ZDWD>").append(srRoute.getStation().getgLaty()).append("</ZDWD>"); | |
| 1508 | - sBuffer.append("<ZZ>").append(srRoute.getStation().getAddr() == null ? "" : srRoute.getStation().getAddr()).append("</ZZ>"); | |
| 1509 | - sBuffer.append("<ZDLX>").append(zdlx).append("</ZDLX>"); | |
| 1510 | - sBuffer.append("<ZJLC>").append(srRoute.getDistances()).append("</ZJLC>"); | |
| 1511 | - sBuffer.append("</Station>"); | |
| 1512 | - startId++; | |
| 1513 | - } | |
| 1514 | - return startId; | |
| 1515 | - } | |
| 1516 | - | |
| 1517 | - /** | |
| 1518 | - * @param pointList 站点点位集 | |
| 1519 | - * @param sBuffer sBuffer | |
| 1520 | - * @param startId 站点序号起始ID | |
| 1521 | - * | |
| 1522 | - * @return 站点序号累加后的ID | |
| 1523 | - */ | |
| 1524 | - private int packagStationPointXml(List<Object[]> pointList,StringBuffer sBuffer,int startId){ | |
| 1525 | - int size = pointList.size(); | |
| 1526 | - Object[] objs; | |
| 1527 | - String bsection,dir,section; | |
| 1528 | - String[] sections ; | |
| 1529 | - for (int i = 0; i < size; i++) { | |
| 1530 | - objs = pointList.get(i); | |
| 1531 | - bsection = objs[0]+""; | |
| 1532 | - dir = objs[1]+""; | |
| 1533 | - // 取括号内的内容 | |
| 1534 | - Pattern pattern = Pattern.compile("(?<=\\()(.+?)(?=\\))"); | |
| 1535 | - Matcher matcher = pattern.matcher(bsection); | |
| 1536 | - if(matcher.find()){ | |
| 1537 | - sections = matcher.group().split(","); | |
| 1538 | - for (int j = 0 ; j < sections.length ; j ++){ | |
| 1539 | - section = sections[j]; | |
| 1540 | - sBuffer.append("<LinePoint>"); | |
| 1541 | - sBuffer.append("<ZDXH>").append(startId).append("</ZDXH>"); | |
| 1542 | - sBuffer.append("<SXX>").append(dir).append("</SXX>"); | |
| 1543 | - sBuffer.append("<ZDJD>").append(section.split(" ")[0]).append("</ZDJD>"); | |
| 1544 | - sBuffer.append("<ZDWD>").append(section.split(" ")[1]).append("</ZDWD>"); | |
| 1545 | - sBuffer.append("</LinePoint>"); | |
| 1546 | - startId++; | |
| 1547 | - } | |
| 1548 | - } | |
| 1549 | - } | |
| 1550 | - return startId; | |
| 1551 | - } | |
| 1552 | - | |
| 1553 | - /** | |
| 1554 | - * 获取运管处站点序号 | |
| 1555 | - * @param map | |
| 1556 | - * @return 运管处站点序号 | |
| 1557 | - */ | |
| 1558 | - private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ | |
| 1559 | - // 线路编码 | |
| 1560 | - String lineCode = map.get("lineCode"); | |
| 1561 | - // 线路走向 0:上行 1:下行 | |
| 1562 | - String direction = map.get("direction"); | |
| 1563 | - // 站点编码 | |
| 1564 | - String stationCode = map.get("stationCode"); | |
| 1565 | - // 站点类型:B:起点站 Z:中途站 E:终点站 T:停车场 | |
| 1566 | - String stationMark = map.get("stationMark"); | |
| 1567 | - String[] marks = null; | |
| 1568 | - // 起点站,先从起点找,找不到再从中途站找,最后从终点找 | |
| 1569 | - if(stationMark.equals("B")){ | |
| 1570 | - marks= new String[]{"B","Z","E"}; | |
| 1571 | - }else if(stationMark.equals("E")){// 终点站相反 | |
| 1572 | - marks= new String[]{"E","Z","B"}; | |
| 1573 | - }else if(stationMark.equals("Z")){ | |
| 1574 | - marks= new String[]{"Z"}; | |
| 1575 | - } | |
| 1576 | - // 默认从缓存BasicData.stationName2YgcNumber | |
| 1577 | - Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | |
| 1578 | - // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | |
| 1579 | - if(stationNumMap != null){ | |
| 1580 | - tempMap = stationNumMap; | |
| 1581 | - } | |
| 1582 | - Integer number = null; | |
| 1583 | - for (int i = 0 ;i < marks.length ; i ++){ | |
| 1584 | - number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | |
| 1585 | - if(number != null){ | |
| 1586 | - break; | |
| 1587 | - } | |
| 1588 | - } | |
| 1589 | - return number == null ? 0 : number; | |
| 1590 | - } | |
| 1591 | - | |
| 1592 | - /** | |
| 1593 | - * 封装查询站序条件 | |
| 1594 | - * @param obj | |
| 1595 | - * @return | |
| 1596 | - */ | |
| 1597 | - private HashMap packageYgcStationNumParam(Object obj,HashMap<String,String> otherParam){ | |
| 1598 | - HashMap<String,String> map = new HashMap<String,String>(); | |
| 1599 | - String lineCode = "",direction = "",stationCode = "",stationMark = ""; | |
| 1600 | - // 站点路由 | |
| 1601 | - if(obj instanceof StationRoute){ | |
| 1602 | - StationRoute sr = (StationRoute)obj; | |
| 1603 | - lineCode = sr.getLineCode(); | |
| 1604 | - direction = String.valueOf(sr.getDirections()); | |
| 1605 | - stationCode = sr.getStationCode(); | |
| 1606 | - stationMark = sr.getStationMark(); | |
| 1607 | - }else if(obj instanceof ScheduleRealInfo){ //实际排班计划明细。 | |
| 1608 | - ScheduleRealInfo sri = (ScheduleRealInfo)obj; | |
| 1609 | - lineCode = sri.getXlBm(); | |
| 1610 | - direction = sri.getXlDir(); | |
| 1611 | - if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1612 | - stationMark = otherParam.get("stationMark"); | |
| 1613 | - if(stationMark.equals("B")){ // 起点站 | |
| 1614 | - stationCode = sri.getQdzCode(); | |
| 1615 | - }else if(stationMark.equals("E")){ // 终点站 | |
| 1616 | - stationCode = sri.getZdzCode(); | |
| 1617 | - } | |
| 1618 | - } | |
| 1619 | - }else if(obj instanceof SchedulePlanInfo){ //排班计划明细 | |
| 1620 | - SchedulePlanInfo spi = (SchedulePlanInfo)obj; | |
| 1621 | - lineCode = spi.getXlBm(); | |
| 1622 | - direction = spi.getXlDir(); | |
| 1623 | - if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1624 | - stationMark = otherParam.get("stationMark"); | |
| 1625 | - if(stationMark.equals("B")){ // 起点站 | |
| 1626 | - stationCode = spi.getQdzCode(); | |
| 1627 | - }else if(stationMark.equals("E")){ // 终点站 | |
| 1628 | - stationCode = spi.getZdzCode(); | |
| 1629 | - } | |
| 1630 | - } | |
| 1631 | - }else if(obj instanceof TTInfoDetail){ //时刻表明细 | |
| 1632 | - TTInfoDetail ttid = (TTInfoDetail)obj; | |
| 1633 | - lineCode = ttid.getXl().getLineCode(); | |
| 1634 | - direction = ttid.getXlDir(); | |
| 1635 | - if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1636 | - stationMark = otherParam.get("stationMark"); | |
| 1637 | - if(stationMark.equals("B")){ // 起点站 | |
| 1638 | - stationCode = ttid.getQdzCode(); | |
| 1639 | - }else if(stationMark.equals("E")){ // 终点站 | |
| 1640 | - stationCode = ttid.getZdzCode(); | |
| 1641 | - } | |
| 1642 | - } | |
| 1643 | - } | |
| 1644 | - map.put("lineCode",lineCode);// 站点编码 | |
| 1645 | - map.put("direction",direction); // 上下行 | |
| 1646 | - map.put("stationCode",stationCode); // 站点编号 | |
| 1647 | - map.put("stationMark",stationMark); // 站点类型 | |
| 1648 | - return map; | |
| 1649 | - } | |
| 1650 | - | |
| 1651 | - /** | |
| 1652 | - * 取得历史站点编码和站点名称的对应关系 | |
| 1653 | - * @return | |
| 1654 | - */ | |
| 1655 | - private Map<String, String> getLsStationCode(String lineCode,int lineVersion){ | |
| 1656 | - Map<String,Object> map = new HashMap<>(); | |
| 1657 | - map.put("lineCode_eq", lineCode); | |
| 1658 | - map.put("versions_eq",lineVersion); | |
| 1659 | - LsStationRoute lsroute; | |
| 1660 | - Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator(); | |
| 1661 | - Map<String, String> stationCode2Name = new HashMap<>(); | |
| 1662 | - while (iterator.hasNext()) { | |
| 1663 | - lsroute = iterator.next(); | |
| 1664 | - stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName()); | |
| 1665 | - } | |
| 1666 | - return stationCode2Name; | |
| 1667 | - } | |
| 1668 | - | |
| 1669 | - private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){ | |
| 1670 | - Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); | |
| 1671 | - /** | |
| 1672 | - * 加载运管处的站点及序号 | |
| 1673 | - * 上行从1开始,下行顺序续编 | |
| 1674 | - */ | |
| 1675 | - List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion); | |
| 1676 | - if(ygcLines != null && ygcLines.size() > 0){ | |
| 1677 | - int size = ygcLines.size(); | |
| 1678 | - Map<String, String> tempMap ; | |
| 1679 | - int num = 1; | |
| 1680 | - String key; | |
| 1681 | - String lineCode = ""; | |
| 1682 | - for (int i = 0; i < size; i ++){ | |
| 1683 | - tempMap = ygcLines.get(i); | |
| 1684 | - if(lineCode.equals("")){ | |
| 1685 | - lineCode = tempMap.get("lineCode"); | |
| 1686 | - }else if(!lineCode.equals(tempMap.get("lineCode"))){ | |
| 1687 | - num = 1; | |
| 1688 | - lineCode = tempMap.get("lineCode"); | |
| 1689 | - } | |
| 1690 | - key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | |
| 1691 | - + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | |
| 1692 | - tempStationName2YgcNumber.put(key,num++); | |
| 1693 | - } | |
| 1694 | - } | |
| 1695 | - return tempStationName2YgcNumber; | |
| 1696 | - } | |
| 1697 | - | |
| 1698 | - private String getSetXlXml(Line line,LineInformation lineInformation){ | |
| 1699 | - StringBuffer sBuffer = new StringBuffer(); | |
| 1700 | - List<StationRoute> upStationsList ;// 上行站点路由集 | |
| 1701 | - List<StationRoute> downStationsList;// 下行站点路由集 | |
| 1702 | - List<Object[]> downPointList;// 下行站点集 | |
| 1703 | - List<Object[]> upPointList;// 上行站点集 | |
| 1704 | - sBuffer.append("<XLs>"); | |
| 1705 | - sBuffer.append("<XL>"); | |
| 1706 | - sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 1707 | - sBuffer.append("<XLMC>").append(line.getName()).append("</XLMC>"); | |
| 1708 | - sBuffer.append("<QDZ>").append(line.getStartStationName()).append("</QDZ>"); | |
| 1709 | - sBuffer.append("<ZDZ>").append(line.getEndStationName()).append("</ZDZ>"); | |
| 1710 | - sBuffer.append("<QZLC>").append(lineInformation.getUpMileage()).append("</QZLC>"); | |
| 1711 | - sBuffer.append("<ZQLC>").append(lineInformation.getDownMileage()).append("</ZQLC>"); | |
| 1712 | - sBuffer.append("<XLGH>").append(line.getLinePlayType()).append("</XLGH>"); | |
| 1713 | - sBuffer.append("<UPDATE_DATE>").append(sdfnyr.format(new Date())).append("</UPDATE_DATE>"); | |
| 1714 | - // 循环添加站点信息 | |
| 1715 | - sBuffer.append("<StationList>"); | |
| 1716 | - // 先查上行 | |
| 1717 | - upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); | |
| 1718 | - Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | |
| 1719 | - int startId = 1; | |
| 1720 | - startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | |
| 1721 | - // 环线不查下行 | |
| 1722 | - if(line.getLinePlayType() != 1){ | |
| 1723 | - // 再查下行 | |
| 1724 | - downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); | |
| 1725 | - packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | |
| 1726 | - } | |
| 1727 | - sBuffer.append("</StationList>"); | |
| 1728 | - // 循环添加站点点位信息 | |
| 1729 | - sBuffer.append("<LinePointList>"); | |
| 1730 | - upPointList = sectionRepository.getSectionDirByLineId(line.getId(),0); | |
| 1731 | - startId = 1; | |
| 1732 | - startId = packagStationPointXml(upPointList, sBuffer, startId); | |
| 1733 | - // 环线不查下行 | |
| 1734 | - if(line.getLinePlayType() != 1){ | |
| 1735 | - downPointList = sectionRepository.getSectionDirByLineId(line.getId(),1); | |
| 1736 | - packagStationPointXml(downPointList, sBuffer, startId); | |
| 1737 | - } | |
| 1738 | - sBuffer.append("</LinePointList>"); | |
| 1739 | - sBuffer.append("</XL>"); | |
| 1740 | - sBuffer.append("</XLs>"); | |
| 1741 | - return sBuffer.toString(); | |
| 1742 | - } | |
| 1743 | -} | |
| 1 | +package com.bsth.service.impl; | |
| 2 | + | |
| 3 | +import com.bsth.data.BasicData; | |
| 4 | +import com.bsth.email.SendEmailController; | |
| 5 | +import com.bsth.email.entity.EmailBean; | |
| 6 | +import com.bsth.entity.*; | |
| 7 | +import com.bsth.entity.realcontrol.ChildTaskPlan; | |
| 8 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | |
| 9 | +import com.bsth.entity.schedule.SchedulePlanInfo; | |
| 10 | +import com.bsth.entity.schedule.TTInfo; | |
| 11 | +import com.bsth.entity.schedule.TTInfoDetail; | |
| 12 | +import com.bsth.entity.search.CustomerSpecs; | |
| 13 | +import com.bsth.entity.sys.SysUser; | |
| 14 | +import com.bsth.entity.traffic.SKBUploadLogger; | |
| 15 | +import com.bsth.repository.*; | |
| 16 | +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | |
| 17 | +import com.bsth.repository.schedule.*; | |
| 18 | +import com.bsth.repository.traffic.SKBUploadLoggerRepository; | |
| 19 | +import com.bsth.security.util.SecurityUtils; | |
| 20 | +import com.bsth.service.TrafficManageService; | |
| 21 | +import com.bsth.service.traffic.YgcBasicDataService; | |
| 22 | +import com.bsth.util.TimeUtils; | |
| 23 | +import com.bsth.util.db.DBUtils_MS; | |
| 24 | +import com.bsth.webService.trafficManage.org.tempuri.Results; | |
| 25 | +import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | |
| 26 | +import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | |
| 27 | +import org.apache.commons.lang.StringEscapeUtils; | |
| 28 | +import org.apache.commons.lang.StringUtils; | |
| 29 | +import org.apache.commons.lang.time.DateUtils; | |
| 30 | +import org.joda.time.DateTime; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 34 | +import org.springframework.data.domain.Sort; | |
| 35 | +import org.springframework.data.domain.Sort.Direction; | |
| 36 | +import org.springframework.security.core.context.SecurityContextHolder; | |
| 37 | +import org.springframework.stereotype.Service; | |
| 38 | + | |
| 39 | +import java.io.*; | |
| 40 | +import java.net.InetAddress; | |
| 41 | +import java.sql.Connection; | |
| 42 | +import java.sql.PreparedStatement; | |
| 43 | +import java.sql.ResultSet; | |
| 44 | +import java.text.DecimalFormat; | |
| 45 | +import java.text.SimpleDateFormat; | |
| 46 | +import java.util.*; | |
| 47 | +import java.util.regex.Matcher; | |
| 48 | +import java.util.regex.Pattern; | |
| 49 | + | |
| 50 | +/** | |
| 51 | + * | |
| 52 | + * @ClassName: TrafficManageServiceImpl(运管处接口service业务层实现类) | |
| 53 | + * | |
| 54 | + * @Extends : BaseService | |
| 55 | + * | |
| 56 | + * @Description: TODO(运管处接口service业务层) | |
| 57 | + * | |
| 58 | + * @Author bsth@zq | |
| 59 | + * | |
| 60 | + * @Date 2016年10月28日 上午9:21:17 | |
| 61 | + * | |
| 62 | + * @Version 公交调度系统BS版 0.1 | |
| 63 | + * | |
| 64 | + */ | |
| 65 | + | |
| 66 | +@Service | |
| 67 | +public class TrafficManageServiceImpl implements TrafficManageService{ | |
| 68 | + | |
| 69 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 70 | + // 运管处上传日志类型 | |
| 71 | + public static final String UPLOAD_TYPE_SKB = "1"; | |
| 72 | + public static final String UPLOAD_TYPE_XL = "2"; | |
| 73 | + public static final String UPLOAD_TYPE_LD = "3"; | |
| 74 | + | |
| 75 | + // 线路repository | |
| 76 | + @Autowired | |
| 77 | + private LineRepository lineRepository; | |
| 78 | + | |
| 79 | + @Autowired | |
| 80 | + private LineInformationRepository lineInformationRepository; | |
| 81 | + | |
| 82 | + // 站点路由repository | |
| 83 | + @Autowired | |
| 84 | + private StationRouteRepository stationRouteRepository; | |
| 85 | + | |
| 86 | + // 历史站点路由repository | |
| 87 | + @Autowired | |
| 88 | + private LsStationRouteRepository lsStationRouteRepository; | |
| 89 | + | |
| 90 | + @Autowired | |
| 91 | + private SectionRepository sectionRepository; | |
| 92 | + | |
| 93 | + // 车辆repository | |
| 94 | + @Autowired | |
| 95 | + private CarsRepository carsRepository; | |
| 96 | + | |
| 97 | + // 人员repository | |
| 98 | + @Autowired | |
| 99 | + private PersonnelRepository personnelRepository; | |
| 100 | + | |
| 101 | + // 时刻模板repository | |
| 102 | + @Autowired | |
| 103 | + private TTInfoRepository ttInfoRepository; | |
| 104 | + | |
| 105 | + // 时刻模板明细repository | |
| 106 | + @Autowired | |
| 107 | + private TTInfoDetailRepository ttInfoDetailRepository; | |
| 108 | + | |
| 109 | + // 排班计划明细repository | |
| 110 | + @Autowired | |
| 111 | + private SchedulePlanInfoRepository schedulePlanInfoRepository; | |
| 112 | + | |
| 113 | + // 实际排班计划明细repository | |
| 114 | + @Autowired | |
| 115 | + private ScheduleRealInfoRepository scheduleRealInfoRepository; | |
| 116 | + | |
| 117 | + // 时刻表上传记录repository | |
| 118 | + @Autowired | |
| 119 | + private SKBUploadLoggerRepository skbUploadLoggerRepository; | |
| 120 | + | |
| 121 | + // 线路站点repository | |
| 122 | + @Autowired | |
| 123 | + private YgcBasicDataService ygcBasicDataService; | |
| 124 | + | |
| 125 | + // 发送邮件 | |
| 126 | + @Autowired | |
| 127 | + private SendEmailController sendEmailController; | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * 线路版本repository | |
| 131 | + */ | |
| 132 | + @Autowired | |
| 133 | + private LineVersionsRepository lineVersionsRepository; | |
| 134 | + | |
| 135 | + // 运管处上传接口 | |
| 136 | + private com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap webServiceSoapUp; | |
| 137 | + private WebServiceSoap ssop ; | |
| 138 | + { | |
| 139 | + try { | |
| 140 | + ssop = new WebServiceLocator().getWebServiceSoap(); | |
| 141 | + } catch (Exception e) { | |
| 142 | + e.printStackTrace(); | |
| 143 | + } | |
| 144 | + } | |
| 145 | + // 格式化 年月日时分秒 nyrsfm是年月日时分秒的拼音首字母 | |
| 146 | + private SimpleDateFormat sdfnyrsfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
| 147 | + | |
| 148 | + // 格式化 年月日 | |
| 149 | + private SimpleDateFormat sdfnyr = new SimpleDateFormat("yyyy-MM-dd"); | |
| 150 | + | |
| 151 | + // 数字格式化 | |
| 152 | + DecimalFormat format = new DecimalFormat("0.00"); | |
| 153 | + | |
| 154 | + // 用户名 | |
| 155 | + private final String userNameOther = "user"; | |
| 156 | + // 密码 | |
| 157 | + private final String passwordOther = "user"; | |
| 158 | + | |
| 159 | + // 用户名 | |
| 160 | + private final String userNameUp = "user"; | |
| 161 | + // 密码 | |
| 162 | + private final String passwordUp = "user"; | |
| 163 | + // 接收邮件人 | |
| 164 | + private final String emailSendToAddress = "113252620@qq.com"; | |
| 165 | + // 记录路单上线的成功、失败线路数 | |
| 166 | + private Integer countSuccess,countFailure; | |
| 167 | + | |
| 168 | + private synchronized com.bsth.webService.trafficManage.up.org.tempuri.WebServiceSoap getWebServiceSoapUp(){ | |
| 169 | + try { | |
| 170 | + if(webServiceSoapUp == null){ | |
| 171 | + webServiceSoapUp = new com.bsth.webService.trafficManage.up.org.tempuri.WebServiceLocator().getWebServiceSoap(); | |
| 172 | + } | |
| 173 | + }catch (Exception e){ | |
| 174 | + e.printStackTrace(); | |
| 175 | + }finally { | |
| 176 | + return webServiceSoapUp; | |
| 177 | + } | |
| 178 | + } | |
| 179 | + /** | |
| 180 | + * 上传线路信息 | |
| 181 | + */ | |
| 182 | + @Override | |
| 183 | + public String setXL(String ids) { | |
| 184 | + String result = "failure"; | |
| 185 | + String xml ; | |
| 186 | + String[] idArray = ids.split(","); | |
| 187 | + try { | |
| 188 | + for (String id : idArray) { | |
| 189 | + if(id == null || id.trim().equals("")){ | |
| 190 | + continue; | |
| 191 | + } | |
| 192 | + Map<String,Object> map = new HashMap<>(); | |
| 193 | + map.put("lineCode_eq", id); | |
| 194 | + Line line ; | |
| 195 | + LineInformation lineInformation; | |
| 196 | + Optional<Line> optionalLine = lineRepository.findOne(new CustomerSpecs<Line>(map)); | |
| 197 | + line = optionalLine.isPresent() ? optionalLine.get() : null; | |
| 198 | + if(line == null){ | |
| 199 | + continue; | |
| 200 | + } | |
| 201 | + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){ | |
| 202 | + return result; | |
| 203 | + } | |
| 204 | + map = new HashMap<>(); | |
| 205 | + map.put("line.id_eq",line.getId()); | |
| 206 | + Optional<LineInformation> optionalLineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(map)); | |
| 207 | + lineInformation = optionalLineInformation.isPresent() ? optionalLineInformation.get() : null; | |
| 208 | + if(lineInformation == null){ | |
| 209 | + continue; | |
| 210 | + } | |
| 211 | + // 取得封装好的xml | |
| 212 | + xml = getSetXlXml(line,lineInformation); | |
| 213 | + // 站点序号不能为0,如果为0,则返回错误 | |
| 214 | + if(xml.indexOf("<ZDXH>0</ZDXH>") != -1){ | |
| 215 | + return "0"; | |
| 216 | + } | |
| 217 | + String state;// 是否上传成功 | |
| 218 | + // 调用上传方法 | |
| 219 | + if(getWebServiceSoapUp().setXL(userNameUp,passwordUp,xml).isSuccess()){ | |
| 220 | + result = "success"; | |
| 221 | + state = "1"; | |
| 222 | + }else{ | |
| 223 | + result = "failure"; | |
| 224 | + state = "0"; | |
| 225 | + } | |
| 226 | + logger.info("setXL:"+xml); | |
| 227 | + logger.info("setXL:"+result); | |
| 228 | + // 保存运管处上传记录 | |
| 229 | + saveYgcUploadLog(line,xml,TrafficManageServiceImpl.UPLOAD_TYPE_XL,state); | |
| 230 | + } | |
| 231 | + } catch (Exception e) { | |
| 232 | + logger.error("setXL:",e); | |
| 233 | + e.printStackTrace(); | |
| 234 | + } | |
| 235 | + return result; | |
| 236 | + } | |
| 237 | + | |
| 238 | + /** | |
| 239 | + * 加载运管处的站点及序号 | |
| 240 | + * 上行从1开始,下行顺序续编 | |
| 241 | + */ | |
| 242 | + private Map<String, Integer> getStationName2YgcNumberMap (String lineCode){ | |
| 243 | + Map<String, Integer> resultMap = new HashMap<>(); | |
| 244 | + List<Map<String, String>> ygcLines = stationRouteRepository.findLineWithYgcByLine(lineCode); | |
| 245 | + if(ygcLines != null && ygcLines.size() > 0){ | |
| 246 | + int size = ygcLines.size(); | |
| 247 | + Map<String, String> tempMap ; | |
| 248 | + int num = 1; | |
| 249 | + String key; | |
| 250 | + for (int i = 0; i < size; i ++){ | |
| 251 | + tempMap = ygcLines.get(i); | |
| 252 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | |
| 253 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | |
| 254 | + resultMap.put(key,num++); | |
| 255 | + } | |
| 256 | + } | |
| 257 | + return resultMap; | |
| 258 | + } | |
| 259 | + | |
| 260 | + /** | |
| 261 | + * 上传线路信息(按in_use上传) | |
| 262 | + */ | |
| 263 | + @Override | |
| 264 | + public String setXLByInUse(String inUse) { | |
| 265 | + StringBuffer result = new StringBuffer(); | |
| 266 | + try { | |
| 267 | + Map<String,Object> map = new HashMap<>(); | |
| 268 | + if(inUse != null && inUse.equals("1")){ | |
| 269 | + map.put("inUse_eq", inUse); | |
| 270 | + } | |
| 271 | + List<Line> lines ; | |
| 272 | + Line line; | |
| 273 | + lines = lineRepository.findAll(new CustomerSpecs<Line>(map)); | |
| 274 | + if(lines != null && lines.size() > 0){ | |
| 275 | + for(int i = 0 ; i < lines.size() ; i ++){ | |
| 276 | + line = lines.get(i); | |
| 277 | + if(line != null && line.getId() != null){ | |
| 278 | + result.append(line.getLineCode()).append(":").append(setXL(line.getLineCode())).append(";"); | |
| 279 | + } | |
| 280 | + } | |
| 281 | + } | |
| 282 | + } catch (Exception e) { | |
| 283 | + result.append("failure"); | |
| 284 | + logger.error("setXLByInUse:",e); | |
| 285 | + e.printStackTrace(); | |
| 286 | + } | |
| 287 | + return result.toString(); | |
| 288 | + } | |
| 289 | + | |
| 290 | + /** | |
| 291 | + * 上传车辆信息 | |
| 292 | + */ | |
| 293 | + @Override | |
| 294 | + public String setCL() { | |
| 295 | + String result = "failure"; | |
| 296 | + StringBuffer sBuffer =new StringBuffer(); | |
| 297 | + try { | |
| 298 | + sBuffer.append("<CLs>"); | |
| 299 | + Cars cars = null; | |
| 300 | + String company; | |
| 301 | + Iterator<Cars> carsIterator = carsRepository.findAll().iterator(); | |
| 302 | + while(carsIterator.hasNext()){ | |
| 303 | + cars = carsIterator.next(); | |
| 304 | + sBuffer.append("<CL>"); | |
| 305 | + company = cars.getCompany(); | |
| 306 | + setCompanyName(company);// 统一公司名称 | |
| 307 | + sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | |
| 308 | + sBuffer.append("<NBH>").append(cars.getInsideCode()).append("</NBH>"); | |
| 309 | + sBuffer.append("<CPH>").append(cars.getCarPlate()).append("</CPH>"); | |
| 310 | + sBuffer.append("<YYZBH>").append(cars.getServiceNo()).append("</YYZBH>"); | |
| 311 | + sBuffer.append("<CZCPH>").append(cars.getCarPlate()).append("</CZCPH>");//******这个数据没有*********** | |
| 312 | + sBuffer.append("<CZZDBH>").append(cars.getEquipmentCode()).append("</CZZDBH>"); | |
| 313 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 314 | + sBuffer.append("</CL>"); | |
| 315 | + } | |
| 316 | + sBuffer.append("</CLs>"); | |
| 317 | + if(ssop.setCL(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 318 | + result = "success"; | |
| 319 | + } | |
| 320 | + } catch (Exception e) { | |
| 321 | + logger.error("setCL:",e); | |
| 322 | + e.printStackTrace(); | |
| 323 | + }finally{ | |
| 324 | + logger.info("setCL:"+sBuffer.toString()); | |
| 325 | + logger.info("setCL:"+result); | |
| 326 | + } | |
| 327 | + return result; | |
| 328 | + } | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * 上传司机信息 | |
| 332 | + */ | |
| 333 | + @Override | |
| 334 | + public String setSJ() { | |
| 335 | + String result = "failure"; | |
| 336 | + StringBuffer sBuffer =new StringBuffer(); | |
| 337 | + try { | |
| 338 | + sBuffer.append("<SJs>"); | |
| 339 | + Personnel personnel = null; | |
| 340 | + String company; | |
| 341 | + Iterator<Personnel> personIterator = personnelRepository.findAll().iterator(); | |
| 342 | + while(personIterator.hasNext()){ | |
| 343 | + personnel = personIterator.next(); | |
| 344 | + sBuffer.append("<SJ>"); | |
| 345 | + company = personnel.getCompany(); | |
| 346 | + setCompanyName(company);// 统一公司名称 | |
| 347 | + sBuffer.append("<GSJC>").append(company).append("</GSJC>"); | |
| 348 | + sBuffer.append("<SJGH>").append(personnel.getJobCode()).append("</SJGH>"); | |
| 349 | + sBuffer.append("<CYZGZH>").append(personnel.getPapersCode()).append("</CYZGZH>");//*********** | |
| 350 | + sBuffer.append("<XM>").append(personnel.getPersonnelName()).append("</XM>"); | |
| 351 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 352 | + sBuffer.append("</SJ>"); | |
| 353 | + } | |
| 354 | + sBuffer.append("</SJs>"); | |
| 355 | + if(ssop.setSJ(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 356 | + result = "success"; | |
| 357 | + }; | |
| 358 | + } catch (Exception e) { | |
| 359 | + logger.error("setSJ:",e); | |
| 360 | + e.printStackTrace(); | |
| 361 | + }finally{ | |
| 362 | + logger.info("setSJ:"+sBuffer.toString()); | |
| 363 | + logger.info("setSJ:"+result); | |
| 364 | + } | |
| 365 | + return result; | |
| 366 | + } | |
| 367 | + | |
| 368 | + /** | |
| 369 | + * 上传路单 指定日期 yyyy-MM-dd | |
| 370 | + * @param theDate | |
| 371 | + * @return | |
| 372 | + */ | |
| 373 | + public String setLD(String theDate){ | |
| 374 | + return uploadLD(theDate); | |
| 375 | + } | |
| 376 | + | |
| 377 | + /** | |
| 378 | + * 上传路单 上传前一天的路单 | |
| 379 | + * @return | |
| 380 | + */ | |
| 381 | + public String setLD(){ | |
| 382 | + return uploadLD(null); | |
| 383 | + } | |
| 384 | + /** | |
| 385 | + * 上传路单 | |
| 386 | + * @return 上传成功标识 | |
| 387 | + */ | |
| 388 | + private String uploadLD(String theDate){ | |
| 389 | + // 取昨天 的日期 | |
| 390 | + String date = theDate == null ?sdfnyr.format(DateUtils.addDays(new Date(), -1)) : theDate; | |
| 391 | + StringBuffer sf = new StringBuffer(); | |
| 392 | + Results results = null; | |
| 393 | + String str = "", xlbm = null, oldXlbm = null; | |
| 394 | + List<Map<String,Object>> listGroup = null; | |
| 395 | + int scount = 0, ccount = 0; | |
| 396 | + long start = System.currentTimeMillis(); | |
| 397 | + try { | |
| 398 | + // 计数器 | |
| 399 | + int counter = 0; | |
| 400 | + // 每几条线路上传一次路单 | |
| 401 | + int per = 10; | |
| 402 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.setLD(date); | |
| 403 | + listGroup = scheduleRealInfoRepository.setLDGroup(date); | |
| 404 | + Map<String,Object> map = new HashMap(); | |
| 405 | + HashMap<String,String> paramMap; | |
| 406 | + HashMap<String,String> otherMap = new HashMap(); | |
| 407 | + | |
| 408 | + // 车辆内部编码和车牌做映射 | |
| 409 | + Map<String, String> inside2plate = new HashMap<>(); | |
| 410 | + Iterable<Cars> cars = carsRepository.findAll(); | |
| 411 | + for (Cars car : cars) { | |
| 412 | + inside2plate.put(car.getInsideCode(), car.getCarPlate()); | |
| 413 | + } | |
| 414 | + | |
| 415 | + // 线路编码和线路信息映射 | |
| 416 | + Map<String, Line> code2line = new HashMap<>(); | |
| 417 | + Iterable<Line> lines = lineRepository.findAll(); | |
| 418 | + for (Line line : lines) { | |
| 419 | + code2line.put(line.getLineCode(), line); | |
| 420 | + } | |
| 421 | + | |
| 422 | + // 线路编码和线路版本映射(电子路单日期) | |
| 423 | + Map<String, Integer> code2version = new HashMap<>(); | |
| 424 | + Iterable<LineVersions> versions = lineVersionsRepository.findLineVersionsByDate((int)(DateTime.parse(date).getMillis() / 1000)); | |
| 425 | + for (LineVersions version : versions) { | |
| 426 | + code2version.put(version.getLineCode(), version.getVersions()); | |
| 427 | + } | |
| 428 | + | |
| 429 | + Map<String, Integer> stationNumMap = null; | |
| 430 | + for(Map<String,Object> schRealInfo:listGroup){ | |
| 431 | + if(schRealInfo != null){ | |
| 432 | + // 获取线路是否使用标识,如果未使用,则不查该线路数据 | |
| 433 | + String lineCode = schRealInfo.get("xlBm")+""; | |
| 434 | + Line line = code2line.get(lineCode); | |
| 435 | + if(line == null || line.getInUse() == null || line.getInUse() == 0){ | |
| 436 | + ccount++; | |
| 437 | + continue; | |
| 438 | + } | |
| 439 | + if(counter % per == 0){ | |
| 440 | + sf = new StringBuffer(); | |
| 441 | + sf.append("<DLDS>"); | |
| 442 | + } | |
| 443 | + counter ++; | |
| 444 | + xlbm = BasicData.lineCode2ShangHaiCodeMap.get(lineCode); | |
| 445 | + if (!xlbm.equals(oldXlbm)) { | |
| 446 | + oldXlbm = xlbm; | |
| 447 | + Integer ver = code2version.get(lineCode); | |
| 448 | + if (ver != null) { | |
| 449 | + stationNumMap = getLsStationRoute(lineCode, ver); | |
| 450 | + } | |
| 451 | + } | |
| 452 | + | |
| 453 | + sf.append("<DLD>"); | |
| 454 | + sf.append("<RQ>").append(date).append("</RQ>"); | |
| 455 | + sf.append("<XLBM>").append(xlbm).append("</XLBM>"); | |
| 456 | + sf.append("<LPBH>").append(schRealInfo.get("lpName")).append("</LPBH>"); | |
| 457 | + sf.append("<CPH>").append(inside2plate.get(schRealInfo.get("clZbh"))).append("</CPH>"); | |
| 458 | + sf.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 459 | + sf.append("<LDList>"); | |
| 460 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 461 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("lpName")+"") | |
| 462 | + .equals(scheduleRealInfo.getLpName()) | |
| 463 | + && (schRealInfo.get("clZbh")+"").equals(scheduleRealInfo.getClZbh())){ | |
| 464 | + | |
| 465 | + if(scheduleRealInfo.isDestroy()){ | |
| 466 | + if(scheduleRealInfo.isReissue()){ | |
| 467 | + scheduleRealInfo.setFcsjActualAll(scheduleRealInfo.getDfsj()); | |
| 468 | + scheduleRealInfo.setZdsjActualAll(scheduleRealInfo.getZdsj()); | |
| 469 | + } | |
| 470 | + else | |
| 471 | + continue; | |
| 472 | + } | |
| 473 | + | |
| 474 | + if(scheduleRealInfo.getBcType().equals("in") | |
| 475 | + || scheduleRealInfo.getBcType().equals("out")){ | |
| 476 | + continue; | |
| 477 | + } | |
| 478 | + | |
| 479 | + sf.append("<LD>"); | |
| 480 | + sf.append("<SJGH>").append(scheduleRealInfo.getjGh()).append("</SJGH>"); | |
| 481 | + sf.append("<SXX>").append(scheduleRealInfo.getXlDir()).append("</SXX>"); | |
| 482 | + sf.append("<FCZDMC>").append(scheduleRealInfo.getQdzName()).append("</FCZDMC>"); | |
| 483 | + // 起点站的参数 | |
| 484 | + otherMap.put("stationMark","B"); | |
| 485 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 486 | + sf.append("<FCZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,stationNumMap)).append("</FCZDXH>"); | |
| 487 | + sf.append("<FCZDBM>").append(scheduleRealInfo.getQdzCode()).append("</FCZDBM>"); | |
| 488 | + sf.append("<JHFCSJ>").append(scheduleRealInfo.getFcsj()).append("</JHFCSJ>"); | |
| 489 | + sf.append("<DFSJ>").append(scheduleRealInfo.getDfsj()).append("</DFSJ>"); | |
| 490 | + sf.append("<SJFCSJ>").append(scheduleRealInfo.getFcsjActual()).append("</SJFCSJ>"); | |
| 491 | + sf.append("<FCZDLX></FCZDLX>"); | |
| 492 | + sf.append("<DDZDMC>").append(scheduleRealInfo.getZdzName()).append("</DDZDMC>"); | |
| 493 | + // 终点站的参数 | |
| 494 | + otherMap.put("stationMark","E"); | |
| 495 | + paramMap = packageYgcStationNumParam(scheduleRealInfo,otherMap); | |
| 496 | + sf.append("<DDZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,stationNumMap)).append("</DDZDXH>"); | |
| 497 | + sf.append("<DDZDBM>").append(scheduleRealInfo.getZdzCode()).append("</DDZDBM>"); | |
| 498 | + sf.append("<JHDDSJ>").append(scheduleRealInfo.getZdsj()).append("</JHDDSJ>"); | |
| 499 | + sf.append("<SJDDSJ>").append(scheduleRealInfo.getZdsjActual()).append("</SJDDSJ>"); | |
| 500 | + sf.append("<DDZDLX></DDZDLX>"); | |
| 501 | + sf.append("<LDSCBZ>0</LDSCBZ>"); | |
| 502 | + sf.append("<DDBZ>").append("").append("</DDBZ>"); | |
| 503 | + sf.append("</LD>"); | |
| 504 | + } | |
| 505 | + } | |
| 506 | + sf.append("</LDList>"); | |
| 507 | + sf.append("</DLD>"); | |
| 508 | + } | |
| 509 | + if(counter % per == per - 1){ | |
| 510 | + sf.append("</DLDS>"); | |
| 511 | + // 去掉'号 | |
| 512 | + str = sf.toString().replace("'",""); | |
| 513 | + scount += invokeSetLD(str, counter); | |
| 514 | + counter = 0; | |
| 515 | + } | |
| 516 | + } | |
| 517 | + // 每per条线路上传后剩下的数据再上传 | |
| 518 | + if(counter > 0){ | |
| 519 | + sf.append("</DLDS>"); | |
| 520 | + // 去掉'号 | |
| 521 | + str = sf.toString().replace("'",""); | |
| 522 | + scount += invokeSetLD(str, counter); | |
| 523 | + } | |
| 524 | + } catch (Exception e) { | |
| 525 | + e.printStackTrace(); | |
| 526 | + logger.error("setLD:", e); | |
| 527 | + } finally { | |
| 528 | + try { | |
| 529 | + //发送邮件 | |
| 530 | + EmailBean mail = new EmailBean(); | |
| 531 | + mail.setSubject(InetAddress.getLocalHost().getHostAddress()+":路单日志数据"+date); | |
| 532 | + mail.setContent("总数:" + (listGroup == null ? 0 : listGroup.size()) + "<br/>成功数:" + scount + "<br/>跳过数:" + ccount + "<br/>耗时:" + (System.currentTimeMillis() - start)); | |
| 533 | + sendEmailController.sendMail(emailSendToAddress, mail); | |
| 534 | + logger.info("setLD-sendMail:邮件发送成功!"); | |
| 535 | + } catch (Exception e) { | |
| 536 | + e.printStackTrace(); | |
| 537 | + logger.error("setLD-sendMail:",e); | |
| 538 | + } | |
| 539 | + } | |
| 540 | + return "success"; | |
| 541 | + } | |
| 542 | + | |
| 543 | + /** | |
| 544 | + * 调用运管处电子路单接口,如果上传失败或有网络问题,最多执行10次 | |
| 545 | + * @param xml 拼接的xml字符串 | |
| 546 | + * @param counter 分组数 | |
| 547 | + * @return 成功返回counter 失败返回0 | |
| 548 | + */ | |
| 549 | + private int invokeSetLD(String xml, int counter) { | |
| 550 | + for (int i = 0;i < 10;i++) { | |
| 551 | + try { | |
| 552 | + Results results = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(xml)); | |
| 553 | + if (results.isSuccess()) { | |
| 554 | + logger.info("setLD: " + xml); | |
| 555 | + logger.info("setLD: 成功"); | |
| 556 | + return counter; | |
| 557 | + } else if (i == 9) { | |
| 558 | + logger.error("setLD: " + xml); | |
| 559 | + logger.error("setLD: 失败," + results.getMessage()); | |
| 560 | + } | |
| 561 | + Thread.sleep(2000); | |
| 562 | + } catch (Exception e) { | |
| 563 | + logger.error("运管处接口调用异常", e); | |
| 564 | + try { | |
| 565 | + Thread.sleep(2000); | |
| 566 | + } catch (InterruptedException ex) { | |
| 567 | + ex.printStackTrace(); | |
| 568 | + } | |
| 569 | + } | |
| 570 | + } | |
| 571 | + | |
| 572 | + return 0; | |
| 573 | + } | |
| 574 | + | |
| 575 | + /** | |
| 576 | + * 上传路单 xml来自文件 | |
| 577 | + * @return 上传成功标识 | |
| 578 | + */ | |
| 579 | + public String setLDFile(){ | |
| 580 | + String result = "failure"; | |
| 581 | + try { | |
| 582 | + String tmp = readXmlFromFile("E:/ld.txt"); | |
| 583 | + Results rss = ssop.setLD(userNameOther, passwordOther, StringEscapeUtils.unescapeHtml(tmp)); | |
| 584 | + if(rss.isSuccess()){ | |
| 585 | + result = "success"; | |
| 586 | + } | |
| 587 | + } catch (Exception e) { | |
| 588 | + logger.error("setLD:",e); | |
| 589 | + e.printStackTrace(); | |
| 590 | + }finally{ | |
| 591 | + | |
| 592 | + } | |
| 593 | + return result; | |
| 594 | + } | |
| 595 | + | |
| 596 | + /** | |
| 597 | + * 从文件中读取xml | |
| 598 | + * @param fileName 例:D:/test.txt | |
| 599 | + * @return | |
| 600 | + * @throws Exception | |
| 601 | + */ | |
| 602 | + private String readXmlFromFile(String fileName) throws Exception { | |
| 603 | + StringBuffer sf = new StringBuffer(""); | |
| 604 | + File file = new File(fileName); | |
| 605 | + InputStreamReader reader = new InputStreamReader(new FileInputStream(file),"GBK"); | |
| 606 | + BufferedReader bufferedReader = new BufferedReader(reader); | |
| 607 | + String lineTxt = ""; | |
| 608 | + while((lineTxt = bufferedReader.readLine()) != null){ | |
| 609 | + sf.append(lineTxt); | |
| 610 | + } | |
| 611 | + reader.close(); | |
| 612 | + return sf.toString().replaceAll("\t",""); | |
| 613 | + } | |
| 614 | + /** | |
| 615 | + * 上传里程油耗 | |
| 616 | + * @return 上传成功标识 | |
| 617 | + */ | |
| 618 | + public String setLCYH(){ | |
| 619 | + String result = "failure"; | |
| 620 | + // 取昨天 的日期 | |
| 621 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 622 | + StringBuffer sf = new StringBuffer(); | |
| 623 | + try { | |
| 624 | + sf.append("<LCYHS>"); | |
| 625 | + List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setLCYHGroup(date); | |
| 626 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 627 | + Map<String,Object> map = new HashMap<String,Object>(); | |
| 628 | + for(Map<String,Object> schRealInfo:listGroup){ | |
| 629 | + if(schRealInfo != null){ | |
| 630 | + map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | |
| 631 | + Optional<Cars> optionalCars = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | |
| 632 | + Cars car = optionalCars.isPresent() ? optionalCars.get() : null; | |
| 633 | + /** | |
| 634 | + * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | |
| 635 | + * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | |
| 636 | + */ | |
| 637 | + if(car == null){ | |
| 638 | + continue; | |
| 639 | + } | |
| 640 | + //计算总公里和空驶公里,营运公里=总公里-空驶公里 | |
| 641 | + double totalKilometers = 0,emptyKilometers =0; | |
| 642 | + sf.append("<LCYH>"); | |
| 643 | + sf.append("<RQ>"+date+"</RQ>"); | |
| 644 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | |
| 645 | + sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | |
| 646 | + if(list != null && list.size() > 0){ | |
| 647 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 648 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | |
| 649 | + .equals(scheduleRealInfo.getClZbh())){ | |
| 650 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 651 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 652 | + if(childTaskPlans.isEmpty()){ | |
| 653 | + if(scheduleRealInfo.getStatus() == 2){ | |
| 654 | + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 655 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 656 | + || scheduleRealInfo.getBcType().equals("venting")){ | |
| 657 | + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 658 | + } | |
| 659 | + } | |
| 660 | + }else{ | |
| 661 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 662 | + while(it.hasNext()){ | |
| 663 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 664 | + if(!childTaskPlan.isDestroy()){ | |
| 665 | + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 666 | + if(childTaskPlan.getMileageType().equals("empty")){ | |
| 667 | + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 668 | + } | |
| 669 | + } | |
| 670 | + } | |
| 671 | + } | |
| 672 | + } | |
| 673 | + } | |
| 674 | + } | |
| 675 | + sf.append("<ZLC>"+totalKilometers+"</ZLC>"); | |
| 676 | + sf.append("<YYLC>"+emptyKilometers+"</YYLC>"); | |
| 677 | + sf.append("<YH>"+""+"</YH>"); | |
| 678 | + sf.append("<JZYL>"+""+"</JZYL>"); | |
| 679 | + sf.append("<DH>"+""+"</DH>"); | |
| 680 | + sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | |
| 681 | + sf.append("<BBSCBZ>"+0+"</BBSCBZ>"); | |
| 682 | + sf.append("</LCYH>"); | |
| 683 | + } | |
| 684 | + } | |
| 685 | + sf.append("</LCYHS>"); | |
| 686 | + if(ssop.setLCYH(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 687 | + result = "success"; | |
| 688 | + } | |
| 689 | + } catch (Exception e) { | |
| 690 | + logger.error("setLCYH:",e); | |
| 691 | + e.printStackTrace(); | |
| 692 | + }finally{ | |
| 693 | + logger.info("setLCYH:"+sf.toString()); | |
| 694 | + logger.info("setLCYH:"+result); | |
| 695 | + } | |
| 696 | + return result; | |
| 697 | + } | |
| 698 | + | |
| 699 | + /** | |
| 700 | + * 上传线路调度日报 | |
| 701 | + * @return | |
| 702 | + */ | |
| 703 | + public String setDDRB(){ | |
| 704 | + String result = "failure"; | |
| 705 | + // 取昨天 的日期 | |
| 706 | + String date = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 707 | + StringBuffer sf = new StringBuffer(); | |
| 708 | + try { | |
| 709 | + sf.append("<DDRBS>"); | |
| 710 | + List<Map<String,Object>> listGroup = scheduleRealInfoRepository.setDDRBGroup(date); | |
| 711 | + List<ScheduleRealInfo> list = scheduleRealInfoRepository.findByDate(date); | |
| 712 | + for(Map<String,Object> schRealInfo:listGroup){ | |
| 713 | + if(schRealInfo != null){ | |
| 714 | + double jhlc = 0,zlc = 0,jhkslc = 0,sjkslc = 0; | |
| 715 | + int jhbc = 0,sjbc = 0,jhzgfbc = 0,sjzgfbc = 0,jhwgfbc = 0,sjwgfbc = 0; | |
| 716 | + sf.append("<DDRB>"); | |
| 717 | + sf.append("<RQ>"+date+"</RQ>"); | |
| 718 | + sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | |
| 719 | + for(ScheduleRealInfo scheduleRealInfo:list){ | |
| 720 | + if(scheduleRealInfo != null){ | |
| 721 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm())){ | |
| 722 | + //计划 | |
| 723 | + if(!scheduleRealInfo.isSflj()){ | |
| 724 | + jhlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 725 | + //计划空驶 | |
| 726 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")){ | |
| 727 | + jhkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 728 | + } | |
| 729 | + //计划早高峰,计划晚高峰 | |
| 730 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 731 | + jhzgfbc++; | |
| 732 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 733 | + jhwgfbc++; | |
| 734 | + } | |
| 735 | + } | |
| 736 | + jhbc++; | |
| 737 | + | |
| 738 | + //实际 | |
| 739 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | |
| 740 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | |
| 741 | + if(childTaskPlans.isEmpty()){ | |
| 742 | + if(scheduleRealInfo.getStatus() == 2){ | |
| 743 | + sjbc++; | |
| 744 | + zlc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | |
| 745 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | |
| 746 | + || scheduleRealInfo.getBcType().equals("venting")){ | |
| 747 | + sjkslc += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc();; | |
| 748 | + } | |
| 749 | + } | |
| 750 | + }else{ | |
| 751 | + sjbc++; | |
| 752 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | |
| 753 | + while(it.hasNext()){ | |
| 754 | + ChildTaskPlan childTaskPlan = it.next(); | |
| 755 | + if(!childTaskPlan.isDestroy()){ | |
| 756 | + zlc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | |
| 757 | + if(childTaskPlan.getMileageType().equals("empty")){ | |
| 758 | + sjkslc += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | |
| 759 | + } | |
| 760 | + } | |
| 761 | + } | |
| 762 | + } | |
| 763 | + //实际早高峰,计划晚高峰 | |
| 764 | + if(scheduleRealInfo.getFcsjActual() != null){ | |
| 765 | + if(TimeUtils.morningPeak(scheduleRealInfo.getFcsj())){ | |
| 766 | + sjzgfbc++; | |
| 767 | + } else if(TimeUtils.evenignPeak(scheduleRealInfo.getFcsj())){ | |
| 768 | + sjwgfbc++; | |
| 769 | + } | |
| 770 | + } | |
| 771 | + } | |
| 772 | + } | |
| 773 | + } | |
| 774 | + sf.append("<JHLC>"+format.format(jhlc)+"</JHLC>"); | |
| 775 | + sf.append("<SSLC>"+format.format((zlc-sjkslc))+"</SSLC>"); | |
| 776 | + sf.append("<JHKSLC>"+format.format(jhkslc)+"</JHKSLC>"); | |
| 777 | + sf.append("<SJKSLC>"+format.format(sjkslc)+"</SJKSLC>"); | |
| 778 | + sf.append("<JHBC>"+jhbc+"</JHBC>"); | |
| 779 | + sf.append("<SJBC>"+sjbc+"</SJBC>"); | |
| 780 | + sf.append("<JHZGFBC>"+jhzgfbc+"</JHZGFBC>"); | |
| 781 | + sf.append("<SJZGFBC>"+sjzgfbc+"</SJZGFBC>"); | |
| 782 | + sf.append("<JHWGFBC>"+jhwgfbc+"</JHWGFBC>"); | |
| 783 | + sf.append("<SJWGFBC>"+sjwgfbc+"</SJWGFBC>"); | |
| 784 | + sf.append("<UPDT>"+sdfnyrsfm.format(new Date())+"</UPDT>"); | |
| 785 | + sf.append("<RBSCBZ>"+0+"</RBSCBZ>"); | |
| 786 | + sf.append("</DDRB>"); | |
| 787 | + } | |
| 788 | + } | |
| 789 | + sf.append("</DDRBS>"); | |
| 790 | + if(ssop.setDDRB(userNameOther, passwordOther, sf.toString()).isSuccess()){ | |
| 791 | + result = "success"; | |
| 792 | + } | |
| 793 | + } catch (Exception e) { | |
| 794 | + logger.error("setDDRB:",e); | |
| 795 | + e.printStackTrace(); | |
| 796 | + }finally{ | |
| 797 | + logger.info("setDDRB:"+sf.toString()); | |
| 798 | + logger.info("setDDRB:"+result); | |
| 799 | + } | |
| 800 | + return result; | |
| 801 | + } | |
| 802 | + | |
| 803 | + /** | |
| 804 | + * 上传计划班次 指定日期 yyyy-MM-dd | |
| 805 | + * @param theDate | |
| 806 | + * @return | |
| 807 | + */ | |
| 808 | + public String setJHBC(String theDate){ | |
| 809 | + return uploadJHBC(theDate); | |
| 810 | + } | |
| 811 | + | |
| 812 | + /** | |
| 813 | + * 上传计划班次 | |
| 814 | + * @return | |
| 815 | + */ | |
| 816 | + public String setJHBC(){ | |
| 817 | + return uploadJHBC(null); | |
| 818 | + } | |
| 819 | + /** | |
| 820 | + * 上传线路计划班次表 | |
| 821 | + */ | |
| 822 | + | |
| 823 | + private String uploadJHBC(String theDate) { | |
| 824 | + String result = "failure"; | |
| 825 | + Line line; | |
| 826 | + StringBuffer sBuffer =new StringBuffer(); | |
| 827 | + try { | |
| 828 | + sBuffer.append("<JHBCs>"); | |
| 829 | + // 声明变量 | |
| 830 | + SchedulePlanInfo schedulePlanInfo; | |
| 831 | + String xlbm,zbh = ""; | |
| 832 | + Long lp = 0L; | |
| 833 | + // 取得计划班次时间 | |
| 834 | + String tomorrow = theDate == null ? sdfnyr.format(DateUtils.addDays(new Date(), +1)) : theDate; | |
| 835 | + // 查询所有班次 | |
| 836 | + List<SchedulePlanInfo> schedulePlanList = schedulePlanInfoRepository.findLineScheduleBc(tomorrow); | |
| 837 | + int j = 0; // 初始化标识 | |
| 838 | + if(schedulePlanList != null ){ | |
| 839 | + HashMap<String,String> paramMap; | |
| 840 | + HashMap<String,String> otherMap = new HashMap<String, String>(); | |
| 841 | + int size = schedulePlanList.size(); | |
| 842 | + for (int i = 0; i < size; i++) { | |
| 843 | + schedulePlanInfo = schedulePlanList.get(i); | |
| 844 | + xlbm = schedulePlanInfo.getXlBm(); | |
| 845 | + // 获取线路是否使用标识,如果未使用,则不查该线路数据 | |
| 846 | + line = lineRepository.findByLineCode(xlbm); | |
| 847 | + if(line.getInUse() == null || line.getInUse() == 0){ | |
| 848 | + continue; | |
| 849 | + } | |
| 850 | + if(++j == 1){// 第一次,则初始化值 | |
| 851 | + zbh = schedulePlanInfo.getClZbh(); | |
| 852 | + lp = schedulePlanInfo.getLp(); | |
| 853 | + // 拼装XML | |
| 854 | + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | |
| 855 | + } | |
| 856 | + // 比较是否为同一条线路同一辆车 | |
| 857 | + if(xlbm.equals(schedulePlanInfo.getXlBm()) | |
| 858 | + && zbh.equals(schedulePlanInfo.getClZbh()) | |
| 859 | + && lp == schedulePlanInfo.getLp()){ | |
| 860 | + if(schedulePlanInfo.getBcType().equals("in") || schedulePlanInfo.getBcType().equals("out")){ | |
| 861 | + continue; | |
| 862 | + } | |
| 863 | + sBuffer.append("<BC>"); | |
| 864 | + sBuffer.append("<SJGH>").append(schedulePlanInfo.getjGh()).append("</SJGH>"); | |
| 865 | + sBuffer.append("<SXX>").append(schedulePlanInfo.getXlDir()).append("</SXX>"); | |
| 866 | + sBuffer.append("<FCZDMC>").append(schedulePlanInfo.getQdzName()).append("</FCZDMC>"); | |
| 867 | + // 起点站的参数 | |
| 868 | + otherMap.put("stationMark","B"); | |
| 869 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 870 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</ZDXH>"); | |
| 871 | + sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | |
| 872 | + sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | |
| 873 | + // 起点站的参数 | |
| 874 | + otherMap.put("stationMark","E"); | |
| 875 | + paramMap = packageYgcStationNumParam(schedulePlanInfo,otherMap); | |
| 876 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,null)).append("</DDXH>"); | |
| 877 | + sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | |
| 878 | + .append("</JHDDSJ>"); | |
| 879 | + sBuffer.append("</BC>"); | |
| 880 | + if(i == size -1 ){ | |
| 881 | + sBuffer.append("</BCList>"); | |
| 882 | + sBuffer.append("</JHBC>"); | |
| 883 | + } | |
| 884 | + }else{ | |
| 885 | + zbh = schedulePlanInfo.getClZbh(); | |
| 886 | + lp = schedulePlanInfo.getLp(); | |
| 887 | + sBuffer.append("</BCList>"); | |
| 888 | + sBuffer.append("</JHBC>"); | |
| 889 | + // 拼装XML | |
| 890 | + assembleJHBC(sBuffer, schedulePlanInfo, xlbm, zbh, lp); | |
| 891 | + } | |
| 892 | + } | |
| 893 | + } | |
| 894 | + // 判断XML是否以</BCList>结尾,如果不是,则加上 | |
| 895 | + String regex = "^*</JHBC>$"; | |
| 896 | + Pattern p = Pattern.compile(regex); | |
| 897 | + Matcher m = p.matcher(sBuffer); | |
| 898 | + boolean isEndWithTrueFlag = false; | |
| 899 | + while (m.find()) { | |
| 900 | + isEndWithTrueFlag = true; | |
| 901 | + } | |
| 902 | + // 加上缺失的标签 | |
| 903 | + if(!isEndWithTrueFlag){ | |
| 904 | + sBuffer.append("</BCList>"); | |
| 905 | + sBuffer.append("</JHBC>"); | |
| 906 | + } | |
| 907 | + sBuffer.append("</JHBCs>"); | |
| 908 | + if(ssop.setJHBC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 909 | + result = "success"; | |
| 910 | + } | |
| 911 | + } catch (Exception e) { | |
| 912 | + logger.error("setJHBC:",e); | |
| 913 | + e.printStackTrace(); | |
| 914 | + }finally{ | |
| 915 | + logger.info("setJHBC:"+sBuffer.toString()); | |
| 916 | + logger.info("setJHBC:"+result); | |
| 917 | + } | |
| 918 | + return result; | |
| 919 | + } | |
| 920 | + | |
| 921 | + /** | |
| 922 | + * 上传线路班次时刻表数据 | |
| 923 | + */ | |
| 924 | + @Override | |
| 925 | + public String setSKB(String ids, String qyrqs) { | |
| 926 | + String result = "上传失败,"; | |
| 927 | + StringBuffer sBuffer = new StringBuffer("<SKBs>"); | |
| 928 | + DecimalFormat df = new DecimalFormat("######0.000"); | |
| 929 | + Map<String,String> lsStationCode2NameMap = null; | |
| 930 | + Map<String, Integer> lsStationName2YgcNumber = null; | |
| 931 | + try { | |
| 932 | + String[] idArray = ids.split(","), qyrqArray = qyrqs.split(","); | |
| 933 | + StringBuffer sBufferA ,sBufferB ,sBufferC ; | |
| 934 | + double zlc,yylc,singleLc,emptyLc;// 总里程、营运里程、单程、空放里程 | |
| 935 | + String bcType,sxx;// 班次类型、上下行 | |
| 936 | + // 上传的时刻表集合 | |
| 937 | + List<TTInfo> ttinfoList = new ArrayList<>(); | |
| 938 | + TTInfo ttInfo; | |
| 939 | + TTInfoDetail ttInfoDetail; | |
| 940 | + LineInformation lineInformation; | |
| 941 | + Iterator<TTInfoDetail> ttInfoDetailIterator; | |
| 942 | + HashMap<String,Object> param ; | |
| 943 | + HashMap<String,String> paramMap; | |
| 944 | + HashMap<String,String> otherMap = new HashMap<>(); | |
| 945 | + // 线路编码、周几执行、发车站点名称、发车站点序号、到达站点名称、到达站点序号 | |
| 946 | + String xlbm,zjzx,fczdmc,zdxh,ddzdmc,ddxh; | |
| 947 | + // 得到时刻表版本号 | |
| 948 | + int lineVersion; | |
| 949 | + long ttinfoId; | |
| 950 | + // 是否输出站点信息 | |
| 951 | + boolean isLogStation; | |
| 952 | + for (int i = 0; i < idArray.length; i++) { | |
| 953 | + ttinfoId = Long.valueOf(idArray[i]); | |
| 954 | + Optional<TTInfo> optionalTTInfo = ttInfoRepository.findById(ttinfoId); | |
| 955 | + ttInfo = optionalTTInfo.isPresent() ? optionalTTInfo.get() : null; | |
| 956 | + if(ttInfo == null) | |
| 957 | + continue; | |
| 958 | + ttinfoList.add(ttInfo); // 保存时刻表 | |
| 959 | + // 得到时刻表版本号 | |
| 960 | + lineVersion = ttInfo.getLineVersion(); | |
| 961 | + // 查询历史站点路由 | |
| 962 | + lsStationCode2NameMap = getLsStationCode(ttInfo.getXl().getLineCode(),lineVersion); | |
| 963 | + // 查询历史站点路由 | |
| 964 | + lsStationName2YgcNumber = getLsStationRoute(ttInfo.getXl().getLineCode(),lineVersion); | |
| 965 | + zlc = 0.0f; | |
| 966 | + yylc = 0.0f; | |
| 967 | + // 获得时刻表 | |
| 968 | + param = new HashMap(); | |
| 969 | + param.put("ttinfo.id_eq", ttInfo.getId()); | |
| 970 | + ttInfoDetailIterator = ttInfoDetailRepository.findAll(new CustomerSpecs<TTInfoDetail>(param), | |
| 971 | + new Sort(Direction.ASC, "xlDir")).iterator(); | |
| 972 | + // 获得lineInformation | |
| 973 | + param = new HashMap(); | |
| 974 | + param.put("line.id_eq", ttInfo.getXl().getId()); | |
| 975 | + Optional<LineInformation> optionalLineInformation = lineInformationRepository.findOne(new CustomerSpecs<LineInformation>(param)); | |
| 976 | + lineInformation = optionalLineInformation.isPresent() ? optionalLineInformation.get() : null; | |
| 977 | + // 初始化 | |
| 978 | + isLogStation = true; | |
| 979 | + if(ttInfoDetailIterator.hasNext()){ | |
| 980 | + // 得到线路信息 | |
| 981 | + Optional<Line> optionalLine = lineRepository.findById(ttInfo.getXl().getId()); | |
| 982 | + Line line = optionalLine.isPresent() ? optionalLine.get() : null; | |
| 983 | + if(line == null){ | |
| 984 | + result += "未找到相应的线路信息,请设置线路信息后再上传"; | |
| 985 | + return result; | |
| 986 | + } | |
| 987 | + // 得到上海市线路编码 | |
| 988 | + xlbm = line.getShanghaiLinecode(); | |
| 989 | + if("".equals(xlbm) || "null".equals(xlbm)){ | |
| 990 | + result += "线路编码为空,请设置线路编码后再上传"; | |
| 991 | + return result; | |
| 992 | + } | |
| 993 | + // 拿到周几执行 | |
| 994 | + zjzx = changeRuleDay(ttInfo.getRule_days()); | |
| 995 | + if("".equals(zjzx) || "null".equals(zjzx)){ | |
| 996 | + result += "时刻表执行时间为空,请设置执行时间后再上传"; | |
| 997 | + return result; | |
| 998 | + } | |
| 999 | + sBuffer.append("<SKB>"); | |
| 1000 | + sBuffer.append("<XLBM>").append(xlbm).append("</XLBM>"); | |
| 1001 | + sBufferB = new StringBuffer(); | |
| 1002 | + sBufferC = new StringBuffer(); | |
| 1003 | + sBufferB.append("<KSRQ>").append(qyrqArray[i]).append("</KSRQ>"); | |
| 1004 | + // 结束日期暂时不要,节假日的班次表才需要,如春节的班次表 | |
| 1005 | + sBufferB.append("<JSRQ>").append("").append("</JSRQ>"); | |
| 1006 | + sBufferB.append("<ZJZX>").append(zjzx).append("</ZJZX>"); | |
| 1007 | + sBufferB.append("<TBYY>").append("").append("</TBYY>"); | |
| 1008 | + sBufferB.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1009 | + sBufferB.append("<BCList>"); | |
| 1010 | + while (ttInfoDetailIterator.hasNext()) { | |
| 1011 | + ttInfoDetail = ttInfoDetailIterator.next(); | |
| 1012 | + bcType = ttInfoDetail.getBcType(); | |
| 1013 | + sxx = ttInfoDetail.getXlDir(); | |
| 1014 | + // 进出场班次的里程,加入总里程 | |
| 1015 | + if(bcType.equals("in") || bcType.equals("out")){ | |
| 1016 | + // 进出班次的计划里程,算空驶里程 | |
| 1017 | + emptyLc = ttInfoDetail.getJhlc(); | |
| 1018 | + // 总里程需要加上空驶里程 | |
| 1019 | + zlc += emptyLc; | |
| 1020 | + continue; | |
| 1021 | + } | |
| 1022 | + // 不是正常班次,不传到运管处 | |
| 1023 | + if(!bcType.equals("normal")){ | |
| 1024 | + continue; | |
| 1025 | + } | |
| 1026 | + // 如果发车时间格式错误,忽略此条 | |
| 1027 | + if(changeTimeFormat(ttInfoDetail) == null){ | |
| 1028 | + continue; | |
| 1029 | + } | |
| 1030 | + // 发生站点名称 | |
| 1031 | + fczdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getQdzCode()); | |
| 1032 | + if("".equals(fczdmc) || "null".equals(fczdmc)){ | |
| 1033 | + result += "发车站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1034 | + return result; | |
| 1035 | + } | |
| 1036 | + sBufferC.append("<BC>"); | |
| 1037 | + sBufferC.append("<LPBH>").append(ttInfoDetail.getLp().getLpNo()).append("</LPBH>"); | |
| 1038 | + sBufferC.append("<SXX>").append(sxx).append("</SXX>"); | |
| 1039 | + sBufferC.append("<FCZDMC>").append(fczdmc).append("</FCZDMC>"); | |
| 1040 | + // 起点站的参数 | |
| 1041 | + otherMap.put("stationMark","B"); | |
| 1042 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 1043 | + if(isLogStation){// 输出起点站信息 | |
| 1044 | + logger.info("setSKB:"+"起点站信息:"+paramMap); | |
| 1045 | + } | |
| 1046 | + // 发车站点序号 | |
| 1047 | + zdxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | |
| 1048 | + if("".equals(zdxh) || "null".equals(zdxh) || "0".equals(zdxh)){ | |
| 1049 | + result += "发车站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1050 | + return result; | |
| 1051 | + } | |
| 1052 | + // 到达站点名称 | |
| 1053 | + ddzdmc = lsStationCode2NameMap.get(ttInfoDetail.getXl().getLineCode()+"_"+ttInfoDetail.getXlDir()+"_"+ttInfoDetail.getZdzCode()); | |
| 1054 | + if("".equals(ddzdmc) || "null".equals(ddzdmc)){ | |
| 1055 | + result += "到达站点名称为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1056 | + return result; | |
| 1057 | + } | |
| 1058 | + sBufferC.append("<ZDXH>").append(zdxh).append("</ZDXH>"); | |
| 1059 | + sBufferC.append("<JHFCSJ>").append(changeTimeFormat(ttInfoDetail)).append("</JHFCSJ>"); | |
| 1060 | + sBufferC.append("<DDZDMC>").append(ddzdmc).append("</DDZDMC>"); | |
| 1061 | + // 终点站的参数 | |
| 1062 | + otherMap.put("stationMark","E"); | |
| 1063 | + paramMap = packageYgcStationNumParam(ttInfoDetail,otherMap); | |
| 1064 | + if(isLogStation){// 输出终点站信息 | |
| 1065 | + logger.info("setSKB:"+"终点站信息:"+paramMap); | |
| 1066 | + } | |
| 1067 | + // 到达站点序号 | |
| 1068 | + ddxh = String.valueOf(getYgcStationNumByLineCodeAndDirectionAndStationName(paramMap,lsStationName2YgcNumber)); | |
| 1069 | + if("".equals(ddxh) || "null".equals(ddxh) || "0".equals(ddxh)){ | |
| 1070 | + result += "到达站点序号为空,请根据时刻表当前的版本号设置好历史站点路由再上传"; | |
| 1071 | + return result; | |
| 1072 | + } | |
| 1073 | + isLogStation = false; // 一条线路只输出一次,后面的不输出了 | |
| 1074 | + sBufferC.append("<DDXH>").append(ddxh).append("</DDXH>"); | |
| 1075 | + sBufferC.append("<JHDDSJ>").append(calcDdsj(ttInfoDetail.getFcsj(),ttInfoDetail.getBcsj())).append("</JHDDSJ>"); | |
| 1076 | + sBufferC.append("</BC>"); | |
| 1077 | + // 0:上行;1:下行 | |
| 1078 | + if("0".equals(sxx)){ | |
| 1079 | + singleLc = lineInformation.getUpMileage(); | |
| 1080 | + }else{ | |
| 1081 | + singleLc = lineInformation.getDownMileage(); | |
| 1082 | + } | |
| 1083 | + zlc += singleLc ; | |
| 1084 | + yylc += singleLc; | |
| 1085 | + } | |
| 1086 | + sBufferC.append("</BCList>"); | |
| 1087 | + sBufferC.append("</SKB>"); | |
| 1088 | + sBufferA = new StringBuffer(); | |
| 1089 | + sBufferA.append("<JHZLC>").append(df.format(zlc)).append("</JHZLC>"); | |
| 1090 | + sBufferA.append("<JHYYLC>").append(df.format(yylc)).append("</JHYYLC>"); | |
| 1091 | + sBuffer.append(sBufferA).append(sBufferB).append(sBufferC); | |
| 1092 | + } | |
| 1093 | + logger.info("setSKB:"+"ttinfoId:"+ttinfoId+";当前站点版本号:"+lineVersion+";查询历史站点路由:"+lsStationCode2NameMap+";查询历史站点编号:"+lsStationName2YgcNumber); | |
| 1094 | + } | |
| 1095 | + sBuffer.append("</SKBs>"); | |
| 1096 | + String state;// 是否上传成功 | |
| 1097 | + if(ssop.setSKB(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1098 | + result = "上传成功"; | |
| 1099 | + state = "1"; | |
| 1100 | + }else{// 上传失败 | |
| 1101 | + result = "上传失败"; | |
| 1102 | + state = "0"; | |
| 1103 | + } | |
| 1104 | + // 保存运管处上传记录 | |
| 1105 | + saveYgcUploadLog(ttinfoList,sBuffer.toString(),TrafficManageServiceImpl.UPLOAD_TYPE_SKB,state); | |
| 1106 | + } catch (Exception e) { | |
| 1107 | + logger.error("setSKB:", e); | |
| 1108 | + e.printStackTrace(); | |
| 1109 | + }finally{ | |
| 1110 | + logger.info("setSKB:"+sBuffer.toString()); | |
| 1111 | + logger.info("setSKB:"+result); | |
| 1112 | + } | |
| 1113 | + return result; | |
| 1114 | + } | |
| 1115 | + | |
| 1116 | + /** | |
| 1117 | + * 保存上传运管处的日志 | |
| 1118 | + * @param obj 参数 | |
| 1119 | + * @param type 日志类型 | |
| 1120 | + * @param xml 上传参数 | |
| 1121 | + */ | |
| 1122 | + private void saveYgcUploadLog(Object obj,String xml,String type,String state){ | |
| 1123 | + SKBUploadLogger skbUploadLogger = new SKBUploadLogger(); | |
| 1124 | + SysUser user; | |
| 1125 | + // 如果不是人为上传,SysUser则为空,设置上传人员为管理员 | |
| 1126 | + if(SecurityContextHolder.getContext() == null || SecurityContextHolder.getContext().getAuthentication() == null){ | |
| 1127 | + user = new SysUser(); | |
| 1128 | + user.setId(1); | |
| 1129 | + }else{// 获取上传人员 | |
| 1130 | + user = SecurityUtils.getCurrentUser(); | |
| 1131 | + } | |
| 1132 | + // 最大的字符长度 | |
| 1133 | + int maxLength = 60000; | |
| 1134 | + int cutLength = 50000;// 需要截取的字符长度 | |
| 1135 | + String xml_sub = null; | |
| 1136 | + skbUploadLogger.setType(type);// 设置类型 | |
| 1137 | + // 判断xml是否超长,如果超长,则截取 | |
| 1138 | + if(xml != null && xml.length() > maxLength){ | |
| 1139 | + int xmlLength = xml.length(); | |
| 1140 | + int cutCount = xmlLength / cutLength + (xmlLength % cutLength > 0 ? 1 : 0); | |
| 1141 | + if(cutCount > 2){ | |
| 1142 | + xml = "由于上传参数内容超长,请查看服务器的系统日志"; | |
| 1143 | + }else if(cutCount == 2){ | |
| 1144 | + xml_sub =xml.substring(cutLength); | |
| 1145 | + xml = xml.substring(0,cutLength); | |
| 1146 | + }else{ | |
| 1147 | + // 不做处理 | |
| 1148 | + } | |
| 1149 | + } | |
| 1150 | +// skbUploadLogger.setUploadXml(xml);// 上传的参数 | |
| 1151 | +// skbUploadLogger.setUploadXmlSub(xml_sub); | |
| 1152 | + skbUploadLogger.setState(state);// 状态:是否成功 | |
| 1153 | + skbUploadLogger.setUser(user); | |
| 1154 | + // 时刻表 | |
| 1155 | + if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_SKB)){ | |
| 1156 | + List<TTInfo> ttInfoList = (List<TTInfo>)obj; | |
| 1157 | + String name = ""; | |
| 1158 | + Line line = null; | |
| 1159 | + for(TTInfo ttInfo : ttInfoList){ | |
| 1160 | + name += ttInfo.getName() + " "; | |
| 1161 | + line = ttInfo.getXl(); | |
| 1162 | + } | |
| 1163 | + skbUploadLogger.setLine(line); | |
| 1164 | + skbUploadLogger.setUser(user); | |
| 1165 | + skbUploadLogger.setName(name); | |
| 1166 | + skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1167 | + }else{ | |
| 1168 | + if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_XL)){ | |
| 1169 | + Line line = (Line) obj; | |
| 1170 | + String name = line.getName() + "线路停靠站上传"; | |
| 1171 | + skbUploadLogger.setLine(line); | |
| 1172 | + skbUploadLogger.setName(name); | |
| 1173 | + skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1174 | + }else if(type.equals(TrafficManageServiceImpl.UPLOAD_TYPE_LD)){ | |
| 1175 | + Map<String ,Line> logLineMap = (Map<String ,Line> )obj; | |
| 1176 | + for (String key : logLineMap.keySet()) { | |
| 1177 | + Line line = logLineMap.get(key); | |
| 1178 | + String name = line.getName() + "路单上传"; | |
| 1179 | + skbUploadLogger = new SKBUploadLogger(); | |
| 1180 | + skbUploadLogger.setType(type);// 设置类型 | |
| 1181 | +// skbUploadLogger.setUploadXml(xml);// 上传的参数 | |
| 1182 | +// skbUploadLogger.setUploadXmlSub(xml_sub); | |
| 1183 | + skbUploadLogger.setState(state);// 状态:是否成功 | |
| 1184 | + skbUploadLogger.setUser(user); | |
| 1185 | + skbUploadLogger.setLine(line); | |
| 1186 | + skbUploadLogger.setName(name); | |
| 1187 | +// skbUploadLoggerRepository.save(skbUploadLogger); | |
| 1188 | + } | |
| 1189 | + } | |
| 1190 | + } | |
| 1191 | + } | |
| 1192 | + /** | |
| 1193 | + * 上传线路人员车辆配置信息 | |
| 1194 | + */ | |
| 1195 | + @Override | |
| 1196 | + public String setXLPC() { | |
| 1197 | + String result = "failure"; | |
| 1198 | + StringBuffer sBuffer =new StringBuffer(); | |
| 1199 | + try { | |
| 1200 | + sBuffer.append("<XLPCs>"); | |
| 1201 | + // 声明变量 | |
| 1202 | + Line line = null; | |
| 1203 | + Cars cars = null; | |
| 1204 | + List<Personnel> personnelList = null; | |
| 1205 | + List<Cars> carsList = null; | |
| 1206 | + int totalPersonnel,totalCar ;// 人员数量。车辆数量 | |
| 1207 | + // 查询所有线路 | |
| 1208 | + Iterator<Line> lineIterator = lineRepository.findAll().iterator(); | |
| 1209 | + // 循环查找线路下的信息 | |
| 1210 | + while(lineIterator.hasNext()){ | |
| 1211 | + line = lineIterator.next(); | |
| 1212 | + sBuffer.append("<XLPC>"); | |
| 1213 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 1214 | + // 查询驾驶员数量 | |
| 1215 | + personnelList = personnelRepository.findJsysByLineId(line.getId()); | |
| 1216 | + totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 1217 | + sBuffer.append("<SJRS>").append(totalPersonnel).append("</SJRS>"); | |
| 1218 | + // 查询售票员人员数量 | |
| 1219 | + personnelList = personnelRepository.findSpysByLineId(line.getId()); | |
| 1220 | + totalPersonnel = personnelList != null ? personnelList.size():0; | |
| 1221 | + sBuffer.append("<SPYRS>").append(totalPersonnel).append("</SPYRS>"); | |
| 1222 | + // 查询车辆 | |
| 1223 | + carsList = carsRepository.findCarsByLineId(line.getId()); | |
| 1224 | + totalCar = carsList != null ? carsList.size():0; | |
| 1225 | + sBuffer.append("<PCSL>").append(totalCar).append("</PCSL>"); | |
| 1226 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1227 | + int carsNum = 0; | |
| 1228 | + // 取车牌号 | |
| 1229 | + if(carsList != null){ | |
| 1230 | + carsNum = carsList.size(); | |
| 1231 | + sBuffer.append("<CPHList>"); | |
| 1232 | + for (int i = 0; i < carsNum; i++) { | |
| 1233 | + cars = carsList.get(i); | |
| 1234 | + sBuffer.append("<CPH>").append("沪").append(cars.getCarCode()).append("</CPH>"); | |
| 1235 | + } | |
| 1236 | + sBuffer.append("</CPHList>"); | |
| 1237 | + } | |
| 1238 | + sBuffer.append("</XLPC>"); | |
| 1239 | + } | |
| 1240 | + sBuffer.append("</XLPCs>"); | |
| 1241 | + if(ssop.setXLPC(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1242 | + result = "success"; | |
| 1243 | + } | |
| 1244 | + } catch (Exception e) { | |
| 1245 | + logger.error("setXLPC:",e); | |
| 1246 | + e.printStackTrace(); | |
| 1247 | + }finally{ | |
| 1248 | + logger.info("setXLPC:"+sBuffer.toString()); | |
| 1249 | + logger.info("setXLPC:"+result); | |
| 1250 | + } | |
| 1251 | + return result; | |
| 1252 | + } | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + /** | |
| 1256 | + * 上传超速数据 | |
| 1257 | + */ | |
| 1258 | + @Override | |
| 1259 | + public String setCS() { | |
| 1260 | + String result = "failure"; | |
| 1261 | + StringBuffer sBuffer =new StringBuffer(); | |
| 1262 | + sBuffer.append("<CSs>"); | |
| 1263 | + String sql = "SELECT * FROM bsth_c_speeding where DATE_FORMAT(create_date,'%Y-%m-%d') = ? order by create_date "; | |
| 1264 | + Connection conn = null; | |
| 1265 | + PreparedStatement ps = null; | |
| 1266 | + ResultSet rs = null; | |
| 1267 | + // 取昨天 的日期 | |
| 1268 | + String yesterday = sdfnyr.format(DateUtils.addDays(new Date(), -1)); | |
| 1269 | + try { | |
| 1270 | + conn = DBUtils_MS.getConnection(); | |
| 1271 | + ps = conn.prepareStatement(sql); | |
| 1272 | + ps.setString(1, yesterday); | |
| 1273 | + rs = ps.executeQuery(); | |
| 1274 | + Float lon, lat; | |
| 1275 | + String kssk; | |
| 1276 | + String speed; | |
| 1277 | + while (rs.next()) { | |
| 1278 | + kssk = sdfnyrsfm.format(rs.getLong("TIMESTAMP")); | |
| 1279 | + speed = rs.getString("SPEED"); | |
| 1280 | + // 经纬度 | |
| 1281 | + lon = rs.getFloat("LON"); | |
| 1282 | + lat = rs.getFloat("LAT"); | |
| 1283 | + sBuffer.append("<CS>"); | |
| 1284 | + sBuffer.append("<RQ>").append(sdfnyr.format(rs.getDate("CREATE_DATE"))).append("</RQ>"); | |
| 1285 | + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(rs.getString("LINE"))).append("</XLBM>");//////// | |
| 1286 | + sBuffer.append("<CPH>").append(rs.getString("VEHICLE")).append("</CPH>"); | |
| 1287 | + sBuffer.append("<KSSK>").append(kssk).append("</KSSK>"); | |
| 1288 | + sBuffer.append("<KSDDJD>").append(lon).append("</KSDDJD>"); | |
| 1289 | + sBuffer.append("<KSDDWD>").append(lat).append("</KSDDWD>"); | |
| 1290 | + sBuffer.append("<KSLD>").append("").append("</KSLD>");//********************** | |
| 1291 | + sBuffer.append("<JSSK>").append(kssk).append("</JSSK>"); | |
| 1292 | + sBuffer.append("<JSDDJD>").append(lon).append("</JSDDJD>"); | |
| 1293 | + sBuffer.append("<JSDDWD>").append(lat).append("</JSDDWD>"); | |
| 1294 | + sBuffer.append("<JSLD>").append("").append("</JSLD>");//********************** | |
| 1295 | + sBuffer.append("<PJSD>").append(speed).append("</PJSD>"); | |
| 1296 | + sBuffer.append("<ZGSS>").append(speed).append("</ZGSS>"); | |
| 1297 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1298 | + sBuffer.append("</CS>"); | |
| 1299 | + } | |
| 1300 | + sBuffer.append("</CSs>"); | |
| 1301 | + if(ssop.setCS(userNameOther, passwordOther, sBuffer.toString()).isSuccess()){ | |
| 1302 | + result = "success"; | |
| 1303 | + } | |
| 1304 | + } catch (Exception e) { | |
| 1305 | + logger.error("setCS:",e); | |
| 1306 | + e.printStackTrace(); | |
| 1307 | + } finally { | |
| 1308 | + logger.info("setCS:"+sBuffer.toString()); | |
| 1309 | + logger.info("setCS:"+result); | |
| 1310 | + DBUtils_MS.close(rs, ps, conn); | |
| 1311 | + } | |
| 1312 | + return result; | |
| 1313 | + } | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + /** | |
| 1317 | + * 下载全量的公交基础数据 | |
| 1318 | + */ | |
| 1319 | + public String getDownLoadAllDataFile() { | |
| 1320 | + String result = "failure"; | |
| 1321 | + try { | |
| 1322 | + try { | |
| 1323 | + if(ygcBasicDataService.download("admin","000000","abc.zip")){ | |
| 1324 | + result = "success"; | |
| 1325 | + } | |
| 1326 | + } catch (Exception e) { | |
| 1327 | + e.printStackTrace(); | |
| 1328 | + } | |
| 1329 | + } catch (Exception e) { | |
| 1330 | + e.printStackTrace(); | |
| 1331 | + } | |
| 1332 | + | |
| 1333 | + return result; | |
| 1334 | + } | |
| 1335 | + | |
| 1336 | + /** | |
| 1337 | + * 下载增量的公交基础数据 | |
| 1338 | + */ | |
| 1339 | + public String getDownLoadIncreaseDataFile() { | |
| 1340 | + String result = "success"; | |
| 1341 | + try { | |
| 1342 | + //System.out.println(portType.downloadIncreaseDataFile(args0, args1, args2)); | |
| 1343 | + } catch (Exception e) { | |
| 1344 | + e.printStackTrace(); | |
| 1345 | + } | |
| 1346 | + | |
| 1347 | + return result; | |
| 1348 | + } | |
| 1349 | + | |
| 1350 | + /** | |
| 1351 | + * 指定线路查询方式公交基础数据下载 | |
| 1352 | + */ | |
| 1353 | + public String getDownLoadWarrantsBusLineStation() { | |
| 1354 | + String result = "success"; | |
| 1355 | + try { | |
| 1356 | + | |
| 1357 | + //portType.setXL(userNameXl, passwordXl, sBuffer.toString()); | |
| 1358 | + } catch (Exception e) { | |
| 1359 | + e.printStackTrace(); | |
| 1360 | + } | |
| 1361 | + | |
| 1362 | + return result; | |
| 1363 | + } | |
| 1364 | + | |
| 1365 | + /** | |
| 1366 | + * 计算结束时间 | |
| 1367 | + * @param fcsj 发车时间 | |
| 1368 | + * @param bcsj 班次历时 | |
| 1369 | + * @return | |
| 1370 | + */ | |
| 1371 | + private String calcDdsj(String fcsj,Integer bcsj){ | |
| 1372 | + String result = ""; | |
| 1373 | + if(fcsj.indexOf(":") != -1){ | |
| 1374 | + if(bcsj == null){ | |
| 1375 | + return fcsj; | |
| 1376 | + } | |
| 1377 | + // 时和分隔开 | |
| 1378 | + String[] fcsjArray = fcsj.split(":"); | |
| 1379 | + // 分和历时时间相加 | |
| 1380 | + Integer fullTime = Integer.valueOf(fcsjArray[1])+ bcsj; | |
| 1381 | + int hour,min,sumHour; | |
| 1382 | + hour = fullTime / 60; | |
| 1383 | + min = fullTime % 60; | |
| 1384 | + sumHour = Integer.valueOf(fcsjArray[0])+hour; | |
| 1385 | + if(sumHour >= 24){ | |
| 1386 | + result = String.format("%02d",sumHour - 24); | |
| 1387 | + }else{ | |
| 1388 | + result = String.format("%02d",sumHour);; | |
| 1389 | + } | |
| 1390 | + result +=":"+String.format("%02d", min); | |
| 1391 | + }else{ | |
| 1392 | + result = fcsj; | |
| 1393 | + } | |
| 1394 | + return result; | |
| 1395 | + } | |
| 1396 | + | |
| 1397 | + /** | |
| 1398 | + * 改变时间格式 | |
| 1399 | + * @param ttInfoDetail 时刻表详细 | |
| 1400 | + * @return xx:yy | |
| 1401 | + */ | |
| 1402 | + private String changeTimeFormat(TTInfoDetail ttInfoDetail){ | |
| 1403 | + String result = "00:00"; | |
| 1404 | + String fcsj = ttInfoDetail.getFcsj(); | |
| 1405 | + if(fcsj.indexOf(":") != -1){ | |
| 1406 | + // 时和分隔开 | |
| 1407 | + String[] fcsjArray = fcsj.split(":"); | |
| 1408 | + result = String.format("%02d", Integer.valueOf(fcsjArray[0]))+":"; | |
| 1409 | + result +=String.format("%02d", Integer.valueOf(fcsjArray[1])); | |
| 1410 | + }else{ | |
| 1411 | + result = null; | |
| 1412 | + logger.info("setSKB:发车时间错误:ttInfoDetail.id="+ttInfoDetail.getId()); | |
| 1413 | + } | |
| 1414 | + return result; | |
| 1415 | + } | |
| 1416 | + | |
| 1417 | + /** | |
| 1418 | + * 拼装线路计划班次表的XML | |
| 1419 | + * @param sBuffer | |
| 1420 | + * @param schedulePlanInfo | |
| 1421 | + * @param xlbm | |
| 1422 | + * @param zbh | |
| 1423 | + * @param lp | |
| 1424 | + */ | |
| 1425 | + private void assembleJHBC(StringBuffer sBuffer,SchedulePlanInfo schedulePlanInfo,String xlbm,String zbh,Long lp){ | |
| 1426 | + sBuffer.append("<JHBC>"); | |
| 1427 | + sBuffer.append("<RQ>").append(sdfnyr.format(schedulePlanInfo.getScheduleDate())).append("</RQ>"); | |
| 1428 | + sBuffer.append("<XLBM>").append(BasicData.lineCode2ShangHaiCodeMap.get(xlbm)).append("</XLBM>"); | |
| 1429 | + sBuffer.append("<CPH>").append("沪"+zbh).append("</CPH>"); | |
| 1430 | + sBuffer.append("<LPBH>").append(lp).append("</LPBH>"); | |
| 1431 | + sBuffer.append("<UPDT>").append(sdfnyrsfm.format(new Date())).append("</UPDT>"); | |
| 1432 | + sBuffer.append("<BCList>"); | |
| 1433 | + } | |
| 1434 | + /** | |
| 1435 | + * 转换排班规则 | |
| 1436 | + * @param ruleDay | |
| 1437 | + * @return | |
| 1438 | + */ | |
| 1439 | + private String changeRuleDay(String ruleDay){ | |
| 1440 | + String result = ""; | |
| 1441 | + int flag ; | |
| 1442 | + String[] ruleDayArray = ruleDay.split(","); | |
| 1443 | + for (int i = 0; i < ruleDayArray.length; i++) { | |
| 1444 | + if(ruleDayArray[i].equals("1")){ | |
| 1445 | + flag = i+1; | |
| 1446 | + }else{ | |
| 1447 | + flag = 0; | |
| 1448 | + } | |
| 1449 | + if(flag > 0){ | |
| 1450 | + result += flag + ","; | |
| 1451 | + } | |
| 1452 | + } | |
| 1453 | + // 去掉最后一个字符 | |
| 1454 | + if(StringUtils.endsWith(result,",")){ | |
| 1455 | + result = StringUtils.removeEnd(result,","); | |
| 1456 | + } | |
| 1457 | + return result; | |
| 1458 | + } | |
| 1459 | + /** | |
| 1460 | + * 设置统一的公司名称 | |
| 1461 | + * @param company | |
| 1462 | + */ | |
| 1463 | + private void setCompanyName(String company){ | |
| 1464 | + if(company.equals("闵行公司")){ | |
| 1465 | + company = "浦东闵行公交公司"; | |
| 1466 | + }else if(company.equals("杨高公司")){ | |
| 1467 | + company = "浦东杨高公交公司"; | |
| 1468 | + }else if(company.equals("上南公司")){ | |
| 1469 | + company = "浦东上南公交公司"; | |
| 1470 | + }else if(company.equals("金高公司")){ | |
| 1471 | + company = "浦东金高公交公司"; | |
| 1472 | + }else if(company.equals("南汇公司")){ | |
| 1473 | + company = "浦东南汇公交公司"; | |
| 1474 | + }else if(company.equals("青浦公交")){ | |
| 1475 | + company = "浦东青浦公交公司"; | |
| 1476 | + } | |
| 1477 | + } | |
| 1478 | + /** | |
| 1479 | + * @param stationsList 站点路由集 | |
| 1480 | + * @param sBuffer sBuffer | |
| 1481 | + * @param startId 站点序号起始ID | |
| 1482 | + * | |
| 1483 | + * @return 站点序号累加后的ID | |
| 1484 | + */ | |
| 1485 | + private int packagStationXml(List<StationRoute> stationsList,StringBuffer sBuffer,int startId,Map<String, Integer> stationNumMap){ | |
| 1486 | + int size = stationsList.size(); | |
| 1487 | + StationRoute srRoute; | |
| 1488 | + HashMap<String,String> paraMap; | |
| 1489 | + String zdlx ;// 站点类型:0:起点站、1:终点站、2:中途站 | |
| 1490 | + for (int i = 0; i < size; i++) { | |
| 1491 | + srRoute = stationsList.get(i); | |
| 1492 | + zdlx = srRoute.getStationMark(); | |
| 1493 | + if(zdlx.equals("B")){ | |
| 1494 | + zdlx = "0"; | |
| 1495 | + }else if(zdlx.equals("E")){ | |
| 1496 | + zdlx = "1"; | |
| 1497 | + }else{ | |
| 1498 | + zdlx = "2"; | |
| 1499 | + } | |
| 1500 | + paraMap = packageYgcStationNumParam(srRoute,null); | |
| 1501 | + sBuffer.append("<Station>"); | |
| 1502 | + sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName(paraMap,stationNumMap)).append("</ZDXH>"); | |
| 1503 | + sBuffer.append("<SXX>").append(srRoute.getDirections()).append("</SXX>"); | |
| 1504 | + sBuffer.append("<ZDMC>").append(srRoute.getStationName()).append("</ZDMC>"); | |
| 1505 | + sBuffer.append("<ZDBM>").append(srRoute.getStationCode()).append("</ZDBM>"); | |
| 1506 | + sBuffer.append("<ZDJD>").append(srRoute.getStation().getgLonx()).append("</ZDJD>"); | |
| 1507 | + sBuffer.append("<ZDWD>").append(srRoute.getStation().getgLaty()).append("</ZDWD>"); | |
| 1508 | + sBuffer.append("<ZZ>").append(srRoute.getStation().getAddr() == null ? "" : srRoute.getStation().getAddr()).append("</ZZ>"); | |
| 1509 | + sBuffer.append("<ZDLX>").append(zdlx).append("</ZDLX>"); | |
| 1510 | + sBuffer.append("<ZJLC>").append(srRoute.getDistances()).append("</ZJLC>"); | |
| 1511 | + sBuffer.append("</Station>"); | |
| 1512 | + startId++; | |
| 1513 | + } | |
| 1514 | + return startId; | |
| 1515 | + } | |
| 1516 | + | |
| 1517 | + /** | |
| 1518 | + * @param pointList 站点点位集 | |
| 1519 | + * @param sBuffer sBuffer | |
| 1520 | + * @param startId 站点序号起始ID | |
| 1521 | + * | |
| 1522 | + * @return 站点序号累加后的ID | |
| 1523 | + */ | |
| 1524 | + private int packagStationPointXml(List<Object[]> pointList,StringBuffer sBuffer,int startId){ | |
| 1525 | + int size = pointList.size(); | |
| 1526 | + Object[] objs; | |
| 1527 | + String bsection,dir,section; | |
| 1528 | + String[] sections ; | |
| 1529 | + for (int i = 0; i < size; i++) { | |
| 1530 | + objs = pointList.get(i); | |
| 1531 | + bsection = objs[0]+""; | |
| 1532 | + dir = objs[1]+""; | |
| 1533 | + // 取括号内的内容 | |
| 1534 | + Pattern pattern = Pattern.compile("(?<=\\()(.+?)(?=\\))"); | |
| 1535 | + Matcher matcher = pattern.matcher(bsection); | |
| 1536 | + if(matcher.find()){ | |
| 1537 | + sections = matcher.group().split(","); | |
| 1538 | + for (int j = 0 ; j < sections.length ; j ++){ | |
| 1539 | + section = sections[j]; | |
| 1540 | + sBuffer.append("<LinePoint>"); | |
| 1541 | + sBuffer.append("<ZDXH>").append(startId).append("</ZDXH>"); | |
| 1542 | + sBuffer.append("<SXX>").append(dir).append("</SXX>"); | |
| 1543 | + sBuffer.append("<ZDJD>").append(section.split(" ")[0]).append("</ZDJD>"); | |
| 1544 | + sBuffer.append("<ZDWD>").append(section.split(" ")[1]).append("</ZDWD>"); | |
| 1545 | + sBuffer.append("</LinePoint>"); | |
| 1546 | + startId++; | |
| 1547 | + } | |
| 1548 | + } | |
| 1549 | + } | |
| 1550 | + return startId; | |
| 1551 | + } | |
| 1552 | + | |
| 1553 | + /** | |
| 1554 | + * 获取运管处站点序号 | |
| 1555 | + * @param map | |
| 1556 | + * @return 运管处站点序号 | |
| 1557 | + */ | |
| 1558 | + private Integer getYgcStationNumByLineCodeAndDirectionAndStationName(HashMap<String,String> map,Map<String, Integer> stationNumMap){ | |
| 1559 | + // 线路编码 | |
| 1560 | + String lineCode = map.get("lineCode"); | |
| 1561 | + // 线路走向 0:上行 1:下行 | |
| 1562 | + String direction = map.get("direction"); | |
| 1563 | + // 站点编码 | |
| 1564 | + String stationCode = map.get("stationCode"); | |
| 1565 | + // 站点类型:B:起点站 Z:中途站 E:终点站 T:停车场 | |
| 1566 | + String stationMark = map.get("stationMark"); | |
| 1567 | + String[] marks = null; | |
| 1568 | + // 起点站,先从起点找,找不到再从中途站找,最后从终点找 | |
| 1569 | + if(stationMark.equals("B")){ | |
| 1570 | + marks= new String[]{"B","Z","E"}; | |
| 1571 | + }else if(stationMark.equals("E")){// 终点站相反 | |
| 1572 | + marks= new String[]{"E","Z","B"}; | |
| 1573 | + }else if(stationMark.equals("Z")){ | |
| 1574 | + marks= new String[]{"Z"}; | |
| 1575 | + } | |
| 1576 | + // 默认从缓存BasicData.stationName2YgcNumber | |
| 1577 | + Map<String, Integer> tempMap = BasicData.stationName2YgcNumber; | |
| 1578 | + // 如果传入的stationNumMap不为空,则不是缓存取,而从stationNumMap取 | |
| 1579 | + if(stationNumMap != null){ | |
| 1580 | + tempMap = stationNumMap; | |
| 1581 | + } | |
| 1582 | + Integer number = null; | |
| 1583 | + for (int i = 0 ;i < marks.length ; i ++){ | |
| 1584 | + number = tempMap.get(lineCode+"_"+direction+"_"+stationCode+"_"+marks[i]); | |
| 1585 | + if(number != null){ | |
| 1586 | + break; | |
| 1587 | + } | |
| 1588 | + } | |
| 1589 | + return number == null ? 0 : number; | |
| 1590 | + } | |
| 1591 | + | |
| 1592 | + /** | |
| 1593 | + * 封装查询站序条件 | |
| 1594 | + * @param obj | |
| 1595 | + * @return | |
| 1596 | + */ | |
| 1597 | + private HashMap packageYgcStationNumParam(Object obj,HashMap<String,String> otherParam){ | |
| 1598 | + HashMap<String,String> map = new HashMap<String,String>(); | |
| 1599 | + String lineCode = "",direction = "",stationCode = "",stationMark = ""; | |
| 1600 | + // 站点路由 | |
| 1601 | + if(obj instanceof StationRoute){ | |
| 1602 | + StationRoute sr = (StationRoute)obj; | |
| 1603 | + lineCode = sr.getLineCode(); | |
| 1604 | + direction = String.valueOf(sr.getDirections()); | |
| 1605 | + stationCode = sr.getStationCode(); | |
| 1606 | + stationMark = sr.getStationMark(); | |
| 1607 | + }else if(obj instanceof ScheduleRealInfo){ //实际排班计划明细。 | |
| 1608 | + ScheduleRealInfo sri = (ScheduleRealInfo)obj; | |
| 1609 | + lineCode = sri.getXlBm(); | |
| 1610 | + direction = sri.getXlDir(); | |
| 1611 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1612 | + stationMark = otherParam.get("stationMark"); | |
| 1613 | + if(stationMark.equals("B")){ // 起点站 | |
| 1614 | + stationCode = sri.getQdzCode(); | |
| 1615 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1616 | + stationCode = sri.getZdzCode(); | |
| 1617 | + } | |
| 1618 | + } | |
| 1619 | + }else if(obj instanceof SchedulePlanInfo){ //排班计划明细 | |
| 1620 | + SchedulePlanInfo spi = (SchedulePlanInfo)obj; | |
| 1621 | + lineCode = spi.getXlBm(); | |
| 1622 | + direction = spi.getXlDir(); | |
| 1623 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1624 | + stationMark = otherParam.get("stationMark"); | |
| 1625 | + if(stationMark.equals("B")){ // 起点站 | |
| 1626 | + stationCode = spi.getQdzCode(); | |
| 1627 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1628 | + stationCode = spi.getZdzCode(); | |
| 1629 | + } | |
| 1630 | + } | |
| 1631 | + }else if(obj instanceof TTInfoDetail){ //时刻表明细 | |
| 1632 | + TTInfoDetail ttid = (TTInfoDetail)obj; | |
| 1633 | + lineCode = ttid.getXl().getLineCode(); | |
| 1634 | + direction = ttid.getXlDir(); | |
| 1635 | + if(otherParam != null && otherParam.get("stationMark") != null){ | |
| 1636 | + stationMark = otherParam.get("stationMark"); | |
| 1637 | + if(stationMark.equals("B")){ // 起点站 | |
| 1638 | + stationCode = ttid.getQdzCode(); | |
| 1639 | + }else if(stationMark.equals("E")){ // 终点站 | |
| 1640 | + stationCode = ttid.getZdzCode(); | |
| 1641 | + } | |
| 1642 | + } | |
| 1643 | + } | |
| 1644 | + map.put("lineCode",lineCode);// 站点编码 | |
| 1645 | + map.put("direction",direction); // 上下行 | |
| 1646 | + map.put("stationCode",stationCode); // 站点编号 | |
| 1647 | + map.put("stationMark",stationMark); // 站点类型 | |
| 1648 | + return map; | |
| 1649 | + } | |
| 1650 | + | |
| 1651 | + /** | |
| 1652 | + * 取得历史站点编码和站点名称的对应关系 | |
| 1653 | + * @return | |
| 1654 | + */ | |
| 1655 | + private Map<String, String> getLsStationCode(String lineCode,int lineVersion){ | |
| 1656 | + Map<String,Object> map = new HashMap<>(); | |
| 1657 | + map.put("lineCode_eq", lineCode); | |
| 1658 | + map.put("versions_eq",lineVersion); | |
| 1659 | + LsStationRoute lsroute; | |
| 1660 | + Iterator<LsStationRoute> iterator = lsStationRouteRepository.findAll(new CustomerSpecs<LsStationRoute>(map)).iterator(); | |
| 1661 | + Map<String, String> stationCode2Name = new HashMap<>(); | |
| 1662 | + while (iterator.hasNext()) { | |
| 1663 | + lsroute = iterator.next(); | |
| 1664 | + stationCode2Name.put(lsroute.getLineCode() + "_" + lsroute.getDirections() + "_" + lsroute.getStationCode(), lsroute.getStationName()); | |
| 1665 | + } | |
| 1666 | + return stationCode2Name; | |
| 1667 | + } | |
| 1668 | + | |
| 1669 | + private Map<String, Integer> getLsStationRoute(String xlbm,int lineVersion){ | |
| 1670 | + Map<String, Integer> tempStationName2YgcNumber = new HashMap<String, Integer>(); | |
| 1671 | + /** | |
| 1672 | + * 加载运管处的站点及序号 | |
| 1673 | + * 上行从1开始,下行顺序续编 | |
| 1674 | + */ | |
| 1675 | + List<Map<String, String>> ygcLines = lsStationRouteRepository.findLineWithLineCode4Ygc(xlbm,lineVersion); | |
| 1676 | + if(ygcLines != null && ygcLines.size() > 0){ | |
| 1677 | + int size = ygcLines.size(); | |
| 1678 | + Map<String, String> tempMap ; | |
| 1679 | + int num = 1; | |
| 1680 | + String key; | |
| 1681 | + String lineCode = ""; | |
| 1682 | + for (int i = 0; i < size; i ++){ | |
| 1683 | + tempMap = ygcLines.get(i); | |
| 1684 | + if(lineCode.equals("")){ | |
| 1685 | + lineCode = tempMap.get("lineCode"); | |
| 1686 | + }else if(!lineCode.equals(tempMap.get("lineCode"))){ | |
| 1687 | + num = 1; | |
| 1688 | + lineCode = tempMap.get("lineCode"); | |
| 1689 | + } | |
| 1690 | + key = tempMap.get("lineCode") + "_"+String.valueOf(tempMap.get("directions")) | |
| 1691 | + + "_"+tempMap.get("stationCode")+ "_"+tempMap.get("stationMark"); | |
| 1692 | + tempStationName2YgcNumber.put(key,num++); | |
| 1693 | + } | |
| 1694 | + } | |
| 1695 | + return tempStationName2YgcNumber; | |
| 1696 | + } | |
| 1697 | + | |
| 1698 | + private String getSetXlXml(Line line,LineInformation lineInformation){ | |
| 1699 | + StringBuffer sBuffer = new StringBuffer(); | |
| 1700 | + List<StationRoute> upStationsList ;// 上行站点路由集 | |
| 1701 | + List<StationRoute> downStationsList;// 下行站点路由集 | |
| 1702 | + List<Object[]> downPointList;// 下行站点集 | |
| 1703 | + List<Object[]> upPointList;// 上行站点集 | |
| 1704 | + sBuffer.append("<XLs>"); | |
| 1705 | + sBuffer.append("<XL>"); | |
| 1706 | + sBuffer.append("<XLBM>").append(BasicData.lineId2ShangHaiCodeMap.get(line.getId())).append("</XLBM>"); | |
| 1707 | + sBuffer.append("<XLMC>").append(line.getName()).append("</XLMC>"); | |
| 1708 | + sBuffer.append("<QDZ>").append(line.getStartStationName()).append("</QDZ>"); | |
| 1709 | + sBuffer.append("<ZDZ>").append(line.getEndStationName()).append("</ZDZ>"); | |
| 1710 | + sBuffer.append("<QZLC>").append(lineInformation.getUpMileage()).append("</QZLC>"); | |
| 1711 | + sBuffer.append("<ZQLC>").append(lineInformation.getDownMileage()).append("</ZQLC>"); | |
| 1712 | + sBuffer.append("<XLGH>").append(line.getLinePlayType()).append("</XLGH>"); | |
| 1713 | + sBuffer.append("<UPDATE_DATE>").append(sdfnyr.format(new Date())).append("</UPDATE_DATE>"); | |
| 1714 | + // 循环添加站点信息 | |
| 1715 | + sBuffer.append("<StationList>"); | |
| 1716 | + // 先查上行 | |
| 1717 | + upStationsList = stationRouteRepository.findByLine(line.getLineCode(), 0); | |
| 1718 | + Map<String, Integer> stationNumMap = getStationName2YgcNumberMap(line.getLineCode()); | |
| 1719 | + int startId = 1; | |
| 1720 | + startId = packagStationXml(upStationsList, sBuffer, startId,stationNumMap); | |
| 1721 | + // 环线不查下行 | |
| 1722 | + if(line.getLinePlayType() != 1){ | |
| 1723 | + // 再查下行 | |
| 1724 | + downStationsList = stationRouteRepository.findByLine(line.getLineCode(), 1); | |
| 1725 | + packagStationXml(downStationsList, sBuffer, startId,stationNumMap); | |
| 1726 | + } | |
| 1727 | + sBuffer.append("</StationList>"); | |
| 1728 | + // 循环添加站点点位信息 | |
| 1729 | + sBuffer.append("<LinePointList>"); | |
| 1730 | + upPointList = sectionRepository.getSectionDirByLineId(line.getId(),0); | |
| 1731 | + startId = 1; | |
| 1732 | + startId = packagStationPointXml(upPointList, sBuffer, startId); | |
| 1733 | + // 环线不查下行 | |
| 1734 | + if(line.getLinePlayType() != 1){ | |
| 1735 | + downPointList = sectionRepository.getSectionDirByLineId(line.getId(),1); | |
| 1736 | + packagStationPointXml(downPointList, sBuffer, startId); | |
| 1737 | + } | |
| 1738 | + sBuffer.append("</LinePointList>"); | |
| 1739 | + sBuffer.append("</XL>"); | |
| 1740 | + sBuffer.append("</XLs>"); | |
| 1741 | + return sBuffer.toString(); | |
| 1742 | + } | |
| 1743 | +} | ... | ... |
src/main/resources/application-prod.properties
| ... | ... | @@ -9,7 +9,7 @@ spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.Im |
| 9 | 9 | spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy |
| 10 | 10 | spring.jpa.database= MYSQL |
| 11 | 11 | spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true |
| 12 | -spring.jpa.show-sql= true | |
| 12 | +spring.jpa.show-sql= false | |
| 13 | 13 | |
| 14 | 14 | #DATABASE |
| 15 | 15 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver | ... | ... |
src/main/resources/static/pages/trafficManage/js/timeTempletUpload.js
| 1 | -/** | |
| 2 | - * | |
| 3 | - * @JSName : timeTempletUpload.js(运管处js) | |
| 4 | - * | |
| 5 | - * @Author : bsth@zq | |
| 6 | - * | |
| 7 | - * @Description : TODO(运管功能公共js) | |
| 8 | - * | |
| 9 | - * @Data : 2016年6月29日 上午9:21:17 | |
| 10 | - * | |
| 11 | - * @Version 公交调度系统BS版 0.1 | |
| 12 | - * | |
| 13 | - */ | |
| 14 | - | |
| 15 | -(function(){ | |
| 16 | - | |
| 17 | - function getComp(cb) { | |
| 18 | - $.get('/user/companyData',null,function(rs) { | |
| 19 | - return cb && cb(rs); | |
| 20 | - }); | |
| 21 | - } | |
| 22 | - | |
| 23 | - initLineSelect2(); | |
| 24 | - | |
| 25 | - function initLineSelect2(compD) { | |
| 26 | - getComp(function(rs) { | |
| 27 | - var params = {}; | |
| 28 | - if(rs.length>0) { | |
| 29 | - var compA = new Array(); | |
| 30 | - for(var c = 0 ; c<rs.length;c++) { | |
| 31 | - var comC = rs[c].companyCode; | |
| 32 | - var child = rs[c].children; | |
| 33 | - if(child.length>0) { | |
| 34 | - for(var d = 0 ;d< child.length;d++) { | |
| 35 | - compA.push(comC + '_' + child[d].code); | |
| 36 | - } | |
| 37 | - }else { | |
| 38 | - compA.push(comC); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - params.cgsbm_in = compA.toString(); | |
| 42 | - } | |
| 43 | - params["remove_ne"] = 1; | |
| 44 | - // 填充线路拉框选择值 | |
| 45 | - $get('/line/all', params, function(array){ | |
| 46 | - var len_ = array.length,paramsD = new Array(); | |
| 47 | - if(len_>0) { | |
| 48 | - $.each(array, function(i, g){ | |
| 49 | - if(g.name!='' || g.name != null) { | |
| 50 | - paramsD.push({'id':g.id ,'text':g.name}); | |
| 51 | - } | |
| 52 | - }); | |
| 53 | - initPinYinSelect2($('#line'),paramsD,function(selector) { | |
| 54 | - selector.select2("val", storage.xlName_AgursData); | |
| 55 | - }); | |
| 56 | - } | |
| 57 | - }); | |
| 58 | - }); | |
| 59 | - } | |
| 60 | - | |
| 61 | - | |
| 62 | - // 绑定查询事件 | |
| 63 | - $("#search").click(searchM); | |
| 64 | - // 绑定上传事件 | |
| 65 | - $("#upload").click(uploadM); | |
| 66 | - // 绑定全部移到右边事件 | |
| 67 | - $("#to_right").click(function() { | |
| 68 | - $("#left_div tbody tr:not(.muted)").click(); | |
| 69 | - }); | |
| 70 | - // 绑定全部移到左边事件 | |
| 71 | - $("#to_left").click(function() { | |
| 72 | - $("#right_div tbody tr:not(.muted)").click(); | |
| 73 | - }); | |
| 74 | - // 查询方法 | |
| 75 | - function searchM() { | |
| 76 | - // 清空已选定列表 | |
| 77 | - $("#right_div table tbody").empty(); | |
| 78 | - var params = {}; | |
| 79 | - // 取得输入框的值 | |
| 80 | - var inputs = $(".param input,select"); | |
| 81 | - // 遍历数组 | |
| 82 | - $.each(inputs, function(i, element) { | |
| 83 | - if($(element).attr("type") == 'checkbox'){ | |
| 84 | - if($(element).is(':checked')){ | |
| 85 | - params[$(element).attr("name")] = $(element).val(); | |
| 86 | - } | |
| 87 | - }else{ | |
| 88 | - params[$(element).attr("name")] = $(element).val(); | |
| 89 | - } | |
| 90 | - }); | |
| 91 | - //params["isCancel_ne"] = true;// 过滤作废时刻表 | |
| 92 | - var i = layer.load(2); | |
| 93 | - $get('/tic_ec', params, function(data) { | |
| 94 | - var content = data.data.content; | |
| 95 | - _dateFormat(content); | |
| 96 | - var bodyHtm = template('timeTemplet_list_temp', { | |
| 97 | - list : content | |
| 98 | - }); | |
| 99 | - $("#left_div table tbody").empty(); | |
| 100 | - $("#left_div table tbody").append(bodyHtm); | |
| 101 | - $("#left_div tbody tr:not(.muted)").click(_click); | |
| 102 | - layer.close(i); | |
| 103 | - }); | |
| 104 | - } | |
| 105 | - | |
| 106 | - // 上传方法 | |
| 107 | - function uploadM() { | |
| 108 | - | |
| 109 | - // 取得输入框的值 | |
| 110 | - var trs = $("#right_div tbody tr input"); | |
| 111 | - if (trs.length == 0) { | |
| 112 | - alert("请选择模板"); | |
| 113 | - return; | |
| 114 | - } | |
| 115 | - var ids ="0,"; | |
| 116 | - // 遍历数组 | |
| 117 | - $.each(trs, function(i, element) { | |
| 118 | - ids +=$(element).val()+","; | |
| 119 | - }); | |
| 120 | - var params = {"ids":ids}; | |
| 121 | - $.ajax({ | |
| 122 | - type: 'get',url: '/trmg/setSKB', | |
| 123 | - data: params ,dataType:'text', | |
| 124 | - success:function(data) { | |
| 125 | - alert(data); | |
| 126 | - }, error : function() { | |
| 127 | - alert("操作失败"); | |
| 128 | - } | |
| 129 | - | |
| 130 | - }); | |
| 131 | - } | |
| 132 | - | |
| 133 | - // 表格行的单击事件 | |
| 134 | - function _click() { | |
| 135 | - var tmpTr = $(this).clone(); | |
| 136 | - tmpTr.unbind("click").click(_click); | |
| 137 | - // 判断父DIV的ID | |
| 138 | - if ($(this).closest(".table-container").attr("id") == "left_div") { | |
| 139 | - // 把要移动行的class=".seq"的HTML的内容设成另一分类的最后一个序号 | |
| 140 | - $(".seq", tmpTr).html( | |
| 141 | - $("#right_div tbody tr:not(.muted)").length + 1); | |
| 142 | - $("#right_div tbody").append(tmpTr); | |
| 143 | - nextAllChildSeqMinusOne($(this)); | |
| 144 | - } else { | |
| 145 | - // 把要移动行的class=".seq"的HTML的内容设成另一分类的最后一个序号 | |
| 146 | - $(".seq", tmpTr).html( | |
| 147 | - $("#left_div tbody tr:not(.muted)").length + 1); | |
| 148 | - $("#left_div tbody").append(tmpTr); | |
| 149 | - nextAllChildSeqMinusOne($(this)); | |
| 150 | - } | |
| 151 | - $(this).remove(); | |
| 152 | - } | |
| 153 | - | |
| 154 | - // 后面所有兄弟节点的中class=".seq"的HTML的内容自减 1 | |
| 155 | - function nextAllChildSeqMinusOne(theElement) { | |
| 156 | - $.each(theElement.nextAll(), function(i, e) { | |
| 157 | - $(".seq", e).html($(".seq", e).html() - 1); | |
| 158 | - }); | |
| 159 | - } | |
| 160 | - // 保存左边空表格 | |
| 161 | - var leftDivTemplate = $("#left_div table").clone(true); | |
| 162 | - // 把左边表格的格式复制到右边 | |
| 163 | - $("#right_div").append(leftDivTemplate); | |
| 164 | - //转换时间格式 | |
| 165 | - function _dateFormat(list) { | |
| 166 | - var fs = 'YYYY-MM-DD HH:mm'; | |
| 167 | - $.each(list, function(i, obj) { | |
| 168 | - obj.qyrq = moment(obj.qyrq).format(fs); | |
| 169 | - }); | |
| 170 | - } | |
| 171 | - | |
| 172 | - // 绑定查询事件 | |
| 173 | - $("#setCL").click(setCLF); | |
| 174 | - var params = {}; | |
| 175 | - function setCLF() { | |
| 176 | - $.ajax({ | |
| 177 | - type: 'get',url: '/trmg/setCL', | |
| 178 | - data: params ,dataType:'text', | |
| 179 | - success:function(data) { | |
| 180 | - alert(data); | |
| 181 | - }, error : function() { | |
| 182 | - alert("操作失败"); | |
| 183 | - } | |
| 184 | - | |
| 185 | - }); | |
| 186 | - } | |
| 187 | - | |
| 188 | - // 绑定查询事件 | |
| 189 | - $("#setSJ").click(setSJF); | |
| 190 | - var params = {}; | |
| 191 | - function setSJF() { | |
| 192 | - $.ajax({ | |
| 193 | - type: 'get',url: '/trmg/setSJ', | |
| 194 | - data: params ,dataType:'text', | |
| 195 | - success:function(data) { | |
| 196 | - alert(data); | |
| 197 | - }, error : function() { | |
| 198 | - alert("操作失败"); | |
| 199 | - } | |
| 200 | - | |
| 201 | - }); | |
| 202 | - } | |
| 203 | - | |
| 204 | - // 绑定查询事件 | |
| 205 | - $("#setLD").click(setLDF); | |
| 206 | - var params = {}; | |
| 207 | - function setLDF() { | |
| 208 | - $.ajax({ | |
| 209 | - type: 'get',url: '/trmg/setLD', | |
| 210 | - data: params ,dataType:'text', | |
| 211 | - success:function(data) { | |
| 212 | - alert(data); | |
| 213 | - }, error : function() { | |
| 214 | - alert("操作失败"); | |
| 215 | - } | |
| 216 | - | |
| 217 | - }); | |
| 218 | - } | |
| 219 | - | |
| 220 | - // 绑定查询事件 | |
| 221 | - $("#setLDFile").click(setLDFileF); | |
| 222 | - var params = {}; | |
| 223 | - function setLDFileF() { | |
| 224 | - $.ajax({ | |
| 225 | - type: 'get',url: '/trmg/setLDFile', | |
| 226 | - data: params ,dataType:'text', | |
| 227 | - success:function(data) { | |
| 228 | - alert(data); | |
| 229 | - }, error : function() { | |
| 230 | - alert("操作失败"); | |
| 231 | - } | |
| 232 | - | |
| 233 | - }); | |
| 234 | - } | |
| 235 | - | |
| 236 | - // 绑定查询事件 | |
| 237 | - $("#setLCYH").click(setLCYHF); | |
| 238 | - var params = {}; | |
| 239 | - function setLCYHF() { | |
| 240 | - $.ajax({ | |
| 241 | - type: 'get',url: '/trmg/setLCYH', | |
| 242 | - data: params ,dataType:'text', | |
| 243 | - success:function(data) { | |
| 244 | - alert(data); | |
| 245 | - }, error : function() { | |
| 246 | - alert("操作失败"); | |
| 247 | - } | |
| 248 | - | |
| 249 | - }); | |
| 250 | - } | |
| 251 | - | |
| 252 | - // 绑定查询事件 | |
| 253 | - $("#setDDRB").click(setDDRBF); | |
| 254 | - var params = {}; | |
| 255 | - function setDDRBF() { | |
| 256 | - $.ajax({ | |
| 257 | - type: 'get',url: '/trmg/setDDRB', | |
| 258 | - data: params ,dataType:'text', | |
| 259 | - success:function(data) { | |
| 260 | - alert(data); | |
| 261 | - }, error : function() { | |
| 262 | - alert("操作失败"); | |
| 263 | - } | |
| 264 | - | |
| 265 | - }); | |
| 266 | - } | |
| 267 | - | |
| 268 | - // 绑定查询事件 | |
| 269 | - $("#setJHBC").click(setJHBCF); | |
| 270 | - var params = {}; | |
| 271 | - function setJHBCF() { | |
| 272 | - $.ajax({ | |
| 273 | - type: 'get',url: '/trmg/setJHBC', | |
| 274 | - data: params ,dataType:'text', | |
| 275 | - success:function(data) { | |
| 276 | - alert(data); | |
| 277 | - }, error : function() { | |
| 278 | - alert("操作失败"); | |
| 279 | - } | |
| 280 | - | |
| 281 | - }); | |
| 282 | - } | |
| 283 | - | |
| 284 | - // 绑定查询事件 | |
| 285 | - $("#setXLPC").click(setXLPCF); | |
| 286 | - var params = {}; | |
| 287 | - function setXLPCF() { | |
| 288 | - $.ajax({ | |
| 289 | - type: 'get',url: '/trmg/setXLPC', | |
| 290 | - data: params ,dataType:'text', | |
| 291 | - success:function(data) { | |
| 292 | - alert(data); | |
| 293 | - }, error : function() { | |
| 294 | - alert("操作失败"); | |
| 295 | - } | |
| 296 | - | |
| 297 | - }); | |
| 298 | - } | |
| 299 | - | |
| 300 | - | |
| 301 | - // 绑定查询事件 | |
| 302 | - $("#setCS").click(setCSF); | |
| 303 | - var params = {}; | |
| 304 | - function setCSF() { | |
| 305 | - $.ajax({ | |
| 306 | - type: 'get',url: '/trmg/setCS', | |
| 307 | - data: params ,dataType:'text', | |
| 308 | - success:function(data) { | |
| 309 | - alert(data); | |
| 310 | - }, error : function() { | |
| 311 | - alert("操作失败"); | |
| 312 | - } | |
| 313 | - | |
| 314 | - }); | |
| 315 | - } | |
| 316 | - | |
| 317 | - // 绑定查询事件 | |
| 318 | - $("#downloadAllDataFile").click(getDownLoadAllDataFileF); | |
| 319 | - var params = {}; | |
| 320 | - function getDownLoadAllDataFileF() { | |
| 321 | - $.ajax({ | |
| 322 | - type: 'get',url: '/trmg/getDownLoadAllDataFile', | |
| 323 | - data: params ,dataType:'text', | |
| 324 | - success:function(data) { | |
| 325 | - alert(data); | |
| 326 | - }, error : function() { | |
| 327 | - alert("操作失败"); | |
| 328 | - } | |
| 329 | - | |
| 330 | - }); | |
| 331 | - } | |
| 332 | - | |
| 1 | +/** | |
| 2 | + * | |
| 3 | + * @JSName : timeTempletUpload.js(运管处js) | |
| 4 | + * | |
| 5 | + * @Author : bsth@zq | |
| 6 | + * | |
| 7 | + * @Description : TODO(运管功能公共js) | |
| 8 | + * | |
| 9 | + * @Data : 2016年6月29日 上午9:21:17 | |
| 10 | + * | |
| 11 | + * @Version 公交调度系统BS版 0.1 | |
| 12 | + * | |
| 13 | + */ | |
| 14 | + | |
| 15 | +(function(){ | |
| 16 | + function getDate(cb) { | |
| 17 | + $.ajax({ | |
| 18 | + url: "/real_control_v2/assets/imgs/time.gif", | |
| 19 | + type: "HEAD" | |
| 20 | + }).done(function (data, textStatus, jqXHR) { | |
| 21 | + cb(jqXHR && jqXHR.getResponseHeader("Date")) | |
| 22 | + }).fail(function (jqXHR, textStatus, errorThrown) { | |
| 23 | + cb(jqXHR && jqXHR.getResponseHeader("Date")) | |
| 24 | + }) | |
| 25 | + } | |
| 26 | + | |
| 27 | + function getComp(cb) { | |
| 28 | + $.get('/user/companyData',null,function(rs) { | |
| 29 | + return cb && cb(rs); | |
| 30 | + }); | |
| 31 | + } | |
| 32 | + | |
| 33 | + initLineSelect2(); | |
| 34 | + | |
| 35 | + function initLineSelect2(compD) { | |
| 36 | + getComp(function(rs) { | |
| 37 | + var params = {}; | |
| 38 | + if(rs.length>0) { | |
| 39 | + var compA = new Array(); | |
| 40 | + for(var c = 0 ; c<rs.length;c++) { | |
| 41 | + var comC = rs[c].companyCode; | |
| 42 | + var child = rs[c].children; | |
| 43 | + if(child.length>0) { | |
| 44 | + for(var d = 0 ;d< child.length;d++) { | |
| 45 | + compA.push(comC + '_' + child[d].code); | |
| 46 | + } | |
| 47 | + }else { | |
| 48 | + compA.push(comC); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + params.cgsbm_in = compA.toString(); | |
| 52 | + } | |
| 53 | + params["remove_ne"] = 1; | |
| 54 | + // 填充线路拉框选择值 | |
| 55 | + $get('/line/all', params, function(array){ | |
| 56 | + var len_ = array.length,paramsD = new Array(); | |
| 57 | + if(len_>0) { | |
| 58 | + $.each(array, function(i, g){ | |
| 59 | + if(g.name!='' || g.name != null) { | |
| 60 | + paramsD.push({'id':g.id ,'text':g.name}); | |
| 61 | + } | |
| 62 | + }); | |
| 63 | + initPinYinSelect2($('#line'),paramsD,function(selector) { | |
| 64 | + selector.select2("val", storage.xlName_AgursData); | |
| 65 | + }); | |
| 66 | + } | |
| 67 | + }); | |
| 68 | + }); | |
| 69 | + } | |
| 70 | + | |
| 71 | + | |
| 72 | + // 绑定查询事件 | |
| 73 | + $("#search").click(searchM); | |
| 74 | + // 绑定上传事件 | |
| 75 | + $("#upload").click(uploadM); | |
| 76 | + // 绑定全部移到右边事件 | |
| 77 | + $("#to_right").click(function() { | |
| 78 | + $("#left_div tbody tr:not(.muted)").dblclick(); | |
| 79 | + }); | |
| 80 | + // 绑定全部移到左边事件 | |
| 81 | + $("#to_left").click(function() { | |
| 82 | + $("#right_div tbody tr:not(.muted)").dblclick(); | |
| 83 | + }); | |
| 84 | + // 查询方法 | |
| 85 | + function searchM() { | |
| 86 | + // 清空已选定列表 | |
| 87 | + $("#right_div table tbody").empty(); | |
| 88 | + var params = {}; | |
| 89 | + // 取得输入框的值 | |
| 90 | + var inputs = $(".param input,select"); | |
| 91 | + // 遍历数组 | |
| 92 | + $.each(inputs, function(i, element) { | |
| 93 | + if($(element).attr("type") == 'checkbox'){ | |
| 94 | + if($(element).is(':checked')){ | |
| 95 | + params[$(element).attr("name")] = $(element).val(); | |
| 96 | + } | |
| 97 | + }else{ | |
| 98 | + params[$(element).attr("name")] = $(element).val(); | |
| 99 | + } | |
| 100 | + }); | |
| 101 | + //params["isCancel_ne"] = true;// 过滤作废时刻表 | |
| 102 | + var i = layer.load(2); | |
| 103 | + $get('/tic_ec', params, function(data) { | |
| 104 | + var content = data.data.content; | |
| 105 | + _dateFormat(content); | |
| 106 | + var bodyHtm = template('timeTemplet_list_temp', { | |
| 107 | + list : content | |
| 108 | + }); | |
| 109 | + $("#left_div table tbody").empty(); | |
| 110 | + $("#left_div table tbody").append(bodyHtm); | |
| 111 | + $("#left_div tbody tr:not(.muted)").dblclick(_dblclick); | |
| 112 | + $('.datetime').datetimepicker({ | |
| 113 | + format : 'YYYY-MM-DD', | |
| 114 | + locale: 'zh-cn', | |
| 115 | + minDate: moment().add(1,'days').toString() | |
| 116 | + }); | |
| 117 | + layer.close(i); | |
| 118 | + }); | |
| 119 | + } | |
| 120 | + | |
| 121 | + // 表格行的单击事件 | |
| 122 | + function _dblclick() { | |
| 123 | + if ($('.datetime').data("DateTimePicker")) { | |
| 124 | + $('.datetime').data("DateTimePicker").destroy(); | |
| 125 | + } | |
| 126 | + var tmpTr = $(this).clone(); | |
| 127 | + tmpTr.unbind("dblclick").dblclick(_dblclick); | |
| 128 | + // 判断父DIV的ID | |
| 129 | + if ($(this).closest(".table-container").attr("id") == "left_div") { | |
| 130 | + // 把要移动行的class=".seq"的HTML的内容设成另一分类的最后一个序号 | |
| 131 | + $(".seq", tmpTr).html( | |
| 132 | + $("#right_div tbody tr:not(.muted)").length + 1); | |
| 133 | + $("#right_div tbody").append(tmpTr); | |
| 134 | + nextAllChildSeqMinusOne($(this)); | |
| 135 | + } else { | |
| 136 | + // 把要移动行的class=".seq"的HTML的内容设成另一分类的最后一个序号 | |
| 137 | + $(".seq", tmpTr).html( | |
| 138 | + $("#left_div tbody tr:not(.muted)").length + 1); | |
| 139 | + $("#left_div tbody").append(tmpTr); | |
| 140 | + nextAllChildSeqMinusOne($(this)); | |
| 141 | + } | |
| 142 | + $('#left_div .datetime').attr('disabled', false).datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn', minDate: moment().add(1,'days').toString()}); | |
| 143 | + $('#right_div .datetime').attr('disabled', true); | |
| 144 | + //$("#left_div .datetime") | |
| 145 | + $(this).remove(); | |
| 146 | + } | |
| 147 | + | |
| 148 | + // 上传方法 | |
| 149 | + function uploadM() { | |
| 150 | + | |
| 151 | + // 取得输入框的值 | |
| 152 | + var trs = $("#right_div tbody tr input[name='tid']"), trs1 = $("#right_div tbody tr input[name='tqyrq']"); | |
| 153 | + if (trs.length == 0) { | |
| 154 | + alert("请选择模板"); | |
| 155 | + return; | |
| 156 | + } | |
| 157 | + var ids ="0,",qyrqs = "0,"; | |
| 158 | + // 遍历数组 | |
| 159 | + $.each(trs, function(i, element) { | |
| 160 | + ids +=$(element).val()+","; | |
| 161 | + }); | |
| 162 | + $.each(trs1, function(i, element) { | |
| 163 | + qyrqs +=$(element).val()+","; | |
| 164 | + }); | |
| 165 | + var params = {"ids":ids, "qyrqs":qyrqs}; | |
| 166 | + $.ajax({ | |
| 167 | + type: 'get',url: '/trmg/setSKB', | |
| 168 | + data: params ,dataType:'text', | |
| 169 | + success:function(data) { | |
| 170 | + alert(data); | |
| 171 | + }, error : function() { | |
| 172 | + alert("操作失败"); | |
| 173 | + } | |
| 174 | + | |
| 175 | + }); | |
| 176 | + } | |
| 177 | + | |
| 178 | + // 后面所有兄弟节点的中class=".seq"的HTML的内容自减 1 | |
| 179 | + function nextAllChildSeqMinusOne(theElement) { | |
| 180 | + $.each(theElement.nextAll(), function(i, e) { | |
| 181 | + $(".seq", e).html($(".seq", e).html() - 1); | |
| 182 | + }); | |
| 183 | + } | |
| 184 | + // 保存左边空表格 | |
| 185 | + var leftDivTemplate = $("#left_div table").clone(true); | |
| 186 | + // 把左边表格的格式复制到右边 | |
| 187 | + $("#right_div").append(leftDivTemplate); | |
| 188 | + //转换时间格式 | |
| 189 | + function _dateFormat(list) { | |
| 190 | + var fs = 'YYYY-MM-DD HH:mm'; | |
| 191 | + $.each(list, function(i, obj) { | |
| 192 | + obj.qyrq = moment(obj.qyrq).format(fs); | |
| 193 | + }); | |
| 194 | + } | |
| 195 | + | |
| 196 | + // 绑定查询事件 | |
| 197 | + $("#setCL").click(setCLF); | |
| 198 | + var params = {}; | |
| 199 | + function setCLF() { | |
| 200 | + $.ajax({ | |
| 201 | + type: 'get',url: '/trmg/setCL', | |
| 202 | + data: params ,dataType:'text', | |
| 203 | + success:function(data) { | |
| 204 | + alert(data); | |
| 205 | + }, error : function() { | |
| 206 | + alert("操作失败"); | |
| 207 | + } | |
| 208 | + | |
| 209 | + }); | |
| 210 | + } | |
| 211 | + | |
| 212 | + // 绑定查询事件 | |
| 213 | + $("#setSJ").click(setSJF); | |
| 214 | + var params = {}; | |
| 215 | + function setSJF() { | |
| 216 | + $.ajax({ | |
| 217 | + type: 'get',url: '/trmg/setSJ', | |
| 218 | + data: params ,dataType:'text', | |
| 219 | + success:function(data) { | |
| 220 | + alert(data); | |
| 221 | + }, error : function() { | |
| 222 | + alert("操作失败"); | |
| 223 | + } | |
| 224 | + | |
| 225 | + }); | |
| 226 | + } | |
| 227 | + | |
| 228 | + // 绑定查询事件 | |
| 229 | + $("#setLD").click(setLDF); | |
| 230 | + var params = {}; | |
| 231 | + function setLDF() { | |
| 232 | + $.ajax({ | |
| 233 | + type: 'get',url: '/trmg/setLD', | |
| 234 | + data: params ,dataType:'text', | |
| 235 | + success:function(data) { | |
| 236 | + alert(data); | |
| 237 | + }, error : function() { | |
| 238 | + alert("操作失败"); | |
| 239 | + } | |
| 240 | + | |
| 241 | + }); | |
| 242 | + } | |
| 243 | + | |
| 244 | + // 绑定查询事件 | |
| 245 | + $("#setLDFile").click(setLDFileF); | |
| 246 | + var params = {}; | |
| 247 | + function setLDFileF() { | |
| 248 | + $.ajax({ | |
| 249 | + type: 'get',url: '/trmg/setLDFile', | |
| 250 | + data: params ,dataType:'text', | |
| 251 | + success:function(data) { | |
| 252 | + alert(data); | |
| 253 | + }, error : function() { | |
| 254 | + alert("操作失败"); | |
| 255 | + } | |
| 256 | + | |
| 257 | + }); | |
| 258 | + } | |
| 259 | + | |
| 260 | + // 绑定查询事件 | |
| 261 | + $("#setLCYH").click(setLCYHF); | |
| 262 | + var params = {}; | |
| 263 | + function setLCYHF() { | |
| 264 | + $.ajax({ | |
| 265 | + type: 'get',url: '/trmg/setLCYH', | |
| 266 | + data: params ,dataType:'text', | |
| 267 | + success:function(data) { | |
| 268 | + alert(data); | |
| 269 | + }, error : function() { | |
| 270 | + alert("操作失败"); | |
| 271 | + } | |
| 272 | + | |
| 273 | + }); | |
| 274 | + } | |
| 275 | + | |
| 276 | + // 绑定查询事件 | |
| 277 | + $("#setDDRB").click(setDDRBF); | |
| 278 | + var params = {}; | |
| 279 | + function setDDRBF() { | |
| 280 | + $.ajax({ | |
| 281 | + type: 'get',url: '/trmg/setDDRB', | |
| 282 | + data: params ,dataType:'text', | |
| 283 | + success:function(data) { | |
| 284 | + alert(data); | |
| 285 | + }, error : function() { | |
| 286 | + alert("操作失败"); | |
| 287 | + } | |
| 288 | + | |
| 289 | + }); | |
| 290 | + } | |
| 291 | + | |
| 292 | + // 绑定查询事件 | |
| 293 | + $("#setJHBC").click(setJHBCF); | |
| 294 | + var params = {}; | |
| 295 | + function setJHBCF() { | |
| 296 | + $.ajax({ | |
| 297 | + type: 'get',url: '/trmg/setJHBC', | |
| 298 | + data: params ,dataType:'text', | |
| 299 | + success:function(data) { | |
| 300 | + alert(data); | |
| 301 | + }, error : function() { | |
| 302 | + alert("操作失败"); | |
| 303 | + } | |
| 304 | + | |
| 305 | + }); | |
| 306 | + } | |
| 307 | + | |
| 308 | + // 绑定查询事件 | |
| 309 | + $("#setXLPC").click(setXLPCF); | |
| 310 | + var params = {}; | |
| 311 | + function setXLPCF() { | |
| 312 | + $.ajax({ | |
| 313 | + type: 'get',url: '/trmg/setXLPC', | |
| 314 | + data: params ,dataType:'text', | |
| 315 | + success:function(data) { | |
| 316 | + alert(data); | |
| 317 | + }, error : function() { | |
| 318 | + alert("操作失败"); | |
| 319 | + } | |
| 320 | + | |
| 321 | + }); | |
| 322 | + } | |
| 323 | + | |
| 324 | + | |
| 325 | + // 绑定查询事件 | |
| 326 | + $("#setCS").click(setCSF); | |
| 327 | + var params = {}; | |
| 328 | + function setCSF() { | |
| 329 | + $.ajax({ | |
| 330 | + type: 'get',url: '/trmg/setCS', | |
| 331 | + data: params ,dataType:'text', | |
| 332 | + success:function(data) { | |
| 333 | + alert(data); | |
| 334 | + }, error : function() { | |
| 335 | + alert("操作失败"); | |
| 336 | + } | |
| 337 | + | |
| 338 | + }); | |
| 339 | + } | |
| 340 | + | |
| 341 | + // 绑定查询事件 | |
| 342 | + $("#downloadAllDataFile").click(getDownLoadAllDataFileF); | |
| 343 | + var params = {}; | |
| 344 | + function getDownLoadAllDataFileF() { | |
| 345 | + $.ajax({ | |
| 346 | + type: 'get',url: '/trmg/getDownLoadAllDataFile', | |
| 347 | + data: params ,dataType:'text', | |
| 348 | + success:function(data) { | |
| 349 | + alert(data); | |
| 350 | + }, error : function() { | |
| 351 | + alert("操作失败"); | |
| 352 | + } | |
| 353 | + | |
| 354 | + }); | |
| 355 | + } | |
| 356 | + | |
| 333 | 357 | })(); |
| 334 | 358 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/trafficManage/timeTempletUpload.html
| 1 | -<link href="css/trafficManage.css" rel="stylesheet" type="text/css" /> | |
| 2 | -<ul class="page-breadcrumb breadcrumb"> | |
| 3 | - <li><a href="/pages/home.html" data-pjax>首页</a> <i | |
| 4 | - class="fa fa-circle"></i></li> | |
| 5 | - <li><span class="active">运维管理</span> <i class="fa fa-circle"></i></li> | |
| 6 | - <li><span class="active">时刻模板上传</span></li> | |
| 7 | -</ul> | |
| 8 | -<div class="tab_line"> | |
| 9 | - <div class="col-md-12"> | |
| 10 | - <form class="form-inline" action=""> | |
| 11 | - <div style="display: inline-block;" class="param"> | |
| 12 | - <span class="item-label" style="width: 80px;">线路: </span> | |
| 13 | - <select class="form-control" name="xl.id_eq" id="line" style="width: 180px;"></select> | |
| 14 | - </div> | |
| 15 | - <div style="display: inline-block;margin-left: 15px;" class="param"> | |
| 16 | - <span class="item-label" style="width: 80px;">模板名称(关键字): </span> | |
| 17 | - <input class="form-control" type="text" id="tempName" name="name_like" style="width: 180px;"/> | |
| 18 | - </div> | |
| 19 | - <div style="display: inline-block;margin-left: 15px;" class="param"> | |
| 20 | - <input type="checkbox" class="group-checkable icheck" name="isEnableDisTemplate_eq" value="true" checked> 是否启用 | |
| 21 | - </div> | |
| 22 | - <div class="form-group" style="display: inline-block;margin-left: 15px;"> | |
| 23 | - <input class="btn btn-default" type="button" id="search" value="查询"/> | |
| 24 | - <input class="btn btn-default" type="button" id="upload" value="上传"/> | |
| 25 | - <!-- <input class="btn btn-default" type="button" id="setXL" value="上传线路"/> | |
| 26 | - <input class="btn btn-default" type="button" id="setCL" value="上传车辆"/> | |
| 27 | - <input class="btn btn-default" type="button" id="setSJ" value="上传司机"/> | |
| 28 | - <input class="btn btn-default" type="button" id="setCS" value="超速"/> | |
| 29 | - <input class="btn btn-default" type="button" id="setXLPC" value="线路人员车辆"/> | |
| 30 | - <input class="btn btn-default" type="button" id="setJHBC" value="线路计划班次表"/> --> | |
| 31 | - </div> | |
| 32 | - </form> | |
| 33 | - </div> | |
| 34 | - <!-- Begin: left-div --> | |
| 35 | - <div class="col-md-5 panel-wrap" style="height: 60%;"> | |
| 36 | - <div class="_panel"> | |
| 37 | - <div class="_head" style="color: #2765A7;">待选线路模板列表</div> | |
| 38 | - <div class="table-container" id="left_div"> | |
| 39 | - <table | |
| 40 | - class="table table-striped table-bordered table-advance pb-table head"> | |
| 41 | - <thead> | |
| 42 | - <tr> | |
| 43 | - <th width="5%">#</th> | |
| 44 | - <th width="20%">线路名称</th> | |
| 45 | - <th width="15%">模板ID</th> | |
| 46 | - <th width="25%">模板名称</th> | |
| 47 | - <th>启用日期</th> | |
| 48 | - </tr> | |
| 49 | - </thead> | |
| 50 | - <tbody> | |
| 51 | - </tbody> | |
| 52 | - </table> | |
| 53 | - </div> | |
| 54 | - </div> | |
| 55 | - </div> | |
| 56 | - <div class="col-md-2" style="height: 60%;"> | |
| 57 | - <ul class="breadcruma divVerHorCenter"> | |
| 58 | - <li><a class="btn btn-circle blue btn-outline" id="to_right">>></a></li> | |
| 59 | - <li><a class="btn btn-circle blue btn-outline" id="to_left"><<</a></li> | |
| 60 | - </ul> | |
| 61 | - </div> | |
| 62 | - <!-- End: left-div --> | |
| 63 | - <!-- Begin: right-div --> | |
| 64 | - <div class="col-md-5 panel-wrap" style="height: 60%;"> | |
| 65 | - <div class="_panel"> | |
| 66 | - <div class="_head" style="color: #2765A7;">已选线路模板列表</div> | |
| 67 | - <div class="table-container" id="right_div"></div> | |
| 68 | - </div> | |
| 69 | - </div> | |
| 70 | - <!-- End: right-div --> | |
| 71 | -</div> | |
| 72 | -<script id="timeTemplet_list_temp" type="text/html"> | |
| 73 | -{{each list as obj i}} | |
| 74 | -<tr> | |
| 75 | - <td class="seq" style="vertical-align: middle;"> | |
| 76 | - {{i+1}} | |
| 77 | - </td> | |
| 78 | - <td> | |
| 79 | - {{obj.xl.name}} | |
| 80 | - </td> | |
| 81 | - <td class="ttInfoId"> | |
| 82 | - {{obj.id}} | |
| 83 | - <input type="hidden" value="{{obj.id}}"/> | |
| 84 | - </td> | |
| 85 | - <td> | |
| 86 | - {{obj.name}} | |
| 87 | - </td> | |
| 88 | - <td > | |
| 89 | - {{obj.qyrq}} | |
| 90 | - </td> | |
| 91 | -</tr> | |
| 92 | -{{/each}} | |
| 93 | -{{if list.length == 0}} | |
| 94 | -<tr class="muted"> | |
| 95 | - <td colspan=5 style="text-align: center;"><h6>没有找到相关数据</h6></td> | |
| 96 | -</tr> | |
| 97 | -{{/if}} | |
| 98 | - </script> | |
| 1 | +<link href="css/trafficManage.css" rel="stylesheet" type="text/css" /> | |
| 2 | +<ul class="page-breadcrumb breadcrumb"> | |
| 3 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i | |
| 4 | + class="fa fa-circle"></i></li> | |
| 5 | + <li><span class="active">运维管理</span> <i class="fa fa-circle"></i></li> | |
| 6 | + <li><span class="active">时刻模板上传</span></li> | |
| 7 | +</ul> | |
| 8 | +<div class="tab_line"> | |
| 9 | + <div class="col-md-12"> | |
| 10 | + <form class="form-inline" action=""> | |
| 11 | + <div style="display: inline-block;" class="param"> | |
| 12 | + <span class="item-label" style="width: 80px;">线路: </span> | |
| 13 | + <select class="form-control" name="xl.id_eq" id="line" style="width: 180px;"></select> | |
| 14 | + </div> | |
| 15 | + <div style="display: inline-block;margin-left: 15px;" class="param"> | |
| 16 | + <span class="item-label" style="width: 80px;">模板名称(关键字): </span> | |
| 17 | + <input class="form-control" type="text" id="tempName" name="name_like" style="width: 180px;"/> | |
| 18 | + </div> | |
| 19 | + <div style="display: inline-block;margin-left: 15px;" class="param"> | |
| 20 | + <input type="checkbox" class="group-checkable icheck" name="isEnableDisTemplate_eq" value="true" checked> 是否启用 | |
| 21 | + </div> | |
| 22 | + <div class="form-group" style="display: inline-block;margin-left: 15px;"> | |
| 23 | + <input class="btn btn-default" type="button" id="search" value="查询"/> | |
| 24 | + <input class="btn btn-default" type="button" id="upload" value="上传"/> | |
| 25 | + <!-- <input class="btn btn-default" type="button" id="setXL" value="上传线路"/> | |
| 26 | + <input class="btn btn-default" type="button" id="setCL" value="上传车辆"/> | |
| 27 | + <input class="btn btn-default" type="button" id="setSJ" value="上传司机"/> | |
| 28 | + <input class="btn btn-default" type="button" id="setCS" value="超速"/> | |
| 29 | + <input class="btn btn-default" type="button" id="setXLPC" value="线路人员车辆"/> | |
| 30 | + <input class="btn btn-default" type="button" id="setJHBC" value="线路计划班次表"/> --> | |
| 31 | + </div> | |
| 32 | + </form> | |
| 33 | + </div> | |
| 34 | + <!-- Begin: left-div --> | |
| 35 | + <div class="col-md-5 panel-wrap" style="height: 60%;"> | |
| 36 | + <div class="_panel"> | |
| 37 | + <div class="_head" style="color: #2765A7;">待选线路模板列表</div> | |
| 38 | + <div class="table-container" id="left_div"> | |
| 39 | + <table | |
| 40 | + class="table table-striped table-bordered table-advance pb-table head"> | |
| 41 | + <thead> | |
| 42 | + <tr> | |
| 43 | + <th width="5%">#</th> | |
| 44 | + <th width="20%">线路名称</th> | |
| 45 | + <th width="15%">模板ID</th> | |
| 46 | + <th width="25%">模板名称</th> | |
| 47 | + <th>灾备系统启用日期</th> | |
| 48 | + </tr> | |
| 49 | + </thead> | |
| 50 | + <tbody> | |
| 51 | + </tbody> | |
| 52 | + </table> | |
| 53 | + </div> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + <div class="col-md-2" style="height: 60%;"> | |
| 57 | + <ul class="breadcruma divVerHorCenter"> | |
| 58 | + <li><a class="btn btn-circle blue btn-outline" id="to_right">>></a></li> | |
| 59 | + <li><a class="btn btn-circle blue btn-outline" id="to_left"><<</a></li> | |
| 60 | + </ul> | |
| 61 | + </div> | |
| 62 | + <!-- End: left-div --> | |
| 63 | + <!-- Begin: right-div --> | |
| 64 | + <div class="col-md-5 panel-wrap" style="height: 60%;"> | |
| 65 | + <div class="_panel"> | |
| 66 | + <div class="_head" style="color: #2765A7;">已选线路模板列表</div> | |
| 67 | + <div class="table-container" id="right_div"></div> | |
| 68 | + </div> | |
| 69 | + </div> | |
| 70 | + <!-- End: right-div --> | |
| 71 | +</div> | |
| 72 | +<script id="timeTemplet_list_temp" type="text/html"> | |
| 73 | +{{each list as obj i}} | |
| 74 | +<tr> | |
| 75 | + <td class="seq" style="vertical-align: middle;"> | |
| 76 | + {{i+1}} | |
| 77 | + </td> | |
| 78 | + <td> | |
| 79 | + {{obj.xl.name}} | |
| 80 | + </td> | |
| 81 | + <td class="ttInfoId"> | |
| 82 | + {{obj.id}} | |
| 83 | + <input name="tid" type="hidden" value="{{obj.id}}"/> | |
| 84 | + </td> | |
| 85 | + <td> | |
| 86 | + {{obj.name}} | |
| 87 | + </td> | |
| 88 | + <td > | |
| 89 | + <input name="tqyrq" type="text" value="{{obj.qyrq}}" class="datetime" style="border: 0px;"/> | |
| 90 | + </td> | |
| 91 | +</tr> | |
| 92 | +{{/each}} | |
| 93 | +{{if list.length == 0}} | |
| 94 | +<tr class="muted"> | |
| 95 | + <td colspan=5 style="text-align: center;"><h6>没有找到相关数据</h6></td> | |
| 96 | +</tr> | |
| 97 | +{{/if}} | |
| 98 | + </script> | |
| 99 | 99 | <script src="./js/timeTempletUpload.js"></script> |
| 100 | 100 | \ No newline at end of file | ... | ... |