Commit ec375259214b18c8bba1c519a84c8a159b40982a
1 parent
44c30450
1.百度地图key替换
2.区间子线路+线路文件、报站文件生成的完善,以及线调的处理变化 3.js打包兼容es6
Showing
26 changed files
with
2134 additions
and
1996 deletions
Too many changes to show.
To preserve performance only 26 of 35 files are displayed.
src/main/java/com/bsth/controller/directive/DirectiveController.java
| 1 | -package com.bsth.controller.directive; | ||
| 2 | - | ||
| 3 | -import com.alibaba.fastjson.JSON; | ||
| 4 | -import com.alibaba.fastjson.JSONObject; | ||
| 5 | -import com.bsth.entity.directive.D80; | ||
| 6 | -import com.bsth.entity.directive.DC0_A3; | ||
| 7 | -import com.bsth.entity.sys.SysUser; | ||
| 8 | -import com.bsth.security.util.SecurityUtils; | ||
| 9 | -import com.bsth.service.directive.DirectiveService; | ||
| 10 | -import org.apache.commons.lang3.StringEscapeUtils; | ||
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 14 | -import org.springframework.web.bind.annotation.RequestParam; | ||
| 15 | -import org.springframework.web.bind.annotation.RestController; | ||
| 16 | - | ||
| 17 | -import java.util.List; | ||
| 18 | -import java.util.Map; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * | ||
| 22 | - * @ClassName: DirectiveController | ||
| 23 | - * @Description: TODO(页面下发调度指令) .0 | ||
| 24 | - * @author PanZhao | ||
| 25 | - * @date 2016年6月8日 上午9:34:51 | ||
| 26 | - * | ||
| 27 | - */ | ||
| 28 | -@RestController | ||
| 29 | -@RequestMapping("/directive") | ||
| 30 | -public class DirectiveController { | ||
| 31 | - | ||
| 32 | - @Autowired | ||
| 33 | - DirectiveService directiveService; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * | ||
| 37 | - * @Title: send60 | ||
| 38 | - * @Description: TODO(60协议短语下发) | ||
| 39 | - * @throws | ||
| 40 | - */ | ||
| 41 | - @RequestMapping(value = "/phrase", method = RequestMethod.POST) | ||
| 42 | - public int send60Phrase(@RequestParam String nbbm, @RequestParam String text){ | ||
| 43 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 44 | - return directiveService.send60Phrase(nbbm, text, user.getUserName()); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - /** | ||
| 48 | - * | ||
| 49 | - * @Title: send60Dispatch | ||
| 50 | - * @Description: TODO(班次信息下发) | ||
| 51 | - * @param @param id | ||
| 52 | - * @throws | ||
| 53 | - */ | ||
| 54 | - @RequestMapping(value = "/dispatch", method = RequestMethod.POST) | ||
| 55 | - public int send60Dispatch(@RequestParam Long id){ | ||
| 56 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 57 | - return directiveService.send60Dispatch(id, user.getUserName()); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - /** | ||
| 61 | - * | ||
| 62 | - * @Title: lineChange | ||
| 63 | - * @Description: TODO(切换线路) | ||
| 64 | - * @param @param nbbm 车辆内部编码 | ||
| 65 | - * @param @param lineId 新线路编码 | ||
| 66 | - * @throws | ||
| 67 | - */ | ||
| 68 | - @RequestMapping(value = "/lineChnage", method = RequestMethod.POST) | ||
| 69 | - public int lineChange(@RequestParam String nbbm, @RequestParam String lineId){ | ||
| 70 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 71 | - return directiveService.lineChange(nbbm, lineId, user.getUserName()); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - /** | ||
| 75 | - * | ||
| 76 | - * @Title: lineChangeByDevice | ||
| 77 | - * @Description: TODO(切换线路) | ||
| 78 | - * @param @param deviceId 设备编码 | ||
| 79 | - * @param @param lineId 新线路编码 | ||
| 80 | - * @throws | ||
| 81 | - */ | ||
| 82 | - @RequestMapping(value = "/lineChangeByDevice", method = RequestMethod.POST) | ||
| 83 | - public int lineChangeByDevice(@RequestParam String deviceId, @RequestParam String lineId){ | ||
| 84 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 85 | - return directiveService.lineChangeByDeviceId(deviceId, lineId, user.getUserName()); | ||
| 86 | - } | ||
| 87 | - | ||
| 88 | - /** | ||
| 89 | - * 刷新线路文件 | ||
| 90 | - * @param deviceId 设备号 | ||
| 91 | - * @return | ||
| 92 | - */ | ||
| 93 | - @RequestMapping(value = "/refreshLineFile", method = RequestMethod.POST) | ||
| 94 | - public int refreshLineFile(@RequestParam String deviceId){ | ||
| 95 | - return directiveService.refreshLineFile(deviceId); | ||
| 96 | - } | ||
| 97 | - | ||
| 98 | - /** | ||
| 99 | - * | ||
| 100 | - * @Title: upDownChange | ||
| 101 | - * @Description: TODO(上下行切换) | ||
| 102 | - * @param @param nbbm 车辆内部编码 | ||
| 103 | - * @param @param upDon | ||
| 104 | - * @throws | ||
| 105 | - */ | ||
| 106 | - @RequestMapping(value = "/upDownChange", method = RequestMethod.POST) | ||
| 107 | - public int upDownChange(@RequestParam String nbbm, @RequestParam Integer upDown){ | ||
| 108 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 109 | - return directiveService.send60Operation(nbbm, 0, upDown, user.getUserName()); | ||
| 110 | - } | ||
| 111 | - | ||
| 112 | - /** | ||
| 113 | - * | ||
| 114 | - * @Title: upDownChange | ||
| 115 | - * @Description: TODO(状态切换,营运状态 和 上下行) | ||
| 116 | - * @param @param nbbm 车辆内部编码 | ||
| 117 | - * @param @param upDon | ||
| 118 | - * @throws | ||
| 119 | - */ | ||
| 120 | - @RequestMapping(value = "/stateChange", method = RequestMethod.POST) | ||
| 121 | - public int stateChange(@RequestParam String nbbm, @RequestParam Integer upDown, @RequestParam Integer state){ | ||
| 122 | - SysUser user = SecurityUtils.getCurrentUser(); | ||
| 123 | - return directiveService.send60Operation(nbbm, state, upDown, user.getUserName()); | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | - /** | ||
| 127 | - * | ||
| 128 | - * @Title: findNoCofm80 | ||
| 129 | - * @Description: TODO(根据线路获取未确认的80驾驶员上报数据) | ||
| 130 | - * @throws | ||
| 131 | - */ | ||
| 132 | - @RequestMapping(value = "/findNoCofm80", method = RequestMethod.GET) | ||
| 133 | - public Map<String, List<D80>> findNoCofm80(@RequestParam String lineCodes){ | ||
| 134 | - return directiveService.findNoCofm80(lineCodes); | ||
| 135 | - } | ||
| 136 | - | ||
| 137 | - @RequestMapping(value = "/findAll80", method = RequestMethod.GET) | ||
| 138 | - public Map<String, Object> findAll80(@RequestParam Map<String, Object> map, | ||
| 139 | - @RequestParam(defaultValue = "0") int page, | ||
| 140 | - @RequestParam(defaultValue = "12") int size){ | ||
| 141 | - | ||
| 142 | - return directiveService.findAll80(map, page,size); | ||
| 143 | - } | ||
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * | ||
| 147 | - * @Title: reply80 | ||
| 148 | - * @Description: TODO(回复80) | ||
| 149 | - * @param @param reply 0:同意 -1:不同意 | ||
| 150 | - * @throws | ||
| 151 | - */ | ||
| 152 | - @RequestMapping(value = "/reply80", method = RequestMethod.POST) | ||
| 153 | - public Map<String, Object> reply80(@RequestParam int id, @RequestParam int reply){ | ||
| 154 | - return directiveService.reply80(id, reply); | ||
| 155 | - } | ||
| 156 | - | ||
| 157 | - /** | ||
| 158 | - * | ||
| 159 | - * @Title: findDirective | ||
| 160 | - * @Description: TODO(查询调度指令) | ||
| 161 | - * @param @param nbbm 车辆 | ||
| 162 | - * @param @param dType 类型 | ||
| 163 | - * @param @param page 页号 | ||
| 164 | - * @param @param size 每页数量 | ||
| 165 | - * @throws | ||
| 166 | - */ | ||
| 167 | - @RequestMapping(value = "/list", method = RequestMethod.GET) | ||
| 168 | - public Map<String, Object> findDirective(String nbbms,@RequestParam int dType | ||
| 169 | - , @RequestParam(defaultValue = "0") int page, | ||
| 170 | - @RequestParam(defaultValue = "10") int size){ | ||
| 171 | - | ||
| 172 | - return directiveService.findDirective(nbbms, dType, page, size); | ||
| 173 | - } | ||
| 174 | - | ||
| 175 | - @RequestMapping(value = "/c0a4", method = RequestMethod.POST) | ||
| 176 | - public Map<String, Object> c0a4(@RequestParam String nbbm){ | ||
| 177 | - return directiveService.sendC0A4(nbbm); | ||
| 178 | - } | ||
| 179 | - | ||
| 180 | - @RequestMapping(value = "/c0a3", method = RequestMethod.POST) | ||
| 181 | - public int c0a3(String json){ | ||
| 182 | - json = StringEscapeUtils.unescapeHtml4(json); | ||
| 183 | - DC0_A3 c0a3 = JSON.toJavaObject(JSONObject.parseObject(json), DC0_A3.class); | ||
| 184 | - return directiveService.sendC0A3(c0a3); | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - @RequestMapping(value = "/c0a5", method = RequestMethod.POST) | ||
| 188 | - public int c0a5(String json){ | ||
| 189 | - json = StringEscapeUtils.unescapeHtml4(json); | ||
| 190 | - return directiveService.sendC0A5(json); | ||
| 191 | - } | ||
| 192 | - | ||
| 193 | - /** | ||
| 194 | - * 设备参数查询 | ||
| 195 | - * @return | ||
| 196 | - */ | ||
| 197 | - @RequestMapping(value = "/deviceCofigList", method = RequestMethod.GET) | ||
| 198 | - public Map<String, Object> deviceCofigList( | ||
| 199 | - @RequestParam Map<String, String> map, | ||
| 200 | - @RequestParam(defaultValue = "0") int page, | ||
| 201 | - @RequestParam(defaultValue = "10") int size){ | ||
| 202 | - return directiveService.deviceCofigList(map, page, size); | ||
| 203 | - } | ||
| 204 | -} | 1 | +package com.bsth.controller.directive; |
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.bsth.entity.directive.D80; | ||
| 6 | +import com.bsth.entity.directive.DC0_A3; | ||
| 7 | +import com.bsth.entity.sys.SysUser; | ||
| 8 | +import com.bsth.security.util.SecurityUtils; | ||
| 9 | +import com.bsth.service.directive.DirectiveService; | ||
| 10 | +import org.apache.commons.lang3.StringEscapeUtils; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 14 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 15 | +import org.springframework.web.bind.annotation.RestController; | ||
| 16 | + | ||
| 17 | +import javax.servlet.http.HttpServletRequest; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Map; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * | ||
| 23 | + * @ClassName: DirectiveController | ||
| 24 | + * @Description: TODO(页面下发调度指令) .0 | ||
| 25 | + * @author PanZhao | ||
| 26 | + * @date 2016年6月8日 上午9:34:51 | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | +@RestController | ||
| 30 | +@RequestMapping("/directive") | ||
| 31 | +public class DirectiveController { | ||
| 32 | + | ||
| 33 | + @Autowired | ||
| 34 | + DirectiveService directiveService; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * | ||
| 38 | + * @Title: send60 | ||
| 39 | + * @Description: TODO(60协议短语下发) | ||
| 40 | + * @throws | ||
| 41 | + */ | ||
| 42 | + @RequestMapping(value = "/phrase", method = RequestMethod.POST) | ||
| 43 | + public int send60Phrase(@RequestParam String nbbm, @RequestParam String text){ | ||
| 44 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 45 | + return directiveService.send60Phrase(nbbm, text, user.getUserName()); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * | ||
| 50 | + * @Title: send60Dispatch | ||
| 51 | + * @Description: TODO(班次信息下发) | ||
| 52 | + * @param @param id | ||
| 53 | + * @throws | ||
| 54 | + */ | ||
| 55 | + @RequestMapping(value = "/dispatch", method = RequestMethod.POST) | ||
| 56 | + public int send60Dispatch(@RequestParam Long id){ | ||
| 57 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 58 | + return directiveService.send60Dispatch(id, user.getUserName()); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * | ||
| 63 | + * @Title: lineChange | ||
| 64 | + * @Description: TODO(切换线路) | ||
| 65 | + * @param @param nbbm 车辆内部编码 | ||
| 66 | + * @param @param lineId 新线路编码 | ||
| 67 | + * @throws | ||
| 68 | + */ | ||
| 69 | + @RequestMapping(value = "/lineChnage", method = RequestMethod.POST) | ||
| 70 | + public int lineChange(@RequestParam String nbbm, @RequestParam String lineId){ | ||
| 71 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 72 | + return directiveService.lineChange(nbbm, lineId, user.getUserName()); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * | ||
| 77 | + * @Title: lineChangeByDevice | ||
| 78 | + * @Description: TODO(切换线路) | ||
| 79 | + * @param @param deviceId 设备编码 | ||
| 80 | + * @param @param lineId 新线路编码 | ||
| 81 | + * @throws | ||
| 82 | + */ | ||
| 83 | + @RequestMapping(value = "/lineChangeByDevice", method = RequestMethod.POST) | ||
| 84 | + public int lineChangeByDevice(@RequestParam String deviceId, @RequestParam String lineId, HttpServletRequest request){ | ||
| 85 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 86 | + int seq = 0; | ||
| 87 | + if (request.getParameter("seq") != null) { | ||
| 88 | + seq = Integer.parseInt(request.getParameter("seq")); | ||
| 89 | + } | ||
| 90 | + return directiveService.lineChangeByDeviceId(deviceId, lineId, user.getUserName(), seq); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 刷新线路文件 | ||
| 95 | + * @param deviceId 设备号 | ||
| 96 | + * @return | ||
| 97 | + */ | ||
| 98 | + @RequestMapping(value = "/refreshLineFile", method = RequestMethod.POST) | ||
| 99 | + public int refreshLineFile(@RequestParam String deviceId){ | ||
| 100 | + return directiveService.refreshLineFile(deviceId); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + /** | ||
| 104 | + * | ||
| 105 | + * @Title: upDownChange | ||
| 106 | + * @Description: TODO(上下行切换) | ||
| 107 | + * @param @param nbbm 车辆内部编码 | ||
| 108 | + * @param @param upDon | ||
| 109 | + * @throws | ||
| 110 | + */ | ||
| 111 | + @RequestMapping(value = "/upDownChange", method = RequestMethod.POST) | ||
| 112 | + public int upDownChange(@RequestParam String nbbm, @RequestParam Integer upDown){ | ||
| 113 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 114 | + return directiveService.send60Operation(nbbm, 0, upDown, user.getUserName()); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * | ||
| 119 | + * @Title: upDownChange | ||
| 120 | + * @Description: TODO(状态切换,营运状态 和 上下行) | ||
| 121 | + * @param @param nbbm 车辆内部编码 | ||
| 122 | + * @param @param upDon | ||
| 123 | + * @throws | ||
| 124 | + */ | ||
| 125 | + @RequestMapping(value = "/stateChange", method = RequestMethod.POST) | ||
| 126 | + public int stateChange(@RequestParam String nbbm, @RequestParam Integer upDown, @RequestParam Integer state){ | ||
| 127 | + SysUser user = SecurityUtils.getCurrentUser(); | ||
| 128 | + return directiveService.send60Operation(nbbm, state, upDown, user.getUserName()); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + /** | ||
| 132 | + * | ||
| 133 | + * @Title: findNoCofm80 | ||
| 134 | + * @Description: TODO(根据线路获取未确认的80驾驶员上报数据) | ||
| 135 | + * @throws | ||
| 136 | + */ | ||
| 137 | + @RequestMapping(value = "/findNoCofm80", method = RequestMethod.GET) | ||
| 138 | + public Map<String, List<D80>> findNoCofm80(@RequestParam String lineCodes){ | ||
| 139 | + return directiveService.findNoCofm80(lineCodes); | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + @RequestMapping(value = "/findAll80", method = RequestMethod.GET) | ||
| 143 | + public Map<String, Object> findAll80(@RequestParam Map<String, Object> map, | ||
| 144 | + @RequestParam(defaultValue = "0") int page, | ||
| 145 | + @RequestParam(defaultValue = "12") int size){ | ||
| 146 | + | ||
| 147 | + return directiveService.findAll80(map, page,size); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + /** | ||
| 151 | + * | ||
| 152 | + * @Title: reply80 | ||
| 153 | + * @Description: TODO(回复80) | ||
| 154 | + * @param @param reply 0:同意 -1:不同意 | ||
| 155 | + * @throws | ||
| 156 | + */ | ||
| 157 | + @RequestMapping(value = "/reply80", method = RequestMethod.POST) | ||
| 158 | + public Map<String, Object> reply80(@RequestParam int id, @RequestParam int reply){ | ||
| 159 | + return directiveService.reply80(id, reply); | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + /** | ||
| 163 | + * | ||
| 164 | + * @Title: findDirective | ||
| 165 | + * @Description: TODO(查询调度指令) | ||
| 166 | + * @param @param nbbm 车辆 | ||
| 167 | + * @param @param dType 类型 | ||
| 168 | + * @param @param page 页号 | ||
| 169 | + * @param @param size 每页数量 | ||
| 170 | + * @throws | ||
| 171 | + */ | ||
| 172 | + @RequestMapping(value = "/list", method = RequestMethod.GET) | ||
| 173 | + public Map<String, Object> findDirective(String nbbms,@RequestParam int dType | ||
| 174 | + , @RequestParam(defaultValue = "0") int page, | ||
| 175 | + @RequestParam(defaultValue = "10") int size){ | ||
| 176 | + | ||
| 177 | + return directiveService.findDirective(nbbms, dType, page, size); | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + @RequestMapping(value = "/c0a4", method = RequestMethod.POST) | ||
| 181 | + public Map<String, Object> c0a4(@RequestParam String nbbm){ | ||
| 182 | + return directiveService.sendC0A4(nbbm); | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + @RequestMapping(value = "/c0a3", method = RequestMethod.POST) | ||
| 186 | + public int c0a3(String json){ | ||
| 187 | + json = StringEscapeUtils.unescapeHtml4(json); | ||
| 188 | + DC0_A3 c0a3 = JSON.toJavaObject(JSONObject.parseObject(json), DC0_A3.class); | ||
| 189 | + return directiveService.sendC0A3(c0a3); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + @RequestMapping(value = "/c0a5", method = RequestMethod.POST) | ||
| 193 | + public int c0a5(String json){ | ||
| 194 | + json = StringEscapeUtils.unescapeHtml4(json); | ||
| 195 | + return directiveService.sendC0A5(json); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * 设备参数查询 | ||
| 200 | + * @return | ||
| 201 | + */ | ||
| 202 | + @RequestMapping(value = "/deviceCofigList", method = RequestMethod.GET) | ||
| 203 | + public Map<String, Object> deviceCofigList( | ||
| 204 | + @RequestParam Map<String, String> map, | ||
| 205 | + @RequestParam(defaultValue = "0") int page, | ||
| 206 | + @RequestParam(defaultValue = "10") int size){ | ||
| 207 | + return directiveService.deviceCofigList(map, page, size); | ||
| 208 | + } | ||
| 209 | +} |
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| @@ -4,6 +4,7 @@ import ch.qos.logback.classic.Level; | @@ -4,6 +4,7 @@ import ch.qos.logback.classic.Level; | ||
| 4 | import ch.qos.logback.classic.LoggerContext; | 4 | import ch.qos.logback.classic.LoggerContext; |
| 5 | import com.bsth.common.ResponseCode; | 5 | import com.bsth.common.ResponseCode; |
| 6 | import com.bsth.data.BasicData; | 6 | import com.bsth.data.BasicData; |
| 7 | +import com.bsth.data.LineConfigData; | ||
| 7 | import com.bsth.data.SystemParamCache; | 8 | import com.bsth.data.SystemParamCache; |
| 8 | import com.bsth.data.directive.DayOfDirectives; | 9 | import com.bsth.data.directive.DayOfDirectives; |
| 9 | import com.bsth.data.directive.DirectivesPstThread; | 10 | import com.bsth.data.directive.DirectivesPstThread; |
| @@ -98,6 +99,9 @@ public class AdminUtilsController { | @@ -98,6 +99,9 @@ public class AdminUtilsController { | ||
| 98 | @Autowired | 99 | @Autowired |
| 99 | private SsoConfig ssoConfig; | 100 | private SsoConfig ssoConfig; |
| 100 | 101 | ||
| 102 | + @Autowired | ||
| 103 | + private LineConfigData lineConfigData; | ||
| 104 | + | ||
| 101 | /** | 105 | /** |
| 102 | * 出现重复班次的车辆 | 106 | * 出现重复班次的车辆 |
| 103 | * | 107 | * |
| @@ -312,6 +316,19 @@ public class AdminUtilsController { | @@ -312,6 +316,19 @@ public class AdminUtilsController { | ||
| 312 | return "error"; | 316 | return "error"; |
| 313 | } | 317 | } |
| 314 | 318 | ||
| 319 | + @RequestMapping("/reload-line-config") | ||
| 320 | + public String reloadLineConfig() { | ||
| 321 | + Map<String, Object> result = new HashMap<>(); | ||
| 322 | + try { | ||
| 323 | + lineConfigData.reload(); | ||
| 324 | + return "success"; | ||
| 325 | + } catch (Exception e) { | ||
| 326 | + e.printStackTrace(); | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + return "error"; | ||
| 330 | + } | ||
| 331 | + | ||
| 315 | @RequestMapping("/setInjectStr") | 332 | @RequestMapping("/setInjectStr") |
| 316 | public String setInjectStr(@RequestParam String injectStr) { | 333 | public String setInjectStr(@RequestParam String injectStr) { |
| 317 | Map<String, Object> result = new HashMap<>(); | 334 | Map<String, Object> result = new HashMap<>(); |
src/main/java/com/bsth/data/LineConfigData.java
| 1 | -package com.bsth.data; | ||
| 2 | - | ||
| 3 | -import com.bsth.Application; | ||
| 4 | -import com.bsth.entity.Line; | ||
| 5 | -import com.bsth.entity.realcontrol.LineConfig; | ||
| 6 | -import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 7 | -import com.bsth.service.LineService; | ||
| 8 | -import com.bsth.service.realcontrol.LineConfigService; | ||
| 9 | -import org.slf4j.Logger; | ||
| 10 | -import org.slf4j.LoggerFactory; | ||
| 11 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | -import org.springframework.boot.CommandLineRunner; | ||
| 13 | -import org.springframework.core.annotation.Order; | ||
| 14 | -import org.springframework.stereotype.Component; | ||
| 15 | - | ||
| 16 | -import java.util.*; | ||
| 17 | -import java.util.concurrent.TimeUnit; | ||
| 18 | - | ||
| 19 | -/** | ||
| 20 | - * @author PanZhao | ||
| 21 | - * @ClassName: LineConfigData | ||
| 22 | - * @Description: TODO(线路配置数据管理) | ||
| 23 | - * @date 2016年8月15日 下午2:50:19 | ||
| 24 | - */ | ||
| 25 | -@Component | ||
| 26 | -@Order(value = 2) | ||
| 27 | -public class LineConfigData implements CommandLineRunner { | ||
| 28 | - | ||
| 29 | - static Logger logger = LoggerFactory.getLogger(LineConfigData.class); | ||
| 30 | - | ||
| 31 | - // 线路编码和配置 | ||
| 32 | - private Map<String, LineConfig> lineConfMap; | ||
| 33 | - | ||
| 34 | - @Autowired | ||
| 35 | - LineConfigService lineConfigService; | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | - LineService lineService; | ||
| 39 | - | ||
| 40 | - //入库缓冲 | ||
| 41 | - static LinkedList<LineConfig> saveBuffers = new LinkedList<>(); | ||
| 42 | - | ||
| 43 | - @Autowired | ||
| 44 | - LineConfigPersistThread configPersistThread; | ||
| 45 | - | ||
| 46 | - @Override | ||
| 47 | - public void run(String... arg0) throws Exception { | ||
| 48 | - lineConfMap = new HashMap<>(); | ||
| 49 | - | ||
| 50 | - Iterator<LineConfig> itr = lineConfigService.findAll().iterator(); | ||
| 51 | - while (itr.hasNext()) | ||
| 52 | - setBuffer(itr.next()); | ||
| 53 | - | ||
| 54 | - //异步入库 | ||
| 55 | - Application.mainServices.scheduleWithFixedDelay(configPersistThread, 60, 60, TimeUnit.SECONDS); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - /** | ||
| 59 | - * 起点发出,应用缓冲区设置参数 | ||
| 60 | - * @param sch | ||
| 61 | - * @param timestamp | ||
| 62 | - * @return | ||
| 63 | - */ | ||
| 64 | - public long applyOut(ScheduleRealInfo sch, Long timestamp) { | ||
| 65 | - LineConfig config = lineConfMap.get(sch.getXlBm()); | ||
| 66 | - int diff = sch.getXlDir().equals("0")?config.getUpOutDiff():config.getDownOutDiff(); | ||
| 67 | - return timestamp - (diff * 1000); | ||
| 68 | - } | ||
| 69 | - | ||
| 70 | - /** | ||
| 71 | - * 终点到达,应用缓冲区设置参数 | ||
| 72 | - * @param sch | ||
| 73 | - * @param timestamp | ||
| 74 | - * @return | ||
| 75 | - */ | ||
| 76 | - public long applyIn(ScheduleRealInfo sch, Long timestamp){ | ||
| 77 | - LineConfig config = lineConfMap.get(sch.getXlBm()); | ||
| 78 | - int diff = sch.getXlDir().equals("0")?config.getUpInDiff():config.getDownInDiff(); | ||
| 79 | - return timestamp + (diff * 1000); | ||
| 80 | - } | ||
| 81 | - | ||
| 82 | - @Component | ||
| 83 | - private static class LineConfigPersistThread extends Thread { | ||
| 84 | - | ||
| 85 | - @Autowired | ||
| 86 | - LineConfigService lineConfigService; | ||
| 87 | - | ||
| 88 | - @Override | ||
| 89 | - public void run() { | ||
| 90 | - LineConfig config; | ||
| 91 | - for (int i = 0; i < 800; i++) { | ||
| 92 | - config = saveBuffers.poll(); | ||
| 93 | - if (config == null) | ||
| 94 | - break; | ||
| 95 | - | ||
| 96 | - try { | ||
| 97 | - lineConfigService.save(config); | ||
| 98 | - }catch (Exception e){ | ||
| 99 | - logger.error("", e); | ||
| 100 | - } | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - public LineConfig get(String lineCode) { | ||
| 106 | - return lineConfMap.get(lineCode); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - public Collection<LineConfig> getAll() { | ||
| 110 | - return lineConfMap.values(); | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - public void set(LineConfig conf) { | ||
| 114 | - //lineConfigService.save(conf); | ||
| 115 | - saveBuffers.add(conf); | ||
| 116 | - setBuffer(conf); | ||
| 117 | - } | ||
| 118 | - | ||
| 119 | - public void setBuffer(LineConfig conf) { | ||
| 120 | - lineConfMap.put(conf.getLine().getLineCode(), conf); | ||
| 121 | - } | ||
| 122 | - | ||
| 123 | - /** | ||
| 124 | - * @Title: init | ||
| 125 | - * @Description: TODO(初始化配置信息) | ||
| 126 | - */ | ||
| 127 | - public void init(String lineCode) throws Exception { | ||
| 128 | - LineConfig conf = new LineConfig(); | ||
| 129 | - //线路 | ||
| 130 | - Line line = lineService.findByLineCode(lineCode); | ||
| 131 | - if (null == line) | ||
| 132 | - throw new NullPointerException("异常的lineCode"); | ||
| 133 | - | ||
| 134 | - conf.setReadReverse(true); | ||
| 135 | - conf.setLine(line); | ||
| 136 | - //开始运营时间 | ||
| 137 | - conf.setStartOpt("02:00"); | ||
| 138 | - //出场时间类型 | ||
| 139 | - conf.setOutConfig(0); | ||
| 140 | - //调度指令模板 | ||
| 141 | - conf.setSchDirectiveTemp(""); | ||
| 142 | - | ||
| 143 | - //应急停靠默认值 | ||
| 144 | - conf.setYjtkStart("00:00"); | ||
| 145 | - conf.setYjtkEnd("23:59"); | ||
| 146 | - | ||
| 147 | - set(conf); | ||
| 148 | - } | ||
| 149 | -} | 1 | +package com.bsth.data; |
| 2 | + | ||
| 3 | +import com.bsth.Application; | ||
| 4 | +import com.bsth.entity.Line; | ||
| 5 | +import com.bsth.entity.realcontrol.LineConfig; | ||
| 6 | +import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 7 | +import com.bsth.service.LineService; | ||
| 8 | +import com.bsth.service.realcontrol.LineConfigService; | ||
| 9 | +import org.slf4j.Logger; | ||
| 10 | +import org.slf4j.LoggerFactory; | ||
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 12 | +import org.springframework.boot.CommandLineRunner; | ||
| 13 | +import org.springframework.core.annotation.Order; | ||
| 14 | +import org.springframework.stereotype.Component; | ||
| 15 | + | ||
| 16 | +import java.util.*; | ||
| 17 | +import java.util.concurrent.TimeUnit; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * @author PanZhao | ||
| 21 | + * @ClassName: LineConfigData | ||
| 22 | + * @Description: TODO(线路配置数据管理) | ||
| 23 | + * @date 2016年8月15日 下午2:50:19 | ||
| 24 | + */ | ||
| 25 | +@Component | ||
| 26 | +@Order(value = 2) | ||
| 27 | +public class LineConfigData implements CommandLineRunner { | ||
| 28 | + | ||
| 29 | + static Logger logger = LoggerFactory.getLogger(LineConfigData.class); | ||
| 30 | + | ||
| 31 | + // 线路编码和配置 | ||
| 32 | + private Map<String, LineConfig> lineConfMap; | ||
| 33 | + | ||
| 34 | + @Autowired | ||
| 35 | + LineConfigService lineConfigService; | ||
| 36 | + | ||
| 37 | + @Autowired | ||
| 38 | + LineService lineService; | ||
| 39 | + | ||
| 40 | + //入库缓冲 | ||
| 41 | + static LinkedList<LineConfig> saveBuffers = new LinkedList<>(); | ||
| 42 | + | ||
| 43 | + @Autowired | ||
| 44 | + LineConfigPersistThread configPersistThread; | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public void run(String... arg0) throws Exception { | ||
| 48 | + lineConfMap = new HashMap<>(); | ||
| 49 | + | ||
| 50 | + Iterator<LineConfig> itr = lineConfigService.findAll().iterator(); | ||
| 51 | + while (itr.hasNext()) | ||
| 52 | + setBuffer(itr.next()); | ||
| 53 | + | ||
| 54 | + //异步入库 | ||
| 55 | + Application.mainServices.scheduleWithFixedDelay(configPersistThread, 60, 60, TimeUnit.SECONDS); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 起点发出,应用缓冲区设置参数 | ||
| 60 | + * @param sch | ||
| 61 | + * @param timestamp | ||
| 62 | + * @return | ||
| 63 | + */ | ||
| 64 | + public long applyOut(ScheduleRealInfo sch, Long timestamp) { | ||
| 65 | + LineConfig config = lineConfMap.get(sch.getXlBm()); | ||
| 66 | + int diff = sch.getXlDir().equals("0")?config.getUpOutDiff():config.getDownOutDiff(); | ||
| 67 | + return timestamp - (diff * 1000); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 终点到达,应用缓冲区设置参数 | ||
| 72 | + * @param sch | ||
| 73 | + * @param timestamp | ||
| 74 | + * @return | ||
| 75 | + */ | ||
| 76 | + public long applyIn(ScheduleRealInfo sch, Long timestamp){ | ||
| 77 | + LineConfig config = lineConfMap.get(sch.getXlBm()); | ||
| 78 | + int diff = sch.getXlDir().equals("0")?config.getUpInDiff():config.getDownInDiff(); | ||
| 79 | + return timestamp + (diff * 1000); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Component | ||
| 83 | + private static class LineConfigPersistThread extends Thread { | ||
| 84 | + | ||
| 85 | + @Autowired | ||
| 86 | + LineConfigService lineConfigService; | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public void run() { | ||
| 90 | + LineConfig config; | ||
| 91 | + for (int i = 0; i < 800; i++) { | ||
| 92 | + config = saveBuffers.poll(); | ||
| 93 | + if (config == null) | ||
| 94 | + break; | ||
| 95 | + | ||
| 96 | + try { | ||
| 97 | + lineConfigService.save(config); | ||
| 98 | + }catch (Exception e){ | ||
| 99 | + logger.error("", e); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public LineConfig get(String lineCode) { | ||
| 106 | + return lineConfMap.get(lineCode); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public Collection<LineConfig> getAll() { | ||
| 110 | + return lineConfMap.values(); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void set(LineConfig conf) { | ||
| 114 | + //lineConfigService.save(conf); | ||
| 115 | + saveBuffers.add(conf); | ||
| 116 | + setBuffer(conf); | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + public void setBuffer(LineConfig conf) { | ||
| 120 | + lineConfMap.put(conf.getLine().getLineCode(), conf); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * @Title: init | ||
| 125 | + * @Description: TODO(初始化配置信息) | ||
| 126 | + */ | ||
| 127 | + public void init(String lineCode) throws Exception { | ||
| 128 | + LineConfig conf = new LineConfig(); | ||
| 129 | + //线路 | ||
| 130 | + Line line = lineService.findByLineCode(lineCode); | ||
| 131 | + if (null == line) | ||
| 132 | + throw new NullPointerException("异常的lineCode"); | ||
| 133 | + | ||
| 134 | + conf.setReadReverse(true); | ||
| 135 | + conf.setLine(line); | ||
| 136 | + //开始运营时间 | ||
| 137 | + conf.setStartOpt("02:00"); | ||
| 138 | + //出场时间类型 | ||
| 139 | + conf.setOutConfig(0); | ||
| 140 | + //调度指令模板 | ||
| 141 | + conf.setSchDirectiveTemp(""); | ||
| 142 | + | ||
| 143 | + //应急停靠默认值 | ||
| 144 | + conf.setYjtkStart("00:00"); | ||
| 145 | + conf.setYjtkEnd("23:59"); | ||
| 146 | + | ||
| 147 | + set(conf); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + /** | ||
| 151 | + * 重新从数据库加载 | ||
| 152 | + */ | ||
| 153 | + public void reload() { | ||
| 154 | + Iterator<LineConfig> itr = lineConfigService.findAll().iterator(); | ||
| 155 | + while (itr.hasNext()) | ||
| 156 | + setBuffer(itr.next()); | ||
| 157 | + } | ||
| 158 | +} |
src/main/java/com/bsth/data/directive/DayOfDirectives.java
| @@ -142,10 +142,6 @@ public class DayOfDirectives { | @@ -142,10 +142,6 @@ public class DayOfDirectives { | ||
| 142 | logger.warn("64响应 data is null ,json: " + json); | 142 | logger.warn("64响应 data is null ,json: " + json); |
| 143 | else { | 143 | else { |
| 144 | logger.info(d64.getDeviceId() + "_" + d64.getData().getLineId() + "响应:" + data.getShort("requestAck")); | 144 | logger.info(d64.getDeviceId() + "_" + d64.getData().getLineId() + "响应:" + data.getShort("requestAck")); |
| 145 | - ScheduleRealInfo sch = d64.getSch(); | ||
| 146 | - if (sch != null) { | ||
| 147 | - sch.setRegionSwitchState(1); | ||
| 148 | - } | ||
| 149 | /*d64.setRespAck(data.getShort("requestAck")); | 145 | /*d64.setRespAck(data.getShort("requestAck")); |
| 150 | // 持久化*/ | 146 | // 持久化*/ |
| 151 | //64 响应不入库了... | 147 | //64 响应不入库了... |
src/main/java/com/bsth/data/directive/DirectiveCreator.java
| @@ -136,7 +136,7 @@ public class DirectiveCreator { | @@ -136,7 +136,7 @@ public class DirectiveCreator { | ||
| 136 | return create64(deviceId, lineCode, t); | 136 | return create64(deviceId, lineCode, t); |
| 137 | }*/ | 137 | }*/ |
| 138 | 138 | ||
| 139 | - public D64 create64(String deviceId, String lineCode, ScheduleRealInfo sch, long t){ | 139 | + public D64 create64(String deviceId, String lineCode, long t, int seq){ |
| 140 | D64 change = new D64(); | 140 | D64 change = new D64(); |
| 141 | D64Data data = new D64Data(); | 141 | D64Data data = new D64Data(); |
| 142 | data.setCityCode(cityCode); | 142 | data.setCityCode(cityCode); |
| @@ -145,20 +145,12 @@ public class DirectiveCreator { | @@ -145,20 +145,12 @@ public class DirectiveCreator { | ||
| 145 | //线路编码补满6位数 | 145 | //线路编码补满6位数 |
| 146 | String lineCodeStr = padLeft(lineCode, 6, '0'); | 146 | String lineCodeStr = padLeft(lineCode, 6, '0'); |
| 147 | data.setLineId(lineCodeStr); | 147 | data.setLineId(lineCodeStr); |
| 148 | - int seq = 0; | ||
| 149 | - if (sch != null) { | ||
| 150 | - String regionId = sch.getLineRegion(); | ||
| 151 | - if (StringUtils.hasText(regionId)) { | ||
| 152 | - seq = Integer.parseInt(regionId.split("_")[1]); | ||
| 153 | - } | ||
| 154 | - } | ||
| 155 | data.setSeq(seq); | 148 | data.setSeq(seq); |
| 156 | 149 | ||
| 157 | change.setDeviceId(deviceId); | 150 | change.setDeviceId(deviceId); |
| 158 | change.setOperCode((short) 0X64); | 151 | change.setOperCode((short) 0X64); |
| 159 | change.setTimestamp(t); | 152 | change.setTimestamp(t); |
| 160 | change.setData(data); | 153 | change.setData(data); |
| 161 | - change.setSch(sch); | ||
| 162 | 154 | ||
| 163 | return change; | 155 | return change; |
| 164 | } | 156 | } |
| @@ -169,9 +161,10 @@ public class DirectiveCreator { | @@ -169,9 +161,10 @@ public class DirectiveCreator { | ||
| 169 | * @Description: TODO(线路刷新指令(用于切换线路后,要求设置重新下载线路文件)) | 161 | * @Description: TODO(线路刷新指令(用于切换线路后,要求设置重新下载线路文件)) |
| 170 | * @param @param deviceId 设备编号 | 162 | * @param @param deviceId 设备编号 |
| 171 | * @param @param lineId 线路ID | 163 | * @param @param lineId 线路ID |
| 164 | + * @param seq 子线路 | ||
| 172 | * @throws | 165 | * @throws |
| 173 | */ | 166 | */ |
| 174 | - public String createDeviceRefreshData(String deviceId, String lineCode) { | 167 | + public String createDeviceRefreshData(String deviceId, String lineCode, int seq) { |
| 175 | Long t = System.currentTimeMillis(); | 168 | Long t = System.currentTimeMillis(); |
| 176 | Map<String, Object> param = new HashMap<>(); | 169 | Map<String, Object> param = new HashMap<>(); |
| 177 | param.put("deviceId", deviceId); | 170 | param.put("deviceId", deviceId); |
| @@ -189,7 +182,7 @@ public class DirectiveCreator { | @@ -189,7 +182,7 @@ public class DirectiveCreator { | ||
| 189 | String lineCodeStr = padLeft(lineCode, 6, '0'); | 182 | String lineCodeStr = padLeft(lineCode, 6, '0'); |
| 190 | 183 | ||
| 191 | data.put("lineId", lineCodeStr); | 184 | data.put("lineId", lineCodeStr); |
| 192 | - data.put("lineVersion", 0); | 185 | + data.put("lineVersion", seq); |
| 193 | data.put("carparkDataVersion", 0); | 186 | data.put("carparkDataVersion", 0); |
| 194 | param.put("data", data); | 187 | param.put("data", data); |
| 195 | 188 |
src/main/java/com/bsth/data/forecast/ArrivalDataLoader.java
| 1 | -package com.bsth.data.forecast; | ||
| 2 | - | ||
| 3 | -import com.bsth.data.BasicData; | ||
| 4 | -import com.bsth.data.LineConfigData; | ||
| 5 | -import com.bsth.data.forecast.entity.ArrivalEntity; | ||
| 6 | -import com.bsth.util.db.DBUtils_MS; | ||
| 7 | -import org.slf4j.Logger; | ||
| 8 | -import org.slf4j.LoggerFactory; | ||
| 9 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | -import org.springframework.stereotype.Component; | ||
| 11 | - | ||
| 12 | -import java.sql.Connection; | ||
| 13 | -import java.sql.PreparedStatement; | ||
| 14 | -import java.sql.ResultSet; | ||
| 15 | -import java.sql.SQLException; | ||
| 16 | -import java.util.ArrayList; | ||
| 17 | -import java.util.Calendar; | ||
| 18 | -import java.util.List; | ||
| 19 | - | ||
| 20 | -/** | ||
| 21 | - * | ||
| 22 | - * @ClassName: DataLoader | ||
| 23 | - * @Description: TODO(从数据库加载进出站数据) | ||
| 24 | - * @author PanZhao | ||
| 25 | - * @date 2016年8月19日 上午9:59:21 | ||
| 26 | - * | ||
| 27 | - */ | ||
| 28 | -@Component | ||
| 29 | -public class ArrivalDataLoader { | ||
| 30 | - | ||
| 31 | - private static Long prveLoadTime; | ||
| 32 | - | ||
| 33 | - private final static long DAY_TIME = 1000 * 60 * 60 * 24; | ||
| 34 | - | ||
| 35 | - private Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | - LineConfigData lineConfigData; | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * | ||
| 42 | - * @Title: load | ||
| 43 | - * @Description: TODO(根据上次加载时间,查询之后的增量数据) | ||
| 44 | - | ||
| 45 | - public List<ArrivalEntity> load(){ | ||
| 46 | - List<ArrivalEntity> list = null; | ||
| 47 | - | ||
| 48 | - if(null == prveLoadTime) | ||
| 49 | - list = recovery(); | ||
| 50 | - else{ | ||
| 51 | - Calendar cal = Calendar.getInstance(); | ||
| 52 | - //周数,表分区字段 | ||
| 53 | - int weeks_year = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 54 | - | ||
| 55 | - Connection conn = null; | ||
| 56 | - PreparedStatement ps = null; | ||
| 57 | - ResultSet rs = null; | ||
| 58 | - | ||
| 59 | - String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by create_date"; | ||
| 60 | - try{ | ||
| 61 | - long t = System.currentTimeMillis(); | ||
| 62 | - | ||
| 63 | - conn = DBUtils_MS.getConnection(); | ||
| 64 | - ps = conn.prepareStatement(sql); | ||
| 65 | - ps.setInt(1, weeks_year); | ||
| 66 | - ps.setLong(2, prveLoadTime); | ||
| 67 | - ps.setLong(3, t); | ||
| 68 | - rs = ps.executeQuery(); | ||
| 69 | - | ||
| 70 | - list = resultSet2Set(rs); | ||
| 71 | - | ||
| 72 | - prveLoadTime = t; | ||
| 73 | - }catch(Exception e){ | ||
| 74 | - logger.error("", e); | ||
| 75 | - }finally { | ||
| 76 | - DBUtils_MS.close(rs, ps, conn); | ||
| 77 | - } | ||
| 78 | - } | ||
| 79 | - return list; | ||
| 80 | - }*/ | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * | ||
| 84 | - * @Title: recovery | ||
| 85 | - * @Description: TODO(从数据库恢复数据,按照线路的开始运营时间恢复) | ||
| 86 | - | ||
| 87 | - public List<ArrivalEntity> recovery(){ | ||
| 88 | - Collection<LineConfig> confs = lineConfigData.getAll(); | ||
| 89 | - long t = System.currentTimeMillis() | ||
| 90 | - ,st; | ||
| 91 | - | ||
| 92 | - List<ArrivalEntity> all = new ArrayList<>(); | ||
| 93 | - for(LineConfig conf : confs){ | ||
| 94 | - st = conf.getCurrStartTime(); | ||
| 95 | - if(t < st) | ||
| 96 | - st = st - DAY_TIME; | ||
| 97 | - try{ | ||
| 98 | - all.addAll(loadByLineAndTime(conf.getLine().getLineCode(), st, t)); | ||
| 99 | - }catch(Exception e){ | ||
| 100 | - logger.error("", e); | ||
| 101 | - } | ||
| 102 | - } | ||
| 103 | - | ||
| 104 | - prveLoadTime = t; | ||
| 105 | - return all; | ||
| 106 | - }*/ | ||
| 107 | - | ||
| 108 | - /** | ||
| 109 | - * | ||
| 110 | - * @Title: loadByLineAndStartTime | ||
| 111 | - * @Description: TODO(根据线路和时间戳加载数据) | ||
| 112 | - */ | ||
| 113 | - public List<ArrivalEntity> loadByLineAndTime(String lineCode, long st, long et){ | ||
| 114 | - Calendar cal = Calendar.getInstance(); | ||
| 115 | - cal.setTimeInMillis(st); | ||
| 116 | - int weeks_year = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 117 | - | ||
| 118 | - Connection conn = null; | ||
| 119 | - PreparedStatement ps = null; | ||
| 120 | - ResultSet rs = null; | ||
| 121 | - | ||
| 122 | - List<ArrivalEntity> list = new ArrayList<>(); | ||
| 123 | - String sql = "select * from bsth_c_arrival_info where weeks_year=? and line_id=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | ||
| 124 | - try{ | ||
| 125 | - conn = DBUtils_MS.getConnection(); | ||
| 126 | - ps = conn.prepareStatement(sql); | ||
| 127 | - ps.setInt(1, weeks_year); | ||
| 128 | - ps.setString(2, lineCode); | ||
| 129 | - ps.setLong(3, st); | ||
| 130 | - ps.setLong(4, et); | ||
| 131 | - rs = ps.executeQuery(); | ||
| 132 | - | ||
| 133 | - list = resultSet2Set(rs); | ||
| 134 | - }catch(Exception e){ | ||
| 135 | - logger.error("", e); | ||
| 136 | - }finally { | ||
| 137 | - DBUtils_MS.close(rs, ps, conn); | ||
| 138 | - } | ||
| 139 | - return list; | ||
| 140 | - } | ||
| 141 | - | ||
| 142 | - /** | ||
| 143 | - * | ||
| 144 | - * @Title: loadByLineAndStartTime | ||
| 145 | - * @Description: TODO(根据线路,走向和时间戳加载数据) | ||
| 146 | - */ | ||
| 147 | - public List<ArrivalEntity> loadByLineAndTime(String lineCode, int updown, long st, long et){ | ||
| 148 | - Calendar cal = Calendar.getInstance(); | ||
| 149 | - cal.setTimeInMillis(st); | ||
| 150 | - int weeks_year = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 151 | - | ||
| 152 | - Connection conn = null; | ||
| 153 | - PreparedStatement ps = null; | ||
| 154 | - ResultSet rs = null; | ||
| 155 | - | ||
| 156 | - List<ArrivalEntity> list = new ArrayList<>(); | ||
| 157 | - String sql = "select * from bsth_c_arrival_info where weeks_year=? and line_id=? and up_down=? and in_out=0 AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | ||
| 158 | - try{ | ||
| 159 | - conn = DBUtils_MS.getConnection(); | ||
| 160 | - ps = conn.prepareStatement(sql); | ||
| 161 | - ps.setInt(1, weeks_year); | ||
| 162 | - ps.setString(2, lineCode); | ||
| 163 | - ps.setInt(3, updown); | ||
| 164 | - ps.setLong(4, st); | ||
| 165 | - ps.setLong(5, et); | ||
| 166 | - rs = ps.executeQuery(); | ||
| 167 | - | ||
| 168 | - list = resultSet2Set(rs); | ||
| 169 | - }catch(Exception e){ | ||
| 170 | - logger.error("", e); | ||
| 171 | - }finally { | ||
| 172 | - DBUtils_MS.close(rs, ps, conn); | ||
| 173 | - } | ||
| 174 | - return list; | ||
| 175 | - } | ||
| 176 | - | ||
| 177 | - public List<ArrivalEntity> resultSet2Set(ResultSet rs) throws SQLException{ | ||
| 178 | - List<ArrivalEntity> list = new ArrayList<>(); | ||
| 179 | - | ||
| 180 | - ArrivalEntity arr; | ||
| 181 | - while(rs.next()){ | ||
| 182 | - arr = new ArrivalEntity(); | ||
| 183 | - arr.setDeviceId(rs.getString("device_id")); | ||
| 184 | - arr.setNbbm(BasicData.deviceId2NbbmMap.get(arr.getDeviceId())); | ||
| 185 | - if(null == arr.getNbbm()){ | ||
| 186 | - logger.warn("未注册的设备号," + arr.getDeviceId()); | ||
| 187 | - continue; | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - arr.setTs(rs.getLong("ts")); | ||
| 191 | - arr.setLineCode(rs.getString("line_id")); | ||
| 192 | - arr.setUpDown(rs.getInt("up_down")); | ||
| 193 | - arr.setStopNo(rs.getString("stop_no")); | ||
| 194 | - arr.setStopName(BasicData.stationCode2NameMap.get(arr.getStopNo())); | ||
| 195 | - arr.setInOut(rs.getInt("in_out")); | ||
| 196 | - arr.setCreateDate(rs.getLong("create_timestamp")); | ||
| 197 | - arr.setWeeksYear(rs.getInt("weeks_year")); | ||
| 198 | - arr.setEnable(true); | ||
| 199 | - | ||
| 200 | - list.add(arr); | ||
| 201 | - } | ||
| 202 | - return list; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - public static void setPrveLoadTime(long t){ | ||
| 206 | - prveLoadTime = t; | ||
| 207 | - } | ||
| 208 | -} | 1 | +package com.bsth.data.forecast; |
| 2 | + | ||
| 3 | +import com.bsth.data.BasicData; | ||
| 4 | +import com.bsth.data.LineConfigData; | ||
| 5 | +import com.bsth.data.forecast.entity.ArrivalEntity; | ||
| 6 | +import com.bsth.util.db.DBUtils_MS; | ||
| 7 | +import org.joda.time.DateTime; | ||
| 8 | +import org.slf4j.Logger; | ||
| 9 | +import org.slf4j.LoggerFactory; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | + | ||
| 13 | +import java.sql.Connection; | ||
| 14 | +import java.sql.PreparedStatement; | ||
| 15 | +import java.sql.ResultSet; | ||
| 16 | +import java.sql.SQLException; | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.Calendar; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * | ||
| 23 | + * @ClassName: DataLoader | ||
| 24 | + * @Description: TODO(从数据库加载进出站数据) | ||
| 25 | + * @author PanZhao | ||
| 26 | + * @date 2016年8月19日 上午9:59:21 | ||
| 27 | + * | ||
| 28 | + */ | ||
| 29 | +@Component | ||
| 30 | +public class ArrivalDataLoader { | ||
| 31 | + | ||
| 32 | + private static Long prveLoadTime; | ||
| 33 | + | ||
| 34 | + private final static long DAY_TIME = 1000 * 60 * 60 * 24; | ||
| 35 | + | ||
| 36 | + private Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + LineConfigData lineConfigData; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * | ||
| 43 | + * @Title: load | ||
| 44 | + * @Description: TODO(根据上次加载时间,查询之后的增量数据) | ||
| 45 | + | ||
| 46 | + public List<ArrivalEntity> load(){ | ||
| 47 | + List<ArrivalEntity> list = null; | ||
| 48 | + | ||
| 49 | + if(null == prveLoadTime) | ||
| 50 | + list = recovery(); | ||
| 51 | + else{ | ||
| 52 | + Calendar cal = Calendar.getInstance(); | ||
| 53 | + //周数,表分区字段 | ||
| 54 | + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 55 | + | ||
| 56 | + Connection conn = null; | ||
| 57 | + PreparedStatement ps = null; | ||
| 58 | + ResultSet rs = null; | ||
| 59 | + | ||
| 60 | + String sql = "select * from bsth_c_arrival_info where weeks_year=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by create_date"; | ||
| 61 | + try{ | ||
| 62 | + long t = System.currentTimeMillis(); | ||
| 63 | + | ||
| 64 | + conn = DBUtils_MS.getConnection(); | ||
| 65 | + ps = conn.prepareStatement(sql); | ||
| 66 | + ps.setInt(1, weeks_year); | ||
| 67 | + ps.setLong(2, prveLoadTime); | ||
| 68 | + ps.setLong(3, t); | ||
| 69 | + rs = ps.executeQuery(); | ||
| 70 | + | ||
| 71 | + list = resultSet2Set(rs); | ||
| 72 | + | ||
| 73 | + prveLoadTime = t; | ||
| 74 | + }catch(Exception e){ | ||
| 75 | + logger.error("", e); | ||
| 76 | + }finally { | ||
| 77 | + DBUtils_MS.close(rs, ps, conn); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + return list; | ||
| 81 | + }*/ | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * | ||
| 85 | + * @Title: recovery | ||
| 86 | + * @Description: TODO(从数据库恢复数据,按照线路的开始运营时间恢复) | ||
| 87 | + | ||
| 88 | + public List<ArrivalEntity> recovery(){ | ||
| 89 | + Collection<LineConfig> confs = lineConfigData.getAll(); | ||
| 90 | + long t = System.currentTimeMillis() | ||
| 91 | + ,st; | ||
| 92 | + | ||
| 93 | + List<ArrivalEntity> all = new ArrayList<>(); | ||
| 94 | + for(LineConfig conf : confs){ | ||
| 95 | + st = conf.getCurrStartTime(); | ||
| 96 | + if(t < st) | ||
| 97 | + st = st - DAY_TIME; | ||
| 98 | + try{ | ||
| 99 | + all.addAll(loadByLineAndTime(conf.getLine().getLineCode(), st, t)); | ||
| 100 | + }catch(Exception e){ | ||
| 101 | + logger.error("", e); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + prveLoadTime = t; | ||
| 106 | + return all; | ||
| 107 | + }*/ | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * | ||
| 111 | + * @Title: loadByLineAndStartTime | ||
| 112 | + * @Description: TODO(根据线路和时间戳加载数据) | ||
| 113 | + */ | ||
| 114 | + public List<ArrivalEntity> loadByLineAndTime(String lineCode, long st, long et){ | ||
| 115 | + Calendar cal = Calendar.getInstance(); | ||
| 116 | + cal.setTimeInMillis(st); | ||
| 117 | + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 118 | + | ||
| 119 | + Connection conn = null; | ||
| 120 | + PreparedStatement ps = null; | ||
| 121 | + ResultSet rs = null; | ||
| 122 | + | ||
| 123 | + List<ArrivalEntity> list = new ArrayList<>(); | ||
| 124 | + String sql = "select * from bsth_c_arrival_info where weeks_year=? and line_id=? AND create_timestamp > ? AND create_timestamp <=? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | ||
| 125 | + try{ | ||
| 126 | + conn = DBUtils_MS.getConnection(); | ||
| 127 | + ps = conn.prepareStatement(sql); | ||
| 128 | + ps.setInt(1, weeks_year); | ||
| 129 | + ps.setString(2, lineCode); | ||
| 130 | + ps.setLong(3, st); | ||
| 131 | + ps.setLong(4, et); | ||
| 132 | + rs = ps.executeQuery(); | ||
| 133 | + | ||
| 134 | + list = resultSet2Set(rs); | ||
| 135 | + }catch(Exception e){ | ||
| 136 | + logger.error("", e); | ||
| 137 | + }finally { | ||
| 138 | + DBUtils_MS.close(rs, ps, conn); | ||
| 139 | + } | ||
| 140 | + return list; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * | ||
| 145 | + * @Title: loadByLineAndStartTime | ||
| 146 | + * @Description: TODO(根据线路,走向和时间戳加载数据) | ||
| 147 | + */ | ||
| 148 | + public List<ArrivalEntity> loadByLineAndTime(String lineCode, int updown, long st, long et){ | ||
| 149 | + DateTime start = new DateTime(st), end = new DateTime(et); | ||
| 150 | + if (start.getYear() != end.getYear()) { | ||
| 151 | + throw new IllegalArgumentException("请选择同一年"); | ||
| 152 | + } | ||
| 153 | + if (et - st > 14 * 24 * 60 * 60 * 1000) { | ||
| 154 | + throw new IllegalArgumentException("时间区间过长"); | ||
| 155 | + } | ||
| 156 | + Calendar cal = Calendar.getInstance(); | ||
| 157 | + cal.setTimeInMillis(st); | ||
| 158 | + int weeksYear1 = cal.get(Calendar.WEEK_OF_YEAR), weeksYear2 = cal.get(Calendar.WEEK_OF_YEAR); | ||
| 159 | + | ||
| 160 | + Connection conn = null; | ||
| 161 | + PreparedStatement ps = null; | ||
| 162 | + ResultSet rs = null; | ||
| 163 | + | ||
| 164 | + List<ArrivalEntity> list = new ArrayList<>(); | ||
| 165 | + String sql = "select * from bsth_c_arrival_info_" + start.getYear() + " where weeks_year between ? and ? and line_id=? and up_down=? and in_out=0 AND create_timestamp BETWEEN ? AND ? AND ABS(create_timestamp - ts) < 3600000 order by ts"; | ||
| 166 | + try{ | ||
| 167 | + conn = DBUtils_MS.getConnection(); | ||
| 168 | + ps = conn.prepareStatement(sql); | ||
| 169 | + ps.setInt(1, weeksYear1); | ||
| 170 | + ps.setInt(2, weeksYear2); | ||
| 171 | + ps.setString(3, lineCode); | ||
| 172 | + ps.setInt(4, updown); | ||
| 173 | + ps.setLong(5, st); | ||
| 174 | + ps.setLong(6, et); | ||
| 175 | + rs = ps.executeQuery(); | ||
| 176 | + | ||
| 177 | + list = resultSet2Set(rs); | ||
| 178 | + }catch(Exception e){ | ||
| 179 | + logger.error("", e); | ||
| 180 | + }finally { | ||
| 181 | + DBUtils_MS.close(rs, ps, conn); | ||
| 182 | + } | ||
| 183 | + return list; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + public List<ArrivalEntity> resultSet2Set(ResultSet rs) throws SQLException{ | ||
| 187 | + List<ArrivalEntity> list = new ArrayList<>(); | ||
| 188 | + | ||
| 189 | + ArrivalEntity arr; | ||
| 190 | + while(rs.next()){ | ||
| 191 | + arr = new ArrivalEntity(); | ||
| 192 | + arr.setDeviceId(rs.getString("device_id")); | ||
| 193 | + arr.setNbbm(BasicData.deviceId2NbbmMap.get(arr.getDeviceId())); | ||
| 194 | + if(null == arr.getNbbm()){ | ||
| 195 | + logger.warn("未注册的设备号," + arr.getDeviceId()); | ||
| 196 | + continue; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + arr.setTs(rs.getLong("ts")); | ||
| 200 | + arr.setLineCode(rs.getString("line_id")); | ||
| 201 | + arr.setUpDown(rs.getInt("up_down")); | ||
| 202 | + arr.setStopNo(rs.getString("stop_no")); | ||
| 203 | + arr.setStopName(BasicData.stationCode2NameMap.get(arr.getStopNo())); | ||
| 204 | + arr.setInOut(rs.getInt("in_out")); | ||
| 205 | + arr.setCreateDate(rs.getLong("create_timestamp")); | ||
| 206 | + arr.setWeeksYear(rs.getInt("weeks_year")); | ||
| 207 | + arr.setEnable(true); | ||
| 208 | + | ||
| 209 | + list.add(arr); | ||
| 210 | + } | ||
| 211 | + return list; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + public static void setPrveLoadTime(long t){ | ||
| 215 | + prveLoadTime = t; | ||
| 216 | + } | ||
| 217 | +} |
src/main/java/com/bsth/data/gpsdata_v2/entity/GpsEntity.java
| @@ -20,6 +20,11 @@ public class GpsEntity implements Cloneable{ | @@ -20,6 +20,11 @@ public class GpsEntity implements Cloneable{ | ||
| 20 | /** 线路编码 */ | 20 | /** 线路编码 */ |
| 21 | private String lineId; | 21 | private String lineId; |
| 22 | 22 | ||
| 23 | + /** | ||
| 24 | + * 子线路ID | ||
| 25 | + */ | ||
| 26 | + private int subLineId; | ||
| 27 | + | ||
| 23 | /** 设备编码 */ | 28 | /** 设备编码 */ |
| 24 | private String deviceId; | 29 | private String deviceId; |
| 25 | 30 | ||
| @@ -228,6 +233,14 @@ public class GpsEntity implements Cloneable{ | @@ -228,6 +233,14 @@ public class GpsEntity implements Cloneable{ | ||
| 228 | this.lineId = lineId; | 233 | this.lineId = lineId; |
| 229 | } | 234 | } |
| 230 | 235 | ||
| 236 | + public int getSubLineId() { | ||
| 237 | + return subLineId; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + public void setSubLineId(int subLineId) { | ||
| 241 | + this.subLineId = subLineId; | ||
| 242 | + } | ||
| 243 | + | ||
| 231 | public Long getSchId() { | 244 | public Long getSchId() { |
| 232 | return schId; | 245 | return schId; |
| 233 | } | 246 | } |
src/main/java/com/bsth/data/gpsdata_v2/handlers/GpsStateProcess.java
| @@ -75,7 +75,12 @@ public class GpsStateProcess { | @@ -75,7 +75,12 @@ public class GpsStateProcess { | ||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | // 线路编码不一致或者未接收到切换区间线的响应 | 77 | // 线路编码不一致或者未接收到切换区间线的响应 |
| 78 | - if (!sch.getXlBm().equals(gps.getLineId()) || StringUtils.hasText(sch.getLineRegion()) && sch.getRegionSwitchState() == 0) { | 78 | + String regionId = sch.getLineRegion(); |
| 79 | + int seq = 0; | ||
| 80 | + if (!StringUtils.isEmpty(regionId)) { | ||
| 81 | + seq = Integer.parseInt(regionId.split("_")[1]); | ||
| 82 | + } | ||
| 83 | + if (!sch.getXlBm().equals(gps.getLineId()) || gps.getSubLineId() != seq) { | ||
| 79 | //切换车载的 线路编码 | 84 | //切换车载的 线路编码 |
| 80 | gpsStatusManager.changeLine(gps.getNbbm(), sch, "同步@系统"); | 85 | gpsStatusManager.changeLine(gps.getNbbm(), sch, "同步@系统"); |
| 81 | } | 86 | } |
src/main/java/com/bsth/data/msg_queue/DirectivePushQueue.java
| @@ -159,7 +159,7 @@ public class DirectivePushQueue implements ApplicationContextAware { | @@ -159,7 +159,7 @@ public class DirectivePushQueue implements ApplicationContextAware { | ||
| 159 | log.info("directive 60_03 nbbm: " + qd.getNbbm()); | 159 | log.info("directive 60_03 nbbm: " + qd.getNbbm()); |
| 160 | } | 160 | } |
| 161 | else if(code.equals("64")){ | 161 | else if(code.equals("64")){ |
| 162 | - directiveService.lineChange(qd.getNbbm(), qd.getLineCode(), qd.getSch(), qd.getSender()); | 162 | + directiveService.lineChange(qd.getNbbm(), qd.getLineCode(), qd.getSender(), qd.getSch().getLineRegion()); |
| 163 | log.info("directive 64 nbbm: " + qd.getNbbm() + " lineCode: " + qd.getLineCode()); | 163 | log.info("directive 64 nbbm: " + qd.getNbbm() + " lineCode: " + qd.getLineCode()); |
| 164 | } | 164 | } |
| 165 | 165 |
src/main/java/com/bsth/entity/directive/D64.java
| @@ -29,10 +29,6 @@ public class D64 extends Directive{ | @@ -29,10 +29,6 @@ public class D64 extends Directive{ | ||
| 29 | 29 | ||
| 30 | private D64Data data; | 30 | private D64Data data; |
| 31 | 31 | ||
| 32 | - @Transient | ||
| 33 | - @JsonIgnore | ||
| 34 | - private ScheduleRealInfo sch; | ||
| 35 | - | ||
| 36 | @Embeddable | 32 | @Embeddable |
| 37 | public static class D64Data { | 33 | public static class D64Data { |
| 38 | 34 | ||
| @@ -115,14 +111,6 @@ public class D64 extends Directive{ | @@ -115,14 +111,6 @@ public class D64 extends Directive{ | ||
| 115 | this.respAck = respAck; | 111 | this.respAck = respAck; |
| 116 | } | 112 | } |
| 117 | 113 | ||
| 118 | - public ScheduleRealInfo getSch() { | ||
| 119 | - return sch; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - public void setSch(ScheduleRealInfo sch) { | ||
| 123 | - this.sch = sch; | ||
| 124 | - } | ||
| 125 | - | ||
| 126 | @Override | 114 | @Override |
| 127 | public void setDeviceId(String deviceId) { | 115 | public void setDeviceId(String deviceId) { |
| 128 | if(this.data != null) | 116 | if(this.data != null) |
src/main/java/com/bsth/entity/realcontrol/ScheduleRealInfo.java
| @@ -268,12 +268,6 @@ public class ScheduleRealInfo implements Cloneable{ | @@ -268,12 +268,6 @@ public class ScheduleRealInfo implements Cloneable{ | ||
| 268 | private String blockStations; | 268 | private String blockStations; |
| 269 | 269 | ||
| 270 | /** | 270 | /** |
| 271 | - * 区间切换状态 0 未发或未成功 1 成功 | ||
| 272 | - */ | ||
| 273 | - @Transient | ||
| 274 | - private int regionSwitchState; | ||
| 275 | - | ||
| 276 | - /** | ||
| 277 | *大客流进度 0下发驾驶员,1下发车辆,2,班次就位 | 271 | *大客流进度 0下发驾驶员,1下发车辆,2,班次就位 |
| 278 | */ | 272 | */ |
| 279 | @Transient | 273 | @Transient |
| @@ -1102,14 +1096,6 @@ public class ScheduleRealInfo implements Cloneable{ | @@ -1102,14 +1096,6 @@ public class ScheduleRealInfo implements Cloneable{ | ||
| 1102 | this.blockStations = blockStations; | 1096 | this.blockStations = blockStations; |
| 1103 | } | 1097 | } |
| 1104 | 1098 | ||
| 1105 | - public int getRegionSwitchState() { | ||
| 1106 | - return regionSwitchState; | ||
| 1107 | - } | ||
| 1108 | - | ||
| 1109 | - public void setRegionSwitchState(int regionSwitchState) { | ||
| 1110 | - this.regionSwitchState = regionSwitchState; | ||
| 1111 | - } | ||
| 1112 | - | ||
| 1113 | @Override | 1099 | @Override |
| 1114 | public ScheduleRealInfo clone() throws CloneNotSupportedException { | 1100 | public ScheduleRealInfo clone() throws CloneNotSupportedException { |
| 1115 | ScheduleRealInfo cloned = (ScheduleRealInfo) super.clone(); | 1101 | ScheduleRealInfo cloned = (ScheduleRealInfo) super.clone(); |
src/main/java/com/bsth/service/directive/DirectiveService.java
| @@ -60,11 +60,11 @@ public interface DirectiveService extends BaseService<D60, Integer>{ | @@ -60,11 +60,11 @@ public interface DirectiveService extends BaseService<D60, Integer>{ | ||
| 60 | */ | 60 | */ |
| 61 | int lineChange(String nbbm, String lineId, String sender); | 61 | int lineChange(String nbbm, String lineId, String sender); |
| 62 | 62 | ||
| 63 | - int lineChange(String nbbm, String lineId, ScheduleRealInfo sch, String sender); | 63 | + int lineChange(String nbbm, String lineId, String sender, String lineRegion); |
| 64 | 64 | ||
| 65 | int lineChangeByDeviceId(String deviceId, String lineCode, String sender); | 65 | int lineChangeByDeviceId(String deviceId, String lineCode, String sender); |
| 66 | 66 | ||
| 67 | - int lineChangeByDeviceId(String deviceId, String lineCode, ScheduleRealInfo sch, String sender); | 67 | + int lineChangeByDeviceId(String deviceId, String lineCode, String sender, int seq); |
| 68 | 68 | ||
| 69 | /** | 69 | /** |
| 70 | * | 70 | * |
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
| @@ -388,28 +388,32 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -388,28 +388,32 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 388 | 388 | ||
| 389 | @Override | 389 | @Override |
| 390 | public int lineChange(String nbbm, String lineCode, String sender) { | 390 | public int lineChange(String nbbm, String lineCode, String sender) { |
| 391 | - return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, null, sender); | 391 | + return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender, 0); |
| 392 | } | 392 | } |
| 393 | 393 | ||
| 394 | /** | 394 | /** |
| 395 | * 线路切换 | 395 | * 线路切换 |
| 396 | */ | 396 | */ |
| 397 | @Override | 397 | @Override |
| 398 | - public int lineChange(String nbbm, String lineCode, ScheduleRealInfo sch, String sender) { | ||
| 399 | - return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sch, sender); | 398 | + public int lineChange(String nbbm, String lineCode, String sender, String lineRegion) { |
| 399 | + int seq = 0; | ||
| 400 | + if (lineRegion != null) { | ||
| 401 | + seq = Integer.parseInt(lineRegion.split("_")[1]); | ||
| 402 | + } | ||
| 403 | + return lineChangeByDeviceId(BasicData.deviceId2NbbmMap.inverse().get(nbbm), lineCode, sender, seq); | ||
| 400 | } | 404 | } |
| 401 | 405 | ||
| 402 | @Override | 406 | @Override |
| 403 | public int lineChangeByDeviceId(String deviceId, String lineCode, String sender) { | 407 | public int lineChangeByDeviceId(String deviceId, String lineCode, String sender) { |
| 404 | - return lineChangeByDeviceId(deviceId, lineCode, null, sender); | 408 | + return lineChangeByDeviceId(deviceId, lineCode, sender, 0); |
| 405 | } | 409 | } |
| 406 | 410 | ||
| 407 | @Override | 411 | @Override |
| 408 | - public int lineChangeByDeviceId(String deviceId, String lineCode, ScheduleRealInfo sch, String sender) { | 412 | + public int lineChangeByDeviceId(String deviceId, String lineCode, String sender, int seq) { |
| 409 | DirectiveCreator crt = new DirectiveCreator(); | 413 | DirectiveCreator crt = new DirectiveCreator(); |
| 410 | Long t = System.currentTimeMillis(); | 414 | Long t = System.currentTimeMillis(); |
| 411 | //生成64数据包 | 415 | //生成64数据包 |
| 412 | - D64 d64 = crt.create64(deviceId, lineCode, sch, t); | 416 | + D64 d64 = crt.create64(deviceId, lineCode, t, seq); |
| 413 | 417 | ||
| 414 | if (null != sender) | 418 | if (null != sender) |
| 415 | d64.setSender(sender); | 419 | d64.setSender(sender); |
| @@ -425,10 +429,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -425,10 +429,10 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 425 | } | 429 | } |
| 426 | // 入库 | 430 | // 入库 |
| 427 | d64.setHttpCode(code); | 431 | d64.setHttpCode(code); |
| 428 | - d64.getData().setTxtContent("切换线路[" + BasicData.lineCode2NameMap.get(lineCode) + "]"); | 432 | + d64.getData().setTxtContent("切换线路[" + BasicData.lineCode2NameMap.get(lineCode) + "]" + (seq != 0 ? "[" + seq + "]" : "")); |
| 429 | // 通知设备刷新线路文件,忽略结果 | 433 | // 通知设备刷新线路文件,忽略结果 |
| 430 | if (code == 0) | 434 | if (code == 0) |
| 431 | - GatewayHttpUtils.postJson(crt.createDeviceRefreshData(deviceId, lineCode)); | 435 | + GatewayHttpUtils.postJson(crt.createDeviceRefreshData(deviceId, lineCode, seq)); |
| 432 | else | 436 | else |
| 433 | d64.setErrorText(" 网关通讯失败, code: " + code); | 437 | d64.setErrorText(" 网关通讯失败, code: " + code); |
| 434 | 438 | ||
| @@ -699,7 +703,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | @@ -699,7 +703,7 @@ public class DirectiveServiceImpl extends BaseServiceImpl<D60, Integer> implemen | ||
| 699 | if (gps == null) | 703 | if (gps == null) |
| 700 | return -1; | 704 | return -1; |
| 701 | 705 | ||
| 702 | - return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId())); | 706 | + return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId(), 0)); |
| 703 | } | 707 | } |
| 704 | 708 | ||
| 705 | /* @Override | 709 | /* @Override |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| @@ -26,19 +26,19 @@ import java.util.zip.ZipEntry; | @@ -26,19 +26,19 @@ import java.util.zip.ZipEntry; | ||
| 26 | import java.util.zip.ZipOutputStream; | 26 | import java.util.zip.ZipOutputStream; |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | - * | 29 | + * |
| 30 | * @ClassName: StationRouteServiceImpl(站点路由service业务层实现类) | 30 | * @ClassName: StationRouteServiceImpl(站点路由service业务层实现类) |
| 31 | - * | 31 | + * |
| 32 | * @Extends : BaseService | 32 | * @Extends : BaseService |
| 33 | - * | 33 | + * |
| 34 | * @Description: TODO(站点路由service业务层) | 34 | * @Description: TODO(站点路由service业务层) |
| 35 | - * | 35 | + * |
| 36 | * @Author bsth@lq | 36 | * @Author bsth@lq |
| 37 | - * | 37 | + * |
| 38 | * @Date 2016年5月03日 上午9:21:17 | 38 | * @Date 2016年5月03日 上午9:21:17 |
| 39 | * | 39 | * |
| 40 | * @Version 公交调度系统BS版 0.1 | 40 | * @Version 公交调度系统BS版 0.1 |
| 41 | - * | 41 | + * |
| 42 | */ | 42 | */ |
| 43 | 43 | ||
| 44 | @Service | 44 | @Service |
| @@ -49,16 +49,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -49,16 +49,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 49 | 49 | ||
| 50 | @Value("${path.speech.line}") | 50 | @Value("${path.speech.line}") |
| 51 | private String linePathPattern; | 51 | private String linePathPattern; |
| 52 | - | 52 | + |
| 53 | @Autowired | 53 | @Autowired |
| 54 | private StationRouteRepository stationRouteRepository; | 54 | private StationRouteRepository stationRouteRepository; |
| 55 | - | 55 | + |
| 56 | @Autowired | 56 | @Autowired |
| 57 | private SectionRouteRepository sectionRouteRepository; | 57 | private SectionRouteRepository sectionRouteRepository; |
| 58 | - | 58 | + |
| 59 | @Autowired | 59 | @Autowired |
| 60 | private LineRepository lineRepository; | 60 | private LineRepository lineRepository; |
| 61 | - | 61 | + |
| 62 | @Autowired | 62 | @Autowired |
| 63 | private StationRepository stationRepository; | 63 | private StationRepository stationRepository; |
| 64 | 64 | ||
| @@ -84,7 +84,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -84,7 +84,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 84 | 84 | ||
| 85 | return stationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(orders)); | 85 | return stationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(orders)); |
| 86 | } | 86 | } |
| 87 | - | 87 | + |
| 88 | @Override | 88 | @Override |
| 89 | public Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp) { | 89 | public Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp) { |
| 90 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 90 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| @@ -136,12 +136,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -136,12 +136,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 136 | } | 136 | } |
| 137 | return resultMap; | 137 | return resultMap; |
| 138 | } | 138 | } |
| 139 | - | 139 | + |
| 140 | /** | 140 | /** |
| 141 | * @Description :TODO(查询树站点与路段数据) | 141 | * @Description :TODO(查询树站点与路段数据) |
| 142 | - * | 142 | + * |
| 143 | * @param map <line.id_eq:线路ID; directions_eq:方向> | 143 | * @param map <line.id_eq:线路ID; directions_eq:方向> |
| 144 | - * | 144 | + * |
| 145 | * @return List<Map<String, Object>> | 145 | * @return List<Map<String, Object>> |
| 146 | */ | 146 | */ |
| 147 | @Override | 147 | @Override |
| @@ -155,26 +155,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -155,26 +155,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 155 | 155 | ||
| 156 | return result; | 156 | return result; |
| 157 | } | 157 | } |
| 158 | - | 158 | + |
| 159 | @Override | 159 | @Override |
| 160 | public Map<String, Object> systemQuote(Map<String, Object> map) { | 160 | public Map<String, Object> systemQuote(Map<String, Object> map) { |
| 161 | Map<String, Object> resultmap = new HashMap<>(); | 161 | Map<String, Object> resultmap = new HashMap<>(); |
| 162 | try{ | 162 | try{ |
| 163 | - | 163 | + |
| 164 | StationRoute route = new StationRoute(); | 164 | StationRoute route = new StationRoute(); |
| 165 | - | 165 | + |
| 166 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); | 166 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 167 | - | 167 | + |
| 168 | Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString()); | 168 | Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString()); |
| 169 | - | 169 | + |
| 170 | Line line = lineRepository.findById(lineId).get(); | 170 | Line line = lineRepository.findById(lineId).get(); |
| 171 | - | 171 | + |
| 172 | Station station = stationRepository.findById(stationId).get(); | 172 | Station station = stationRepository.findById(stationId).get(); |
| 173 | - | 173 | + |
| 174 | route.setLine(line); | 174 | route.setLine(line); |
| 175 | - | 175 | + |
| 176 | route.setStation(station); | 176 | route.setStation(station); |
| 177 | - | 177 | + |
| 178 | //baseRepository.save(t); | 178 | //baseRepository.save(t); |
| 179 | resultmap.put("status", ResponseCode.SUCCESS); | 179 | resultmap.put("status", ResponseCode.SUCCESS); |
| 180 | }catch(Exception e){ | 180 | }catch(Exception e){ |
| @@ -183,13 +183,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -183,13 +183,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 183 | } | 183 | } |
| 184 | return resultmap; | 184 | return resultmap; |
| 185 | } | 185 | } |
| 186 | - | 186 | + |
| 187 | /** | 187 | /** |
| 188 | * @Description :TODO(查询线路某方向下的站点序号与类型) | 188 | * @Description :TODO(查询线路某方向下的站点序号与类型) |
| 189 | - * | 189 | + * |
| 190 | * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> | 190 | * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> |
| 191 | - * | ||
| 192 | - * @return List<Map<String, Object>> | 191 | + * |
| 192 | + * @return List<Map<String, Object>> | ||
| 193 | */ | 193 | */ |
| 194 | @Override | 194 | @Override |
| 195 | public List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map) { | 195 | public List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map) { |
| @@ -304,40 +304,40 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -304,40 +304,40 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 304 | 304 | ||
| 305 | /** | 305 | /** |
| 306 | * @Description :TODO(查询线路某方向下所有站点的中心百度坐标) | 306 | * @Description :TODO(查询线路某方向下所有站点的中心百度坐标) |
| 307 | - * | 307 | + * |
| 308 | * @param map <lineId:线路ID; direction:方向> | 308 | * @param map <lineId:线路ID; direction:方向> |
| 309 | - * | ||
| 310 | - * @return List<Map<String, Object>> | 309 | + * |
| 310 | + * @return List<Map<String, Object>> | ||
| 311 | */ | 311 | */ |
| 312 | @Override | 312 | @Override |
| 313 | public List<Map<String, Object>> getStationRouteCenterPoints(Map<String, Object> map) { | 313 | public List<Map<String, Object>> getStationRouteCenterPoints(Map<String, Object> map) { |
| 314 | - | 314 | + |
| 315 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); | 315 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 316 | - | 316 | + |
| 317 | // 线路ID | 317 | // 线路ID |
| 318 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); | 318 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 319 | - | 319 | + |
| 320 | // 方向 | 320 | // 方向 |
| 321 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); | 321 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 322 | - | 322 | + |
| 323 | List<Object[]> list = stationRouteRepository.getSelectStationRouteCenterPoints(lineId, direction); | 323 | List<Object[]> list = stationRouteRepository.getSelectStationRouteCenterPoints(lineId, direction); |
| 324 | - | 324 | + |
| 325 | if(list.size()>0) { | 325 | if(list.size()>0) { |
| 326 | - | 326 | + |
| 327 | for(int i = 0;i<list.size();i++) { | 327 | for(int i = 0;i<list.size();i++) { |
| 328 | - | 328 | + |
| 329 | Map<String, Object> tempM = new HashMap<String,Object>(); | 329 | Map<String, Object> tempM = new HashMap<String,Object>(); |
| 330 | - | 330 | + |
| 331 | tempM.put("bJwpoints", list.get(i)[0]); | 331 | tempM.put("bJwpoints", list.get(i)[0]); |
| 332 | - | 332 | + |
| 333 | tempM.put("stationName", list.get(i)[1]); | 333 | tempM.put("stationName", list.get(i)[1]); |
| 334 | - | 334 | + |
| 335 | resultList.add(tempM); | 335 | resultList.add(tempM); |
| 336 | - | 336 | + |
| 337 | } | 337 | } |
| 338 | - | 338 | + |
| 339 | } | 339 | } |
| 340 | - | 340 | + |
| 341 | return resultList; | 341 | return resultList; |
| 342 | } | 342 | } |
| 343 | 343 | ||
| @@ -355,7 +355,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -355,7 +355,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 355 | } | 355 | } |
| 356 | map.put("destroy_eq", 0); | 356 | map.put("destroy_eq", 0); |
| 357 | List<LsStationRoute> stationRoutes = lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Direction.ASC, "stationRouteCode")); | 357 | List<LsStationRoute> stationRoutes = lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Direction.ASC, "stationRouteCode")); |
| 358 | - | 358 | + |
| 359 | List<Map<String, Object>> resultList = new ArrayList<>(); | 359 | List<Map<String, Object>> resultList = new ArrayList<>(); |
| 360 | 360 | ||
| 361 | int len = stationRoutes.size(); | 361 | int len = stationRoutes.size(); |
| @@ -366,44 +366,44 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -366,44 +366,44 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 366 | } | 366 | } |
| 367 | return resultList; | 367 | return resultList; |
| 368 | } | 368 | } |
| 369 | - | 369 | + |
| 370 | /** | 370 | /** |
| 371 | * @Description :TODO(撤销站点) | 371 | * @Description :TODO(撤销站点) |
| 372 | - * | 372 | + * |
| 373 | * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)> | 373 | * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)> |
| 374 | - * | 374 | + * |
| 375 | * @return Map<String, Object> <SUCCESS ; ERROR> | 375 | * @return Map<String, Object> <SUCCESS ; ERROR> |
| 376 | */ | 376 | */ |
| 377 | @Override | 377 | @Override |
| 378 | public Map<String, Object> stationRouteIsDestroy(Map<String, Object> map) { | 378 | public Map<String, Object> stationRouteIsDestroy(Map<String, Object> map) { |
| 379 | Map<String, Object> resultMap = new HashMap<String,Object>(); | 379 | Map<String, Object> resultMap = new HashMap<String,Object>(); |
| 380 | - | 380 | + |
| 381 | try { | 381 | try { |
| 382 | - | 382 | + |
| 383 | Integer stationRouteId = map.get("stationRouteId").equals("") ? 0 : Integer.parseInt(map.get("stationRouteId").toString()); | 383 | Integer stationRouteId = map.get("stationRouteId").equals("") ? 0 : Integer.parseInt(map.get("stationRouteId").toString()); |
| 384 | - | 384 | + |
| 385 | Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString()); | 385 | Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString()); |
| 386 | 386 | ||
| 387 | lsStationRouteRepository.deleteById(stationRouteId); | 387 | lsStationRouteRepository.deleteById(stationRouteId); |
| 388 | 388 | ||
| 389 | resultMap.put("status", ResponseCode.SUCCESS); | 389 | resultMap.put("status", ResponseCode.SUCCESS); |
| 390 | - | 390 | + |
| 391 | } catch (Exception e) { | 391 | } catch (Exception e) { |
| 392 | - | 392 | + |
| 393 | resultMap.put("status", ResponseCode.ERROR); | 393 | resultMap.put("status", ResponseCode.ERROR); |
| 394 | - | 394 | + |
| 395 | logger.error("save erro.", e); | 395 | logger.error("save erro.", e); |
| 396 | - | 396 | + |
| 397 | } | 397 | } |
| 398 | - | 398 | + |
| 399 | return resultMap; | 399 | return resultMap; |
| 400 | } | 400 | } |
| 401 | - | 401 | + |
| 402 | /** | 402 | /** |
| 403 | * @Description : TODO(根据线路ID生成行单) | 403 | * @Description : TODO(根据线路ID生成行单) |
| 404 | - * | 404 | + * |
| 405 | * @param map <lineId:线路ID> | 405 | * @param map <lineId:线路ID> |
| 406 | - * | 406 | + * |
| 407 | * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA> | 407 | * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA> |
| 408 | */ | 408 | */ |
| 409 | @Override | 409 | @Override |
| @@ -440,7 +440,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -440,7 +440,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 440 | languages.add("cn"); | 440 | languages.add("cn"); |
| 441 | languages.add("sh"); | 441 | languages.add("sh"); |
| 442 | languages.add("en"); | 442 | languages.add("en"); |
| 443 | - InputStream tts = ttsAndZip(objects, line, languages); | 443 | + ttsAndZip(objects, line, languages, lineRegions); |
| 444 | /** 获取配置文件里的ftp登录参数 */ | 444 | /** 获取配置文件里的ftp登录参数 */ |
| 445 | Map<String, Object> FTPParamMap = readPropertiesGetFTPParam(); | 445 | Map<String, Object> FTPParamMap = readPropertiesGetFTPParam(); |
| 446 | // 压缩文件名 | 446 | // 压缩文件名 |
| @@ -505,23 +505,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -505,23 +505,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 505 | 505 | ||
| 506 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); | 506 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 507 | 507 | ||
| 508 | + // 线路文件上传(全程) | ||
| 508 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", textFileName, input); | 509 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", textFileName, input); |
| 510 | + String linePath = String.format(linePathPattern, lineId), voicePath = String.format("%s%s.zip", linePath, lineId); | ||
| 511 | + // 报站文件上传(全程) | ||
| 512 | + clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | ||
| 513 | + clientUtils.FTPUpLoadFromDisk(new File(voicePath), String.format("%s.zip", line.getLineCode()), url, port, username, password, remotePath + "/voice/"); | ||
| 509 | 514 | ||
| 510 | -// textFile.delete(); | ||
| 511 | // 线路区间 | 515 | // 线路区间 |
| 512 | if (lineRegions.size() > 0) { | 516 | if (lineRegions.size() > 0) { |
| 513 | FTPClientUtils.deleteFileByPrefix(String.format("%s-", line.getLineCode()), url, port, username, password, String.format("%s/voice/", remotePath)); | 517 | FTPClientUtils.deleteFileByPrefix(String.format("%s-", line.getLineCode()), url, port, username, password, String.format("%s/voice/", remotePath)); |
| 514 | for (LineRegion lineRegion : lineRegions) { | 518 | for (LineRegion lineRegion : lineRegions) { |
| 519 | + voicePath = String.format("%s%s-%d.zip", linePath, lineId, lineRegion.getSeq()); | ||
| 515 | textStr = String.format("%s\r\n%s", head, subLine2Ftp(lineRegion)); | 520 | textStr = String.format("%s\r\n%s", head, subLine2Ftp(lineRegion)); |
| 516 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); | 521 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 517 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s-%d.txt", line.getLineCode(), lineRegion.getSeq()), input); | 522 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s-%d.txt", line.getLineCode(), lineRegion.getSeq()), input); |
| 523 | + clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s-%d.zip", line.getLineCode(), lineRegion.getSeq())); | ||
| 524 | + clientUtils.FTPUpLoadFromDisk(new File(voicePath), String.format("%s-%d.zip", line.getLineCode(), lineRegion.getSeq()), url, port, username, password, remotePath + "/voice/"); | ||
| 518 | } | 525 | } |
| 519 | } | 526 | } |
| 520 | 527 | ||
| 521 | - | ||
| 522 | - clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | ||
| 523 | - clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode()), tts); | ||
| 524 | - | ||
| 525 | resultMap.put("status", ResponseCode.SUCCESS); | 528 | resultMap.put("status", ResponseCode.SUCCESS); |
| 526 | }else { | 529 | }else { |
| 527 | resultMap.put("status","NOTDATA"); | 530 | resultMap.put("status","NOTDATA"); |
| @@ -533,22 +536,22 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -533,22 +536,22 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 533 | return resultMap; | 536 | return resultMap; |
| 534 | } | 537 | } |
| 535 | } | 538 | } |
| 536 | - | 539 | + |
| 537 | /** | 540 | /** |
| 538 | * @Description : TODO(形成行单文件内容) | 541 | * @Description : TODO(形成行单文件内容) |
| 539 | - * | 542 | + * |
| 540 | * @param objects :站点路由信息 | 543 | * @param objects :站点路由信息 |
| 541 | - * | 544 | + * |
| 542 | * {[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标) | 545 | * {[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标) |
| 543 | - * | 546 | + * |
| 544 | * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码); | 547 | * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码); |
| 545 | - * | 548 | + * |
| 546 | * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)} | 549 | * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)} |
| 547 | - * | 550 | + * |
| 548 | * @param lineId :线路ID | 551 | * @param lineId :线路ID |
| 549 | - * | 552 | + * |
| 550 | * @return String | 553 | * @return String |
| 551 | - */ | 554 | + */ |
| 552 | public String newTextFileToFTP(List<Object[]> objects,Integer lineId) { | 555 | public String newTextFileToFTP(List<Object[]> objects,Integer lineId) { |
| 553 | 556 | ||
| 554 | // 返回值String | 557 | // 返回值String |
| @@ -563,34 +566,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -563,34 +566,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 563 | defaultZdxh ++ ; | 566 | defaultZdxh ++ ; |
| 564 | // 经度 | 567 | // 经度 |
| 565 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); | 568 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 566 | - | 569 | + |
| 567 | // 纬度 | 570 | // 纬度 |
| 568 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); | 571 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 569 | - | 572 | + |
| 570 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); | 573 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 571 | - | 574 | + |
| 572 | lat = "\t" + lat; | 575 | lat = "\t" + lat; |
| 573 | - | 576 | + |
| 574 | // 站点类型 | 577 | // 站点类型 |
| 575 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); | 578 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); |
| 576 | - | 579 | + |
| 577 | String stationMake = ""; | 580 | String stationMake = ""; |
| 578 | - | 581 | + |
| 579 | if(stationMakeStr.equals("E")) { | 582 | if(stationMakeStr.equals("E")) { |
| 580 | stationMake = "\t2"; | 583 | stationMake = "\t2"; |
| 581 | }else { | 584 | }else { |
| 582 | stationMake ="\t1"; | 585 | stationMake ="\t1"; |
| 583 | } | 586 | } |
| 584 | - | ||
| 585 | - // 站点序号 | 587 | + |
| 588 | + // 站点序号 | ||
| 586 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); | 589 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 587 | String stationNo = String.valueOf(defaultZdxh); | 590 | String stationNo = String.valueOf(defaultZdxh); |
| 588 | - | 591 | + |
| 589 | stationNo = "\t" + stationNo; | 592 | stationNo = "\t" + stationNo; |
| 590 | - | 593 | + |
| 591 | // 站点编码 | 594 | // 站点编码 |
| 592 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); | 595 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); |
| 593 | - | 596 | + |
| 594 | int len = stationCode.length(); | 597 | int len = stationCode.length(); |
| 595 | if(len<8) { | 598 | if(len<8) { |
| 596 | int dx = 8 - len; | 599 | int dx = 8 - len; |
| @@ -602,24 +605,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -602,24 +605,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 602 | }else if(len>8){ | 605 | }else if(len>8){ |
| 603 | stationCode = stationCode.substring(8); | 606 | stationCode = stationCode.substring(8); |
| 604 | } | 607 | } |
| 605 | - | 608 | + |
| 606 | stationCode = "\t" +stationCode; | 609 | stationCode = "\t" +stationCode; |
| 607 | - | 610 | + |
| 608 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; | 611 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; |
| 609 | - | 612 | + |
| 610 | String tempDistc = String.valueOf((int) dis); | 613 | String tempDistc = String.valueOf((int) dis); |
| 611 | - | 614 | + |
| 612 | // 站点距离 | 615 | // 站点距离 |
| 613 | String staitondistance = "\t" + tempDistc; | 616 | String staitondistance = "\t" + tempDistc; |
| 614 | - | 617 | + |
| 615 | // 站点名称 | 618 | // 站点名称 |
| 616 | String stationName = objects.get(i)[7].equals("") ? "" : objects.get(i)[7].toString(); | 619 | String stationName = objects.get(i)[7].equals("") ? "" : objects.get(i)[7].toString(); |
| 617 | - | 620 | + |
| 618 | stationName = "\t" +stationName; | 621 | stationName = "\t" +stationName; |
| 619 | - | 622 | + |
| 620 | // 限速 | 623 | // 限速 |
| 621 | // String sleepStr = " " + "60"; | 624 | // String sleepStr = " " + "60"; |
| 622 | - | 625 | + |
| 623 | // 限速 | 626 | // 限速 |
| 624 | String sleepStr = ""; | 627 | String sleepStr = ""; |
| 625 | // 方向 | 628 | // 方向 |
| @@ -649,16 +652,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -649,16 +652,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 649 | } | 652 | } |
| 650 | } | 653 | } |
| 651 | } | 654 | } |
| 652 | - if(sleepStr.equals("")) | 655 | + if(sleepStr.equals("")) |
| 653 | sleepStr = "\t" + "60"; | 656 | sleepStr = "\t" + "60"; |
| 654 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; | 657 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; |
| 655 | } | 658 | } |
| 656 | - | 659 | + |
| 657 | } | 660 | } |
| 658 | return stationRStr; | 661 | return stationRStr; |
| 659 | - | 662 | + |
| 660 | } | 663 | } |
| 661 | - | 664 | + |
| 662 | public String newTextVoiceFileToFTP(List<Object[]> objects,Integer lineId) { | 665 | public String newTextVoiceFileToFTP(List<Object[]> objects,Integer lineId) { |
| 663 | 666 | ||
| 664 | // 返回值String | 667 | // 返回值String |
| @@ -673,34 +676,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -673,34 +676,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 673 | defaultZdxh ++ ; | 676 | defaultZdxh ++ ; |
| 674 | // 经度 | 677 | // 经度 |
| 675 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); | 678 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 676 | - | 679 | + |
| 677 | // 纬度 | 680 | // 纬度 |
| 678 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); | 681 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 679 | - | 682 | + |
| 680 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); | 683 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 681 | - | 684 | + |
| 682 | lat = "\t" + lat; | 685 | lat = "\t" + lat; |
| 683 | - | 686 | + |
| 684 | // 站点类型 | 687 | // 站点类型 |
| 685 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); | 688 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); |
| 686 | - | 689 | + |
| 687 | String stationMake = ""; | 690 | String stationMake = ""; |
| 688 | - | 691 | + |
| 689 | if(stationMakeStr.equals("E")) { | 692 | if(stationMakeStr.equals("E")) { |
| 690 | stationMake = "\t2"; | 693 | stationMake = "\t2"; |
| 691 | }else { | 694 | }else { |
| 692 | stationMake ="\t1"; | 695 | stationMake ="\t1"; |
| 693 | } | 696 | } |
| 694 | - | ||
| 695 | - // 站点序号 | 697 | + |
| 698 | + // 站点序号 | ||
| 696 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); | 699 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 697 | String stationNo = String.valueOf(defaultZdxh); | 700 | String stationNo = String.valueOf(defaultZdxh); |
| 698 | - | 701 | + |
| 699 | stationNo = "\t" + stationNo; | 702 | stationNo = "\t" + stationNo; |
| 700 | - | 703 | + |
| 701 | // 站点编码 | 704 | // 站点编码 |
| 702 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); | 705 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); |
| 703 | - | 706 | + |
| 704 | int len = stationCode.length(); | 707 | int len = stationCode.length(); |
| 705 | if(len<8) { | 708 | if(len<8) { |
| 706 | int dx = 8 - len; | 709 | int dx = 8 - len; |
| @@ -712,31 +715,31 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -712,31 +715,31 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 712 | }else if(len>8){ | 715 | }else if(len>8){ |
| 713 | stationCode = stationCode.substring(8); | 716 | stationCode = stationCode.substring(8); |
| 714 | } | 717 | } |
| 715 | - | 718 | + |
| 716 | stationCode = "\t" +stationCode; | 719 | stationCode = "\t" +stationCode; |
| 717 | - | 720 | + |
| 718 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; | 721 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; |
| 719 | - | 722 | + |
| 720 | String tempDistc = String.valueOf((int) dis); | 723 | String tempDistc = String.valueOf((int) dis); |
| 721 | - | 724 | + |
| 722 | // 站点距离 | 725 | // 站点距离 |
| 723 | String staitondistance = "\t" + tempDistc; | 726 | String staitondistance = "\t" + tempDistc; |
| 724 | - | 727 | + |
| 725 | // 站点名称 | 728 | // 站点名称 |
| 726 | String stationName = objects.get(i)[7].equals("") ? " " : objects.get(i)[7].toString(); | 729 | String stationName = objects.get(i)[7].equals("") ? " " : objects.get(i)[7].toString(); |
| 727 | - | 730 | + |
| 728 | String stationNameEn = " "; | 731 | String stationNameEn = " "; |
| 729 | if(objects.get(i)[9] != null){ | 732 | if(objects.get(i)[9] != null){ |
| 730 | stationNameEn = objects.get(i)[9].equals("") ? " " : objects.get(i)[9].toString(); | 733 | stationNameEn = objects.get(i)[9].equals("") ? " " : objects.get(i)[9].toString(); |
| 731 | } | 734 | } |
| 732 | - | ||
| 733 | - | 735 | + |
| 736 | + | ||
| 734 | stationName = "\t" +stationName; | 737 | stationName = "\t" +stationName; |
| 735 | stationNameEn = "\t" +stationNameEn; | 738 | stationNameEn = "\t" +stationNameEn; |
| 736 | - | 739 | + |
| 737 | // 限速 | 740 | // 限速 |
| 738 | // String sleepStr = " " + "60"; | 741 | // String sleepStr = " " + "60"; |
| 739 | - | 742 | + |
| 740 | // 限速 | 743 | // 限速 |
| 741 | String sleepStr = ""; | 744 | String sleepStr = ""; |
| 742 | // 方向 | 745 | // 方向 |
| @@ -769,16 +772,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -769,16 +772,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 769 | } | 772 | } |
| 770 | } | 773 | } |
| 771 | } | 774 | } |
| 772 | - if(sleepStr.equals("")) | 775 | + if(sleepStr.equals("")) |
| 773 | sleepStr = "\t" + "60"; | 776 | sleepStr = "\t" + "60"; |
| 774 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + stationNameEn + enterStr; | 777 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + stationNameEn + enterStr; |
| 775 | } | 778 | } |
| 776 | - | 779 | + |
| 777 | } | 780 | } |
| 778 | return stationRStr; | 781 | return stationRStr; |
| 779 | - | 782 | + |
| 780 | } | 783 | } |
| 781 | - | 784 | + |
| 782 | public String hxTextFileToFtp(List<Object[]> objects,Integer lineId) { | 785 | public String hxTextFileToFtp(List<Object[]> objects,Integer lineId) { |
| 783 | String restStr = ""; | 786 | String restStr = ""; |
| 784 | // windows下的文本文件换行符 | 787 | // windows下的文本文件换行符 |
| @@ -791,10 +794,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -791,10 +794,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 791 | if(Integer.valueOf(objects.get(i)[8].toString())==0) { | 794 | if(Integer.valueOf(objects.get(i)[8].toString())==0) { |
| 792 | // 经度 | 795 | // 经度 |
| 793 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); | 796 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 794 | - | 797 | + |
| 795 | // 纬度 | 798 | // 纬度 |
| 796 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); | 799 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 797 | - | 800 | + |
| 798 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); | 801 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 799 | lat = "\t" + lat; | 802 | lat = "\t" + lat; |
| 800 | // 站点类型 | 803 | // 站点类型 |
| @@ -805,7 +808,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -805,7 +808,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 805 | }else { | 808 | }else { |
| 806 | stationMake ="\t1"; | 809 | stationMake ="\t1"; |
| 807 | } | 810 | } |
| 808 | - // 站点序号 | 811 | + // 站点序号 |
| 809 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); | 812 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 810 | String stationNo = "\t" + xh; | 813 | String stationNo = "\t" + xh; |
| 811 | // 站点编码 | 814 | // 站点编码 |
| @@ -861,7 +864,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -861,7 +864,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 861 | } | 864 | } |
| 862 | } | 865 | } |
| 863 | } | 866 | } |
| 864 | - if(sleepStr.equals("")) | 867 | + if(sleepStr.equals("")) |
| 865 | sleepStr = "\t" + "60"; | 868 | sleepStr = "\t" + "60"; |
| 866 | xh++; | 869 | xh++; |
| 867 | restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; | 870 | restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; |
| @@ -871,70 +874,70 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -871,70 +874,70 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 871 | System.out.println(restStr); | 874 | System.out.println(restStr); |
| 872 | return restStr; | 875 | return restStr; |
| 873 | } | 876 | } |
| 874 | - | 877 | + |
| 875 | public boolean isPointOnPolyline (Map<String, Object> point, List<Map<String, Object>> listMap ){ | 878 | public boolean isPointOnPolyline (Map<String, Object> point, List<Map<String, Object>> listMap ){ |
| 876 | - | 879 | + |
| 877 | boolean success = false; | 880 | boolean success = false; |
| 878 | - | 881 | + |
| 879 | for(int l = 0; l < listMap.size() - 1; l ++){ | 882 | for(int l = 0; l < listMap.size() - 1; l ++){ |
| 880 | - | 883 | + |
| 881 | Map<String, Object> tempM = listMap.get(l); | 884 | Map<String, Object> tempM = listMap.get(l); |
| 882 | - | 885 | + |
| 883 | Map<String, Object> nextTempM = listMap.get(l+1); | 886 | Map<String, Object> nextTempM = listMap.get(l+1); |
| 884 | - | 887 | + |
| 885 | if (Double.valueOf(point.get("lng").toString())>= Math.min(Double.valueOf(tempM.get("lng").toString()), Double.valueOf(nextTempM.get("lng").toString())) && Double.valueOf(point.get("lng").toString()) <= Math.max(Double.valueOf(tempM.get("lng").toString()), Double.valueOf(nextTempM.get("lng").toString())) && | 888 | if (Double.valueOf(point.get("lng").toString())>= Math.min(Double.valueOf(tempM.get("lng").toString()), Double.valueOf(nextTempM.get("lng").toString())) && Double.valueOf(point.get("lng").toString()) <= Math.max(Double.valueOf(tempM.get("lng").toString()), Double.valueOf(nextTempM.get("lng").toString())) && |
| 886 | Double.valueOf(point.get("lat").toString()) >= Math.min(Double.valueOf(tempM.get("lat").toString()), Double.valueOf(nextTempM.get("lat").toString())) && Double.valueOf(point.get("lat").toString()) <= Math.max(Double.valueOf(tempM.get("lat").toString()), Double.valueOf(nextTempM.get("lat").toString()))){ | 889 | Double.valueOf(point.get("lat").toString()) >= Math.min(Double.valueOf(tempM.get("lat").toString()), Double.valueOf(nextTempM.get("lat").toString())) && Double.valueOf(point.get("lat").toString()) <= Math.max(Double.valueOf(tempM.get("lat").toString()), Double.valueOf(nextTempM.get("lat").toString()))){ |
| 887 | - | ||
| 888 | - | ||
| 889 | - double precision = (Double.valueOf(tempM.get("lng").toString()) - Double.valueOf(point.get("lng").toString())) * (Double.valueOf(nextTempM.get("lat").toString()) - Double.valueOf(point.get("lat").toString())) - | 890 | + |
| 891 | + | ||
| 892 | + double precision = (Double.valueOf(tempM.get("lng").toString()) - Double.valueOf(point.get("lng").toString())) * (Double.valueOf(nextTempM.get("lat").toString()) - Double.valueOf(point.get("lat").toString())) - | ||
| 890 | (Double.valueOf(nextTempM.get("lng").toString()) - Double.valueOf(tempM.get("lng").toString())) * (Double.valueOf(tempM.get("lat").toString()) - Double.valueOf(nextTempM.get("lat").toString())); | 893 | (Double.valueOf(nextTempM.get("lng").toString()) - Double.valueOf(tempM.get("lng").toString())) * (Double.valueOf(tempM.get("lat").toString()) - Double.valueOf(nextTempM.get("lat").toString())); |
| 891 | - | 894 | + |
| 892 | if(precision < 2e-10 && precision > -2e-10){ | 895 | if(precision < 2e-10 && precision > -2e-10){ |
| 893 | - | 896 | + |
| 894 | //实质判断是否接近0 | 897 | //实质判断是否接近0 |
| 895 | success = true; | 898 | success = true; |
| 896 | - | ||
| 897 | - } | ||
| 898 | - | 899 | + |
| 900 | + } | ||
| 901 | + | ||
| 899 | } | 902 | } |
| 900 | - | 903 | + |
| 901 | } | 904 | } |
| 902 | - | 905 | + |
| 903 | return success; | 906 | return success; |
| 904 | } | 907 | } |
| 905 | - | 908 | + |
| 906 | /** | 909 | /** |
| 907 | * @Description:TOOD(获取FTP登录参数) 这里暂时只做一个map值返回,以后可以作为ftp登录类提出来 | 910 | * @Description:TOOD(获取FTP登录参数) 这里暂时只做一个map值返回,以后可以作为ftp登录类提出来 |
| 908 | - * | 911 | + * |
| 909 | * @return : Map<String, Object> <url:IP;port:端口;username:用户名;password:密码;remotePath:相对路径> | 912 | * @return : Map<String, Object> <url:IP;port:端口;username:用户名;password:密码;remotePath:相对路径> |
| 910 | */ | 913 | */ |
| 911 | public Map<String, Object> readPropertiesGetFTPParam(){ | 914 | public Map<String, Object> readPropertiesGetFTPParam(){ |
| 912 | - | 915 | + |
| 913 | // 返回值map | 916 | // 返回值map |
| 914 | Map<String, Object> resultMap = new HashMap<String, Object>(); | 917 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 915 | - | 918 | + |
| 916 | Properties env = new Properties(); | 919 | Properties env = new Properties(); |
| 917 | - | 920 | + |
| 918 | try { | 921 | try { |
| 919 | - | 922 | + |
| 920 | env.load(DBUtils_MS.class.getClassLoader().getResourceAsStream("ftp.properties")); | 923 | env.load(DBUtils_MS.class.getClassLoader().getResourceAsStream("ftp.properties")); |
| 921 | - | 924 | + |
| 922 | resultMap.put("url", env.getProperty("ftp.url")); | 925 | resultMap.put("url", env.getProperty("ftp.url")); |
| 923 | - | 926 | + |
| 924 | resultMap.put("port", env.getProperty("ftp.port")); | 927 | resultMap.put("port", env.getProperty("ftp.port")); |
| 925 | - | 928 | + |
| 926 | resultMap.put("username", env.getProperty("ftp.username")); | 929 | resultMap.put("username", env.getProperty("ftp.username")); |
| 927 | - | 930 | + |
| 928 | resultMap.put("password", env.getProperty("ftp.password")); | 931 | resultMap.put("password", env.getProperty("ftp.password")); |
| 929 | - | 932 | + |
| 930 | resultMap.put("remotePath", env.getProperty("ftp.path")); | 933 | resultMap.put("remotePath", env.getProperty("ftp.path")); |
| 931 | - | 934 | + |
| 932 | } catch (Exception e) { | 935 | } catch (Exception e) { |
| 933 | 936 | ||
| 934 | e.printStackTrace(); | 937 | e.printStackTrace(); |
| 935 | - | 938 | + |
| 936 | } | 939 | } |
| 937 | - | 940 | + |
| 938 | return resultMap ; | 941 | return resultMap ; |
| 939 | } | 942 | } |
| 940 | 943 | ||
| @@ -961,7 +964,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -961,7 +964,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 961 | } | 964 | } |
| 962 | //过滤部分字段 | 965 | //过滤部分字段 |
| 963 | /*String jsonStr = JSON.toJSONString(list, new PropertyFilter() { | 966 | /*String jsonStr = JSON.toJSONString(list, new PropertyFilter() { |
| 964 | - | 967 | + |
| 965 | @Override | 968 | @Override |
| 966 | public boolean apply(Object object, String name, Object value) { | 969 | public boolean apply(Object object, String name, Object value) { |
| 967 | if(name.equals("line")) | 970 | if(name.equals("line")) |
| @@ -969,14 +972,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -969,14 +972,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 969 | return true; | 972 | return true; |
| 970 | } | 973 | } |
| 971 | });*/ | 974 | });*/ |
| 972 | - | 975 | + |
| 973 | rs.put("status", ResponseCode.SUCCESS); | 976 | rs.put("status", ResponseCode.SUCCESS); |
| 974 | rs.put("list", list); | 977 | rs.put("list", list); |
| 975 | }catch(Exception e){ | 978 | }catch(Exception e){ |
| 976 | logger.error("", e); | 979 | logger.error("", e); |
| 977 | rs.put("status", ResponseCode.ERROR); | 980 | rs.put("status", ResponseCode.ERROR); |
| 978 | } | 981 | } |
| 979 | - | 982 | + |
| 980 | return rs; | 983 | return rs; |
| 981 | } | 984 | } |
| 982 | 985 | ||
| @@ -1065,7 +1068,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1065,7 +1068,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1065 | * @param line | 1068 | * @param line |
| 1066 | * @param languages 语言 如:cn、en、sh | 1069 | * @param languages 语言 如:cn、en、sh |
| 1067 | */ | 1070 | */ |
| 1068 | - private InputStream ttsAndZip(List<Object[]> objects, Line line, Set<String> languages) throws Exception { | 1071 | + private void ttsAndZip(List<Object[]> objects, Line line, Set<String> languages, List<LineRegion> lineRegions) throws Exception { |
| 1069 | String lineId = line.getLineCode(); | 1072 | String lineId = line.getLineCode(); |
| 1070 | StringBuilder cnBuilder = new StringBuilder(line.getName()).append("[p1000]"), enBuilder = new StringBuilder("Hello[p1000]"); | 1073 | StringBuilder cnBuilder = new StringBuilder(line.getName()).append("[p1000]"), enBuilder = new StringBuilder("Hello[p1000]"); |
| 1071 | int ups = 0, downs = 0; | 1074 | int ups = 0, downs = 0; |
| @@ -1094,75 +1097,116 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1094,75 +1097,116 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1094 | downs++; | 1097 | downs++; |
| 1095 | } | 1098 | } |
| 1096 | } | 1099 | } |
| 1097 | - cnBuilder.delete(cnBuilder.length() - 8, cnBuilder.length() - 1); | ||
| 1098 | - enBuilder.delete(enBuilder.length() - 8, enBuilder.length() - 1); | 1100 | + cnBuilder.delete(cnBuilder.length() - 7, cnBuilder.length()); |
| 1101 | + enBuilder.delete(enBuilder.length() - 7, enBuilder.length()); | ||
| 1099 | 1102 | ||
| 1100 | // 文本转语音并进行分割 | 1103 | // 文本转语音并进行分割 |
| 1101 | // 音频存放及压缩文件路径 | 1104 | // 音频存放及压缩文件路径 |
| 1102 | String linePath = String.format(linePathPattern, lineId), voicePath = String.format("%s%s.zip", linePath, lineId); | 1105 | String linePath = String.format(linePathPattern, lineId), voicePath = String.format("%s%s.zip", linePath, lineId); |
| 1103 | - try { | ||
| 1104 | - String path = String.format("%scn.mp3", linePath); | ||
| 1105 | - IFlyUtils.textToSpeechCn(cnBuilder.toString(), path); | ||
| 1106 | - AudioOperationUtils.splitBySilence(path, String.format("%scn", linePath), 500, -40); | ||
| 1107 | - } catch (Exception e) { | ||
| 1108 | - throw new RuntimeException(e); | ||
| 1109 | - } | ||
| 1110 | - if (languages.contains("sh")) { | ||
| 1111 | - try { | ||
| 1112 | - String path = String.format("%ssh.mp3", linePath); | ||
| 1113 | - IFlyUtils.textToSpeechSh(cnBuilder.toString(), path); | ||
| 1114 | - AudioOperationUtils.splitBySilence(path, String.format("%ssh", linePath), 500, -40); | ||
| 1115 | - } catch (Exception e) { | ||
| 1116 | - throw new RuntimeException(e); | ||
| 1117 | - } | ||
| 1118 | - } | ||
| 1119 | - if (languages.contains("en")) { | 1106 | + // 先清理历史生成的文件 |
| 1107 | + cleanHistoryAudio(new File(linePath)); | ||
| 1108 | + for (String language : languages) { | ||
| 1120 | try { | 1109 | try { |
| 1121 | - String path = String.format("%sen.mp3", linePath); | ||
| 1122 | - IFlyUtils.textToSpeechEn(enBuilder.toString(), path); | ||
| 1123 | - AudioOperationUtils.splitBySilence(path, String.format("%sen", linePath), 500, -40); | 1110 | + String path = String.format("%s%s.mp3", linePath, language); |
| 1111 | + if ("cn".equals(language) || "sh".equals(language)) { | ||
| 1112 | + IFlyUtils.textToSpeech(cnBuilder.toString(), language, path); | ||
| 1113 | + } else if ("en".equals(language)) { | ||
| 1114 | + IFlyUtils.textToSpeech(enBuilder.toString(), language, path); | ||
| 1115 | + } | ||
| 1116 | + AudioOperationUtils.splitBySilence(path, String.format("%s%s", linePath, language), 500, -40); | ||
| 1124 | } catch (Exception e) { | 1117 | } catch (Exception e) { |
| 1125 | throw new RuntimeException(e); | 1118 | throw new RuntimeException(e); |
| 1126 | } | 1119 | } |
| 1127 | } | 1120 | } |
| 1128 | - // 删除原线路音频 | ||
| 1129 | - File file = new File(linePath); | ||
| 1130 | - for (File f : file.listFiles()) { | ||
| 1131 | - if (f.isFile() && f.getName().endsWith(".mp3")) { | ||
| 1132 | - file.delete(); | 1121 | + |
| 1122 | + // 合并每站起步、到达语音(全程) | ||
| 1123 | + int seq = 1; | ||
| 1124 | + List<SeqStationLevel> seqs = new ArrayList<>(); | ||
| 1125 | + for (int i = seq;i <= ups;i++) { | ||
| 1126 | + seqs.add(new SeqStationLevel(i, i)); | ||
| 1127 | + } | ||
| 1128 | + seq = merge(lineId, "0", seq, seqs, languages); | ||
| 1129 | + if (line.getLinePlayType() != 1) { | ||
| 1130 | + seqs.clear(); | ||
| 1131 | + for (int i = seq;i < ups + downs;i++) { | ||
| 1132 | + seqs.add(new SeqStationLevel(i, i + 1, 1)); | ||
| 1133 | + } | ||
| 1134 | + merge(lineId, "0", seq, seqs, languages); | ||
| 1135 | + } | ||
| 1136 | + zipAudio(String.format("%s%s/", linePath, "0"), voicePath, lineId); | ||
| 1137 | + | ||
| 1138 | + // 线路区间 | ||
| 1139 | + Map<String, List<SeqStationLevel>> region2map = new HashMap<>(); | ||
| 1140 | + for (LineRegion lineRegion : lineRegions) { | ||
| 1141 | + for (int i = 0;i < objects.size();i++) { | ||
| 1142 | + Object[] objArr = objects.get(i); | ||
| 1143 | + String stationCode = (String) objArr[5]; | ||
| 1144 | + int direction = (int) objArr[8]; | ||
| 1145 | + if (lineRegion.getDirection() == direction) { | ||
| 1146 | + for (int j = 0;j < lineRegion.getStationRoutes().size();j++) { | ||
| 1147 | + LsStationRoute stationRoute = lineRegion.getStationRoutes().get(j); | ||
| 1148 | + if (stationCode.equals(stationRoute.getStationCode())) { | ||
| 1149 | + List<SeqStationLevel> map = region2map.get(lineRegion.getSeq().toString()); | ||
| 1150 | + if (map == null) { | ||
| 1151 | + map = new ArrayList<>(); | ||
| 1152 | + region2map.put(lineRegion.getSeq().toString(), map); | ||
| 1153 | + } | ||
| 1154 | + map.add(new SeqStationLevel(j + 1, i + 1, direction)); | ||
| 1155 | + break; | ||
| 1156 | + } | ||
| 1157 | + } | ||
| 1158 | + } | ||
| 1133 | } | 1159 | } |
| 1134 | } | 1160 | } |
| 1161 | + for (Map.Entry<String, List<SeqStationLevel>> entry : region2map.entrySet()) { | ||
| 1162 | + String subLineId = entry.getKey(); | ||
| 1163 | + List<SeqStationLevel> map = entry.getValue(); | ||
| 1164 | + seq = 1; | ||
| 1165 | + merge(lineId, subLineId, seq, map, languages); | ||
| 1166 | + zipAudio(String.format("%s%s/", linePath, subLineId), String.format("%s%s-%s.zip", linePath, lineId, subLineId), String.format("%s-%s", lineId, subLineId)); | ||
| 1167 | + } | ||
| 1168 | + } | ||
| 1135 | 1169 | ||
| 1136 | - // 合并每站起步、到达语音 | ||
| 1137 | - int seq = 1, startSeq = 1, direction = 0; | ||
| 1138 | - seq = merge(lineId, seq, startSeq, direction, ups, languages); | ||
| 1139 | - startSeq = ups + 1; | ||
| 1140 | - direction = 1; | ||
| 1141 | - merge(lineId, seq, startSeq, direction, ups + downs, languages); | 1170 | + private void cleanHistoryAudio(File file) throws Exception { |
| 1171 | + if (file.isDirectory()) { | ||
| 1172 | + File[] files = file.listFiles(); | ||
| 1173 | + for (File f : files) { | ||
| 1174 | + cleanHistoryAudio(f); | ||
| 1175 | + } | ||
| 1176 | + } else { | ||
| 1177 | + if (file.getName().endsWith(".mp3") || file.getName().endsWith(".zip")) { | ||
| 1178 | + file.delete(); | ||
| 1179 | + } | ||
| 1180 | + } | ||
| 1181 | + } | ||
| 1142 | 1182 | ||
| 1143 | - // 压缩音频到zip | 1183 | + /** |
| 1184 | + * 压缩音频到zip | ||
| 1185 | + * @param subLinePath 子线路文件夹 | ||
| 1186 | + * @param voicePath 语音报站文件压缩包路径 | ||
| 1187 | + */ | ||
| 1188 | + private void zipAudio(String subLinePath, String voicePath, String zipFolder) throws Exception { | ||
| 1189 | + File file = new File(subLinePath); | ||
| 1144 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(voicePath)); | 1190 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(voicePath)); |
| 1145 | for (File f : file.listFiles()) { | 1191 | for (File f : file.listFiles()) { |
| 1146 | if (f.isFile() && f.getName().endsWith(".mp3")) { | 1192 | if (f.isFile() && f.getName().endsWith(".mp3")) { |
| 1147 | - addFileToZip(zos, f); | 1193 | + addFileToZip(zos, f, zipFolder); |
| 1148 | } | 1194 | } |
| 1149 | } | 1195 | } |
| 1150 | // Key打头音频 | 1196 | // Key打头音频 |
| 1151 | file = new File(commonPath); | 1197 | file = new File(commonPath); |
| 1152 | for (File f : file.listFiles()) { | 1198 | for (File f : file.listFiles()) { |
| 1153 | if (f.isFile() && f.getName().startsWith("Key-")) { | 1199 | if (f.isFile() && f.getName().startsWith("Key-")) { |
| 1154 | - addFileToZip(zos, f); | 1200 | + addFileToZip(zos, f, zipFolder); |
| 1155 | } | 1201 | } |
| 1156 | } | 1202 | } |
| 1157 | zos.flush(); | 1203 | zos.flush(); |
| 1158 | zos.close(); | 1204 | zos.close(); |
| 1159 | - | ||
| 1160 | - return new FileInputStream(voicePath); | ||
| 1161 | } | 1205 | } |
| 1162 | 1206 | ||
| 1163 | - private static void addFileToZip(ZipOutputStream zos, File file) throws IOException { | 1207 | + private static void addFileToZip(ZipOutputStream zos, File file, String zipFolder) throws IOException { |
| 1164 | FileInputStream fis = new FileInputStream(file); | 1208 | FileInputStream fis = new FileInputStream(file); |
| 1165 | - ZipEntry zipEntry = new ZipEntry(file.getName()); | 1209 | + ZipEntry zipEntry = new ZipEntry(String.format("%s/%s", zipFolder, file.getName())); |
| 1166 | zos.putNextEntry(zipEntry); | 1210 | zos.putNextEntry(zipEntry); |
| 1167 | 1211 | ||
| 1168 | byte[] bytes = new byte[4096]; | 1212 | byte[] bytes = new byte[4096]; |
| @@ -1175,21 +1219,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1175,21 +1219,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1175 | fis.close(); | 1219 | fis.close(); |
| 1176 | } | 1220 | } |
| 1177 | 1221 | ||
| 1178 | - private int merge(String lineId, int seq, int startSeq, int direction, int terminal, Set<String> languages) throws Exception { | ||
| 1179 | - for (int i = startSeq;i <= terminal;i++) { | ||
| 1180 | - if (i > startSeq) { | ||
| 1181 | - if (i == startSeq + 1) { | 1222 | + /** |
| 1223 | + * | ||
| 1224 | + * @param lineId 线路编码 | ||
| 1225 | + * @param seq 线路站级序号(全局) | ||
| 1226 | + * @param seqs 当前方向站级序号 | ||
| 1227 | + * @param languages 语种 | ||
| 1228 | + * @return | ||
| 1229 | + * @throws Exception | ||
| 1230 | + */ | ||
| 1231 | + private int merge(String lineId, String subLineId, int seq, List<SeqStationLevel> seqs, Set<String> languages) throws Exception { | ||
| 1232 | + SeqStationLevel startSeq = seqs.get(0), terminal = seqs.get(seqs.size() - 1); | ||
| 1233 | + for (int i = 0;i < seqs.size();i++) { | ||
| 1234 | + SeqStationLevel current = seqs.get(i); | ||
| 1235 | + if (current.getStationLevel() > startSeq.getStationLevel()) { | ||
| 1236 | + if (i == 1) { | ||
| 1182 | // 生成首站 | 1237 | // 生成首站 |
| 1183 | - mergeOriginStart(lineId, seq, i, direction, terminal, languages); | ||
| 1184 | - mergeNormalArrive(lineId, seq, i, direction, terminal, languages); | ||
| 1185 | - } else if (i == terminal) { | 1238 | + mergeOriginStart(lineId, subLineId, seq, current, terminal, languages); |
| 1239 | + mergeNormalArrive(lineId, subLineId, seq, current, terminal, languages); | ||
| 1240 | + } else if (current.getStationLevel() == terminal.getStationLevel()) { | ||
| 1186 | // 生成终点站 | 1241 | // 生成终点站 |
| 1187 | - mergeNormalStart(lineId, seq, i, direction, terminal, languages); | ||
| 1188 | - mergeTerminalArrive(lineId, seq, i, direction, terminal, languages); | 1242 | + mergeNormalStart(lineId, subLineId, seq, current, terminal, languages); |
| 1243 | + mergeTerminalArrive(lineId, subLineId, seq, current, terminal, languages); | ||
| 1189 | } else { | 1244 | } else { |
| 1190 | // 生成中途站 | 1245 | // 生成中途站 |
| 1191 | - mergeNormalStart(lineId, seq, i, direction, terminal, languages); | ||
| 1192 | - mergeNormalArrive(lineId, seq, i, direction, terminal, languages); | 1246 | + mergeNormalStart(lineId, subLineId, seq, current, terminal, languages); |
| 1247 | + mergeNormalArrive(lineId, subLineId, seq, current, terminal, languages); | ||
| 1193 | } | 1248 | } |
| 1194 | seq++; | 1249 | seq++; |
| 1195 | } | 1250 | } |
| @@ -1198,9 +1253,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1198,9 +1253,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1198 | return seq; | 1253 | return seq; |
| 1199 | } | 1254 | } |
| 1200 | 1255 | ||
| 1201 | - private void mergeOriginStart(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | 1256 | + private void mergeOriginStart(String lineId, String subLineId, int seq, SeqStationLevel current, SeqStationLevel terminal, Set<String> languages) throws Exception { |
| 1257 | + // 子线路路径 | ||
| 1202 | String linePath = String.format(linePathPattern, lineId); | 1258 | String linePath = String.format(linePathPattern, lineId); |
| 1203 | - List<String> arr = Arrays.asList(commonPath + "cn_origin_1.mp3", linePath + String.format("cn/%03d.mp3", 0), commonPath + "cn_origin_2.mp3", linePath + String.format("cn/%03d.mp3", terminal), commonPath + "sh_origin_1.mp3", linePath + String.format("sh/%03d.mp3", 0), commonPath + "sh_origin_2.mp3", linePath + String.format("cn/%03d.mp3", terminal), commonPath + "cn_start_1.mp3", linePath + String.format("cn/%03d.mp3", stationLevel), commonPath + "cn_start_2.mp3", commonPath + "sh_start_1.mp3", linePath + String.format("sh/%03d.mp3", stationLevel), commonPath + "sh_start_2.mp3", commonPath + "en_1.mp3", linePath + String.format("en/%03d.mp3", stationLevel), commonPath + "cn_start_3.mp3", commonPath + "sh_start_3.mp3"); | 1259 | + String subLinePath = String.format("%s%s/", linePath, subLineId); |
| 1260 | + int direction = current.getDirection(); | ||
| 1261 | + List<String> arr = Arrays.asList(commonPath + "cn_origin_1.mp3", linePath + String.format("cn/%03d.mp3", 0), commonPath + "cn_origin_2.mp3", linePath + String.format("cn/%03d.mp3", terminal.getStationLevel()), commonPath + "sh_origin_1.mp3", linePath + String.format("sh/%03d.mp3", 0), commonPath + "sh_origin_2.mp3", linePath + String.format("cn/%03d.mp3", terminal.getStationLevel()), commonPath + "cn_start_1.mp3", linePath + String.format("cn/%03d.mp3", current.getStationLevel()), commonPath + "cn_start_2.mp3", commonPath + "sh_start_1.mp3", linePath + String.format("sh/%03d.mp3", current.getStationLevel()), commonPath + "sh_start_2.mp3", commonPath + "en_1.mp3", linePath + String.format("en/%03d.mp3", current.getStationLevel()), commonPath + "cn_start_3.mp3", commonPath + "sh_start_3.mp3"); | ||
| 1204 | List<String> inputPaths = new ArrayList<>(); | 1262 | List<String> inputPaths = new ArrayList<>(); |
| 1205 | for (String path : arr) { | 1263 | for (String path : arr) { |
| 1206 | for (String lang : languages) { | 1264 | for (String lang : languages) { |
| @@ -1210,12 +1268,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1210,12 +1268,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1210 | } | 1268 | } |
| 1211 | } | 1269 | } |
| 1212 | } | 1270 | } |
| 1213 | - AudioOperationUtils.merge(inputPaths, String.format("%s%03da%s-%03d-%s-Start.mp3", linePath, seq, direction == 0 ? "u" : "d", direction == 0 ? stationLevel : terminal - stationLevel + 1, direction == 0 ? "Up" : "Dn")); | 1271 | + AudioOperationUtils.merge(inputPaths, String.format("%s%03da%s-%03d-%s-Start.mp3", subLinePath, seq, direction == 0 ? "u" : "d", direction == 0 ? current.getSeq() : terminal.getSeq() - current.getSeq() + 1, direction == 0 ? "Up" : "Dn")); |
| 1214 | } | 1272 | } |
| 1215 | 1273 | ||
| 1216 | - private void mergeNormalStart(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | 1274 | + private void mergeNormalStart(String lineId, String subLineId, int seq, SeqStationLevel current, SeqStationLevel terminal, Set<String> languages) throws Exception { |
| 1217 | String linePath = String.format(linePathPattern, lineId); | 1275 | String linePath = String.format(linePathPattern, lineId); |
| 1218 | - List<String> arr = Arrays.asList(commonPath + "cn_start.mp3", linePath + String.format("cn/%03d.mp3", stationLevel), commonPath + "cn_start_2.mp3", commonPath + "sh_start_1.mp3", linePath + String.format("sh/%03d.mp3", stationLevel), commonPath + "sh_start_2.mp3", commonPath + "en_1.mp3", linePath + String.format("en/%03d.mp3", stationLevel), commonPath + "cn_start_3.mp3", commonPath + "sh_start_3.mp3"); | 1276 | + String subLinePath = String.format("%s%s/", linePath, subLineId); |
| 1277 | + int direction = current.getDirection(); | ||
| 1278 | + List<String> arr = Arrays.asList(commonPath + "cn_start.mp3", linePath + String.format("cn/%03d.mp3", current.getStationLevel()), commonPath + "cn_start_2.mp3", commonPath + "sh_start_1.mp3", linePath + String.format("sh/%03d.mp3", current.getStationLevel()), commonPath + "sh_start_2.mp3", commonPath + "en_1.mp3", linePath + String.format("en/%03d.mp3", current.getStationLevel()), commonPath + "cn_start_3.mp3", commonPath + "sh_start_3.mp3"); | ||
| 1219 | List<String> inputPaths = new ArrayList<>(); | 1279 | List<String> inputPaths = new ArrayList<>(); |
| 1220 | for (String path : arr) { | 1280 | for (String path : arr) { |
| 1221 | for (String lang : languages) { | 1281 | for (String lang : languages) { |
| @@ -1225,26 +1285,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1225,26 +1285,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1225 | } | 1285 | } |
| 1226 | } | 1286 | } |
| 1227 | } | 1287 | } |
| 1228 | - AudioOperationUtils.merge(inputPaths, String.format("%s%03da%s-%03d-%s-Start.mp3", linePath, seq, direction == 0 ? "u" : "d", direction == 0 ? stationLevel : terminal - stationLevel + 1, direction == 0 ? "Up" : "Dn")); | 1288 | + AudioOperationUtils.merge(inputPaths, String.format("%s%03da%s-%03d-%s-Start.mp3", subLinePath, seq, direction == 0 ? "u" : "d", direction == 0 ? current.getSeq() : terminal.getSeq() - current.getSeq() + 1, direction == 0 ? "Up" : "Dn")); |
| 1229 | } | 1289 | } |
| 1230 | 1290 | ||
| 1231 | - private void mergeNormalArrive(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | 1291 | + private void mergeNormalArrive(String lineId, String subLineId, int seq, SeqStationLevel current, SeqStationLevel terminal, Set<String> languages) throws Exception { |
| 1232 | String linePath = String.format(linePathPattern, lineId); | 1292 | String linePath = String.format(linePathPattern, lineId); |
| 1233 | - List<String> arr = new ArrayList<>(Arrays.asList(commonPath + "cn_arrive.mp3", linePath + String.format("cn/%03d.mp3", stationLevel), commonPath + "cn_arrive_1.mp3", linePath + String.format("sh/%03d.mp3", stationLevel), commonPath + "sh_arrive_1.mp3", commonPath + "en_2.mp3", linePath + String.format("en/%03d.mp3", stationLevel))); | 1293 | + String subLinePath = String.format("%s%s/", linePath, subLineId); |
| 1294 | + int direction = current.getDirection(); | ||
| 1295 | + List<String> arr = new ArrayList<>(Arrays.asList(commonPath + "cn_arrive.mp3", linePath + String.format("cn/%03d.mp3", current.getStationLevel()), commonPath + "cn_arrive_1.mp3", linePath + String.format("sh/%03d.mp3", current.getStationLevel()), commonPath + "sh_arrive_1.mp3", commonPath + "en_2.mp3", linePath + String.format("en/%03d.mp3", current.getStationLevel()))); | ||
| 1234 | List<String> inputPaths = new ArrayList<>(); | 1296 | List<String> inputPaths = new ArrayList<>(); |
| 1235 | if (languages.contains("sh")) { | 1297 | if (languages.contains("sh")) { |
| 1236 | for (int i = 0;i < 3;i++) { | 1298 | for (int i = 0;i < 3;i++) { |
| 1237 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); | 1299 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); |
| 1238 | arr.add(commonPath + "cn_origin_2.mp3"); | 1300 | arr.add(commonPath + "cn_origin_2.mp3"); |
| 1239 | - arr.add(linePath + String.format("cn/%03d.mp3", terminal)); | 1301 | + arr.add(linePath + String.format("cn/%03d.mp3", terminal.getStationLevel())); |
| 1240 | arr.add(linePath + String.format("sh/%03d.mp3", 0)); | 1302 | arr.add(linePath + String.format("sh/%03d.mp3", 0)); |
| 1241 | arr.add(commonPath + "sh_origin_2.mp3"); | 1303 | arr.add(commonPath + "sh_origin_2.mp3"); |
| 1242 | - arr.add(linePath + String.format("sh/%03d.mp3", terminal)); | 1304 | + arr.add(linePath + String.format("sh/%03d.mp3", terminal.getStationLevel())); |
| 1243 | } | 1305 | } |
| 1244 | } else { | 1306 | } else { |
| 1245 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); | 1307 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); |
| 1246 | arr.add(commonPath + "cn_origin_2.mp3"); | 1308 | arr.add(commonPath + "cn_origin_2.mp3"); |
| 1247 | - arr.add(linePath + String.format("cn/%03d.mp3", terminal)); | 1309 | + arr.add(linePath + String.format("cn/%03d.mp3", terminal.getStationLevel())); |
| 1248 | } | 1310 | } |
| 1249 | for (String path : arr) { | 1311 | for (String path : arr) { |
| 1250 | for (String lang : languages) { | 1312 | for (String lang : languages) { |
| @@ -1254,12 +1316,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1254,12 +1316,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1254 | } | 1316 | } |
| 1255 | } | 1317 | } |
| 1256 | } | 1318 | } |
| 1257 | - AudioOperationUtils.merge(inputPaths, String.format("%s%03db%s-%03d-%s-Arrive.mp3", linePath, seq, direction == 0 ? "u" : "d", direction == 0 ? stationLevel : terminal - stationLevel + 1, direction == 0 ? "Up" : "Dn")); | 1319 | + AudioOperationUtils.merge(inputPaths, String.format("%s%03db%s-%03d-%s-Arrive.mp3", subLinePath, seq, direction == 0 ? "u" : "d", direction == 0 ? current.getSeq() : terminal.getSeq() - current.getSeq() + 1, direction == 0 ? "Up" : "Dn")); |
| 1258 | } | 1320 | } |
| 1259 | 1321 | ||
| 1260 | - private void mergeTerminalArrive(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | 1322 | + private void mergeTerminalArrive(String lineId, String subLineId, int seq, SeqStationLevel current, SeqStationLevel terminal, Set<String> languages) throws Exception { |
| 1261 | String linePath = String.format(linePathPattern, lineId); | 1323 | String linePath = String.format(linePathPattern, lineId); |
| 1262 | - List<String> arr = Arrays.asList(commonPath + "cn_terminal.mp3", linePath + String.format("cn/%03d.mp3", stationLevel), commonPath + "cn_arrive_1.mp3", commonPath + "sh_terminal.mp3", linePath + String.format("sh/%03d.mp3", stationLevel), commonPath + "sh_arrive_1.mp3", commonPath + "en_3.mp3", linePath + String.format("en/%03d.mp3", stationLevel), commonPath + "terminal_music.mp3"); | 1324 | + String subLinePath = String.format("%s%s/", linePath, subLineId); |
| 1325 | + int direction = current.getDirection(); | ||
| 1326 | + List<String> arr = Arrays.asList(commonPath + "cn_terminal.mp3", linePath + String.format("cn/%03d.mp3", current.getStationLevel()), commonPath + "cn_arrive_1.mp3", commonPath + "sh_terminal.mp3", linePath + String.format("sh/%03d.mp3", current.getStationLevel()), commonPath + "sh_arrive_1.mp3", commonPath + "en_3.mp3", linePath + String.format("en/%03d.mp3", current.getStationLevel()), commonPath + "terminal_music.mp3"); | ||
| 1263 | List<String> inputPaths = new ArrayList<>(); | 1327 | List<String> inputPaths = new ArrayList<>(); |
| 1264 | for (String path : arr) { | 1328 | for (String path : arr) { |
| 1265 | for (String lang : languages) { | 1329 | for (String lang : languages) { |
| @@ -1269,7 +1333,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1269,7 +1333,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1269 | } | 1333 | } |
| 1270 | } | 1334 | } |
| 1271 | } | 1335 | } |
| 1272 | - AudioOperationUtils.merge(inputPaths, String.format("%s%03db%s-%03d-%s-Arrive.mp3", linePath, seq, direction == 0 ? "u" : "d", direction == 0 ? stationLevel : terminal - stationLevel + 1, direction == 0 ? "Up" : "Dn")); | 1336 | + AudioOperationUtils.merge(inputPaths, String.format("%s%03db%s-%03d-%s-Arrive.mp3", subLinePath, seq, direction == 0 ? "u" : "d", direction == 0 ? current.getSeq() : terminal.getSeq() - current.getSeq() + 1, direction == 0 ? "Up" : "Dn")); |
| 1273 | } | 1337 | } |
| 1274 | 1338 | ||
| 1275 | private void description() { | 1339 | private void description() { |
| @@ -1294,4 +1358,50 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1294,4 +1358,50 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1294 | // 终点站(沪) (sh_terminal.mp3) | 1358 | // 终点站(沪) (sh_terminal.mp3) |
| 1295 | // 终点音乐 (terminal_music.mp3) | 1359 | // 终点音乐 (terminal_music.mp3) |
| 1296 | } | 1360 | } |
| 1361 | + | ||
| 1362 | + /** | ||
| 1363 | + * 站序和站级的映射,全程和区间时会不一致 | ||
| 1364 | + */ | ||
| 1365 | + private final static class SeqStationLevel { | ||
| 1366 | + | ||
| 1367 | + private Integer seq; | ||
| 1368 | + | ||
| 1369 | + private Integer stationLevel; | ||
| 1370 | + | ||
| 1371 | + private int direction; | ||
| 1372 | + | ||
| 1373 | + private SeqStationLevel(Integer seq, Integer stationLevel) { | ||
| 1374 | + this(seq, stationLevel, 0); | ||
| 1375 | + } | ||
| 1376 | + | ||
| 1377 | + private SeqStationLevel(Integer seq, Integer stationLevel, int direction) { | ||
| 1378 | + this.seq = seq; | ||
| 1379 | + this.stationLevel = stationLevel; | ||
| 1380 | + this.direction = direction; | ||
| 1381 | + } | ||
| 1382 | + | ||
| 1383 | + public Integer getSeq() { | ||
| 1384 | + return seq; | ||
| 1385 | + } | ||
| 1386 | + | ||
| 1387 | + public void setSeq(Integer seq) { | ||
| 1388 | + this.seq = seq; | ||
| 1389 | + } | ||
| 1390 | + | ||
| 1391 | + public Integer getStationLevel() { | ||
| 1392 | + return stationLevel; | ||
| 1393 | + } | ||
| 1394 | + | ||
| 1395 | + public void setStationLevel(Integer stationLevel) { | ||
| 1396 | + this.stationLevel = stationLevel; | ||
| 1397 | + } | ||
| 1398 | + | ||
| 1399 | + public int getDirection() { | ||
| 1400 | + return direction; | ||
| 1401 | + } | ||
| 1402 | + | ||
| 1403 | + public void setDirection(int direction) { | ||
| 1404 | + this.direction = direction; | ||
| 1405 | + } | ||
| 1406 | + } | ||
| 1297 | } | 1407 | } |
src/main/java/com/bsth/util/IFlyUtils.java
| @@ -31,71 +31,37 @@ public class IFlyUtils { | @@ -31,71 +31,37 @@ public class IFlyUtils { | ||
| 31 | 31 | ||
| 32 | private final static String appId = "b4b21ad4"; | 32 | private final static String appId = "b4b21ad4"; |
| 33 | 33 | ||
| 34 | - /** | ||
| 35 | - * 生成普通话语音 | ||
| 36 | - * text以","进行分割 | ||
| 37 | - * @param text | ||
| 38 | - */ | ||
| 39 | - public static void textToSpeechCn(String text, String outputPath) throws Exception { | ||
| 40 | - File file = new File(outputPath); | ||
| 41 | - if (!file.getParentFile().exists()) { | ||
| 42 | - file.getParentFile().mkdirs(); | ||
| 43 | - } | ||
| 44 | - String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); | ||
| 45 | - SpeechRequest request = new SpeechRequest(); | ||
| 46 | - request.getCommon().put("app_id", appId); | ||
| 47 | - request.getBusiness().put("aue", "lame"); | ||
| 48 | - request.getBusiness().put("sfl", 1); | ||
| 49 | - request.getBusiness().put("vcn", "x4_lingxiaoshan_profnews"); | ||
| 50 | - request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes("GBK"))); | ||
| 51 | - request.getData().put("status", 2); | ||
| 52 | - websocketWork(wsUrl, request, new FileOutputStream(file)); | ||
| 53 | - while (!request.isCompleted()) { | ||
| 54 | - Thread.sleep(500); | ||
| 55 | - } | 34 | + private static Map<String, String> language2vcn = new HashMap<>(); |
| 35 | + | ||
| 36 | + static { | ||
| 37 | + language2vcn.put("cn", "x4_lingxiaoshan_profnews"); | ||
| 38 | + language2vcn.put("sh", "x3_ziling"); | ||
| 39 | + language2vcn.put("en", "x4_enus_luna_assist"); | ||
| 56 | } | 40 | } |
| 57 | 41 | ||
| 58 | - /** | ||
| 59 | - * 生成上海话语音 | ||
| 60 | - * text以","进行分割 | ||
| 61 | - * @param text | ||
| 62 | - */ | ||
| 63 | - public static void textToSpeechSh(String text, String outputPath) throws Exception { | 42 | + public static void textToSpeech(String text, String language, String outputPath) throws Exception { |
| 64 | File file = new File(outputPath); | 43 | File file = new File(outputPath); |
| 65 | if (!file.getParentFile().exists()) { | 44 | if (!file.getParentFile().exists()) { |
| 66 | file.getParentFile().mkdirs(); | 45 | file.getParentFile().mkdirs(); |
| 67 | } | 46 | } |
| 47 | + String vcn = language2vcn.get(language); | ||
| 48 | + if (vcn == null) { | ||
| 49 | + throw new IllegalArgumentException("Language is not supported: " + language); | ||
| 50 | + } | ||
| 68 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); | 51 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); |
| 69 | SpeechRequest request = new SpeechRequest(); | 52 | SpeechRequest request = new SpeechRequest(); |
| 70 | request.getCommon().put("app_id", appId); | 53 | request.getCommon().put("app_id", appId); |
| 71 | request.getBusiness().put("aue", "lame"); | 54 | request.getBusiness().put("aue", "lame"); |
| 72 | request.getBusiness().put("sfl", 1); | 55 | request.getBusiness().put("sfl", 1); |
| 73 | - request.getBusiness().put("vcn", "x3_ziling"); | ||
| 74 | - request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes("GBK"))); | ||
| 75 | - request.getData().put("status", 2); | ||
| 76 | - websocketWork(wsUrl, request, new FileOutputStream(file)); | ||
| 77 | - while (!request.isCompleted()) { | ||
| 78 | - Thread.sleep(500); | 56 | + request.getBusiness().put("vcn", vcn); |
| 57 | + String charset = "GBK"; | ||
| 58 | + if ("en".equals(language)) { | ||
| 59 | + charset = "UTF-8"; | ||
| 79 | } | 60 | } |
| 80 | - } | ||
| 81 | - | ||
| 82 | - /** | ||
| 83 | - * 生成英语语音 | ||
| 84 | - * text以","进行分割 | ||
| 85 | - * @param text | ||
| 86 | - */ | ||
| 87 | - public static void textToSpeechEn(String text, String outputPath) throws Exception { | ||
| 88 | - File file = new File(outputPath); | ||
| 89 | - if (!file.getParentFile().exists()) { | ||
| 90 | - file.getParentFile().mkdirs(); | 61 | + if ("en".equals(language) || "sh".equals(language)) { |
| 62 | + request.getBusiness().put("volume", 100); | ||
| 91 | } | 63 | } |
| 92 | - String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); | ||
| 93 | - SpeechRequest request = new SpeechRequest(); | ||
| 94 | - request.getCommon().put("app_id", appId); | ||
| 95 | - request.getBusiness().put("aue", "lame"); | ||
| 96 | - request.getBusiness().put("sfl", 1); | ||
| 97 | - request.getBusiness().put("vcn", "x4_enus_luna_assist"); | ||
| 98 | - request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes(StandardCharsets.UTF_8))); | 64 | + request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes(charset))); |
| 99 | request.getData().put("status", 2); | 65 | request.getData().put("status", 2); |
| 100 | websocketWork(wsUrl, request, new FileOutputStream(file)); | 66 | websocketWork(wsUrl, request, new FileOutputStream(file)); |
| 101 | while (!request.isCompleted()) { | 67 | while (!request.isCompleted()) { |
| @@ -183,8 +149,8 @@ public class IFlyUtils { | @@ -183,8 +149,8 @@ public class IFlyUtils { | ||
| 183 | String authorization = String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", apiKey, "hmac-sha256", "host date request-line", sha); | 149 | String authorization = String.format("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", apiKey, "hmac-sha256", "host date request-line", sha); |
| 184 | StringBuilder sb = new StringBuilder(hostUrl); | 150 | StringBuilder sb = new StringBuilder(hostUrl); |
| 185 | sb.append("?authorization=").append(Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))) | 151 | sb.append("?authorization=").append(Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))) |
| 186 | - .append("&date=").append(URLEncoder.encode(date)) | ||
| 187 | - .append("&host=").append(URLEncoder.encode(url.getHost())); | 152 | + .append("&date=").append(URLEncoder.encode(date)) |
| 153 | + .append("&host=").append(URLEncoder.encode(url.getHost())); | ||
| 188 | // // 拼接地址 | 154 | // // 拼接地址 |
| 189 | // HttpUrl httpUrl = Objects.requireNonNull(HttpUrl.parse("https://" + url.getHost() + url.getPath())).newBuilder().// | 155 | // HttpUrl httpUrl = Objects.requireNonNull(HttpUrl.parse("https://" + url.getHost() + url.getPath())).newBuilder().// |
| 190 | // addQueryParameter("authorization", Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))).// | 156 | // addQueryParameter("authorization", Base64.getEncoder().encodeToString(authorization.getBytes(StandardCharsets.UTF_8))).// |
| @@ -194,4 +160,4 @@ public class IFlyUtils { | @@ -194,4 +160,4 @@ public class IFlyUtils { | ||
| 194 | 160 | ||
| 195 | return sb.toString(); | 161 | return sb.toString(); |
| 196 | } | 162 | } |
| 197 | -} | 163 | -} |
| 164 | +} | ||
| 198 | \ No newline at end of file | 165 | \ No newline at end of file |
src/main/resources/fatso/handle_real_ctl.js
| 1 | -/** | ||
| 2 | - * 处理线调文件 | ||
| 3 | - */ | ||
| 4 | -var fs = require('fs') | ||
| 5 | - , cheerio = require('cheerio') | ||
| 6 | - , minifier = require('./minifier') | ||
| 7 | - , crypto = require("crypto") | ||
| 8 | - , CleanCSS = require('clean-css') | ||
| 9 | - , UglifyJS = require("uglify-js"); | ||
| 10 | -; | ||
| 11 | - | ||
| 12 | -var platform = process.platform; | ||
| 13 | -var iswin = platform=='win32'; | ||
| 14 | -var sp = platform=='win32'?'\\':'/'; | ||
| 15 | -//不参与的目录 | ||
| 16 | -var pName = 'bsth_control' | ||
| 17 | - , path = process.cwd() | ||
| 18 | - //根目录 | ||
| 19 | - , root = path.substr(0, path.indexOf(sp + 'src'+sp+'main')) | ||
| 20 | - , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | ||
| 21 | - //临时目录 | ||
| 22 | - , dest = (workspace + sp + pName + '@fatso_copy')//.replace(/\//g, '\\') | ||
| 23 | - , _static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static'; | ||
| 24 | - | ||
| 25 | - | ||
| 26 | -var mainFile = dest + _static + sp + 'real_control_v2'+sp+'main.html'; | ||
| 27 | -var aloneMapWrapFile = dest + _static + sp + 'real_control_v2'+sp+'alone_page'+sp+'map'+sp+'alone_wrap.html'; | ||
| 28 | -var aloneHomeWrapFile = dest + _static + sp + 'real_control_v2'+sp+'alone_page'+sp+'home'+sp+'home_wrap.html'; | ||
| 29 | -var mapFile = dest + _static + sp + 'real_control_v2'+sp+'mapmonitor'+sp+'real.html'; | ||
| 30 | -var realCtl = { | ||
| 31 | - /** | ||
| 32 | - * 处理线调首页 | ||
| 33 | - */ | ||
| 34 | - handleMain: function (cb) { | ||
| 35 | - //处理main.html | ||
| 36 | - var data = fs.readFileSync(mainFile, 'utf-8'), | ||
| 37 | - $ = cheerio.load(data); | ||
| 38 | - handleCss($, function () { | ||
| 39 | - handleJs($, mainFile, cb); | ||
| 40 | - }); | ||
| 41 | - | ||
| 42 | - | ||
| 43 | - }, | ||
| 44 | - /** | ||
| 45 | - * 处理地图模块 | ||
| 46 | - * @param cb | ||
| 47 | - */ | ||
| 48 | - handleMap: function (cb) { | ||
| 49 | - //读取文件 | ||
| 50 | - var data = fs.readFileSync(mapFile, 'utf-8') | ||
| 51 | - , $ = cheerio.load(data); | ||
| 52 | - | ||
| 53 | - handleCss($, function () { | ||
| 54 | - handleJs($, mapFile, cb); | ||
| 55 | - }); | ||
| 56 | - }, | ||
| 57 | - /** | ||
| 58 | - * 处理单屏地图页面 | ||
| 59 | - * @param cb | ||
| 60 | - */ | ||
| 61 | - handleAlonePage: function (cb) { | ||
| 62 | - var data = fs.readFileSync(aloneMapWrapFile, 'utf-8'); | ||
| 63 | - var $ = cheerio.load(data); | ||
| 64 | - handleCss($, function () { | ||
| 65 | - handleJs($, aloneMapWrapFile, cb); | ||
| 66 | - }); | ||
| 67 | - }, | ||
| 68 | - /** | ||
| 69 | - * 处理单屏主页 | ||
| 70 | - * @param cb | ||
| 71 | - */ | ||
| 72 | - handleAloneHomePage: function (cb) { | ||
| 73 | - var data = fs.readFileSync(aloneHomeWrapFile, 'utf-8'); | ||
| 74 | - var $ = cheerio.load(data); | ||
| 75 | - handleCss($, function () { | ||
| 76 | - handleJs($, aloneHomeWrapFile, cb); | ||
| 77 | - }); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | -}; | ||
| 81 | - | ||
| 82 | -/** | ||
| 83 | - * 处理css | ||
| 84 | - * @type {any} | ||
| 85 | - */ | ||
| 86 | -var handleCss = function ($, cb) { | ||
| 87 | - var cssArray = $('link[rel=stylesheet][merge]'); | ||
| 88 | - //按 merge 值分组 | ||
| 89 | - var cssMap = {}, mergeName; | ||
| 90 | - for (var i = 0, c; c = cssArray[i++];) { | ||
| 91 | - mergeName = $(c).attr('merge'); | ||
| 92 | - if (!cssMap[mergeName]) | ||
| 93 | - cssMap[mergeName] = []; | ||
| 94 | - cssMap[mergeName].push(dest + _static + $(c).attr('href')); | ||
| 95 | - //remove | ||
| 96 | - $(c).remove(); | ||
| 97 | - } | ||
| 98 | - //按 merge 合并压缩css | ||
| 99 | - var ks = get_keys(cssMap), index = 0; | ||
| 100 | - (function () { | ||
| 101 | - if (index >= ks.length) { | ||
| 102 | - cb && cb(); | ||
| 103 | - return; | ||
| 104 | - } | ||
| 105 | - var k = ks[index]; | ||
| 106 | - index++; | ||
| 107 | - var f = arguments.callee; | ||
| 108 | - //合并css | ||
| 109 | - new CleanCSS().minify(cssMap[k], function (error, out) { | ||
| 110 | - var data = out.styles; | ||
| 111 | - var fName = (k + '_' + md5(data)) + '.css'; | ||
| 112 | - //写入 assets css 目录下 | ||
| 113 | - var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'css' + sp + fName; | ||
| 114 | - fs.open(descFile, 'a', function (err, fd) { | ||
| 115 | - | ||
| 116 | - fs.write(fd, data, function () { | ||
| 117 | - var tag = '<link rel="stylesheet" href="/real_control_v2/assets/css/' + fName + '"/>'; | ||
| 118 | - if ($('head').length > 0) | ||
| 119 | - $('head').append(tag); | ||
| 120 | - else { | ||
| 121 | - if($('link').length > 0) | ||
| 122 | - $('link').last().before(tag); | ||
| 123 | - else | ||
| 124 | - $('div').first().before(tag); | ||
| 125 | - } | ||
| 126 | - console.log(k + ' css', '结束,下一个'); | ||
| 127 | - f(); | ||
| 128 | - }); | ||
| 129 | - }); | ||
| 130 | - }); | ||
| 131 | - })(); | ||
| 132 | -}; | ||
| 133 | - | ||
| 134 | -/** | ||
| 135 | - * 处理js | ||
| 136 | - */ | ||
| 137 | -var handleJs = function ($, file, cb) { | ||
| 138 | - var scriptArray = $('script[merge]'); | ||
| 139 | - //按 merge 值分组 | ||
| 140 | - var jsMap = {}, mergeName; | ||
| 141 | - for (var i = 0, s; s = scriptArray[i++];) { | ||
| 142 | - mergeName = $(s).attr('merge'); | ||
| 143 | - if (!jsMap[mergeName]) | ||
| 144 | - jsMap[mergeName] = []; | ||
| 145 | - jsMap[mergeName].push(dest + _static + $(s).attr('src')); | ||
| 146 | - //remove | ||
| 147 | - $(s).remove(); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | - //按 merge 合并压缩js | ||
| 151 | - var ks = get_keys(jsMap), index = 0; | ||
| 152 | - (function () { | ||
| 153 | - if (index >= ks.length) { | ||
| 154 | - write(file, $.html()); | ||
| 155 | - console.log(file + ' 结束'.green); | ||
| 156 | - cb && cb(); | ||
| 157 | - return; | ||
| 158 | - } | ||
| 159 | - var k = ks[index]; | ||
| 160 | - index++; | ||
| 161 | - var f = arguments.callee; | ||
| 162 | - //合并压缩js | ||
| 163 | - var result = UglifyJS.minify(jsMap[k]); | ||
| 164 | - var data = result.code; | ||
| 165 | - var fName = (k + '_' + md5(data)) + '.js'; | ||
| 166 | - //写入 assets js 目录下 | ||
| 167 | - var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'js' + sp + fName; | ||
| 168 | - fs.open(descFile, 'a', function (err, fd) { | ||
| 169 | - | ||
| 170 | - fs.write(fd, data, function () { | ||
| 171 | - var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>'; | ||
| 172 | - if ($('body').length > 0) | ||
| 173 | - $('body').append(tag); | ||
| 174 | - else { | ||
| 175 | - //没有body 就写在尾部 | ||
| 176 | - $('*').last().after(tag); | ||
| 177 | - } | ||
| 178 | - console.log(k + ' js', '结束,下一个'); | ||
| 179 | - f(); | ||
| 180 | - }); | ||
| 181 | - }); | ||
| 182 | - })(); | ||
| 183 | -}; | ||
| 184 | - | ||
| 185 | -var get_keys = function (json) { | ||
| 186 | - var array = []; | ||
| 187 | - for (var key in json) { | ||
| 188 | - array.push(key); | ||
| 189 | - } | ||
| 190 | - return array; | ||
| 191 | -}; | ||
| 192 | - | ||
| 193 | -function md5(text) { | ||
| 194 | - return crypto.createHash("md5").update(text).digest("hex"); | ||
| 195 | -} | ||
| 196 | - | ||
| 197 | -function write(file, text) { | ||
| 198 | - fs.writeFile(file, text, function (err) { | ||
| 199 | - if (err) { | ||
| 200 | - console.log(err.toString().red); | ||
| 201 | - process.exit(); | ||
| 202 | - } | ||
| 203 | - console.log(file.green); | ||
| 204 | - }); | ||
| 205 | -} | ||
| 206 | - | 1 | +/** |
| 2 | + * 处理线调文件 | ||
| 3 | + */ | ||
| 4 | +var fs = require('fs') | ||
| 5 | + , cheerio = require('cheerio') | ||
| 6 | + , minifier = require('./minifier') | ||
| 7 | + , crypto = require("crypto") | ||
| 8 | + , CleanCSS = require('clean-css'); | ||
| 9 | +; | ||
| 10 | + | ||
| 11 | +var platform = process.platform; | ||
| 12 | +var iswin = platform=='win32'; | ||
| 13 | +var sp = platform=='win32'?'\\':'/'; | ||
| 14 | +//不参与的目录 | ||
| 15 | +var pName = 'bsth_control' | ||
| 16 | + , path = process.cwd() | ||
| 17 | + //根目录 | ||
| 18 | + , root = path.substr(0, path.indexOf(sp + 'src'+sp+'main')) | ||
| 19 | + , workspace = root.substr(0, root.lastIndexOf(sp + pName)) | ||
| 20 | + //临时目录 | ||
| 21 | + , dest = (workspace + sp + pName + '@fatso_copy')//.replace(/\//g, '\\') | ||
| 22 | + , _static = sp + 'src'+sp+'main'+sp+'resources'+sp+'static'; | ||
| 23 | + | ||
| 24 | + | ||
| 25 | +var mainFile = dest + _static + sp + 'real_control_v2'+sp+'main.html'; | ||
| 26 | +var aloneMapWrapFile = dest + _static + sp + 'real_control_v2'+sp+'alone_page'+sp+'map'+sp+'alone_wrap.html'; | ||
| 27 | +var aloneHomeWrapFile = dest + _static + sp + 'real_control_v2'+sp+'alone_page'+sp+'home'+sp+'home_wrap.html'; | ||
| 28 | +var mapFile = dest + _static + sp + 'real_control_v2'+sp+'mapmonitor'+sp+'real.html'; | ||
| 29 | +var realCtl = { | ||
| 30 | + /** | ||
| 31 | + * 处理线调首页 | ||
| 32 | + */ | ||
| 33 | + handleMain: function (cb) { | ||
| 34 | + //处理main.html | ||
| 35 | + var data = fs.readFileSync(mainFile, 'utf-8'), | ||
| 36 | + $ = cheerio.load(data); | ||
| 37 | + handleCss($, function () { | ||
| 38 | + handleJs($, mainFile, cb); | ||
| 39 | + }); | ||
| 40 | + | ||
| 41 | + | ||
| 42 | + }, | ||
| 43 | + /** | ||
| 44 | + * 处理地图模块 | ||
| 45 | + * @param cb | ||
| 46 | + */ | ||
| 47 | + handleMap: function (cb) { | ||
| 48 | + //读取文件 | ||
| 49 | + var data = fs.readFileSync(mapFile, 'utf-8') | ||
| 50 | + , $ = cheerio.load(data); | ||
| 51 | + | ||
| 52 | + handleCss($, function () { | ||
| 53 | + handleJs($, mapFile, cb); | ||
| 54 | + }); | ||
| 55 | + }, | ||
| 56 | + /** | ||
| 57 | + * 处理单屏地图页面 | ||
| 58 | + * @param cb | ||
| 59 | + */ | ||
| 60 | + handleAlonePage: function (cb) { | ||
| 61 | + var data = fs.readFileSync(aloneMapWrapFile, 'utf-8'); | ||
| 62 | + var $ = cheerio.load(data); | ||
| 63 | + handleCss($, function () { | ||
| 64 | + handleJs($, aloneMapWrapFile, cb); | ||
| 65 | + }); | ||
| 66 | + }, | ||
| 67 | + /** | ||
| 68 | + * 处理单屏主页 | ||
| 69 | + * @param cb | ||
| 70 | + */ | ||
| 71 | + handleAloneHomePage: function (cb) { | ||
| 72 | + var data = fs.readFileSync(aloneHomeWrapFile, 'utf-8'); | ||
| 73 | + var $ = cheerio.load(data); | ||
| 74 | + handleCss($, function () { | ||
| 75 | + handleJs($, aloneHomeWrapFile, cb); | ||
| 76 | + }); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | +}; | ||
| 80 | + | ||
| 81 | +/** | ||
| 82 | + * 处理css | ||
| 83 | + * @type {any} | ||
| 84 | + */ | ||
| 85 | +var handleCss = function ($, cb) { | ||
| 86 | + var cssArray = $('link[rel=stylesheet][merge]'); | ||
| 87 | + //按 merge 值分组 | ||
| 88 | + var cssMap = {}, mergeName; | ||
| 89 | + for (var i = 0, c; c = cssArray[i++];) { | ||
| 90 | + mergeName = $(c).attr('merge'); | ||
| 91 | + if (!cssMap[mergeName]) | ||
| 92 | + cssMap[mergeName] = []; | ||
| 93 | + cssMap[mergeName].push(dest + _static + $(c).attr('href')); | ||
| 94 | + //remove | ||
| 95 | + $(c).remove(); | ||
| 96 | + } | ||
| 97 | + //按 merge 合并压缩css | ||
| 98 | + var ks = get_keys(cssMap), index = 0; | ||
| 99 | + (function () { | ||
| 100 | + if (index >= ks.length) { | ||
| 101 | + cb && cb(); | ||
| 102 | + return; | ||
| 103 | + } | ||
| 104 | + var k = ks[index]; | ||
| 105 | + index++; | ||
| 106 | + var f = arguments.callee; | ||
| 107 | + //合并css | ||
| 108 | + new CleanCSS().minify(cssMap[k], function (error, out) { | ||
| 109 | + var data = out.styles; | ||
| 110 | + var fName = (k + '_' + md5(data)) + '.css'; | ||
| 111 | + //写入 assets css 目录下 | ||
| 112 | + var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'css' + sp + fName; | ||
| 113 | + fs.open(descFile, 'a', function (err, fd) { | ||
| 114 | + | ||
| 115 | + fs.write(fd, data, function () { | ||
| 116 | + var tag = '<link rel="stylesheet" href="/real_control_v2/assets/css/' + fName + '"/>'; | ||
| 117 | + if ($('head').length > 0) | ||
| 118 | + $('head').append(tag); | ||
| 119 | + else { | ||
| 120 | + if($('link').length > 0) | ||
| 121 | + $('link').last().before(tag); | ||
| 122 | + else | ||
| 123 | + $('div').first().before(tag); | ||
| 124 | + } | ||
| 125 | + console.log(k + ' css', '结束,下一个'); | ||
| 126 | + f(); | ||
| 127 | + }); | ||
| 128 | + }); | ||
| 129 | + }); | ||
| 130 | + })(); | ||
| 131 | +}; | ||
| 132 | + | ||
| 133 | +/** | ||
| 134 | + * 处理js | ||
| 135 | + */ | ||
| 136 | +var handleJs = function ($, file, cb) { | ||
| 137 | + var scriptArray = $('script[merge]'); | ||
| 138 | + //按 merge 值分组 | ||
| 139 | + var jsMap = {}, mergeName; | ||
| 140 | + for (var i = 0, s; s = scriptArray[i++];) { | ||
| 141 | + mergeName = $(s).attr('merge'); | ||
| 142 | + if (!jsMap[mergeName]) | ||
| 143 | + jsMap[mergeName] = []; | ||
| 144 | + jsMap[mergeName].push(dest + _static + $(s).attr('src')); | ||
| 145 | + //remove | ||
| 146 | + $(s).remove(); | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + //按 merge 合并压缩js | ||
| 150 | + var ks = get_keys(jsMap), index = 0; | ||
| 151 | + (function () { | ||
| 152 | + if (index >= ks.length) { | ||
| 153 | + write(file, $.html()); | ||
| 154 | + console.log(file + ' 结束'); // 移除.green调用 | ||
| 155 | + cb && cb(); | ||
| 156 | + return; | ||
| 157 | + } | ||
| 158 | + var k = ks[index]; | ||
| 159 | + index++; | ||
| 160 | + var f = arguments.callee; | ||
| 161 | + //合并压缩js | ||
| 162 | + try { | ||
| 163 | + // 先合并文件内容 | ||
| 164 | + let code = ''; | ||
| 165 | + for(let j = 0; j < jsMap[k].length; j++) { | ||
| 166 | + code += fs.readFileSync(jsMap[k][j], 'utf8') + '\n'; | ||
| 167 | + } | ||
| 168 | + // 使用Terser压缩 | ||
| 169 | + var data = minifier.mini(code); | ||
| 170 | + if (code !== '' && data === '') { | ||
| 171 | + console.error('压缩出错') | ||
| 172 | + process.exit(); | ||
| 173 | + } | ||
| 174 | + var fName = (k + '_' + md5(data)) + '.js'; | ||
| 175 | + //写入 assets js 目录下 | ||
| 176 | + var descFile = dest + _static + sp + 'real_control_v2'+sp+'assets'+sp+'js' + sp + fName; | ||
| 177 | + fs.open(descFile, 'a', function (err, fd) { | ||
| 178 | + fs.write(fd, data, function () { | ||
| 179 | + var tag = '<script src="/real_control_v2/assets/js/' + fName + '"></script>'; | ||
| 180 | + if ($('body').length > 0) | ||
| 181 | + $('body').append(tag); | ||
| 182 | + else { | ||
| 183 | + //没有body 就写在尾部 | ||
| 184 | + $('*').last().after(tag); | ||
| 185 | + } | ||
| 186 | + console.log(k + ' js', '结束,下一个'); | ||
| 187 | + f(); | ||
| 188 | + }); | ||
| 189 | + }); | ||
| 190 | + } catch (e) { | ||
| 191 | + console.error('合并压缩错误:', e); | ||
| 192 | + process.exit(); | ||
| 193 | + } | ||
| 194 | + })(); | ||
| 195 | +}; | ||
| 196 | + | ||
| 197 | +var get_keys = function (json) { | ||
| 198 | + var array = []; | ||
| 199 | + for (var key in json) { | ||
| 200 | + array.push(key); | ||
| 201 | + } | ||
| 202 | + return array; | ||
| 203 | +}; | ||
| 204 | + | ||
| 205 | +function md5(text) { | ||
| 206 | + return crypto.createHash("md5").update(text).digest("hex"); | ||
| 207 | +} | ||
| 208 | + | ||
| 209 | +function write(file, text) { | ||
| 210 | + fs.writeFile(file, text, function (err) { | ||
| 211 | + if (err) { | ||
| 212 | + console.log(err.toString()); // 移除.red调用 | ||
| 213 | + process.exit(); | ||
| 214 | + } | ||
| 215 | + console.log(file); // 移除.green调用 | ||
| 216 | + }); | ||
| 217 | +} | ||
| 218 | + | ||
| 207 | module.exports = realCtl; | 219 | module.exports = realCtl; |
| 208 | \ No newline at end of file | 220 | \ No newline at end of file |
src/main/resources/fatso/minifier.js
| 1 | -/** | ||
| 2 | - * @author PanZhao | ||
| 3 | - * @date 2016年3月17日 下午12:44:06 | ||
| 4 | - */ | ||
| 5 | -var fs = require('fs'); | ||
| 6 | -var UglifyJS = require("uglify-js"); | ||
| 7 | - | ||
| 8 | -var platform = process.platform; | ||
| 9 | -var iswin = platform=='win32'; | ||
| 10 | -var separator = platform=='win32'?'\\':'/'; | ||
| 11 | -var minifier = { | ||
| 12 | - | ||
| 13 | - mergeAndMini: function(fileArray,scriptString, root, file){ | ||
| 14 | - var len = fileArray.length; | ||
| 15 | - for(var i = 0; i < len; i ++){ | ||
| 16 | - fileArray[i] = root + fileArray[i].split('/').join(separator); | ||
| 17 | - } | ||
| 18 | - | ||
| 19 | - var result, indoorRs; | ||
| 20 | - | ||
| 21 | - try { | ||
| 22 | - if(fileArray && len > 0) | ||
| 23 | - result = UglifyJS.minify(fileArray); | ||
| 24 | - | ||
| 25 | - if(scriptString) | ||
| 26 | - indoorRs = UglifyJS.minify(scriptString, {fromString: true}); | ||
| 27 | - } catch (e) { | ||
| 28 | - console.log(e); | ||
| 29 | - console.log(file.red); | ||
| 30 | - process.exit(); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - return {outside: result?result.code:'', inside: indoorRs?indoorRs.code:''}; | ||
| 34 | - }, | ||
| 35 | - mini: function(file){ | ||
| 36 | - return UglifyJS.minify(file).code; | ||
| 37 | - } | ||
| 38 | -} | ||
| 39 | - | 1 | +var fs = require('fs'); |
| 2 | +var Terser = require('terser'); | ||
| 3 | + | ||
| 4 | +var platform = process.platform; | ||
| 5 | +var iswin = platform=='win32'; | ||
| 6 | +var separator = platform=='win32'?'\\':'/'; | ||
| 7 | +var minifier = { | ||
| 8 | + | ||
| 9 | + mergeAndMini: function(fileArray, scriptString, root, file) { | ||
| 10 | + var len = fileArray.length; | ||
| 11 | + for(var i = 0; i < len; i ++){ | ||
| 12 | + fileArray[i] = root + fileArray[i].split('/').join(separator); | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + var result, indoorRs; | ||
| 16 | + | ||
| 17 | + try { | ||
| 18 | + if(fileArray && len > 0) { | ||
| 19 | + // Terser可以直接接受文件路径数组 | ||
| 20 | + result = Terser.minify_sync(fs.readFileSync(fileArray[0], 'utf8')); | ||
| 21 | + // 如果有多个文件,需要先合并内容 | ||
| 22 | + if(len > 1) { | ||
| 23 | + let code = ''; | ||
| 24 | + for(let j = 0; j < len; j++) { | ||
| 25 | + code += fs.readFileSync(fileArray[j], 'utf8') + '\n'; | ||
| 26 | + } | ||
| 27 | + result = Terser.minify_sync(code); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + if(scriptString) { | ||
| 32 | + // Terser不需要fromString选项,直接传递代码字符串 | ||
| 33 | + indoorRs = Terser.minify_sync(scriptString); | ||
| 34 | + } | ||
| 35 | + } catch (e) { | ||
| 36 | + console.log(e); | ||
| 37 | + console.log(file); // 移除.red调用,除非有chalk等库 | ||
| 38 | + process.exit(); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + return {outside: result && !result.error ? result.code : '', inside: indoorRs && !indoorRs.error ? indoorRs.code : ''}; | ||
| 42 | + }, | ||
| 43 | + | ||
| 44 | + mini: function(file) { | ||
| 45 | + try { | ||
| 46 | + // 检查file是文件路径还是代码字符串 | ||
| 47 | + if(typeof file === 'string' && fs.existsSync(file)) { | ||
| 48 | + const code = fs.readFileSync(file, 'utf8'); | ||
| 49 | + const result = Terser.minify_sync(code); | ||
| 50 | + return result && !result.error ? result.code : ''; | ||
| 51 | + } else { | ||
| 52 | + // 假设是代码字符串 | ||
| 53 | + const result = Terser.minify_sync(file); | ||
| 54 | + return result && !result.error ? result.code : ''; | ||
| 55 | + } | ||
| 56 | + } catch (e) { | ||
| 57 | + console.log(e); | ||
| 58 | + return ''; | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | +}; | ||
| 62 | + | ||
| 40 | module.exports = minifier; | 63 | module.exports = minifier; |
| 41 | \ No newline at end of file | 64 | \ No newline at end of file |
src/main/resources/fatso/package.json
| 1 | -{ | ||
| 2 | - "name": "fatso", | ||
| 3 | - "version": "1.0.0", | ||
| 4 | - "description": "子页面js检查、合并、压缩等处理", | ||
| 5 | - "main": "start.js", | ||
| 6 | - "scripts": { | ||
| 7 | - "test": "echo \"Error: no test specified\" && exit 1" | ||
| 8 | - }, | ||
| 9 | - "author": "panzhaov5", | ||
| 10 | - "license": "ISC", | ||
| 11 | - "dependencies": { | ||
| 12 | - "cheerio": "^0.20.0", | ||
| 13 | - "clean-css": "^4.0.12", | ||
| 14 | - "colors": "^1.3.3", | ||
| 15 | - "eventproxy": "^0.3.5", | ||
| 16 | - "uglify-js": "^2.6.2" | ||
| 17 | - } | ||
| 18 | -} | 1 | +{ |
| 2 | + "name": "fatso", | ||
| 3 | + "version": "1.0.0", | ||
| 4 | + "description": "子页面js检查、合并、压缩等处理", | ||
| 5 | + "main": "start.js", | ||
| 6 | + "scripts": { | ||
| 7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
| 8 | + }, | ||
| 9 | + "author": "panzhaov5", | ||
| 10 | + "license": "ISC", | ||
| 11 | + "dependencies": { | ||
| 12 | + "cheerio": "^0.20.0", | ||
| 13 | + "clean-css": "^4.0.12", | ||
| 14 | + "colors": "^1.3.3", | ||
| 15 | + "eventproxy": "^0.3.4", | ||
| 16 | + "terser": "^5.44.0", | ||
| 17 | + "uglify-js": "^2.6.2" | ||
| 18 | + } | ||
| 19 | +} |
src/main/resources/static/gpsTest/test.html
| @@ -84,7 +84,7 @@ form .item select { | @@ -84,7 +84,7 @@ form .item select { | ||
| 84 | <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | 84 | <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> |
| 85 | <script src="/assets/plugins/jquery.serializejson.js"></script> | 85 | <script src="/assets/plugins/jquery.serializejson.js"></script> |
| 86 | <script | 86 | <script |
| 87 | - src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | 87 | + src="//api.map.baidu.com/api?v=2.0&ak=1TgEKvYqohJyeGXnN6yHSSTb4psOarQw"></script> |
| 88 | <script type="text/javascript" | 88 | <script type="text/javascript" |
| 89 | src="//api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> | 89 | src="//api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> |
| 90 | <!-- moment.js 日期处理类库 --> | 90 | <!-- moment.js 日期处理类库 --> |
src/main/resources/static/pages/base/carpark/add.html
| 1 | -<link href="/pages/base/carpark/css/carpark-add.css" rel="stylesheet" type="text/css" /> | ||
| 2 | -<div class="page-head"> | ||
| 3 | - <div class="page-title"> | ||
| 4 | - <h1>添加停车场</h1> | ||
| 5 | - </div> | ||
| 6 | -</div> | ||
| 7 | - | ||
| 8 | -<ul class="page-breadcrumb breadcrumb"> | ||
| 9 | - <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 10 | - <li><span class="active">基础信息</span> <i class="fa fa-circle"></i></li> | ||
| 11 | - <li><a href="/pages/base/carpark/list.html" data-pjax>停车场信息</a> <i class="fa fa-circle"></i></li> | ||
| 12 | - <li><span class="active">添加停车场</span></li> | ||
| 13 | -</ul> | ||
| 14 | - | ||
| 15 | -<div class="portlet light bordered" id="form-wizard-info"> | ||
| 16 | - <div class="portlet-title"> | ||
| 17 | - <div class="caption"> | ||
| 18 | - <i class="icon-equalizer font-red-sunglo"></i> | ||
| 19 | - <span class="caption-subject font-red-sunglo bold uppercase">添加停车场 | ||
| 20 | - <span class="step-title"> 1 - 4 </span> | ||
| 21 | - <i class="fa fa-question-circle tipso-animation" style="color: rgba(158, 158, 158, 0.49);"></i> | ||
| 22 | - </span> | ||
| 23 | - </div> | ||
| 24 | - | ||
| 25 | - <div class="actions"> | ||
| 26 | - <div class="btn-group btn-group-devided" data-toggle="buttons"> | ||
| 27 | - <a class="btn btn-circle default" href="/pages/base/carpark/list.html" style="float: right;padding: 4px 23px;" data-pjax=""><i class="fa fa-reply"></i> 退出</a> | ||
| 28 | - </div> | ||
| 29 | - </div> | ||
| 30 | - </div> | ||
| 31 | - <div class="portlet-body form"> | ||
| 32 | - | ||
| 33 | - <!-- START FORM --> | ||
| 34 | - <form class="form-horizontal" id="submit_carpark_form" action="/" method="POST" novalidate="novalidate"> | ||
| 35 | - <div class="form-wizard"> | ||
| 36 | - <div class="form-body"> | ||
| 37 | - <ul class="nav nav-pills nav-justified steps"> | ||
| 38 | - <li class="active"> | ||
| 39 | - <a href="#tab1" data-toggle="tab" class="step" aria-expanded="true"> | ||
| 40 | - <span class="number"> 1 </span> | ||
| 41 | - <span class="desc"> | ||
| 42 | - <i class="fa fa-check"></i> 获取停车场位置方式 </span> | ||
| 43 | - </a> | ||
| 44 | - </li> | ||
| 45 | - <li> | ||
| 46 | - <a href="#tab2" data-toggle="tab" class="step"> | ||
| 47 | - <span class="number"> 2 </span> | ||
| 48 | - <span class="desc"> | ||
| 49 | - <i class="fa fa-check"></i> 确定停车场位置 </span> | ||
| 50 | - </a> | ||
| 51 | - </li> | ||
| 52 | - <li> | ||
| 53 | - <a href="#tab3" data-toggle="tab" class="step active"> | ||
| 54 | - <span class="number"> 3 </span> | ||
| 55 | - <span class="desc"> | ||
| 56 | - <i class="fa fa-check"></i> 填写停车场信息 </span> | ||
| 57 | - </a> | ||
| 58 | - </li> | ||
| 59 | - <li> | ||
| 60 | - <a href="#tab4" data-toggle="tab" class="step"> | ||
| 61 | - <span class="number"> 4 </span> | ||
| 62 | - <span class="desc"> | ||
| 63 | - <i class="fa fa-check"></i> 确认并提交 </span> | ||
| 64 | - </a> | ||
| 65 | - </li> | ||
| 66 | - </ul> | ||
| 67 | - | ||
| 68 | - <!-- 进度条 --> | ||
| 69 | - <div id="bar" class="progress progress-striped" role="progressbar"> | ||
| 70 | - <div class="progress-bar progress-bar-success" style="width: 25%;"></div> | ||
| 71 | - </div> | ||
| 72 | - | ||
| 73 | - <div class="tab-content"> | ||
| 74 | - <div class="alert alert-danger display-hide"> | ||
| 75 | - <button class="close" data-close="alert"></button> | ||
| 76 | - 您的输入有误,请检查下面的输入项 | ||
| 77 | - </div> | ||
| 78 | - <div class="alert alert-success display-none"> | ||
| 79 | - <button class="close" data-dismiss="alert"></button> | ||
| 80 | - Your form validation is successful! | ||
| 81 | - </div> | ||
| 82 | - | ||
| 83 | - <!-- 选择添加站点方式 --> | ||
| 84 | - <div class="tab-pane active" id="tab1"> | ||
| 85 | - <h3 class="block"> 获取停车场位置方式 </h3> | ||
| 86 | - <!--停车场名称 --> | ||
| 87 | - <div class="form-group" id="formRequ"> | ||
| 88 | - <label class="col-md-3 control-label"><span class="required"> * </span>停车场名称 :</label> | ||
| 89 | - <div class="col-md-9"> | ||
| 90 | - <input type="text" class="form-control input-medium" id="parkNamebooxtInput" name="parkNamebooxt" placeholder="请输入停车场名称"> | ||
| 91 | - </div> | ||
| 92 | - </div> | ||
| 93 | - <!-- 新增方式 --> | ||
| 94 | - <div class="form-group"> | ||
| 95 | - <label class="col-md-3 control-label"><span class="required"> * </span>选择获取方式:</label> | ||
| 96 | - <div class="col-md-9"> | ||
| 97 | - <div class="icheck-list"> | ||
| 98 | - <label> | ||
| 99 | - <input type="radio" class="icheck" name="baseRes" value=0 checked> 系统生成 | ||
| 100 | - </label> | ||
| 101 | - <label > | ||
| 102 | - <input type="radio" class="icheck" name="baseRes" value=1 > 手动绘制 | ||
| 103 | - </label> | ||
| 104 | - </div> | ||
| 105 | - </div> | ||
| 106 | - </div> | ||
| 107 | - </div> | ||
| 108 | - <!--停车场位置 --> | ||
| 109 | - <div class="tab-pane" id="tab2"> | ||
| 110 | - <h3 class="block"> 停车场位置 </h3> | ||
| 111 | - <div id="addCarParkbmap_basic"></div> | ||
| 112 | - <div class="leftUtils"> | ||
| 113 | - <div class="btn-group" style="left: 100px;"> | ||
| 114 | - <a class="btn btn-sm green-seagreen dropdown-toggle" style="width: 98px;" href="javascript:;" data-toggle="dropdown" aria-expanded="false"> 绘制工具 | ||
| 115 | - <i class="fa fa-angle-down"></i> | ||
| 116 | - </a> | ||
| 117 | - <ul class="dropdown-menu pull-right" style="min-width:100px"> | ||
| 118 | - <li> | ||
| 119 | - <a href="javascript:;" id="oppenDrawingManager"><i class="fa fa-pencil"></i> 打开 </a> | ||
| 120 | - </li> | ||
| 121 | - <li> | ||
| 122 | - <a href="javascript:;" id = "closeDrawingManager"> <i class="fa fa-reply"></i> 关闭 </a> | ||
| 123 | - </li> | ||
| 124 | - | ||
| 125 | - </ul> | ||
| 126 | - </div> | ||
| 127 | - </div> | ||
| 128 | - </div> | ||
| 129 | - <!--停车场信息 --> | ||
| 130 | - <div class="tab-pane" id="tab3"> | ||
| 131 | - <h3 class="block"> 停车场信息 </h3> | ||
| 132 | - <input type="hidden" name="bParkPoint" id="bParkPointInput" /> | ||
| 133 | - <input type="hidden" name="gParkPoint" id="gParkPointInput" /> | ||
| 134 | - <input type="hidden" name="dbType" id="dbTypeInput" value="b"/> | ||
| 135 | - <!-- 停车场名称 --> | ||
| 136 | - <div class="form-body"> | ||
| 137 | - <div class="form-group"> | ||
| 138 | - <label class="control-label col-md-3"> | ||
| 139 | - <span class="required"> * </span> 停车场名称 : | ||
| 140 | - </label> | ||
| 141 | - <div class="col-md-6"> | ||
| 142 | - <input type="text" class="form-control" name="parkName" id="parkNameInput" placeholder="请输入站点名称" readonly="readonly"> | ||
| 143 | - </div> | ||
| 144 | - </div> | ||
| 145 | - </div> | ||
| 146 | - <!-- 停车场编码 --> | ||
| 147 | - <div class="form-body"> | ||
| 148 | - <div class="form-group"> | ||
| 149 | - <label class="control-label col-md-3"> | ||
| 150 | - <span class="required"> * </span>停车场编码 : | ||
| 151 | - </label> | ||
| 152 | - <div class="col-md-6"> | ||
| 153 | - <input type="text" class="form-control" name="parkCode" id="parkCodeInput" placeholder="请输入停车场编码"> | ||
| 154 | - </div> | ||
| 155 | - </div> | ||
| 156 | - </div> | ||
| 157 | - <!-- 经纬度坐标点 --> | ||
| 158 | - <div class="form-body"> | ||
| 159 | - <div class="form-group"> | ||
| 160 | - <label class="col-md-3 control-label"><span class="required"> * </span>经纬度坐标点:</label> | ||
| 161 | - <div class="col-md-6"> | ||
| 162 | - <input type="text" class="form-control" name="bCenterPoint" id="bCenterPointInput" readonly="readonly" placeholder="请输入经纬度坐标点"> | ||
| 163 | - </div> | ||
| 164 | - </div> | ||
| 165 | - </div> | ||
| 166 | - | ||
| 167 | - <!-- 几何图形类型 --> | ||
| 168 | - <div class="form-body"> | ||
| 169 | - <div class="form-group"> | ||
| 170 | - <label class="col-md-3 control-label"><span class="required"> * </span>几何图形类型:</label> | ||
| 171 | - <div class="col-md-6"> | ||
| 172 | - <input type="text" class="form-control" name="shapesType" id="shapesTypeSelect" readonly="readonly" placeholder="请输入几何图形类型"> | ||
| 173 | - </div> | ||
| 174 | - </div> | ||
| 175 | - </div> | ||
| 176 | - <!-- 圆形半径 --> | ||
| 177 | - <div class="form-body" id="radiusGroup"> | ||
| 178 | - <div class="form-group"> | ||
| 179 | - <label class="col-md-3 control-label"><span class="required"> * </span> 圆形半径 :</label> | ||
| 180 | - <div class="col-md-6"> | ||
| 181 | - <input type="text" class="form-control" name="radius" id="radiusInput" placeholder="请输入圆形半径"> | ||
| 182 | - </div> | ||
| 183 | - </div> | ||
| 184 | - </div> | ||
| 185 | - <!-- 是否撤销 --> | ||
| 186 | - <div class="form-body"> | ||
| 187 | - <div class="form-group"> | ||
| 188 | - <label class="col-md-3 control-label"><span class="required"> * </span>是否撤销 :</label> | ||
| 189 | - <div class="col-md-6"> | ||
| 190 | - <select name="destroy" class="form-control" id="destroySelect"> | ||
| 191 | - <option value="">-- 请选择撤销类型 --</option> | ||
| 192 | - <option value="0">否</option> | ||
| 193 | - <option value="1">是</option> | ||
| 194 | - </select> | ||
| 195 | - </div> | ||
| 196 | - </div> | ||
| 197 | - </div> | ||
| 198 | - <!-- 面积 --> | ||
| 199 | - <div class="form-body"> | ||
| 200 | - <div class="form-group"> | ||
| 201 | - <label class="col-md-3 control-label">面积 :</label> | ||
| 202 | - <div class="col-md-6"> | ||
| 203 | - <input type="text" class="form-control" name="area" id="areaInput" placeholder="请输入面积"> | ||
| 204 | - <span class="help-block">单位:平方米(㎡)</span> | ||
| 205 | - </div> | ||
| 206 | - </div> | ||
| 207 | - </div> | ||
| 208 | - <!-- 所属公司 --> | ||
| 209 | - <div class="form-body"> | ||
| 210 | - <div class="form-group"> | ||
| 211 | - <label class="col-md-3 control-label"><span class="required"> * </span>所属公司 :</label> | ||
| 212 | - <div class="col-md-6"> | ||
| 213 | - <select name="company" class="form-control" style="width:100%" id="companySelect"></select> | ||
| 214 | - </div> | ||
| 215 | - </div> | ||
| 216 | - </div> | ||
| 217 | - <!-- 所属分公司 --> | ||
| 218 | - <div class="form-body"> | ||
| 219 | - <div class="form-group"> | ||
| 220 | - <label class="col-md-3 control-label"><span class="required"> * </span>所属分公司 :</label> | ||
| 221 | - <div class="col-md-6"> | ||
| 222 | - <select name="brancheCompany" class="form-control" style="width:100%" id="brancheCompanySelect"> | ||
| 223 | - </select> | ||
| 224 | - </div> | ||
| 225 | - </div> | ||
| 226 | - </div> | ||
| 227 | - <!-- 版本号 --> | ||
| 228 | - <div class="form-body"> | ||
| 229 | - <div class="form-group"> | ||
| 230 | - <label class="col-md-3 control-label">版本号 :</label> | ||
| 231 | - <div class="col-md-6"> | ||
| 232 | - <input type="text" class="form-control" name="versions" value='1' Readonly placeholder="请输入版本号"> | ||
| 233 | - </div> | ||
| 234 | - </div> | ||
| 235 | - </div> | ||
| 236 | - <!-- 描述/说明 --> | ||
| 237 | - <div class="form-group"> | ||
| 238 | - <label class="control-label col-md-3"> 描述/说明 : </label> | ||
| 239 | - <div class="col-md-6"> | ||
| 240 | - <textarea class="form-control" rows="3" name="descriptions" id="descriptionsTextarea" placeholder="请输入描述/说明"></textarea> | ||
| 241 | - </div> | ||
| 242 | - </div> | ||
| 243 | - | ||
| 244 | - </div> | ||
| 245 | - <!-- 确定提交资料信息 --> | ||
| 246 | - <div class="tab-pane" id="tab4"> | ||
| 247 | - <h3 class="block"> 确认您提交的停车场信息 </h3> | ||
| 248 | - <h4 class="form-section"> 地理位置 </h4> | ||
| 249 | - <div class="form-group"> | ||
| 250 | - <label class="control-label col-md-3"> 几何图形类型: </label> | ||
| 251 | - <div class="col-md-4"> | ||
| 252 | - <p class="form-control-static" data-display="shapesType"> </p> | ||
| 253 | - </div> | ||
| 254 | - </div> | ||
| 255 | - <div class="form-group"> | ||
| 256 | - <label class="control-label col-md-3"> 圆形半径 : </label> | ||
| 257 | - <div class="col-md-4"> | ||
| 258 | - <p class="form-control-static" data-display="radius"> </p> | ||
| 259 | - </div> | ||
| 260 | - </div> | ||
| 261 | - | ||
| 262 | - <div class="form-group"> | ||
| 263 | - <label class="control-label col-md-3"> 经纬度坐标点: </label> | ||
| 264 | - <div class="col-md-4"> | ||
| 265 | - <p class="form-control-static" data-display="bCenterPoint"> </p> | ||
| 266 | - </div> | ||
| 267 | - </div> | ||
| 268 | - <h4 class="form-section"> 停车场信息 </h4> | ||
| 269 | - <div class="form-group"> | ||
| 270 | - <label class="control-label col-md-3">停车场名称 :</label> | ||
| 271 | - <div class="col-md-4"> | ||
| 272 | - <p class="form-control-static" data-display="parkName"> </p> | ||
| 273 | - </div> | ||
| 274 | - </div> | ||
| 275 | - <div class="form-group"> | ||
| 276 | - <label class="control-label col-md-3">停车场编码 :</label> | ||
| 277 | - <div class="col-md-4"> | ||
| 278 | - <p class="form-control-static" data-display="parkCode"> </p> | ||
| 279 | - </div> | ||
| 280 | - </div> | ||
| 281 | - <div class="form-group"> | ||
| 282 | - <label class="control-label col-md-3">是否撤销 :</label> | ||
| 283 | - <div class="col-md-4"> | ||
| 284 | - <p class="form-control-static" data-display="destroy"> </p> | ||
| 285 | - </div> | ||
| 286 | - </div> | ||
| 287 | - <div class="form-group"> | ||
| 288 | - <label class="control-label col-md-3">面积 :</label> | ||
| 289 | - <div class="col-md-4"> | ||
| 290 | - <p class="form-control-static" data-display="area"> </p> | ||
| 291 | - </div> | ||
| 292 | - </div> | ||
| 293 | - <div class="form-group"> | ||
| 294 | - <label class="control-label col-md-3">所属公司 :</label> | ||
| 295 | - <div class="col-md-4"> | ||
| 296 | - <p class="form-control-static" data-display="company"> </p> | ||
| 297 | - </div> | ||
| 298 | - </div> | ||
| 299 | - <div class="form-group"> | ||
| 300 | - <label class="control-label col-md-3">分公司 :</label> | ||
| 301 | - <div class="col-md-4"> | ||
| 302 | - <p class="form-control-static" data-display="brancheCompany"> </p> | ||
| 303 | - </div> | ||
| 304 | - </div> | ||
| 305 | - <div class="form-group"> | ||
| 306 | - <label class="control-label col-md-3">版本号 :</label> | ||
| 307 | - <div class="col-md-4"> | ||
| 308 | - <p class="form-control-static" data-display="versions"> </p> | ||
| 309 | - </div> | ||
| 310 | - </div> | ||
| 311 | - <div class="form-group"> | ||
| 312 | - <label class="control-label col-md-3">描述/说明 :</label> | ||
| 313 | - <div class="col-md-4"> | ||
| 314 | - <p class="form-control-static" data-display="descriptions"> </p> | ||
| 315 | - </div> | ||
| 316 | - </div> | ||
| 317 | - </div> | ||
| 318 | - </div> | ||
| 319 | - </div> | ||
| 320 | - <div class="form-actions"> | ||
| 321 | - <div class="row"> | ||
| 322 | - <div class="col-md-offset-3 col-md-9"> | ||
| 323 | - <a href="javascript:;" class="btn default button-previous disabled" style="display: none;"> | ||
| 324 | - <i class="fa fa-angle-left"></i> 返回 </a> | ||
| 325 | - <a href="javascript:;" class="btn btn-outline green button-next"> 下一步 | ||
| 326 | - <i class="fa fa-angle-right"></i> | ||
| 327 | - </a> | ||
| 328 | - <a href="javascript:;" class="btn green button-submit" style="display: none;" id="submintBtn"> 提交 | ||
| 329 | - <i class="fa fa-check"></i> | ||
| 330 | - </a> | ||
| 331 | - </div> | ||
| 332 | - </div> | ||
| 333 | - </div> | ||
| 334 | - </div> | ||
| 335 | - </form> | ||
| 336 | - <!-- END FORM--> | ||
| 337 | - </div> | ||
| 338 | -</div> | ||
| 339 | -<!-- 函数方法JS类库 --> | ||
| 340 | -<script src="/pages/base/carpark/js/add-input-function.js"></script> | ||
| 341 | -<!-- 表单向导JS类库 --> | ||
| 342 | -<script src="/pages/base/carpark/js/add-form-wizard.js"></script> | ||
| 343 | -<!-- reload事件 --> | ||
| 344 | -<script src="/pages/base/carpark/js/add-form-reload.js"></script> | ||
| 345 | -<!-- 地图JS类库 --> | ||
| 346 | -<script src="/pages/base/carpark/js/add-vmap-world.js"></script> | ||
| 347 | -<!-- 表单元素事件JS类库 --> | 1 | +<link href="/pages/base/carpark/css/carpark-add.css" rel="stylesheet" type="text/css" /> |
| 2 | +<div class="page-head"> | ||
| 3 | + <div class="page-title"> | ||
| 4 | + <h1>添加停车场</h1> | ||
| 5 | + </div> | ||
| 6 | +</div> | ||
| 7 | + | ||
| 8 | +<ul class="page-breadcrumb breadcrumb"> | ||
| 9 | + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li> | ||
| 10 | + <li><span class="active">基础信息</span> <i class="fa fa-circle"></i></li> | ||
| 11 | + <li><a href="/pages/base/carpark/list.html" data-pjax>场站信息</a> <i class="fa fa-circle"></i></li> | ||
| 12 | + <li><span class="active">添加停车场</span></li> | ||
| 13 | +</ul> | ||
| 14 | + | ||
| 15 | +<div class="portlet light bordered" id="form-wizard-info"> | ||
| 16 | + <div class="portlet-title"> | ||
| 17 | + <div class="caption"> | ||
| 18 | + <i class="icon-equalizer font-red-sunglo"></i> | ||
| 19 | + <span class="caption-subject font-red-sunglo bold uppercase">添加停车场 | ||
| 20 | + <span class="step-title"> 1 - 4 </span> | ||
| 21 | + <i class="fa fa-question-circle tipso-animation" style="color: rgba(158, 158, 158, 0.49);"></i> | ||
| 22 | + </span> | ||
| 23 | + </div> | ||
| 24 | + | ||
| 25 | + <div class="actions"> | ||
| 26 | + <div class="btn-group btn-group-devided" data-toggle="buttons"> | ||
| 27 | + <a class="btn btn-circle default" href="/pages/base/carpark/list.html" style="float: right;padding: 4px 23px;" data-pjax=""><i class="fa fa-reply"></i> 退出</a> | ||
| 28 | + </div> | ||
| 29 | + </div> | ||
| 30 | + </div> | ||
| 31 | + <div class="portlet-body form"> | ||
| 32 | + | ||
| 33 | + <!-- START FORM --> | ||
| 34 | + <form class="form-horizontal" id="submit_carpark_form" action="/" method="POST" novalidate="novalidate"> | ||
| 35 | + <div class="form-wizard"> | ||
| 36 | + <div class="form-body"> | ||
| 37 | + <ul class="nav nav-pills nav-justified steps"> | ||
| 38 | + <li class="active"> | ||
| 39 | + <a href="#tab1" data-toggle="tab" class="step" aria-expanded="true"> | ||
| 40 | + <span class="number"> 1 </span> | ||
| 41 | + <span class="desc"> | ||
| 42 | + <i class="fa fa-check"></i> 获取停车场位置方式 </span> | ||
| 43 | + </a> | ||
| 44 | + </li> | ||
| 45 | + <li> | ||
| 46 | + <a href="#tab2" data-toggle="tab" class="step"> | ||
| 47 | + <span class="number"> 2 </span> | ||
| 48 | + <span class="desc"> | ||
| 49 | + <i class="fa fa-check"></i> 确定停车场位置 </span> | ||
| 50 | + </a> | ||
| 51 | + </li> | ||
| 52 | + <li> | ||
| 53 | + <a href="#tab3" data-toggle="tab" class="step active"> | ||
| 54 | + <span class="number"> 3 </span> | ||
| 55 | + <span class="desc"> | ||
| 56 | + <i class="fa fa-check"></i> 填写场站信息 </span> | ||
| 57 | + </a> | ||
| 58 | + </li> | ||
| 59 | + <li> | ||
| 60 | + <a href="#tab4" data-toggle="tab" class="step"> | ||
| 61 | + <span class="number"> 4 </span> | ||
| 62 | + <span class="desc"> | ||
| 63 | + <i class="fa fa-check"></i> 确认并提交 </span> | ||
| 64 | + </a> | ||
| 65 | + </li> | ||
| 66 | + </ul> | ||
| 67 | + | ||
| 68 | + <!-- 进度条 --> | ||
| 69 | + <div id="bar" class="progress progress-striped" role="progressbar"> | ||
| 70 | + <div class="progress-bar progress-bar-success" style="width: 25%;"></div> | ||
| 71 | + </div> | ||
| 72 | + | ||
| 73 | + <div class="tab-content"> | ||
| 74 | + <div class="alert alert-danger display-hide"> | ||
| 75 | + <button class="close" data-close="alert"></button> | ||
| 76 | + 您的输入有误,请检查下面的输入项 | ||
| 77 | + </div> | ||
| 78 | + <div class="alert alert-success display-none"> | ||
| 79 | + <button class="close" data-dismiss="alert"></button> | ||
| 80 | + Your form validation is successful! | ||
| 81 | + </div> | ||
| 82 | + | ||
| 83 | + <!-- 选择添加站点方式 --> | ||
| 84 | + <div class="tab-pane active" id="tab1"> | ||
| 85 | + <h3 class="block"> 获取停车场位置方式 </h3> | ||
| 86 | + <!--停车场名称 --> | ||
| 87 | + <div class="form-group" id="formRequ"> | ||
| 88 | + <label class="col-md-3 control-label"><span class="required"> * </span>停车场名称 :</label> | ||
| 89 | + <div class="col-md-9"> | ||
| 90 | + <input type="text" class="form-control input-medium" id="parkNamebooxtInput" name="parkNamebooxt" placeholder="请输入停车场名称"> | ||
| 91 | + </div> | ||
| 92 | + </div> | ||
| 93 | + <!-- 新增方式 --> | ||
| 94 | + <div class="form-group"> | ||
| 95 | + <label class="col-md-3 control-label"><span class="required"> * </span>选择获取方式:</label> | ||
| 96 | + <div class="col-md-9"> | ||
| 97 | + <div class="icheck-list"> | ||
| 98 | + <label> | ||
| 99 | + <input type="radio" class="icheck" name="baseRes" value=0 checked> 系统生成 | ||
| 100 | + </label> | ||
| 101 | + <label > | ||
| 102 | + <input type="radio" class="icheck" name="baseRes" value=1 > 手动绘制 | ||
| 103 | + </label> | ||
| 104 | + </div> | ||
| 105 | + </div> | ||
| 106 | + </div> | ||
| 107 | + </div> | ||
| 108 | + <!--停车场位置 --> | ||
| 109 | + <div class="tab-pane" id="tab2"> | ||
| 110 | + <h3 class="block"> 停车场位置 </h3> | ||
| 111 | + <div id="addCarParkbmap_basic"></div> | ||
| 112 | + <div class="leftUtils"> | ||
| 113 | + <div class="btn-group" style="left: 100px;"> | ||
| 114 | + <a class="btn btn-sm green-seagreen dropdown-toggle" style="width: 98px;" href="javascript:;" data-toggle="dropdown" aria-expanded="false"> 绘制工具 | ||
| 115 | + <i class="fa fa-angle-down"></i> | ||
| 116 | + </a> | ||
| 117 | + <ul class="dropdown-menu pull-right" style="min-width:100px"> | ||
| 118 | + <li> | ||
| 119 | + <a href="javascript:;" id="oppenDrawingManager"><i class="fa fa-pencil"></i> 打开 </a> | ||
| 120 | + </li> | ||
| 121 | + <li> | ||
| 122 | + <a href="javascript:;" id = "closeDrawingManager"> <i class="fa fa-reply"></i> 关闭 </a> | ||
| 123 | + </li> | ||
| 124 | + | ||
| 125 | + </ul> | ||
| 126 | + </div> | ||
| 127 | + </div> | ||
| 128 | + </div> | ||
| 129 | + <!--场站信息 --> | ||
| 130 | + <div class="tab-pane" id="tab3"> | ||
| 131 | + <h3 class="block"> 场站信息 </h3> | ||
| 132 | + <input type="hidden" name="bParkPoint" id="bParkPointInput" /> | ||
| 133 | + <input type="hidden" name="gParkPoint" id="gParkPointInput" /> | ||
| 134 | + <input type="hidden" name="dbType" id="dbTypeInput" value="b"/> | ||
| 135 | + <!-- 停车场名称 --> | ||
| 136 | + <div class="form-body"> | ||
| 137 | + <div class="form-group"> | ||
| 138 | + <label class="control-label col-md-3"> | ||
| 139 | + <span class="required"> * </span> 停车场名称 : | ||
| 140 | + </label> | ||
| 141 | + <div class="col-md-6"> | ||
| 142 | + <input type="text" class="form-control" name="parkName" id="parkNameInput" placeholder="请输入站点名称" readonly="readonly"> | ||
| 143 | + </div> | ||
| 144 | + </div> | ||
| 145 | + </div> | ||
| 146 | + <!-- 停车场编码 --> | ||
| 147 | + <div class="form-body"> | ||
| 148 | + <div class="form-group"> | ||
| 149 | + <label class="control-label col-md-3"> | ||
| 150 | + <span class="required"> * </span>停车场编码 : | ||
| 151 | + </label> | ||
| 152 | + <div class="col-md-6"> | ||
| 153 | + <input type="text" class="form-control" name="parkCode" id="parkCodeInput" placeholder="请输入停车场编码"> | ||
| 154 | + </div> | ||
| 155 | + </div> | ||
| 156 | + </div> | ||
| 157 | + <!-- 经纬度坐标点 --> | ||
| 158 | + <div class="form-body"> | ||
| 159 | + <div class="form-group"> | ||
| 160 | + <label class="col-md-3 control-label"><span class="required"> * </span>经纬度坐标点:</label> | ||
| 161 | + <div class="col-md-6"> | ||
| 162 | + <input type="text" class="form-control" name="bCenterPoint" id="bCenterPointInput" readonly="readonly" placeholder="请输入经纬度坐标点"> | ||
| 163 | + </div> | ||
| 164 | + </div> | ||
| 165 | + </div> | ||
| 166 | + | ||
| 167 | + <!-- 几何图形类型 --> | ||
| 168 | + <div class="form-body"> | ||
| 169 | + <div class="form-group"> | ||
| 170 | + <label class="col-md-3 control-label"><span class="required"> * </span>几何图形类型:</label> | ||
| 171 | + <div class="col-md-6"> | ||
| 172 | + <input type="text" class="form-control" name="shapesType" id="shapesTypeSelect" readonly="readonly" placeholder="请输入几何图形类型"> | ||
| 173 | + </div> | ||
| 174 | + </div> | ||
| 175 | + </div> | ||
| 176 | + <!-- 圆形半径 --> | ||
| 177 | + <div class="form-body" id="radiusGroup"> | ||
| 178 | + <div class="form-group"> | ||
| 179 | + <label class="col-md-3 control-label"><span class="required"> * </span> 圆形半径 :</label> | ||
| 180 | + <div class="col-md-6"> | ||
| 181 | + <input type="text" class="form-control" name="radius" id="radiusInput" placeholder="请输入圆形半径"> | ||
| 182 | + </div> | ||
| 183 | + </div> | ||
| 184 | + </div> | ||
| 185 | + <!-- 是否撤销 --> | ||
| 186 | + <div class="form-body"> | ||
| 187 | + <div class="form-group"> | ||
| 188 | + <label class="col-md-3 control-label"><span class="required"> * </span>是否撤销 :</label> | ||
| 189 | + <div class="col-md-6"> | ||
| 190 | + <select name="destroy" class="form-control" id="destroySelect"> | ||
| 191 | + <option value="">-- 请选择撤销类型 --</option> | ||
| 192 | + <option value="0">否</option> | ||
| 193 | + <option value="1">是</option> | ||
| 194 | + </select> | ||
| 195 | + </div> | ||
| 196 | + </div> | ||
| 197 | + </div> | ||
| 198 | + <!-- 面积 --> | ||
| 199 | + <div class="form-body"> | ||
| 200 | + <div class="form-group"> | ||
| 201 | + <label class="col-md-3 control-label">面积 :</label> | ||
| 202 | + <div class="col-md-6"> | ||
| 203 | + <input type="text" class="form-control" name="area" id="areaInput" placeholder="请输入面积"> | ||
| 204 | + <span class="help-block">单位:平方米(㎡)</span> | ||
| 205 | + </div> | ||
| 206 | + </div> | ||
| 207 | + </div> | ||
| 208 | + <!-- 所属公司 --> | ||
| 209 | + <div class="form-body"> | ||
| 210 | + <div class="form-group"> | ||
| 211 | + <label class="col-md-3 control-label"><span class="required"> * </span>所属公司 :</label> | ||
| 212 | + <div class="col-md-6"> | ||
| 213 | + <select name="company" class="form-control" style="width:100%" id="companySelect"></select> | ||
| 214 | + </div> | ||
| 215 | + </div> | ||
| 216 | + </div> | ||
| 217 | + <!-- 所属分公司 --> | ||
| 218 | + <div class="form-body"> | ||
| 219 | + <div class="form-group"> | ||
| 220 | + <label class="col-md-3 control-label"><span class="required"> * </span>所属分公司 :</label> | ||
| 221 | + <div class="col-md-6"> | ||
| 222 | + <select name="brancheCompany" class="form-control" style="width:100%" id="brancheCompanySelect"> | ||
| 223 | + </select> | ||
| 224 | + </div> | ||
| 225 | + </div> | ||
| 226 | + </div> | ||
| 227 | + <!-- 版本号 --> | ||
| 228 | + <div class="form-body"> | ||
| 229 | + <div class="form-group"> | ||
| 230 | + <label class="col-md-3 control-label">版本号 :</label> | ||
| 231 | + <div class="col-md-6"> | ||
| 232 | + <input type="text" class="form-control" name="versions" value='1' Readonly placeholder="请输入版本号"> | ||
| 233 | + </div> | ||
| 234 | + </div> | ||
| 235 | + </div> | ||
| 236 | + <!-- 描述/说明 --> | ||
| 237 | + <div class="form-group"> | ||
| 238 | + <label class="control-label col-md-3"> 描述/说明 : </label> | ||
| 239 | + <div class="col-md-6"> | ||
| 240 | + <textarea class="form-control" rows="3" name="descriptions" id="descriptionsTextarea" placeholder="请输入描述/说明"></textarea> | ||
| 241 | + </div> | ||
| 242 | + </div> | ||
| 243 | + | ||
| 244 | + </div> | ||
| 245 | + <!-- 确定提交资料信息 --> | ||
| 246 | + <div class="tab-pane" id="tab4"> | ||
| 247 | + <h3 class="block"> 确认您提交的场站信息 </h3> | ||
| 248 | + <h4 class="form-section"> 地理位置 </h4> | ||
| 249 | + <div class="form-group"> | ||
| 250 | + <label class="control-label col-md-3"> 几何图形类型: </label> | ||
| 251 | + <div class="col-md-4"> | ||
| 252 | + <p class="form-control-static" data-display="shapesType"> </p> | ||
| 253 | + </div> | ||
| 254 | + </div> | ||
| 255 | + <div class="form-group"> | ||
| 256 | + <label class="control-label col-md-3"> 圆形半径 : </label> | ||
| 257 | + <div class="col-md-4"> | ||
| 258 | + <p class="form-control-static" data-display="radius"> </p> | ||
| 259 | + </div> | ||
| 260 | + </div> | ||
| 261 | + | ||
| 262 | + <div class="form-group"> | ||
| 263 | + <label class="control-label col-md-3"> 经纬度坐标点: </label> | ||
| 264 | + <div class="col-md-4"> | ||
| 265 | + <p class="form-control-static" data-display="bCenterPoint"> </p> | ||
| 266 | + </div> | ||
| 267 | + </div> | ||
| 268 | + <h4 class="form-section"> 场站信息 </h4> | ||
| 269 | + <div class="form-group"> | ||
| 270 | + <label class="control-label col-md-3">停车场名称 :</label> | ||
| 271 | + <div class="col-md-4"> | ||
| 272 | + <p class="form-control-static" data-display="parkName"> </p> | ||
| 273 | + </div> | ||
| 274 | + </div> | ||
| 275 | + <div class="form-group"> | ||
| 276 | + <label class="control-label col-md-3">停车场编码 :</label> | ||
| 277 | + <div class="col-md-4"> | ||
| 278 | + <p class="form-control-static" data-display="parkCode"> </p> | ||
| 279 | + </div> | ||
| 280 | + </div> | ||
| 281 | + <div class="form-group"> | ||
| 282 | + <label class="control-label col-md-3">是否撤销 :</label> | ||
| 283 | + <div class="col-md-4"> | ||
| 284 | + <p class="form-control-static" data-display="destroy"> </p> | ||
| 285 | + </div> | ||
| 286 | + </div> | ||
| 287 | + <div class="form-group"> | ||
| 288 | + <label class="control-label col-md-3">面积 :</label> | ||
| 289 | + <div class="col-md-4"> | ||
| 290 | + <p class="form-control-static" data-display="area"> </p> | ||
| 291 | + </div> | ||
| 292 | + </div> | ||
| 293 | + <div class="form-group"> | ||
| 294 | + <label class="control-label col-md-3">所属公司 :</label> | ||
| 295 | + <div class="col-md-4"> | ||
| 296 | + <p class="form-control-static" data-display="company"> </p> | ||
| 297 | + </div> | ||
| 298 | + </div> | ||
| 299 | + <div class="form-group"> | ||
| 300 | + <label class="control-label col-md-3">分公司 :</label> | ||
| 301 | + <div class="col-md-4"> | ||
| 302 | + <p class="form-control-static" data-display="brancheCompany"> </p> | ||
| 303 | + </div> | ||
| 304 | + </div> | ||
| 305 | + <div class="form-group"> | ||
| 306 | + <label class="control-label col-md-3">版本号 :</label> | ||
| 307 | + <div class="col-md-4"> | ||
| 308 | + <p class="form-control-static" data-display="versions"> </p> | ||
| 309 | + </div> | ||
| 310 | + </div> | ||
| 311 | + <div class="form-group"> | ||
| 312 | + <label class="control-label col-md-3">描述/说明 :</label> | ||
| 313 | + <div class="col-md-4"> | ||
| 314 | + <p class="form-control-static" data-display="descriptions"> </p> | ||
| 315 | + </div> | ||
| 316 | + </div> | ||
| 317 | + </div> | ||
| 318 | + </div> | ||
| 319 | + </div> | ||
| 320 | + <div class="form-actions"> | ||
| 321 | + <div class="row"> | ||
| 322 | + <div class="col-md-offset-3 col-md-9"> | ||
| 323 | + <a href="javascript:;" class="btn default button-previous disabled" style="display: none;"> | ||
| 324 | + <i class="fa fa-angle-left"></i> 返回 </a> | ||
| 325 | + <a href="javascript:;" class="btn btn-outline green button-next"> 下一步 | ||
| 326 | + <i class="fa fa-angle-right"></i> | ||
| 327 | + </a> | ||
| 328 | + <a href="javascript:;" class="btn green button-submit" style="display: none;" id="submintBtn"> 提交 | ||
| 329 | + <i class="fa fa-check"></i> | ||
| 330 | + </a> | ||
| 331 | + </div> | ||
| 332 | + </div> | ||
| 333 | + </div> | ||
| 334 | + </div> | ||
| 335 | + </form> | ||
| 336 | + <!-- END FORM--> | ||
| 337 | + </div> | ||
| 338 | +</div> | ||
| 339 | +<!-- 函数方法JS类库 --> | ||
| 340 | +<script src="/pages/base/carpark/js/add-input-function.js"></script> | ||
| 341 | +<!-- 表单向导JS类库 --> | ||
| 342 | +<script src="/pages/base/carpark/js/add-form-wizard.js"></script> | ||
| 343 | +<!-- reload事件 --> | ||
| 344 | +<script src="/pages/base/carpark/js/add-form-reload.js"></script> | ||
| 345 | +<!-- 地图JS类库 --> | ||
| 346 | +<script src="/pages/base/carpark/js/add-vmap-world.js"></script> | ||
| 347 | +<!-- 表单元素事件JS类库 --> | ||
| 348 | <script src="/pages/base/carpark/js/add-form-events.js"></script> | 348 | <script src="/pages/base/carpark/js/add-form-events.js"></script> |
| 349 | \ No newline at end of file | 349 | \ No newline at end of file |
src/main/resources/static/pages/base/carpark/edit.html
| @@ -145,7 +145,7 @@ | @@ -145,7 +145,7 @@ | ||
| 145 | <script type="text/javascript"> | 145 | <script type="text/javascript"> |
| 146 | 146 | ||
| 147 | $('#editPoitsions_carpark_mobal').on('editCarParkMobal_show', function(e, map,fun,carP,ajaxd){ | 147 | $('#editPoitsions_carpark_mobal').on('editCarParkMobal_show', function(e, map,fun,carP,ajaxd){ |
| 148 | - /** 获取停车场信息对象 */ | 148 | + /** 获取场站信息对象 */ |
| 149 | var CarParkObj = carP.getEitdCarPark(); | 149 | var CarParkObj = carP.getEitdCarPark(); |
| 150 | // 获取修改停车场对象ID | 150 | // 获取修改停车场对象ID |
| 151 | var carParkId = CarParkObj.carParkId; | 151 | var carParkId = CarParkObj.carParkId; |
src/main/resources/static/pages/base/carpark/js/add-vmap-world.js
| 1 | -var addCarParkVmapWorlds = function() { | ||
| 2 | - var mapB = '', circle = '', drawingManager = '',circle='',marker=''; | ||
| 3 | - var Bmap = { | ||
| 4 | - init : function() { | ||
| 5 | - // 设置中心点, | ||
| 6 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 7 | - // 百度API Key | ||
| 8 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 9 | - // 初始化百度地图 | ||
| 10 | - mapB = new BMap.Map("addCarParkbmap_basic"); | ||
| 11 | - //中心点和缩放级别 | ||
| 12 | - mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 13 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 14 | - mapB.enableDragging(); | ||
| 15 | - //启用地图滚轮放大缩小 | ||
| 16 | - mapB.enableScrollWheelZoom(); | ||
| 17 | - //禁用鼠标双击放大 | ||
| 18 | - mapB.disableDoubleClickZoom(); | ||
| 19 | - //启用键盘上下左右键移动地图 | ||
| 20 | - mapB.enableKeyboard(); | ||
| 21 | - var styleOptions = { | ||
| 22 | - //边线颜色。 | ||
| 23 | - strokeColor : "blue", | ||
| 24 | - //填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 25 | - fillColor : "blue", | ||
| 26 | - //边线的宽度,以像素为单位。 | ||
| 27 | - strokeWeight : 3, | ||
| 28 | - //边线透明度,取值范围0 - 1。 | ||
| 29 | - strokeOpacity : 0.8, | ||
| 30 | - //填充的透明度,取值范围0 - 1。 | ||
| 31 | - fillOpacity : 0.6, | ||
| 32 | - //边线的样式,solid或dashed。 | ||
| 33 | - strokeStyle : 'solid' | ||
| 34 | - }; | ||
| 35 | - // 创建鼠标绘制管理类 | ||
| 36 | - drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 37 | - //是否开启绘制模式 | ||
| 38 | - isOpen : false, | ||
| 39 | - //是否显示工具栏 | ||
| 40 | - enableDrawingTool : false, | ||
| 41 | - drawingToolOptions : { | ||
| 42 | - //位置 | ||
| 43 | - anchor : BMAP_ANCHOR_TOP_RIGHT, | ||
| 44 | - //偏离值 | ||
| 45 | - offset : new BMap.Size(5, 5), | ||
| 46 | - //工具栏缩放比例 | ||
| 47 | - scale : 0.8 | ||
| 48 | - }, | ||
| 49 | - //线的样式 | ||
| 50 | - polygonOptions : styleOptions | ||
| 51 | - }); | ||
| 52 | - // 添加绘画完成事件 | ||
| 53 | - drawingManager.addEventListener('polygoncomplete', function(e) { | ||
| 54 | - drawingManager.close(); | ||
| 55 | - if (e.getPath().length <= 2) { | ||
| 56 | - // 弹出提示消息 | ||
| 57 | - layer.msg('坐标点不能小于等于两个...'); | ||
| 58 | - // 清除地图覆盖物 | ||
| 59 | - mapB.clearOverlays(); | ||
| 60 | - drawingManager.open(); | ||
| 61 | - return false; | ||
| 62 | - }else { | ||
| 63 | - var pointE = e; | ||
| 64 | - // 多变行质心点 | ||
| 65 | - var addSttationPoints_ = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat; | ||
| 66 | - var addPolyGonLen_ = pointE.getPath().length; | ||
| 67 | - for(var k =0;k<addPolyGonLen_;k++) { | ||
| 68 | - if(k==0) { | ||
| 69 | - bPloygonGrid = pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 70 | - }else { | ||
| 71 | - bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 72 | - } | ||
| 73 | - } | ||
| 74 | - bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[0].lng + ' ' + pointE.getPath()[0].lat; | ||
| 75 | - PublicFunctions.setFormInputValue(addSttationPoints_,bPloygonGrid,'d',''); | ||
| 76 | - } | ||
| 77 | - }); | ||
| 78 | - return mapB; | ||
| 79 | - }, | ||
| 80 | - // 根据地理名称获取百度经纬度坐标 | ||
| 81 | - localSearchFromAdreesToPoint: function(Address,cb) { | ||
| 82 | - // 创建一个搜索类实例 | ||
| 83 | - var localSearch = new BMap.LocalSearch(mapB); | ||
| 84 | - // 检索完成后的回调函数。 | ||
| 85 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 86 | - var resultPoints = ''; | ||
| 87 | - if(searchResult) { | ||
| 88 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 89 | - var poi = searchResult.getPoi(0); | ||
| 90 | - if(poi) { | ||
| 91 | - //获取经度和纬度 | ||
| 92 | - var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 93 | - marker = new BMap.Marker(stationNameChangePoint); | ||
| 94 | - var PanOptions ={noAnimation :true}; | ||
| 95 | - mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 96 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 97 | - mapB.setZoom(18); | ||
| 98 | - mapB.panBy(0,-80); | ||
| 99 | - // 将标注添加到地图中 | ||
| 100 | - mapB.addOverlay(marker); | ||
| 101 | - //跳动的动画 | ||
| 102 | - marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 103 | - cb && cb(stationNameChangePoint); | ||
| 104 | - }else { | ||
| 105 | - // 弹出添加成功提示消息 | ||
| 106 | - layer.msg('无法获取停车场【'+Address+'】地理位置!'); | ||
| 107 | - cb && cb(false); | ||
| 108 | - } | ||
| 109 | - }else { | ||
| 110 | - // 弹出添加成功提示消息 | ||
| 111 | - layer.msg('无法获取停车场【'+Address+'】地理位置!'); | ||
| 112 | - cb && cb(false); | ||
| 113 | - } | ||
| 114 | - }); | ||
| 115 | - // 根据检索词发起检索。 | ||
| 116 | - localSearch.search(Address); | ||
| 117 | - }, | ||
| 118 | - | ||
| 119 | - // 画圆 | ||
| 120 | - pointsCircle : function(stationNameChangePoint) { | ||
| 121 | - //创建圆 | ||
| 122 | - circle = new BMap.Circle(stationNameChangePoint,100,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 123 | - // 百度地图添加覆盖物圆 | ||
| 124 | - mapB.addOverlay(circle); | ||
| 125 | - // 开启编辑功能 | ||
| 126 | - circle.enableEditing(); | ||
| 127 | - // 编辑圆监听事件 | ||
| 128 | - circle.addEventListener('remove',function() { | ||
| 129 | - // 清除marker | ||
| 130 | - mapB.removeOverlay(marker); | ||
| 131 | - // 返回圆形的半径,单位为米。 | ||
| 132 | - var newRadius = circle.getRadius(); | ||
| 133 | - // 返回圆形的中心点坐标。 | ||
| 134 | - var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 135 | - var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 136 | - circle = ''; | ||
| 137 | - PublicFunctions.setFormInputValue(newCenter,'','r',Math.round(newRadius)); | ||
| 138 | - }); | ||
| 139 | - }, | ||
| 140 | - // 打开绘画工具 | ||
| 141 | - drawingManagerOpen : function() { | ||
| 142 | - // 打开鼠标绘画工具 | ||
| 143 | - drawingManager.open(); | ||
| 144 | - // 设置属性 | ||
| 145 | - drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON); | ||
| 146 | - }, | ||
| 147 | - drawingManagerClose : function() { | ||
| 148 | - drawingManager.close(); | ||
| 149 | - }, | ||
| 150 | - clearMarkAndOverlays : function() { | ||
| 151 | - // 清楚地图覆盖物 | ||
| 152 | - mapB.clearOverlays(); | ||
| 153 | - } | ||
| 154 | - } | ||
| 155 | - return Bmap; | 1 | +var addCarParkVmapWorlds = function() { |
| 2 | + var mapB = '', circle = '', drawingManager = '',circle='',marker=''; | ||
| 3 | + var Bmap = { | ||
| 4 | + init : function() { | ||
| 5 | + // 设置中心点, | ||
| 6 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 7 | + // 百度API Key | ||
| 8 | + var bdKey = '1TgEKvYqohJyeGXnN6yHSSTb4psOarQw'; | ||
| 9 | + // 初始化百度地图 | ||
| 10 | + mapB = new BMap.Map("addCarParkbmap_basic"); | ||
| 11 | + //中心点和缩放级别 | ||
| 12 | + mapB.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 13 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 14 | + mapB.enableDragging(); | ||
| 15 | + //启用地图滚轮放大缩小 | ||
| 16 | + mapB.enableScrollWheelZoom(); | ||
| 17 | + //禁用鼠标双击放大 | ||
| 18 | + mapB.disableDoubleClickZoom(); | ||
| 19 | + //启用键盘上下左右键移动地图 | ||
| 20 | + mapB.enableKeyboard(); | ||
| 21 | + var styleOptions = { | ||
| 22 | + //边线颜色。 | ||
| 23 | + strokeColor : "blue", | ||
| 24 | + //填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 25 | + fillColor : "blue", | ||
| 26 | + //边线的宽度,以像素为单位。 | ||
| 27 | + strokeWeight : 3, | ||
| 28 | + //边线透明度,取值范围0 - 1。 | ||
| 29 | + strokeOpacity : 0.8, | ||
| 30 | + //填充的透明度,取值范围0 - 1。 | ||
| 31 | + fillOpacity : 0.6, | ||
| 32 | + //边线的样式,solid或dashed。 | ||
| 33 | + strokeStyle : 'solid' | ||
| 34 | + }; | ||
| 35 | + // 创建鼠标绘制管理类 | ||
| 36 | + drawingManager = new BMapLib.DrawingManager(mapB, { | ||
| 37 | + //是否开启绘制模式 | ||
| 38 | + isOpen : false, | ||
| 39 | + //是否显示工具栏 | ||
| 40 | + enableDrawingTool : false, | ||
| 41 | + drawingToolOptions : { | ||
| 42 | + //位置 | ||
| 43 | + anchor : BMAP_ANCHOR_TOP_RIGHT, | ||
| 44 | + //偏离值 | ||
| 45 | + offset : new BMap.Size(5, 5), | ||
| 46 | + //工具栏缩放比例 | ||
| 47 | + scale : 0.8 | ||
| 48 | + }, | ||
| 49 | + //线的样式 | ||
| 50 | + polygonOptions : styleOptions | ||
| 51 | + }); | ||
| 52 | + // 添加绘画完成事件 | ||
| 53 | + drawingManager.addEventListener('polygoncomplete', function(e) { | ||
| 54 | + drawingManager.close(); | ||
| 55 | + if (e.getPath().length <= 2) { | ||
| 56 | + // 弹出提示消息 | ||
| 57 | + layer.msg('坐标点不能小于等于两个...'); | ||
| 58 | + // 清除地图覆盖物 | ||
| 59 | + mapB.clearOverlays(); | ||
| 60 | + drawingManager.open(); | ||
| 61 | + return false; | ||
| 62 | + }else { | ||
| 63 | + var pointE = e; | ||
| 64 | + // 多变行质心点 | ||
| 65 | + var addSttationPoints_ = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat; | ||
| 66 | + var addPolyGonLen_ = pointE.getPath().length; | ||
| 67 | + for(var k =0;k<addPolyGonLen_;k++) { | ||
| 68 | + if(k==0) { | ||
| 69 | + bPloygonGrid = pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 70 | + }else { | ||
| 71 | + bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[0].lng + ' ' + pointE.getPath()[0].lat; | ||
| 75 | + PublicFunctions.setFormInputValue(addSttationPoints_,bPloygonGrid,'d',''); | ||
| 76 | + } | ||
| 77 | + }); | ||
| 78 | + return mapB; | ||
| 79 | + }, | ||
| 80 | + // 根据地理名称获取百度经纬度坐标 | ||
| 81 | + localSearchFromAdreesToPoint: function(Address,cb) { | ||
| 82 | + // 创建一个搜索类实例 | ||
| 83 | + var localSearch = new BMap.LocalSearch(mapB); | ||
| 84 | + // 检索完成后的回调函数。 | ||
| 85 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 86 | + var resultPoints = ''; | ||
| 87 | + if(searchResult) { | ||
| 88 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 89 | + var poi = searchResult.getPoi(0); | ||
| 90 | + if(poi) { | ||
| 91 | + //获取经度和纬度 | ||
| 92 | + var stationNameChangePoint = new BMap.Point( poi.point.lng, poi.point.lat); | ||
| 93 | + marker = new BMap.Marker(stationNameChangePoint); | ||
| 94 | + var PanOptions ={noAnimation :true}; | ||
| 95 | + mapB.panTo(stationNameChangePoint,PanOptions); | ||
| 96 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 97 | + mapB.setZoom(18); | ||
| 98 | + mapB.panBy(0,-80); | ||
| 99 | + // 将标注添加到地图中 | ||
| 100 | + mapB.addOverlay(marker); | ||
| 101 | + //跳动的动画 | ||
| 102 | + marker.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 103 | + cb && cb(stationNameChangePoint); | ||
| 104 | + }else { | ||
| 105 | + // 弹出添加成功提示消息 | ||
| 106 | + layer.msg('无法获取停车场【'+Address+'】地理位置!'); | ||
| 107 | + cb && cb(false); | ||
| 108 | + } | ||
| 109 | + }else { | ||
| 110 | + // 弹出添加成功提示消息 | ||
| 111 | + layer.msg('无法获取停车场【'+Address+'】地理位置!'); | ||
| 112 | + cb && cb(false); | ||
| 113 | + } | ||
| 114 | + }); | ||
| 115 | + // 根据检索词发起检索。 | ||
| 116 | + localSearch.search(Address); | ||
| 117 | + }, | ||
| 118 | + | ||
| 119 | + // 画圆 | ||
| 120 | + pointsCircle : function(stationNameChangePoint) { | ||
| 121 | + //创建圆 | ||
| 122 | + circle = new BMap.Circle(stationNameChangePoint,100,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 123 | + // 百度地图添加覆盖物圆 | ||
| 124 | + mapB.addOverlay(circle); | ||
| 125 | + // 开启编辑功能 | ||
| 126 | + circle.enableEditing(); | ||
| 127 | + // 编辑圆监听事件 | ||
| 128 | + circle.addEventListener('remove',function() { | ||
| 129 | + // 清除marker | ||
| 130 | + mapB.removeOverlay(marker); | ||
| 131 | + // 返回圆形的半径,单位为米。 | ||
| 132 | + var newRadius = circle.getRadius(); | ||
| 133 | + // 返回圆形的中心点坐标。 | ||
| 134 | + var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 135 | + var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 136 | + circle = ''; | ||
| 137 | + PublicFunctions.setFormInputValue(newCenter,'','r',Math.round(newRadius)); | ||
| 138 | + }); | ||
| 139 | + }, | ||
| 140 | + // 打开绘画工具 | ||
| 141 | + drawingManagerOpen : function() { | ||
| 142 | + // 打开鼠标绘画工具 | ||
| 143 | + drawingManager.open(); | ||
| 144 | + // 设置属性 | ||
| 145 | + drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON); | ||
| 146 | + }, | ||
| 147 | + drawingManagerClose : function() { | ||
| 148 | + drawingManager.close(); | ||
| 149 | + }, | ||
| 150 | + clearMarkAndOverlays : function() { | ||
| 151 | + // 清楚地图覆盖物 | ||
| 152 | + mapB.clearOverlays(); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + return Bmap; | ||
| 156 | }(); | 156 | }(); |
| 157 | \ No newline at end of file | 157 | \ No newline at end of file |
src/main/resources/static/pages/base/carpark/js/carpark-positions-ajax.js
| 1 | -/** | ||
| 2 | - * GetAjaxData :ajax异步请求 | ||
| 3 | - * | ||
| 4 | - */ | ||
| 5 | -var GetAjaxData = function(){ | ||
| 6 | - var ajaxData = { | ||
| 7 | - // 查询停车场信息 | ||
| 8 | - getCarParkInfo : function(carParkId,callback){ | ||
| 9 | - $get('/carpark/findCarParkInfoFormId',{id:carParkId},function(r) { | ||
| 10 | - return callback && callback(r); | ||
| 11 | - }); | ||
| 12 | - }, | ||
| 13 | - carParkUpdate : function(params,callback){ | ||
| 14 | - $post('/carpark/carParkUpdate',params,function(data) { | ||
| 15 | - callback && callback(data); | ||
| 16 | - }); | ||
| 17 | - } | ||
| 18 | - } | ||
| 19 | - return ajaxData; | 1 | +/** |
| 2 | + * GetAjaxData :ajax异步请求 | ||
| 3 | + * | ||
| 4 | + */ | ||
| 5 | +var GetAjaxData = function(){ | ||
| 6 | + var ajaxData = { | ||
| 7 | + // 查询场站信息 | ||
| 8 | + getCarParkInfo : function(carParkId,callback){ | ||
| 9 | + $get('/carpark/findCarParkInfoFormId',{id:carParkId},function(r) { | ||
| 10 | + return callback && callback(r); | ||
| 11 | + }); | ||
| 12 | + }, | ||
| 13 | + carParkUpdate : function(params,callback){ | ||
| 14 | + $post('/carpark/carParkUpdate',params,function(data) { | ||
| 15 | + callback && callback(data); | ||
| 16 | + }); | ||
| 17 | + } | ||
| 18 | + } | ||
| 19 | + return ajaxData; | ||
| 20 | }(); | 20 | }(); |
| 21 | \ No newline at end of file | 21 | \ No newline at end of file |
src/main/resources/static/pages/base/carpark/js/carpark-positions-function.js
| @@ -5,15 +5,15 @@ | @@ -5,15 +5,15 @@ | ||
| 5 | 5 | ||
| 6 | var PublicFunctions = function () { | 6 | var PublicFunctions = function () { |
| 7 | var PubFun = { | 7 | var PubFun = { |
| 8 | - /** 停车场信息初始化 @param:<id:停车场ID> */ | 8 | + /** 场站信息初始化 @param:<id:停车场ID> */ |
| 9 | initCarPark : function(id) { | 9 | initCarPark : function(id) { |
| 10 | - /** 获取停车场信息 @param:<id:停车场Id> */ | 10 | + /** 获取场站信息 @param:<id:停车场Id> */ |
| 11 | GetAjaxData.getCarParkInfo(id,function(r) { | 11 | GetAjaxData.getCarParkInfo(id,function(r) { |
| 12 | // 获取返回数据长度 | 12 | // 获取返回数据长度 |
| 13 | var len = r.length; | 13 | var len = r.length; |
| 14 | // 如果大于零 | 14 | // 如果大于零 |
| 15 | if(len>0) { | 15 | if(len>0) { |
| 16 | - // 获取停车场信息数据 | 16 | + // 获取场站信息数据 |
| 17 | var carParkObj = r[0]; | 17 | var carParkObj = r[0]; |
| 18 | /** 设置停车场对象值 @param:<carParkObj:停车场对象值> */ | 18 | /** 设置停车场对象值 @param:<carParkObj:停车场对象值> */ |
| 19 | EditCarParkObj.setEitdCarPark(carParkObj); | 19 | EditCarParkObj.setEitdCarPark(carParkObj); |
| @@ -133,10 +133,10 @@ var PublicFunctions = function () { | @@ -133,10 +133,10 @@ var PublicFunctions = function () { | ||
| 133 | enableAutoPan:true | 133 | enableAutoPan:true |
| 134 | }; | 134 | }; |
| 135 | if(stationShapesType == 'r') { | 135 | if(stationShapesType == 'r') { |
| 136 | - /** 画圆 @param:<r:停车场信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | 136 | + /** 画圆 @param:<r:场站信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ |
| 137 | CarParkPWorldsBMap.pointsCircle(r,point,htm,opts); | 137 | CarParkPWorldsBMap.pointsCircle(r,point,htm,opts); |
| 138 | }else if(stationShapesType == 'd'){ | 138 | }else if(stationShapesType == 'd'){ |
| 139 | - /** 画多边形 @param:<r:停车场信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | 139 | + /** 画多边形 @param:<r:场站信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ |
| 140 | CarParkPWorldsBMap.pointsPolygon(r,point,htm,opts); | 140 | CarParkPWorldsBMap.pointsPolygon(r,point,htm,opts); |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
src/main/resources/static/pages/base/carpark/js/carpark-positions-map.js
| 1 | -/** | ||
| 2 | - * 百度地图 | ||
| 3 | - * | ||
| 4 | - */ | ||
| 5 | - | ||
| 6 | -var CarParkPWorldsBMap = function () { | ||
| 7 | - | ||
| 8 | - var mapValue='',drawingManager='',marker='',circle='',polygon=''; | ||
| 9 | - | ||
| 10 | - var Bmap = { | ||
| 11 | - init : function() { | ||
| 12 | - // 设置中心点, | ||
| 13 | - var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 14 | - // 百度API Key | ||
| 15 | - var bdKey = 'IGGrr4UjwIYzatoCRFKEL8sT'; | ||
| 16 | - // 初始化百度地图 | ||
| 17 | - mapValue = new BMap.Map("carParkbmap_basic"); | ||
| 18 | - //中心点和缩放级别 | ||
| 19 | - mapValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 20 | - //启用地图拖拽事件,默认启用(可不写) | ||
| 21 | - mapValue.enableDragging(); | ||
| 22 | - //启用地图滚轮放大缩小 | ||
| 23 | - mapValue.enableScrollWheelZoom(); | ||
| 24 | - //禁用鼠标双击放大 | ||
| 25 | - mapValue.disableDoubleClickZoom(); | ||
| 26 | - //启用键盘上下左右键移动地图 | ||
| 27 | - mapValue.enableKeyboard(); | ||
| 28 | - var styleOptions = { | ||
| 29 | - //边线颜色。 | ||
| 30 | - strokeColor : "blue", | ||
| 31 | - //填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 32 | - fillColor : "blue", | ||
| 33 | - //边线的宽度,以像素为单位。 | ||
| 34 | - strokeWeight : 3, | ||
| 35 | - //边线透明度,取值范围0 - 1。 | ||
| 36 | - strokeOpacity : 0.8, | ||
| 37 | - //填充的透明度,取值范围0 - 1。 | ||
| 38 | - fillOpacity : 0.6, | ||
| 39 | - //边线的样式,solid或dashed。 | ||
| 40 | - strokeStyle : 'solid' | ||
| 41 | - }; | ||
| 42 | - // 创建鼠标绘制管理类 | ||
| 43 | - drawingManager = new BMapLib.DrawingManager(mapValue, { | ||
| 44 | - //是否开启绘制模式 | ||
| 45 | - isOpen : false, | ||
| 46 | - //是否显示工具栏 | ||
| 47 | - enableDrawingTool : false, | ||
| 48 | - drawingToolOptions : { | ||
| 49 | - //位置 | ||
| 50 | - anchor : BMAP_ANCHOR_TOP_RIGHT, | ||
| 51 | - //偏离值 | ||
| 52 | - offset : new BMap.Size(5, 5), | ||
| 53 | - //工具栏缩放比例 | ||
| 54 | - scale : 0.8 | ||
| 55 | - }, | ||
| 56 | - //线的样式 | ||
| 57 | - polygonOptions : styleOptions | ||
| 58 | - }); | ||
| 59 | - // 添加绘画完成事件 | ||
| 60 | - drawingManager.addEventListener('polygoncomplete', function(e) { | ||
| 61 | - drawingManager.close(); | ||
| 62 | - if (e.getPath().length <= 2) { | ||
| 63 | - // 弹出提示消息 | ||
| 64 | - layer.msg('坐标点不能小于等于两个...'); | ||
| 65 | - // 清除地图覆盖物 | ||
| 66 | - Bmap.clearMarkAndOverlays(); | ||
| 67 | - // 加载该线路下所有站点位置添加到地图上 | ||
| 68 | - return false; | ||
| 69 | - }else { | ||
| 70 | - var pointE = e; | ||
| 71 | - // 多变行质心点 | ||
| 72 | - var addSttationPoints_ = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat; | ||
| 73 | - var addPolyGonLen_ = pointE.getPath().length; | ||
| 74 | - for(var k =0;k<addPolyGonLen_;k++) { | ||
| 75 | - if(k==0) { | ||
| 76 | - bPloygonGrid = pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 77 | - }else { | ||
| 78 | - bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - } | ||
| 82 | - bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[0].lng + ' ' + pointE.getPath()[0].lat; | ||
| 83 | - /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 84 | - EditCarParkObj.setCarParkBcenterPoint(addSttationPoints_); | ||
| 85 | - /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 86 | - EditCarParkObj.setCarParkShapesType('d'); | ||
| 87 | - /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 88 | - EditCarParkObj.setCarParkRadius(''); | ||
| 89 | - /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 90 | - EditCarParkObj.setCarParkBparkPoint(bPloygonGrid); | ||
| 91 | - $.get('edit.html', function(m){ | ||
| 92 | - $(pjaxContainer).append(m); | ||
| 93 | - $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 94 | - }); | ||
| 95 | - } | ||
| 96 | - }); | ||
| 97 | - return mapValue; | ||
| 98 | - }, | ||
| 99 | - openDrawingManager : function() { | ||
| 100 | - // 清楚地图覆盖物 | ||
| 101 | - // mapValue.clearOverlays(); | ||
| 102 | - // 打开鼠标绘画工具 | ||
| 103 | - drawingManager.open(); | ||
| 104 | - // 设置属性 | ||
| 105 | - drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON); | ||
| 106 | - }, | ||
| 107 | - drawingManagerClose : function() { | ||
| 108 | - drawingManager.close(); | ||
| 109 | - }, | ||
| 110 | - localSearchFromAdreesToPoint: function(Address) { | ||
| 111 | - // 创建一个搜索类实例 | ||
| 112 | - var localSearch = new BMap.LocalSearch(mapValue); | ||
| 113 | - // 检索完成后的回调函数。 | ||
| 114 | - localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 115 | - var resultPoints = ''; | ||
| 116 | - if(searchResult) { | ||
| 117 | - // 返回索引指定的结果。索引0表示第1条结果 | ||
| 118 | - var poi = searchResult.getPoi(0); | ||
| 119 | - if(poi) { | ||
| 120 | - //获取经度和纬度 | ||
| 121 | - var Points = poi.point.lng + ' ' + poi.point.lat; | ||
| 122 | - var BJwpointsArray = Points.split(' '); | ||
| 123 | - var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 124 | - var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 125 | - var PanOptions ={noAnimation :true}; | ||
| 126 | - mapValue.panTo(stationNameChangePoint,PanOptions); | ||
| 127 | - mapValue.panBy(0,-200); | ||
| 128 | - // 将标注添加到地图中 | ||
| 129 | - mapValue.addOverlay(marker_stargt2); | ||
| 130 | - //跳动的动画 | ||
| 131 | - marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 132 | - } | ||
| 133 | - } | ||
| 134 | - }); | ||
| 135 | - // 根据检索词发起检索。 | ||
| 136 | - localSearch.search(Address); | ||
| 137 | - }, | ||
| 138 | - /** 画圆 @param:<r:停车场信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | ||
| 139 | - pointsCircle : function(r,point,htm,opts) { | ||
| 140 | - //创建圆 | ||
| 141 | - circle = new BMap.Circle(point,r[0].carParkRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 142 | - // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 143 | - circle.enableMassClear(); | ||
| 144 | - // 百度地图添加覆盖物圆 | ||
| 145 | - mapValue.addOverlay(circle); | ||
| 146 | - // 创建信息窗口 | ||
| 147 | - infoWindow = new BMap.InfoWindow(htm, opts); | ||
| 148 | - // 自定义标注物图片 | ||
| 149 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 150 | - // 创建点 | ||
| 151 | - marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 152 | - // 把标注添物加到地图上 | ||
| 153 | - mapValue.addOverlay(marker); | ||
| 154 | - setTimeout(function(){ | ||
| 155 | - //开启信息窗口 | ||
| 156 | - marker.openInfoWindow(infoWindow,point); | ||
| 157 | - },100); | ||
| 158 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 159 | - var PanOptions_ ={noAnimation :true}; | ||
| 160 | - // 将地图的中心点更改为给定的点。 | ||
| 161 | - mapValue.panTo(point,PanOptions_); | ||
| 162 | - // 添加标志物监听事件 | ||
| 163 | - marker.addEventListener("click",function() { | ||
| 164 | - //开启信息窗口 | ||
| 165 | - marker.openInfoWindow(infoWindow,point); | ||
| 166 | - }); | ||
| 167 | - }, | ||
| 168 | - | ||
| 169 | - /** 画多边形 @param:<r:停车场信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | ||
| 170 | - pointsPolygon : function(r,pointPolygon,htm,opts_polygon) { | ||
| 171 | - // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 172 | - mapValue.setZoom(17); | ||
| 173 | - // 获取多边形坐标字符串 | ||
| 174 | - var stationBPolygonGrid = r[0].carParkBparkPoint; | ||
| 175 | - // 截取多边形坐标字符串 | ||
| 176 | - var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 177 | - // 按逗号切割 | ||
| 178 | - var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 179 | - // 多边形坐标集合 | ||
| 180 | - var polygonP = []; | ||
| 181 | - for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 182 | - polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 183 | - } | ||
| 184 | - // 画多边形 | ||
| 185 | - polygon = new BMap.Polygon(polygonP, { | ||
| 186 | - // 线条显色 | ||
| 187 | - strokeColor : "blue", | ||
| 188 | - // 边线的宽度,以像素为单位。 | ||
| 189 | - strokeWeight : 2, | ||
| 190 | - // 边线透明度,取值范围0 - 1。 | ||
| 191 | - strokeOpacity : 0.5 | ||
| 192 | - }); | ||
| 193 | - // 增加地图覆盖物多边形 | ||
| 194 | - mapValue.addOverlay(polygon); | ||
| 195 | - // 创建信息窗口 | ||
| 196 | - infoWindow = new BMap.InfoWindow(htm, opts_polygon); | ||
| 197 | - // 自定义标注物图片 | ||
| 198 | - var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 199 | - // 创建点 | ||
| 200 | - marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 201 | - // 把标注添物加到地图上 | ||
| 202 | - mapValue.addOverlay(marker); | ||
| 203 | - // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 204 | - var PanOptions_ ={noAnimation :true}; | ||
| 205 | - // 将地图的中心点更改为给定的点。 | ||
| 206 | - mapValue.panTo(pointPolygon,PanOptions_); | ||
| 207 | - // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 208 | - mapValue.panBy(10,-250,PanOptions_); | ||
| 209 | - //开启信息窗口 | ||
| 210 | - marker.openInfoWindow(infoWindow,pointPolygon); | ||
| 211 | - }, | ||
| 212 | - | ||
| 213 | - // 编辑图形 | ||
| 214 | - editShapes : function(stationShapesTypeV,mindex) { | ||
| 215 | - // 关闭信息窗口 | ||
| 216 | - marker.closeInfoWindow(); | ||
| 217 | - // 清除marker | ||
| 218 | - mapValue.removeOverlay(marker); | ||
| 219 | - // 编辑圆 | ||
| 220 | - if(stationShapesTypeV =='r') { | ||
| 221 | - // 开启编辑功能 | ||
| 222 | - circle.enableEditing(); | ||
| 223 | - // 编辑圆监听事件 | ||
| 224 | - circle.addEventListener('dblclick',function() { | ||
| 225 | - // 关闭提示弹出层 | ||
| 226 | - layer.close(mindex); | ||
| 227 | - // 返回圆形的半径,单位为米。 | ||
| 228 | - var newRadius = circle.getRadius(); | ||
| 229 | - // 返回圆形的中心点坐标。 | ||
| 230 | - var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 231 | - var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 232 | - /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 233 | - EditCarParkObj.setCarParkBcenterPoint(newCenter); | ||
| 234 | - /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 235 | - EditCarParkObj.setCarParkShapesType('r'); | ||
| 236 | - /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 237 | - EditCarParkObj.setCarParkRadius(Math.round(newRadius)); | ||
| 238 | - /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 239 | - EditCarParkObj.setCarParkBparkPoint(''); | ||
| 240 | - // 加载编辑页面 | ||
| 241 | - $.get('edit.html', function(m){ | ||
| 242 | - $(pjaxContainer).append(m); | ||
| 243 | - $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 244 | - }); | ||
| 245 | - }); | ||
| 246 | - // 编辑多变行 | ||
| 247 | - }else if(stationShapesTypeV =='d') { | ||
| 248 | - // 开启编辑功能(自 1.1 新增) | ||
| 249 | - polygon.enableEditing(); | ||
| 250 | - // 添加多变行编辑事件 | ||
| 251 | - polygon.addEventListener('dblclick',function(e) { | ||
| 252 | - // 获取编辑的多边形对象 | ||
| 253 | - var edit_pointE = polygon; | ||
| 254 | - var edit_bPloygonGrid = ""; | ||
| 255 | - var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 256 | - for(var k =0;k<editPolyGonLen_;k++) { | ||
| 257 | - if(k==0) { | ||
| 258 | - edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 259 | - }else { | ||
| 260 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 261 | - } | ||
| 262 | - } | ||
| 263 | - edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 264 | - // 多边形中心点 | ||
| 265 | - var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 266 | - /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 267 | - EditCarParkObj.setCarParkBcenterPoint(centre_points); | ||
| 268 | - /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 269 | - EditCarParkObj.setCarParkShapesType('d'); | ||
| 270 | - /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 271 | - EditCarParkObj.setCarParkRadius(''); | ||
| 272 | - /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 273 | - EditCarParkObj.setCarParkBparkPoint(edit_bPloygonGrid); | ||
| 274 | - $.get('edit.html', function(m){ | ||
| 275 | - $(pjaxContainer).append(m); | ||
| 276 | - $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 277 | - }); | ||
| 278 | - }); | ||
| 279 | - } | ||
| 280 | - }, | ||
| 281 | - clearMarkAndOverlays : function() { | ||
| 282 | - // 清楚地图覆盖物 | ||
| 283 | - mapValue.clearOverlays(); | ||
| 284 | - } | ||
| 285 | - } | ||
| 286 | - return Bmap; | 1 | +/** |
| 2 | + * 百度地图 | ||
| 3 | + * | ||
| 4 | + */ | ||
| 5 | + | ||
| 6 | +var CarParkPWorldsBMap = function () { | ||
| 7 | + | ||
| 8 | + var mapValue='',drawingManager='',marker='',circle='',polygon=''; | ||
| 9 | + | ||
| 10 | + var Bmap = { | ||
| 11 | + init : function() { | ||
| 12 | + // 设置中心点, | ||
| 13 | + var CENTER_POINT = {lng : 121.528733,lat : 31.237425}; | ||
| 14 | + // 百度API Key | ||
| 15 | + var bdKey = '1TgEKvYqohJyeGXnN6yHSSTb4psOarQw'; | ||
| 16 | + // 初始化百度地图 | ||
| 17 | + mapValue = new BMap.Map("carParkbmap_basic"); | ||
| 18 | + //中心点和缩放级别 | ||
| 19 | + mapValue.centerAndZoom(new BMap.Point(CENTER_POINT.lng,CENTER_POINT.lat), 15); | ||
| 20 | + //启用地图拖拽事件,默认启用(可不写) | ||
| 21 | + mapValue.enableDragging(); | ||
| 22 | + //启用地图滚轮放大缩小 | ||
| 23 | + mapValue.enableScrollWheelZoom(); | ||
| 24 | + //禁用鼠标双击放大 | ||
| 25 | + mapValue.disableDoubleClickZoom(); | ||
| 26 | + //启用键盘上下左右键移动地图 | ||
| 27 | + mapValue.enableKeyboard(); | ||
| 28 | + var styleOptions = { | ||
| 29 | + //边线颜色。 | ||
| 30 | + strokeColor : "blue", | ||
| 31 | + //填充颜色。当参数为空时,圆形将没有填充效果。 | ||
| 32 | + fillColor : "blue", | ||
| 33 | + //边线的宽度,以像素为单位。 | ||
| 34 | + strokeWeight : 3, | ||
| 35 | + //边线透明度,取值范围0 - 1。 | ||
| 36 | + strokeOpacity : 0.8, | ||
| 37 | + //填充的透明度,取值范围0 - 1。 | ||
| 38 | + fillOpacity : 0.6, | ||
| 39 | + //边线的样式,solid或dashed。 | ||
| 40 | + strokeStyle : 'solid' | ||
| 41 | + }; | ||
| 42 | + // 创建鼠标绘制管理类 | ||
| 43 | + drawingManager = new BMapLib.DrawingManager(mapValue, { | ||
| 44 | + //是否开启绘制模式 | ||
| 45 | + isOpen : false, | ||
| 46 | + //是否显示工具栏 | ||
| 47 | + enableDrawingTool : false, | ||
| 48 | + drawingToolOptions : { | ||
| 49 | + //位置 | ||
| 50 | + anchor : BMAP_ANCHOR_TOP_RIGHT, | ||
| 51 | + //偏离值 | ||
| 52 | + offset : new BMap.Size(5, 5), | ||
| 53 | + //工具栏缩放比例 | ||
| 54 | + scale : 0.8 | ||
| 55 | + }, | ||
| 56 | + //线的样式 | ||
| 57 | + polygonOptions : styleOptions | ||
| 58 | + }); | ||
| 59 | + // 添加绘画完成事件 | ||
| 60 | + drawingManager.addEventListener('polygoncomplete', function(e) { | ||
| 61 | + drawingManager.close(); | ||
| 62 | + if (e.getPath().length <= 2) { | ||
| 63 | + // 弹出提示消息 | ||
| 64 | + layer.msg('坐标点不能小于等于两个...'); | ||
| 65 | + // 清除地图覆盖物 | ||
| 66 | + Bmap.clearMarkAndOverlays(); | ||
| 67 | + // 加载该线路下所有站点位置添加到地图上 | ||
| 68 | + return false; | ||
| 69 | + }else { | ||
| 70 | + var pointE = e; | ||
| 71 | + // 多变行质心点 | ||
| 72 | + var addSttationPoints_ = pointE.getBounds().getCenter().lng+ ' ' + pointE.getBounds().getCenter().lat; | ||
| 73 | + var addPolyGonLen_ = pointE.getPath().length; | ||
| 74 | + for(var k =0;k<addPolyGonLen_;k++) { | ||
| 75 | + if(k==0) { | ||
| 76 | + bPloygonGrid = pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 77 | + }else { | ||
| 78 | + bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[k].lng + ' ' + pointE.getPath()[k].lat; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + } | ||
| 82 | + bPloygonGrid = bPloygonGrid + ',' + pointE.getPath()[0].lng + ' ' + pointE.getPath()[0].lat; | ||
| 83 | + /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 84 | + EditCarParkObj.setCarParkBcenterPoint(addSttationPoints_); | ||
| 85 | + /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 86 | + EditCarParkObj.setCarParkShapesType('d'); | ||
| 87 | + /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 88 | + EditCarParkObj.setCarParkRadius(''); | ||
| 89 | + /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 90 | + EditCarParkObj.setCarParkBparkPoint(bPloygonGrid); | ||
| 91 | + $.get('edit.html', function(m){ | ||
| 92 | + $(pjaxContainer).append(m); | ||
| 93 | + $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 94 | + }); | ||
| 95 | + } | ||
| 96 | + }); | ||
| 97 | + return mapValue; | ||
| 98 | + }, | ||
| 99 | + openDrawingManager : function() { | ||
| 100 | + // 清楚地图覆盖物 | ||
| 101 | + // mapValue.clearOverlays(); | ||
| 102 | + // 打开鼠标绘画工具 | ||
| 103 | + drawingManager.open(); | ||
| 104 | + // 设置属性 | ||
| 105 | + drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON); | ||
| 106 | + }, | ||
| 107 | + drawingManagerClose : function() { | ||
| 108 | + drawingManager.close(); | ||
| 109 | + }, | ||
| 110 | + localSearchFromAdreesToPoint: function(Address) { | ||
| 111 | + // 创建一个搜索类实例 | ||
| 112 | + var localSearch = new BMap.LocalSearch(mapValue); | ||
| 113 | + // 检索完成后的回调函数。 | ||
| 114 | + localSearch.setSearchCompleteCallback(function (searchResult) { | ||
| 115 | + var resultPoints = ''; | ||
| 116 | + if(searchResult) { | ||
| 117 | + // 返回索引指定的结果。索引0表示第1条结果 | ||
| 118 | + var poi = searchResult.getPoi(0); | ||
| 119 | + if(poi) { | ||
| 120 | + //获取经度和纬度 | ||
| 121 | + var Points = poi.point.lng + ' ' + poi.point.lat; | ||
| 122 | + var BJwpointsArray = Points.split(' '); | ||
| 123 | + var stationNameChangePoint = new BMap.Point(BJwpointsArray[0], BJwpointsArray[1]); | ||
| 124 | + var marker_stargt2 = new BMap.Marker(stationNameChangePoint); | ||
| 125 | + var PanOptions ={noAnimation :true}; | ||
| 126 | + mapValue.panTo(stationNameChangePoint,PanOptions); | ||
| 127 | + mapValue.panBy(0,-200); | ||
| 128 | + // 将标注添加到地图中 | ||
| 129 | + mapValue.addOverlay(marker_stargt2); | ||
| 130 | + //跳动的动画 | ||
| 131 | + marker_stargt2.setAnimation(BMAP_ANIMATION_BOUNCE); | ||
| 132 | + } | ||
| 133 | + } | ||
| 134 | + }); | ||
| 135 | + // 根据检索词发起检索。 | ||
| 136 | + localSearch.search(Address); | ||
| 137 | + }, | ||
| 138 | + /** 画圆 @param:<r:场站信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | ||
| 139 | + pointsCircle : function(r,point,htm,opts) { | ||
| 140 | + //创建圆 | ||
| 141 | + circle = new BMap.Circle(point,r[0].carParkRadius,{strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); | ||
| 142 | + // 允许覆盖物在map.clearOverlays方法中被清除 | ||
| 143 | + circle.enableMassClear(); | ||
| 144 | + // 百度地图添加覆盖物圆 | ||
| 145 | + mapValue.addOverlay(circle); | ||
| 146 | + // 创建信息窗口 | ||
| 147 | + infoWindow = new BMap.InfoWindow(htm, opts); | ||
| 148 | + // 自定义标注物图片 | ||
| 149 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 150 | + // 创建点 | ||
| 151 | + marker = new BMap.Marker(point,{icon : icon_target}); | ||
| 152 | + // 把标注添物加到地图上 | ||
| 153 | + mapValue.addOverlay(marker); | ||
| 154 | + setTimeout(function(){ | ||
| 155 | + //开启信息窗口 | ||
| 156 | + marker.openInfoWindow(infoWindow,point); | ||
| 157 | + },100); | ||
| 158 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 159 | + var PanOptions_ ={noAnimation :true}; | ||
| 160 | + // 将地图的中心点更改为给定的点。 | ||
| 161 | + mapValue.panTo(point,PanOptions_); | ||
| 162 | + // 添加标志物监听事件 | ||
| 163 | + marker.addEventListener("click",function() { | ||
| 164 | + //开启信息窗口 | ||
| 165 | + marker.openInfoWindow(infoWindow,point); | ||
| 166 | + }); | ||
| 167 | + }, | ||
| 168 | + | ||
| 169 | + /** 画多边形 @param:<r:场站信息;point:中心点;htm:信息窗口html文本;pots:信息窗口参数属性> */ | ||
| 170 | + pointsPolygon : function(r,pointPolygon,htm,opts_polygon) { | ||
| 171 | + // 将视图切换到指定的缩放等级,中心点坐标不变。注意:当有信息窗口在地图上打开时,地图缩放将保证信息窗口所在的坐标位置不动。(自1.2新增) | ||
| 172 | + mapValue.setZoom(17); | ||
| 173 | + // 获取多边形坐标字符串 | ||
| 174 | + var stationBPolygonGrid = r[0].carParkBparkPoint; | ||
| 175 | + // 截取多边形坐标字符串 | ||
| 176 | + var stationBPolygonGridStr = stationBPolygonGrid.substring(9,stationBPolygonGrid.length-2); | ||
| 177 | + // 按逗号切割 | ||
| 178 | + var pointPolygonArray = stationBPolygonGridStr.split(','); | ||
| 179 | + // 多边形坐标集合 | ||
| 180 | + var polygonP = []; | ||
| 181 | + for(var v = 0;v<pointPolygonArray.length;v++) { | ||
| 182 | + polygonP.push(new BMap.Point(pointPolygonArray[v].split(" ")[0],pointPolygonArray[v].split(" ")[1])); | ||
| 183 | + } | ||
| 184 | + // 画多边形 | ||
| 185 | + polygon = new BMap.Polygon(polygonP, { | ||
| 186 | + // 线条显色 | ||
| 187 | + strokeColor : "blue", | ||
| 188 | + // 边线的宽度,以像素为单位。 | ||
| 189 | + strokeWeight : 2, | ||
| 190 | + // 边线透明度,取值范围0 - 1。 | ||
| 191 | + strokeOpacity : 0.5 | ||
| 192 | + }); | ||
| 193 | + // 增加地图覆盖物多边形 | ||
| 194 | + mapValue.addOverlay(polygon); | ||
| 195 | + // 创建信息窗口 | ||
| 196 | + infoWindow = new BMap.InfoWindow(htm, opts_polygon); | ||
| 197 | + // 自定义标注物图片 | ||
| 198 | + var icon_target = new BMap.Icon('/pages/base/stationroute/css/img/cz.png',new BMap.Size(20, 20)); | ||
| 199 | + // 创建点 | ||
| 200 | + marker = new BMap.Marker(pointPolygon,{icon : icon_target}); | ||
| 201 | + // 把标注添物加到地图上 | ||
| 202 | + mapValue.addOverlay(marker); | ||
| 203 | + // 是否在平移过程中禁止动画。(自1.2新增) | ||
| 204 | + var PanOptions_ ={noAnimation :true}; | ||
| 205 | + // 将地图的中心点更改为给定的点。 | ||
| 206 | + mapValue.panTo(pointPolygon,PanOptions_); | ||
| 207 | + // 将地图在水平位置上移动x像素,垂直位置上移动y像素。 | ||
| 208 | + mapValue.panBy(10,-250,PanOptions_); | ||
| 209 | + //开启信息窗口 | ||
| 210 | + marker.openInfoWindow(infoWindow,pointPolygon); | ||
| 211 | + }, | ||
| 212 | + | ||
| 213 | + // 编辑图形 | ||
| 214 | + editShapes : function(stationShapesTypeV,mindex) { | ||
| 215 | + // 关闭信息窗口 | ||
| 216 | + marker.closeInfoWindow(); | ||
| 217 | + // 清除marker | ||
| 218 | + mapValue.removeOverlay(marker); | ||
| 219 | + // 编辑圆 | ||
| 220 | + if(stationShapesTypeV =='r') { | ||
| 221 | + // 开启编辑功能 | ||
| 222 | + circle.enableEditing(); | ||
| 223 | + // 编辑圆监听事件 | ||
| 224 | + circle.addEventListener('dblclick',function() { | ||
| 225 | + // 关闭提示弹出层 | ||
| 226 | + layer.close(mindex); | ||
| 227 | + // 返回圆形的半径,单位为米。 | ||
| 228 | + var newRadius = circle.getRadius(); | ||
| 229 | + // 返回圆形的中心点坐标。 | ||
| 230 | + var newCenter = circle.getCenter().lng + ' ' + circle.getCenter().lat; | ||
| 231 | + var centre_New = [{potion:{lng:circle.getCenter().lng,lat:circle.getCenter().lat}}]; | ||
| 232 | + /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 233 | + EditCarParkObj.setCarParkBcenterPoint(newCenter); | ||
| 234 | + /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 235 | + EditCarParkObj.setCarParkShapesType('r'); | ||
| 236 | + /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 237 | + EditCarParkObj.setCarParkRadius(Math.round(newRadius)); | ||
| 238 | + /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 239 | + EditCarParkObj.setCarParkBparkPoint(''); | ||
| 240 | + // 加载编辑页面 | ||
| 241 | + $.get('edit.html', function(m){ | ||
| 242 | + $(pjaxContainer).append(m); | ||
| 243 | + $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 244 | + }); | ||
| 245 | + }); | ||
| 246 | + // 编辑多变行 | ||
| 247 | + }else if(stationShapesTypeV =='d') { | ||
| 248 | + // 开启编辑功能(自 1.1 新增) | ||
| 249 | + polygon.enableEditing(); | ||
| 250 | + // 添加多变行编辑事件 | ||
| 251 | + polygon.addEventListener('dblclick',function(e) { | ||
| 252 | + // 获取编辑的多边形对象 | ||
| 253 | + var edit_pointE = polygon; | ||
| 254 | + var edit_bPloygonGrid = ""; | ||
| 255 | + var editPolyGonLen_ = edit_pointE.getPath().length; | ||
| 256 | + for(var k =0;k<editPolyGonLen_;k++) { | ||
| 257 | + if(k==0) { | ||
| 258 | + edit_bPloygonGrid = edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 259 | + }else { | ||
| 260 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[k].lng + ' ' + edit_pointE.getPath()[k].lat; | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + edit_bPloygonGrid = edit_bPloygonGrid + ',' + edit_pointE.getPath()[0].lng + ' ' + edit_pointE.getPath()[0].lat; | ||
| 264 | + // 多边形中心点 | ||
| 265 | + var centre_points = edit_pointE.getBounds().getCenter().lng + ' ' + edit_pointE.getBounds().getCenter().lat; | ||
| 266 | + /** 设置修改停车场集合对象图形质心点属性 @param:<addSttationPoints_:多边形质心点> */ | ||
| 267 | + EditCarParkObj.setCarParkBcenterPoint(centre_points); | ||
| 268 | + /** 设置修改停车场集合对象图形类型属性 @param:<shapeType:图形类型> */ | ||
| 269 | + EditCarParkObj.setCarParkShapesType('d'); | ||
| 270 | + /** 设置修改停车场集合对象圆形半径属性 @param:<radius:圆形半径> */ | ||
| 271 | + EditCarParkObj.setCarParkRadius(''); | ||
| 272 | + /** 设置修改停车场集合对象名称 @param:<bParkPoint:多边形图形坐标集合> */ | ||
| 273 | + EditCarParkObj.setCarParkBparkPoint(edit_bPloygonGrid); | ||
| 274 | + $.get('edit.html', function(m){ | ||
| 275 | + $(pjaxContainer).append(m); | ||
| 276 | + $('#editPoitsions_carpark_mobal').trigger('editCarParkMobal_show', [CarParkPWorldsBMap,PublicFunctions,EditCarParkObj,GetAjaxData]); | ||
| 277 | + }); | ||
| 278 | + }); | ||
| 279 | + } | ||
| 280 | + }, | ||
| 281 | + clearMarkAndOverlays : function() { | ||
| 282 | + // 清楚地图覆盖物 | ||
| 283 | + mapValue.clearOverlays(); | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + return Bmap; | ||
| 287 | }(); | 287 | }(); |
| 288 | \ No newline at end of file | 288 | \ No newline at end of file |
src/main/resources/static/pages/base/carpark/js/carpark-positions-reload.js
| 1 | -/** | ||
| 2 | - * | ||
| 3 | - * @JSName : list.js(停车场定位positions.html页面js) | ||
| 4 | - * | ||
| 5 | - * @Author : bsth@lq | ||
| 6 | - * | ||
| 7 | - * @Description : TODO(停车场定位positions.html页面js) | ||
| 8 | - * | ||
| 9 | - * @Data : 2016年4月28日 上午9:21:17 | ||
| 10 | - * | ||
| 11 | - * @Version 公交调度系统BS版 0.1 | ||
| 12 | - * | ||
| 13 | - */ | ||
| 14 | - | ||
| 15 | -(function(){ | ||
| 16 | - // 获取参数停车场ID | ||
| 17 | - var id = $.url().param('no'); | ||
| 18 | - // 关闭左侧栏 | ||
| 19 | - if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();} | ||
| 20 | - // 等候300毫秒执行 | ||
| 21 | - setTimeout(function(){ | ||
| 22 | - // 地图初始化 | ||
| 23 | - mapB = CarParkPWorldsBMap.init(); | ||
| 24 | - /** 停车场信息初始化 @param:<id:停车场ID> */ | ||
| 25 | - PublicFunctions.initCarPark(id); | ||
| 26 | - },300); | 1 | +/** |
| 2 | + * | ||
| 3 | + * @JSName : list.js(停车场定位positions.html页面js) | ||
| 4 | + * | ||
| 5 | + * @Author : bsth@lq | ||
| 6 | + * | ||
| 7 | + * @Description : TODO(停车场定位positions.html页面js) | ||
| 8 | + * | ||
| 9 | + * @Data : 2016年4月28日 上午9:21:17 | ||
| 10 | + * | ||
| 11 | + * @Version 公交调度系统BS版 0.1 | ||
| 12 | + * | ||
| 13 | + */ | ||
| 14 | + | ||
| 15 | +(function(){ | ||
| 16 | + // 获取参数停车场ID | ||
| 17 | + var id = $.url().param('no'); | ||
| 18 | + // 关闭左侧栏 | ||
| 19 | + if (!$('body').hasClass('page-sidebar-closed')) {$('.menu-toggler.sidebar-toggler').click();} | ||
| 20 | + // 等候300毫秒执行 | ||
| 21 | + setTimeout(function(){ | ||
| 22 | + // 地图初始化 | ||
| 23 | + mapB = CarParkPWorldsBMap.init(); | ||
| 24 | + /** 场站信息初始化 @param:<id:停车场ID> */ | ||
| 25 | + PublicFunctions.initCarPark(id); | ||
| 26 | + },300); | ||
| 27 | })(); | 27 | })(); |
| 28 | \ No newline at end of file | 28 | \ No newline at end of file |