Commit 51d73d3b03c5854ca28511d718493e6950c0ac2e
1 parent
52eb029a
1.解决报站语音生成在centos7下异常问题
2.百度地图商用key替换 3.js压缩兼容es6
Showing
11 changed files
with
2181 additions
and
2003 deletions
Too many changes to show.
To preserve performance only 11 of 21 files are displayed.
pom.xml
| ... | ... | @@ -419,10 +419,23 @@ |
| 419 | 419 | <version>1.5.3</version> |
| 420 | 420 | </dependency> |
| 421 | 421 | |
| 422 | + <!-- 核心依赖 --> | |
| 422 | 423 | <dependency> |
| 423 | 424 | <groupId>org.bytedeco</groupId> |
| 424 | - <artifactId>javacv-platform</artifactId> | |
| 425 | - <version>1.5.11</version> | |
| 425 | + <artifactId>javacv</artifactId> | |
| 426 | + <version>1.5.5</version> | |
| 427 | + </dependency> | |
| 428 | + <dependency> | |
| 429 | + <groupId>org.bytedeco</groupId> | |
| 430 | + <artifactId>javacpp</artifactId> | |
| 431 | + <version>1.5.5</version> | |
| 432 | + </dependency> | |
| 433 | + <!-- Linux x86_64平台特定的FFmpeg依赖 --> | |
| 434 | + <dependency> | |
| 435 | + <groupId>org.bytedeco</groupId> | |
| 436 | + <artifactId>ffmpeg</artifactId> | |
| 437 | + <version>4.3.2-1.5.5</version> | |
| 438 | + <classifier>${javacpp.platform}</classifier> | |
| 426 | 439 | </dependency> |
| 427 | 440 | </dependencies> |
| 428 | 441 | |
| ... | ... | @@ -496,6 +509,7 @@ |
| 496 | 509 | |
| 497 | 510 | <properties> |
| 498 | 511 | <start-class>com.bsth.Application</start-class> |
| 512 | + <!-- 平台配置,只打包Linux x86_64平台的jar包 --> | |
| 499 | 513 | <javacpp.platform>linux-x86_64</javacpp.platform> |
| 500 | 514 | </properties> |
| 501 | 515 | </project> | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -8,7 +8,6 @@ import com.bsth.service.StationRouteService; |
| 8 | 8 | import com.bsth.util.*; |
| 9 | 9 | import com.bsth.util.Geo.GeoUtils; |
| 10 | 10 | import com.bsth.util.Geo.Point; |
| 11 | -import com.bsth.util.PackTarGZUtils; | |
| 12 | 11 | import com.bsth.util.db.DBUtils_MS; |
| 13 | 12 | import com.google.common.base.Splitter; |
| 14 | 13 | import org.apache.commons.lang3.StringUtils; |
| ... | ... | @@ -27,19 +26,19 @@ import java.util.zip.ZipEntry; |
| 27 | 26 | import java.util.zip.ZipOutputStream; |
| 28 | 27 | |
| 29 | 28 | /** |
| 30 | - * | |
| 29 | + * | |
| 31 | 30 | * @ClassName: StationRouteServiceImpl(站点路由service业务层实现类) |
| 32 | - * | |
| 31 | + * | |
| 33 | 32 | * @Extends : BaseService |
| 34 | - * | |
| 33 | + * | |
| 35 | 34 | * @Description: TODO(站点路由service业务层) |
| 36 | - * | |
| 35 | + * | |
| 37 | 36 | * @Author bsth@lq |
| 38 | - * | |
| 37 | + * | |
| 39 | 38 | * @Date 2016年5月03日 上午9:21:17 |
| 40 | 39 | * |
| 41 | 40 | * @Version 公交调度系统BS版 0.1 |
| 42 | - * | |
| 41 | + * | |
| 43 | 42 | */ |
| 44 | 43 | |
| 45 | 44 | @Service |
| ... | ... | @@ -50,16 +49,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 50 | 49 | |
| 51 | 50 | @Value("${path.speech.line}") |
| 52 | 51 | private String linePathPattern; |
| 53 | - | |
| 52 | + | |
| 54 | 53 | @Autowired |
| 55 | 54 | private StationRouteRepository stationRouteRepository; |
| 56 | - | |
| 55 | + | |
| 57 | 56 | @Autowired |
| 58 | 57 | private SectionRouteRepository sectionRouteRepository; |
| 59 | - | |
| 58 | + | |
| 60 | 59 | @Autowired |
| 61 | 60 | private LineRepository lineRepository; |
| 62 | - | |
| 61 | + | |
| 63 | 62 | @Autowired |
| 64 | 63 | private StationRepository stationRepository; |
| 65 | 64 | |
| ... | ... | @@ -72,6 +71,11 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 72 | 71 | @Autowired |
| 73 | 72 | private LsSectionRouteRepository lsSectionRouteRepository; |
| 74 | 73 | |
| 74 | + @Autowired | |
| 75 | + private LineRegionRepository lineRegionRepository; | |
| 76 | + @Autowired | |
| 77 | + private LineVersionsRepository lineVersionsRepository; | |
| 78 | + | |
| 75 | 79 | @Override |
| 76 | 80 | public Iterable<StationRoute> list(Map<String, Object> map) { |
| 77 | 81 | List<Sort.Order> orders = new ArrayList<>(); |
| ... | ... | @@ -80,7 +84,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 80 | 84 | |
| 81 | 85 | return stationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(orders)); |
| 82 | 86 | } |
| 83 | - | |
| 87 | + | |
| 84 | 88 | @Override |
| 85 | 89 | public Map<String, Object> getSectionRouteExport(Integer id, HttpServletResponse resp) { |
| 86 | 90 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| ... | ... | @@ -132,12 +136,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 132 | 136 | } |
| 133 | 137 | return resultMap; |
| 134 | 138 | } |
| 135 | - | |
| 139 | + | |
| 136 | 140 | /** |
| 137 | 141 | * @Description :TODO(查询树站点与路段数据) |
| 138 | - * | |
| 142 | + * | |
| 139 | 143 | * @param map <line.id_eq:线路ID; directions_eq:方向> |
| 140 | - * | |
| 144 | + * | |
| 141 | 145 | * @return List<Map<String, Object>> |
| 142 | 146 | */ |
| 143 | 147 | @Override |
| ... | ... | @@ -151,26 +155,26 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 151 | 155 | |
| 152 | 156 | return result; |
| 153 | 157 | } |
| 154 | - | |
| 158 | + | |
| 155 | 159 | @Override |
| 156 | 160 | public Map<String, Object> systemQuote(Map<String, Object> map) { |
| 157 | 161 | Map<String, Object> resultmap = new HashMap<>(); |
| 158 | 162 | try{ |
| 159 | - | |
| 163 | + | |
| 160 | 164 | StationRoute route = new StationRoute(); |
| 161 | - | |
| 165 | + | |
| 162 | 166 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 163 | - | |
| 167 | + | |
| 164 | 168 | Integer stationId = map.get("stationId").equals("") ? null : Integer.parseInt(map.get("stationId").toString()); |
| 165 | - | |
| 169 | + | |
| 166 | 170 | Line line = lineRepository.findById(lineId).get(); |
| 167 | - | |
| 171 | + | |
| 168 | 172 | Station station = stationRepository.findById(stationId).get(); |
| 169 | - | |
| 173 | + | |
| 170 | 174 | route.setLine(line); |
| 171 | - | |
| 175 | + | |
| 172 | 176 | route.setStation(station); |
| 173 | - | |
| 177 | + | |
| 174 | 178 | //baseRepository.save(t); |
| 175 | 179 | resultmap.put("status", ResponseCode.SUCCESS); |
| 176 | 180 | }catch(Exception e){ |
| ... | ... | @@ -179,13 +183,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 179 | 183 | } |
| 180 | 184 | return resultmap; |
| 181 | 185 | } |
| 182 | - | |
| 186 | + | |
| 183 | 187 | /** |
| 184 | 188 | * @Description :TODO(查询线路某方向下的站点序号与类型) |
| 185 | - * | |
| 189 | + * | |
| 186 | 190 | * @param map <lineId:线路ID; direction:方向;stationRouteCode:站点编码> |
| 187 | - * | |
| 188 | - * @return List<Map<String, Object>> | |
| 191 | + * | |
| 192 | + * @return List<Map<String, Object>> | |
| 189 | 193 | */ |
| 190 | 194 | @Override |
| 191 | 195 | public List<Map<String, Object>> findUpStationRouteCode(Map<String, Object> map) { |
| ... | ... | @@ -300,40 +304,40 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 300 | 304 | |
| 301 | 305 | /** |
| 302 | 306 | * @Description :TODO(查询线路某方向下所有站点的中心百度坐标) |
| 303 | - * | |
| 307 | + * | |
| 304 | 308 | * @param map <lineId:线路ID; direction:方向> |
| 305 | - * | |
| 306 | - * @return List<Map<String, Object>> | |
| 309 | + * | |
| 310 | + * @return List<Map<String, Object>> | |
| 307 | 311 | */ |
| 308 | 312 | @Override |
| 309 | 313 | public List<Map<String, Object>> getStationRouteCenterPoints(Map<String, Object> map) { |
| 310 | - | |
| 314 | + | |
| 311 | 315 | List<Map<String, Object>> resultList = new ArrayList<Map<String,Object>>(); |
| 312 | - | |
| 316 | + | |
| 313 | 317 | // 线路ID |
| 314 | 318 | Integer lineId = map.get("lineId").equals("") ? null : Integer.parseInt(map.get("lineId").toString()); |
| 315 | - | |
| 319 | + | |
| 316 | 320 | // 方向 |
| 317 | 321 | Integer direction = map.get("direction").equals("") ? null : Integer.parseInt(map.get("direction").toString()); |
| 318 | - | |
| 322 | + | |
| 319 | 323 | List<Object[]> list = stationRouteRepository.getSelectStationRouteCenterPoints(lineId, direction); |
| 320 | - | |
| 324 | + | |
| 321 | 325 | if(list.size()>0) { |
| 322 | - | |
| 326 | + | |
| 323 | 327 | for(int i = 0;i<list.size();i++) { |
| 324 | - | |
| 328 | + | |
| 325 | 329 | Map<String, Object> tempM = new HashMap<String,Object>(); |
| 326 | - | |
| 330 | + | |
| 327 | 331 | tempM.put("bJwpoints", list.get(i)[0]); |
| 328 | - | |
| 332 | + | |
| 329 | 333 | tempM.put("stationName", list.get(i)[1]); |
| 330 | - | |
| 334 | + | |
| 331 | 335 | resultList.add(tempM); |
| 332 | - | |
| 336 | + | |
| 333 | 337 | } |
| 334 | - | |
| 338 | + | |
| 335 | 339 | } |
| 336 | - | |
| 340 | + | |
| 337 | 341 | return resultList; |
| 338 | 342 | } |
| 339 | 343 | |
| ... | ... | @@ -351,7 +355,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 351 | 355 | } |
| 352 | 356 | map.put("destroy_eq", 0); |
| 353 | 357 | List<LsStationRoute> stationRoutes = lsStationRouteRepository.findAll(new CustomerSpecs<>(map), Sort.by(Direction.ASC, "stationRouteCode")); |
| 354 | - | |
| 358 | + | |
| 355 | 359 | List<Map<String, Object>> resultList = new ArrayList<>(); |
| 356 | 360 | |
| 357 | 361 | int len = stationRoutes.size(); |
| ... | ... | @@ -362,44 +366,44 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 362 | 366 | } |
| 363 | 367 | return resultList; |
| 364 | 368 | } |
| 365 | - | |
| 369 | + | |
| 366 | 370 | /** |
| 367 | 371 | * @Description :TODO(撤销站点) |
| 368 | - * | |
| 372 | + * | |
| 369 | 373 | * @param map <lineId:线路ID; destroy:是否撤销(0:否;1:是)> |
| 370 | - * | |
| 374 | + * | |
| 371 | 375 | * @return Map<String, Object> <SUCCESS ; ERROR> |
| 372 | 376 | */ |
| 373 | 377 | @Override |
| 374 | 378 | public Map<String, Object> stationRouteIsDestroy(Map<String, Object> map) { |
| 375 | 379 | Map<String, Object> resultMap = new HashMap<String,Object>(); |
| 376 | - | |
| 380 | + | |
| 377 | 381 | try { |
| 378 | - | |
| 382 | + | |
| 379 | 383 | Integer stationRouteId = map.get("stationRouteId").equals("") ? 0 : Integer.parseInt(map.get("stationRouteId").toString()); |
| 380 | - | |
| 384 | + | |
| 381 | 385 | Integer destroy = map.get("destroy").equals("") ? 0 : Integer.parseInt(map.get("destroy").toString()); |
| 382 | 386 | |
| 383 | 387 | lsStationRouteRepository.deleteById(stationRouteId); |
| 384 | 388 | |
| 385 | 389 | resultMap.put("status", ResponseCode.SUCCESS); |
| 386 | - | |
| 390 | + | |
| 387 | 391 | } catch (Exception e) { |
| 388 | - | |
| 392 | + | |
| 389 | 393 | resultMap.put("status", ResponseCode.ERROR); |
| 390 | - | |
| 394 | + | |
| 391 | 395 | logger.error("save erro.", e); |
| 392 | - | |
| 396 | + | |
| 393 | 397 | } |
| 394 | - | |
| 398 | + | |
| 395 | 399 | return resultMap; |
| 396 | 400 | } |
| 397 | - | |
| 401 | + | |
| 398 | 402 | /** |
| 399 | 403 | * @Description : TODO(根据线路ID生成行单) |
| 400 | - * | |
| 404 | + * | |
| 401 | 405 | * @param map <lineId:线路ID> |
| 402 | - * | |
| 406 | + * | |
| 403 | 407 | * @return Map<String, Object> <SUCCESS ; ERROR ; NOTDATA> |
| 404 | 408 | */ |
| 405 | 409 | @Override |
| ... | ... | @@ -409,10 +413,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 409 | 413 | try { |
| 410 | 414 | // 获取线路ID |
| 411 | 415 | Integer lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 416 | + Integer version = lineVersionsRepository.findCurrentVersion(lineId); | |
| 417 | + Map<String, Object> param = new HashMap<>(); | |
| 418 | + param.put("line_eq", lineId); | |
| 419 | + param.put("version_eq", version); | |
| 412 | 420 | /** 查询线路信息 @param:<lineId:线路ID> */ |
| 413 | 421 | Line line = lineRepository.findById(lineId).get(); |
| 414 | 422 | |
| 415 | - | |
| 416 | 423 | Business company = businessRepository.findByBusinessCode(line.getCompany()).get(0); |
| 417 | 424 | |
| 418 | 425 | Integer fileVersions = lineRepository.findfileVersions(lineId); |
| ... | ... | @@ -426,13 +433,15 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 426 | 433 | // Integer fileVersions = map.get("fileVersions").equals("") ? 1 : Integer.parseInt(map.get("fileVersions").toString());// 没有输入就默认1 |
| 427 | 434 | /** 查询线路信息下的站点路由信息 @param:<lineId:线路ID> */ |
| 428 | 435 | List<Object[]> objects = stationRouteRepository.usingSingle(lineId); |
| 436 | + List<LineRegion> lineRegions = lineRegionRepository.findAll(new CustomerSpecs<>(param)); | |
| 429 | 437 | if (objects.size()>0) { |
| 430 | -// // 报站音频 | |
| 431 | -// Set<String> languages = new HashSet<>(); | |
| 432 | -// languages.add("cn"); | |
| 433 | -// languages.add("sh"); | |
| 434 | -// languages.add("en"); | |
| 435 | -// InputStream tts = ttsAndZip(objects, line, languages); | |
| 438 | + // 报站音频 | |
| 439 | + Set<String> languages = new HashSet<>(); | |
| 440 | + languages.add("cn"); | |
| 441 | + languages.add("sh"); | |
| 442 | + languages.add("en"); | |
| 443 | + ttsAndZip(objects, line, languages, lineRegions); | |
| 444 | + | |
| 436 | 445 | /** 获取配置文件里的ftp登录参数 */ |
| 437 | 446 | Map<String, Object> FTPParamMap = readPropertiesGetFTPParam(); |
| 438 | 447 | // 压缩文件名 |
| ... | ... | @@ -497,12 +506,25 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 497 | 506 | |
| 498 | 507 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 499 | 508 | |
| 509 | + // 线路文件上传(全程) | |
| 500 | 510 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", textFileName, input); |
| 501 | - | |
| 502 | -// textFile.delete(); | |
| 503 | - | |
| 504 | -// clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | |
| 505 | -// clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode()), tts); | |
| 511 | + String linePath = String.format(linePathPattern, lineId), voicePath = String.format("%s%s.zip", linePath, lineId); | |
| 512 | + // 报站文件上传(全程) | |
| 513 | + clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | |
| 514 | + clientUtils.FTPUpLoadFromDisk(new File(voicePath), String.format("%s.zip", line.getLineCode()), url, port, username, password, remotePath + "/voice/"); | |
| 515 | + | |
| 516 | + // 线路区间 | |
| 517 | + if (lineRegions.size() > 0) { | |
| 518 | + FTPClientUtils.deleteFileByPrefix(String.format("%s-", line.getLineCode()), url, port, username, password, String.format("%s/voice/", remotePath)); | |
| 519 | + for (LineRegion lineRegion : lineRegions) { | |
| 520 | + voicePath = String.format("%s%s-%d.zip", linePath, lineId, lineRegion.getSeq()); | |
| 521 | + textStr = String.format("%s\r\n%s", head, subLine2Ftp(lineRegion)); | |
| 522 | + input = new ByteArrayInputStream(textStr.getBytes("gbk")); | |
| 523 | + clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s-%d.txt", line.getLineCode(), lineRegion.getSeq()), input); | |
| 524 | + clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s-%d.zip", line.getLineCode(), lineRegion.getSeq())); | |
| 525 | + clientUtils.FTPUpLoadFromDisk(new File(voicePath), String.format("%s-%d.zip", line.getLineCode(), lineRegion.getSeq()), url, port, username, password, remotePath + "/voice/"); | |
| 526 | + } | |
| 527 | + } | |
| 506 | 528 | |
| 507 | 529 | resultMap.put("status", ResponseCode.SUCCESS); |
| 508 | 530 | }else { |
| ... | ... | @@ -515,22 +537,22 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 515 | 537 | return resultMap; |
| 516 | 538 | } |
| 517 | 539 | } |
| 518 | - | |
| 540 | + | |
| 519 | 541 | /** |
| 520 | 542 | * @Description : TODO(形成行单文件内容) |
| 521 | - * | |
| 543 | + * | |
| 522 | 544 | * @param objects :站点路由信息 |
| 523 | - * | |
| 545 | + * | |
| 524 | 546 | * {[0]:g_lonx(GPS经度);[1]:g_laty(GPS纬度);[2]:b_jwpoints(百度经纬度坐标) |
| 525 | - * | |
| 547 | + * | |
| 526 | 548 | * [3]:station_mark(站点类型);[4]:station_route_code(站点序号);[5]:station_cod(站点编码); |
| 527 | - * | |
| 549 | + * | |
| 528 | 550 | * [6]:distances(站点距离);[7]:station_name(站点名称);[8]:directions(方向)} |
| 529 | - * | |
| 551 | + * | |
| 530 | 552 | * @param lineId :线路ID |
| 531 | - * | |
| 553 | + * | |
| 532 | 554 | * @return String |
| 533 | - */ | |
| 555 | + */ | |
| 534 | 556 | public String newTextFileToFTP(List<Object[]> objects,Integer lineId) { |
| 535 | 557 | |
| 536 | 558 | // 返回值String |
| ... | ... | @@ -545,34 +567,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 545 | 567 | defaultZdxh ++ ; |
| 546 | 568 | // 经度 |
| 547 | 569 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 548 | - | |
| 570 | + | |
| 549 | 571 | // 纬度 |
| 550 | 572 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 551 | - | |
| 573 | + | |
| 552 | 574 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 553 | - | |
| 575 | + | |
| 554 | 576 | lat = "\t" + lat; |
| 555 | - | |
| 577 | + | |
| 556 | 578 | // 站点类型 |
| 557 | 579 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); |
| 558 | - | |
| 580 | + | |
| 559 | 581 | String stationMake = ""; |
| 560 | - | |
| 582 | + | |
| 561 | 583 | if(stationMakeStr.equals("E")) { |
| 562 | 584 | stationMake = "\t2"; |
| 563 | 585 | }else { |
| 564 | 586 | stationMake ="\t1"; |
| 565 | 587 | } |
| 566 | - | |
| 567 | - // 站点序号 | |
| 588 | + | |
| 589 | + // 站点序号 | |
| 568 | 590 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 569 | 591 | String stationNo = String.valueOf(defaultZdxh); |
| 570 | - | |
| 592 | + | |
| 571 | 593 | stationNo = "\t" + stationNo; |
| 572 | - | |
| 594 | + | |
| 573 | 595 | // 站点编码 |
| 574 | 596 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); |
| 575 | - | |
| 597 | + | |
| 576 | 598 | int len = stationCode.length(); |
| 577 | 599 | if(len<8) { |
| 578 | 600 | int dx = 8 - len; |
| ... | ... | @@ -584,24 +606,24 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 584 | 606 | }else if(len>8){ |
| 585 | 607 | stationCode = stationCode.substring(8); |
| 586 | 608 | } |
| 587 | - | |
| 609 | + | |
| 588 | 610 | stationCode = "\t" +stationCode; |
| 589 | - | |
| 611 | + | |
| 590 | 612 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; |
| 591 | - | |
| 613 | + | |
| 592 | 614 | String tempDistc = String.valueOf((int) dis); |
| 593 | - | |
| 615 | + | |
| 594 | 616 | // 站点距离 |
| 595 | 617 | String staitondistance = "\t" + tempDistc; |
| 596 | - | |
| 618 | + | |
| 597 | 619 | // 站点名称 |
| 598 | 620 | String stationName = objects.get(i)[7].equals("") ? "" : objects.get(i)[7].toString(); |
| 599 | - | |
| 621 | + | |
| 600 | 622 | stationName = "\t" +stationName; |
| 601 | - | |
| 623 | + | |
| 602 | 624 | // 限速 |
| 603 | 625 | // String sleepStr = " " + "60"; |
| 604 | - | |
| 626 | + | |
| 605 | 627 | // 限速 |
| 606 | 628 | String sleepStr = ""; |
| 607 | 629 | // 方向 |
| ... | ... | @@ -631,16 +653,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 631 | 653 | } |
| 632 | 654 | } |
| 633 | 655 | } |
| 634 | - if(sleepStr.equals("")) | |
| 656 | + if(sleepStr.equals("")) | |
| 635 | 657 | sleepStr = "\t" + "60"; |
| 636 | 658 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; |
| 637 | 659 | } |
| 638 | - | |
| 660 | + | |
| 639 | 661 | } |
| 640 | 662 | return stationRStr; |
| 641 | - | |
| 663 | + | |
| 642 | 664 | } |
| 643 | - | |
| 665 | + | |
| 644 | 666 | public String newTextVoiceFileToFTP(List<Object[]> objects,Integer lineId) { |
| 645 | 667 | |
| 646 | 668 | // 返回值String |
| ... | ... | @@ -655,34 +677,34 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 655 | 677 | defaultZdxh ++ ; |
| 656 | 678 | // 经度 |
| 657 | 679 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 658 | - | |
| 680 | + | |
| 659 | 681 | // 纬度 |
| 660 | 682 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 661 | - | |
| 683 | + | |
| 662 | 684 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 663 | - | |
| 685 | + | |
| 664 | 686 | lat = "\t" + lat; |
| 665 | - | |
| 687 | + | |
| 666 | 688 | // 站点类型 |
| 667 | 689 | String stationMakeStr = objects.get(i)[3].equals("") ? "" : objects.get(i)[3].toString(); |
| 668 | - | |
| 690 | + | |
| 669 | 691 | String stationMake = ""; |
| 670 | - | |
| 692 | + | |
| 671 | 693 | if(stationMakeStr.equals("E")) { |
| 672 | 694 | stationMake = "\t2"; |
| 673 | 695 | }else { |
| 674 | 696 | stationMake ="\t1"; |
| 675 | 697 | } |
| 676 | - | |
| 677 | - // 站点序号 | |
| 698 | + | |
| 699 | + // 站点序号 | |
| 678 | 700 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 679 | 701 | String stationNo = String.valueOf(defaultZdxh); |
| 680 | - | |
| 702 | + | |
| 681 | 703 | stationNo = "\t" + stationNo; |
| 682 | - | |
| 704 | + | |
| 683 | 705 | // 站点编码 |
| 684 | 706 | String stationCode = objects.get(i)[5].equals("") ? "" : objects.get(i)[5].toString(); |
| 685 | - | |
| 707 | + | |
| 686 | 708 | int len = stationCode.length(); |
| 687 | 709 | if(len<8) { |
| 688 | 710 | int dx = 8 - len; |
| ... | ... | @@ -694,31 +716,31 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 694 | 716 | }else if(len>8){ |
| 695 | 717 | stationCode = stationCode.substring(8); |
| 696 | 718 | } |
| 697 | - | |
| 719 | + | |
| 698 | 720 | stationCode = "\t" +stationCode; |
| 699 | - | |
| 721 | + | |
| 700 | 722 | double dis = objects.get(i)[6]==null ? 0.0 : Double.parseDouble(objects.get(i)[6].toString())*1000; |
| 701 | - | |
| 723 | + | |
| 702 | 724 | String tempDistc = String.valueOf((int) dis); |
| 703 | - | |
| 725 | + | |
| 704 | 726 | // 站点距离 |
| 705 | 727 | String staitondistance = "\t" + tempDistc; |
| 706 | - | |
| 728 | + | |
| 707 | 729 | // 站点名称 |
| 708 | 730 | String stationName = objects.get(i)[7].equals("") ? " " : objects.get(i)[7].toString(); |
| 709 | - | |
| 731 | + | |
| 710 | 732 | String stationNameEn = " "; |
| 711 | 733 | if(objects.get(i)[9] != null){ |
| 712 | 734 | stationNameEn = objects.get(i)[9].equals("") ? " " : objects.get(i)[9].toString(); |
| 713 | 735 | } |
| 714 | - | |
| 715 | - | |
| 736 | + | |
| 737 | + | |
| 716 | 738 | stationName = "\t" +stationName; |
| 717 | 739 | stationNameEn = "\t" +stationNameEn; |
| 718 | - | |
| 740 | + | |
| 719 | 741 | // 限速 |
| 720 | 742 | // String sleepStr = " " + "60"; |
| 721 | - | |
| 743 | + | |
| 722 | 744 | // 限速 |
| 723 | 745 | String sleepStr = ""; |
| 724 | 746 | // 方向 |
| ... | ... | @@ -751,16 +773,16 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 751 | 773 | } |
| 752 | 774 | } |
| 753 | 775 | } |
| 754 | - if(sleepStr.equals("")) | |
| 776 | + if(sleepStr.equals("")) | |
| 755 | 777 | sleepStr = "\t" + "60"; |
| 756 | 778 | stationRStr = stationRStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + stationNameEn + enterStr; |
| 757 | 779 | } |
| 758 | - | |
| 780 | + | |
| 759 | 781 | } |
| 760 | 782 | return stationRStr; |
| 761 | - | |
| 783 | + | |
| 762 | 784 | } |
| 763 | - | |
| 785 | + | |
| 764 | 786 | public String hxTextFileToFtp(List<Object[]> objects,Integer lineId) { |
| 765 | 787 | String restStr = ""; |
| 766 | 788 | // windows下的文本文件换行符 |
| ... | ... | @@ -773,10 +795,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 773 | 795 | if(Integer.valueOf(objects.get(i)[8].toString())==0) { |
| 774 | 796 | // 经度 |
| 775 | 797 | String lng = objects.get(i)[0].equals("") ? "0" : objects.get(i)[0].toString(); |
| 776 | - | |
| 798 | + | |
| 777 | 799 | // 纬度 |
| 778 | 800 | String lat = objects.get(i)[1].equals("") ? "0" : objects.get(i)[1].toString(); |
| 779 | - | |
| 801 | + | |
| 780 | 802 | Point point = new Point(Double.valueOf(lng), Double.valueOf(lat)); |
| 781 | 803 | lat = "\t" + lat; |
| 782 | 804 | // 站点类型 |
| ... | ... | @@ -787,7 +809,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 787 | 809 | }else { |
| 788 | 810 | stationMake ="\t1"; |
| 789 | 811 | } |
| 790 | - // 站点序号 | |
| 812 | + // 站点序号 | |
| 791 | 813 | // String stationNo = objects.get(i)[4].equals("") ? "" : objects.get(i)[4].toString(); |
| 792 | 814 | String stationNo = "\t" + xh; |
| 793 | 815 | // 站点编码 |
| ... | ... | @@ -843,7 +865,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 843 | 865 | } |
| 844 | 866 | } |
| 845 | 867 | } |
| 846 | - if(sleepStr.equals("")) | |
| 868 | + if(sleepStr.equals("")) | |
| 847 | 869 | sleepStr = "\t" + "60"; |
| 848 | 870 | xh++; |
| 849 | 871 | restStr = restStr + lng + lat + stationMake + stationNo + stationCode + staitondistance + sleepStr + stationName + enterStr; |
| ... | ... | @@ -853,70 +875,70 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 853 | 875 | System.out.println(restStr); |
| 854 | 876 | return restStr; |
| 855 | 877 | } |
| 856 | - | |
| 878 | + | |
| 857 | 879 | public boolean isPointOnPolyline (Map<String, Object> point, List<Map<String, Object>> listMap ){ |
| 858 | - | |
| 880 | + | |
| 859 | 881 | boolean success = false; |
| 860 | - | |
| 882 | + | |
| 861 | 883 | for(int l = 0; l < listMap.size() - 1; l ++){ |
| 862 | - | |
| 884 | + | |
| 863 | 885 | Map<String, Object> tempM = listMap.get(l); |
| 864 | - | |
| 886 | + | |
| 865 | 887 | Map<String, Object> nextTempM = listMap.get(l+1); |
| 866 | - | |
| 888 | + | |
| 867 | 889 | 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())) && |
| 868 | 890 | 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()))){ |
| 869 | - | |
| 870 | - | |
| 871 | - 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())) - | |
| 891 | + | |
| 892 | + | |
| 893 | + 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())) - | |
| 872 | 894 | (Double.valueOf(nextTempM.get("lng").toString()) - Double.valueOf(tempM.get("lng").toString())) * (Double.valueOf(tempM.get("lat").toString()) - Double.valueOf(nextTempM.get("lat").toString())); |
| 873 | - | |
| 895 | + | |
| 874 | 896 | if(precision < 2e-10 && precision > -2e-10){ |
| 875 | - | |
| 897 | + | |
| 876 | 898 | //实质判断是否接近0 |
| 877 | 899 | success = true; |
| 878 | - | |
| 879 | - } | |
| 880 | - | |
| 900 | + | |
| 901 | + } | |
| 902 | + | |
| 881 | 903 | } |
| 882 | - | |
| 904 | + | |
| 883 | 905 | } |
| 884 | - | |
| 906 | + | |
| 885 | 907 | return success; |
| 886 | 908 | } |
| 887 | - | |
| 909 | + | |
| 888 | 910 | /** |
| 889 | 911 | * @Description:TOOD(获取FTP登录参数) 这里暂时只做一个map值返回,以后可以作为ftp登录类提出来 |
| 890 | - * | |
| 912 | + * | |
| 891 | 913 | * @return : Map<String, Object> <url:IP;port:端口;username:用户名;password:密码;remotePath:相对路径> |
| 892 | 914 | */ |
| 893 | 915 | public Map<String, Object> readPropertiesGetFTPParam(){ |
| 894 | - | |
| 916 | + | |
| 895 | 917 | // 返回值map |
| 896 | 918 | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| 897 | - | |
| 919 | + | |
| 898 | 920 | Properties env = new Properties(); |
| 899 | - | |
| 921 | + | |
| 900 | 922 | try { |
| 901 | - | |
| 923 | + | |
| 902 | 924 | env.load(DBUtils_MS.class.getClassLoader().getResourceAsStream("ftp.properties")); |
| 903 | - | |
| 925 | + | |
| 904 | 926 | resultMap.put("url", env.getProperty("ftp.url")); |
| 905 | - | |
| 927 | + | |
| 906 | 928 | resultMap.put("port", env.getProperty("ftp.port")); |
| 907 | - | |
| 929 | + | |
| 908 | 930 | resultMap.put("username", env.getProperty("ftp.username")); |
| 909 | - | |
| 931 | + | |
| 910 | 932 | resultMap.put("password", env.getProperty("ftp.password")); |
| 911 | - | |
| 933 | + | |
| 912 | 934 | resultMap.put("remotePath", env.getProperty("ftp.path")); |
| 913 | - | |
| 935 | + | |
| 914 | 936 | } catch (Exception e) { |
| 915 | 937 | |
| 916 | 938 | e.printStackTrace(); |
| 917 | - | |
| 939 | + | |
| 918 | 940 | } |
| 919 | - | |
| 941 | + | |
| 920 | 942 | return resultMap ; |
| 921 | 943 | } |
| 922 | 944 | |
| ... | ... | @@ -943,7 +965,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 943 | 965 | } |
| 944 | 966 | //过滤部分字段 |
| 945 | 967 | /*String jsonStr = JSON.toJSONString(list, new PropertyFilter() { |
| 946 | - | |
| 968 | + | |
| 947 | 969 | @Override |
| 948 | 970 | public boolean apply(Object object, String name, Object value) { |
| 949 | 971 | if(name.equals("line")) |
| ... | ... | @@ -951,14 +973,14 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 951 | 973 | return true; |
| 952 | 974 | } |
| 953 | 975 | });*/ |
| 954 | - | |
| 976 | + | |
| 955 | 977 | rs.put("status", ResponseCode.SUCCESS); |
| 956 | 978 | rs.put("list", list); |
| 957 | 979 | }catch(Exception e){ |
| 958 | 980 | logger.error("", e); |
| 959 | 981 | rs.put("status", ResponseCode.ERROR); |
| 960 | 982 | } |
| 961 | - | |
| 983 | + | |
| 962 | 984 | return rs; |
| 963 | 985 | } |
| 964 | 986 | |
| ... | ... | @@ -1047,7 +1069,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1047 | 1069 | * @param line |
| 1048 | 1070 | * @param languages 语言 如:cn、en、sh |
| 1049 | 1071 | */ |
| 1050 | - private InputStream ttsAndZip(List<Object[]> objects, Line line, Set<String> languages) throws Exception { | |
| 1072 | + private void ttsAndZip(List<Object[]> objects, Line line, Set<String> languages, List<LineRegion> lineRegions) throws Exception { | |
| 1051 | 1073 | String lineId = line.getLineCode(); |
| 1052 | 1074 | StringBuilder cnBuilder = new StringBuilder(line.getName()).append("[p1000]"), enBuilder = new StringBuilder("Hello[p1000]"); |
| 1053 | 1075 | int ups = 0, downs = 0; |
| ... | ... | @@ -1082,47 +1104,90 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1082 | 1104 | // 文本转语音并进行分割 |
| 1083 | 1105 | // 音频存放及压缩文件路径 |
| 1084 | 1106 | String linePath = String.format(linePathPattern, lineId), voicePath = String.format("%s%s.zip", linePath, lineId); |
| 1085 | - try { | |
| 1086 | - String path = String.format("%scn.mp3", linePath); | |
| 1087 | - IFlyUtils.textToSpeechCn(cnBuilder.toString(), path); | |
| 1088 | - AudioOperationUtils.splitBySilence(path, String.format("%scn", linePath), 500, -40); | |
| 1089 | - } catch (Exception e) { | |
| 1090 | - throw new RuntimeException(e); | |
| 1091 | - } | |
| 1092 | - if (languages.contains("sh")) { | |
| 1093 | - try { | |
| 1094 | - String path = String.format("%ssh.mp3", linePath); | |
| 1095 | - IFlyUtils.textToSpeechSh(cnBuilder.toString(), path); | |
| 1096 | - AudioOperationUtils.splitBySilence(path, String.format("%ssh", linePath), 500, -40); | |
| 1097 | - } catch (Exception e) { | |
| 1098 | - throw new RuntimeException(e); | |
| 1099 | - } | |
| 1100 | - } | |
| 1101 | - if (languages.contains("en")) { | |
| 1107 | + // 先清理历史生成的文件 | |
| 1108 | + cleanHistoryAudio(new File(linePath)); | |
| 1109 | + for (String language : languages) { | |
| 1102 | 1110 | try { |
| 1103 | - String path = String.format("%sen.mp3", linePath); | |
| 1104 | - IFlyUtils.textToSpeechEn(enBuilder.toString(), path); | |
| 1105 | - AudioOperationUtils.splitBySilence(path, String.format("%sen", linePath), 500, -40); | |
| 1111 | + String path = String.format("%s%s.mp3", linePath, language); | |
| 1112 | + if ("cn".equals(language) || "sh".equals(language)) { | |
| 1113 | + IFlyUtils.textToSpeech(cnBuilder.toString(), language, path); | |
| 1114 | + } else if ("en".equals(language)) { | |
| 1115 | + IFlyUtils.textToSpeech(enBuilder.toString(), language, path); | |
| 1116 | + } | |
| 1117 | + AudioOperationUtils.splitBySilence(path, String.format("%s%s", linePath, language), 500, -40); | |
| 1106 | 1118 | } catch (Exception e) { |
| 1107 | 1119 | throw new RuntimeException(e); |
| 1108 | 1120 | } |
| 1109 | 1121 | } |
| 1110 | - // 删除原线路音频 | |
| 1111 | - File file = new File(linePath); | |
| 1112 | - for (File f : file.listFiles()) { | |
| 1113 | - if (f.isFile() && f.getName().endsWith(".mp3")) { | |
| 1114 | - file.delete(); | |
| 1122 | + | |
| 1123 | + // 合并每站起步、到达语音(全程) | |
| 1124 | + int seq = 1; | |
| 1125 | + List<SeqStationLevel> seqs = new ArrayList<>(); | |
| 1126 | + for (int i = seq;i <= ups;i++) { | |
| 1127 | + seqs.add(new SeqStationLevel(i, i)); | |
| 1128 | + } | |
| 1129 | + seq = merge(lineId, "0", seq, seqs, languages); | |
| 1130 | + if (line.getLinePlayType() != 1) { | |
| 1131 | + seqs.clear(); | |
| 1132 | + for (int i = seq;i <= ups + downs;i++) { | |
| 1133 | + seqs.add(new SeqStationLevel(i, i, 1)); | |
| 1134 | + } | |
| 1135 | + merge(lineId, "0", seq, seqs, languages); | |
| 1136 | + } | |
| 1137 | + zipAudio(String.format("%s%s/", linePath, "0"), voicePath); | |
| 1138 | + | |
| 1139 | + // 线路区间 | |
| 1140 | + Map<String, List<SeqStationLevel>> region2map = new HashMap<>(); | |
| 1141 | + for (LineRegion lineRegion : lineRegions) { | |
| 1142 | + for (int i = 0;i < objects.size();i++) { | |
| 1143 | + Object[] objArr = objects.get(i); | |
| 1144 | + String stationCode = (String) objArr[5]; | |
| 1145 | + int direction = (int) objArr[8]; | |
| 1146 | + if (lineRegion.getDirection() == direction) { | |
| 1147 | + for (int j = 0;j < lineRegion.getStationRoutes().size();j++) { | |
| 1148 | + LsStationRoute stationRoute = lineRegion.getStationRoutes().get(j); | |
| 1149 | + if (stationCode.equals(stationRoute.getStationCode())) { | |
| 1150 | + List<SeqStationLevel> map = region2map.get(lineRegion.getSeq().toString()); | |
| 1151 | + if (map == null) { | |
| 1152 | + map = new ArrayList<>(); | |
| 1153 | + region2map.put(lineRegion.getSeq().toString(), map); | |
| 1154 | + } | |
| 1155 | + map.add(new SeqStationLevel(j + 1, i + 1, direction)); | |
| 1156 | + break; | |
| 1157 | + } | |
| 1158 | + } | |
| 1159 | + } | |
| 1115 | 1160 | } |
| 1116 | 1161 | } |
| 1162 | + for (Map.Entry<String, List<SeqStationLevel>> entry : region2map.entrySet()) { | |
| 1163 | + String subLineId = entry.getKey(); | |
| 1164 | + List<SeqStationLevel> map = entry.getValue(); | |
| 1165 | + seq = 1; | |
| 1166 | + merge(lineId, subLineId, seq, map, languages); | |
| 1167 | + zipAudio(String.format("%s%s/", linePath, subLineId), String.format("%s%s-%s.zip", linePath, lineId, subLineId)); | |
| 1168 | + } | |
| 1169 | + } | |
| 1117 | 1170 | |
| 1118 | - // 合并每站起步、到达语音 | |
| 1119 | - int seq = 1, startSeq = 1, direction = 0; | |
| 1120 | - seq = merge(lineId, seq, startSeq, direction, ups, languages); | |
| 1121 | - startSeq = ups + 1; | |
| 1122 | - direction = 1; | |
| 1123 | - merge(lineId, seq, startSeq, direction, ups + downs, languages); | |
| 1171 | + private void cleanHistoryAudio(File file) throws Exception { | |
| 1172 | + if (file.isDirectory()) { | |
| 1173 | + File[] files = file.listFiles(); | |
| 1174 | + for (File f : files) { | |
| 1175 | + cleanHistoryAudio(f); | |
| 1176 | + } | |
| 1177 | + } else { | |
| 1178 | + if (file.getName().endsWith(".mp3") || file.getName().endsWith(".zip")) { | |
| 1179 | + file.delete(); | |
| 1180 | + } | |
| 1181 | + } | |
| 1182 | + } | |
| 1124 | 1183 | |
| 1125 | - // 压缩音频到zip | |
| 1184 | + /** | |
| 1185 | + * 压缩音频到zip | |
| 1186 | + * @param subLinePath 子线路文件夹 | |
| 1187 | + * @param voicePath 语音报站文件压缩包路径 | |
| 1188 | + */ | |
| 1189 | + private void zipAudio(String subLinePath, String voicePath) throws Exception { | |
| 1190 | + File file = new File(subLinePath); | |
| 1126 | 1191 | ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(voicePath)); |
| 1127 | 1192 | for (File f : file.listFiles()) { |
| 1128 | 1193 | if (f.isFile() && f.getName().endsWith(".mp3")) { |
| ... | ... | @@ -1138,8 +1203,6 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1138 | 1203 | } |
| 1139 | 1204 | zos.flush(); |
| 1140 | 1205 | zos.close(); |
| 1141 | - | |
| 1142 | - return new FileInputStream(voicePath); | |
| 1143 | 1206 | } |
| 1144 | 1207 | |
| 1145 | 1208 | private static void addFileToZip(ZipOutputStream zos, File file) throws IOException { |
| ... | ... | @@ -1157,21 +1220,32 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1157 | 1220 | fis.close(); |
| 1158 | 1221 | } |
| 1159 | 1222 | |
| 1160 | - private int merge(String lineId, int seq, int startSeq, int direction, int terminal, Set<String> languages) throws Exception { | |
| 1161 | - for (int i = startSeq;i <= terminal;i++) { | |
| 1162 | - if (i > startSeq) { | |
| 1163 | - if (i == startSeq + 1) { | |
| 1223 | + /** | |
| 1224 | + * | |
| 1225 | + * @param lineId 线路编码 | |
| 1226 | + * @param seq 线路站级序号(全局) | |
| 1227 | + * @param seqs 当前方向站级序号 | |
| 1228 | + * @param languages 语种 | |
| 1229 | + * @return | |
| 1230 | + * @throws Exception | |
| 1231 | + */ | |
| 1232 | + private int merge(String lineId, String subLineId, int seq, List<SeqStationLevel> seqs, Set<String> languages) throws Exception { | |
| 1233 | + SeqStationLevel startSeq = seqs.get(0), terminal = seqs.get(seqs.size() - 1); | |
| 1234 | + for (int i = 0;i < seqs.size();i++) { | |
| 1235 | + SeqStationLevel current = seqs.get(i); | |
| 1236 | + if (current.getStationLevel() > startSeq.getStationLevel()) { | |
| 1237 | + if (i == 1) { | |
| 1164 | 1238 | // 生成首站 |
| 1165 | - mergeOriginStart(lineId, seq, i, direction, terminal, languages); | |
| 1166 | - mergeNormalArrive(lineId, seq, i, direction, terminal, languages); | |
| 1167 | - } else if (i == terminal) { | |
| 1239 | + mergeOriginStart(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1240 | + mergeNormalArrive(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1241 | + } else if (current.getStationLevel() == terminal.getStationLevel()) { | |
| 1168 | 1242 | // 生成终点站 |
| 1169 | - mergeNormalStart(lineId, seq, i, direction, terminal, languages); | |
| 1170 | - mergeTerminalArrive(lineId, seq, i, direction, terminal, languages); | |
| 1243 | + mergeNormalStart(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1244 | + mergeTerminalArrive(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1171 | 1245 | } else { |
| 1172 | 1246 | // 生成中途站 |
| 1173 | - mergeNormalStart(lineId, seq, i, direction, terminal, languages); | |
| 1174 | - mergeNormalArrive(lineId, seq, i, direction, terminal, languages); | |
| 1247 | + mergeNormalStart(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1248 | + mergeNormalArrive(lineId, subLineId, seq, current, current.getDirection(), terminal, languages); | |
| 1175 | 1249 | } |
| 1176 | 1250 | seq++; |
| 1177 | 1251 | } |
| ... | ... | @@ -1180,9 +1254,11 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1180 | 1254 | return seq; |
| 1181 | 1255 | } |
| 1182 | 1256 | |
| 1183 | - private void mergeOriginStart(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | |
| 1257 | + private void mergeOriginStart(String lineId, String subLineId, int seq, SeqStationLevel current, int direction, SeqStationLevel terminal, Set<String> languages) throws Exception { | |
| 1258 | + // 子线路路径 | |
| 1184 | 1259 | String linePath = String.format(linePathPattern, lineId); |
| 1185 | - 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"); | |
| 1260 | + String subLinePath = String.format("%s%s/", linePath, subLineId); | |
| 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"); | |
| 1186 | 1262 | List<String> inputPaths = new ArrayList<>(); |
| 1187 | 1263 | for (String path : arr) { |
| 1188 | 1264 | for (String lang : languages) { |
| ... | ... | @@ -1192,12 +1268,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1192 | 1268 | } |
| 1193 | 1269 | } |
| 1194 | 1270 | } |
| 1195 | - 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")); | |
| 1196 | 1272 | } |
| 1197 | 1273 | |
| 1198 | - 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, int direction, SeqStationLevel terminal, Set<String> languages) throws Exception { | |
| 1199 | 1275 | String linePath = String.format(linePathPattern, lineId); |
| 1200 | - 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 | + 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"); | |
| 1201 | 1278 | List<String> inputPaths = new ArrayList<>(); |
| 1202 | 1279 | for (String path : arr) { |
| 1203 | 1280 | for (String lang : languages) { |
| ... | ... | @@ -1207,26 +1284,27 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1207 | 1284 | } |
| 1208 | 1285 | } |
| 1209 | 1286 | } |
| 1210 | - 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")); | |
| 1287 | + 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")); | |
| 1211 | 1288 | } |
| 1212 | 1289 | |
| 1213 | - private void mergeNormalArrive(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | |
| 1290 | + private void mergeNormalArrive(String lineId, String subLineId, int seq, SeqStationLevel current, int direction, SeqStationLevel terminal, Set<String> languages) throws Exception { | |
| 1214 | 1291 | String linePath = String.format(linePathPattern, lineId); |
| 1215 | - 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))); | |
| 1292 | + String subLinePath = String.format("%s%s/", linePath, subLineId); | |
| 1293 | + 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()))); | |
| 1216 | 1294 | List<String> inputPaths = new ArrayList<>(); |
| 1217 | 1295 | if (languages.contains("sh")) { |
| 1218 | 1296 | for (int i = 0;i < 3;i++) { |
| 1219 | 1297 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); |
| 1220 | 1298 | arr.add(commonPath + "cn_origin_2.mp3"); |
| 1221 | - arr.add(linePath + String.format("cn/%03d.mp3", terminal)); | |
| 1299 | + arr.add(linePath + String.format("cn/%03d.mp3", terminal.getStationLevel())); | |
| 1222 | 1300 | arr.add(linePath + String.format("sh/%03d.mp3", 0)); |
| 1223 | 1301 | arr.add(commonPath + "sh_origin_2.mp3"); |
| 1224 | - arr.add(linePath + String.format("sh/%03d.mp3", terminal)); | |
| 1302 | + arr.add(linePath + String.format("sh/%03d.mp3", terminal.getStationLevel())); | |
| 1225 | 1303 | } |
| 1226 | 1304 | } else { |
| 1227 | 1305 | arr.add(linePath + String.format("cn/%03d.mp3", 0)); |
| 1228 | 1306 | arr.add(commonPath + "cn_origin_2.mp3"); |
| 1229 | - arr.add(linePath + String.format("cn/%03d.mp3", terminal)); | |
| 1307 | + arr.add(linePath + String.format("cn/%03d.mp3", terminal.getStationLevel())); | |
| 1230 | 1308 | } |
| 1231 | 1309 | for (String path : arr) { |
| 1232 | 1310 | for (String lang : languages) { |
| ... | ... | @@ -1236,12 +1314,13 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1236 | 1314 | } |
| 1237 | 1315 | } |
| 1238 | 1316 | } |
| 1239 | - 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")); | |
| 1317 | + 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")); | |
| 1240 | 1318 | } |
| 1241 | 1319 | |
| 1242 | - private void mergeTerminalArrive(String lineId, int seq, int stationLevel, int direction, int terminal, Set<String> languages) throws Exception { | |
| 1320 | + private void mergeTerminalArrive(String lineId, String subLineId, int seq, SeqStationLevel current, int direction, SeqStationLevel terminal, Set<String> languages) throws Exception { | |
| 1243 | 1321 | String linePath = String.format(linePathPattern, lineId); |
| 1244 | - 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"); | |
| 1322 | + String subLinePath = String.format("%s%s/", linePath, subLineId); | |
| 1323 | + 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"); | |
| 1245 | 1324 | List<String> inputPaths = new ArrayList<>(); |
| 1246 | 1325 | for (String path : arr) { |
| 1247 | 1326 | for (String lang : languages) { |
| ... | ... | @@ -1251,7 +1330,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1251 | 1330 | } |
| 1252 | 1331 | } |
| 1253 | 1332 | } |
| 1254 | - 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")); | |
| 1333 | + 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")); | |
| 1255 | 1334 | } |
| 1256 | 1335 | |
| 1257 | 1336 | private void description() { |
| ... | ... | @@ -1276,4 +1355,50 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 1276 | 1355 | // 终点站(沪) (sh_terminal.mp3) |
| 1277 | 1356 | // 终点音乐 (terminal_music.mp3) |
| 1278 | 1357 | } |
| 1358 | + | |
| 1359 | + /** | |
| 1360 | + * 站序和站级的影响,全程和区间时会不一致 | |
| 1361 | + */ | |
| 1362 | + private final static class SeqStationLevel { | |
| 1363 | + | |
| 1364 | + private Integer seq; | |
| 1365 | + | |
| 1366 | + private Integer stationLevel; | |
| 1367 | + | |
| 1368 | + private int direction; | |
| 1369 | + | |
| 1370 | + private SeqStationLevel(Integer seq, Integer stationLevel) { | |
| 1371 | + this(seq, stationLevel, 0); | |
| 1372 | + } | |
| 1373 | + | |
| 1374 | + private SeqStationLevel(Integer seq, Integer stationLevel, int direction) { | |
| 1375 | + this.seq = seq; | |
| 1376 | + this.stationLevel = stationLevel; | |
| 1377 | + this.direction = direction; | |
| 1378 | + } | |
| 1379 | + | |
| 1380 | + public Integer getSeq() { | |
| 1381 | + return seq; | |
| 1382 | + } | |
| 1383 | + | |
| 1384 | + public void setSeq(Integer seq) { | |
| 1385 | + this.seq = seq; | |
| 1386 | + } | |
| 1387 | + | |
| 1388 | + public Integer getStationLevel() { | |
| 1389 | + return stationLevel; | |
| 1390 | + } | |
| 1391 | + | |
| 1392 | + public void setStationLevel(Integer stationLevel) { | |
| 1393 | + this.stationLevel = stationLevel; | |
| 1394 | + } | |
| 1395 | + | |
| 1396 | + public int getDirection() { | |
| 1397 | + return direction; | |
| 1398 | + } | |
| 1399 | + | |
| 1400 | + public void setDirection(int direction) { | |
| 1401 | + this.direction = direction; | |
| 1402 | + } | |
| 1403 | + } | |
| 1279 | 1404 | } | ... | ... |
src/main/java/com/bsth/util/FTPClientUtils.java
| 1 | -package com.bsth.util; | |
| 2 | - | |
| 3 | -import java.io.ByteArrayInputStream; | |
| 4 | -import java.io.File; | |
| 5 | -import java.io.FileInputStream; | |
| 6 | -import java.io.FileNotFoundException; | |
| 7 | -import java.io.FileOutputStream; | |
| 8 | -import java.io.IOException; | |
| 9 | -import java.io.InputStream; | |
| 10 | -import java.io.OutputStream; | |
| 11 | -import java.io.UnsupportedEncodingException; | |
| 12 | - | |
| 13 | -import org.apache.commons.net.ftp.FTPClient; | |
| 14 | -import org.apache.commons.net.ftp.FTPFile; | |
| 15 | -import org.apache.commons.net.ftp.FTPReply; | |
| 16 | -/** | |
| 17 | - * @Description: 向FTP服务器上传文件 | |
| 18 | - * | |
| 19 | - * @Version 1.0 2016-06-21 4:31:09 by 李强 | |
| 20 | - * | |
| 21 | - */ | |
| 22 | -public class FTPClientUtils { | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * @param url FTP服务器hostname; | |
| 26 | - * | |
| 27 | - * - - - - port FTP服务器端口; | |
| 28 | - * | |
| 29 | - * - - - - username FTP登录账号; | |
| 30 | - * | |
| 31 | - * - - - - password FTP登录密码 ; | |
| 32 | - * | |
| 33 | - * - - - - path FTP服务器保存目录; | |
| 34 | - * | |
| 35 | - * - - - - filename 上传到FTP服务器上的文件名 | |
| 36 | - * | |
| 37 | - * - - - - input 输入流; | |
| 38 | - * | |
| 39 | - * @return 成功返回true,否则返回false | |
| 40 | - * | |
| 41 | - */ | |
| 42 | - public boolean uploadFile(String url,int port,String username, String password, String path, String filename, InputStream input) { | |
| 43 | - | |
| 44 | - boolean success = false; | |
| 45 | - | |
| 46 | - FTPClient ftp = new FTPClient(); | |
| 47 | - | |
| 48 | - try { | |
| 49 | - | |
| 50 | - int reply; | |
| 51 | - | |
| 52 | - //连接FTP服务器,如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器 | |
| 53 | - ftp.connect(url, port); | |
| 54 | - | |
| 55 | - //登录 | |
| 56 | - ftp.login(username, password); | |
| 57 | - | |
| 58 | - reply = ftp.getReplyCode(); | |
| 59 | - | |
| 60 | - if (!FTPReply.isPositiveCompletion(reply)) { | |
| 61 | - | |
| 62 | - ftp.disconnect(); | |
| 63 | - | |
| 64 | - return success; | |
| 65 | - | |
| 66 | - } | |
| 67 | - | |
| 68 | - ftp.changeWorkingDirectory(path); | |
| 69 | - ftp.setFileType(FTPClient.BINARY_FILE_TYPE); | |
| 70 | - ftp.enterLocalPassiveMode(); | |
| 71 | - success = ftp.storeFile(new String(filename.getBytes("gbk"),"gbk"), input); | |
| 72 | - /*success = ftp.storeFile(filename, input); */ | |
| 73 | - input.close(); | |
| 74 | - | |
| 75 | - ftp.logout(); | |
| 76 | - | |
| 77 | - // success = true; | |
| 78 | - | |
| 79 | - } catch (IOException e) { | |
| 80 | - | |
| 81 | - e.printStackTrace(); | |
| 82 | - | |
| 83 | - } finally { | |
| 84 | - | |
| 85 | - if (ftp.isConnected()) { | |
| 86 | - | |
| 87 | - try { | |
| 88 | - | |
| 89 | - ftp.disconnect(); | |
| 90 | - | |
| 91 | - } catch (IOException ioe) { | |
| 92 | - | |
| 93 | - } | |
| 94 | - | |
| 95 | - } | |
| 96 | - | |
| 97 | - } | |
| 98 | - | |
| 99 | - return success; | |
| 100 | - } | |
| 101 | - | |
| 102 | - /** | |
| 103 | - * @Description : TOOD(将本地文件上传到FTP服务器上) | |
| 104 | - * | |
| 105 | - * @param file | |
| 106 | - * | |
| 107 | - * @param name | |
| 108 | - * | |
| 109 | - * @param url | |
| 110 | - * | |
| 111 | - * @param port | |
| 112 | - * | |
| 113 | - * @param username | |
| 114 | - * | |
| 115 | - * @param password | |
| 116 | - * | |
| 117 | - * @param remotePath | |
| 118 | - * | |
| 119 | - */ | |
| 120 | - public void FTPUpLoadFromDisk(File file,String name,String url, int port, String username, String password, String remotePath){ | |
| 121 | - | |
| 122 | - try { | |
| 123 | - FileInputStream in=new FileInputStream(file); | |
| 124 | - | |
| 125 | - boolean flag = uploadFile(url, port,username, password, remotePath, name, in); | |
| 126 | - | |
| 127 | - /* boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", name, in);*/ | |
| 128 | - | |
| 129 | - /* boolean flag = uploadFile("222.66.0.205", 21, "transport", "transport123", "ftptest/", name, in);*/ | |
| 130 | - | |
| 131 | - } catch (FileNotFoundException e) { | |
| 132 | - | |
| 133 | - e.printStackTrace(); | |
| 134 | - | |
| 135 | - } | |
| 136 | - | |
| 137 | - } | |
| 138 | - | |
| 139 | - // 在FTP服务器上生成一个文件,并将一个字符串写入到该文件中 | |
| 140 | - public void testUpLoadFromString(){ | |
| 141 | - | |
| 142 | - try { | |
| 143 | - | |
| 144 | - String str = "test ftp "+ "\r\n"+ "ccccc dddd"; | |
| 145 | - | |
| 146 | - InputStream input = new ByteArrayInputStream(str.getBytes("utf-8")); | |
| 147 | - | |
| 148 | - uploadFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", "test.txt", input); | |
| 149 | - | |
| 150 | - } catch (UnsupportedEncodingException e) { | |
| 151 | - | |
| 152 | - e.printStackTrace(); | |
| 153 | - | |
| 154 | - } | |
| 155 | - | |
| 156 | - } | |
| 157 | - | |
| 158 | - /** | |
| 159 | - * @Description (删除FTP上的文件) | |
| 160 | - * | |
| 161 | - * @param url FTP服务器IP地址 | |
| 162 | - * | |
| 163 | - * @param port FTP服务器端口 | |
| 164 | - * | |
| 165 | - * @param username FTP服务器登录名 | |
| 166 | - * | |
| 167 | - * @param password FTP服务器密码 | |
| 168 | - * | |
| 169 | - * @param remotePath 远程文件路径 | |
| 170 | - * | |
| 171 | - * @param fileName 待删除的文件名 | |
| 172 | - * | |
| 173 | - * @return boolean | |
| 174 | - */ | |
| 175 | - public static boolean deleteFtpFile(String url, int port, String username, String password, String remotePath, String fileName){ | |
| 176 | - | |
| 177 | - boolean success = false; | |
| 178 | - | |
| 179 | - FTPClient ftp = new FTPClient(); | |
| 180 | - | |
| 181 | - try { | |
| 182 | - | |
| 183 | - int reply; | |
| 184 | - | |
| 185 | - // 连接FTP服务器 | |
| 186 | - if (port > -1) | |
| 187 | - | |
| 188 | - ftp.connect(url, port); | |
| 189 | - | |
| 190 | - else | |
| 191 | - | |
| 192 | - ftp.connect(url); | |
| 193 | - | |
| 194 | - // 登录 | |
| 195 | - ftp.login(username, password); | |
| 196 | - | |
| 197 | - reply = ftp.getReplyCode(); | |
| 198 | - | |
| 199 | - if (!FTPReply.isPositiveCompletion(reply)) { | |
| 200 | - | |
| 201 | - ftp.disconnect(); | |
| 202 | - | |
| 203 | - return success; | |
| 204 | - } | |
| 205 | - | |
| 206 | - // 转移到FTP服务器目录 | |
| 207 | - | |
| 208 | - ftp.changeWorkingDirectory(remotePath); | |
| 209 | - | |
| 210 | - /*success = ftp.deleteFile(fileName);*/ | |
| 211 | - | |
| 212 | - success = ftp.deleteFile(new String(fileName.getBytes("gbk"),"gbk")); | |
| 213 | - | |
| 214 | - ftp.logout(); | |
| 215 | - | |
| 216 | - } catch (IOException e){ | |
| 217 | - | |
| 218 | - e.printStackTrace(); | |
| 219 | - | |
| 220 | - success = false; | |
| 221 | - | |
| 222 | - } finally { | |
| 223 | - | |
| 224 | - if (ftp.isConnected()) { | |
| 225 | - | |
| 226 | - try { | |
| 227 | - | |
| 228 | - ftp.disconnect(); | |
| 229 | - | |
| 230 | - } catch (IOException e) { | |
| 231 | - | |
| 232 | - e.printStackTrace(); | |
| 233 | - | |
| 234 | - } | |
| 235 | - } | |
| 236 | - } | |
| 237 | - | |
| 238 | - return success; | |
| 239 | - } | |
| 240 | - | |
| 241 | - public static File GetFtpFile(String url, int port, String username, String password, String remotePath, String fileName){ | |
| 242 | - | |
| 243 | - FTPClient ftp = new FTPClient(); | |
| 244 | - | |
| 245 | - /*File destFile = new File(fileName); */ | |
| 246 | - | |
| 247 | - File destFile = new File(fileName); | |
| 248 | - | |
| 249 | - InputStream in = null; | |
| 250 | - | |
| 251 | - OutputStream out = null; | |
| 252 | - | |
| 253 | - try { | |
| 254 | - | |
| 255 | - int reply; | |
| 256 | - | |
| 257 | - // 连接FTP服务器 | |
| 258 | - if (port > -1) | |
| 259 | - | |
| 260 | - ftp.connect(url, port); | |
| 261 | - | |
| 262 | - else | |
| 263 | - | |
| 264 | - ftp.connect(url); | |
| 265 | - | |
| 266 | - // 登录 | |
| 267 | - ftp.login(username, password); | |
| 268 | - | |
| 269 | - reply = ftp.getReplyCode(); | |
| 270 | - | |
| 271 | - if (!FTPReply.isPositiveCompletion(reply)) { | |
| 272 | - | |
| 273 | - ftp.disconnect(); | |
| 274 | - | |
| 275 | - } | |
| 276 | - | |
| 277 | - // 转移到FTP服务器目录 | |
| 278 | - | |
| 279 | - ftp.changeWorkingDirectory(remotePath); | |
| 280 | - | |
| 281 | - ftp.enterLocalPassiveMode(); | |
| 282 | - | |
| 283 | - FTPFile[] fs = ftp.listFiles(); | |
| 284 | - | |
| 285 | - System.out.println(fs.length); | |
| 286 | - | |
| 287 | - /* for (FTPFile ff : fs) { | |
| 288 | - //解决中文乱码问题,两次解码 | |
| 289 | - byte[] bytes=ff.getName().getBytes("gbk"); | |
| 290 | - String fn=new String(bytes,"gbk"); | |
| 291 | - if (fn.equals(fileName)) { | |
| 292 | - //6.写操作,将其写入到本地文件中 | |
| 293 | - File localFile = new File(ff.getName()); | |
| 294 | - | |
| 295 | - | |
| 296 | - OutputStream is = new FileOutputStream(localFile); | |
| 297 | - ftp.retrieveFile(ff.getName(), is); | |
| 298 | - is.close(); | |
| 299 | - } | |
| 300 | - } */ | |
| 301 | - | |
| 302 | - /* File srcFile = new File(fileName); */ | |
| 303 | - | |
| 304 | - /* File srcFile = new File(new String(fileName.getBytes("gbk"),"gbk"));*/ | |
| 305 | - | |
| 306 | - int byteread = 0; // 读取的字节数 | |
| 307 | - | |
| 308 | - /* in = ftp.retrieveFileStream(remotePath + fileName);*/ | |
| 309 | - | |
| 310 | - in = ftp.retrieveFileStream(new String(fileName.getBytes("gbk"),"gbk")); | |
| 311 | - | |
| 312 | - | |
| 313 | - out = new FileOutputStream(destFile); | |
| 314 | - | |
| 315 | - byte[] buffer = new byte[1024]; | |
| 316 | - | |
| 317 | - while ((byteread = in.read(buffer)) != -1) { | |
| 318 | - | |
| 319 | - out.write(buffer, 0, byteread); | |
| 320 | - | |
| 321 | - } | |
| 322 | - | |
| 323 | - out.flush(); | |
| 324 | - ftp.logout(); | |
| 325 | - | |
| 326 | - } catch (IOException e){ | |
| 327 | - | |
| 328 | - e.printStackTrace(); | |
| 329 | - | |
| 330 | - } finally { | |
| 331 | - | |
| 332 | - try { | |
| 333 | - | |
| 334 | - if (out != null) | |
| 335 | - | |
| 336 | - out.close(); | |
| 337 | - | |
| 338 | - if (in != null) | |
| 339 | - | |
| 340 | - in.close(); | |
| 341 | - | |
| 342 | - } catch (IOException e) { | |
| 343 | - | |
| 344 | - e.printStackTrace(); | |
| 345 | - | |
| 346 | - } | |
| 347 | - | |
| 348 | - if (ftp.isConnected()) { | |
| 349 | - | |
| 350 | - try { | |
| 351 | - | |
| 352 | - ftp.disconnect(); | |
| 353 | - | |
| 354 | - } catch (IOException e) { | |
| 355 | - | |
| 356 | - e.printStackTrace(); | |
| 357 | - | |
| 358 | - } | |
| 359 | - } | |
| 360 | - } | |
| 361 | - | |
| 362 | - return destFile; | |
| 363 | - } | |
| 364 | - | |
| 365 | - | |
| 366 | - public static void main(String[] args) { | |
| 367 | - | |
| 368 | - FTPClientUtils clientUtils = new FTPClientUtils(); | |
| 369 | - | |
| 370 | - Test test= new Test(); | |
| 371 | - | |
| 372 | - File[] sources = new File[] {new File("E:/20079.txt")}; | |
| 373 | - | |
| 374 | - File target = new File("release_package.tar.gz"); | |
| 375 | - | |
| 376 | - File targetFile = test.pack(sources, target); | |
| 377 | - | |
| 378 | - /* clientUtils.testUpLoadFromDisk(targetFile,targetFile.getName());*/ | |
| 379 | - | |
| 380 | - | |
| 381 | - /** 删除文件 */ | |
| 382 | - /*boolean a =clientUtils.deleteFtpFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", "release_package.tar.gz");*/ | |
| 383 | - | |
| 384 | - } | |
| 385 | -} | |
| 1 | +package com.bsth.util; | |
| 2 | + | |
| 3 | +import java.io.ByteArrayInputStream; | |
| 4 | +import java.io.File; | |
| 5 | +import java.io.FileInputStream; | |
| 6 | +import java.io.FileNotFoundException; | |
| 7 | +import java.io.FileOutputStream; | |
| 8 | +import java.io.IOException; | |
| 9 | +import java.io.InputStream; | |
| 10 | +import java.io.OutputStream; | |
| 11 | +import java.io.UnsupportedEncodingException; | |
| 12 | + | |
| 13 | +import org.apache.commons.net.ftp.FTPClient; | |
| 14 | +import org.apache.commons.net.ftp.FTPFile; | |
| 15 | +import org.apache.commons.net.ftp.FTPReply; | |
| 16 | +/** | |
| 17 | + * @Description: 向FTP服务器上传文件 | |
| 18 | + * | |
| 19 | + * @Version 1.0 2016-06-21 4:31:09 by 李强 | |
| 20 | + * | |
| 21 | + */ | |
| 22 | +public class FTPClientUtils { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * @param url FTP服务器hostname; | |
| 26 | + * | |
| 27 | + * - - - - port FTP服务器端口; | |
| 28 | + * | |
| 29 | + * - - - - username FTP登录账号; | |
| 30 | + * | |
| 31 | + * - - - - password FTP登录密码 ; | |
| 32 | + * | |
| 33 | + * - - - - path FTP服务器保存目录; | |
| 34 | + * | |
| 35 | + * - - - - filename 上传到FTP服务器上的文件名 | |
| 36 | + * | |
| 37 | + * - - - - input 输入流; | |
| 38 | + * | |
| 39 | + * @return 成功返回true,否则返回false | |
| 40 | + * | |
| 41 | + */ | |
| 42 | + public boolean uploadFile(String url,int port,String username, String password, String path, String filename, InputStream input) { | |
| 43 | + | |
| 44 | + boolean success = false; | |
| 45 | + | |
| 46 | + FTPClient ftp = new FTPClient(); | |
| 47 | + | |
| 48 | + try { | |
| 49 | + | |
| 50 | + int reply; | |
| 51 | + | |
| 52 | + //连接FTP服务器,如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器 | |
| 53 | + ftp.connect(url, port); | |
| 54 | + | |
| 55 | + //登录 | |
| 56 | + ftp.login(username, password); | |
| 57 | + | |
| 58 | + reply = ftp.getReplyCode(); | |
| 59 | + | |
| 60 | + if (!FTPReply.isPositiveCompletion(reply)) { | |
| 61 | + | |
| 62 | + ftp.disconnect(); | |
| 63 | + | |
| 64 | + return success; | |
| 65 | + | |
| 66 | + } | |
| 67 | + | |
| 68 | + ftp.changeWorkingDirectory(path); | |
| 69 | + ftp.setFileType(FTPClient.BINARY_FILE_TYPE); | |
| 70 | + ftp.enterLocalPassiveMode(); | |
| 71 | + success = ftp.storeFile(new String(filename.getBytes("gbk"),"gbk"), input); | |
| 72 | + /*success = ftp.storeFile(filename, input); */ | |
| 73 | + input.close(); | |
| 74 | + | |
| 75 | + ftp.logout(); | |
| 76 | + | |
| 77 | + // success = true; | |
| 78 | + | |
| 79 | + } catch (IOException e) { | |
| 80 | + | |
| 81 | + e.printStackTrace(); | |
| 82 | + | |
| 83 | + } finally { | |
| 84 | + | |
| 85 | + if (ftp.isConnected()) { | |
| 86 | + | |
| 87 | + try { | |
| 88 | + | |
| 89 | + ftp.disconnect(); | |
| 90 | + | |
| 91 | + } catch (IOException ioe) { | |
| 92 | + | |
| 93 | + } | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + } | |
| 98 | + | |
| 99 | + return success; | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * @Description : TOOD(将本地文件上传到FTP服务器上) | |
| 104 | + * | |
| 105 | + * @param file | |
| 106 | + * | |
| 107 | + * @param name | |
| 108 | + * | |
| 109 | + * @param url | |
| 110 | + * | |
| 111 | + * @param port | |
| 112 | + * | |
| 113 | + * @param username | |
| 114 | + * | |
| 115 | + * @param password | |
| 116 | + * | |
| 117 | + * @param remotePath | |
| 118 | + * | |
| 119 | + */ | |
| 120 | + public void FTPUpLoadFromDisk(File file,String name,String url, int port, String username, String password, String remotePath){ | |
| 121 | + | |
| 122 | + try { | |
| 123 | + FileInputStream in=new FileInputStream(file); | |
| 124 | + | |
| 125 | + boolean flag = uploadFile(url, port,username, password, remotePath, name, in); | |
| 126 | + | |
| 127 | + /* boolean flag = uploadFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", name, in);*/ | |
| 128 | + | |
| 129 | + /* boolean flag = uploadFile("222.66.0.205", 21, "transport", "transport123", "ftptest/", name, in);*/ | |
| 130 | + | |
| 131 | + } catch (FileNotFoundException e) { | |
| 132 | + | |
| 133 | + e.printStackTrace(); | |
| 134 | + | |
| 135 | + } | |
| 136 | + | |
| 137 | + } | |
| 138 | + | |
| 139 | + // 在FTP服务器上生成一个文件,并将一个字符串写入到该文件中 | |
| 140 | + public void testUpLoadFromString(){ | |
| 141 | + | |
| 142 | + try { | |
| 143 | + | |
| 144 | + String str = "test ftp "+ "\r\n"+ "ccccc dddd"; | |
| 145 | + | |
| 146 | + InputStream input = new ByteArrayInputStream(str.getBytes("utf-8")); | |
| 147 | + | |
| 148 | + uploadFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", "test.txt", input); | |
| 149 | + | |
| 150 | + } catch (UnsupportedEncodingException e) { | |
| 151 | + | |
| 152 | + e.printStackTrace(); | |
| 153 | + | |
| 154 | + } | |
| 155 | + | |
| 156 | + } | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * @Description (删除FTP上的文件) | |
| 160 | + * | |
| 161 | + * @param url FTP服务器IP地址 | |
| 162 | + * | |
| 163 | + * @param port FTP服务器端口 | |
| 164 | + * | |
| 165 | + * @param username FTP服务器登录名 | |
| 166 | + * | |
| 167 | + * @param password FTP服务器密码 | |
| 168 | + * | |
| 169 | + * @param remotePath 远程文件路径 | |
| 170 | + * | |
| 171 | + * @param fileName 待删除的文件名 | |
| 172 | + * | |
| 173 | + * @return boolean | |
| 174 | + */ | |
| 175 | + public static boolean deleteFtpFile(String url, int port, String username, String password, String remotePath, String fileName){ | |
| 176 | + | |
| 177 | + boolean success = false; | |
| 178 | + | |
| 179 | + FTPClient ftp = new FTPClient(); | |
| 180 | + | |
| 181 | + try { | |
| 182 | + | |
| 183 | + int reply; | |
| 184 | + | |
| 185 | + // 连接FTP服务器 | |
| 186 | + if (port > -1) | |
| 187 | + | |
| 188 | + ftp.connect(url, port); | |
| 189 | + | |
| 190 | + else | |
| 191 | + | |
| 192 | + ftp.connect(url); | |
| 193 | + | |
| 194 | + // 登录 | |
| 195 | + ftp.login(username, password); | |
| 196 | + | |
| 197 | + reply = ftp.getReplyCode(); | |
| 198 | + | |
| 199 | + if (!FTPReply.isPositiveCompletion(reply)) { | |
| 200 | + | |
| 201 | + ftp.disconnect(); | |
| 202 | + | |
| 203 | + return success; | |
| 204 | + } | |
| 205 | + | |
| 206 | + // 转移到FTP服务器目录 | |
| 207 | + | |
| 208 | + ftp.changeWorkingDirectory(remotePath); | |
| 209 | + | |
| 210 | + /*success = ftp.deleteFile(fileName);*/ | |
| 211 | + | |
| 212 | + success = ftp.deleteFile(new String(fileName.getBytes("gbk"),"gbk")); | |
| 213 | + | |
| 214 | + ftp.logout(); | |
| 215 | + | |
| 216 | + } catch (IOException e){ | |
| 217 | + | |
| 218 | + e.printStackTrace(); | |
| 219 | + | |
| 220 | + success = false; | |
| 221 | + | |
| 222 | + } finally { | |
| 223 | + | |
| 224 | + if (ftp.isConnected()) { | |
| 225 | + | |
| 226 | + try { | |
| 227 | + | |
| 228 | + ftp.disconnect(); | |
| 229 | + | |
| 230 | + } catch (IOException e) { | |
| 231 | + | |
| 232 | + e.printStackTrace(); | |
| 233 | + | |
| 234 | + } | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 238 | + return success; | |
| 239 | + } | |
| 240 | + | |
| 241 | + public static File GetFtpFile(String url, int port, String username, String password, String remotePath, String fileName){ | |
| 242 | + | |
| 243 | + FTPClient ftp = new FTPClient(); | |
| 244 | + | |
| 245 | + /*File destFile = new File(fileName); */ | |
| 246 | + | |
| 247 | + File destFile = new File(fileName); | |
| 248 | + | |
| 249 | + InputStream in = null; | |
| 250 | + | |
| 251 | + OutputStream out = null; | |
| 252 | + | |
| 253 | + try { | |
| 254 | + | |
| 255 | + int reply; | |
| 256 | + | |
| 257 | + // 连接FTP服务器 | |
| 258 | + if (port > -1) | |
| 259 | + | |
| 260 | + ftp.connect(url, port); | |
| 261 | + | |
| 262 | + else | |
| 263 | + | |
| 264 | + ftp.connect(url); | |
| 265 | + | |
| 266 | + // 登录 | |
| 267 | + ftp.login(username, password); | |
| 268 | + | |
| 269 | + reply = ftp.getReplyCode(); | |
| 270 | + | |
| 271 | + if (!FTPReply.isPositiveCompletion(reply)) { | |
| 272 | + | |
| 273 | + ftp.disconnect(); | |
| 274 | + | |
| 275 | + } | |
| 276 | + | |
| 277 | + // 转移到FTP服务器目录 | |
| 278 | + | |
| 279 | + ftp.changeWorkingDirectory(remotePath); | |
| 280 | + | |
| 281 | + ftp.enterLocalPassiveMode(); | |
| 282 | + | |
| 283 | + FTPFile[] fs = ftp.listFiles(); | |
| 284 | + | |
| 285 | + System.out.println(fs.length); | |
| 286 | + | |
| 287 | + /* for (FTPFile ff : fs) { | |
| 288 | + //解决中文乱码问题,两次解码 | |
| 289 | + byte[] bytes=ff.getName().getBytes("gbk"); | |
| 290 | + String fn=new String(bytes,"gbk"); | |
| 291 | + if (fn.equals(fileName)) { | |
| 292 | + //6.写操作,将其写入到本地文件中 | |
| 293 | + File localFile = new File(ff.getName()); | |
| 294 | + | |
| 295 | + | |
| 296 | + OutputStream is = new FileOutputStream(localFile); | |
| 297 | + ftp.retrieveFile(ff.getName(), is); | |
| 298 | + is.close(); | |
| 299 | + } | |
| 300 | + } */ | |
| 301 | + | |
| 302 | + /* File srcFile = new File(fileName); */ | |
| 303 | + | |
| 304 | + /* File srcFile = new File(new String(fileName.getBytes("gbk"),"gbk"));*/ | |
| 305 | + | |
| 306 | + int byteread = 0; // 读取的字节数 | |
| 307 | + | |
| 308 | + /* in = ftp.retrieveFileStream(remotePath + fileName);*/ | |
| 309 | + | |
| 310 | + in = ftp.retrieveFileStream(new String(fileName.getBytes("gbk"),"gbk")); | |
| 311 | + | |
| 312 | + | |
| 313 | + out = new FileOutputStream(destFile); | |
| 314 | + | |
| 315 | + byte[] buffer = new byte[1024]; | |
| 316 | + | |
| 317 | + while ((byteread = in.read(buffer)) != -1) { | |
| 318 | + | |
| 319 | + out.write(buffer, 0, byteread); | |
| 320 | + | |
| 321 | + } | |
| 322 | + | |
| 323 | + out.flush(); | |
| 324 | + ftp.logout(); | |
| 325 | + | |
| 326 | + } catch (IOException e){ | |
| 327 | + | |
| 328 | + e.printStackTrace(); | |
| 329 | + | |
| 330 | + } finally { | |
| 331 | + | |
| 332 | + try { | |
| 333 | + | |
| 334 | + if (out != null) | |
| 335 | + | |
| 336 | + out.close(); | |
| 337 | + | |
| 338 | + if (in != null) | |
| 339 | + | |
| 340 | + in.close(); | |
| 341 | + | |
| 342 | + } catch (IOException e) { | |
| 343 | + | |
| 344 | + e.printStackTrace(); | |
| 345 | + | |
| 346 | + } | |
| 347 | + | |
| 348 | + if (ftp.isConnected()) { | |
| 349 | + | |
| 350 | + try { | |
| 351 | + | |
| 352 | + ftp.disconnect(); | |
| 353 | + | |
| 354 | + } catch (IOException e) { | |
| 355 | + | |
| 356 | + e.printStackTrace(); | |
| 357 | + | |
| 358 | + } | |
| 359 | + } | |
| 360 | + } | |
| 361 | + | |
| 362 | + return destFile; | |
| 363 | + } | |
| 364 | + | |
| 365 | + public static boolean deleteFileByPrefix(String prefix, String url, int port, String username, String password, String remotePath) { | |
| 366 | + boolean flag = false; | |
| 367 | + FTPClient ftp = new FTPClient(); | |
| 368 | + try { | |
| 369 | + int reply; | |
| 370 | + if (port > -1) { | |
| 371 | + ftp.connect(url, port); | |
| 372 | + } else { | |
| 373 | + ftp.connect(url); | |
| 374 | + } | |
| 375 | + ftp.login(username, password); | |
| 376 | + reply = ftp.getReplyCode(); | |
| 377 | + if (!FTPReply.isPositiveCompletion(reply)) { | |
| 378 | + ftp.disconnect(); | |
| 379 | + return flag; | |
| 380 | + } | |
| 381 | + ftp.enterLocalPassiveMode(); | |
| 382 | + ftp.changeWorkingDirectory(remotePath); | |
| 383 | + for (FTPFile file : ftp.listFiles()) { | |
| 384 | + if (file.getName().startsWith(prefix)) { | |
| 385 | + ftp.deleteFile(file.getName()); | |
| 386 | + } | |
| 387 | + } | |
| 388 | + ftp.logout(); | |
| 389 | + } catch (IOException e){ | |
| 390 | + e.printStackTrace(); | |
| 391 | + } finally { | |
| 392 | + if (ftp.isConnected()) { | |
| 393 | + try { | |
| 394 | + ftp.disconnect(); | |
| 395 | + } catch (IOException e) { | |
| 396 | + e.printStackTrace(); | |
| 397 | + } | |
| 398 | + } | |
| 399 | + } | |
| 400 | + | |
| 401 | + return flag; | |
| 402 | + } | |
| 403 | + | |
| 404 | + | |
| 405 | + public static void main(String[] args) { | |
| 406 | + | |
| 407 | + FTPClientUtils clientUtils = new FTPClientUtils(); | |
| 408 | + | |
| 409 | + Test test= new Test(); | |
| 410 | + | |
| 411 | + File[] sources = new File[] {new File("E:/20079.txt")}; | |
| 412 | + | |
| 413 | + File target = new File("release_package.tar.gz"); | |
| 414 | + | |
| 415 | + File targetFile = test.pack(sources, target); | |
| 416 | + | |
| 417 | + /* clientUtils.testUpLoadFromDisk(targetFile,targetFile.getName());*/ | |
| 418 | + | |
| 419 | + | |
| 420 | + /** 删除文件 */ | |
| 421 | + /*boolean a =clientUtils.deleteFtpFile("192.168.168.101", 21, "testftpservice", "123", "ftptest/", "release_package.tar.gz");*/ | |
| 422 | + | |
| 423 | + } | |
| 424 | +} | ... | ... |
src/main/java/com/bsth/util/IFlyUtils.java
| ... | ... | @@ -31,65 +31,36 @@ public class IFlyUtils { |
| 31 | 31 | |
| 32 | 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 { | |
| 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"); | |
| 40 | + } | |
| 41 | + | |
| 42 | + public static void textToSpeech(String text, String language, String outputPath) throws Exception { | |
| 40 | 43 | File file = new File(outputPath); |
| 41 | 44 | if (!file.getParentFile().exists()) { |
| 42 | 45 | file.getParentFile().mkdirs(); |
| 43 | 46 | } |
| 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); | |
| 47 | + String vcn = language2vcn.get(language); | |
| 48 | + if (vcn == null) { | |
| 49 | + throw new IllegalArgumentException("Language is not supported: " + language); | |
| 55 | 50 | } |
| 56 | - } | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * 生成上海话语音 | |
| 60 | - * text以","进行分割 | |
| 61 | - * @param text | |
| 62 | - */ | |
| 63 | - public static void textToSpeechSh(String text, String outputPath) throws Exception { | |
| 64 | 51 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); |
| 65 | 52 | SpeechRequest request = new SpeechRequest(); |
| 66 | 53 | request.getCommon().put("app_id", appId); |
| 67 | 54 | request.getBusiness().put("aue", "lame"); |
| 68 | 55 | request.getBusiness().put("sfl", 1); |
| 69 | - request.getBusiness().put("vcn", "x3_ziling"); | |
| 70 | - request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes("GBK"))); | |
| 71 | - request.getData().put("status", 2); | |
| 72 | - websocketWork(wsUrl, request, new FileOutputStream(outputPath)); | |
| 73 | - while (!request.isCompleted()) { | |
| 74 | - Thread.sleep(500); | |
| 56 | + request.getBusiness().put("vcn", vcn); | |
| 57 | + String charset = "GBK"; | |
| 58 | + if (language.equals("en")) { | |
| 59 | + charset = "UTF-8"; | |
| 75 | 60 | } |
| 76 | - } | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * 生成英语语音 | |
| 80 | - * text以","进行分割 | |
| 81 | - * @param text | |
| 82 | - */ | |
| 83 | - public static void textToSpeechEn(String text, String outputPath) throws Exception { | |
| 84 | - String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); | |
| 85 | - SpeechRequest request = new SpeechRequest(); | |
| 86 | - request.getCommon().put("app_id", appId); | |
| 87 | - request.getBusiness().put("aue", "lame"); | |
| 88 | - request.getBusiness().put("sfl", 1); | |
| 89 | - request.getBusiness().put("vcn", "x4_enus_luna_assist"); | |
| 90 | - request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes(StandardCharsets.UTF_8))); | |
| 61 | + request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes(charset))); | |
| 91 | 62 | request.getData().put("status", 2); |
| 92 | - websocketWork(wsUrl, request, new FileOutputStream(outputPath)); | |
| 63 | + websocketWork(wsUrl, request, new FileOutputStream(file)); | |
| 93 | 64 | while (!request.isCompleted()) { |
| 94 | 65 | Thread.sleep(500); |
| 95 | 66 | } | ... | ... |
src/main/resources/application-dev.properties
| 1 | 1 | server.port=9088 |
| 2 | 2 | |
| 3 | -# dubbo服务化使用开关flag | |
| 3 | +# dubbo����ʹ�ÿ���flag | |
| 4 | 4 | dubbo.use=false |
| 5 | 5 | |
| 6 | 6 | #JPA |
| ... | ... | @@ -9,21 +9,14 @@ spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.Im |
| 9 | 9 | spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy |
| 10 | 10 | spring.jpa.database= MYSQL |
| 11 | 11 | spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true |
| 12 | -spring.jpa.show-sql= true | |
| 12 | +spring.jpa.show-sql= false | |
| 13 | 13 | spring.jpa.properties.hibernate.dialect= org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect |
| 14 | 14 | |
| 15 | 15 | #DATABASE |
| 16 | 16 | spring.datasource.driver-class-name= com.mysql.jdbc.Driver |
| 17 | -#spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 18 | -##spring.datasource.url= jdbc:mysql://192.168.168.222/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 19 | -#spring.datasource.username= root | |
| 20 | -#spring.datasource.password= | |
| 21 | -spring.datasource.url= jdbc:mysql://127.0.0.1/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 17 | +spring.datasource.url= jdbc:mysql://192.168.168.152/control_lg?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 22 | 18 | spring.datasource.username= root |
| 23 | -spring.datasource.password= root | |
| 24 | -#spring.datasource.url= jdbc:mysql://192.168.168.241/control?useUnicode=true&characterEncoding=utf-8&useSSL=false | |
| 25 | -#spring.datasource.username= root | |
| 26 | -#spring.datasource.password= root2jsp | |
| 19 | +spring.datasource.password= root2jsp | |
| 27 | 20 | spring.datasource.type= com.zaxxer.hikari.HikariDataSource |
| 28 | 21 | |
| 29 | 22 | #DATASOURCE SETTING |
| ... | ... | @@ -39,17 +32,17 @@ spring.datasource.hikari.validation-timeout= 3000 |
| 39 | 32 | spring.datasource.hikari.register-mbeans=true |
| 40 | 33 | |
| 41 | 34 | kafka.use= false |
| 42 | -spring.kafka.consumer.bootstrap-servers= localhost:9092 | |
| 43 | -spring.kafka.consumer.group-id= schedule-system | |
| 35 | +spring.kafka.consumer.bootstrap-servers= 192.170.100.114:9092,192.170.100.114:9093,192.170.100.114:9094 | |
| 36 | +spring.kafka.consumer.group-id= schedule-system-test | |
| 44 | 37 | spring.kafka.consumer.auto-offset-reset= latest |
| 45 | 38 | spring.kafka.consumer.key-deserializer= org.apache.kafka.common.serialization.StringDeserializer |
| 46 | 39 | spring.kafka.consumer.value-deserializer= org.apache.kafka.common.serialization.StringDeserializer |
| 47 | 40 | |
| 48 | 41 | sso.enabled= false |
| 49 | -sso.systemcode = SYS0019 | |
| 50 | -sso.http.url.login= http://180.169.154.251:28090/portal/index.html#/login | |
| 51 | -sso.http.url.logout= http://180.169.154.251:18080/information/api/v1/logout | |
| 52 | -sso.http.url.auth= http://180.169.154.251:18080/information/authenticate/authorityAuthentication | |
| 42 | +sso.systemcode = SYS0023 | |
| 43 | +sso.http.url.login= https://112.64.45.51/portal/index.html#/login | |
| 44 | +sso.http.url.logout= https://112.64.45.51/information/api/v1/logout | |
| 45 | +sso.http.url.auth= https://112.64.45.51/information/authenticate/authorityAuthentication | |
| 53 | 46 | |
| 54 | -path.speech.common = /data/control/speech/common/ | |
| 55 | -path.speech.line = /data/control/speech/%s/ | |
| 56 | 47 | \ No newline at end of file |
| 48 | +path.speech.common = D:/speech/common/ | |
| 49 | +path.speech.line = D:/speech/%s/ | |
| 57 | 50 | \ 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 | 219 | module.exports = realCtl; |
| 208 | 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 | 63 | module.exports = minifier; |
| 41 | 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.4", | |
| 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
| 1 | -<!DOCTYPE html> | |
| 2 | -<html> | |
| 3 | -<head> | |
| 4 | -<meta charset="UTF-8"> | |
| 5 | -<title>GPS点测试</title> | |
| 6 | -<meta name=”renderer” content=”webkit”> | |
| 7 | -<meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″> | |
| 8 | - | |
| 9 | -<meta http-equiv="Pragma" content="no-cache"> | |
| 10 | -<meta http-equiv="Cache-control" content="no-cache"> | |
| 11 | -<meta http-equiv="Cache" content="no-cache"> | |
| 12 | -<head> | |
| 13 | -<!-- select2 下拉框插件 --> | |
| 14 | -<link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | |
| 15 | - rel="stylesheet" type="text/css" /> | |
| 16 | -<style type="text/css"> | |
| 17 | -html,body { | |
| 18 | - height: 100%; | |
| 19 | - overflow: hidden; | |
| 20 | -} | |
| 21 | - | |
| 22 | -#mapContainer { | |
| 23 | - width: 100%; | |
| 24 | - height: calc(100% - 93px); | |
| 25 | -} | |
| 26 | - | |
| 27 | -form { | |
| 28 | - padding: 25px; | |
| 29 | -} | |
| 30 | - | |
| 31 | -form .item { | |
| 32 | - display: inline-block; | |
| 33 | -} | |
| 34 | - | |
| 35 | -form .item input { | |
| 36 | - height: 26px; | |
| 37 | - width: 110px; | |
| 38 | -} | |
| 39 | - | |
| 40 | -form .item select { | |
| 41 | - height: 32px; | |
| 42 | -} | |
| 43 | -</style> | |
| 44 | -</head> | |
| 45 | -<body> | |
| 46 | - <form action=""> | |
| 47 | - <div class="item"> | |
| 48 | - 线路: <select name="xl" style="width: 150px;"> | |
| 49 | - </select> | |
| 50 | - </div> | |
| 51 | - <div class="item"> | |
| 52 | - 方向: <select name="directions" style="width: 70px;"> | |
| 53 | - <option value="0">上行</option> | |
| 54 | - <option value="1">下行</option> | |
| 55 | - </select> | |
| 56 | - </div> | |
| 57 | - <div class="item"> | |
| 58 | - 设备号: <input name="device" value="059L0903" /> | |
| 59 | - </div> | |
| 60 | - <div class="item"> | |
| 61 | - 开始时间戳: <input type="number" name="startTime" value="1461380940000" /> | |
| 62 | - </div> | |
| 63 | - <div class="item"> | |
| 64 | - 结束时间戳: <input type="number" name="endTime" value="1461381960000" /> | |
| 65 | - </div> | |
| 66 | - <div class="item"> | |
| 67 | - <input type="button" value="查询GPS轨迹" onclick="searchGps()"> | |
| 68 | - </div> | |
| 69 | - <div class="item"> | |
| 70 | - <input type="button" value="开启测距" onclick="myDis.open();" | |
| 71 | - style="width: 75px" /> <input type="button" value="关闭测距" | |
| 72 | - onclick="myDis.close()" style="width: 75px" /> | |
| 73 | - | |
| 74 | - </div> | |
| 75 | - | |
| 76 | - <div class="item"> | |
| 77 | - <a target="_blank" href="http://tool.chinaz.com/Tools/unixtime.aspx" | |
| 78 | - style="font-size: 12px; color: red;">毫秒时间戳转换</a> | |
| 79 | - </div> | |
| 80 | - </form> | |
| 81 | - | |
| 82 | - <div id="mapContainer"></div> | |
| 83 | - <script src="/assets/plugins/pinyin.js"></script> | |
| 84 | - <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | |
| 85 | - <script src="/assets/plugins/jquery.serializejson.js"></script> | |
| 86 | - <script | |
| 87 | - src="//api.map.baidu.com/api?v=2.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> | |
| 88 | - <script type="text/javascript" | |
| 89 | - src="//api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> | |
| 90 | - <!-- moment.js 日期处理类库 --> | |
| 91 | - <script src="/assets/plugins/moment-with-locales.js"></script> | |
| 92 | - <!-- select2 下拉框 --> | |
| 93 | - <script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | |
| 94 | - <script> | |
| 95 | - | |
| 96 | - var inMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA1CAYAAABSrotqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAGW0lEQVRYw62XX2wc1RWHv3vv7NhrQkKCIa0poaKRmjdUFUGr+IH+ITy0Kg/0qVRV1ZamVV95al94oPSBVmoRUZTIKRFBLW1aapBK6gIChYTgFJRQHoITqCCO7eC1vY7t2Z1/954+zK69Xs9mx4mPdLWjmTvnO79z7zl3VlHAvv3XmXuM8R4EBpVSu1DqpiQRBJlH5APn5KQ4NzzycP/pbr7U1R5+6y+Vr2njP6EVX1FKoRTZAOJUQMBlP4gIIrwtNvnlyMO3vL4u4AND49vMjZsOaqMfUgpMA+ZEiBJIrJAkQslT+B4YrXACzknj1x4N6rWfnfrJ7XNdgd888NEOs+XmEaPVLq0zRVEiRGnmsGlJsnKtFfT4ih5PIQJWwDr3QRJUHzix9wsXOwLvOzDW72269ZQxeqcxIAL1WLAtoDzgMlgr+vwsG6kTrOXDoDL91Xcf/eLM8pxWuJT7j4hSO5UC66AW5cM6mXNCEDmsA60UAjv9rf1HWoU1L9Tg0OT3dU/5Wd9TeFpRiwWRFZhNhSvTMbX5hDh0uNhR6jWUb/LYvL0H460kSyko+xrrhCgVJAp/MPrzgecAMVkuH/PuuHv335VSW3s8TZgIrgUWzKdMXagRLqU4KygF4gRnhSiwLFZivF6N32tWAhTwPUWSCmhz18RC3z4+fsNpgN3f+/H9oO4ESO3qNNaupFQ+qWeRa5U7AGY/rlO7kq5Kb+qkUUrqzru/+8M9zTXUeKUHs92miG3LmlhhbjJCGVVoVCdCnG3ZyamgVRaQLvV+B9AeoJUu3QtgdLZWy6mspgigzdpyFS+/ZwTVhBv7/WyOgDbZBtTa3NMEKqX0Dsg6RqvFoUN3cOyczr2f1F3+FtbmDkB5gEKzFQFr215OBe3lO9Yu33GSrg47XUnxtiYQRKUgpdadCaAbnSMfmK+8Pf3L74ssATSAtorSt7a/vKnPUA87pMhTa9cAKJfzMwKysAwU56aUWQvcssUQJ/lA6aBw8xaPJHe+m4asLERcOpb3cvkGg1/SeEatGSZn+CVFeZPJDQRnxwDJgDY5nzcniIXbBkq5zo3Jyqg5PAMDAz5BlL/oLo0uLAOT4MqZvEnWCbEoPjfgU/LUKoDRK/BSSXHbgE8kqmOzt+HiGUA8QBY+Ov127823u0YAq1VGDno0n9/hs7BoWQocSSKIQKmk6OvTbN5sqAZCLeqw3uBmz791ChBFdmL4g4dnziptdnXYYhit2FxWlH2N72WHcmqhFjkW61c/xsTZc6OP3PIlIPayAHA2Dt/wem/oCLROqAZCNchU5B3AnczF9dcBR0sKxQZzI4U9rNOS+vwrDWHLJ76bOH7gTZBwo2GCBDOv/OF4Q+EyUCb+sW/JJeGxDQfG4b8vjRwK2hUKYNPF6gsbDUyC6lHAtgMB3NTfnv5ns+dtkL6F2eF9/6KRznagXDyxvyZx9PJG4WxUf+niif01Wtr8KiBgo8VPj24UMA5mXqAlne1AAPfhc79+DZHZ66aJq0wM/eJVWtKZB5Tqu0frNlr80/Xy0jB4fmbsZNQVCNj6+LlDoFxh7+2mkHjy3OFGOtse5U2H3sE/Xn5ZeT33dfJ5tdYmNjk5+tPt9wMhbd8Fed8DAqTJwuyhaxWYLM4MASk5HyGdPkDshT8/+hLiLq8XJuIu/+/Ir4bz0nk1oMyNHgttuPTseoGuvnh4/uzwqtorBATszNnXDqyvoUu48N6rB2mrvSJAAHd+/48mbVgr3AhsGDw/NvTIFG2lUBQoQFr/5L2nipSIgAvH//s0HTZL01QXPwro3X3o8rAu9expfdBeFpJGx0b3fvYhckqhqMJllVFl/PfdFNanx5/qpq6IwmZQvYPPTB9XpvTlPIWSxqOjez/z9YY6181ZN3NAEs5d+k2nCfHc5JNA0g1WVGGLyspbynh3tSp0aXLm9N7tg0XUFVXYVJlG81NPrlE3P/k7srUr1OyLAgHS/zzxjRex9v3mDbHp+2d/u+fFBrBwqoqaUKnEYfXS480b4dzk41QqMV125vWYBvoGn5l+596Dn74D9K0z6MY/4M7WvqkESOPK+GNRlsRm3eXNK+SwVYkPlBpBacA05uvGfVgpBSFr2K4RRALE5GykTif+toZT1WFu87pVSft1Asy1q70WhYrVwOa4ZoXred7JOq7h/wF6az0ukZgX/AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0yNVQyMTo1MDo0MyswODowMOgS43cAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTMtMTEtMjBUMjI6NDc6MTErMDg6MDAou1syAAAATnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjguOC0xMCBRMTYgeDg2XzY0IDIwMTUtMDctMTkgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmcFDJw1AAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OkhlaWdodAA1Mwmpb+QAAAAWdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMjgpleAmAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADEzODQ5NTg4MzEXUMEwAAAAE3RFWHRUaHVtYjo6U2l6ZQA0LjUzS0JC/AyPiAAAAFp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC93d3cuZWFzeWljb24ubmV0L2Nkbi1pbWcuZWFzeWljb24uY24vc3JjLzExMjk3LzExMjk3NzIucG5nqXNeUQAAAABJRU5ErkJggg=='; | |
| 97 | - var outMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAvCAMAAAC18jgTAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABO1BMVEUAAAAiu4ggv40gvowgvowgvosgvowfvo0jv44hv40gvosgvowcxo4fvowgvowdvYogv4whvo0gvowhvYwrqoAhv4wnxIkgv4wA//8gvIshvosgvowhvIshvowgvowrv5Ugv4ohvosgvowhv4wgv4whvYwXuYsgvowgvowiu4gfvo0zzJkhvowktpIgvowgv40hvo0gv4wgvowAqqogvosgvowjv4sgvowivIskv4khvowgvYsiu44hvosfvI0hv4sgvYofvowgvowgv40gv4wjuYsgvowhvowfvIsgvYsgvo0hvoxAv4Agv4wgvowgvoshvo0mv4whvowgvowfwo8gv4wgv40duokAAAAfvYsgvYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAYjGUYj2kAAAAAAAAAAAAgvoz///9v2GMAAAAAZ3RSTlMAD1eZyOr4miSc950Jivoj0i/pfAarDaoBWH3JLuv5DDDL0ZunbQvu/h6CBbQO5jhOkNwDtfAsz0Qc42EtdUGLYKKOwsYW7/s5f7nMBCj9N40U8/YZh48aAaOmAggNERMWF0lLGBkanzLKGQAAAAFiS0dEaMts9CIAAAGZSURBVDjLfZRnW8IwFIUvyN6FUlCx4AZxKw7cA/eeKKNUwfz/f2ChZNAmnC+U+54m9548KQCRwznicns8bpfX6QC7fP4AIgoEfRYcCkfQgCLhEMujMWRTLEq55EYcuSXyPpcbjv4aoRgSKGb2EUZChXvzRcSGSHfaIP0fT0iyLCXitOI38qP5JBWzKSVFE3OAk/I0HiudJMVR8JL1FRqMQgb3ggs/Jthox3B1HIg3wxoyuDoBKn6UWYOMqyp4uIYsNfC3yNEtJoc3OQXT3DFJmDNMUCkaFI1yFubmqcMedb4AsMAeVqaYzbGHtWj4l5bFx51f6a64mhca/OaeayK+3m9qY5PPS1tk7G0eV3doMLtlToN7bLT7JZvhYPByHqoWfmS93ceD/CRtNcApy89kG4fiOeXlCucLAoULzC+vgCvSxjUIdGPy2zuR4b53jx8eQagn5gi5en5B6PVtiAHeEfoYxqHiUT9FrNrT17f5a8O1eqOptXT951fXW1qzUa9ZXtfanU7nry/jsa1VuSsYtjZ3BdIDFin/A1AVNdoKDyAYAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTI1VDIxOjUwOjQzKzA4OjAw6BLjdwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0xMS0yMFQyMjo0NzoxMyswODowML8kShsAAABOdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuOC44LTEwIFExNiB4ODZfNjQgMjAxNS0wNy0xOSBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZwUMnDUAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAXdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADQ3F9+avAAAABZ0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAzMtBbOHkAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTM4NDk1ODgzM/leoBwAAAATdEVYdFRodW1iOjpTaXplADQuMDFLQkKe5chzAAAAWnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vaG9tZS93d3dyb290L3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTEyOTcvMTEyOTc4Ni5wbmetpUpEAAAAAElFTkSuQmCC'; | |
| 98 | - | |
| 99 | - var inOuts = [outMark, inMark]; | |
| 100 | - | |
| 101 | - var stationCodeMap = {}; | |
| 102 | - | |
| 103 | - var map = new BMap.Map("mapContainer"); | |
| 104 | - map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15); | |
| 105 | - map.enableScrollWheelZoom(); | |
| 106 | - //中心点和缩放级别 | |
| 107 | - map.setCurrentCity("上海"); | |
| 108 | - var myDis = new BMapLib.DistanceTool(map); | |
| 109 | - | |
| 110 | - | |
| 111 | - $.get('/line/all', function(rs){ | |
| 112 | - var data = []; | |
| 113 | - $.each(rs, function(){ | |
| 114 | - data.push({id: this.id, text: this.name}); | |
| 115 | - }); | |
| 116 | - | |
| 117 | - initPinYinSelect2('select[name=xl]', data); | |
| 118 | - }); | |
| 119 | - | |
| 120 | - function searchGps(){ | |
| 121 | - var params = $('form').serializeJSON(); | |
| 122 | - //查询线路路由站点 | |
| 123 | - $.get('/test/gps/route', params, function(rs){ | |
| 124 | - var array = rs[0].children[0].children | |
| 125 | - ,coords,circle, cdsArray, points, polygon; | |
| 126 | - //画出站点 | |
| 127 | - console.log(array); | |
| 128 | - $.each(array, function(){ | |
| 129 | - stationCodeMap[this.stationStationCod] = this.name; | |
| 130 | - if(this.stationShapesType === 'r'){ | |
| 131 | - //画圆 | |
| 132 | - coords = this.stationBJwpoints.split(' '); | |
| 133 | - circle = new BMap.Circle(new BMap.Point(coords[0], coords[1]),this.stationRadius); | |
| 134 | - circle.setStrokeColor('red'); | |
| 135 | - circle.setStrokeWeight(2) | |
| 136 | - map.addOverlay(circle); | |
| 137 | - } | |
| 138 | - else if(this.stationShapesType === 'd'){ | |
| 139 | - //画多边形 | |
| 140 | - coords = this.stationBPolygonGrid.substring(9, this.stationBPolygonGrid.length - 2); | |
| 141 | - cdsArray = coords.split(','); | |
| 142 | - points = []; | |
| 143 | - $.each(cdsArray, function(){ | |
| 144 | - coords = this.split(' '); | |
| 145 | - points.push(new BMap.Point(coords[0], coords[1])); | |
| 146 | - }); | |
| 147 | - | |
| 148 | - polygon = new BMap.Polygon(points, {strokeColor:"red", strokeWeight:2, strokeOpacity:0.5}); | |
| 149 | - map.addOverlay(polygon); | |
| 150 | - } | |
| 151 | - }); | |
| 152 | - coords = array[array.length / 2].stationBJwpoints.split(' '); | |
| 153 | - map.setCenter(new BMap.Point(coords[0], coords[1])) | |
| 154 | - }); | |
| 155 | - | |
| 156 | - //查询gps点 | |
| 157 | - $.get('/gps/history/' + params.device, params, function(gpsArray){ | |
| 158 | - console.log(stationCodeMap); | |
| 159 | - var marker, label, point, state, text; | |
| 160 | - $.each(gpsArray, function(){ | |
| 161 | - point = new BMap.Point(this.lon, this.lat); | |
| 162 | - marker = new BMap.Marker(point); | |
| 163 | - state = this.inout_stop; | |
| 164 | - | |
| 165 | - if(state == 0 || state == 1){ | |
| 166 | - text = state == 0?'出':'进'; | |
| 167 | - | |
| 168 | - console.log(stationCodeMap[this.stopNo], this); | |
| 169 | - marker.setIcon(new BMap.Icon(inOuts[this.inout_stop], new BMap.Size(25,25))); | |
| 170 | - label = new BMap.Label( | |
| 171 | - stationCodeMap[this.stopNo] + '/' +moment(this.ts).format('HH:mm.ss') + ' -'+text | |
| 172 | - , {position: point, offset: new BMap.Size(-25,-18)}); | |
| 173 | - marker.setLabel(label); | |
| 174 | - } | |
| 175 | - else{ | |
| 176 | - label = new BMap.Label(moment(this.ts).format('HH:mm.ss') | |
| 177 | - , {position: point, offset: new BMap.Size(-25,-18)}); | |
| 178 | - marker.setLabel(label); | |
| 179 | - } | |
| 180 | - | |
| 181 | - map.addOverlay(marker); | |
| 182 | - }); | |
| 183 | - }); | |
| 184 | - } | |
| 185 | - | |
| 186 | - | |
| 187 | - /** | |
| 188 | - * 支持拼音搜索的select2 | |
| 189 | - * @param selector | |
| 190 | - * @param data | |
| 191 | - */ | |
| 192 | - function initPinYinSelect2(selector, data, cb){ | |
| 193 | - | |
| 194 | - $.each(data, function(){ | |
| 195 | - this.fullChars = pinyin.getFullChars(this.text).toUpperCase(); | |
| 196 | - this.camelChars = pinyin.getCamelChars(this.text); | |
| 197 | - }); | |
| 198 | - | |
| 199 | - $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { | |
| 200 | - $(selector).select2({ | |
| 201 | - data: data, | |
| 202 | - matcher: oldMatcher(function(term, text, item){ | |
| 203 | - var upTerm = term.toUpperCase(); | |
| 204 | - if(item.fullChars.indexOf(upTerm) != -1 | |
| 205 | - || item.camelChars.indexOf(upTerm) != -1) | |
| 206 | - return true; | |
| 207 | - | |
| 208 | - return text.indexOf(term) != -1; | |
| 209 | - }) | |
| 210 | - }); | |
| 211 | - | |
| 212 | - cb && cb(); | |
| 213 | - }); | |
| 214 | - | |
| 215 | - return $(selector); | |
| 216 | - } | |
| 217 | -</script> | |
| 218 | -</body> | |
| 219 | -</html> | |
| 1 | +<!DOCTYPE html> | |
| 2 | +<html> | |
| 3 | +<head> | |
| 4 | +<meta charset="UTF-8"> | |
| 5 | +<title>GPS点测试</title> | |
| 6 | +<meta name=”renderer” content=”webkit”> | |
| 7 | +<meta http-equiv=”X-UA-Compatible” content=”IE=Edge,chrome=1″> | |
| 8 | + | |
| 9 | +<meta http-equiv="Pragma" content="no-cache"> | |
| 10 | +<meta http-equiv="Cache-control" content="no-cache"> | |
| 11 | +<meta http-equiv="Cache" content="no-cache"> | |
| 12 | +<head> | |
| 13 | +<!-- select2 下拉框插件 --> | |
| 14 | +<link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | |
| 15 | + rel="stylesheet" type="text/css" /> | |
| 16 | +<style type="text/css"> | |
| 17 | +html,body { | |
| 18 | + height: 100%; | |
| 19 | + overflow: hidden; | |
| 20 | +} | |
| 21 | + | |
| 22 | +#mapContainer { | |
| 23 | + width: 100%; | |
| 24 | + height: calc(100% - 93px); | |
| 25 | +} | |
| 26 | + | |
| 27 | +form { | |
| 28 | + padding: 25px; | |
| 29 | +} | |
| 30 | + | |
| 31 | +form .item { | |
| 32 | + display: inline-block; | |
| 33 | +} | |
| 34 | + | |
| 35 | +form .item input { | |
| 36 | + height: 26px; | |
| 37 | + width: 110px; | |
| 38 | +} | |
| 39 | + | |
| 40 | +form .item select { | |
| 41 | + height: 32px; | |
| 42 | +} | |
| 43 | +</style> | |
| 44 | +</head> | |
| 45 | +<body> | |
| 46 | + <form action=""> | |
| 47 | + <div class="item"> | |
| 48 | + 线路: <select name="xl" style="width: 150px;"> | |
| 49 | + </select> | |
| 50 | + </div> | |
| 51 | + <div class="item"> | |
| 52 | + 方向: <select name="directions" style="width: 70px;"> | |
| 53 | + <option value="0">上行</option> | |
| 54 | + <option value="1">下行</option> | |
| 55 | + </select> | |
| 56 | + </div> | |
| 57 | + <div class="item"> | |
| 58 | + 设备号: <input name="device" value="059L0903" /> | |
| 59 | + </div> | |
| 60 | + <div class="item"> | |
| 61 | + 开始时间戳: <input type="number" name="startTime" value="1461380940000" /> | |
| 62 | + </div> | |
| 63 | + <div class="item"> | |
| 64 | + 结束时间戳: <input type="number" name="endTime" value="1461381960000" /> | |
| 65 | + </div> | |
| 66 | + <div class="item"> | |
| 67 | + <input type="button" value="查询GPS轨迹" onclick="searchGps()"> | |
| 68 | + </div> | |
| 69 | + <div class="item"> | |
| 70 | + <input type="button" value="开启测距" onclick="myDis.open();" | |
| 71 | + style="width: 75px" /> <input type="button" value="关闭测距" | |
| 72 | + onclick="myDis.close()" style="width: 75px" /> | |
| 73 | + | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="item"> | |
| 77 | + <a target="_blank" href="http://tool.chinaz.com/Tools/unixtime.aspx" | |
| 78 | + style="font-size: 12px; color: red;">毫秒时间戳转换</a> | |
| 79 | + </div> | |
| 80 | + </form> | |
| 81 | + | |
| 82 | + <div id="mapContainer"></div> | |
| 83 | + <script src="/assets/plugins/pinyin.js"></script> | |
| 84 | + <script src="/metronic_v4.5.4/plugins/jquery.min.js"></script> | |
| 85 | + <script src="/assets/plugins/jquery.serializejson.js"></script> | |
| 86 | + <script | |
| 87 | + src="//api.map.baidu.com/api?v=2.0&ak=1TgEKvYqohJyeGXnN6yHSSTb4psOarQw"></script> | |
| 88 | + <script type="text/javascript" | |
| 89 | + src="//api.map.baidu.com/library/DistanceTool/1.2/src/DistanceTool_min.js"></script> | |
| 90 | + <!-- moment.js 日期处理类库 --> | |
| 91 | + <script src="/assets/plugins/moment-with-locales.js"></script> | |
| 92 | + <!-- select2 下拉框 --> | |
| 93 | + <script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | |
| 94 | + <script> | |
| 95 | + | |
| 96 | + var inMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAA1CAYAAABSrotqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAGW0lEQVRYw62XX2wc1RWHv3vv7NhrQkKCIa0poaKRmjdUFUGr+IH+ITy0Kg/0qVRV1ZamVV95al94oPSBVmoRUZTIKRFBLW1aapBK6gIChYTgFJRQHoITqCCO7eC1vY7t2Z1/954+zK69Xs9mx4mPdLWjmTvnO79z7zl3VlHAvv3XmXuM8R4EBpVSu1DqpiQRBJlH5APn5KQ4NzzycP/pbr7U1R5+6y+Vr2njP6EVX1FKoRTZAOJUQMBlP4gIIrwtNvnlyMO3vL4u4AND49vMjZsOaqMfUgpMA+ZEiBJIrJAkQslT+B4YrXACzknj1x4N6rWfnfrJ7XNdgd888NEOs+XmEaPVLq0zRVEiRGnmsGlJsnKtFfT4ih5PIQJWwDr3QRJUHzix9wsXOwLvOzDW72269ZQxeqcxIAL1WLAtoDzgMlgr+vwsG6kTrOXDoDL91Xcf/eLM8pxWuJT7j4hSO5UC66AW5cM6mXNCEDmsA60UAjv9rf1HWoU1L9Tg0OT3dU/5Wd9TeFpRiwWRFZhNhSvTMbX5hDh0uNhR6jWUb/LYvL0H460kSyko+xrrhCgVJAp/MPrzgecAMVkuH/PuuHv335VSW3s8TZgIrgUWzKdMXagRLqU4KygF4gRnhSiwLFZivF6N32tWAhTwPUWSCmhz18RC3z4+fsNpgN3f+/H9oO4ESO3qNNaupFQ+qWeRa5U7AGY/rlO7kq5Kb+qkUUrqzru/+8M9zTXUeKUHs92miG3LmlhhbjJCGVVoVCdCnG3ZyamgVRaQLvV+B9AeoJUu3QtgdLZWy6mspgigzdpyFS+/ZwTVhBv7/WyOgDbZBtTa3NMEKqX0Dsg6RqvFoUN3cOyczr2f1F3+FtbmDkB5gEKzFQFr215OBe3lO9Yu33GSrg47XUnxtiYQRKUgpdadCaAbnSMfmK+8Pf3L74ssATSAtorSt7a/vKnPUA87pMhTa9cAKJfzMwKysAwU56aUWQvcssUQJ/lA6aBw8xaPJHe+m4asLERcOpb3cvkGg1/SeEatGSZn+CVFeZPJDQRnxwDJgDY5nzcniIXbBkq5zo3Jyqg5PAMDAz5BlL/oLo0uLAOT4MqZvEnWCbEoPjfgU/LUKoDRK/BSSXHbgE8kqmOzt+HiGUA8QBY+Ov127823u0YAq1VGDno0n9/hs7BoWQocSSKIQKmk6OvTbN5sqAZCLeqw3uBmz791ChBFdmL4g4dnziptdnXYYhit2FxWlH2N72WHcmqhFjkW61c/xsTZc6OP3PIlIPayAHA2Dt/wem/oCLROqAZCNchU5B3AnczF9dcBR0sKxQZzI4U9rNOS+vwrDWHLJ76bOH7gTZBwo2GCBDOv/OF4Q+EyUCb+sW/JJeGxDQfG4b8vjRwK2hUKYNPF6gsbDUyC6lHAtgMB3NTfnv5ns+dtkL6F2eF9/6KRznagXDyxvyZx9PJG4WxUf+niif01Wtr8KiBgo8VPj24UMA5mXqAlne1AAPfhc79+DZHZ66aJq0wM/eJVWtKZB5Tqu0frNlr80/Xy0jB4fmbsZNQVCNj6+LlDoFxh7+2mkHjy3OFGOtse5U2H3sE/Xn5ZeT33dfJ5tdYmNjk5+tPt9wMhbd8Fed8DAqTJwuyhaxWYLM4MASk5HyGdPkDshT8/+hLiLq8XJuIu/+/Ir4bz0nk1oMyNHgttuPTseoGuvnh4/uzwqtorBATszNnXDqyvoUu48N6rB2mrvSJAAHd+/48mbVgr3AhsGDw/NvTIFG2lUBQoQFr/5L2nipSIgAvH//s0HTZL01QXPwro3X3o8rAu9expfdBeFpJGx0b3fvYhckqhqMJllVFl/PfdFNanx5/qpq6IwmZQvYPPTB9XpvTlPIWSxqOjez/z9YY6181ZN3NAEs5d+k2nCfHc5JNA0g1WVGGLyspbynh3tSp0aXLm9N7tg0XUFVXYVJlG81NPrlE3P/k7srUr1OyLAgHS/zzxjRex9v3mDbHp+2d/u+fFBrBwqoqaUKnEYfXS480b4dzk41QqMV125vWYBvoGn5l+596Dn74D9K0z6MY/4M7WvqkESOPK+GNRlsRm3eXNK+SwVYkPlBpBacA05uvGfVgpBSFr2K4RRALE5GykTif+toZT1WFu87pVSft1Asy1q70WhYrVwOa4ZoXred7JOq7h/wF6az0ukZgX/AAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wNy0yNVQyMTo1MDo0MyswODowMOgS43cAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTMtMTEtMjBUMjI6NDc6MTErMDg6MDAou1syAAAATnRFWHRzb2Z0d2FyZQBJbWFnZU1hZ2ljayA2LjguOC0xMCBRMTYgeDg2XzY0IDIwMTUtMDctMTkgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmcFDJw1AAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OkhlaWdodAA1Mwmpb+QAAAAWdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMjgpleAmAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADEzODQ5NTg4MzEXUMEwAAAAE3RFWHRUaHVtYjo6U2l6ZQA0LjUzS0JC/AyPiAAAAFp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC93d3cuZWFzeWljb24ubmV0L2Nkbi1pbWcuZWFzeWljb24uY24vc3JjLzExMjk3LzExMjk3NzIucG5nqXNeUQAAAABJRU5ErkJggg=='; | |
| 97 | + var outMark = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAvCAMAAAC18jgTAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAABO1BMVEUAAAAiu4ggv40gvowgvowgvosgvowfvo0jv44hv40gvosgvowcxo4fvowgvowdvYogv4whvo0gvowhvYwrqoAhv4wnxIkgv4wA//8gvIshvosgvowhvIshvowgvowrv5Ugv4ohvosgvowhv4wgv4whvYwXuYsgvowgvowiu4gfvo0zzJkhvowktpIgvowgv40hvo0gv4wgvowAqqogvosgvowjv4sgvowivIskv4khvowgvYsiu44hvosfvI0hv4sgvYofvowgvowgv40gv4wjuYsgvowhvowfvIsgvYsgvo0hvoxAv4Agv4wgvowgvoshvo0mv4whvowgvowfwo8gv4wgv40duokAAAAfvYsgvYwAAAAAAAAAAAAAAAAAAAAAAAAAAAAYjGUYj2kAAAAAAAAAAAAgvoz///9v2GMAAAAAZ3RSTlMAD1eZyOr4miSc950Jivoj0i/pfAarDaoBWH3JLuv5DDDL0ZunbQvu/h6CBbQO5jhOkNwDtfAsz0Qc42EtdUGLYKKOwsYW7/s5f7nMBCj9N40U8/YZh48aAaOmAggNERMWF0lLGBkanzLKGQAAAAFiS0dEaMts9CIAAAGZSURBVDjLfZRnW8IwFIUvyN6FUlCx4AZxKw7cA/eeKKNUwfz/f2ChZNAmnC+U+54m9548KQCRwznicns8bpfX6QC7fP4AIgoEfRYcCkfQgCLhEMujMWRTLEq55EYcuSXyPpcbjv4aoRgSKGb2EUZChXvzRcSGSHfaIP0fT0iyLCXitOI38qP5JBWzKSVFE3OAk/I0HiudJMVR8JL1FRqMQgb3ggs/Jthox3B1HIg3wxoyuDoBKn6UWYOMqyp4uIYsNfC3yNEtJoc3OQXT3DFJmDNMUCkaFI1yFubmqcMedb4AsMAeVqaYzbGHtWj4l5bFx51f6a64mhca/OaeayK+3m9qY5PPS1tk7G0eV3doMLtlToN7bLT7JZvhYPByHqoWfmS93ceD/CRtNcApy89kG4fiOeXlCucLAoULzC+vgCvSxjUIdGPy2zuR4b53jx8eQagn5gi5en5B6PVtiAHeEfoYxqHiUT9FrNrT17f5a8O1eqOptXT951fXW1qzUa9ZXtfanU7nry/jsa1VuSsYtjZ3BdIDFin/A1AVNdoKDyAYAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA3LTI1VDIxOjUwOjQzKzA4OjAw6BLjdwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxMy0xMS0yMFQyMjo0NzoxMyswODowML8kShsAAABOdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuOC44LTEwIFExNiB4ODZfNjQgMjAxNS0wNy0xOSBodHRwOi8vd3d3LmltYWdlbWFnaWNrLm9yZwUMnDUAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAXdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADQ3F9+avAAAABZ0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAzMtBbOHkAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTM4NDk1ODgzM/leoBwAAAATdEVYdFRodW1iOjpTaXplADQuMDFLQkKe5chzAAAAWnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vaG9tZS93d3dyb290L3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9zcmMvMTEyOTcvMTEyOTc4Ni5wbmetpUpEAAAAAElFTkSuQmCC'; | |
| 98 | + | |
| 99 | + var inOuts = [outMark, inMark]; | |
| 100 | + | |
| 101 | + var stationCodeMap = {}; | |
| 102 | + | |
| 103 | + var map = new BMap.Map("mapContainer"); | |
| 104 | + map.centerAndZoom(new BMap.Point(121.544336, 31.221315), 15); | |
| 105 | + map.enableScrollWheelZoom(); | |
| 106 | + //中心点和缩放级别 | |
| 107 | + map.setCurrentCity("上海"); | |
| 108 | + var myDis = new BMapLib.DistanceTool(map); | |
| 109 | + | |
| 110 | + | |
| 111 | + $.get('/line/all', function(rs){ | |
| 112 | + var data = []; | |
| 113 | + $.each(rs, function(){ | |
| 114 | + data.push({id: this.id, text: this.name}); | |
| 115 | + }); | |
| 116 | + | |
| 117 | + initPinYinSelect2('select[name=xl]', data); | |
| 118 | + }); | |
| 119 | + | |
| 120 | + function searchGps(){ | |
| 121 | + var params = $('form').serializeJSON(); | |
| 122 | + //查询线路路由站点 | |
| 123 | + $.get('/test/gps/route', params, function(rs){ | |
| 124 | + var array = rs[0].children[0].children | |
| 125 | + ,coords,circle, cdsArray, points, polygon; | |
| 126 | + //画出站点 | |
| 127 | + console.log(array); | |
| 128 | + $.each(array, function(){ | |
| 129 | + stationCodeMap[this.stationStationCod] = this.name; | |
| 130 | + if(this.stationShapesType === 'r'){ | |
| 131 | + //画圆 | |
| 132 | + coords = this.stationBJwpoints.split(' '); | |
| 133 | + circle = new BMap.Circle(new BMap.Point(coords[0], coords[1]),this.stationRadius); | |
| 134 | + circle.setStrokeColor('red'); | |
| 135 | + circle.setStrokeWeight(2) | |
| 136 | + map.addOverlay(circle); | |
| 137 | + } | |
| 138 | + else if(this.stationShapesType === 'd'){ | |
| 139 | + //画多边形 | |
| 140 | + coords = this.stationBPolygonGrid.substring(9, this.stationBPolygonGrid.length - 2); | |
| 141 | + cdsArray = coords.split(','); | |
| 142 | + points = []; | |
| 143 | + $.each(cdsArray, function(){ | |
| 144 | + coords = this.split(' '); | |
| 145 | + points.push(new BMap.Point(coords[0], coords[1])); | |
| 146 | + }); | |
| 147 | + | |
| 148 | + polygon = new BMap.Polygon(points, {strokeColor:"red", strokeWeight:2, strokeOpacity:0.5}); | |
| 149 | + map.addOverlay(polygon); | |
| 150 | + } | |
| 151 | + }); | |
| 152 | + coords = array[array.length / 2].stationBJwpoints.split(' '); | |
| 153 | + map.setCenter(new BMap.Point(coords[0], coords[1])) | |
| 154 | + }); | |
| 155 | + | |
| 156 | + //查询gps点 | |
| 157 | + $.get('/gps/history/' + params.device, params, function(gpsArray){ | |
| 158 | + console.log(stationCodeMap); | |
| 159 | + var marker, label, point, state, text; | |
| 160 | + $.each(gpsArray, function(){ | |
| 161 | + point = new BMap.Point(this.lon, this.lat); | |
| 162 | + marker = new BMap.Marker(point); | |
| 163 | + state = this.inout_stop; | |
| 164 | + | |
| 165 | + if(state == 0 || state == 1){ | |
| 166 | + text = state == 0?'出':'进'; | |
| 167 | + | |
| 168 | + console.log(stationCodeMap[this.stopNo], this); | |
| 169 | + marker.setIcon(new BMap.Icon(inOuts[this.inout_stop], new BMap.Size(25,25))); | |
| 170 | + label = new BMap.Label( | |
| 171 | + stationCodeMap[this.stopNo] + '/' +moment(this.ts).format('HH:mm.ss') + ' -'+text | |
| 172 | + , {position: point, offset: new BMap.Size(-25,-18)}); | |
| 173 | + marker.setLabel(label); | |
| 174 | + } | |
| 175 | + else{ | |
| 176 | + label = new BMap.Label(moment(this.ts).format('HH:mm.ss') | |
| 177 | + , {position: point, offset: new BMap.Size(-25,-18)}); | |
| 178 | + marker.setLabel(label); | |
| 179 | + } | |
| 180 | + | |
| 181 | + map.addOverlay(marker); | |
| 182 | + }); | |
| 183 | + }); | |
| 184 | + } | |
| 185 | + | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * 支持拼音搜索的select2 | |
| 189 | + * @param selector | |
| 190 | + * @param data | |
| 191 | + */ | |
| 192 | + function initPinYinSelect2(selector, data, cb){ | |
| 193 | + | |
| 194 | + $.each(data, function(){ | |
| 195 | + this.fullChars = pinyin.getFullChars(this.text).toUpperCase(); | |
| 196 | + this.camelChars = pinyin.getCamelChars(this.text); | |
| 197 | + }); | |
| 198 | + | |
| 199 | + $.fn.select2.amd.require(['select2/compat/matcher'], function (oldMatcher) { | |
| 200 | + $(selector).select2({ | |
| 201 | + data: data, | |
| 202 | + matcher: oldMatcher(function(term, text, item){ | |
| 203 | + var upTerm = term.toUpperCase(); | |
| 204 | + if(item.fullChars.indexOf(upTerm) != -1 | |
| 205 | + || item.camelChars.indexOf(upTerm) != -1) | |
| 206 | + return true; | |
| 207 | + | |
| 208 | + return text.indexOf(term) != -1; | |
| 209 | + }) | |
| 210 | + }); | |
| 211 | + | |
| 212 | + cb && cb(); | |
| 213 | + }); | |
| 214 | + | |
| 215 | + return $(selector); | |
| 216 | + } | |
| 217 | +</script> | |
| 218 | +</body> | |
| 219 | +</html> | ... | ... |
src/main/resources/static/index.html
| 1 | -<!DOCTYPE html> | |
| 2 | -<html lang="zh"> | |
| 3 | -<head> | |
| 4 | - <meta name="renderer" content="webkit" /> | |
| 5 | - <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
| 6 | - <meta charset="UTF-8"> | |
| 7 | - <title>调度系统</title> | |
| 8 | - | |
| 9 | - <meta http-equiv="Pragma" content="no-cache"> | |
| 10 | - <meta http-equiv="Cache-control" content="no-cache"> | |
| 11 | - <meta http-equiv="Cache" content="no-cache"> | |
| 12 | - | |
| 13 | - <!-- Font Awesome 图标字体 --> | |
| 14 | - <link | |
| 15 | - href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css" | |
| 16 | - rel="stylesheet" type="text/css" /> | |
| 17 | - <!-- Bootstrap style --> | |
| 18 | - <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css" | |
| 19 | - rel="stylesheet" type="text/css" /> | |
| 20 | - <!-- jsTree 数插件 --> | |
| 21 | - <link | |
| 22 | - href="/metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css" | |
| 23 | - rel="stylesheet" type="text/css" /> | |
| 24 | - <!-- MULTI-select 多选下拉框美化 --> | |
| 25 | - <link | |
| 26 | - href="/metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css" | |
| 27 | - rel="stylesheet" type="text/css" /> | |
| 28 | - | |
| 29 | - <!-- editable --> | |
| 30 | - <link | |
| 31 | - href="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/css/bootstrap-editable.css" | |
| 32 | - rel="stylesheet" type="text/css" /> | |
| 33 | - <!-- METRONIC style --> | |
| 34 | - <link href="/metronic_v4.5.4/layout4/css/themes/light.min.css" | |
| 35 | - rel="stylesheet" type="text/css" id="style_color" /> | |
| 36 | - <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet" | |
| 37 | - type="text/css" /> | |
| 38 | - <link href="/metronic_v4.5.4/css/plugins.css" rel="stylesheet" | |
| 39 | - type="text/css" /> | |
| 40 | - <link href="/metronic_v4.5.4/layout4/css/layout.min.css" | |
| 41 | - rel="stylesheet" type="text/css" /> | |
| 42 | - <link href="/metronic_v4.5.4/layout4/css/custom.min.css" | |
| 43 | - rel="stylesheet" type="text/css" /> | |
| 44 | - <!-- select2 下拉框插件 --> | |
| 45 | - <link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | |
| 46 | - rel="stylesheet" type="text/css" /> | |
| 47 | - <link | |
| 48 | - href="/metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css" | |
| 49 | - rel="stylesheet" type="text/css" /> | |
| 50 | - <!-- layer 弹层 插件 --> | |
| 51 | - <link href="/assets/plugins/layer-v2.4/layer/skin/layer.css" | |
| 52 | - rel="stylesheet" type="text/css" /> | |
| 53 | - <!-- fileinput 上传 插件 --> | |
| 54 | - <link href="/assets/plugins/fileinput/css/fileinput.min.css" | |
| 55 | - rel="stylesheet" type="text/css" /> | |
| 56 | - <!-- iCheck 单选框和复选框 --> | |
| 57 | - <link href="/metronic_v4.5.4/plugins/icheck/skins/all.css" | |
| 58 | - rel="stylesheet" type="text/css" /> | |
| 59 | - <!-- 日期控件 --> | |
| 60 | - <link | |
| 61 | - href="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css" | |
| 62 | - rel="stylesheet" type="text/css" /> | |
| 63 | - <!-- table 表格控件 --> | |
| 64 | - <!--<link rel="stylesheet"--> | |
| 65 | - <!--href="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css"--> | |
| 66 | - <!--type="text/css" />--> | |
| 67 | - <link href="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet" type="text/css"/> | |
| 68 | - <!-- handsontable样式 --> | |
| 69 | - <link rel="stylesheet" | |
| 70 | - href="/assets/bower_components/handsontable/dist/handsontable.full.css" /> | |
| 71 | - <!-- sweetalert样式 --> | |
| 72 | - <link rel="stylesheet" | |
| 73 | - href="/assets/bower_components/sweetalert/dist/sweetalert.css" /> | |
| 74 | - <!-- schedule计划调度AngularJS模块主css --> | |
| 75 | - <link rel="stylesheet" href="/pages/scheduleApp/module/common/main.css" | |
| 76 | - type="text/css" /> | |
| 77 | - <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/> | |
| 78 | - | |
| 79 | - <!-- CSS动画 --> | |
| 80 | - <link | |
| 81 | - href="/metronic_v4.5.4/plugins/tipso/css/animate.css" | |
| 82 | - rel="stylesheet" type="text/css" /> | |
| 83 | - | |
| 84 | - <!-- 提示工具样式 --> | |
| 85 | - <link | |
| 86 | - href="/metronic_v4.5.4/plugins/tipso/css/tipso.css" | |
| 87 | - rel="stylesheet" type="text/css" /> | |
| 88 | - | |
| 89 | - <style type="text/css"> | |
| 90 | - .searchForm { | |
| 91 | - | |
| 92 | - } | |
| 93 | - | |
| 94 | - .searchForm .form-group .control-label { | |
| 95 | - padding-right: 0px; | |
| 96 | - text-align: right; | |
| 97 | - margin-top: 7px; | |
| 98 | - } | |
| 99 | - | |
| 100 | - .searchForm .form-group>div { | |
| 101 | - padding-left: 10px; | |
| 102 | - padding-right: 0px; | |
| 103 | - } | |
| 104 | - | |
| 105 | - .searchForm .row>div { | |
| 106 | - padding-left: 0px; | |
| 107 | - padding-right: 0px; | |
| 108 | - padding: 5px 0 5px 0; | |
| 109 | - width: 270px; | |
| 110 | - display: inline-block; | |
| 111 | - } | |
| 112 | - | |
| 113 | - .searchForm .form-actions { | |
| 114 | - | |
| 115 | - } | |
| 116 | - | |
| 117 | - tr.row-active td { | |
| 118 | - border-bottom: 1px solid blue !important; | |
| 119 | - color: blue; | |
| 120 | - } | |
| 121 | - | |
| 122 | - .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection | |
| 123 | - { | |
| 124 | - font-size: 14px; | |
| 125 | - } | |
| 126 | - | |
| 127 | - .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection | |
| 128 | - { | |
| 129 | - padding: 6px 26px; | |
| 130 | - } | |
| 131 | - | |
| 132 | - .ms-container .ms-list { | |
| 133 | - height: 306px; | |
| 134 | - } | |
| 135 | - | |
| 136 | - .ms-container .ms-selectable,.ms-container .ms-selection { | |
| 137 | - width: 47%; | |
| 138 | - } | |
| 139 | - | |
| 140 | - .ms-container { | |
| 141 | - width: 470px; | |
| 142 | - margin: auto; | |
| 143 | - } | |
| 144 | - | |
| 145 | - .multi-custom-header-left { | |
| 146 | - text-align: center; | |
| 147 | - padding: 7px; | |
| 148 | - color: #3B3F51; | |
| 149 | - } | |
| 150 | - | |
| 151 | - .multi-custom-header-right { | |
| 152 | - text-align: center; | |
| 153 | - padding: 7px; | |
| 154 | - font-weight: bold; | |
| 155 | - color: #36C6D3; | |
| 156 | - } | |
| 157 | - | |
| 158 | - .mt-element-list .list-simple.mt-list-container ul>.mt-list-item>.list-item-content | |
| 159 | - { | |
| 160 | - padding: 0 55px 0 0px; | |
| 161 | - } | |
| 162 | - | |
| 163 | - .mt-element-list .list-simple.mt-list-container ul>.mt-list-item { | |
| 164 | - padding: 3.3px 0; | |
| 165 | - } | |
| 166 | - | |
| 167 | - #route-container { | |
| 168 | - display: none; | |
| 169 | - } | |
| 170 | - | |
| 171 | - .page-content.active { | |
| 172 | - display: block !important; | |
| 173 | - } | |
| 174 | - | |
| 175 | - .page-header.navbar .page-logo .logo-default { | |
| 176 | - margin: 0; | |
| 177 | - } | |
| 178 | - | |
| 179 | - .page-header.navbar .top-menu .navbar-nav>li.dropdown.open .dropdown-toggle | |
| 180 | - { | |
| 181 | - background-color: #284a99; | |
| 182 | - } | |
| 183 | - | |
| 184 | - .page-header.navbar .page-logo { | |
| 185 | - padding-right: 10px; | |
| 186 | - } | |
| 187 | - | |
| 188 | - .page-logo .logo-default.logo-default-text { | |
| 189 | - font-weight: 600; | |
| 190 | - color: white !important; | |
| 191 | - margin-top: 19px !important; | |
| 192 | - font-size: 24px; | |
| 193 | - text-decoration: none; | |
| 194 | - } | |
| 195 | - | |
| 196 | - .page-logo .logo-default.logo-default-text:HOVER { | |
| 197 | - color: #dedede !important; | |
| 198 | - } | |
| 199 | - | |
| 200 | - body,.page-content-wrapper,#pjax-container{ | |
| 201 | - height: 100%; | |
| 202 | - } | |
| 203 | - html{ | |
| 204 | - height: 90%; | |
| 205 | - } | |
| 206 | - .page-container{ | |
| 207 | - height: 100%; | |
| 208 | - } | |
| 209 | - </style> | |
| 210 | - | |
| 211 | - <!-- ocLazyLoading载入文件的位置 --> | |
| 212 | - <link id="ng_load_plugins_before" /> | |
| 213 | - | |
| 214 | -</head> | |
| 215 | -<body | |
| 216 | - class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo page-sidebar-fixed"> | |
| 217 | -<div class="page-header navbar navbar-fixed-top" | |
| 218 | - style="background: linear-gradient(to bottom, #124e78, #125688);"> | |
| 219 | - <div class="page-header-inner "> | |
| 220 | - <!-- LOGO --> | |
| 221 | - <div class="page-logo"> | |
| 222 | - <a href="index.html" class="logo-default logo-default-text"> | |
| 223 | - 浦东公交调度系统 </a> | |
| 224 | - <div class="menu-toggler sidebar-toggler"></div> | |
| 225 | - </div> | |
| 226 | - <!-- END LOGO --> | |
| 227 | - <a href="javascript:;" class="menu-toggler responsive-toggler" | |
| 228 | - data-toggle="collapse" data-target=".navbar-collapse"> </a> | |
| 229 | - <div class="page-top"> | |
| 230 | - <div class="top-menu"> | |
| 231 | - <ul class="nav navbar-nav pull-right"> | |
| 232 | - <!-- 信息通知区 --> | |
| 233 | - <li | |
| 234 | - class="dropdown dropdown-extended dropdown-notification dropdown-dark" | |
| 235 | - id="header_notification_bar"><a href="javascript:;" | |
| 236 | - class="dropdown-toggle" data-toggle="dropdown" | |
| 237 | - data-hover="dropdown" data-close-others="true"> <i | |
| 238 | - class="fa fa-bell"></i> <span class="badge badge-success"> | |
| 239 | - 0 </span> | |
| 240 | - </a> | |
| 241 | - <ul class="dropdown-menu" style="max-width: 345px; width: 345px;"> | |
| 242 | - <li class="external"> | |
| 243 | - <h3> | |
| 244 | - 今日 <span class="bold">0 条</span> 通知 | |
| 245 | - </h3> <a href="javascript:;">查看全部</a> | |
| 246 | - </li> | |
| 247 | - <li> | |
| 248 | - <ul class="dropdown-menu-list scroller" style="height: 250px;" | |
| 249 | - data-handle-color="#637283"> | |
| 250 | - </ul> | |
| 251 | - </li> | |
| 252 | - </ul></li> | |
| 253 | - <li class="dropdown dropdown-user dropdown-dark"><a | |
| 254 | - href="javascript:;" class="dropdown-toggle" | |
| 255 | - data-toggle="dropdown" data-hover="dropdown" | |
| 256 | - data-close-others="true"> <span id="indexTopUName" | |
| 257 | - class="username username-hide-on-mobile" | |
| 258 | - style="vertical-align: middle;"> <i class="fa fa-user"></i></span> | |
| 259 | - </a> | |
| 260 | - <ul class="dropdown-menu dropdown-menu-default"> | |
| 261 | - <li><a href="javascript:;"> <i class="fa fa-user"></i> | |
| 262 | - 我的信息 | |
| 263 | - </a></li> | |
| 264 | - <li><a href="javascript:;" id="changePWD"> <i | |
| 265 | - class="fa fa-unlock-alt"></i> 修改密码 | |
| 266 | - </a></li> | |
| 267 | - <li class="divider"></li> | |
| 268 | - <li><a href="javascript:;"> <i class="fa fa-lock"></i> | |
| 269 | - 锁屏 | |
| 270 | - </a></li> | |
| 271 | - <li><a href="/logout"> <i class="fa fa-key"></i> 注销登陆 | |
| 272 | - </a></li> | |
| 273 | - </ul></li> | |
| 274 | - </ul> | |
| 275 | - </div> | |
| 276 | - </div> | |
| 277 | - </div> | |
| 278 | -</div> | |
| 279 | -<div class="page-container"> | |
| 280 | - <div class="page-sidebar-wrapper"> | |
| 281 | - <div class="page-sidebar navbar-collapse collapse"> | |
| 282 | - <ul class="page-sidebar-menu page-sidebar-menu-fixed" | |
| 283 | - data-keep-expanded="false" data-auto-scroll="true" | |
| 284 | - data-slide-speed="200" id="leftMenuSidebar"> | |
| 285 | - </ul> | |
| 286 | - </div> | |
| 287 | - </div> | |
| 288 | - <div class="page-content-wrapper"> | |
| 289 | - <div id="pjax-container" class="page-content"></div> | |
| 290 | - | |
| 291 | - <div id="route-container"> | |
| 292 | - <div ng-app="ScheduleApp"> | |
| 293 | - <div ng-controller="ScheduleAppController"> | |
| 294 | - | |
| 295 | - <!-- loading widget --> | |
| 296 | - <div id="loadingWidget" class="flyover mask" loading-widget> | |
| 297 | - <div class="alert alert-info"> | |
| 298 | - <strong>载入中......</strong> | |
| 299 | - </div> | |
| 300 | - </div> | |
| 301 | - | |
| 302 | - <div ui-view class="uv"></div> | |
| 303 | - </div> | |
| 304 | - </div> | |
| 305 | - </div> | |
| 306 | - </div> | |
| 307 | -</div> | |
| 308 | - | |
| 309 | -<script id="menu_list_temp" type="text/html"> | |
| 310 | - {{each list as group i}} | |
| 311 | - <li class="heading"> | |
| 312 | - <h3 class="uppercase">{{group.name}}</h3> | |
| 313 | - </li> | |
| 314 | - {{each group.children as dir j}} | |
| 315 | - <li class="nav-item"> | |
| 316 | - <a href="javascript:;" class="nav-link nav-toggle "> | |
| 317 | - <i class="{{dir.icon}}"></i> | |
| 318 | - <span class="title">{{dir.name}}</span> | |
| 319 | - <span class="arrow"></span> | |
| 320 | - </a> | |
| 321 | - <ul class="sub-menu"> | |
| 322 | - {{each dir.children as module s}} | |
| 323 | - <li class="nav-item "> | |
| 324 | - {{if module.container=="pjax-container"}} | |
| 325 | - <a href="/pages/{{module.path}}" class="nav-link " data-pjax> | |
| 326 | - <span class="title">{{module.name}}</span> | |
| 327 | - </a> | |
| 328 | - {{else}} | |
| 329 | - <a href="{{module.path}}" class="nav-link " data-angularjs> | |
| 330 | - <span class="title">{{module.name}}</span> | |
| 331 | - </a> | |
| 332 | - {{/if}} | |
| 333 | - </li> | |
| 334 | - {{/each}} | |
| 335 | - </ul> | |
| 336 | - </li> | |
| 337 | - {{/each}} | |
| 338 | - {{/each}} | |
| 339 | - | |
| 340 | -</script> | |
| 341 | -<script> | |
| 342 | - delete window.require; | |
| 343 | - delete window.exports; | |
| 344 | - delete window.module; | |
| 345 | -</script> | |
| 346 | -<!-- jQuery --> | |
| 347 | -<script src="/metronic_v4.5.4/plugins/jquery.min.js" data-exclude=1></script> | |
| 348 | -<!-- bootstrap --> | |
| 349 | -<script src="/metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js" | |
| 350 | - data-exclude=1></script> | |
| 351 | -<script src="/pages/forms/statement/js/jquery.autocompleter.js"></script> | |
| 352 | -<script src="/pages/forms/statement/js/jquery.PrintArea.js"></script> | |
| 353 | -<!-- MTRONIC JS --> | |
| 354 | -<script src="/metronic_v4.5.4/scripts/app.min.js" data-exclude=1></script> | |
| 355 | -<script src="/metronic_v4.5.4/layout4/scripts/layout.min.js" | |
| 356 | - data-exclude=1></script> | |
| 357 | -<!-- 虚拟滚动条 --> | |
| 358 | -<script | |
| 359 | - src="/metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script> | |
| 360 | -<!-- jsTree 树插件 --> | |
| 361 | -<script src="/metronic_v4.5.4/plugins/jstree/dist/jstree.min.js"></script> | |
| 362 | -<!-- bootstrap-hover-dropDown --> | |
| 363 | -<script | |
| 364 | - src="/metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script> | |
| 365 | -<!-- jquery.validate 表单验证 --> | |
| 366 | -<script | |
| 367 | - src="/metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script> | |
| 368 | -<script | |
| 369 | - src="/metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script> | |
| 370 | -<!-- 向导式插件 --> | |
| 371 | -<script | |
| 372 | - src="/metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script> | |
| 373 | -<!-- iCheck 单选框和复选框 --> | |
| 374 | -<script src="/metronic_v4.5.4/plugins/icheck/icheck.min.js"></script> | |
| 375 | -<!-- select2 下拉框 --> | |
| 376 | -<script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | |
| 377 | -<!-- MULTI SELECT 多选下拉框 --> | |
| 378 | -<script | |
| 379 | - src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script> | |
| 380 | -<!-- editable.js --> | |
| 381 | -<script | |
| 382 | - src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script> | |
| 383 | -<!-- PJAX --> | |
| 384 | -<script src="/assets/plugins/jquery.pjax.js"></script> | |
| 385 | -<!-- layer 弹层 --> | |
| 386 | -<script src="/assets/plugins/layer-v2.4/layer/layer.js" data-exclude=1></script> | |
| 387 | -<!-- fileinput 上传 --> | |
| 388 | -<script src="/assets/plugins/fileinput/canvas-to-blob.min.js"></script> | |
| 389 | -<script src="/assets/plugins/fileinput/purify.min.js"></script> | |
| 390 | -<script src="/assets/plugins/fileinput/sortable.min.js"></script> | |
| 391 | -<script src="/assets/plugins/fileinput/fileinput.min.js"></script> | |
| 392 | -<script src="/assets/plugins/fileinput/fileinput_locale_zh.js"></script> | |
| 393 | -<!-- jquery.purl URL解析 --> | |
| 394 | -<script src="/assets/plugins/purl.js"></script> | |
| 395 | -<!-- jquery.serializejson JSON序列化插件 --> | |
| 396 | -<script src="/assets/plugins/jquery.serializejson.js"></script> | |
| 397 | -<!-- art-template 模版引擎 --> | |
| 398 | -<script src="/assets/plugins/template.js"></script> | |
| 399 | -<!-- jquery.pageinator 分页 --> | |
| 400 | -<script src="/assets/plugins/jqPaginator.min.js"></script> | |
| 401 | -<!-- moment.js 日期处理类库 --> | |
| 402 | -<script src="/assets/plugins/moment-with-locales.js"></script> | |
| 403 | - | |
| 404 | -<script src="/assets/plugins/pinyin.js"></script> | |
| 405 | -<!-- 日期控件 --> | |
| 406 | -<script | |
| 407 | - src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js"></script> | |
| 408 | -<!-- 表格控件 --> | |
| 409 | -<script src="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script> | |
| 410 | -<!-- 统计图控件 --> | |
| 411 | -<!--<script src="/assets/global/getEchart.js"></script> | |
| 412 | -<script src="/assets/global/echarts.js"></script> --> | |
| 413 | -<script src="/assets/js/common.js"></script> | |
| 414 | -<script src="/assets/js/dictionary.js"></script> | |
| 415 | -<!-- tipso JS --> | |
| 416 | -<script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script> | |
| 417 | -<script data-exclude=1> | |
| 418 | - //初始打开的片段地址 | |
| 419 | - var initFragment = "^_^initFragment^_^"; | |
| 420 | - //静态文件目录 | |
| 421 | - var dir = '/pages/'; | |
| 422 | - //片段容器 | |
| 423 | - var pjaxContainer = '#pjax-container' | |
| 424 | - , angJsContainer = '#route-container'; | |
| 425 | - | |
| 426 | - $(document).ajaxError(function (event, jqxhr, settings, thrownError) { | |
| 427 | - if(jqxhr.status == 403){ | |
| 428 | - layer.closeAll(); | |
| 429 | - layer.alert(jqxhr.message?jqxhr.message:'访问被拒绝', {icon: 2, title: '操作失败'}); | |
| 430 | - } | |
| 431 | - }); | |
| 432 | - | |
| 433 | - $(function () { | |
| 434 | - $.ajax({ | |
| 435 | - url: '/user/isWeakCipher', | |
| 436 | - type: 'POST', | |
| 437 | - async: false, | |
| 438 | - success: function (result,status,xhr) { | |
| 439 | - if (result.data == 1) { | |
| 440 | - $.get('/pages/permission/user/forceChangePWD.html', function (content) { | |
| 441 | - layer.open({ | |
| 442 | - type: 1, | |
| 443 | - area: ['600px', '360px'], | |
| 444 | - content: content, | |
| 445 | - title: '修改密码', | |
| 446 | - shift: 5, | |
| 447 | - scrollbar: false, | |
| 448 | - closeBtn: 0, | |
| 449 | - success: function () { | |
| 450 | - } | |
| 451 | - }); | |
| 452 | - }); | |
| 453 | - } | |
| 454 | - } | |
| 455 | - }); | |
| 456 | - | |
| 457 | - $.ajax({ | |
| 458 | - url: '/user/isRealName', | |
| 459 | - type: 'POST', | |
| 460 | - async: false, | |
| 461 | - success: function (result,status,xhr) { | |
| 462 | - if (result.data == 0) { | |
| 463 | - $.get('/pages/permission/user/jobCode.html', function (content) { | |
| 464 | - layer.open({ | |
| 465 | - type: 1, | |
| 466 | - area: ['600px', '360px'], | |
| 467 | - content: content, | |
| 468 | - title: '设置工号(后期统一登录平台接入)', | |
| 469 | - shift: 5, | |
| 470 | - scrollbar: false, | |
| 471 | - success: function () { | |
| 472 | - } | |
| 473 | - }); | |
| 474 | - }); | |
| 475 | - } | |
| 476 | - } | |
| 477 | - }); | |
| 478 | - | |
| 479 | - $.get('/user/currentUser', function (user) { | |
| 480 | - $('#indexTopUName').text(user.userName); | |
| 481 | - }); | |
| 482 | - | |
| 483 | - //带 data-pjax 的链接由pjax加载 | |
| 484 | - $(document).pjax('a[data-pjax]', pjaxContainer); | |
| 485 | - | |
| 486 | - //pjax左菜单点击事件 | |
| 487 | - $(document).on('click', '#leftMenuSidebar a[data-pjax]', function () { | |
| 488 | - setTitle(this); | |
| 489 | - | |
| 490 | - $('#leftMenuSidebar li.nav-item.active').removeClass('active'); | |
| 491 | - $(this).parent().addClass('active'); | |
| 492 | - showPjax(); | |
| 493 | - }); | |
| 494 | - | |
| 495 | - //angularjs左菜单点击事件 | |
| 496 | - $(document).on('click', '#leftMenuSidebar a[data-angularjs]', function () { | |
| 497 | - setTitle(this); | |
| 498 | - | |
| 499 | - $('#leftMenuSidebar li.nav-item.active').removeClass('active'); | |
| 500 | - $(this).parent().addClass('active'); | |
| 501 | - showAngJs(); | |
| 502 | - }); | |
| 503 | - | |
| 504 | - //加载左菜单栏 | |
| 505 | - $get('/module/findByCurrentUser', null, | |
| 506 | - function (ms) { | |
| 507 | - var treeArray = createTreeData(ms); | |
| 508 | - treeArray.sort(function (a, b) { | |
| 509 | - return a.createDate - b.createDate; | |
| 510 | - }); | |
| 511 | - var menuHtml = template('menu_list_temp', {list: treeArray}); | |
| 512 | - $('#leftMenuSidebar').html(menuHtml); | |
| 513 | - | |
| 514 | - //----------- 检查URL ---------------- | |
| 515 | - var h = location.hash; | |
| 516 | - if (initFragment && initFragment != '') { | |
| 517 | - showPjax(); | |
| 518 | - //普通片段 | |
| 519 | - loadPage(initFragment); | |
| 520 | - //选中菜单 | |
| 521 | - $.each($('#leftMenuSidebar a'), function (i, item) { | |
| 522 | - if (urlPattern($(item).attr('href'), initFragment)) { | |
| 523 | - activeLeftMenu(item); | |
| 524 | - } | |
| 525 | - }); | |
| 526 | - } else if (h) { | |
| 527 | - //angularjs片段 | |
| 528 | - showAngJs(); | |
| 529 | - //选中菜单 | |
| 530 | - $.each($('#leftMenuSidebar a'), function (i, item) { | |
| 531 | - if ($(item).attr('href') == h) { | |
| 532 | - activeLeftMenu(item); | |
| 533 | - } | |
| 534 | - }); | |
| 535 | - } | |
| 536 | - else { | |
| 537 | - //加载主页 | |
| 538 | - loadPage('/pages/home.html'); | |
| 539 | - } | |
| 540 | - }); | |
| 541 | - | |
| 542 | - //修改密码 | |
| 543 | - $('#changePWD').on('click', function () { | |
| 544 | - $.get('/pages/permission/user/changePWD.html', function (content) { | |
| 545 | - layer.open({ | |
| 546 | - type: 1, | |
| 547 | - area: ['600px', '360px'], | |
| 548 | - content: content, | |
| 549 | - title: '修改密码', | |
| 550 | - shift: 5, | |
| 551 | - scrollbar: false, | |
| 552 | - success: function () { | |
| 553 | - } | |
| 554 | - }); | |
| 555 | - }); | |
| 556 | - }); | |
| 557 | - }); | |
| 558 | - | |
| 559 | - //modal关闭时销毁dom | |
| 560 | - $(document).on('hidden.bs.modal', '.modal', function () { | |
| 561 | - $(this).remove(); | |
| 562 | - }); | |
| 563 | - | |
| 564 | - //pjax加载完成事件 | |
| 565 | - $(document).on('pjax:success', function () { | |
| 566 | - var dicts = $(pjaxContainer).find('.nt-dictionary'); | |
| 567 | - dictionaryUtils.transformDom(dicts); | |
| 568 | - }); | |
| 569 | - | |
| 570 | - function loadPage(url) { | |
| 571 | - $.pjax({url: url, container: pjaxContainer}) | |
| 572 | - } | |
| 573 | - | |
| 574 | - function urlPattern(a, b) { | |
| 575 | - var r; | |
| 576 | - try { | |
| 577 | - r = a.substring(0, a.lastIndexOf('/')) == b.substring(0, b.lastIndexOf('/')); | |
| 578 | - } catch (e) { | |
| 579 | - r = false; | |
| 580 | - } | |
| 581 | - return r; | |
| 582 | - } | |
| 583 | - | |
| 584 | - function showPjax() { | |
| 585 | - $(angJsContainer).removeClass('page-content active').hide(); | |
| 586 | - $(pjaxContainer).addClass('page-content active'); | |
| 587 | - } | |
| 588 | - | |
| 589 | - function showAngJs() { | |
| 590 | - $(pjaxContainer).html('').removeClass('page-content active').hide(); | |
| 591 | - $(angJsContainer).addClass('page-content active'); | |
| 592 | - } | |
| 593 | - | |
| 594 | - function activeLeftMenu(item) { | |
| 595 | - $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open'); | |
| 596 | - setTitle(item); | |
| 597 | - } | |
| 598 | - | |
| 599 | - function setTitle(menuItem){ | |
| 600 | - document.title = $('span.title', menuItem).text(); | |
| 601 | - } | |
| 602 | - | |
| 603 | -</script> | |
| 604 | -<!-- d3 --> | |
| 605 | -<script src="/assets/js/d3.min.js" data-exclude=1></script> | |
| 606 | -<!-- webSocket JS --> | |
| 607 | -<script src="/assets/js/sockjs.min.js"></script> | |
| 608 | - | |
| 609 | -<!-- TODO:angularJS相关库 --> | |
| 610 | - | |
| 611 | -<!-- angularJS相关库 --> | |
| 612 | -<!-- 这个是基于angularjs 1.4.10修改的版本,主要是修改了history控制部分,用于兼容route和pjax的同时操作history的冲突 --> | |
| 613 | -<script src="/assets/js/angular.js" data-autocephaly=1></script> | |
| 614 | -<script src="/assets/bower_components/angular-i18n/angular-locale_zh-cn.js" data-autocephaly=1></script> | |
| 615 | -<script | |
| 616 | - src="/assets/bower_components/angular-resource/angular-resource.min.js" | |
| 617 | - data-exclude=1></script> | |
| 618 | -<script | |
| 619 | - src="/assets/bower_components/angular-sanitize/angular-sanitize.min.js" | |
| 620 | - data-exclude=1></script> | |
| 621 | -<script | |
| 622 | - src="/assets/bower_components/angular-animate/angular-animate.min.js" | |
| 623 | - data-exclude=1></script> | |
| 624 | -<script | |
| 625 | - src="/assets/bower_components/angular-touch/angular-touch.min.js" | |
| 626 | - data-exclude=1></script> | |
| 627 | -<script | |
| 628 | - src="/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js" | |
| 629 | - data-exclude=1></script> | |
| 630 | -<script | |
| 631 | - src="/assets/bower_components/oclazyload/dist/ocLazyLoad.min.js" | |
| 632 | - data-exclude=1></script> | |
| 633 | -<script | |
| 634 | - src="/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js" | |
| 635 | - data-exclude=1></script> | |
| 636 | -<!-- handsontable相关js --> | |
| 637 | -<script | |
| 638 | - src="/assets/bower_components/handsontable/dist/handsontable.full.js"></script> | |
| 639 | -<script | |
| 640 | - src="/assets/bower_components/ngHandsontable/dist/ngHandsontable.js"></script> | |
| 641 | -<!-- sweetalert相关js --> | |
| 642 | -<script src="/assets/bower_components/sweetalert/dist/sweetalert.min.js"></script> | |
| 643 | -<script src="/assets/bower_components/ng-sweet-alert/ng-sweet-alert.js"></script> | |
| 644 | - | |
| 645 | -<!-- schedule计划调度AngularJS模块主JS --> | |
| 646 | -<script src="/pages/scheduleApp/module/common/main.js" data-exclude=1></script> | |
| 647 | -<script | |
| 648 | - src="/pages/scheduleApp/module/common/prj-common-globalservice.js" | |
| 649 | - data-exclude=1></script> | |
| 650 | -<script src="/pages/scheduleApp/module/common/prj-common-filter.js" | |
| 651 | - data-exclude=1></script> | |
| 652 | -<script src="/pages/scheduleApp/module/common/prj-common-directive.js" | |
| 653 | - data-exclude=1></script> | |
| 654 | -<script | |
| 655 | - src="/pages/scheduleApp/module/common/prj-common-ui-route-state.js" | |
| 656 | - data-exclude=1></script> | |
| 657 | - | |
| 658 | -<!-- 地图相关 --> | |
| 659 | -<!-- 百度 --> | |
| 660 | -<script | |
| 661 | - src="//api.map.baidu.com/api?v=3.0&ak=IGGrr4UjwIYzatoCRFKEL8sT" | |
| 662 | - data-exclude=1></script> | |
| 663 | -<script | |
| 664 | - src="//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js" | |
| 665 | - data-exclude=1></script> | |
| 666 | -<script type="text/javascript" | |
| 667 | - src="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js" | |
| 668 | - data-exclude=1></script> | |
| 669 | -<script type="text/javascript" | |
| 670 | - src="//api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js " | |
| 671 | - data-exclude=1></script> | |
| 672 | -<script src="/assets/js/baidu/TextIconOverlay.js" data-exclude=1></script> | |
| 673 | -<script src="/assets/js/baidu//MarkerClusterer.js" data-exclude=1></script> | |
| 674 | -<!-- 高德 --> | |
| 675 | -<script | |
| 676 | - src="//webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda" | |
| 677 | - data-exclude=1></script> | |
| 678 | -<!-- echarts4 --> | |
| 679 | -<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script> | |
| 680 | -<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | |
| 681 | -<!-- RSA加密 --> | |
| 682 | -<script src="/assets/plugins/jsencrypt.min.js"></script> | |
| 683 | -<script src="/assets/js/eventproxy.js"></script> | |
| 684 | -<!-- 线路路由信息操作 --> | |
| 685 | -<script src="/pages/base/stationroute/js/routes-operation.js"></script> | |
| 686 | -<script src="/pages/base/stationroute/js/routes-service.js"></script> | |
| 687 | -<script src="/assets/js/CoordinateConverter.js"></script> | |
| 688 | -</body> | |
| 1 | +<!DOCTYPE html> | |
| 2 | +<html lang="zh"> | |
| 3 | +<head> | |
| 4 | + <meta name="renderer" content="webkit" /> | |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
| 6 | + <meta charset="UTF-8"> | |
| 7 | + <title>调度系统</title> | |
| 8 | + | |
| 9 | + <meta http-equiv="Pragma" content="no-cache"> | |
| 10 | + <meta http-equiv="Cache-control" content="no-cache"> | |
| 11 | + <meta http-equiv="Cache" content="no-cache"> | |
| 12 | + | |
| 13 | + <!-- Font Awesome 图标字体 --> | |
| 14 | + <link | |
| 15 | + href="/metronic_v4.5.4/plugins/font-awesome/css/font-awesome.min.css" | |
| 16 | + rel="stylesheet" type="text/css" /> | |
| 17 | + <!-- Bootstrap style --> | |
| 18 | + <link href="/metronic_v4.5.4/plugins/bootstrap/css/bootstrap.min.css" | |
| 19 | + rel="stylesheet" type="text/css" /> | |
| 20 | + <!-- jsTree 数插件 --> | |
| 21 | + <link | |
| 22 | + href="/metronic_v4.5.4/plugins/jstree/dist/themes/default/style.min.css" | |
| 23 | + rel="stylesheet" type="text/css" /> | |
| 24 | + <!-- MULTI-select 多选下拉框美化 --> | |
| 25 | + <link | |
| 26 | + href="/metronic_v4.5.4/plugins/jquery-multi-select/css/multi-select.css" | |
| 27 | + rel="stylesheet" type="text/css" /> | |
| 28 | + | |
| 29 | + <!-- editable --> | |
| 30 | + <link | |
| 31 | + href="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/css/bootstrap-editable.css" | |
| 32 | + rel="stylesheet" type="text/css" /> | |
| 33 | + <!-- METRONIC style --> | |
| 34 | + <link href="/metronic_v4.5.4/layout4/css/themes/light.min.css" | |
| 35 | + rel="stylesheet" type="text/css" id="style_color" /> | |
| 36 | + <link href="/metronic_v4.5.4/css/components.css" rel="stylesheet" | |
| 37 | + type="text/css" /> | |
| 38 | + <link href="/metronic_v4.5.4/css/plugins.css" rel="stylesheet" | |
| 39 | + type="text/css" /> | |
| 40 | + <link href="/metronic_v4.5.4/layout4/css/layout.min.css" | |
| 41 | + rel="stylesheet" type="text/css" /> | |
| 42 | + <link href="/metronic_v4.5.4/layout4/css/custom.min.css" | |
| 43 | + rel="stylesheet" type="text/css" /> | |
| 44 | + <!-- select2 下拉框插件 --> | |
| 45 | + <link href="/metronic_v4.5.4/plugins/select2/css/select2.min.css" | |
| 46 | + rel="stylesheet" type="text/css" /> | |
| 47 | + <link | |
| 48 | + href="/metronic_v4.5.4/plugins/select2/css/select2-bootstrap.min.css" | |
| 49 | + rel="stylesheet" type="text/css" /> | |
| 50 | + <!-- layer 弹层 插件 --> | |
| 51 | + <link href="/assets/plugins/layer-v2.4/layer/skin/layer.css" | |
| 52 | + rel="stylesheet" type="text/css" /> | |
| 53 | + <!-- fileinput 上传 插件 --> | |
| 54 | + <link href="/assets/plugins/fileinput/css/fileinput.min.css" | |
| 55 | + rel="stylesheet" type="text/css" /> | |
| 56 | + <!-- iCheck 单选框和复选框 --> | |
| 57 | + <link href="/metronic_v4.5.4/plugins/icheck/skins/all.css" | |
| 58 | + rel="stylesheet" type="text/css" /> | |
| 59 | + <!-- 日期控件 --> | |
| 60 | + <link | |
| 61 | + href="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/css/bootstrap-datetimepicker.min.css" | |
| 62 | + rel="stylesheet" type="text/css" /> | |
| 63 | + <!-- table 表格控件 --> | |
| 64 | + <!--<link rel="stylesheet"--> | |
| 65 | + <!--href="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css"--> | |
| 66 | + <!--type="text/css" />--> | |
| 67 | + <link href="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.css" rel="stylesheet" type="text/css"/> | |
| 68 | + <!-- handsontable样式 --> | |
| 69 | + <link rel="stylesheet" | |
| 70 | + href="/assets/bower_components/handsontable/dist/handsontable.full.css" /> | |
| 71 | + <!-- sweetalert样式 --> | |
| 72 | + <link rel="stylesheet" | |
| 73 | + href="/assets/bower_components/sweetalert/dist/sweetalert.css" /> | |
| 74 | + <!-- schedule计划调度AngularJS模块主css --> | |
| 75 | + <link rel="stylesheet" href="/pages/scheduleApp/module/common/main.css" | |
| 76 | + type="text/css" /> | |
| 77 | + <link rel="stylesheet" href="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.css" merge="plugins"/> | |
| 78 | + | |
| 79 | + <!-- CSS动画 --> | |
| 80 | + <link | |
| 81 | + href="/metronic_v4.5.4/plugins/tipso/css/animate.css" | |
| 82 | + rel="stylesheet" type="text/css" /> | |
| 83 | + | |
| 84 | + <!-- 提示工具样式 --> | |
| 85 | + <link | |
| 86 | + href="/metronic_v4.5.4/plugins/tipso/css/tipso.css" | |
| 87 | + rel="stylesheet" type="text/css" /> | |
| 88 | + | |
| 89 | + <style type="text/css"> | |
| 90 | + .searchForm { | |
| 91 | + | |
| 92 | + } | |
| 93 | + | |
| 94 | + .searchForm .form-group .control-label { | |
| 95 | + padding-right: 0px; | |
| 96 | + text-align: right; | |
| 97 | + margin-top: 7px; | |
| 98 | + } | |
| 99 | + | |
| 100 | + .searchForm .form-group>div { | |
| 101 | + padding-left: 10px; | |
| 102 | + padding-right: 0px; | |
| 103 | + } | |
| 104 | + | |
| 105 | + .searchForm .row>div { | |
| 106 | + padding-left: 0px; | |
| 107 | + padding-right: 0px; | |
| 108 | + padding: 5px 0 5px 0; | |
| 109 | + width: 270px; | |
| 110 | + display: inline-block; | |
| 111 | + } | |
| 112 | + | |
| 113 | + .searchForm .form-actions { | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 117 | + tr.row-active td { | |
| 118 | + border-bottom: 1px solid blue !important; | |
| 119 | + color: blue; | |
| 120 | + } | |
| 121 | + | |
| 122 | + .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection | |
| 123 | + { | |
| 124 | + font-size: 14px; | |
| 125 | + } | |
| 126 | + | |
| 127 | + .ms-container .ms-selectable li.ms-elem-selectable,.ms-container .ms-selection li.ms-elem-selection | |
| 128 | + { | |
| 129 | + padding: 6px 26px; | |
| 130 | + } | |
| 131 | + | |
| 132 | + .ms-container .ms-list { | |
| 133 | + height: 306px; | |
| 134 | + } | |
| 135 | + | |
| 136 | + .ms-container .ms-selectable,.ms-container .ms-selection { | |
| 137 | + width: 47%; | |
| 138 | + } | |
| 139 | + | |
| 140 | + .ms-container { | |
| 141 | + width: 470px; | |
| 142 | + margin: auto; | |
| 143 | + } | |
| 144 | + | |
| 145 | + .multi-custom-header-left { | |
| 146 | + text-align: center; | |
| 147 | + padding: 7px; | |
| 148 | + color: #3B3F51; | |
| 149 | + } | |
| 150 | + | |
| 151 | + .multi-custom-header-right { | |
| 152 | + text-align: center; | |
| 153 | + padding: 7px; | |
| 154 | + font-weight: bold; | |
| 155 | + color: #36C6D3; | |
| 156 | + } | |
| 157 | + | |
| 158 | + .mt-element-list .list-simple.mt-list-container ul>.mt-list-item>.list-item-content | |
| 159 | + { | |
| 160 | + padding: 0 55px 0 0px; | |
| 161 | + } | |
| 162 | + | |
| 163 | + .mt-element-list .list-simple.mt-list-container ul>.mt-list-item { | |
| 164 | + padding: 3.3px 0; | |
| 165 | + } | |
| 166 | + | |
| 167 | + #route-container { | |
| 168 | + display: none; | |
| 169 | + } | |
| 170 | + | |
| 171 | + .page-content.active { | |
| 172 | + display: block !important; | |
| 173 | + } | |
| 174 | + | |
| 175 | + .page-header.navbar .page-logo .logo-default { | |
| 176 | + margin: 0; | |
| 177 | + } | |
| 178 | + | |
| 179 | + .page-header.navbar .top-menu .navbar-nav>li.dropdown.open .dropdown-toggle | |
| 180 | + { | |
| 181 | + background-color: #284a99; | |
| 182 | + } | |
| 183 | + | |
| 184 | + .page-header.navbar .page-logo { | |
| 185 | + padding-right: 10px; | |
| 186 | + } | |
| 187 | + | |
| 188 | + .page-logo .logo-default.logo-default-text { | |
| 189 | + font-weight: 600; | |
| 190 | + color: white !important; | |
| 191 | + margin-top: 19px !important; | |
| 192 | + font-size: 24px; | |
| 193 | + text-decoration: none; | |
| 194 | + } | |
| 195 | + | |
| 196 | + .page-logo .logo-default.logo-default-text:HOVER { | |
| 197 | + color: #dedede !important; | |
| 198 | + } | |
| 199 | + | |
| 200 | + body,.page-content-wrapper,#pjax-container{ | |
| 201 | + height: 100%; | |
| 202 | + } | |
| 203 | + html{ | |
| 204 | + height: 90%; | |
| 205 | + } | |
| 206 | + .page-container{ | |
| 207 | + height: 100%; | |
| 208 | + } | |
| 209 | + </style> | |
| 210 | + | |
| 211 | + <!-- ocLazyLoading载入文件的位置 --> | |
| 212 | + <link id="ng_load_plugins_before" /> | |
| 213 | + | |
| 214 | +</head> | |
| 215 | +<body | |
| 216 | + class="page-container-bg-solid page-header-fixed page-sidebar-closed-hide-logo page-sidebar-fixed"> | |
| 217 | +<div class="page-header navbar navbar-fixed-top" | |
| 218 | + style="background: linear-gradient(to bottom, #124e78, #125688);"> | |
| 219 | + <div class="page-header-inner "> | |
| 220 | + <!-- LOGO --> | |
| 221 | + <div class="page-logo"> | |
| 222 | + <a href="index.html" class="logo-default logo-default-text"> | |
| 223 | + 浦东公交调度系统 </a> | |
| 224 | + <div class="menu-toggler sidebar-toggler"></div> | |
| 225 | + </div> | |
| 226 | + <!-- END LOGO --> | |
| 227 | + <a href="javascript:;" class="menu-toggler responsive-toggler" | |
| 228 | + data-toggle="collapse" data-target=".navbar-collapse"> </a> | |
| 229 | + <div class="page-top"> | |
| 230 | + <div class="top-menu"> | |
| 231 | + <ul class="nav navbar-nav pull-right"> | |
| 232 | + <!-- 信息通知区 --> | |
| 233 | + <li | |
| 234 | + class="dropdown dropdown-extended dropdown-notification dropdown-dark" | |
| 235 | + id="header_notification_bar"><a href="javascript:;" | |
| 236 | + class="dropdown-toggle" data-toggle="dropdown" | |
| 237 | + data-hover="dropdown" data-close-others="true"> <i | |
| 238 | + class="fa fa-bell"></i> <span class="badge badge-success"> | |
| 239 | + 0 </span> | |
| 240 | + </a> | |
| 241 | + <ul class="dropdown-menu" style="max-width: 345px; width: 345px;"> | |
| 242 | + <li class="external"> | |
| 243 | + <h3> | |
| 244 | + 今日 <span class="bold">0 条</span> 通知 | |
| 245 | + </h3> <a href="javascript:;">查看全部</a> | |
| 246 | + </li> | |
| 247 | + <li> | |
| 248 | + <ul class="dropdown-menu-list scroller" style="height: 250px;" | |
| 249 | + data-handle-color="#637283"> | |
| 250 | + </ul> | |
| 251 | + </li> | |
| 252 | + </ul></li> | |
| 253 | + <li class="dropdown dropdown-user dropdown-dark"><a | |
| 254 | + href="javascript:;" class="dropdown-toggle" | |
| 255 | + data-toggle="dropdown" data-hover="dropdown" | |
| 256 | + data-close-others="true"> <span id="indexTopUName" | |
| 257 | + class="username username-hide-on-mobile" | |
| 258 | + style="vertical-align: middle;"> <i class="fa fa-user"></i></span> | |
| 259 | + </a> | |
| 260 | + <ul class="dropdown-menu dropdown-menu-default"> | |
| 261 | + <li><a href="javascript:;"> <i class="fa fa-user"></i> | |
| 262 | + 我的信息 | |
| 263 | + </a></li> | |
| 264 | + <li><a href="javascript:;" id="changePWD"> <i | |
| 265 | + class="fa fa-unlock-alt"></i> 修改密码 | |
| 266 | + </a></li> | |
| 267 | + <li class="divider"></li> | |
| 268 | + <li><a href="javascript:;"> <i class="fa fa-lock"></i> | |
| 269 | + 锁屏 | |
| 270 | + </a></li> | |
| 271 | + <li><a href="/logout"> <i class="fa fa-key"></i> 注销登陆 | |
| 272 | + </a></li> | |
| 273 | + </ul></li> | |
| 274 | + </ul> | |
| 275 | + </div> | |
| 276 | + </div> | |
| 277 | + </div> | |
| 278 | +</div> | |
| 279 | +<div class="page-container"> | |
| 280 | + <div class="page-sidebar-wrapper"> | |
| 281 | + <div class="page-sidebar navbar-collapse collapse"> | |
| 282 | + <ul class="page-sidebar-menu page-sidebar-menu-fixed" | |
| 283 | + data-keep-expanded="false" data-auto-scroll="true" | |
| 284 | + data-slide-speed="200" id="leftMenuSidebar"> | |
| 285 | + </ul> | |
| 286 | + </div> | |
| 287 | + </div> | |
| 288 | + <div class="page-content-wrapper"> | |
| 289 | + <div id="pjax-container" class="page-content"></div> | |
| 290 | + | |
| 291 | + <div id="route-container"> | |
| 292 | + <div ng-app="ScheduleApp"> | |
| 293 | + <div ng-controller="ScheduleAppController"> | |
| 294 | + | |
| 295 | + <!-- loading widget --> | |
| 296 | + <div id="loadingWidget" class="flyover mask" loading-widget> | |
| 297 | + <div class="alert alert-info"> | |
| 298 | + <strong>载入中......</strong> | |
| 299 | + </div> | |
| 300 | + </div> | |
| 301 | + | |
| 302 | + <div ui-view class="uv"></div> | |
| 303 | + </div> | |
| 304 | + </div> | |
| 305 | + </div> | |
| 306 | + </div> | |
| 307 | +</div> | |
| 308 | + | |
| 309 | +<script id="menu_list_temp" type="text/html"> | |
| 310 | + {{each list as group i}} | |
| 311 | + <li class="heading"> | |
| 312 | + <h3 class="uppercase">{{group.name}}</h3> | |
| 313 | + </li> | |
| 314 | + {{each group.children as dir j}} | |
| 315 | + <li class="nav-item"> | |
| 316 | + <a href="javascript:;" class="nav-link nav-toggle "> | |
| 317 | + <i class="{{dir.icon}}"></i> | |
| 318 | + <span class="title">{{dir.name}}</span> | |
| 319 | + <span class="arrow"></span> | |
| 320 | + </a> | |
| 321 | + <ul class="sub-menu"> | |
| 322 | + {{each dir.children as module s}} | |
| 323 | + <li class="nav-item "> | |
| 324 | + {{if module.container=="pjax-container"}} | |
| 325 | + <a href="/pages/{{module.path}}" class="nav-link " data-pjax> | |
| 326 | + <span class="title">{{module.name}}</span> | |
| 327 | + </a> | |
| 328 | + {{else}} | |
| 329 | + <a href="{{module.path}}" class="nav-link " data-angularjs> | |
| 330 | + <span class="title">{{module.name}}</span> | |
| 331 | + </a> | |
| 332 | + {{/if}} | |
| 333 | + </li> | |
| 334 | + {{/each}} | |
| 335 | + </ul> | |
| 336 | + </li> | |
| 337 | + {{/each}} | |
| 338 | + {{/each}} | |
| 339 | + | |
| 340 | +</script> | |
| 341 | +<script> | |
| 342 | + delete window.require; | |
| 343 | + delete window.exports; | |
| 344 | + delete window.module; | |
| 345 | +</script> | |
| 346 | +<!-- jQuery --> | |
| 347 | +<script src="/metronic_v4.5.4/plugins/jquery.min.js" data-exclude=1></script> | |
| 348 | +<!-- bootstrap --> | |
| 349 | +<script src="/metronic_v4.5.4/plugins/bootstrap/js/bootstrap.min.js" | |
| 350 | + data-exclude=1></script> | |
| 351 | +<script src="/pages/forms/statement/js/jquery.autocompleter.js"></script> | |
| 352 | +<script src="/pages/forms/statement/js/jquery.PrintArea.js"></script> | |
| 353 | +<!-- MTRONIC JS --> | |
| 354 | +<script src="/metronic_v4.5.4/scripts/app.min.js" data-exclude=1></script> | |
| 355 | +<script src="/metronic_v4.5.4/layout4/scripts/layout.min.js" | |
| 356 | + data-exclude=1></script> | |
| 357 | +<!-- 虚拟滚动条 --> | |
| 358 | +<script | |
| 359 | + src="/metronic_v4.5.4/plugins/jquery-slimscroll/jquery.slimscroll.min.js"></script> | |
| 360 | +<!-- jsTree 树插件 --> | |
| 361 | +<script src="/metronic_v4.5.4/plugins/jstree/dist/jstree.min.js"></script> | |
| 362 | +<!-- bootstrap-hover-dropDown --> | |
| 363 | +<script | |
| 364 | + src="/metronic_v4.5.4/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"></script> | |
| 365 | +<!-- jquery.validate 表单验证 --> | |
| 366 | +<script | |
| 367 | + src="/metronic_v4.5.4/plugins/jquery-validation/js/jquery.validate.min.js"></script> | |
| 368 | +<script | |
| 369 | + src="/metronic_v4.5.4/plugins/jquery-validation/js/localization/messages_zh.js"></script> | |
| 370 | +<!-- 向导式插件 --> | |
| 371 | +<script | |
| 372 | + src="/metronic_v4.5.4//plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script> | |
| 373 | +<!-- iCheck 单选框和复选框 --> | |
| 374 | +<script src="/metronic_v4.5.4/plugins/icheck/icheck.min.js"></script> | |
| 375 | +<!-- select2 下拉框 --> | |
| 376 | +<script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script> | |
| 377 | +<!-- MULTI SELECT 多选下拉框 --> | |
| 378 | +<script | |
| 379 | + src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script> | |
| 380 | +<!-- editable.js --> | |
| 381 | +<script | |
| 382 | + src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script> | |
| 383 | +<!-- PJAX --> | |
| 384 | +<script src="/assets/plugins/jquery.pjax.js"></script> | |
| 385 | +<!-- layer 弹层 --> | |
| 386 | +<script src="/assets/plugins/layer-v2.4/layer/layer.js" data-exclude=1></script> | |
| 387 | +<!-- fileinput 上传 --> | |
| 388 | +<script src="/assets/plugins/fileinput/canvas-to-blob.min.js"></script> | |
| 389 | +<script src="/assets/plugins/fileinput/purify.min.js"></script> | |
| 390 | +<script src="/assets/plugins/fileinput/sortable.min.js"></script> | |
| 391 | +<script src="/assets/plugins/fileinput/fileinput.min.js"></script> | |
| 392 | +<script src="/assets/plugins/fileinput/fileinput_locale_zh.js"></script> | |
| 393 | +<!-- jquery.purl URL解析 --> | |
| 394 | +<script src="/assets/plugins/purl.js"></script> | |
| 395 | +<!-- jquery.serializejson JSON序列化插件 --> | |
| 396 | +<script src="/assets/plugins/jquery.serializejson.js"></script> | |
| 397 | +<!-- art-template 模版引擎 --> | |
| 398 | +<script src="/assets/plugins/template.js"></script> | |
| 399 | +<!-- jquery.pageinator 分页 --> | |
| 400 | +<script src="/assets/plugins/jqPaginator.min.js"></script> | |
| 401 | +<!-- moment.js 日期处理类库 --> | |
| 402 | +<script src="/assets/plugins/moment-with-locales.js"></script> | |
| 403 | + | |
| 404 | +<script src="/assets/plugins/pinyin.js"></script> | |
| 405 | +<!-- 日期控件 --> | |
| 406 | +<script | |
| 407 | + src="/metronic_v4.5.4/plugins/bootstrap-datetimepicker-2/js/bootstrap-datetimepicker.min.js"></script> | |
| 408 | +<!-- 表格控件 --> | |
| 409 | +<script src="/metronic_v4.5.4/plugins/bootstrap-tagsinput/bootstrap-tagsinput.min.js"></script> | |
| 410 | +<!-- 统计图控件 --> | |
| 411 | +<!--<script src="/assets/global/getEchart.js"></script> | |
| 412 | +<script src="/assets/global/echarts.js"></script> --> | |
| 413 | +<script src="/assets/js/common.js"></script> | |
| 414 | +<script src="/assets/js/dictionary.js"></script> | |
| 415 | +<!-- tipso JS --> | |
| 416 | +<script src="/metronic_v4.5.4/plugins/tipso/js/tipso.js"></script> | |
| 417 | +<script data-exclude=1> | |
| 418 | + //初始打开的片段地址 | |
| 419 | + var initFragment = "^_^initFragment^_^"; | |
| 420 | + //静态文件目录 | |
| 421 | + var dir = '/pages/'; | |
| 422 | + //片段容器 | |
| 423 | + var pjaxContainer = '#pjax-container' | |
| 424 | + , angJsContainer = '#route-container'; | |
| 425 | + | |
| 426 | + $(document).ajaxError(function (event, jqxhr, settings, thrownError) { | |
| 427 | + if(jqxhr.status == 403){ | |
| 428 | + layer.closeAll(); | |
| 429 | + layer.alert(jqxhr.message?jqxhr.message:'访问被拒绝', {icon: 2, title: '操作失败'}); | |
| 430 | + } | |
| 431 | + }); | |
| 432 | + | |
| 433 | + $(function () { | |
| 434 | + $.ajax({ | |
| 435 | + url: '/user/isWeakCipher', | |
| 436 | + type: 'POST', | |
| 437 | + async: false, | |
| 438 | + success: function (result,status,xhr) { | |
| 439 | + if (result.data == 1) { | |
| 440 | + $.get('/pages/permission/user/forceChangePWD.html', function (content) { | |
| 441 | + layer.open({ | |
| 442 | + type: 1, | |
| 443 | + area: ['600px', '360px'], | |
| 444 | + content: content, | |
| 445 | + title: '修改密码', | |
| 446 | + shift: 5, | |
| 447 | + scrollbar: false, | |
| 448 | + closeBtn: 0, | |
| 449 | + success: function () { | |
| 450 | + } | |
| 451 | + }); | |
| 452 | + }); | |
| 453 | + } | |
| 454 | + } | |
| 455 | + }); | |
| 456 | + | |
| 457 | + $.ajax({ | |
| 458 | + url: '/user/isRealName', | |
| 459 | + type: 'POST', | |
| 460 | + async: false, | |
| 461 | + success: function (result,status,xhr) { | |
| 462 | + if (result.data == 0) { | |
| 463 | + $.get('/pages/permission/user/jobCode.html', function (content) { | |
| 464 | + layer.open({ | |
| 465 | + type: 1, | |
| 466 | + area: ['600px', '360px'], | |
| 467 | + content: content, | |
| 468 | + title: '设置工号(后期统一登录平台接入)', | |
| 469 | + shift: 5, | |
| 470 | + scrollbar: false, | |
| 471 | + success: function () { | |
| 472 | + } | |
| 473 | + }); | |
| 474 | + }); | |
| 475 | + } | |
| 476 | + } | |
| 477 | + }); | |
| 478 | + | |
| 479 | + $.get('/user/currentUser', function (user) { | |
| 480 | + $('#indexTopUName').text(user.userName); | |
| 481 | + }); | |
| 482 | + | |
| 483 | + //带 data-pjax 的链接由pjax加载 | |
| 484 | + $(document).pjax('a[data-pjax]', pjaxContainer); | |
| 485 | + | |
| 486 | + //pjax左菜单点击事件 | |
| 487 | + $(document).on('click', '#leftMenuSidebar a[data-pjax]', function () { | |
| 488 | + setTitle(this); | |
| 489 | + | |
| 490 | + $('#leftMenuSidebar li.nav-item.active').removeClass('active'); | |
| 491 | + $(this).parent().addClass('active'); | |
| 492 | + showPjax(); | |
| 493 | + }); | |
| 494 | + | |
| 495 | + //angularjs左菜单点击事件 | |
| 496 | + $(document).on('click', '#leftMenuSidebar a[data-angularjs]', function () { | |
| 497 | + setTitle(this); | |
| 498 | + | |
| 499 | + $('#leftMenuSidebar li.nav-item.active').removeClass('active'); | |
| 500 | + $(this).parent().addClass('active'); | |
| 501 | + showAngJs(); | |
| 502 | + }); | |
| 503 | + | |
| 504 | + //加载左菜单栏 | |
| 505 | + $get('/module/findByCurrentUser', null, | |
| 506 | + function (ms) { | |
| 507 | + var treeArray = createTreeData(ms); | |
| 508 | + treeArray.sort(function (a, b) { | |
| 509 | + return a.createDate - b.createDate; | |
| 510 | + }); | |
| 511 | + var menuHtml = template('menu_list_temp', {list: treeArray}); | |
| 512 | + $('#leftMenuSidebar').html(menuHtml); | |
| 513 | + | |
| 514 | + //----------- 检查URL ---------------- | |
| 515 | + var h = location.hash; | |
| 516 | + if (initFragment && initFragment != '') { | |
| 517 | + showPjax(); | |
| 518 | + //普通片段 | |
| 519 | + loadPage(initFragment); | |
| 520 | + //选中菜单 | |
| 521 | + $.each($('#leftMenuSidebar a'), function (i, item) { | |
| 522 | + if (urlPattern($(item).attr('href'), initFragment)) { | |
| 523 | + activeLeftMenu(item); | |
| 524 | + } | |
| 525 | + }); | |
| 526 | + } else if (h) { | |
| 527 | + //angularjs片段 | |
| 528 | + showAngJs(); | |
| 529 | + //选中菜单 | |
| 530 | + $.each($('#leftMenuSidebar a'), function (i, item) { | |
| 531 | + if ($(item).attr('href') == h) { | |
| 532 | + activeLeftMenu(item); | |
| 533 | + } | |
| 534 | + }); | |
| 535 | + } | |
| 536 | + else { | |
| 537 | + //加载主页 | |
| 538 | + loadPage('/pages/home.html'); | |
| 539 | + } | |
| 540 | + }); | |
| 541 | + | |
| 542 | + //修改密码 | |
| 543 | + $('#changePWD').on('click', function () { | |
| 544 | + $.get('/pages/permission/user/changePWD.html', function (content) { | |
| 545 | + layer.open({ | |
| 546 | + type: 1, | |
| 547 | + area: ['600px', '360px'], | |
| 548 | + content: content, | |
| 549 | + title: '修改密码', | |
| 550 | + shift: 5, | |
| 551 | + scrollbar: false, | |
| 552 | + success: function () { | |
| 553 | + } | |
| 554 | + }); | |
| 555 | + }); | |
| 556 | + }); | |
| 557 | + }); | |
| 558 | + | |
| 559 | + //modal关闭时销毁dom | |
| 560 | + $(document).on('hidden.bs.modal', '.modal', function () { | |
| 561 | + $(this).remove(); | |
| 562 | + }); | |
| 563 | + | |
| 564 | + //pjax加载完成事件 | |
| 565 | + $(document).on('pjax:success', function () { | |
| 566 | + var dicts = $(pjaxContainer).find('.nt-dictionary'); | |
| 567 | + dictionaryUtils.transformDom(dicts); | |
| 568 | + }); | |
| 569 | + | |
| 570 | + function loadPage(url) { | |
| 571 | + $.pjax({url: url, container: pjaxContainer}) | |
| 572 | + } | |
| 573 | + | |
| 574 | + function urlPattern(a, b) { | |
| 575 | + var r; | |
| 576 | + try { | |
| 577 | + r = a.substring(0, a.lastIndexOf('/')) == b.substring(0, b.lastIndexOf('/')); | |
| 578 | + } catch (e) { | |
| 579 | + r = false; | |
| 580 | + } | |
| 581 | + return r; | |
| 582 | + } | |
| 583 | + | |
| 584 | + function showPjax() { | |
| 585 | + $(angJsContainer).removeClass('page-content active').hide(); | |
| 586 | + $(pjaxContainer).addClass('page-content active'); | |
| 587 | + } | |
| 588 | + | |
| 589 | + function showAngJs() { | |
| 590 | + $(pjaxContainer).html('').removeClass('page-content active').hide(); | |
| 591 | + $(angJsContainer).addClass('page-content active'); | |
| 592 | + } | |
| 593 | + | |
| 594 | + function activeLeftMenu(item) { | |
| 595 | + $(item).parent('.nav-item').addClass('active').parent('.sub-menu').show().parent().addClass('open'); | |
| 596 | + setTitle(item); | |
| 597 | + } | |
| 598 | + | |
| 599 | + function setTitle(menuItem){ | |
| 600 | + document.title = $('span.title', menuItem).text(); | |
| 601 | + } | |
| 602 | + | |
| 603 | +</script> | |
| 604 | +<!-- d3 --> | |
| 605 | +<script src="/assets/js/d3.min.js" data-exclude=1></script> | |
| 606 | +<!-- webSocket JS --> | |
| 607 | +<script src="/assets/js/sockjs.min.js"></script> | |
| 608 | + | |
| 609 | +<!-- TODO:angularJS相关库 --> | |
| 610 | + | |
| 611 | +<!-- angularJS相关库 --> | |
| 612 | +<!-- 这个是基于angularjs 1.4.10修改的版本,主要是修改了history控制部分,用于兼容route和pjax的同时操作history的冲突 --> | |
| 613 | +<script src="/assets/js/angular.js" data-autocephaly=1></script> | |
| 614 | +<script src="/assets/bower_components/angular-i18n/angular-locale_zh-cn.js" data-autocephaly=1></script> | |
| 615 | +<script | |
| 616 | + src="/assets/bower_components/angular-resource/angular-resource.min.js" | |
| 617 | + data-exclude=1></script> | |
| 618 | +<script | |
| 619 | + src="/assets/bower_components/angular-sanitize/angular-sanitize.min.js" | |
| 620 | + data-exclude=1></script> | |
| 621 | +<script | |
| 622 | + src="/assets/bower_components/angular-animate/angular-animate.min.js" | |
| 623 | + data-exclude=1></script> | |
| 624 | +<script | |
| 625 | + src="/assets/bower_components/angular-touch/angular-touch.min.js" | |
| 626 | + data-exclude=1></script> | |
| 627 | +<script | |
| 628 | + src="/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js" | |
| 629 | + data-exclude=1></script> | |
| 630 | +<script | |
| 631 | + src="/assets/bower_components/oclazyload/dist/ocLazyLoad.min.js" | |
| 632 | + data-exclude=1></script> | |
| 633 | +<script | |
| 634 | + src="/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js" | |
| 635 | + data-exclude=1></script> | |
| 636 | +<!-- handsontable相关js --> | |
| 637 | +<script | |
| 638 | + src="/assets/bower_components/handsontable/dist/handsontable.full.js"></script> | |
| 639 | +<script | |
| 640 | + src="/assets/bower_components/ngHandsontable/dist/ngHandsontable.js"></script> | |
| 641 | +<!-- sweetalert相关js --> | |
| 642 | +<script src="/assets/bower_components/sweetalert/dist/sweetalert.min.js"></script> | |
| 643 | +<script src="/assets/bower_components/ng-sweet-alert/ng-sweet-alert.js"></script> | |
| 644 | + | |
| 645 | +<!-- schedule计划调度AngularJS模块主JS --> | |
| 646 | +<script src="/pages/scheduleApp/module/common/main.js" data-exclude=1></script> | |
| 647 | +<script | |
| 648 | + src="/pages/scheduleApp/module/common/prj-common-globalservice.js" | |
| 649 | + data-exclude=1></script> | |
| 650 | +<script src="/pages/scheduleApp/module/common/prj-common-filter.js" | |
| 651 | + data-exclude=1></script> | |
| 652 | +<script src="/pages/scheduleApp/module/common/prj-common-directive.js" | |
| 653 | + data-exclude=1></script> | |
| 654 | +<script | |
| 655 | + src="/pages/scheduleApp/module/common/prj-common-ui-route-state.js" | |
| 656 | + data-exclude=1></script> | |
| 657 | + | |
| 658 | +<!-- 地图相关 --> | |
| 659 | +<!-- 百度 --> | |
| 660 | +<script | |
| 661 | + src="//api.map.baidu.com/api?v=3.0&ak=1TgEKvYqohJyeGXnN6yHSSTb4psOarQw" | |
| 662 | + data-exclude=1></script> | |
| 663 | +<script | |
| 664 | + src="//api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js" | |
| 665 | + data-exclude=1></script> | |
| 666 | +<script type="text/javascript" | |
| 667 | + src="//api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js" | |
| 668 | + data-exclude=1></script> | |
| 669 | +<script type="text/javascript" | |
| 670 | + src="//api.map.baidu.com/library/RichMarker/1.2/src/RichMarker_min.js " | |
| 671 | + data-exclude=1></script> | |
| 672 | +<script src="/assets/js/baidu/TextIconOverlay.js" data-exclude=1></script> | |
| 673 | +<script src="/assets/js/baidu//MarkerClusterer.js" data-exclude=1></script> | |
| 674 | +<!-- 高德 --> | |
| 675 | +<script | |
| 676 | + src="//webapi.amap.com/maps?v=1.3&key=16cb1c5043847e09ef9edafdd77befda" | |
| 677 | + data-exclude=1></script> | |
| 678 | +<!-- echarts4 --> | |
| 679 | +<script src="/metronic_v4.5.4/plugins/echarts4/echarts.min.js"></script> | |
| 680 | +<script src="/real_control_v2/assets/plugins/perfect-scrollbar/perfect-scrollbar.jquery.js" merge="plugins"></script> | |
| 681 | +<!-- RSA加密 --> | |
| 682 | +<script src="/assets/plugins/jsencrypt.min.js"></script> | |
| 683 | +<script src="/assets/js/eventproxy.js"></script> | |
| 684 | +<!-- 线路路由信息操作 --> | |
| 685 | +<script src="/pages/base/stationroute/js/routes-operation.js"></script> | |
| 686 | +<script src="/pages/base/stationroute/js/routes-service.js"></script> | |
| 687 | +<script src="/assets/js/CoordinateConverter.js"></script> | |
| 688 | +</body> | |
| 689 | 689 | </html> |
| 690 | 690 | \ No newline at end of file | ... | ... |
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 | 157 | \ No newline at end of file | ... | ... |