Commit 98b3ce7d2ccf4ec7d0bbabe368141bb7dab153a5

Authored by 李强
1 parent 657931da

李强

src/main/java/com/bsth/controller/LineController.java
@@ -51,8 +51,11 @@ public class LineController extends BaseController<Line, Integer> { @@ -51,8 +51,11 @@ public class LineController extends BaseController<Line, Integer> {
51 @RequestMapping(method = RequestMethod.POST) 51 @RequestMapping(method = RequestMethod.POST)
52 public Map<String, Object> save(Line t){ 52 public Map<String, Object> save(Line t){
53 53
54 - t.setId(Integer.valueOf(t.getLineCode()));  
55 - 54 + if(t.getId()==null) {
  55 +
  56 + t.setId(Integer.valueOf(t.getLineCode()));
  57 +
  58 + }
56 return service.save(t); 59 return service.save(t);
57 } 60 }
58 } 61 }
src/main/java/com/bsth/repository/StationRouteRepository.java
@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query; @@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query;
7 import org.springframework.stereotype.Repository; 7 import org.springframework.stereotype.Repository;
8 import org.springframework.transaction.annotation.Transactional; 8 import org.springframework.transaction.annotation.Transactional;
9 9
  10 +import com.bsth.entity.Line;
  11 +import com.bsth.entity.LineInformation;
10 import com.bsth.entity.StationRoute; 12 import com.bsth.entity.StationRoute;
11 13
12 /** 14 /**
@@ -212,4 +214,6 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int @@ -212,4 +214,6 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
212 " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " + 214 " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " +
213 " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true) 215 " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
214 List<Object[]> findStationRouteInfo(Integer id); 216 List<Object[]> findStationRouteInfo(Integer id);
  217 +
  218 + List<StationRoute> findByLine(Line line);
215 } 219 }
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
@@ -563,8 +563,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -563,8 +563,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
563 563
564 Test test= new Test(); 564 Test test= new Test();
565 565
  566 +
566 File textFile = clientUtils.GetFtpFile(url, port, username, password, remotePath, textFileName); 567 File textFile = clientUtils.GetFtpFile(url, port, username, password, remotePath, textFileName);
567 568
  569 + /*File[] sources = new File[] {textFile};*/
568 File[] sources = new File[] {textFile}; 570 File[] sources = new File[] {textFile};
569 571
570 File target = new File(odlGzFileName); 572 File target = new File(odlGzFileName);
@@ -598,10 +600,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ @@ -598,10 +600,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
598 String stationRStr = ""; 600 String stationRStr = "";
599 601
600 // windows下的文本文件换行符 602 // windows下的文本文件换行符
601 - // String enterStr = "\r\n"; 603 + //String enterStr = "\r\n";
602 604
603 // linux/unix下的文本文件换行符 605 // linux/unix下的文本文件换行符
604 - String enterStr = "\r"; 606 + String enterStr = "\r";
605 607
606 if(objects.size()>0) { 608 if(objects.size()>0) {
607 609
src/main/java/com/bsth/service/impl/StationServiceImpl.java
@@ -161,6 +161,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -161,6 +161,11 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
161 // 更新里程 161 // 更新里程
162 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage); 162 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
163 163
  164 + if(directions==0) {
  165 +
  166 + lineUpdateStationName(resultLine);
  167 +
  168 + }
164 resultMap.put("status", ResponseCode.SUCCESS); 169 resultMap.put("status", ResponseCode.SUCCESS);
165 170
166 } catch (Exception e) { 171 } catch (Exception e) {
@@ -175,6 +180,53 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -175,6 +180,53 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
175 } 180 }
176 181
177 182
  183 + public void lineUpdateStationName(Line resultLine) {
  184 +
  185 + List<StationRoute> stationRoutes = routeRepository.findByLine(resultLine);
  186 +
  187 + int sizeL = stationRoutes.size();
  188 +
  189 + if(sizeL<0) {
  190 +
  191 + return;
  192 +
  193 + }
  194 +
  195 + if(resultLine.getStartStationName()==null){
  196 +
  197 + for(int k =0;k<sizeL;k++) {
  198 +
  199 + StationRoute tempS = stationRoutes.get(k);
  200 +
  201 + if(tempS.getStationMark().equals("B") && tempS.getDirections()==0) {
  202 +
  203 + resultLine.setStartStationName(tempS.getStationName());
  204 +
  205 + lineRepository.save(resultLine);
  206 +
  207 + }
  208 + }
  209 +
  210 + };
  211 +
  212 + if(resultLine.getEndStationName()==null) {
  213 +
  214 + for(int k =0;k<sizeL;k++) {
  215 +
  216 + StationRoute tempS = stationRoutes.get(k);
  217 +
  218 + if(tempS.getStationMark().equals("E") && tempS.getDirections()==0) {
  219 +
  220 + resultLine.setEndStationName(tempS.getStationName());
  221 +
  222 + lineRepository.save(resultLine);
  223 +
  224 + }
  225 + }
  226 +
  227 + }
  228 + }
  229 +
178 /** 230 /**
179 * @Description :保存站点和站点路由信息(系统规划) 231 * @Description :保存站点和站点路由信息(系统规划)
180 * 232 *
@@ -877,7 +929,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -877,7 +929,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
877 929
878 String stationRouteCodeArray [] = stationRouteCodeStr.split("_"); 930 String stationRouteCodeArray [] = stationRouteCodeStr.split("_");
879 931
880 - stationRouteCode = Integer.parseInt(stationRouteCodeArray[0]+1); 932 + stationRouteCode = Integer.parseInt(stationRouteCodeArray[0].toString())+1;
881 933
882 934
883 }else { 935 }else {
@@ -1436,6 +1488,12 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem @@ -1436,6 +1488,12 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1436 // 更新里程 1488 // 更新里程
1437 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage); 1489 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
1438 1490
  1491 + if(directions==0) {
  1492 +
  1493 + lineUpdateStationName(resultLine);
  1494 +
  1495 + }
  1496 +
1439 resultMap.put("status", ResponseCode.SUCCESS); 1497 resultMap.put("status", ResponseCode.SUCCESS);
1440 1498
1441 } catch (Exception e) { 1499 } catch (Exception e) {
src/main/java/com/bsth/util/FTPClientUtils.java
1 package com.bsth.util; 1 package com.bsth.util;
2 2
  3 +import java.io.BufferedReader;
3 import java.io.ByteArrayInputStream; 4 import java.io.ByteArrayInputStream;
4 import java.io.File; 5 import java.io.File;
5 import java.io.FileInputStream; 6 import java.io.FileInputStream;
@@ -7,10 +8,12 @@ import java.io.FileNotFoundException; @@ -7,10 +8,12 @@ import java.io.FileNotFoundException;
7 import java.io.FileOutputStream; 8 import java.io.FileOutputStream;
8 import java.io.IOException; 9 import java.io.IOException;
9 import java.io.InputStream; 10 import java.io.InputStream;
  11 +import java.io.InputStreamReader;
10 import java.io.OutputStream; 12 import java.io.OutputStream;
11 import java.io.UnsupportedEncodingException; 13 import java.io.UnsupportedEncodingException;
12 14
13 import org.apache.commons.net.ftp.FTPClient; 15 import org.apache.commons.net.ftp.FTPClient;
  16 +import org.apache.commons.net.ftp.FTPFile;
14 import org.apache.commons.net.ftp.FTPReply; 17 import org.apache.commons.net.ftp.FTPReply;
15 /** 18 /**
16 * @Description: 向FTP服务器上传文件 19 * @Description: 向FTP服务器上传文件
@@ -66,13 +69,16 @@ public class FTPClientUtils { @@ -66,13 +69,16 @@ public class FTPClientUtils {
66 69
67 ftp.changeWorkingDirectory(path); 70 ftp.changeWorkingDirectory(path);
68 71
69 - ftp.storeFile(filename, input); 72 + ftp.enterLocalPassiveMode();
  73 +
  74 + success = ftp.storeFile(new String(filename.getBytes("gbk"),"gbk"), input);
  75 + /*success = ftp.storeFile(filename, input); */
70 76
71 input.close(); 77 input.close();
72 78
73 ftp.logout(); 79 ftp.logout();
74 80
75 - success = true; 81 + // success = true;
76 82
77 } catch (IOException e) { 83 } catch (IOException e) {
78 84
@@ -170,8 +176,6 @@ public class FTPClientUtils { @@ -170,8 +176,6 @@ public class FTPClientUtils {
170 // 登录 176 // 登录
171 ftp.login(username, password); 177 ftp.login(username, password);
172 178
173 -  
174 -  
175 reply = ftp.getReplyCode(); 179 reply = ftp.getReplyCode();
176 180
177 if (!FTPReply.isPositiveCompletion(reply)) { 181 if (!FTPReply.isPositiveCompletion(reply)) {
@@ -185,7 +189,9 @@ public class FTPClientUtils { @@ -185,7 +189,9 @@ public class FTPClientUtils {
185 189
186 ftp.changeWorkingDirectory(remotePath); 190 ftp.changeWorkingDirectory(remotePath);
187 191
188 - success = ftp.deleteFile(fileName); 192 + /*success = ftp.deleteFile(fileName);*/
  193 +
  194 + success = ftp.deleteFile(new String(fileName.getBytes("gbk"),"gbk"));
189 195
190 ftp.logout(); 196 ftp.logout();
191 197
@@ -217,6 +223,8 @@ public class FTPClientUtils { @@ -217,6 +223,8 @@ public class FTPClientUtils {
217 public static File GetFtpFile(String url, int port, String username, String password, String remotePath, String fileName){ 223 public static File GetFtpFile(String url, int port, String username, String password, String remotePath, String fileName){
218 224
219 FTPClient ftp = new FTPClient(); 225 FTPClient ftp = new FTPClient();
  226 +
  227 + /*File destFile = new File(fileName); */
220 228
221 File destFile = new File(fileName); 229 File destFile = new File(fileName);
222 230
@@ -247,16 +255,42 @@ public class FTPClientUtils { @@ -247,16 +255,42 @@ public class FTPClientUtils {
247 ftp.disconnect(); 255 ftp.disconnect();
248 256
249 } 257 }
250 - 258 +
251 // 转移到FTP服务器目录 259 // 转移到FTP服务器目录
252 - 260 +
253 ftp.changeWorkingDirectory(remotePath); 261 ftp.changeWorkingDirectory(remotePath);
254 262
255 - File srcFile = new File(fileName); 263 + ftp.enterLocalPassiveMode();
  264 +
  265 + FTPFile[] fs = ftp.listFiles();
  266 +
  267 + System.out.println(fs.length);
  268 +
  269 + /* for (FTPFile ff : fs) {
  270 + //解决中文乱码问题,两次解码
  271 + byte[] bytes=ff.getName().getBytes("gbk");
  272 + String fn=new String(bytes,"gbk");
  273 + if (fn.equals(fileName)) {
  274 + //6.写操作,将其写入到本地文件中
  275 + File localFile = new File(ff.getName());
  276 +
  277 +
  278 + OutputStream is = new FileOutputStream(localFile);
  279 + ftp.retrieveFile(ff.getName(), is);
  280 + is.close();
  281 + }
  282 + } */
  283 +
  284 + /* File srcFile = new File(fileName); */
  285 +
  286 + /* File srcFile = new File(new String(fileName.getBytes("gbk"),"gbk"));*/
256 287
257 int byteread = 0; // 读取的字节数 288 int byteread = 0; // 读取的字节数
  289 +
  290 + /* in = ftp.retrieveFileStream(remotePath + fileName);*/
258 291
259 - in = ftp.retrieveFileStream(fileName); 292 + in = ftp.retrieveFileStream(new String(fileName.getBytes("gbk"),"gbk"));
  293 +
260 294
261 out = new FileOutputStream(destFile); 295 out = new FileOutputStream(destFile);
262 296
src/main/resources/ftp.properties
@@ -2,7 +2,7 @@ ftp.url=222.66.0.205 @@ -2,7 +2,7 @@ ftp.url=222.66.0.205
2 ftp.port=21 2 ftp.port=21
3 ftp.username=transport 3 ftp.username=transport
4 ftp.password=transport123 4 ftp.password=transport123
5 -ftp.path= down/ 5 +ftp.path=down/
6 6
7 #ftp.url=192.168.168.101 7 #ftp.url=192.168.168.101
8 #ftp.port=21 8 #ftp.port=21
src/main/resources/static/pages/base/stationroute/editsection.html
@@ -399,9 +399,7 @@ $(&#39;#edit_section_mobal&#39;).on(&#39;editSectionMobal_show&#39;, function(e, map_,ajaxd,sect @@ -399,9 +399,7 @@ $(&#39;#edit_section_mobal&#39;).on(&#39;editSectionMobal_show&#39;, function(e, map_,ajaxd,sect
399 399
400 console.log(params); 400 console.log(params);
401 401
402 - return;  
403 -  
404 - ajaxd.sectionUpdata(params,function(resuntDate) { 402 + ajaxd.sectionUpdate(params,function(resuntDate) {
405 403
406 if(resuntDate.status=='SUCCESS') { 404 if(resuntDate.status=='SUCCESS') {
407 405
src/main/resources/static/pages/base/stationroute/js/stationroute-list-function.js
@@ -431,6 +431,9 @@ var PublicFunctions = function () { @@ -431,6 +431,9 @@ var PublicFunctions = function () {
431 431
432 var Line = LineObj.getLineObj(); 432 var Line = LineObj.getLineObj();
433 433
  434 + // 刷行左边树
  435 + PublicFunctions.resjtreeDate(Line.id,stationRouteDirections);
  436 +
434 /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:上行路段数据 */ 437 /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:上行路段数据 */
435 GetAjaxData.getSectionRouteInfo(Line.id,stationRouteDirections,function(data) { 438 GetAjaxData.getSectionRouteInfo(Line.id,stationRouteDirections,function(data) {
436 439
src/main/resources/static/pages/base/stationroute/list.html
@@ -85,7 +85,7 @@ @@ -85,7 +85,7 @@
85 </div> 85 </div>
86 <!-- 树 --> 86 <!-- 树 -->
87 <div class="portlet-body"> 87 <div class="portlet-body">
88 - <div id="station_Up_tree" style="height: 550px;overflow-y: auto;"></div> 88 + <div id="station_Up_tree" style="height: auto;max-height: 500px;overflow-y: auto;"></div>
89 </div> 89 </div>
90 </div> 90 </div>
91 91
@@ -167,7 +167,7 @@ @@ -167,7 +167,7 @@
167 </div> 167 </div>
168 <!-- 树 --> 168 <!-- 树 -->
169 <div class="portlet-body"> 169 <div class="portlet-body">
170 - <div id="station_Down_tree" style="height: 550px;overflow-y: auto;"></div> 170 + <div id="station_Down_tree" style="height: auto;max-height: 500px;overflow-y: auto;"></div>
171 </div> 171 </div>
172 </div> 172 </div>
173 173