Commit d124d9c94ae545674fd5cd2aa099ffa79274741f

Authored by 廖磊
2 parents c6c0822a 82eb58f8

Merge branch 'minhang' of

http://222.66.0.204:8090/panzhaov5/bsth_control into minhang
src/main/java/com/bsth/controller/schedule/TrafficManageController.java
... ... @@ -8,8 +8,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
8 8 import org.springframework.web.bind.annotation.RequestParam;
9 9 import org.springframework.web.bind.annotation.RestController;
10 10  
11   -import java.util.Map;
12   -
13 11 /**
14 12 *
15 13 * @author BSTH
... ... @@ -24,9 +22,9 @@ public class TrafficManageController {
24 22  
25 23  
26 24 @RequestMapping(value = "/setXL", method = RequestMethod.GET)
27   - public String setXL(@RequestParam Map<String, Object> param) throws Exception {
  25 + public String setXL(@RequestParam("ids") String ids) throws Exception {
28 26 try {
29   - return trManageService.setXL(param);
  27 + return trManageService.setXL(ids);
30 28 } catch (Exception exp) {
31 29 throw new Exception(exp.getCause());
32 30 }
... ...
src/main/java/com/bsth/service/TrafficManageService.java
... ... @@ -24,7 +24,7 @@ public interface TrafficManageService {
24 24 *
25 25 * @return 调用接口返回信息
26 26 */
27   - String setXL(Map<String, Object> param);
  27 + String setXL(String ids);
28 28  
29 29 /**
30 30 * 上传车辆信息
... ...
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
... ... @@ -16,6 +16,7 @@ import com.bsth.repository.schedule.*;
16 16 import com.bsth.repository.traffic.SKBUploadLoggerRepository;
17 17 import com.bsth.security.util.SecurityUtils;
18 18 import com.bsth.service.TrafficManageService;
  19 +import com.bsth.service.traffic.YgcBasicDataService;
19 20 import com.bsth.util.TimeUtils;
20 21 import com.bsth.util.db.DBUtils_MS;
21 22 import com.bsth.webService.trafficManage.geotool.services.InternalPortType;
... ... @@ -99,7 +100,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{
99 100  
100 101 // 线路站点repository
101 102 @Autowired
102   - private StationRepository stationRepository;
  103 + private YgcBasicDataService ygcBasicDataService;
103 104  
104 105  
105 106 // 运管处接口
... ... @@ -122,11 +123,6 @@ public class TrafficManageServiceImpl implements TrafficManageService{
122 123 DecimalFormat format = new DecimalFormat("0.00");
123 124  
124 125 // 用户名
125   - private final String userNameXl = "pudong";
126   - // 密码
127   - private final String passwordXl = "pudong123";
128   -
129   - // 用户名
130 126 private final String userNameOther = "user";
131 127 // 密码
132 128 private final String passwordOther = "user";
... ... @@ -134,34 +130,25 @@ public class TrafficManageServiceImpl implements TrafficManageService{
134 130 * 上传线路信息
135 131 */
136 132 @Override
137   - public String setXL(Map<String, Object> param) {
  133 + public String setXL(String ids) {
138 134 String result = "failure";
139 135 StringBuffer sBuffer = new StringBuffer();
  136 + String[] idArray = ids.split(",");
140 137 try {
141   - Map<String,Object> map = new HashMap<String,Object>();
142   - map.put("lineCode_eq", param.get("xl.lineCode_like")+"");
143   - Iterator<Line> lineIterator;
144   - Line line = null;
145   - if(param.get("xl.lineCode_like").equals("")){
146   - lineIterator = lineRepository.findAll().iterator();
147   - }else {
  138 + for (String id : idArray) {
  139 + Map<String,Object> map = new HashMap<>();
  140 + map.put("lineCode_eq", id);
  141 + Line line ;
148 142 line = lineRepository.findOne(new CustomerSpecs<Line>(map));
149   - }
150   - List<StationRoute> upStationsList = null;// 上行站点路由集
151   - List<StationRoute> downStationsList = null;// 下行站点路由集
152   - List<LineInformation> lineInformationsList = null;
153   - LineInformation lineInformation = null;
154   - sBuffer.append("<Data>");
155   - sBuffer.append("<RequestOrg>上海巴士拓华科技发展有限公司</RequestOrg>");
156   - sBuffer.append("<DataList>");
157   -// while(lineIterator.hasNext()){
158   -// line = lineIterator.next();
159   -// if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null
160   -// || line.getInUse() == 0){
161   -// continue;
162   -// }
163   - if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null
164   - || line.getInUse() == 0){
  143 + if(line == null){
  144 + continue;
  145 + }
  146 + List<StationRoute> upStationsList ;// 上行站点路由集
  147 + List<StationRoute> downStationsList = null;// 下行站点路由集
  148 + sBuffer.append("<Data>");
  149 + sBuffer.append("<RequestOrg>上海巴士拓华科技发展有限公司</RequestOrg>");
  150 + sBuffer.append("<DataList>");
  151 + if(BasicData.lineId2ShangHaiCodeMap.get(line.getId()) == null){
165 152 return result;
166 153 }
167 154 sBuffer.append("<LINE_ID>").append(line.getId()).append("</LINE_ID>");
... ... @@ -190,32 +177,24 @@ public class TrafficManageServiceImpl implements TrafficManageService{
190 177 packagStationPointXml(downStationsList, sBuffer, startId);
191 178 }
192 179 sBuffer.append("</LinePointList>");
193   -// }
194   - sBuffer.append("</DataList>");
195   - sBuffer.append("</Data>");
196   - System.out.println(sBuffer.toString());
197   - if(sBuffer.indexOf("<XL>") != -1){
198   - portType = new Internal().getInternalHttpSoap11Endpoint();
199   - String portResult = portType.setXL(userNameXl, passwordXl, sBuffer.toString());
200   - String portArray[] = portResult.split("\n");
201   - if(portArray.length >= 4){
202   - // 返回数据的编码
203   - String returnCode = portArray[1].substring(portArray[1].indexOf(">")+1,portArray[1].indexOf("</"));
204   - // 返回的信息
205   - String returnDescription = portArray[2].substring(portArray[2].indexOf(">")+1,portArray[2].indexOf("</"));
206   - if(returnCode.equals("1")){
207   - result = "success";
208   - }else{
209   - result = returnDescription;
210   - }
  180 + sBuffer.append("</DataList>");
  181 + sBuffer.append("</Data>");
  182 + // 调用上传方法
  183 + result = ygcBasicDataService.invokeMethod("UpdateBusLineStation",sBuffer.toString());
  184 + String str = "ReturnCode";
  185 + // 解析返回值
  186 + result = result.substring(result.indexOf(str)+str.length()+1,result.lastIndexOf(str)-2);
  187 + if(result.equals("1")){
  188 + result = "success";
  189 + }else{
  190 + result = "failure";
211 191 }
  192 + logger.info("setXL:"+sBuffer.toString());
  193 + logger.info("setXL:"+result);
212 194 }
213 195 } catch (Exception e) {
214 196 logger.error("setXL:",e);
215 197 e.printStackTrace();
216   - }finally{
217   - logger.info("setXL:"+sBuffer.toString());
218   - logger.info("setXL:"+result);
219 198 }
220 199 return result;
221 200 }
... ...
src/main/java/com/bsth/service/traffic/YgcBasicDataService.java
... ... @@ -9,5 +9,13 @@ public interface YgcBasicDataService {
9 9 * 更新运管处基础数据
10 10 */
11 11 void updateYgcBasicData();
  12 +
  13 + /**
  14 + * 调用方法
  15 + * @param methodName 方法名
  16 + * @param param 参数
  17 + * @return
  18 + */
  19 + String invokeMethod(String methodName,String param);
12 20 }
13 21  
... ...
src/main/java/com/bsth/service/traffic/impl/YgcBasicDataServiceImpl.java
... ... @@ -7,6 +7,7 @@ import org.apache.axiom.om.*;
7 7 import org.apache.axis2.addressing.EndpointReference;
8 8 import org.apache.axis2.client.Options;
9 9 import org.apache.axis2.client.ServiceClient;
  10 +import org.apache.axis2.rpc.client.RPCServiceClient;
10 11 import org.apache.commons.codec.digest.DigestUtils;
11 12 import org.slf4j.Logger;
12 13 import org.slf4j.LoggerFactory;
... ... @@ -18,6 +19,7 @@ import org.w3c.dom.Document;
18 19 import org.w3c.dom.NodeList;
19 20  
20 21 import javax.activation.DataHandler;
  22 +import javax.xml.namespace.QName;
21 23 import javax.xml.parsers.DocumentBuilder;
22 24 import javax.xml.parsers.DocumentBuilderFactory;
23 25 import java.io.*;
... ... @@ -42,14 +44,17 @@ public class YgcBasicDataServiceImpl implements YgcBasicDataService{
42 44 JdbcTemplate jdbcTemplate;
43 45  
44 46 private static String IP = "218.242.195.76:9091";
45   - private static String targetEndpoint = "http://" + IP +"/ygc.TransManager.Basicdown?wsdl";
  47 + private static String downTargetEndpoint = "http://" + IP +"/ygc.TransManager.Basicdown?wsdl";
  48 + private static String upTargetEndpoint = "http://" + IP +"/ygc.TransManager.BasicUpload?wsdl";
46 49 private static String namespace = "http://service.shygc.com";
47 50 private static String userName = "admin";
48 51 private static String passWord = "000000";
49   - private static EndpointReference targetEPR;
  52 + private static EndpointReference downTargetEPR;
  53 + private static EndpointReference upTargetEPR;
50 54 {
51 55 try {
52   - targetEPR = new EndpointReference(targetEndpoint);
  56 + downTargetEPR = new EndpointReference(downTargetEndpoint);
  57 + upTargetEPR = new EndpointReference(upTargetEndpoint);
53 58 } catch (Exception e) {
54 59 e.printStackTrace();
55 60 }
... ... @@ -102,7 +107,7 @@ public class YgcBasicDataServiceImpl implements YgcBasicDataService{
102 107 ServiceClient sender = new ServiceClient();
103 108 Options options = sender.getOptions();
104 109 options.setProperty("SO_TIMEOUT", Integer.valueOf(1800000));
105   - options.setTo(targetEPR);
  110 + options.setTo(downTargetEPR);
106 111 sender.setOptions(options);
107 112 System.out.println("The data in method download: " + data);
108 113 data.build();
... ... @@ -280,4 +285,37 @@ public class YgcBasicDataServiceImpl implements YgcBasicDataService{
280 285 flag = true;
281 286 return flag;
282 287 }
  288 +
  289 + /**
  290 + * 调用方法
  291 + * @param methodName 方法名
  292 + * @param param 参数
  293 + * @return
  294 + */
  295 + public String invokeMethod(String methodName,String param){
  296 + String result = null;
  297 + try {
  298 + // 获得客户端
  299 + RPCServiceClient serviceClient = new RPCServiceClient();
  300 + // 可以在该对象中设置服务端的验证信息
  301 + Options options = serviceClient.getOptions();
  302 + options.setTo(upTargetEPR);
  303 + // 在创建QName对象时,QName类的构造方法的第一个参数表示WSDL文件的命名空间名,也就是<wsdl:definitions>元素的targetNamespace属性值
  304 + QName opAddEntry = new QName(namespace,methodName);
  305 + // 参数,如果有多个,继续往后面增加即可,不用指定参数的名称
  306 + Object[] opAddEntryArgs = new Object[] {param };
  307 + // 返回参数类型,这个和axis1有点区别
  308 + // invokeBlocking方法有三个参数,其中第一个参数的类型是QName对象,表示要调用的方法名;
  309 + // 第二个参数表示要调用的WebService方法的参数值,参数类型为Object[];
  310 + // 第三个参数表示WebService方法的返回值类型的Class对象,参数类型为Class[]。
  311 + // 当方法没有参数时,invokeBlocking方法的第二个参数值不能是null,而要使用new Object[]{}
  312 + // 如果被调用的WebService方法没有返回值,应使用RPCServiceClient类的invokeRobust方法,
  313 + // 该方法只有两个参数,它们的含义与invokeBlocking方法的前两个参数的含义相同
  314 + Class[] classes = new Class[] { String.class };
  315 + result = serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs, classes)[0].toString();
  316 + }catch (Exception e){
  317 + e.printStackTrace();
  318 + }
  319 + return result;
  320 + }
283 321 }
... ...
src/main/resources/static/pages/trafficManage/js/lineStationUpload.js
... ... @@ -13,124 +13,46 @@
13 13 */
14 14  
15 15 (function(){
16   - /**
17   - * 取得编码-公司map
18   - * gsmap["5"] = 南汇公司
19   - * gsmap["5_3"] = 芦潮港分公司
20   - */
21   - function getBusMap(){
22   - // 取得公司信息,替换公司编码
23   - var gsmap = {};
24   - $get('/business/all', null, function(array){
25   - $.each(array, function(i, gs){
26   - var k = gs.upCode + '_' + gs.businessCode;
27   - if(gs.upCode === '88'){
28   - k = gs.businessCode;
29   - }
30   - gsmap[k] = gs.businessName;
31   - });
32   - });
33   - return gsmap;
34   - }
35   - // 填充公司下拉框选择值
36   - $get('/business/all', {upCode_eq: '88'}, function(array){
37   -
38   - // 公司下拉options属性值
39   - var options = '<option value="">请选择...</option>';
40   -
41   - // 遍历array
42   - $.each(array, function(i,d){
43   -
44   - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>';
45   -
46   - });
47   -
48   - // 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions
49   - $('#companySelect').html(options).on('change', setbrancheCompanySelectOptions);
50   -
51   - });
52   -
53   - // 填充分公司下拉框选择值
54   - function setbrancheCompanySelectOptions(){
55   -
56   - // 获取公司下拉框选择值
57   - var businessCode = $('#companySelect').val();
58   -
59   - // 分公司下拉框options属性值
60   - var options = '<option value="">请选择...</option>';
61   -
62   - // 如果公司选择为空则分公司为空 ; 否则查询出所属公司下的分公司名称和相应分公司代码
63   - if(businessCode == null || businessCode ==''){
64   -
65   - // 填充分公司下拉框options
66   - $('#brancheCompanySelect').html(options);
67   -
68   - } else {
69   -
70   - // 查询出所属公司下的分公司名称和相应分公司代码
71   - $get('/business/all', {upCode_eq: businessCode}, function(array){
72   -
73   - // 遍历array
74   - $.each(array, function(i,d){
75   -
76   - options += '<option value="'+d.businessCode+'">'+d.businessName+'</option>';
77   -
78   - // 填充分公司下拉框options
79   - $('#brancheCompanySelect').html(options);
80   -
81   - });
82   - });
83   -
84   - // 填充公司下拉框options,并添加公司下拉框值改变事件setbrancheCompanySelectOptions
85   - $('#brancheCompanySelect').html(options).on('change', setLineAutocompleteOptions);
86   - }
87   - }
88   -
89   - function setLineAutocompleteOptions(){
90   - // 搜索参数集合
91   - var params = {};
92   - // 搜索字段名称
93   - var name;
94   - var items = $("ul.breadcrumb select");
95   - // 遍历items集合
96   - for(var j = 0, item; item = items[j++];){
97   - // 获取字段名称
98   - name = $(item).attr('name');
99   - if(name){
100   - // 赋取相对应的值
101   - params[name] = $(item).val();
102   - }
103   - }
104   - var lines = new Array();
105   - var gsmap = getBusMap();
106   - // 取得所有线路
107   - $get('/line/all', params, function(allLine) {
108   - // 遍历数组
109   - $.each(allLine, function(i, e) {
110   - var companyCode = e.company;
111   - e.company = gsmap[e.company];
112   - e.brancheCompany = gsmap[companyCode+"_"+e.brancheCompany];
113   - var line = '{"hex":"'+e.company+'","label":"'+e.name+'"}';
114   - var obj = jQuery.parseJSON(line);
115   - lines[i]= obj;
116   - });
117   -
118   -
119   - });
120   - // 给输入框绑定autocomplete事件
121   - $("input[name='name_eq']").autocompleter({
122   - highlightMatches: true,
123   - source: lines,
124   - template: '{{ label }} <span>({{ hex }})</span>',
125   - hint: true,
126   - empty: false,
127   - limit: 5,
128   - });
129   - }
130   -
131   -
132   - // 设置autocompleter的宽度和输入框一样
133   - $(".autocompleter").css("width",$("input[name='name_eq']").css("width"))
  16 +
  17 + $('#line').select2({
  18 + ajax: {
  19 + url: '/realSchedule/findLine',
  20 + type: 'post',
  21 + dataType: 'json',
  22 + delay: 150,
  23 + data: function(params){
  24 + return{line: params.term};
  25 + },
  26 + processResults: function (data) {
  27 + return {
  28 + results: data
  29 + };
  30 + },
  31 + cache: true
  32 + },
  33 + templateResult: function(repo){
  34 + if (repo.loading) return repo.text;
  35 + var h = '<span>'+repo.text+'</span>';
  36 + return h;
  37 + },
  38 + escapeMarkup: function (markup) { return markup; },
  39 + minimumInputLength: 1,
  40 + templateSelection: function(repo){
  41 + return repo.text;
  42 + },
  43 + language: {
  44 + noResults: function(){
  45 + return '<span style="color:red;font-size: 12px;">没有搜索到线路!</span>';
  46 + },
  47 + inputTooShort : function(e) {
  48 + return '<span style="color:gray;font-size: 12px;"><i class="fa fa-search"></i> 输入线路搜索线路</span>';
  49 + },
  50 + searching : function() {
  51 + return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>';
  52 + }
  53 + }
  54 + });
  55 +
134 56 // 绑定查询事件
135 57 $("#search").click(searchM);
136 58 // 绑定上传事件
... ... @@ -149,7 +71,7 @@
149 71 $("#right_div table tbody").empty();
150 72 var params = {};
151 73 // 取得输入框的值
152   - var inputs = $("ul.breadcrumb input");
  74 + var inputs = $(".param input,select");
153 75 // 遍历数组
154 76 $.each(inputs, function(i, element) {
155 77 params[$(element).attr("name")] = $(element).val();
... ... @@ -168,17 +90,36 @@
168 90  
169 91 // 上传方法
170 92 function uploadM() {
171   - var params = {};
172   - // 取得输入框的值
173   - var trs = $("#right_div tbody tr");
174   - if (trs.length == 0) {
175   - alert("请选择模板");
176   - return;
177   - }
178   - // 遍历数组
179   - $.each(trs, function(i, element) {
180   - alert($(".ttInfoId", element).html());
181   - });
  93 + // 取得输入框的值
  94 + var trs = $("#right_div tbody tr input");
  95 + if (trs.length == 0) {
  96 + alert("请选择线路");
  97 + return;
  98 + }else if(trs.length > 1){
  99 + alert("一次只能上传一条线路");
  100 + return;
  101 + }
  102 + var ids ="0,";
  103 + // 遍历数组
  104 + $.each(trs, function(i, element) {
  105 + ids +=$(element).val()+",";
  106 + });
  107 + var params = {"ids":ids};
  108 + $.ajax({
  109 + type: 'get',url: '/trmg/setXL',
  110 + data: params ,dataType:'text',
  111 + success:function(data) {
  112 + if(data == 'success'){
  113 + alert("上传成功");
  114 + }else{
  115 + alert("上传失败");
  116 + }
  117 +
  118 + }, error : function() {
  119 + alert("操作失败");
  120 + }
  121 +
  122 + });
182 123 }
183 124  
184 125 // 表格行的单击事件
... ...
src/main/resources/static/pages/trafficManage/js/timeTempletUpload.js
... ... @@ -183,29 +183,6 @@
183 183 }
184 184  
185 185 // 绑定查询事件
186   - $("#setXL").click(setXLF);
187   -
188   - function setXLF() {
189   - var params = {};
190   - // 取得输入框的值
191   - var inputs = $(".param input,select");debugger;
192   - // 遍历数组
193   - $.each(inputs, function(i, element) {
194   - params[$(element).attr("name")] = $(element).val();
195   - });
196   - $.ajax({
197   - type: 'get',url: '/trmg/setXL',
198   - data: params ,dataType:'text',
199   - success:function(data) {
200   - alert(data);
201   - }, error : function() {
202   - alert("操作失败");
203   - }
204   -
205   - });
206   - }
207   -
208   - // 绑定查询事件
209 186 $("#setCL").click(setCLF);
210 187 var params = {};
211 188 function setCLF() {
... ...
src/main/resources/static/pages/trafficManage/lineStationUpload.html
1 1 <link href="css/trafficManage.css" rel="stylesheet" type="text/css" />
2   -<link href="css/autocompleter.css" rel="stylesheet" type="text/css" />
3 2 <ul class="page-breadcrumb breadcrumb">
4 3 <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
5 4 <li><span class="active">运维管理</span> <i class="fa fa-circle"></i></li>
... ... @@ -7,17 +6,16 @@
7 6 </ul>
8 7 <div class="tab_line">
9 8 <div class="col-md-12">
10   - <ul class="breadcrumb">
11   - <li>公司:</li>
12   - <li><select name="company_eq" class="form-control" id="companySelect"></select></li>
13   - <li>分公司:</li>
14   - <li><select name="brancheCompany_eq" class="form-control" id="brancheCompanySelect"></select></li>
15   - <li>线路名称:</li>
16   - <li><input type="text" class="form-control form-filter input-sm"
17   - name="name_eq" placeholder="请输入线路名称" maxlength="40" /></li>
18   - <li><a class="btn btn-circle blue" id="search">查询</a></li>
19   - <li><a class="btn btn-circle red" id="upload">上传</a></li>
20   - </ul>
  9 + <form class="form-inline" action="">
  10 + <div style="display: inline-block;" class="param">
  11 + <span class="item-label" style="width: 80px;">线路名称: </span>
  12 + <select class="form-control" name="lineCode_like" id="line" style="width: 180px;"></select>
  13 + </div>
  14 + <div class="form-group" style="display: inline-block;margin-left: 15px;">
  15 + <input class="btn btn-default" type="button" id="search" value="查询"/>
  16 + <input class="btn btn-default" type="button" id="upload" value="上传"/>
  17 + </div>
  18 + </form>
21 19 </div>
22 20 <!-- Begin: left-div -->
23 21 <div class="col-md-5 panel-wrap" style="height: 60%;">
... ... @@ -63,6 +61,7 @@
63 61 </td>
64 62 <td>
65 63 {{obj.lineCode}}
  64 + <input type="hidden" value="{{obj.lineCode}}"/>
66 65 </td>
67 66 <td class="ttInfoId">
68 67 {{obj.name}}
... ...