Commit 0fdefb5fb3fee81dd110a2433e9220fbb44fed86

Authored by 娄高锋
2 parents 7690f231 13886e75

Merge branch 'pudong' of 192.168.168.201:panzhaov5/bsth_control into pudong

src/main/java/com/bsth/controller/schedule/core/TTInfoController.java
@@ -55,6 +55,23 @@ public class TTInfoController extends BController<TTInfo, Long> { @@ -55,6 +55,23 @@ public class TTInfoController extends BController<TTInfo, Long> {
55 return rtn; 55 return rtn;
56 } 56 }
57 57
  58 + @RequestMapping(value = "/versiondesc2/{lineid}/{status}")
  59 + public Map<String, Object> getLineVersionDesc2(
  60 + @PathVariable(value = "lineid") Integer lineid,
  61 + @PathVariable(value = "status") Integer status) {
  62 + Map<String, Object> rtn = new HashMap<>();
  63 + try {
  64 + rtn.put("status", ResponseCode.SUCCESS);
  65 + rtn.put("data", ttInfoService.getLineVersions(lineid, status));
  66 +
  67 + } catch (Exception exp) {
  68 + rtn.put("status", ResponseCode.ERROR);
  69 + rtn.put("msg", exp.getMessage());
  70 + }
  71 +
  72 + return rtn;
  73 + }
  74 +
58 @RequestMapping(value = "/validate_name", method = RequestMethod.GET) 75 @RequestMapping(value = "/validate_name", method = RequestMethod.GET)
59 public Map<String, Object> validate_name(@RequestParam Map<String, Object> param) { 76 public Map<String, Object> validate_name(@RequestParam Map<String, Object> param) {
60 Map<String, Object> rtn = new HashMap<>(); 77 Map<String, Object> rtn = new HashMap<>();
src/main/java/com/bsth/repository/schedule/TTInfoRepository.java
@@ -11,7 +11,9 @@ import org.springframework.data.jpa.repository.EntityGraph; @@ -11,7 +11,9 @@ import org.springframework.data.jpa.repository.EntityGraph;
11 import org.springframework.data.jpa.repository.Query; 11 import org.springframework.data.jpa.repository.Query;
12 import org.springframework.stereotype.Repository; 12 import org.springframework.stereotype.Repository;
13 13
  14 +import javax.persistence.Tuple;
14 import java.util.List; 15 import java.util.List;
  16 +import java.util.Map;
15 17
16 /** 18 /**
17 * Created by xu on 16/5/12. 19 * Created by xu on 16/5/12.
@@ -31,4 +33,19 @@ public interface TTInfoRepository extends BaseRepository&lt;TTInfo, Long&gt; { @@ -31,4 +33,19 @@ public interface TTInfoRepository extends BaseRepository&lt;TTInfo, Long&gt; {
31 33
32 @Query("select t from TTInfo t where t.xl = ?1 and t.isCancel = false") 34 @Query("select t from TTInfo t where t.xl = ?1 and t.isCancel = false")
33 List<TTInfo> findInCanceledByXl(Line xl); 35 List<TTInfo> findInCanceledByXl(Line xl);
  36 +
  37 + @Query(value = "select new map(lv.name as name, lv.startDate as sd, " +
  38 + "lv.status as status, lv.versions as version) " +
  39 + "from LineVersions lv where lv.line.id = ?1 ")
  40 + List<Map<String, Object>> findLineVersionDescs(Integer lineId);
  41 +
  42 + @Query(value = "select new map(lv.name as name, lv.startDate as sd, " +
  43 + "lv.status as status, lv.versions as version) " +
  44 + "from LineVersions lv where lv.line.id = ?1 and lv.versions = ?2 ")
  45 + List<Map<String, Object>> findLineVersionDescs2(Integer lineId, Integer version);
  46 +
  47 + @Query(value = "select new map(lv.name as name, lv.versions as version) " +
  48 + "from LineVersions lv where lv.line.id = ?1 and lv.status = ?2 ")
  49 + List<Map<String, Object>> findLineVersionDescs3(Integer lineId, Integer status);
  50 +
34 } 51 }
src/main/java/com/bsth/service/schedule/TTInfoService.java
@@ -21,4 +21,6 @@ public interface TTInfoService extends BService&lt;TTInfo, Long&gt; { @@ -21,4 +21,6 @@ public interface TTInfoService extends BService&lt;TTInfo, Long&gt; {
21 21
22 String getLineVersionDesc(Integer lineId, Integer version); 22 String getLineVersionDesc(Integer lineId, Integer version);
23 23
  24 + List<Map<String, Object>> getLineVersions(Integer lineId, Integer status);
  25 +
24 } 26 }
src/main/java/com/bsth/service/schedule/impl/TTInfoServiceImpl.java
1 package com.bsth.service.schedule.impl; 1 package com.bsth.service.schedule.impl;
2 2
3 -import com.bsth.entity.LineVersions;  
4 import com.bsth.entity.schedule.TTInfo; 3 import com.bsth.entity.schedule.TTInfo;
5 import com.bsth.entity.schedule.TTInfoBackup; 4 import com.bsth.entity.schedule.TTInfoBackup;
6 import com.bsth.entity.schedule.TTInfoDetail; 5 import com.bsth.entity.schedule.TTInfoDetail;
7 import com.bsth.repository.schedule.TTInfoBackupRepository; 6 import com.bsth.repository.schedule.TTInfoBackupRepository;
8 import com.bsth.repository.schedule.TTInfoDetailRepository; 7 import com.bsth.repository.schedule.TTInfoDetailRepository;
9 import com.bsth.repository.schedule.TTInfoRepository; 8 import com.bsth.repository.schedule.TTInfoRepository;
10 -import com.bsth.service.LineVersionsService;  
11 import com.bsth.service.schedule.TTInfoService; 9 import com.bsth.service.schedule.TTInfoService;
12 import com.bsth.service.schedule.exception.ScheduleException; 10 import com.bsth.service.schedule.exception.ScheduleException;
13 import com.bsth.service.schedule.utils.TimeTableProto; 11 import com.bsth.service.schedule.utils.TimeTableProto;
@@ -24,6 +22,7 @@ import org.springframework.util.CollectionUtils; @@ -24,6 +22,7 @@ import org.springframework.util.CollectionUtils;
24 22
25 import java.io.PrintWriter; 23 import java.io.PrintWriter;
26 import java.io.StringWriter; 24 import java.io.StringWriter;
  25 +import java.sql.Timestamp;
27 import java.util.*; 26 import java.util.*;
28 27
29 /** 28 /**
@@ -40,8 +39,6 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI @@ -40,8 +39,6 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI
40 private TTInfoDetailRepository ttInfoDetailRepository; 39 private TTInfoDetailRepository ttInfoDetailRepository;
41 @Autowired 40 @Autowired
42 private TTInfoBackupRepository ttInfoBackupRepository; 41 private TTInfoBackupRepository ttInfoBackupRepository;
43 - @Autowired  
44 - private LineVersionsService lineVersionsService;  
45 42
46 @Override 43 @Override
47 public void validate_name(TTInfo ttInfo) throws ScheduleException { 44 public void validate_name(TTInfo ttInfo) throws ScheduleException {
@@ -140,15 +137,18 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI @@ -140,15 +137,18 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI
140 137
141 @Override 138 @Override
142 public List<Map<String, Object>> getLineStationRouteVersions(Integer lineId) { 139 public List<Map<String, Object>> getLineStationRouteVersions(Integer lineId) {
143 - // 获取线路版本  
144 - List<LineVersions> lineVersionsList = lineVersionsService.findByLineCode(lineId); 140 + // 获取线路版本数据
  141 + List<Map<String, Object>> lineVersionDescs = ttInfoRepository.findLineVersionDescs(lineId);
145 // 按照version版本降序排序 142 // 按照version版本降序排序
146 - Collections.sort(lineVersionsList, new Comparator<LineVersions>() { 143 + Collections.sort(lineVersionDescs, new Comparator<Map<String, Object>>() {
147 @Override 144 @Override
148 - public int compare(LineVersions o1, LineVersions o2) {  
149 - if (o1.getVersions() > o2.getVersions()) { 145 + public int compare(Map<String, Object> o1, Map<String, Object> o2) {
  146 + int o1_v = Integer.parseInt(o1.get("version").toString());
  147 + int o2_v = Integer.parseInt(o2.get("version").toString());
  148 +
  149 + if (o1_v > o2_v) {
150 return -1; 150 return -1;
151 - } else if (o1.getVersions() < o2.getVersions()) { 151 + } else if (o1_v < o2_v) {
152 return 1; 152 return 1;
153 } else { 153 } else {
154 return 0; 154 return 0;
@@ -158,14 +158,19 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI @@ -158,14 +158,19 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI
158 158
159 // 取最开始的2条记录 159 // 取最开始的2条记录
160 List<Map<String, Object>> mapList = new ArrayList<>(); 160 List<Map<String, Object>> mapList = new ArrayList<>();
161 - for (LineVersions lv: lineVersionsList) {  
162 - String vname = lv.getName();  
163 - String rq = lv.getStartDate() == null ? "未知启用日期" : new DateTime(lv.getStartDate()).toString("YYYY年MM月dd日");  
164 - String sdesc = lv.getStatus() == 0 ? "历史" : (lv.getStatus() == 1 ? "当前" : "待更新"); 161 + for (Map<String, Object> lv: lineVersionDescs) {
  162 + String t_name = (String) lv.get("name");
  163 + Timestamp t_sd = (Timestamp) lv.get("sd");
  164 + int status = Integer.parseInt(lv.get("status").toString());
  165 + int version = Integer.parseInt(lv.get("version").toString());
  166 +
  167 + String vname = t_name;
  168 + String rq = t_sd == null ? "未知启用日期" : new DateTime(t_sd).toString("YYYY年MM月dd日");
  169 + String sdesc = status == 0 ? "历史" : (status == 1 ? "当前" : "待更新");
165 170
166 Map<String, Object> value = new HashMap<>(); 171 Map<String, Object> value = new HashMap<>();
167 value.put("desc", vname + "-" + rq + "-" + sdesc); 172 value.put("desc", vname + "-" + rq + "-" + sdesc);
168 - value.put("version", lv.getVersions()); 173 + value.put("version", version);
169 174
170 mapList.add(value); 175 mapList.add(value);
171 176
@@ -180,28 +185,34 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI @@ -180,28 +185,34 @@ public class TTInfoServiceImpl extends BServiceImpl&lt;TTInfo, Long&gt; implements TTI
180 @Override 185 @Override
181 public String getLineVersionDesc(Integer lineId, Integer version) { 186 public String getLineVersionDesc(Integer lineId, Integer version) {
182 // 查找指定版本,并判定 187 // 查找指定版本,并判定
183 - Map<String, Object> param = new HashMap<>();  
184 - param.put("line_eq", lineId);  
185 - param.put("versions_eq", version);  
186 - List<LineVersions> lineVersionsList = (List<LineVersions>) lineVersionsService.list(param); 188 + List<Map<String, Object>> lineVersionDescs = ttInfoRepository.findLineVersionDescs2(lineId, version);
187 189
188 - LineVersions lv;  
189 - if (CollectionUtils.isEmpty(lineVersionsList)) { 190 + Map<String, Object> lv;
  191 + if (CollectionUtils.isEmpty(lineVersionDescs)) {
190 return "未知版本"; 192 return "未知版本";
191 - } else if (lineVersionsList.size() > 1) { 193 + } else if (lineVersionDescs.size() > 1) {
192 return "重复版本"; 194 return "重复版本";
193 } else { 195 } else {
194 - lv = lineVersionsList.get(0); 196 + lv = lineVersionDescs.get(0);
195 } 197 }
196 198
197 - String vname = lv.getName();  
198 - String rq = lv.getStartDate() == null ? "未知启用日期" : new DateTime(lv.getStartDate()).toString("YYYY年MM月dd日");  
199 - String sdesc = lv.getStatus() == 0 ? "历史" : (lv.getStatus() == 1 ? "当前" : "待更新"); 199 + String t_name = (String) lv.get("name");
  200 + Timestamp t_sd = (Timestamp) lv.get("sd");
  201 + int status = Integer.parseInt(lv.get("status").toString());
  202 +
  203 + String vname = t_name;
  204 + String rq = t_sd == null ? "未知启用日期" : new DateTime(t_sd).toString("YYYY年MM月dd日");
  205 + String sdesc = status == 0 ? "历史" : (status == 1 ? "当前" : "待更新");
200 206
201 return String.format("%s-%s-%s", vname, rq, sdesc); 207 return String.format("%s-%s-%s", vname, rq, sdesc);
202 } 208 }
203 209
204 @Override 210 @Override
  211 + public List<Map<String, Object>> getLineVersions(Integer lineId, Integer status) {
  212 + return ttInfoRepository.findLineVersionDescs3(lineId, status);
  213 + }
  214 +
  215 + @Override
205 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ) 216 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.REPEATABLE_READ)
206 public void backUp(Long ttInfoId) throws ScheduleException { 217 public void backUp(Long ttInfoId) throws ScheduleException {
207 LOG.info(">>>>>>开始备份时刻表<<<<<<"); 218 LOG.info(">>>>>>开始备份时刻表<<<<<<");
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
@@ -748,12 +748,20 @@ angular.module(&#39;ScheduleApp&#39;).factory( @@ -748,12 +748,20 @@ angular.module(&#39;ScheduleApp&#39;).factory(
748 ), 748 ),
749 749
750 lineverions: $resource( 750 lineverions: $resource(
751 - '/lineVersions/all', 751 + '/tic_ec/versiondesc2/:lineId/:status',
752 {}, 752 {},
753 { 753 {
754 list: { 754 list: {
755 method: 'GET', 755 method: 'GET',
756 - isArray: true 756 + isArray: true,
  757 + transformResponse: function(rs) {
  758 + var dst = angular.fromJson(rs);
  759 + if (dst.status == 'SUCCESS') {
  760 + return dst.data;
  761 + } else {
  762 + return dst; // 业务错误留给控制器处理
  763 + }
  764 + }
757 } 765 }
758 } 766 }
759 ) 767 )
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/detailedit/module.js
@@ -25,7 +25,7 @@ angular.module(&#39;ScheduleApp&#39;).factory( @@ -25,7 +25,7 @@ angular.module(&#39;ScheduleApp&#39;).factory(
25 * @returns {*|Function|promise|n} 25 * @returns {*|Function|promise|n}
26 */ 26 */
27 getCurrentLineVersion: function(xlid) { 27 getCurrentLineVersion: function(xlid) {
28 - var params = {'line.id_eq': xlid, 'status_eq': 1}; 28 + var params = {'lineId': xlid, 'status': 1};
29 return service2.lineverions.list(params).$promise; 29 return service2.lineverions.list(params).$promise;
30 30
31 } 31 }
@@ -69,7 +69,7 @@ angular.module(&#39;ScheduleApp&#39;).controller( @@ -69,7 +69,7 @@ angular.module(&#39;ScheduleApp&#39;).controller(
69 } else if (result.length > 1) { 69 } else if (result.length > 1) {
70 alert("有多个线路当前版本"); 70 alert("有多个线路当前版本");
71 } else { 71 } else {
72 - self.ttInfoDetailManageForForm.lineversion = result[0].versions; 72 + self.ttInfoDetailManageForForm.lineversion = result[0].version;
73 } 73 }
74 } 74 }
75 ); 75 );
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/service.js
@@ -74,12 +74,20 @@ angular.module(&#39;ScheduleApp&#39;).factory( @@ -74,12 +74,20 @@ angular.module(&#39;ScheduleApp&#39;).factory(
74 ), 74 ),
75 75
76 lineverions: $resource( 76 lineverions: $resource(
77 - '/lineVersions/all', 77 + '/tic_ec/versiondesc2/:lineId/:status',
78 {}, 78 {},
79 { 79 {
80 list: { 80 list: {
81 method: 'GET', 81 method: 'GET',
82 - isArray: true 82 + isArray: true,
  83 + transformResponse: function(rs) {
  84 + var dst = angular.fromJson(rs);
  85 + if (dst.status == 'SUCCESS') {
  86 + return dst.data;
  87 + } else {
  88 + return dst; // 业务错误留给控制器处理
  89 + }
  90 + }
83 } 91 }
84 } 92 }
85 ) 93 )