Commit 9145e31250c19efa4ae89a4156add0743e3866a5
1.merge lggj
Showing
12 changed files
with
316 additions
and
330 deletions
src/main/java/com/bsth/entity/LsStationRoute.java
src/main/java/com/bsth/entity/Station.java
| ... | ... | @@ -5,13 +5,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 5 | 5 | import org.geolatte.geom.Point; |
| 6 | 6 | import org.hibernate.annotations.DynamicInsert; |
| 7 | 7 | import org.hibernate.annotations.DynamicUpdate; |
| 8 | -import org.hibernate.annotations.Formula; | |
| 9 | -import org.locationtech.jts.geom.Geometry; | |
| 10 | -import org.locationtech.jts.io.WKBReader; | |
| 11 | -import org.springframework.util.StringUtils; | |
| 12 | 8 | |
| 13 | 9 | import javax.persistence.*; |
| 14 | - | |
| 15 | 10 | import java.util.Date; |
| 16 | 11 | |
| 17 | 12 | /** | ... | ... |
src/main/java/com/bsth/entity/StationRoute.java
src/main/java/com/bsth/repository/SectionRouteRepository.java
| ... | ... | @@ -111,8 +111,8 @@ public interface SectionRouteRepository extends BaseRepository<SectionRoute, Int |
| 111 | 111 | * @param version |
| 112 | 112 | */ |
| 113 | 113 | @Modifying |
| 114 | - @Query(value="delete from SectionRoute sr where sr.line.id = ?1 and sr.versions = ?2") | |
| 115 | - void deleteByLineAndVersion(Integer lineId, Integer version); | |
| 114 | + @Query(value="delete from SectionRoute sr where sr.line.id = ?1") | |
| 115 | + void deleteByLineAndVersion(Integer lineId); | |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * 历史路由表变更之后从历史表批量更新当前版本至当前表 | ... | ... |
src/main/java/com/bsth/repository/StationRouteRepository.java
| ... | ... | @@ -213,8 +213,8 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 213 | 213 | * @param version |
| 214 | 214 | */ |
| 215 | 215 | @Modifying |
| 216 | - @Query(value="delete from StationRoute sr where sr.line.id = ?1 and sr.versions = ?2") | |
| 217 | - void deleteByLineAndVersion(Integer lineId, Integer version); | |
| 216 | + @Query(value="delete from StationRoute sr where sr.line.id = ?1") | |
| 217 | + void deleteByLineAndVersion(Integer lineId); | |
| 218 | 218 | |
| 219 | 219 | /** |
| 220 | 220 | * 历史路由表变更之后从历史表批量更新当前版本至当前表 |
| ... | ... | @@ -224,4 +224,4 @@ public interface StationRouteRepository extends BaseRepository<StationRoute, Int |
| 224 | 224 | @Modifying |
| 225 | 225 | @Query(value="insert into bsth_c_stationroute select * from bsth_c_ls_stationroute where line = ?1 and versions = ?2", nativeQuery = true) |
| 226 | 226 | void updateFromHistory(Integer lineId, Integer version); |
| 227 | 227 | -} |
| 228 | +} | |
| 228 | 229 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/impl/LineVersionsServiceImpl.java
| ... | ... | @@ -123,9 +123,9 @@ public class LineVersionsServiceImpl extends BaseServiceImpl<LineVersions, Integ |
| 123 | 123 | String lineCode = lineVersions.getLineCode(); |
| 124 | 124 | Integer versions = lineVersions.getVersions(); |
| 125 | 125 | |
| 126 | - stationRouteRepository.deleteByLineAndVersion(lineId, versions); | |
| 126 | + stationRouteRepository.deleteByLineAndVersion(lineId); | |
| 127 | 127 | stationRouteRepository.updateFromHistory(lineId, versions); |
| 128 | - sectionRouteRepository.deleteByLineAndVersion(lineId, versions); | |
| 128 | + sectionRouteRepository.deleteByLineAndVersion(lineId); | |
| 129 | 129 | sectionRouteRepository.updateFromHistory(lineId, versions); |
| 130 | 130 | // 更新线路版本 |
| 131 | 131 | repository.updateOdlVersions(lineId, lineCode); | ... | ... |
src/main/java/com/bsth/service/impl/LsSectionRouteServiceImpl.java
| ... | ... | @@ -3,12 +3,7 @@ package com.bsth.service.impl; |
| 3 | 3 | import com.bsth.entity.*; |
| 4 | 4 | import com.bsth.repository.*; |
| 5 | 5 | import com.bsth.service.LsSectionRouteService; |
| 6 | -import com.bsth.util.CoordinateConverter; | |
| 7 | 6 | import com.bsth.util.CustomBeanUtils; |
| 8 | -import com.bsth.util.GeoConverter; | |
| 9 | -import org.geolatte.geom.Point; | |
| 10 | -import org.geolatte.geom.Polygon; | |
| 11 | -import org.geolatte.geom.codec.Wkt; | |
| 12 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | 8 | import org.springframework.stereotype.Service; |
| 14 | 9 | import org.springframework.transaction.annotation.Transactional; |
| ... | ... | @@ -116,7 +111,7 @@ public class LsSectionRouteServiceImpl extends BaseServiceImpl<LsSectionRoute, I |
| 116 | 111 | } |
| 117 | 112 | |
| 118 | 113 | protected void refreshCurrent(int lineId, int version) { |
| 119 | - sectionRouteRepository.deleteByLineAndVersion(lineId, version); | |
| 114 | + sectionRouteRepository.deleteByLineAndVersion(lineId); | |
| 120 | 115 | sectionRouteRepository.updateFromHistory(lineId, version); |
| 121 | 116 | } |
| 122 | 117 | } |
| 123 | 118 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/impl/LsStationRouteServiceImpl.java
| ... | ... | @@ -9,8 +9,6 @@ import com.bsth.util.CustomBeanUtils; |
| 9 | 9 | import com.bsth.util.Geo.GeoUtils; |
| 10 | 10 | import com.bsth.util.Geo.Point; |
| 11 | 11 | import com.bsth.util.GeoConverter; |
| 12 | -import com.fasterxml.jackson.core.JsonProcessingException; | |
| 13 | -import com.fasterxml.jackson.databind.ObjectMapper; | |
| 14 | 12 | import org.geolatte.geom.LineString; |
| 15 | 13 | import org.geolatte.geom.Polygon; |
| 16 | 14 | import org.geolatte.geom.Position; |
| ... | ... | @@ -445,7 +443,7 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl<LsStationRoute, I |
| 445 | 443 | } |
| 446 | 444 | |
| 447 | 445 | protected void refreshCurrent(int lineId, int version) { |
| 448 | - stationRouteRepository.deleteByLineAndVersion(lineId, version); | |
| 446 | + stationRouteRepository.deleteByLineAndVersion(lineId); | |
| 449 | 447 | stationRouteRepository.updateFromHistory(lineId, version); |
| 450 | 448 | } |
| 451 | 449 | } | ... | ... |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -630,10 +630,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 630 | 630 | Integer lineId = map.get("lineId").equals("") ? 0 : Integer.parseInt(map.get("lineId").toString()); |
| 631 | 631 | /** 查询线路信息 @param:<lineId:线路ID> */ |
| 632 | 632 | Line line = lineRepository.findById(lineId).get(); |
| 633 | - | |
| 634 | - | |
| 633 | + | |
| 634 | + | |
| 635 | 635 | Business company = businessRepository.findByBusinessCode(line.getCompany()).get(0); |
| 636 | - | |
| 636 | + | |
| 637 | 637 | Integer fileVersions = lineRepository.findfileVersions(lineId); |
| 638 | 638 | if(fileVersions == null) { |
| 639 | 639 | lineRepository.addFileVersions(line.getId(), line.getLineCode()); |
| ... | ... | @@ -677,7 +677,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 677 | 677 | textStr = newTextFileToFTP(objects,lineId);/** 双向行单文件内容 @param:<objects:站点路由;lineId:线路ID>*/ |
| 678 | 678 | else |
| 679 | 679 | resultMap.put("status","NOLinePlayType");// 线路无线路规划类型 |
| 680 | - | |
| 680 | + | |
| 681 | 681 | textStr = line.getName() + " " + fileVersions + "\r\n" + textStr; |
| 682 | 682 | InputStream input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 683 | 683 | /** 生成txt文件,上传ftp */ |
| ... | ... | @@ -693,28 +693,28 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 693 | 693 | // 删除文件 |
| 694 | 694 | textFile.delete(); |
| 695 | 695 | targetFile.delete(); |
| 696 | - | |
| 696 | + | |
| 697 | 697 | |
| 698 | 698 | textStr = newTextVoiceFileToFTP(objects,lineId); |
| 699 | - | |
| 699 | + | |
| 700 | 700 | String lineName = line.getName(); |
| 701 | - | |
| 701 | + | |
| 702 | 702 | try { |
| 703 | 703 | lineName = Integer.parseInt(line.getName().replace("路", "")) + ""; |
| 704 | 704 | } catch (Exception e) { |
| 705 | 705 | } |
| 706 | - | |
| 706 | + | |
| 707 | 707 | String head = lineName + " " + fileVersions + " " + line.getStartStationFirstTime() + "-" + line.getStartStationEndTime() + " " + line.getEndStationFirstTime() + "-" + line.getEndStationEndTime() + " " + line.getTicketPrice() + " " + company.getBusinessName() + " " + (company.getPhoneNum()== null ? "-" : company.getPhoneNum()); |
| 708 | - | |
| 708 | + | |
| 709 | 709 | textStr = head +"\r\n" + textStr; |
| 710 | 710 | |
| 711 | 711 | input = new ByteArrayInputStream(textStr.getBytes("gbk")); |
| 712 | - | |
| 712 | + | |
| 713 | 713 | clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", textFileName, input); |
| 714 | 714 | |
| 715 | 715 | // textFile.delete(); |
| 716 | - | |
| 717 | - | |
| 716 | + | |
| 717 | + | |
| 718 | 718 | resultMap.put("status", ResponseCode.SUCCESS); |
| 719 | 719 | }else { |
| 720 | 720 | resultMap.put("status","NOTDATA"); |
| ... | ... | @@ -747,7 +747,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 747 | 747 | // 返回值String |
| 748 | 748 | String stationRStr = ""; |
| 749 | 749 | // windows下的文本文件换行符 |
| 750 | -// String enterStr = "\r\n"; | |
| 750 | + //String enterStr = "\r\n"; | |
| 751 | 751 | // linux/unix下的文本文件换行符 |
| 752 | 752 | String enterStr = "\r"; |
| 753 | 753 | int defaultZdxh = 0; |
| ... | ... | @@ -972,7 +972,7 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 972 | 972 | public String hxTextFileToFtp(List<Object[]> objects,Integer lineId) { |
| 973 | 973 | String restStr = ""; |
| 974 | 974 | // windows下的文本文件换行符 |
| 975 | -// String enterStr = "\r\n"; | |
| 975 | + //String enterStr = "\r\n"; | |
| 976 | 976 | // linux/unix下的文本文件换行符 |
| 977 | 977 | String enterStr = "\r"; |
| 978 | 978 | int xh = 1 ; | ... | ... |
src/main/resources/static/pages/base/line/edit.html
| ... | ... | @@ -417,7 +417,7 @@ |
| 417 | 417 | <div class="col-md-6"> |
| 418 | 418 | <label class="control-label col-md-5"> 终点站调度电话: </label> |
| 419 | 419 | <div class="col-md-4"> |
| 420 | - <input type="text" class="form-control" name="endPhone" id="startPhoneInput" | |
| 420 | + <input type="text" class="form-control" name="endPhone" id="endPhoneInput" | |
| 421 | 421 | placeholder="终点站调度电话"> |
| 422 | 422 | </div> |
| 423 | 423 | </div> | ... | ... |
src/main/resources/static/pages/base/line/js/line-add-form.js
| 1 | -/** | |
| 2 | - * @description TODO(线路信息添加片段JS模块) | |
| 3 | - * | |
| 4 | - * @author bsth@lq | |
| 5 | - * | |
| 6 | - * @date 二〇一六年十月十八日 13:31:58 | |
| 7 | - * | |
| 8 | - */ | |
| 9 | - | |
| 10 | -$(function(){ | |
| 11 | - /** 获取线路编码 @param cb <回调函数> */ | |
| 12 | - /*function getLineCode(cb) { | |
| 13 | - *//** get请求获取线路编码。返回线路编码值 *//* | |
| 14 | - $.get('/line/getLineCode',function(lineCode){ | |
| 15 | - return cb && cb(lineCode); | |
| 16 | - }); | |
| 17 | - }*/ | |
| 18 | - /** 填充分公司下拉框选择值 */ | |
| 19 | - function setbrancheCompanySelectOptions(){ | |
| 20 | - // 获取公司下拉框选择值 | |
| 21 | - var businessCode = $('#companySelect').val(); | |
| 22 | - // 分公司下拉框options属性值 | |
| 23 | - var options = '<option value="">-- 请选择分公司 --</option>'; | |
| 24 | - // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码 | |
| 25 | - if(businessCode == null || businessCode ==''){ | |
| 26 | - // 填充分公司下拉框options | |
| 27 | - $('#brancheCompanySelect').html(options); | |
| 28 | - } else { | |
| 29 | - // 查询出所属公司下的分公司名称和相应分公司代码 | |
| 30 | - $get('/business/all', {upCode_eq: businessCode}, function(array){ | |
| 31 | - // 遍历array | |
| 32 | - $.each(array, function(i,d){ | |
| 33 | - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 34 | - }); | |
| 35 | - | |
| 36 | - // 填充分公司下拉框options | |
| 37 | - $('#brancheCompanySelect').html(options); | |
| 38 | - }); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - /** 根据线路名称值设置英文名称值和线路简称 */ | |
| 42 | - function setPinYin(){ | |
| 43 | - /** 获取线路名称值 */ | |
| 44 | - var val = $('#nameInput').val(); | |
| 45 | - /** 汉字转换为拼音 设置英文名称值 */ | |
| 46 | - $('#esInput').val(pinyin.getFullChars(val)); | |
| 47 | - /** 汉字转换为拼音将每一个字的拼音的首字母提取出来并大写 设置线路简称值 */ | |
| 48 | - $('#shortNameInput').val(pinyin.getCamelChars(val)); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** 获取线路编码元素并设值 @param 匿名函数 *//* | |
| 52 | - getLineCode(function(result){ | |
| 53 | - // 设置线路编码值 | |
| 54 | - $('#lineCodeInput').val(result); | |
| 55 | - })*/ | |
| 56 | - /** 输入线路名称,自动生成英文名称和线路简称 */ | |
| 57 | - $('#nameInput').on('keyup', setPinYin); | |
| 58 | - /** 开辟日期 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 59 | - $('#openDateInput').datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn'}); | |
| 60 | - /** 起始站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 61 | - $('#startStationFirstTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 62 | - /** 起始站末班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 63 | - $('#endTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 64 | - /** 终点站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 65 | - $('#endStationFirstTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 66 | - /** 终点站末班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 67 | - $('#endStationEndTimeInput').datetimepicker({format : 'HH:mm',locale: 'zh-cn'}); | |
| 68 | - /** get请求获取公司表数据并填充公司下拉框选择值 */ | |
| 69 | - $get('/business/all', {upCode_eq: '88'}, function(array){ | |
| 70 | - /** 公司下拉options属性值 */ | |
| 71 | - var options = '<option value="">-- 请选择公司 --</option>'; | |
| 72 | - /** 遍历array */ | |
| 73 | - $.each(array, function(i,d){ | |
| 74 | - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 75 | - }); | |
| 76 | - /** 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions */ | |
| 77 | - $('#companySelect').html(options).on('change', setbrancheCompanySelectOptions); | |
| 78 | - }); | |
| 79 | - | |
| 80 | - /** 填充分公司下拉框 */ | |
| 81 | - setbrancheCompanySelectOptions(); | |
| 82 | - // 定义表单 | |
| 83 | - var form = $('#line_add_form'); | |
| 84 | - // 定义表单异常 | |
| 85 | - var error = $('.alert-danger',form); | |
| 86 | - // 表单验证 | |
| 87 | - form.validate({ | |
| 88 | - // 错误提示元素span对象 | |
| 89 | - errorElement : 'span', | |
| 90 | - // 错误提示元素class名称 | |
| 91 | - errorClass : 'help-block help-block-error', | |
| 92 | - // 验证错误获取焦点 | |
| 93 | - focusInvalid : true, | |
| 94 | - // 需要验证的表单元素 | |
| 95 | - rules : { | |
| 96 | - 'name' : {required : true,maxlength: 30},// 线路名称 必填项、 最大长度. | |
| 97 | - 'lineCode' : {required : true,maxlength: 6,digits:true ,isLineCode:true, | |
| 98 | - remote:{type: 'GET', | |
| 99 | - url: '/line/lineCodeVerification', | |
| 100 | - cache:false, | |
| 101 | - async:false, | |
| 102 | - data:{'lineCode':function(){ return $("#lineCodeInput").val();}} | |
| 103 | - }},// 线路编码 必填项、最大长度. | |
| 104 | - 'company' : {required : true,maxlength: 30},// 所属公司 必填项、最大长度. | |
| 105 | - 'ticketPrice' : {required : true}, | |
| 106 | - 'brancheCompany' : {required : true,maxlength: 30},// 所属分公司 必填项、最大长度. | |
| 107 | - 'level' : {required : true,maxlength: 30},// 线路等级 必填项、最大长度. | |
| 108 | - 'nature' : {required : true,maxlength: 30},// 线路性质 必填项、最大长度. | |
| 109 | - 'startStationName' : {required : true,maxlength: 30},// 起始站名称 必填项、最大长度. | |
| 110 | - 'endStationName' : {required : true,maxlength: 30},// 终点站名称 必填项、最大长度. | |
| 111 | - 'startStationFirstTime' : {required : true,maxlength: 30},// 起始站首班时间 必填项、最大长度. | |
| 112 | - 'StartStationEndTime' : {required : true,maxlength: 30},// 起始站末班时间 必填项、最大长度. | |
| 113 | - 'endStationFirstTime' : {required : true,maxlength: 30},// 终点站首班时间 必填项、最大长度. | |
| 114 | - 'endStationEndTime' : {required : true,maxlength: 30},// 终点站末班时间 必填项、最大长度. | |
| 115 | - 'linePlayType' : {required : true,maxlength: 30},// 线路规划类型 <0:双向;1:环线> 必填项、最大长度. | |
| 116 | - 'openDate' : {date : true,dateISO:true},// 开辟日期 正确格式的日期(日期校验 ie6 出错,慎用。)必须输入正确格式的日期(ISO),例如:2009-06-23,1998/01/22。只验证格式,不验证有效性。 | |
| 117 | - 'es' : {maxlength: 30},// 英文名称 最大长度. | |
| 118 | - 'shortName' : {maxlength: 30},// 线路简称 最大长度. | |
| 119 | - 'shanghaiLinecode' : {maxlength: 30},// 上海市线路编码 最大长度. | |
| 120 | - 'eqLinecode' : {maxlength: 30},// 设备线路编码 最大长度. | |
| 121 | - 'startPhone' : {number : true,digits : true,isPhone : true,maxlength: 30},// 起始站调度电话 必须输入合法的数字(负数,小数)。必须输入整数。电话号码格式 最大长度 | |
| 122 | - 'endPhone' : {number : true,digits : true,isPhone : true,maxlength: 30},// 终点站调度电话 必须输入合法的数字(负数,小数)。必须输入整数。电话号码格式 、最大长度 | |
| 123 | - 'carSumNumber' : {number : true,digits : true,maxlength: 8},// 车辆总数 必须输入合法的数字(负数,小数)。必须输入整数。最大长度. | |
| 124 | - 'hvacCarNumber' : {number : true,digits : true,maxlength: 8},// 空调车辆数 必须输入合法的数字(负数,小数)。 必须输入整数。 最大长度. | |
| 125 | - 'ordCarNumber' : {number : true,digits : true,maxlength: 8},// 普通车辆数 必须输入合法的数字(负数,小数)。 必须输入整数。最大长度. | |
| 126 | - 'history' : {maxlength: 200},// 线路沿革 输入长度最多是 200 的字符串(汉字算一个字符)。 | |
| 127 | - 'descriptions' : {maxlength: 200},// 描述/说明 输入长度最多是 200 的字符串(汉字算一个字符)。 | |
| 128 | - 'region' : {required : true}// 线路区域必选 | |
| 129 | - }, | |
| 130 | - messages:{ | |
| 131 | - 'lineCode':{ | |
| 132 | - remote: '此线路编码已存在!' | |
| 133 | - } | |
| 134 | - }, | |
| 135 | - /** | |
| 136 | - * 类型:Callback。当未通过验证的表单提交时,可以在该回调函数中处理一些事情。 | |
| 137 | - * | |
| 138 | - * 参数:该回调函数有两个参数:第一个为一个事件对象,第二个为验证器(validator) | |
| 139 | - */ | |
| 140 | - invalidHandler : function(event, validator) { | |
| 141 | - | |
| 142 | - // 显示表单未通过提示信息 | |
| 143 | - error.show(); | |
| 144 | - | |
| 145 | - // 把提示信息放到指定的位置。 | |
| 146 | - App.scrollTo(error, -200); | |
| 147 | - }, | |
| 148 | - | |
| 149 | - /** | |
| 150 | - * 类型:Callback。 | |
| 151 | - * | |
| 152 | - * 默认:添加errorClass("has-error")到表单元素。将未通过验证的表单元素设置高亮。 | |
| 153 | - */ | |
| 154 | - highlight : function(element) { | |
| 155 | - | |
| 156 | - // 添加errorClass("has-error")到表单元素 | |
| 157 | - $(element).closest('.form-group').addClass('has-error'); | |
| 158 | - | |
| 159 | - }, | |
| 160 | - | |
| 161 | - /** | |
| 162 | - * 类型:Callback。 | |
| 163 | - * | |
| 164 | - * 默认:移除errorClass("has-error")。与highlight操作相反 | |
| 165 | - */ | |
| 166 | - unhighlight : function(element) { | |
| 167 | - | |
| 168 | - // 移除errorClass("has-error") | |
| 169 | - $(element).closest('.form-group').removeClass('has-error'); | |
| 170 | - | |
| 171 | - }, | |
| 172 | - | |
| 173 | - /** | |
| 174 | - * 类型:String,Callback。 | |
| 175 | - * | |
| 176 | - * 如果指定它,当验证通过时显示一个消息。 | |
| 177 | - * | |
| 178 | - * 如果是String类型的,则添加该样式到标签中; | |
| 179 | - * | |
| 180 | - * 如果是一个回调函数,则将标签作为其唯一的参数。 | |
| 181 | - */ | |
| 182 | - success : function(label) { | |
| 183 | - | |
| 184 | - // 当验证通过时,移除errorClass("has-error") | |
| 185 | - label.closest('.form-group').removeClass('has-error'); | |
| 186 | - | |
| 187 | - }, | |
| 188 | - | |
| 189 | - /** | |
| 190 | - * 类型:Callback。 | |
| 191 | - * | |
| 192 | - * 默认:default (native) form submit;当表单通过验证,提交表单。回调函数有个默认参数form | |
| 193 | - */ | |
| 194 | - submitHandler : function(f) { | |
| 195 | - | |
| 196 | - // 隐藏错误提示 | |
| 197 | - error.hide(); | |
| 198 | - // 表单序列化 | |
| 199 | - var params = form.serializeJSON(); | |
| 200 | - submit(); | |
| 201 | - | |
| 202 | - // 查询线路编码的顺延号 | |
| 203 | - /*$get('/line/all', {lineCode_eq: params.lineCode},function(lineCode){ | |
| 204 | - | |
| 205 | - // 定义返回值的长度 | |
| 206 | - var len = lineCode.length; | |
| 207 | - | |
| 208 | - // 如果大于零,则已存在录入的线路编码;否则不存在 | |
| 209 | - if(len > 0) { | |
| 210 | - | |
| 211 | - // 定义已有的线路编码 | |
| 212 | - var oldCode = params.lineCode; | |
| 213 | - | |
| 214 | - // 自动获取线路编码 | |
| 215 | - getLineCode(function(result) { | |
| 216 | - | |
| 217 | - // 重新设置提交参数线路编码值 | |
| 218 | - params.lineCode = result; | |
| 219 | - | |
| 220 | - // 弹出选择框;确认则提交;取消则返回 | |
| 221 | - layer.confirm('线路编码【'+oldCode+'】已存在!自动顺延为如下:<br>线路编码:'+result, { | |
| 222 | - btn : [ '确认提示并提交', '取消' ] | |
| 223 | - }, submit); | |
| 224 | - | |
| 225 | - }); | |
| 226 | - layer.open({ | |
| 227 | - title: '消息提示' | |
| 228 | - ,content: '线路编码【'+params.lineCode+'】已存在,请重新输入编码!' | |
| 229 | - }); | |
| 230 | - } else { | |
| 231 | - | |
| 232 | - // 提交 | |
| 233 | - submit(); | |
| 234 | - | |
| 235 | - } | |
| 236 | - });*/ | |
| 237 | - | |
| 238 | - | |
| 239 | - // 提交 | |
| 240 | - function submit() { | |
| 241 | - | |
| 242 | - // 防止用户多次提交 | |
| 243 | - $("#submintBtn").addClass("disabled"); | |
| 244 | - | |
| 245 | - // 添加数据 | |
| 246 | - $post('/line', params, function(result) { | |
| 247 | - // 如果返回结果不为空 | |
| 248 | - if(result){ | |
| 249 | - | |
| 250 | - // 返回状态码为"SUCCESS" ,则添加成功;返回状态码为"ERROR" ,则添加失败 | |
| 251 | - if(result.status=='SUCCESS') { | |
| 252 | - | |
| 253 | - // 弹出添加成功提示消息 | |
| 254 | - layer.msg('添加成功,并已自动为您生成线路原始版本,可以在线路版本信息下查看!', {time: 7000}); | |
| 255 | - | |
| 256 | - } else if(result.status=='ERROR') { | |
| 257 | - | |
| 258 | - // 弹出添加失败提示消息 | |
| 259 | - layer.msg('添加失败...'); | |
| 260 | - | |
| 261 | - } | |
| 262 | - } | |
| 263 | - | |
| 264 | - // 返回list.html页面 | |
| 265 | - loadPage('list.html'); | |
| 266 | - }); | |
| 267 | - } | |
| 268 | - } | |
| 269 | - }); | |
| 270 | - | |
| 271 | - // 线路编码不能0开头 | |
| 272 | - $.validator.addMethod("isLineCode", function(value,element) { | |
| 273 | - // 线路编码正则表达式 | |
| 274 | - var lineCode = /^([1-9])/; | |
| 275 | - return lineCode.test(value); | |
| 276 | - }, "线路编码不能以0开头"); | |
| 277 | - | |
| 278 | - // 联系电话(手机/电话皆可)验证 | |
| 279 | - $.validator.addMethod("isPhone", function(value,element) { | |
| 280 | - // 长度 | |
| 281 | - var length = value.length; | |
| 282 | - // 手机正则表达式 | |
| 283 | - var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/; | |
| 284 | - // 固定电话正则表达式 | |
| 285 | - var tel = /^\d{3,4}-?\d{7,9}$/; | |
| 286 | - return this.optional(element) || (tel.test(value) || mobile.test(value)); | |
| 287 | - }, "请正确填写您的联系电话"); | |
| 1 | +/** | |
| 2 | + * @description TODO(线路信息添加片段JS模块) | |
| 3 | + * | |
| 4 | + * @author bsth@lq | |
| 5 | + * | |
| 6 | + * @date 二〇一六年十月十八日 13:31:58 | |
| 7 | + * | |
| 8 | + */ | |
| 9 | + | |
| 10 | +$(function(){ | |
| 11 | + /** 获取线路编码 @param cb <回调函数> */ | |
| 12 | + /*function getLineCode(cb) { | |
| 13 | + *//** get请求获取线路编码。返回线路编码值 *//* | |
| 14 | + $.get('/line/getLineCode',function(lineCode){ | |
| 15 | + return cb && cb(lineCode); | |
| 16 | + }); | |
| 17 | + }*/ | |
| 18 | + /** 填充分公司下拉框选择值 */ | |
| 19 | + function setbrancheCompanySelectOptions(){ | |
| 20 | + // 获取公司下拉框选择值 | |
| 21 | + var businessCode = $('#companySelect').val(); | |
| 22 | + // 分公司下拉框options属性值 | |
| 23 | + var options = '<option value="">-- 请选择分公司 --</option>'; | |
| 24 | + // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码 | |
| 25 | + if(businessCode == null || businessCode ==''){ | |
| 26 | + // 填充分公司下拉框options | |
| 27 | + $('#brancheCompanySelect').html(options); | |
| 28 | + } else { | |
| 29 | + // 查询出所属公司下的分公司名称和相应分公司代码 | |
| 30 | + $get('/business/all', {upCode_eq: businessCode}, function(array){ | |
| 31 | + // 遍历array | |
| 32 | + $.each(array, function(i,d){ | |
| 33 | + options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 34 | + }); | |
| 35 | + | |
| 36 | + // 填充分公司下拉框options | |
| 37 | + $('#brancheCompanySelect').html(options); | |
| 38 | + }); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + /** 根据线路名称值设置英文名称值和线路简称 */ | |
| 42 | + function setPinYin(){ | |
| 43 | + /** 获取线路名称值 */ | |
| 44 | + var val = $('#nameInput').val(); | |
| 45 | + /** 汉字转换为拼音 设置英文名称值 */ | |
| 46 | + $('#esInput').val(pinyin.getFullChars(val)); | |
| 47 | + /** 汉字转换为拼音将每一个字的拼音的首字母提取出来并大写 设置线路简称值 */ | |
| 48 | + $('#shortNameInput').val(pinyin.getCamelChars(val)); | |
| 49 | + } | |
| 50 | + | |
| 51 | + /** 获取线路编码元素并设值 @param 匿名函数 *//* | |
| 52 | + getLineCode(function(result){ | |
| 53 | + // 设置线路编码值 | |
| 54 | + $('#lineCodeInput').val(result); | |
| 55 | + })*/ | |
| 56 | + /** 输入线路名称,自动生成英文名称和线路简称 */ | |
| 57 | + $('#nameInput').on('keyup', setPinYin); | |
| 58 | + /** 开辟日期 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 59 | + $('#openDateInput').datetimepicker({format : 'YYYY-MM-DD', locale: 'zh-cn'}); | |
| 60 | + /** 起始站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 61 | + $('#startStationFirstTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 62 | + /** 起始站末班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 63 | + $('#endTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 64 | + /** 终点站首班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 65 | + $('#endStationFirstTimeInput').datetimepicker({format : 'HH:mm', locale: 'zh-cn'}); | |
| 66 | + /** 终点站末班时间 日期控件 <format:日期控件时间格式;locale:语言> */ | |
| 67 | + $('#endStationEndTimeInput').datetimepicker({format : 'HH:mm',locale: 'zh-cn'}); | |
| 68 | + /** get请求获取公司表数据并填充公司下拉框选择值 */ | |
| 69 | + $get('/business/all', {upCode_eq: '88'}, function(array){ | |
| 70 | + /** 公司下拉options属性值 */ | |
| 71 | + var options = '<option value="">-- 请选择公司 --</option>'; | |
| 72 | + /** 遍历array */ | |
| 73 | + $.each(array, function(i,d){ | |
| 74 | + options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>'; | |
| 75 | + }); | |
| 76 | + /** 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions */ | |
| 77 | + $('#companySelect').html(options).on('change', setbrancheCompanySelectOptions); | |
| 78 | + }); | |
| 79 | + | |
| 80 | + /** 填充分公司下拉框 */ | |
| 81 | + setbrancheCompanySelectOptions(); | |
| 82 | + // 定义表单 | |
| 83 | + var form = $('#line_add_form'); | |
| 84 | + // 定义表单异常 | |
| 85 | + var error = $('.alert-danger',form); | |
| 86 | + // 表单验证 | |
| 87 | + form.validate({ | |
| 88 | + // 错误提示元素span对象 | |
| 89 | + errorElement : 'span', | |
| 90 | + // 错误提示元素class名称 | |
| 91 | + errorClass : 'help-block help-block-error', | |
| 92 | + // 验证错误获取焦点 | |
| 93 | + focusInvalid : true, | |
| 94 | + // 需要验证的表单元素 | |
| 95 | + rules : { | |
| 96 | + 'name' : {required : true,maxlength: 30},// 线路名称 必填项、 最大长度. | |
| 97 | + 'lineCode' : {required : true,maxlength: 6,digits:true ,isLineCode:true, | |
| 98 | + remote:{type: 'GET', | |
| 99 | + url: '/line/lineCodeVerification', | |
| 100 | + cache:false, | |
| 101 | + async:false, | |
| 102 | + data:{'lineCode':function(){ return $("#lineCodeInput").val();}} | |
| 103 | + }},// 线路编码 必填项、最大长度. | |
| 104 | + 'company' : {required : true,maxlength: 30},// 所属公司 必填项、最大长度. | |
| 105 | + 'brancheCompany' : {required : true,maxlength: 30},// 所属分公司 必填项、最大长度. | |
| 106 | + 'level' : {required : true,maxlength: 30},// 线路等级 必填项、最大长度. | |
| 107 | + 'nature' : {required : true,maxlength: 30},// 线路性质 必填项、最大长度. | |
| 108 | + 'startStationName' : {required : true,maxlength: 30},// 起始站名称 必填项、最大长度. | |
| 109 | + 'endStationName' : {required : true,maxlength: 30},// 终点站名称 必填项、最大长度. | |
| 110 | + 'startStationFirstTime' : {required : true,maxlength: 30},// 起始站首班时间 必填项、最大长度. | |
| 111 | + 'StartStationEndTime' : {required : true,maxlength: 30},// 起始站末班时间 必填项、最大长度. | |
| 112 | + 'endStationFirstTime' : {required : true,maxlength: 30},// 终点站首班时间 必填项、最大长度. | |
| 113 | + 'endStationEndTime' : {required : true,maxlength: 30},// 终点站末班时间 必填项、最大长度. | |
| 114 | + 'linePlayType' : {required : true,maxlength: 30},// 线路规划类型 <0:双向;1:环线> 必填项、最大长度. | |
| 115 | + 'openDate' : {date : true,dateISO:true},// 开辟日期 正确格式的日期(日期校验 ie6 出错,慎用。)必须输入正确格式的日期(ISO),例如:2009-06-23,1998/01/22。只验证格式,不验证有效性。 | |
| 116 | + 'es' : {maxlength: 30},// 英文名称 最大长度. | |
| 117 | + 'shortName' : {maxlength: 30},// 线路简称 最大长度. | |
| 118 | + 'shanghaiLinecode' : {maxlength: 30},// 上海市线路编码 最大长度. | |
| 119 | + 'eqLinecode' : {maxlength: 30},// 设备线路编码 最大长度. | |
| 120 | + 'startPhone' : {number : true,digits : true,isPhone : true,maxlength: 30},// 起始站调度电话 必须输入合法的数字(负数,小数)。必须输入整数。电话号码格式 最大长度 | |
| 121 | + 'endPhone' : {number : true,digits : true,isPhone : true,maxlength: 30},// 终点站调度电话 必须输入合法的数字(负数,小数)。必须输入整数。电话号码格式 、最大长度 | |
| 122 | + 'carSumNumber' : {number : true,digits : true,maxlength: 8},// 车辆总数 必须输入合法的数字(负数,小数)。必须输入整数。最大长度. | |
| 123 | + 'hvacCarNumber' : {number : true,digits : true,maxlength: 8},// 空调车辆数 必须输入合法的数字(负数,小数)。 必须输入整数。 最大长度. | |
| 124 | + 'ordCarNumber' : {number : true,digits : true,maxlength: 8},// 普通车辆数 必须输入合法的数字(负数,小数)。 必须输入整数。最大长度. | |
| 125 | + 'history' : {maxlength: 200},// 线路沿革 输入长度最多是 200 的字符串(汉字算一个字符)。 | |
| 126 | + 'descriptions' : {maxlength: 200},// 描述/说明 输入长度最多是 200 的字符串(汉字算一个字符)。 | |
| 127 | + 'region' : {required : true}// 线路区域必选 | |
| 128 | + }, | |
| 129 | + messages:{ | |
| 130 | + 'lineCode':{ | |
| 131 | + remote: '此线路编码已存在!' | |
| 132 | + } | |
| 133 | + }, | |
| 134 | + /** | |
| 135 | + * 类型:Callback。当未通过验证的表单提交时,可以在该回调函数中处理一些事情。 | |
| 136 | + * | |
| 137 | + * 参数:该回调函数有两个参数:第一个为一个事件对象,第二个为验证器(validator) | |
| 138 | + */ | |
| 139 | + invalidHandler : function(event, validator) { | |
| 140 | + | |
| 141 | + // 显示表单未通过提示信息 | |
| 142 | + error.show(); | |
| 143 | + | |
| 144 | + // 把提示信息放到指定的位置。 | |
| 145 | + App.scrollTo(error, -200); | |
| 146 | + }, | |
| 147 | + | |
| 148 | + /** | |
| 149 | + * 类型:Callback。 | |
| 150 | + * | |
| 151 | + * 默认:添加errorClass("has-error")到表单元素。将未通过验证的表单元素设置高亮。 | |
| 152 | + */ | |
| 153 | + highlight : function(element) { | |
| 154 | + | |
| 155 | + // 添加errorClass("has-error")到表单元素 | |
| 156 | + $(element).closest('.form-group').addClass('has-error'); | |
| 157 | + | |
| 158 | + }, | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * 类型:Callback。 | |
| 162 | + * | |
| 163 | + * 默认:移除errorClass("has-error")。与highlight操作相反 | |
| 164 | + */ | |
| 165 | + unhighlight : function(element) { | |
| 166 | + | |
| 167 | + // 移除errorClass("has-error") | |
| 168 | + $(element).closest('.form-group').removeClass('has-error'); | |
| 169 | + | |
| 170 | + }, | |
| 171 | + | |
| 172 | + /** | |
| 173 | + * 类型:String,Callback。 | |
| 174 | + * | |
| 175 | + * 如果指定它,当验证通过时显示一个消息。 | |
| 176 | + * | |
| 177 | + * 如果是String类型的,则添加该样式到标签中; | |
| 178 | + * | |
| 179 | + * 如果是一个回调函数,则将标签作为其唯一的参数。 | |
| 180 | + */ | |
| 181 | + success : function(label) { | |
| 182 | + | |
| 183 | + // 当验证通过时,移除errorClass("has-error") | |
| 184 | + label.closest('.form-group').removeClass('has-error'); | |
| 185 | + | |
| 186 | + }, | |
| 187 | + | |
| 188 | + /** | |
| 189 | + * 类型:Callback。 | |
| 190 | + * | |
| 191 | + * 默认:default (native) form submit;当表单通过验证,提交表单。回调函数有个默认参数form | |
| 192 | + */ | |
| 193 | + submitHandler : function(f) { | |
| 194 | + | |
| 195 | + // 隐藏错误提示 | |
| 196 | + error.hide(); | |
| 197 | + // 表单序列化 | |
| 198 | + var params = form.serializeJSON(); | |
| 199 | + submit(); | |
| 200 | + | |
| 201 | + // 查询线路编码的顺延号 | |
| 202 | + /*$get('/line/all', {lineCode_eq: params.lineCode},function(lineCode){ | |
| 203 | + | |
| 204 | + // 定义返回值的长度 | |
| 205 | + var len = lineCode.length; | |
| 206 | + | |
| 207 | + // 如果大于零,则已存在录入的线路编码;否则不存在 | |
| 208 | + if(len > 0) { | |
| 209 | + | |
| 210 | + // 定义已有的线路编码 | |
| 211 | + var oldCode = params.lineCode; | |
| 212 | + | |
| 213 | + // 自动获取线路编码 | |
| 214 | + getLineCode(function(result) { | |
| 215 | + | |
| 216 | + // 重新设置提交参数线路编码值 | |
| 217 | + params.lineCode = result; | |
| 218 | + | |
| 219 | + // 弹出选择框;确认则提交;取消则返回 | |
| 220 | + layer.confirm('线路编码【'+oldCode+'】已存在!自动顺延为如下:<br>线路编码:'+result, { | |
| 221 | + btn : [ '确认提示并提交', '取消' ] | |
| 222 | + }, submit); | |
| 223 | + | |
| 224 | + }); | |
| 225 | + layer.open({ | |
| 226 | + title: '消息提示' | |
| 227 | + ,content: '线路编码【'+params.lineCode+'】已存在,请重新输入编码!' | |
| 228 | + }); | |
| 229 | + } else { | |
| 230 | + | |
| 231 | + // 提交 | |
| 232 | + submit(); | |
| 233 | + | |
| 234 | + } | |
| 235 | + });*/ | |
| 236 | + | |
| 237 | + | |
| 238 | + // 提交 | |
| 239 | + function submit() { | |
| 240 | + | |
| 241 | + // 防止用户多次提交 | |
| 242 | + $("#submintBtn").addClass("disabled"); | |
| 243 | + | |
| 244 | + // 添加数据 | |
| 245 | + $post('/line', params, function(result) { | |
| 246 | + // 如果返回结果不为空 | |
| 247 | + if(result){ | |
| 248 | + | |
| 249 | + // 返回状态码为"SUCCESS" ,则添加成功;返回状态码为"ERROR" ,则添加失败 | |
| 250 | + if(result.status=='SUCCESS') { | |
| 251 | + | |
| 252 | + // 弹出添加成功提示消息 | |
| 253 | + layer.msg('添加成功,并已自动为您生成线路原始版本,可以在线路版本信息下查看!', {time: 7000}); | |
| 254 | + | |
| 255 | + } else if(result.status=='ERROR') { | |
| 256 | + | |
| 257 | + // 弹出添加失败提示消息 | |
| 258 | + layer.msg('添加失败...'); | |
| 259 | + | |
| 260 | + } | |
| 261 | + } | |
| 262 | + | |
| 263 | + // 返回list.html页面 | |
| 264 | + loadPage('list.html'); | |
| 265 | + }); | |
| 266 | + } | |
| 267 | + } | |
| 268 | + }); | |
| 269 | + | |
| 270 | + // 线路编码不能0开头 | |
| 271 | + $.validator.addMethod("isLineCode", function(value,element) { | |
| 272 | + // 线路编码正则表达式 | |
| 273 | + var lineCode = /^([1-9])/; | |
| 274 | + return lineCode.test(value); | |
| 275 | + }, "线路编码不能以0开头"); | |
| 276 | + | |
| 277 | + // 联系电话(手机/电话皆可)验证 | |
| 278 | + $.validator.addMethod("isPhone", function(value,element) { | |
| 279 | + // 长度 | |
| 280 | + var length = value.length; | |
| 281 | + // 手机正则表达式 | |
| 282 | + var mobile = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/; | |
| 283 | + // 固定电话正则表达式 | |
| 284 | + var tel = /^\d{3,4}-?\d{7,9}$/; | |
| 285 | + return this.optional(element) || (tel.test(value) || mobile.test(value)); | |
| 286 | + }, "请正确填写您的联系电话"); | |
| 288 | 287 | }); |
| 289 | 288 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/section/js/add-vmap-world.js
| ... | ... | @@ -80,14 +80,14 @@ var SectionVmapWorlds = function() { |
| 80 | 80 | }, |
| 81 | 81 | // 根据名称获取坐标. |
| 82 | 82 | sectionsNameToPoints : function(sectionNames, callback) { |
| 83 | - var arguments = new Array(); | |
| 83 | + var args = new Array(); | |
| 84 | 84 | for (var i = 0;i < sectionNames.length;i++) { |
| 85 | - arguments.push('searchComplete' + i); | |
| 85 | + args.push('searchComplete' + i); | |
| 86 | 86 | } |
| 87 | - arguments.push(function(... args) { | |
| 88 | - callback(args); | |
| 87 | + args.push(function() { | |
| 88 | + callback(arguments); | |
| 89 | 89 | }) |
| 90 | - var proxy = EventProxy.create(arguments); | |
| 90 | + var proxy = EventProxy.create(args); | |
| 91 | 91 | sectionNames.forEach(function(item, idx) { |
| 92 | 92 | var localSearch = new BMap.LocalSearch(mapB); |
| 93 | 93 | localSearch.setSearchCompleteCallback(function (searchResult) { | ... | ... |