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 51 @RequestMapping(method = RequestMethod.POST)
52 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 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 7 import org.springframework.stereotype.Repository;
8 8 import org.springframework.transaction.annotation.Transactional;
9 9  
  10 +import com.bsth.entity.Line;
  11 +import com.bsth.entity.LineInformation;
10 12 import com.bsth.entity.StationRoute;
11 13  
12 14 /**
... ... @@ -212,4 +214,6 @@ public interface StationRouteRepository extends BaseRepository&lt;StationRoute, Int
212 214 " s.update_date AS stationRouteUpdateDate FROM bsth_c_stationroute s WHERE s.id = ?1 ) a " +
213 215 " LEFT JOIN bsth_c_station b ON a.stationRouteStation = b.id", nativeQuery=true)
214 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 563  
564 564 Test test= new Test();
565 565  
  566 +
566 567 File textFile = clientUtils.GetFtpFile(url, port, username, password, remotePath, textFileName);
567 568  
  569 + /*File[] sources = new File[] {textFile};*/
568 570 File[] sources = new File[] {textFile};
569 571  
570 572 File target = new File(odlGzFileName);
... ... @@ -598,10 +600,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl&lt;StationRoute, Integ
598 600 String stationRStr = "";
599 601  
600 602 // windows下的文本文件换行符
601   - // String enterStr = "\r\n";
  603 + //String enterStr = "\r\n";
602 604  
603 605 // linux/unix下的文本文件换行符
604   - String enterStr = "\r";
  606 + String enterStr = "\r";
605 607  
606 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 161 // 更新里程
162 162 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
163 163  
  164 + if(directions==0) {
  165 +
  166 + lineUpdateStationName(resultLine);
  167 +
  168 + }
164 169 resultMap.put("status", ResponseCode.SUCCESS);
165 170  
166 171 } catch (Exception e) {
... ... @@ -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 231 * @Description :保存站点和站点路由信息(系统规划)
180 232 *
... ... @@ -877,7 +929,7 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
877 929  
878 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 935 }else {
... ... @@ -1436,6 +1488,12 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
1436 1488 // 更新里程
1437 1489 updateLineInfoUpOrDownMileage( resultLine , directions, sumUpOrDownMileage);
1438 1490  
  1491 + if(directions==0) {
  1492 +
  1493 + lineUpdateStationName(resultLine);
  1494 +
  1495 + }
  1496 +
1439 1497 resultMap.put("status", ResponseCode.SUCCESS);
1440 1498  
1441 1499 } catch (Exception e) {
... ...
src/main/java/com/bsth/util/FTPClientUtils.java
1 1 package com.bsth.util;
2 2  
  3 +import java.io.BufferedReader;
3 4 import java.io.ByteArrayInputStream;
4 5 import java.io.File;
5 6 import java.io.FileInputStream;
... ... @@ -7,10 +8,12 @@ import java.io.FileNotFoundException;
7 8 import java.io.FileOutputStream;
8 9 import java.io.IOException;
9 10 import java.io.InputStream;
  11 +import java.io.InputStreamReader;
10 12 import java.io.OutputStream;
11 13 import java.io.UnsupportedEncodingException;
12 14  
13 15 import org.apache.commons.net.ftp.FTPClient;
  16 +import org.apache.commons.net.ftp.FTPFile;
14 17 import org.apache.commons.net.ftp.FTPReply;
15 18 /**
16 19 * @Description: 向FTP服务器上传文件
... ... @@ -66,13 +69,16 @@ public class FTPClientUtils {
66 69  
67 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 77 input.close();
72 78  
73 79 ftp.logout();
74 80  
75   - success = true;
  81 + // success = true;
76 82  
77 83 } catch (IOException e) {
78 84  
... ... @@ -170,8 +176,6 @@ public class FTPClientUtils {
170 176 // 登录
171 177 ftp.login(username, password);
172 178  
173   -
174   -
175 179 reply = ftp.getReplyCode();
176 180  
177 181 if (!FTPReply.isPositiveCompletion(reply)) {
... ... @@ -185,7 +189,9 @@ public class FTPClientUtils {
185 189  
186 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 196 ftp.logout();
191 197  
... ... @@ -217,6 +223,8 @@ public class FTPClientUtils {
217 223 public static File GetFtpFile(String url, int port, String username, String password, String remotePath, String fileName){
218 224  
219 225 FTPClient ftp = new FTPClient();
  226 +
  227 + /*File destFile = new File(fileName); */
220 228  
221 229 File destFile = new File(fileName);
222 230  
... ... @@ -247,16 +255,42 @@ public class FTPClientUtils {
247 255 ftp.disconnect();
248 256  
249 257 }
250   -
  258 +
251 259 // 转移到FTP服务器目录
252   -
  260 +
253 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 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 295 out = new FileOutputStream(destFile);
262 296  
... ...
src/main/resources/ftp.properties
... ... @@ -2,7 +2,7 @@ ftp.url=222.66.0.205
2 2 ftp.port=21
3 3 ftp.username=transport
4 4 ftp.password=transport123
5   -ftp.path= down/
  5 +ftp.path=down/
6 6  
7 7 #ftp.url=192.168.168.101
8 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 399  
400 400 console.log(params);
401 401  
402   - return;
403   -
404   - ajaxd.sectionUpdata(params,function(resuntDate) {
  402 + ajaxd.sectionUpdate(params,function(resuntDate) {
405 403  
406 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 431  
432 432 var Line = LineObj.getLineObj();
433 433  
  434 + // 刷行左边树
  435 + PublicFunctions.resjtreeDate(Line.id,stationRouteDirections);
  436 +
434 437 /** 查询上行路段信息 @param:<Line.id:线路Id;0:上行> @return:data:上行路段数据 */
435 438 GetAjaxData.getSectionRouteInfo(Line.id,stationRouteDirections,function(data) {
436 439  
... ...
src/main/resources/static/pages/base/stationroute/list.html
... ... @@ -85,7 +85,7 @@
85 85 </div>
86 86 <!-- 树 -->
87 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 89 </div>
90 90 </div>
91 91  
... ... @@ -167,7 +167,7 @@
167 167 </div>
168 168 <!-- 树 -->
169 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 171 </div>
172 172 </div>
173 173  
... ...