Commit 9aab93ac84571bd1c305b7c90610a618f3f740aa
Merge branch 'minhang' of http://192.168.168.201:8888/panzhaov5/bsth_control into minhang
Showing
91 changed files
with
2039 additions
and
1356 deletions
Too many changes to show.
To preserve performance only 91 of 199 files are displayed.
pom.xml
| @@ -155,6 +155,12 @@ | @@ -155,6 +155,12 @@ | ||
| 155 | <version>2.1.8</version> | 155 | <version>2.1.8</version> |
| 156 | </dependency> | 156 | </dependency> |
| 157 | 157 | ||
| 158 | + <dependency> | ||
| 159 | + <groupId>org.apache.tika</groupId> | ||
| 160 | + <artifactId>tika-core</artifactId> | ||
| 161 | + <version>1.7</version> | ||
| 162 | + </dependency> | ||
| 163 | + | ||
| 158 | <!-- pentaho kettle 依赖 --> | 164 | <!-- pentaho kettle 依赖 --> |
| 159 | <dependency> | 165 | <dependency> |
| 160 | <groupId>com.pentaho.kettle</groupId> | 166 | <groupId>com.pentaho.kettle</groupId> |
src/main/java/com/bsth/controller/DownloadController.java
| @@ -2,6 +2,7 @@ package com.bsth.controller; | @@ -2,6 +2,7 @@ package com.bsth.controller; | ||
| 2 | 2 | ||
| 3 | import java.io.File; | 3 | import java.io.File; |
| 4 | import java.io.IOException; | 4 | import java.io.IOException; |
| 5 | +import java.net.URLDecoder; | ||
| 5 | 6 | ||
| 6 | import org.apache.commons.io.FileUtils; | 7 | import org.apache.commons.io.FileUtils; |
| 7 | import org.springframework.context.annotation.Scope; | 8 | import org.springframework.context.annotation.Scope; |
| @@ -30,12 +31,14 @@ public class DownloadController | @@ -30,12 +31,14 @@ public class DownloadController | ||
| 30 | @RequestMapping("download") | 31 | @RequestMapping("download") |
| 31 | public ResponseEntity<byte[]> download(String fileName) throws IOException { | 32 | public ResponseEntity<byte[]> download(String fileName) throws IOException { |
| 32 | fileName = fileName+".xls"; | 33 | fileName = fileName+".xls"; |
| 33 | - String moudelPath = this.getClass().getResource("/").getPath()+ "static\\pages\\forms\\export\\"+fileName; | 34 | + String moudelPath = this.getClass().getResource("/").getPath()+ "static/pages/forms/export/"+fileName; |
| 35 | + System.out.println(moudelPath); | ||
| 34 | // String path="D:\\export\\target\\"+jName+".xls"; | 36 | // String path="D:\\export\\target\\"+jName+".xls"; |
| 35 | File file=new File(moudelPath); | 37 | File file=new File(moudelPath); |
| 36 | HttpHeaders headers = new HttpHeaders(); | 38 | HttpHeaders headers = new HttpHeaders(); |
| 37 | String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题 | 39 | String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题 |
| 38 | - headers.setContentDispositionFormData("attachment", realFileName); | 40 | + headers.setContentDispositionFormData("attachment", fileName); |
| 41 | + System.out.println( URLDecoder.decode(realFileName,"utf-8")); | ||
| 39 | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); | 42 | headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); |
| 40 | return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), | 43 | return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file), |
| 41 | headers, HttpStatus.CREATED); | 44 | headers, HttpStatus.CREATED); |
src/main/java/com/bsth/controller/oil/YlbController.java
| @@ -106,24 +106,24 @@ public class YlbController extends BaseController<Ylb, Integer>{ | @@ -106,24 +106,24 @@ public class YlbController extends BaseController<Ylb, Integer>{ | ||
| 106 | @RequestParam(defaultValue = "DESC") String direction){ | 106 | @RequestParam(defaultValue = "DESC") String direction){ |
| 107 | 107 | ||
| 108 | Direction d; | 108 | Direction d; |
| 109 | - try { | 109 | +// try { |
| 110 | String rq=map.get("rq").toString(); | 110 | String rq=map.get("rq").toString(); |
| 111 | if(!(rq=="")){ | 111 | if(!(rq=="")){ |
| 112 | - | ||
| 113 | - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); | ||
| 114 | - Calendar calendar = new GregorianCalendar(); | ||
| 115 | - calendar.setTime(sdf.parse(rq)); | ||
| 116 | - calendar.add(calendar.DATE,1); | ||
| 117 | - Date date=calendar.getTime(); | ||
| 118 | - map.put("rq_ge", rq); | ||
| 119 | - map.put("rq_le", sdf.format(date)); | ||
| 120 | - System.out.println(rq); | ||
| 121 | - System.out.println(sdf.format(date)); | ||
| 122 | - } | ||
| 123 | - } catch (ParseException e) { | ||
| 124 | - // TODO Auto-generated catch block | ||
| 125 | - e.printStackTrace(); | 112 | +// |
| 113 | +// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); | ||
| 114 | +// Calendar calendar = new GregorianCalendar(); | ||
| 115 | +// calendar.setTime(sdf.parse(rq)); | ||
| 116 | +// calendar.add(calendar.DATE,1); | ||
| 117 | +// Date date=calendar.getTime(); | ||
| 118 | + map.put("rq_eq", rq); | ||
| 119 | +// map.put("rq_lt", sdf.format(date)); | ||
| 120 | +// System.out.println(rq); | ||
| 121 | +// System.out.println(sdf.format(date)); | ||
| 126 | } | 122 | } |
| 123 | +// } catch (ParseException e) { | ||
| 124 | +// // TODO Auto-generated catch block | ||
| 125 | +// e.printStackTrace(); | ||
| 126 | +// } | ||
| 127 | if(null != direction && direction.equals("ASC")) | 127 | if(null != direction && direction.equals("ASC")) |
| 128 | d = Direction.ASC; | 128 | d = Direction.ASC; |
| 129 | else | 129 | else |
src/main/java/com/bsth/controller/realcontrol/RealMapController.java
| @@ -59,4 +59,14 @@ public class RealMapController { | @@ -59,4 +59,14 @@ public class RealMapController { | ||
| 59 | public Map<String, Object> findRouteAndStationByLine(@RequestParam String lineCode){ | 59 | public Map<String, Object> findRouteAndStationByLine(@RequestParam String lineCode){ |
| 60 | return realMapService.findRouteAndStationByLine(lineCode); | 60 | return realMapService.findRouteAndStationByLine(lineCode); |
| 61 | } | 61 | } |
| 62 | + | ||
| 63 | + /** | ||
| 64 | + * 获取多个线路的路段信息(为前端越界计算提供数据) | ||
| 65 | + * @param codeIdx | ||
| 66 | + * @return | ||
| 67 | + */ | ||
| 68 | + @RequestMapping(value = "/multiSectionRoute") | ||
| 69 | + public Map<String, Object> multiSectionRoute(@RequestParam String codeIdx){ | ||
| 70 | + return realMapService.multiSectionRoute(codeIdx); | ||
| 71 | + } | ||
| 62 | } | 72 | } |
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| @@ -36,35 +36,13 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -36,35 +36,13 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | * | 38 | * |
| 39 | - * 改由通过 websocket 注册监听!!! | ||
| 40 | - * | ||
| 41 | - * @Title: registerLine @Description: TODO(注册线路,后续才能收到数据推送) @param @param | ||
| 42 | - * lineCodes @throws | ||
| 43 | - * 用GET 防止监控模式下被拦截 | ||
| 44 | - | ||
| 45 | - @RequestMapping(value = "/registerLine", method = RequestMethod.GET) | ||
| 46 | - public int registerLine(@RequestParam String lineCodes) { | ||
| 47 | - List<String> list = Splitter.on(",").trimResults().omitEmptyStrings().splitToList(lineCodes); | ||
| 48 | - String userName = SecurityUtils.getCurrentUser().getUserName(); | ||
| 49 | - // 注销之前的绑定 | ||
| 50 | - for (String line : list) | ||
| 51 | - BasicData.lineCode2SocketUserMap.get(line).remove(userName); | ||
| 52 | - // 重新绑定 | ||
| 53 | - for (String line : list) | ||
| 54 | - BasicData.lineCode2SocketUserMap.put(line, userName); | ||
| 55 | - | ||
| 56 | - return 0; | ||
| 57 | - }*/ | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | - * | ||
| 61 | * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id | 39 | * @Title: outgoAdjust @Description: TODO(待发调整) @param @param id |
| 62 | * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws | 40 | * 主键 @param @param remarks 备注 @param @param dfsj 待发时间(HH:mm) @throws |
| 63 | */ | 41 | */ |
| 64 | @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST) | 42 | @RequestMapping(value = "/outgoAdjust", method = RequestMethod.POST) |
| 65 | public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks, | 43 | public Map<String, Object> outgoAdjust(@RequestParam Long id, @RequestParam String remarks, |
| 66 | - @RequestParam String dfsj/*, String clZbh, String jsy, String spy*/) { | ||
| 67 | - return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj/*, clZbh, jsy, spy*/); | 44 | + @RequestParam String dfsj,String bcType) { |
| 45 | + return scheduleRealInfoService.outgoAdjust(id, remarks, dfsj, bcType); | ||
| 68 | } | 46 | } |
| 69 | 47 | ||
| 70 | /** | 48 | /** |
| @@ -125,19 +103,6 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -125,19 +103,6 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 125 | public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) { | 103 | public List<Map<String, String>> sreachVehic(@RequestParam String nbbm) { |
| 126 | return scheduleRealInfoService.sreachVehic(nbbm); | 104 | return scheduleRealInfoService.sreachVehic(nbbm); |
| 127 | } | 105 | } |
| 128 | - | ||
| 129 | - /** | ||
| 130 | - * | ||
| 131 | - * @Title: adjust @Description: TODO(调整人车) @param @param id | ||
| 132 | - * 班次ID @param @param nbbm 内部编码 @param @param jsy 驾驶员 @param @param spy | ||
| 133 | - * 售票员 @throws | ||
| 134 | - | ||
| 135 | - @RequestMapping(value = "/adjust", method = RequestMethod.POST) | ||
| 136 | - public Map<String, Object> adjust(@RequestParam Long id, String nbbm, String jsy, | ||
| 137 | - String spy, Integer revertLine, Integer borrowLine, String borrowTimeStr, String revertTimeStr) { | ||
| 138 | - return scheduleRealInfoService.adjust(id, nbbm, jsy, spy, revertLine, borrowLine, borrowTimeStr, revertTimeStr); | ||
| 139 | - } | ||
| 140 | - */ | ||
| 141 | /** | 106 | /** |
| 142 | * | 107 | * |
| 143 | * @Title: realOutAdjust | 108 | * @Title: realOutAdjust |
| @@ -299,10 +264,17 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -299,10 +264,17 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 299 | 264 | ||
| 300 | @RequestMapping(value = "/exportWaybill") | 265 | @RequestMapping(value = "/exportWaybill") |
| 301 | public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName, @RequestParam String clZbh, | 266 | public List<ScheduleRealInfo> exportWaybill(@RequestParam String jName, @RequestParam String clZbh, |
| 302 | - @RequestParam String lpName,@RequestParam String date) { | ||
| 303 | - return scheduleRealInfoService.exportWaybill(jName, clZbh, lpName,date); | 267 | + @RequestParam String lpName,@RequestParam String date,@RequestParam String line) { |
| 268 | + return scheduleRealInfoService.exportWaybill(jName, clZbh, lpName,date,line); | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + @RequestMapping(value = "/exportWaybillQp") | ||
| 272 | + public List<ScheduleRealInfo> exportWaybillQp(@RequestParam String clZbh | ||
| 273 | + ,@RequestParam String date,@RequestParam String line) { | ||
| 274 | + return scheduleRealInfoService.exportWaybillQp( clZbh, date,line); | ||
| 304 | } | 275 | } |
| 305 | 276 | ||
| 277 | + | ||
| 306 | @RequestMapping(value = "/dailyInfo") | 278 | @RequestMapping(value = "/dailyInfo") |
| 307 | public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) { | 279 | public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) { |
| 308 | return scheduleRealInfoService.dailyInfo(line, date, type); | 280 | return scheduleRealInfoService.dailyInfo(line, date, type); |
| @@ -310,8 +282,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -310,8 +282,8 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 310 | 282 | ||
| 311 | @RequestMapping(value = "/historyMessage") | 283 | @RequestMapping(value = "/historyMessage") |
| 312 | public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date, | 284 | public List<Object[]> historyMessage(@RequestParam String line, @RequestParam String date, |
| 313 | - @RequestParam String code) { | ||
| 314 | - return scheduleRealInfoService.historyMessage(line, date, code); | 285 | + @RequestParam String code, @RequestParam String type) { |
| 286 | + return scheduleRealInfoService.historyMessage(line, date, code, type); | ||
| 315 | } | 287 | } |
| 316 | 288 | ||
| 317 | @RequestMapping(value="/findLine") | 289 | @RequestMapping(value="/findLine") |
| @@ -321,8 +293,14 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -321,8 +293,14 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 321 | 293 | ||
| 322 | @RequestMapping(value="/findKMBC") | 294 | @RequestMapping(value="/findKMBC") |
| 323 | public Map<String,Object> findKMBC(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName | 295 | public Map<String,Object> findKMBC(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName |
| 324 | - ,@RequestParam String date){ | ||
| 325 | - return scheduleRealInfoService.findKMBC(jName, clZbh,lpName,date); | 296 | + ,@RequestParam String date,@RequestParam String line){ |
| 297 | + return scheduleRealInfoService.findKMBC(jName, clZbh,lpName,date,line); | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + @RequestMapping(value="/findKMBCQp") | ||
| 301 | + public Map<String,Object> findKMBCQp(@RequestParam String clZbh | ||
| 302 | + ,@RequestParam String date,@RequestParam String line){ | ||
| 303 | + return scheduleRealInfoService.findKMBCQp(clZbh,date,line); | ||
| 326 | } | 304 | } |
| 327 | 305 | ||
| 328 | @RequestMapping(value="/findLpName") | 306 | @RequestMapping(value="/findLpName") |
| @@ -332,14 +310,14 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -332,14 +310,14 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 332 | 310 | ||
| 333 | @RequestMapping(value = "/account") | 311 | @RequestMapping(value = "/account") |
| 334 | public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date, | 312 | public List<Map<String,Object>> account(@RequestParam String line, @RequestParam String date, |
| 335 | - @RequestParam String code,@RequestParam String xlName) { | ||
| 336 | - return scheduleRealInfoService.account(line, date, code,xlName); | 313 | + @RequestParam String code,@RequestParam String xlName, @RequestParam String type) { |
| 314 | + return scheduleRealInfoService.account(line, date, code, xlName, type); | ||
| 337 | } | 315 | } |
| 338 | 316 | ||
| 339 | @RequestMapping(value = "/correctForm") | 317 | @RequestMapping(value = "/correctForm") |
| 340 | public List<ScheduleRealInfo> correctForm(@RequestParam String line, @RequestParam String startDate, | 318 | public List<ScheduleRealInfo> correctForm(@RequestParam String line, @RequestParam String startDate, |
| 341 | - @RequestParam String endDate,@RequestParam String lpName,@RequestParam String code) { | ||
| 342 | - return scheduleRealInfoService.correctForm(line, startDate, endDate, lpName, code); | 319 | + @RequestParam String endDate, @RequestParam String lpName, @RequestParam String code, @RequestParam String type) { |
| 320 | + return scheduleRealInfoService.correctForm(line, startDate, endDate, lpName, code, type); | ||
| 343 | } | 321 | } |
| 344 | /** | 322 | /** |
| 345 | * @Title queryListWaybill | 323 | * @Title queryListWaybill |
| @@ -351,21 +329,25 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -351,21 +329,25 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 351 | */ | 329 | */ |
| 352 | @RequestMapping(value="/queryListWaybill") | 330 | @RequestMapping(value="/queryListWaybill") |
| 353 | public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName | 331 | public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName |
| 354 | - ,@RequestParam String date){ | ||
| 355 | - String type="fqp"; | ||
| 356 | - return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,type); | 332 | + ,@RequestParam String date,@RequestParam String line){ |
| 333 | + return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,line); | ||
| 357 | } | 334 | } |
| 358 | 335 | ||
| 359 | @RequestMapping(value="/queryListWaybillQp") | 336 | @RequestMapping(value="/queryListWaybillQp") |
| 360 | - public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName | ||
| 361 | - ,@RequestParam String date){ | ||
| 362 | - String type="qp"; | ||
| 363 | - return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName,date,type); | 337 | + public List<ScheduleRealInfo> queryListWaybillQp(@RequestParam String clZbh, |
| 338 | + @RequestParam String date,@RequestParam String line){ | ||
| 339 | + return scheduleRealInfoService.queryListWaybillQp(clZbh,date,line); | ||
| 364 | } | 340 | } |
| 365 | 341 | ||
| 366 | @RequestMapping(value="/statisticsDaily") | 342 | @RequestMapping(value="/statisticsDaily") |
| 367 | - public List<Map<String,Object>> statisticsDaily(@RequestParam String line,@RequestParam String date,@RequestParam String xlName){ | ||
| 368 | - return scheduleRealInfoService.statisticsDaily(line, date,xlName); | 343 | + public List<Map<String,Object>> statisticsDaily(@RequestParam String line, @RequestParam String date, |
| 344 | + @RequestParam String xlName, @RequestParam String type){ | ||
| 345 | + return scheduleRealInfoService.statisticsDaily(line, date, xlName, type); | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + @RequestMapping(value="/MapById",method = RequestMethod.GET) | ||
| 349 | + public Map<String, Object> MapById(@RequestParam("id") Long id){ | ||
| 350 | + return scheduleRealInfoService.MapById(id); | ||
| 369 | } | 351 | } |
| 370 | 352 | ||
| 371 | /** | 353 | /** |
| @@ -427,4 +409,24 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | @@ -427,4 +409,24 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, | ||
| 427 | } | 409 | } |
| 428 | return rs; | 410 | return rs; |
| 429 | } | 411 | } |
| 412 | + | ||
| 413 | + @RequestMapping(value = "svgAttr", method = RequestMethod.POST) | ||
| 414 | + public Map<String, Object> svgAttr(@RequestParam String jsonStr){ | ||
| 415 | + return scheduleRealInfoService.svgAttr(jsonStr); | ||
| 416 | + } | ||
| 417 | + | ||
| 418 | + @RequestMapping(value = "svgAttr", method = RequestMethod.GET) | ||
| 419 | + public Map<String, Object> findSvgAttr(@RequestParam String idx){ | ||
| 420 | + return scheduleRealInfoService.findSvgAttr(idx); | ||
| 421 | + } | ||
| 422 | + | ||
| 423 | + @RequestMapping(value = "addRemarks", method = RequestMethod.POST) | ||
| 424 | + public Map<String, Object> addRemarks(@RequestParam Long id, @RequestParam String remarks){ | ||
| 425 | + return scheduleRealInfoService.addRemarks(id, remarks); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + @RequestMapping(value = "scheduleDailyQp", method = RequestMethod.GET) | ||
| 429 | + public List<Map<String, Object>> scheduleDailyQp(@RequestParam String line,@RequestParam String date){ | ||
| 430 | + return scheduleRealInfoService.scheduleDailyQp(line,date); | ||
| 431 | + } | ||
| 430 | } | 432 | } |
src/main/java/com/bsth/controller/schedule/BController.java
| @@ -5,16 +5,21 @@ import com.bsth.common.ResponseCode; | @@ -5,16 +5,21 @@ import com.bsth.common.ResponseCode; | ||
| 5 | import com.bsth.entity.schedule.BEntity; | 5 | import com.bsth.entity.schedule.BEntity; |
| 6 | import com.bsth.entity.sys.SysUser; | 6 | import com.bsth.entity.sys.SysUser; |
| 7 | import com.bsth.service.schedule.BService; | 7 | import com.bsth.service.schedule.BService; |
| 8 | -import com.bsth.service.schedule.ScheduleException; | 8 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 9 | import com.bsth.service.sys.SysUserService; | 9 | import com.bsth.service.sys.SysUserService; |
| 10 | import com.google.common.base.Splitter; | 10 | import com.google.common.base.Splitter; |
| 11 | +import jxl.Sheet; | ||
| 12 | +import jxl.Workbook; | ||
| 13 | +import org.apache.commons.lang3.StringUtils; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.data.domain.PageRequest; | 15 | import org.springframework.data.domain.PageRequest; |
| 13 | import org.springframework.data.domain.Sort; | 16 | import org.springframework.data.domain.Sort; |
| 14 | import org.springframework.web.bind.annotation.*; | 17 | import org.springframework.web.bind.annotation.*; |
| 18 | +import org.springframework.web.multipart.MultipartFile; | ||
| 15 | 19 | ||
| 20 | +import javax.servlet.http.HttpServletResponse; | ||
| 16 | import javax.servlet.http.HttpSession; | 21 | import javax.servlet.http.HttpSession; |
| 17 | -import java.io.Serializable; | 22 | +import java.io.*; |
| 18 | import java.util.*; | 23 | import java.util.*; |
| 19 | 24 | ||
| 20 | /** | 25 | /** |
| @@ -26,7 +31,7 @@ public class BController<T, ID extends Serializable> { | @@ -26,7 +31,7 @@ public class BController<T, ID extends Serializable> { | ||
| 26 | @Autowired | 31 | @Autowired |
| 27 | private SysUserService sysUserService; | 32 | private SysUserService sysUserService; |
| 28 | 33 | ||
| 29 | - // CRUD 操作 | 34 | + //---------------- CRUD 操作 ----------------// |
| 30 | // Create操作 | 35 | // Create操作 |
| 31 | @RequestMapping(method = RequestMethod.POST) | 36 | @RequestMapping(method = RequestMethod.POST) |
| 32 | public Map<String, Object> save(@RequestBody T t, HttpSession httpSession) { | 37 | public Map<String, Object> save(@RequestBody T t, HttpSession httpSession) { |
| @@ -73,6 +78,7 @@ public class BController<T, ID extends Serializable> { | @@ -73,6 +78,7 @@ public class BController<T, ID extends Serializable> { | ||
| 73 | rtn.put("data", t); | 78 | rtn.put("data", t); |
| 74 | return rtn; | 79 | return rtn; |
| 75 | } | 80 | } |
| 81 | + // 查询所有操作 | ||
| 76 | @RequestMapping(value = "/all", method = RequestMethod.GET) | 82 | @RequestMapping(value = "/all", method = RequestMethod.GET) |
| 77 | public Map<String, Object> list(@RequestParam Map<String, Object> param) { | 83 | public Map<String, Object> list(@RequestParam Map<String, Object> param) { |
| 78 | List<T> tList = bService.list(param); | 84 | List<T> tList = bService.list(param); |
| @@ -81,6 +87,7 @@ public class BController<T, ID extends Serializable> { | @@ -81,6 +87,7 @@ public class BController<T, ID extends Serializable> { | ||
| 81 | rtn.put("data", tList); | 87 | rtn.put("data", tList); |
| 82 | return rtn; | 88 | return rtn; |
| 83 | } | 89 | } |
| 90 | + // 分页查询操作 | ||
| 84 | @RequestMapping(method = RequestMethod.GET) | 91 | @RequestMapping(method = RequestMethod.GET) |
| 85 | public Map<String, Object> list( | 92 | public Map<String, Object> list( |
| 86 | @RequestParam Map<String, Object> map, | 93 | @RequestParam Map<String, Object> map, |
| @@ -138,4 +145,99 @@ public class BController<T, ID extends Serializable> { | @@ -138,4 +145,99 @@ public class BController<T, ID extends Serializable> { | ||
| 138 | return rtn; | 145 | return rtn; |
| 139 | } | 146 | } |
| 140 | 147 | ||
| 148 | + //---------------- 数据服务操作 ----------------// | ||
| 149 | + // 上传excel文件 | ||
| 150 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | ||
| 151 | + public Map<String, Object> uploadFile(MultipartFile file) { | ||
| 152 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 153 | + try { | ||
| 154 | + File file1 = bService.uploadFile(file.getOriginalFilename(), file.getBytes()); | ||
| 155 | + // excel文件名 | ||
| 156 | + String fileName = file1.getAbsolutePath(); | ||
| 157 | + // excel文件sheet | ||
| 158 | + List<String> sheetnames = new ArrayList<>(); | ||
| 159 | + Workbook book = Workbook.getWorkbook(file1); | ||
| 160 | + for (Sheet sheet : book.getSheets()) { | ||
| 161 | + sheetnames.add(sheet.getName()); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 165 | + rtn.put("filename", fileName); | ||
| 166 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | ||
| 167 | + } catch (Exception exp) { | ||
| 168 | + rtn.put("status", ResponseCode.ERROR); | ||
| 169 | + rtn.put("msg", exp.getMessage()); | ||
| 170 | + } | ||
| 171 | + return rtn; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + // 导入excel文件 | ||
| 175 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | ||
| 176 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | ||
| 177 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 178 | + | ||
| 179 | + try { | ||
| 180 | + File file = new File(String.valueOf(params.get("filename"))); | ||
| 181 | + if (!file.exists()) { | ||
| 182 | + throw new Exception("导入文件不存在!"); | ||
| 183 | + } | ||
| 184 | + bService.importData(file, params); | ||
| 185 | + | ||
| 186 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 187 | + rtn.put("msg", "导入文件成功"); | ||
| 188 | + } catch (Exception exp) { | ||
| 189 | + rtn.put("status", ResponseCode.ERROR); | ||
| 190 | + rtn.put("msg", exp.getMessage()); | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + return rtn; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + // 上传并导入excel文件 | ||
| 197 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | ||
| 198 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | ||
| 199 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 200 | + | ||
| 201 | + try { | ||
| 202 | + File file1 = bService.uploadFile(file.getOriginalFilename(), file.getBytes()); | ||
| 203 | + Map<String, Object> params = new HashMap<>(); | ||
| 204 | + bService.importData(file1, params); | ||
| 205 | + | ||
| 206 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 207 | + rtn.put("msg", "上传&导入文件成功"); | ||
| 208 | + } catch (Exception exp) { | ||
| 209 | + rtn.put("status", ResponseCode.ERROR); | ||
| 210 | + rtn.put("msg", exp.getMessage()); | ||
| 211 | + } | ||
| 212 | + | ||
| 213 | + return rtn; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + // 导出数据到xls文件 | ||
| 217 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | ||
| 218 | + public void exportFile(HttpServletResponse response, | ||
| 219 | + @RequestParam Map<String, Object> params) throws Exception { | ||
| 220 | + File file = bService.exportData(params); | ||
| 221 | + // 流输出导出文件 | ||
| 222 | + response.setHeader("content-type", "application/octet-stream"); | ||
| 223 | + response.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); | ||
| 224 | + response.setContentType("application/octet-stream"); | ||
| 225 | + | ||
| 226 | + OutputStream os = response.getOutputStream(); | ||
| 227 | + BufferedOutputStream bos = new BufferedOutputStream(os); | ||
| 228 | + | ||
| 229 | + InputStream is = new FileInputStream(file); | ||
| 230 | + BufferedInputStream bis = new BufferedInputStream(is); | ||
| 231 | + | ||
| 232 | + int length = 0; | ||
| 233 | + byte[] temp = new byte[1 * 1024 * 10]; | ||
| 234 | + while ((length = bis.read(temp)) != -1) { | ||
| 235 | + bos.write(temp, 0, length); | ||
| 236 | + } | ||
| 237 | + bos.flush(); | ||
| 238 | + bis.close(); | ||
| 239 | + bos.close(); | ||
| 240 | + is.close(); | ||
| 241 | + } | ||
| 242 | + | ||
| 141 | } | 243 | } |
src/main/java/com/bsth/controller/schedule/ScheduleRule1FlatController.java deleted
100644 → 0
| 1 | -package com.bsth.controller.schedule; | ||
| 2 | - | ||
| 3 | -import com.bsth.controller.BaseController; | ||
| 4 | -import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 5 | -import com.bsth.repository.schedule.ScheduleRule1FlatRepository; | ||
| 6 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | -import org.springframework.web.bind.annotation.*; | ||
| 8 | - | ||
| 9 | -import java.util.Map; | ||
| 10 | - | ||
| 11 | -/** | ||
| 12 | - * Created by xu on 16/7/4. | ||
| 13 | - */ | ||
| 14 | -@RestController | ||
| 15 | -@RequestMapping("sr1fc") | ||
| 16 | -public class ScheduleRule1FlatController extends BaseController<ScheduleRule1Flat, Long> { | ||
| 17 | - | ||
| 18 | - @Autowired | ||
| 19 | - private ScheduleRule1FlatRepository scheduleRule1FlatRepository; | ||
| 20 | - | ||
| 21 | - @Override | ||
| 22 | - public ScheduleRule1Flat findById(@PathVariable("id") Long aLong) { | ||
| 23 | - return scheduleRule1FlatRepository.findOneExtend(aLong); | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody | ||
| 28 | - * @Title: save | ||
| 29 | - * @Description: TODO(持久化对象) | ||
| 30 | - * @param @param t | ||
| 31 | - * @param @return 设定文件 | ||
| 32 | - * @return Map<String,Object> {status: 1(成功),-1(失败)} | ||
| 33 | - * @throws | ||
| 34 | - */ | ||
| 35 | - @RequestMapping(method = RequestMethod.POST) | ||
| 36 | - public Map<String, Object> save(@RequestBody ScheduleRule1Flat t){ | ||
| 37 | - return baseService.save(t); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | -} |
src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java deleted
100644 → 0
| 1 | -package com.bsth.controller.schedule; | ||
| 2 | - | ||
| 3 | -import com.bsth.common.ResponseCode; | ||
| 4 | -import com.bsth.controller.BaseController2; | ||
| 5 | -import com.bsth.entity.CarPark; | ||
| 6 | -import com.bsth.entity.LineInformation; | ||
| 7 | -import com.bsth.entity.StationRoute; | ||
| 8 | -import com.bsth.entity.schedule.GuideboardInfo; | ||
| 9 | -import com.bsth.entity.schedule.TTInfoDetail; | ||
| 10 | -import com.bsth.repository.schedule.TTInfoDetailRepository; | ||
| 11 | -import com.bsth.service.CarParkService; | ||
| 12 | -import com.bsth.service.LineInformationService; | ||
| 13 | -import com.bsth.service.StationRouteService; | ||
| 14 | -import com.bsth.service.schedule.GuideboardInfoService; | ||
| 15 | -import com.bsth.service.schedule.TTInfoDetailService; | ||
| 16 | -import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 17 | -import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 18 | -import jxl.Cell; | ||
| 19 | -import jxl.Sheet; | ||
| 20 | -import jxl.Workbook; | ||
| 21 | -import jxl.write.Label; | ||
| 22 | -import jxl.write.WritableSheet; | ||
| 23 | -import jxl.write.WritableWorkbook; | ||
| 24 | -import org.apache.commons.lang3.StringUtils; | ||
| 25 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 26 | -import org.springframework.util.CollectionUtils; | ||
| 27 | -import org.springframework.web.bind.annotation.*; | ||
| 28 | -import org.springframework.web.multipart.MultipartFile; | ||
| 29 | - | ||
| 30 | -import javax.servlet.http.HttpServletResponse; | ||
| 31 | -import java.io.File; | ||
| 32 | -import java.util.*; | ||
| 33 | -import java.util.regex.Matcher; | ||
| 34 | -import java.util.regex.Pattern; | ||
| 35 | - | ||
| 36 | -/** | ||
| 37 | - * Created by xu on 16/7/2. | ||
| 38 | - */ | ||
| 39 | -@RestController | ||
| 40 | -@RequestMapping("tidc") | ||
| 41 | -public class TTInfoDetailController extends BaseController2<TTInfoDetail, Long> { | ||
| 42 | - @Autowired | ||
| 43 | - private TTInfoDetailService ttInfoDetailService; | ||
| 44 | - @Autowired | ||
| 45 | - private CarParkService carParkService; | ||
| 46 | - @Autowired | ||
| 47 | - private LineInformationService lineInformationService; | ||
| 48 | - @Autowired | ||
| 49 | - private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 50 | - @Autowired | ||
| 51 | - private DataImportExportService dataImportExportService; | ||
| 52 | - @Autowired | ||
| 53 | - private StationRouteService stationRouteService; | ||
| 54 | - @Autowired | ||
| 55 | - private GuideboardInfoService guideboardInfoService; | ||
| 56 | - @Autowired | ||
| 57 | - private DataToolsProperties dataToolsProperties; | ||
| 58 | - | ||
| 59 | - /** | ||
| 60 | - * 1、上传Excel文件,返回文件全路径名,工作区名称列表。 | ||
| 61 | - * @param file | ||
| 62 | - * @return | ||
| 63 | - * @throws Exception | ||
| 64 | - */ | ||
| 65 | - | ||
| 66 | - | ||
| 67 | - /** | ||
| 68 | - * 2、验证sheet(以后放到规则引擎里去做)。 | ||
| 69 | - * @param filename excel文件全路径名 | ||
| 70 | - * @param sheetname sheet名字 | ||
| 71 | - * @param lineid 线路id | ||
| 72 | - * @param linename 线路名称 | ||
| 73 | - * @return | ||
| 74 | - */ | ||
| 75 | - @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) | ||
| 76 | - public Map<String, Object> validateSheet(String filename, String sheetname, Integer lineid, String linename) throws Exception { | ||
| 77 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 78 | - Workbook book = Workbook.getWorkbook(new File(filename)); | ||
| 79 | - Sheet sheet = book.getSheet(sheetname); | ||
| 80 | - if (sheet.getRows() == 0 || sheet.getColumns() == 0) { // 工作区是否为空 | ||
| 81 | - rtn.put("status", ResponseCode.ERROR); | ||
| 82 | - rtn.put("msg", String.format("%s 工作区没有数据!", sheetname)); | ||
| 83 | - return rtn; | ||
| 84 | - } else { | ||
| 85 | - if (sheet.getRows() <= 1 || sheet.getColumns() <= 1) { | ||
| 86 | - rtn.put("status", ResponseCode.ERROR); | ||
| 87 | - rtn.put("msg", String.format("工作区至少包含2行2列的数据")); | ||
| 88 | - return rtn; | ||
| 89 | - } else { | ||
| 90 | - Cell[] cells = sheet.getRow(0); // 获取第一行数据列 | ||
| 91 | - for (int i = 0; i < cells.length; i++) { | ||
| 92 | - String cell_con = cells[i].getContents(); | ||
| 93 | - | ||
| 94 | - if (StringUtils.isEmpty(cell_con)) { | ||
| 95 | - rtn.put("status", ResponseCode.ERROR); | ||
| 96 | - rtn.put("msg", String.format("第1行,第%d列数据不能为空", i + 1)); | ||
| 97 | - return rtn; | ||
| 98 | - } else { | ||
| 99 | - // 正则表达式去除数字 | ||
| 100 | - cell_con = cell_con.replaceAll("[\\d+]", ""); | ||
| 101 | - | ||
| 102 | - if (i == 0) { // 第一列必须是路牌2个字 | ||
| 103 | - if (!"路牌".equals(cell_con.trim())) { | ||
| 104 | - rtn.put("status", ResponseCode.ERROR); | ||
| 105 | - rtn.put("msg", "第1行,第1列数据必须是路牌2个字"); | ||
| 106 | - return rtn; | ||
| 107 | - } | ||
| 108 | - } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | ||
| 109 | - if ((!"出场".equals(cell_con.trim())) && | ||
| 110 | - (!"进场".equals(cell_con.trim()))) { | ||
| 111 | - Map<String, Object> p1 = new HashMap<>(); | ||
| 112 | - p1.put("line.id_eq", lineid); | ||
| 113 | - p1.put("stationName_eq", cell_con.trim()); | ||
| 114 | - p1.put("stationMark_eq", "B"); | ||
| 115 | - | ||
| 116 | - | ||
| 117 | - // TODO:这里要修改(起点站有启用撤销的标志的) | ||
| 118 | - | ||
| 119 | - List<StationRoute> stationRouteList = (List<StationRoute>) stationRouteService.list(p1); | ||
| 120 | - if (CollectionUtils.isEmpty(stationRouteList)) { | ||
| 121 | - rtn.put("status", ResponseCode.ERROR); | ||
| 122 | - rtn.put("msg", String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename)); | ||
| 123 | - return rtn; | ||
| 124 | - } else if (stationRouteList.size() > 1) { | ||
| 125 | - rtn.put("status", ResponseCode.ERROR); | ||
| 126 | - rtn.put("msg", String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename)); | ||
| 127 | - return rtn; | ||
| 128 | - } | ||
| 129 | - } | ||
| 130 | - | ||
| 131 | - } | ||
| 132 | - } | ||
| 133 | - } | ||
| 134 | - | ||
| 135 | - // 验证路牌内容 | ||
| 136 | - Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | ||
| 137 | - for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 138 | - Cell bcell = sheet.getRow(i)[0]; // 获取第1列 | ||
| 139 | - String bcell_con = bcell.getContents(); | ||
| 140 | - if (StringUtils.isEmpty(bcell_con)) { | ||
| 141 | - rtn.put("status", ResponseCode.ERROR); | ||
| 142 | - rtn.put("msg", String.format("第%d行,第1列路牌无数据", i + 1)); | ||
| 143 | - return rtn; | ||
| 144 | - } else if (gbindexmap.get(bcell_con.trim()) != null) { | ||
| 145 | - rtn.put("status", ResponseCode.ERROR); | ||
| 146 | - rtn.put("msg", String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | ||
| 147 | - i + 1, | ||
| 148 | - gbindexmap.get(bcell_con.trim()))); | ||
| 149 | - return rtn; | ||
| 150 | - } else { | ||
| 151 | - Map<String, Object> p2 = new HashMap<>(); | ||
| 152 | - p2.put("xl.id_eq", lineid); | ||
| 153 | - p2.put("lpName_eq", bcell_con.trim()); | ||
| 154 | - List<GuideboardInfo> guideboardInfoList = (List<GuideboardInfo>) guideboardInfoService.list(p2); | ||
| 155 | - if (CollectionUtils.isEmpty(guideboardInfoList)) { | ||
| 156 | - rtn.put("status", ResponseCode.ERROR); | ||
| 157 | - rtn.put("msg", String.format("第%d行,第1列的路牌在%s中不存在", i + 1, linename)); | ||
| 158 | - return rtn; | ||
| 159 | - } else if (guideboardInfoList.size() > 1) { | ||
| 160 | - rtn.put("status", ResponseCode.ERROR); | ||
| 161 | - rtn.put("msg", String.format("第%d行,第1列的路牌在%s中重复", i + 1, linename)); | ||
| 162 | - return rtn; | ||
| 163 | - } else { | ||
| 164 | - gbindexmap.put(bcell_con.trim(), i + 1); | ||
| 165 | - } | ||
| 166 | - } | ||
| 167 | - } | ||
| 168 | - | ||
| 169 | - // 班次时间验证,正则表达式,格式hh:mm或者hhmm | ||
| 170 | - String el = "^(([0-1]\\d)|(2[0-4])):[0-5]\\d$"; // hh:mm格式 | ||
| 171 | - String el2 = "^(([0-1]\\d)|(2[0-4]))[0-5]\\d$"; // hhmm格式 | ||
| 172 | - Pattern p = Pattern.compile(el); | ||
| 173 | - Pattern p2 = Pattern.compile(el2); | ||
| 174 | - | ||
| 175 | - for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 176 | - Cell[] bcells = sheet.getRow(i); | ||
| 177 | - for (int j = 1; j < bcells.length; j++) { // 从第2列开始 | ||
| 178 | - String bcell_con = bcells[j].getContents(); | ||
| 179 | - if (StringUtils.isNotEmpty(bcell_con)) { | ||
| 180 | - Matcher m = p.matcher(bcell_con.trim()); | ||
| 181 | - Matcher m2 = p2.matcher(bcell_con.trim()); | ||
| 182 | - if ((!m.matches()) && (!m2.matches())) { | ||
| 183 | - rtn.put("status", ResponseCode.ERROR); | ||
| 184 | - rtn.put("msg", String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hhmm", i + 1, j + 1)); | ||
| 185 | - return rtn; | ||
| 186 | - } | ||
| 187 | - } | ||
| 188 | - } | ||
| 189 | - } | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - rtn.put("status", ResponseCode.SUCCESS); | ||
| 195 | - return rtn; | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - /** | ||
| 199 | - * 3、验证关联的线路标准信息(以后放到规则引擎里去做)。 | ||
| 200 | - * @param lineinfoid | ||
| 201 | - * @return | ||
| 202 | - */ | ||
| 203 | - @RequestMapping(value = "/validate/lineinfo", method = RequestMethod.GET) | ||
| 204 | - public Map<String, Object> validateAssoLineInfo(Integer lineinfoid) { | ||
| 205 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 206 | - LineInformation lineInformation = lineInformationService.findById(lineinfoid); | ||
| 207 | - if (lineInformation.getUpInMileage() == null) { | ||
| 208 | - rtn.put("status", ResponseCode.ERROR); | ||
| 209 | - rtn.put("msg", "上行进场里程为空"); | ||
| 210 | - return rtn; | ||
| 211 | - } else if (lineInformation.getUpInTimer() == null) { | ||
| 212 | - rtn.put("status", ResponseCode.ERROR); | ||
| 213 | - rtn.put("msg", "上行进场时间为空"); | ||
| 214 | - return rtn; | ||
| 215 | - } else if (lineInformation.getUpOutMileage() == null) { | ||
| 216 | - rtn.put("status", ResponseCode.ERROR); | ||
| 217 | - rtn.put("msg", "上行出场里程为空"); | ||
| 218 | - return rtn; | ||
| 219 | - } else if (lineInformation.getUpOutTimer() == null) { | ||
| 220 | - rtn.put("status", ResponseCode.ERROR); | ||
| 221 | - rtn.put("msg", "上行出场时间为空"); | ||
| 222 | - return rtn; | ||
| 223 | - } else if (lineInformation.getUpMileage() == null) { | ||
| 224 | - rtn.put("status", ResponseCode.ERROR); | ||
| 225 | - rtn.put("msg", "上行班次里程为空"); | ||
| 226 | - return rtn; | ||
| 227 | - } else if (lineInformation.getUpTravelTime() == null) { | ||
| 228 | - rtn.put("status", ResponseCode.ERROR); | ||
| 229 | - rtn.put("msg", "上行班次时间为空"); | ||
| 230 | - return rtn; | ||
| 231 | - } else if (lineInformation.getDownInMileage() == null) { | ||
| 232 | - rtn.put("status", ResponseCode.ERROR); | ||
| 233 | - rtn.put("msg", "下行进场里程为空"); | ||
| 234 | - return rtn; | ||
| 235 | - } else if (lineInformation.getDownInTimer() == null) { | ||
| 236 | - rtn.put("status", ResponseCode.ERROR); | ||
| 237 | - rtn.put("msg", "下行进场时间为空"); | ||
| 238 | - return rtn; | ||
| 239 | - } else if (lineInformation.getDownOutMileage() == null) { | ||
| 240 | - rtn.put("status", ResponseCode.ERROR); | ||
| 241 | - rtn.put("msg", "下行出场里程为空"); | ||
| 242 | - return rtn; | ||
| 243 | - } else if (lineInformation.getDownOutTimer() == null) { | ||
| 244 | - rtn.put("status", ResponseCode.ERROR); | ||
| 245 | - rtn.put("msg", "下行出场时间为空"); | ||
| 246 | - return rtn; | ||
| 247 | - } else if (lineInformation.getDownMileage() == null) { | ||
| 248 | - rtn.put("status", ResponseCode.ERROR); | ||
| 249 | - rtn.put("msg", "下行班次里程为空"); | ||
| 250 | - return rtn; | ||
| 251 | - } else if (lineInformation.getDownTravelTime() == null) { | ||
| 252 | - rtn.put("status", ResponseCode.ERROR); | ||
| 253 | - rtn.put("msg", "下行班次时间为空"); | ||
| 254 | - return rtn; | ||
| 255 | - } else if (StringUtils.isEmpty(lineInformation.getCarPark())) { | ||
| 256 | - rtn.put("status", ResponseCode.ERROR); | ||
| 257 | - rtn.put("msg", "停车场必须选择"); | ||
| 258 | - return rtn; | ||
| 259 | - } | ||
| 260 | - | ||
| 261 | - // 单独验证停车场信息 | ||
| 262 | - String tcccode = lineInformation.getCarPark(); | ||
| 263 | - Map<String, Object> p1 = new HashMap<>(); | ||
| 264 | - p1.put("parkCode_eq", tcccode); | ||
| 265 | - List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 266 | - if (CollectionUtils.isEmpty(carParkList)) { | ||
| 267 | - rtn.put("status", ResponseCode.ERROR); | ||
| 268 | - rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中未找到", tcccode)); | ||
| 269 | - return rtn; | ||
| 270 | - } else if (carParkList.size() > 1) { | ||
| 271 | - rtn.put("status", ResponseCode.ERROR); | ||
| 272 | - rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中有重复数据", tcccode)); | ||
| 273 | - return rtn; | ||
| 274 | - } else { | ||
| 275 | - CarPark carPark = carParkList.get(0); | ||
| 276 | - if (StringUtils.isEmpty(carPark.getParkName())) { | ||
| 277 | - rtn.put("status", ResponseCode.ERROR); | ||
| 278 | - rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中没有停车场名字", tcccode)); | ||
| 279 | - return rtn; | ||
| 280 | - } | ||
| 281 | - } | ||
| 282 | - | ||
| 283 | - rtn.put("status", ResponseCode.SUCCESS); | ||
| 284 | - return rtn; | ||
| 285 | - } | ||
| 286 | - | ||
| 287 | - /** | ||
| 288 | - * 4、导入时刻表明细数据。 | ||
| 289 | - * @param form | ||
| 290 | - * @return | ||
| 291 | - */ | ||
| 292 | - @RequestMapping(value = "/importfile", method = RequestMethod.POST) | ||
| 293 | - public Map<String, Object> importTTinfo(@RequestParam Map<String, Object> form) throws Exception { | ||
| 294 | - Map<String, Object> rtn = new HashMap<>(); | ||
| 295 | - | ||
| 296 | - // 1、修改已经上传的excel文件,在每个起点站后标示数字,表示第几个班次 | ||
| 297 | - // 2、由于格式问题,需要把内容都转换成字符串 | ||
| 298 | - String filename = (String) form.get("filename"); | ||
| 299 | - List<String> colList = new ArrayList<>(); | ||
| 300 | - Workbook workbook = Workbook.getWorkbook(new File(filename)); | ||
| 301 | - Sheet sheet = workbook.getSheet((String) form.get("sheetname")); | ||
| 302 | - Cell[] cells = sheet.getRow(0); | ||
| 303 | - for (int i = 0; i < cells.length; i++) { | ||
| 304 | - if (i == 0) { | ||
| 305 | - colList.add(cells[i].getContents().trim()); | ||
| 306 | - } else { | ||
| 307 | - colList.add(cells[i].getContents() + i); | ||
| 308 | - } | ||
| 309 | - } | ||
| 310 | - | ||
| 311 | - WritableWorkbook writableWorkbook = Workbook.createWorkbook(new File(filename + "_temp.xls"), workbook); | ||
| 312 | - WritableSheet sheet1 = writableWorkbook.getSheet((String) form.get("sheetname")); | ||
| 313 | - for (int i = 0; i < sheet1.getColumns(); i++) { // 第一行数据 | ||
| 314 | - sheet1.addCell(new Label(i, 0, colList.get(i))); | ||
| 315 | - } | ||
| 316 | - for (int i = 1; i < sheet1.getRows(); i++) { // 第二行开始 | ||
| 317 | - Cell[] cells1 = sheet.getRow(i); | ||
| 318 | - for (int j = 0; j < cells1.length; j++) { | ||
| 319 | - sheet1.addCell(new Label(j, i, cells1[j].getContents())); | ||
| 320 | - } | ||
| 321 | - } | ||
| 322 | - writableWorkbook.write(); | ||
| 323 | - writableWorkbook.close(); | ||
| 324 | - | ||
| 325 | - // 2、删除原有数据 | ||
| 326 | - ttInfoDetailService.deleteByTtinfo(Long.valueOf(form.get("ttid").toString())); | ||
| 327 | - | ||
| 328 | - // 3、导入时刻表 | ||
| 329 | - // 获取停车场名字 | ||
| 330 | - LineInformation lineInformation = lineInformationService.findById(Integer.valueOf(form.get("lineinfo").toString())); | ||
| 331 | - Map<String, Object> p1 = new HashMap<>(); | ||
| 332 | - p1.put("parkCode_eq", lineInformation.getCarPark()); | ||
| 333 | - List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 334 | - String tccname = carParkList.get(0).getParkName(); | ||
| 335 | - | ||
| 336 | - ttInfoDetailService.fileDataImport( | ||
| 337 | - new File(filename + "_temp.xls"), | ||
| 338 | - (String) form.get("sheetname"), | ||
| 339 | - (String) form.get("xlname"), | ||
| 340 | - (String) form.get("ttname"), | ||
| 341 | - tccname | ||
| 342 | - ); | ||
| 343 | - | ||
| 344 | - return rtn; | ||
| 345 | - } | ||
| 346 | - | ||
| 347 | - //------------- 旧版本 --------------// | ||
| 348 | - @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST) | ||
| 349 | - public Map<String, Object> uploadDataAndImport( | ||
| 350 | - MultipartFile file, String xlmc, String ttinfoname) throws Exception { | ||
| 351 | - Map<String, Object> resultMap = new HashMap<>(); | ||
| 352 | - | ||
| 353 | - try { | ||
| 354 | - // 查找lineinformation对象,没有报错 | ||
| 355 | - Map<String, Object> param = new HashMap<>(); | ||
| 356 | - param.put("line.name_eq", xlmc); | ||
| 357 | - Iterator<LineInformation> lineInformationIterator = lineInformationService.list(param).iterator(); | ||
| 358 | - if (!lineInformationIterator.hasNext()) { | ||
| 359 | - // 没有lineinformation,报错 | ||
| 360 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 361 | - resultMap.put("msg", "没有lineinfomation,线路名称=" + xlmc); | ||
| 362 | - } else { | ||
| 363 | - String tcccode = lineInformationIterator.next().getCarPark(); | ||
| 364 | - if (StringUtils.isEmpty(tcccode)) { | ||
| 365 | - // 没有停车场code,报错 | ||
| 366 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 367 | - resultMap.put("msg", "线路lineinfomation没有停车场code信息,线路名称=" + xlmc); | ||
| 368 | - } else { | ||
| 369 | - // 使用停车场code查找停车场 | ||
| 370 | - param.clear();; | ||
| 371 | - param.put("parkCode_eq", tcccode); | ||
| 372 | - Iterator<CarPark> carParkIterator = carParkService.list(param).iterator(); | ||
| 373 | - if (!carParkIterator.hasNext()) { | ||
| 374 | - // 指定的停车场code没有找到停车场信息,报错 | ||
| 375 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 376 | - resultMap.put("msg", "没有找到停车场信息,停车场code=" + tcccode); | ||
| 377 | - } else { | ||
| 378 | - String tccname = carParkIterator.next().getParkName(); | ||
| 379 | - if (StringUtils.isEmpty(tccname)) { | ||
| 380 | - // 没有停车场名字,报错 | ||
| 381 | - resultMap.put("status", ResponseCode.ERROR); | ||
| 382 | - resultMap.put("msg", "停车场信息没有停车场名字,停车场code=" + tcccode); | ||
| 383 | - } else { | ||
| 384 | - ttInfoDetailService.fileDataImport(file, xlmc, ttinfoname, tccname); | ||
| 385 | - resultMap.put("status", ResponseCode.SUCCESS); | ||
| 386 | - resultMap.put("msg", "导入成功"); | ||
| 387 | - } | ||
| 388 | - } | ||
| 389 | - } | ||
| 390 | - } | ||
| 391 | - } catch (Exception exp) { | ||
| 392 | - exp.printStackTrace(); | ||
| 393 | - throw exp; | ||
| 394 | - } | ||
| 395 | - | ||
| 396 | - return resultMap; | ||
| 397 | - } | ||
| 398 | - | ||
| 399 | - @RequestMapping(value = "/edit/{xlid}/{ttid}", method = RequestMethod.GET) | ||
| 400 | - public Object getEditInfo( | ||
| 401 | - @PathVariable("xlid") Integer xlid, | ||
| 402 | - @PathVariable("ttid") Long ttid) throws Exception { | ||
| 403 | - // TODO:返回类型需要修正 | ||
| 404 | - return ttInfoDetailService.getEditInfo(xlid, ttid); | ||
| 405 | - } | ||
| 406 | - | ||
| 407 | - @Override | ||
| 408 | - public TTInfoDetail findById(@PathVariable("id") Long aLong) { | ||
| 409 | - return ttInfoDetailRepository.findOneExtend(aLong); | ||
| 410 | - } | ||
| 411 | - | ||
| 412 | - @RequestMapping(value = "/bcdetail", method = RequestMethod.GET) | ||
| 413 | - public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { | ||
| 414 | - return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); | ||
| 415 | - } | ||
| 416 | - | ||
| 417 | - @Override | ||
| 418 | - public void dataExport(HttpServletResponse response, @RequestParam Map<String, Object> param) throws Exception { | ||
| 419 | - // 获取injectktr | ||
| 420 | - File ktrFile2 = new File(this.getClass().getResource( | ||
| 421 | - dataToolsProperties.getTtinfodetailOutput()).toURI()); | ||
| 422 | - param.put("injectktrfile", ktrFile2.getAbsolutePath()); | ||
| 423 | - param.put("ttinfoid", param.get("ttinfoid")); | ||
| 424 | - | ||
| 425 | - super.dataExport(response, param); | ||
| 426 | - } | ||
| 427 | - | ||
| 428 | - @Override | ||
| 429 | - protected String getDataExportKtrClasspath() { | ||
| 430 | - return dataToolsProperties.getTtinfodetailMetaoutput(); | ||
| 431 | - } | ||
| 432 | - | ||
| 433 | - @Override | ||
| 434 | - protected String getDataExportFilename() { | ||
| 435 | - return "时刻表"; | ||
| 436 | - } | ||
| 437 | -} |
src/main/java/com/bsth/controller/schedule/basicinfo/CarDeviceController.java
| @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.controller.schedule.BController; | 4 | import com.bsth.controller.schedule.BController; |
| 5 | import com.bsth.entity.CarDevice; | 5 | import com.bsth.entity.CarDevice; |
| 6 | import com.bsth.service.schedule.CarDeviceService; | 6 | import com.bsth.service.schedule.CarDeviceService; |
| 7 | -import com.bsth.service.schedule.ScheduleException; | 7 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | import org.springframework.web.bind.annotation.RequestMethod; | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
src/main/java/com/bsth/controller/schedule/basicinfo/CarsController.java
| @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.controller.schedule.BController; | 4 | import com.bsth.controller.schedule.BController; |
| 5 | import com.bsth.entity.Cars; | 5 | import com.bsth.entity.Cars; |
| 6 | import com.bsth.service.schedule.CarsService; | 6 | import com.bsth.service.schedule.CarsService; |
| 7 | -import com.bsth.service.schedule.ScheduleException; | 7 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | import org.springframework.web.bind.annotation.RequestMethod; | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
src/main/java/com/bsth/controller/schedule/basicinfo/EmployeeController.java
| @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | @@ -4,7 +4,7 @@ import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.controller.schedule.BController; | 4 | import com.bsth.controller.schedule.BController; |
| 5 | import com.bsth.entity.Personnel; | 5 | import com.bsth.entity.Personnel; |
| 6 | import com.bsth.service.schedule.EmployeeService; | 6 | import com.bsth.service.schedule.EmployeeService; |
| 7 | -import com.bsth.service.schedule.ScheduleException; | 7 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| 10 | import org.springframework.web.bind.annotation.RequestMethod; | 10 | import org.springframework.web.bind.annotation.RequestMethod; |
src/main/java/com/bsth/controller/schedule/core/CarConfigInfoController.java
| @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | ||
| 5 | import com.bsth.entity.schedule.CarConfigInfo; | 5 | import com.bsth.entity.schedule.CarConfigInfo; |
| 6 | import com.bsth.repository.schedule.CarConfigInfoRepository; | 6 | import com.bsth.repository.schedule.CarConfigInfoRepository; |
| 7 | import com.bsth.service.schedule.CarConfigInfoService; | 7 | import com.bsth.service.schedule.CarConfigInfoService; |
| 8 | -import com.bsth.service.schedule.ScheduleException; | 8 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.web.bind.annotation.RequestMapping; | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | import org.springframework.web.bind.annotation.RequestMethod; | 11 | import org.springframework.web.bind.annotation.RequestMethod; |
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController.java
| @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | ||
| 5 | import com.bsth.entity.schedule.EmployeeConfigInfo; | 5 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 6 | import com.bsth.repository.schedule.EmployeeConfigInfoRepository; | 6 | import com.bsth.repository.schedule.EmployeeConfigInfoRepository; |
| 7 | import com.bsth.service.schedule.EmployeeConfigInfoService; | 7 | import com.bsth.service.schedule.EmployeeConfigInfoService; |
| 8 | -import com.bsth.service.schedule.ScheduleException; | 8 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.web.bind.annotation.RequestMapping; | 10 | import org.springframework.web.bind.annotation.RequestMapping; |
| 11 | import org.springframework.web.bind.annotation.RequestMethod; | 11 | import org.springframework.web.bind.annotation.RequestMethod; |
src/main/java/com/bsth/controller/schedule/core/GuideboardInfoController.java
| @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | @@ -5,7 +5,7 @@ import com.bsth.controller.schedule.BController; | ||
| 5 | import com.bsth.entity.schedule.GuideboardInfo; | 5 | import com.bsth.entity.schedule.GuideboardInfo; |
| 6 | import com.bsth.repository.schedule.GuideboardInfoRepository; | 6 | import com.bsth.repository.schedule.GuideboardInfoRepository; |
| 7 | import com.bsth.service.schedule.GuideboardInfoService; | 7 | import com.bsth.service.schedule.GuideboardInfoService; |
| 8 | -import com.bsth.service.schedule.ScheduleException; | 8 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 9 | import com.bsth.service.schedule.utils.DataToolsProperties; | 9 | import com.bsth.service.schedule.utils.DataToolsProperties; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | import org.springframework.boot.context.properties.EnableConfigurationProperties; | 11 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
src/main/java/com/bsth/controller/schedule/core/ScheduleRule1FlatController.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.schedule.BController; | ||
| 4 | +import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RestController; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by xu on 16/7/4. | ||
| 10 | + */ | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("sr1fc") | ||
| 13 | +public class ScheduleRule1FlatController extends BController<ScheduleRule1Flat, Long> { | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +} |
src/main/java/com/bsth/controller/schedule/core/TTInfoController.java
| @@ -3,7 +3,7 @@ package com.bsth.controller.schedule.core; | @@ -3,7 +3,7 @@ package com.bsth.controller.schedule.core; | ||
| 3 | import com.bsth.common.ResponseCode; | 3 | import com.bsth.common.ResponseCode; |
| 4 | import com.bsth.controller.schedule.BController; | 4 | import com.bsth.controller.schedule.BController; |
| 5 | import com.bsth.entity.schedule.TTInfo; | 5 | import com.bsth.entity.schedule.TTInfo; |
| 6 | -import com.bsth.service.schedule.ScheduleException; | 6 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | import com.bsth.service.schedule.TTInfoService; | 7 | import com.bsth.service.schedule.TTInfoService; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.web.bind.annotation.RequestMapping; | 9 | import org.springframework.web.bind.annotation.RequestMapping; |
| @@ -87,42 +87,4 @@ public class TTInfoController extends BController<TTInfo, Long> { | @@ -87,42 +87,4 @@ public class TTInfoController extends BController<TTInfo, Long> { | ||
| 87 | return rtn; | 87 | return rtn; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | -} | ||
| 91 | - | ||
| 92 | -// | ||
| 93 | -//@Autowired | ||
| 94 | -//private DataToolsProperties dataToolsProperties; | ||
| 95 | -//@Autowired | ||
| 96 | -//private TTInfoRepository ttInfoRepository; | ||
| 97 | -//@Autowired | ||
| 98 | -//private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 99 | -// | ||
| 100 | -// @Override | ||
| 101 | -// protected String getDataImportKtrClasspath() { | ||
| 102 | -// return dataToolsProperties.getTtinfoDatainputktr(); | ||
| 103 | -// } | ||
| 104 | -// | ||
| 105 | -// @Override | ||
| 106 | -// public TTInfo findById(@PathVariable("id") Long aLong) { | ||
| 107 | -// return ttInfoRepository.findOneExtend(aLong); | ||
| 108 | -// } | ||
| 109 | -// | ||
| 110 | -// /** | ||
| 111 | -// * 验证。 | ||
| 112 | -// * @param map | ||
| 113 | -// * @return | ||
| 114 | -// */ | ||
| 115 | -// @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) | ||
| 116 | -// public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { | ||
| 117 | -// // 一般比较自编号是否重复 | ||
| 118 | -// return baseService.validateEquale(map); | ||
| 119 | -// } | ||
| 120 | -// | ||
| 121 | -// @Override | ||
| 122 | -// public Page<TTInfo> list(@RequestParam Map<String, Object> map, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "10") int size, @RequestParam(defaultValue = "id") String order, @RequestParam(defaultValue = "DESC") String direction) { | ||
| 123 | -// // 如果有isCancel键值,将其值变成boolean | ||
| 124 | -// if (map.get("isCancel_eq") != null) | ||
| 125 | -// map.put("isCancel_eq", new Boolean(map.get("isCancel_eq").toString())); | ||
| 126 | -// | ||
| 127 | -// return super.list(map, page, size, order, direction); | ||
| 128 | -// } | ||
| 129 | \ No newline at end of file | 90 | \ No newline at end of file |
| 91 | +} | ||
| 130 | \ No newline at end of file | 92 | \ No newline at end of file |
src/main/java/com/bsth/controller/schedule/core/TTInfoDetailController.java
0 → 100644
| 1 | +package com.bsth.controller.schedule.core; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 4 | +import com.bsth.controller.schedule.BController; | ||
| 5 | +import com.bsth.entity.schedule.TTInfoDetail; | ||
| 6 | +import com.bsth.service.schedule.TTInfoDetailService; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 11 | +import org.springframework.web.bind.annotation.RestController; | ||
| 12 | + | ||
| 13 | +import java.util.HashMap; | ||
| 14 | +import java.util.List; | ||
| 15 | +import java.util.Map; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * Created by xu on 17/1/4. | ||
| 19 | + */ | ||
| 20 | +@RestController | ||
| 21 | +@RequestMapping("tidc") | ||
| 22 | +public class TTInfoDetailController extends BController<TTInfoDetail, Long> { | ||
| 23 | + @Autowired | ||
| 24 | + private TTInfoDetailService ttInfoDetailService; | ||
| 25 | + | ||
| 26 | + @RequestMapping(value = "/bcdetail", method = RequestMethod.GET) | ||
| 27 | + public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { | ||
| 28 | + return ttInfoDetailService.findBcdetails(xlId, ttinfoId, lpId); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 验证sheet(以后放到规则引擎里去做)。 | ||
| 33 | + * @param filename excel文件全路径名 | ||
| 34 | + * @param sheetname sheet名字 | ||
| 35 | + * @param lineid 线路id | ||
| 36 | + * @param linename 线路名称 | ||
| 37 | + * @return | ||
| 38 | + */ | ||
| 39 | + @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) | ||
| 40 | + public Map<String, Object> validate_sheet(String filename, String sheetname, Integer lineid, String linename) { | ||
| 41 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 42 | + try { | ||
| 43 | + ttInfoDetailService.validateExcelSheet(filename, sheetname, lineid, linename); | ||
| 44 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 45 | + } catch (Exception exp) { | ||
| 46 | + rtn.put("status", ResponseCode.ERROR); | ||
| 47 | + rtn.put("msg", exp.getMessage()); | ||
| 48 | + } | ||
| 49 | + return rtn; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 验证关联的线路标准信息(以后放到规则引擎里去做)。 | ||
| 54 | + * @param lineinfoid | ||
| 55 | + * @return | ||
| 56 | + */ | ||
| 57 | + @RequestMapping(value = "/validate/lineinfo", method = RequestMethod.GET) | ||
| 58 | + public Map<String, Object> validate_lineInfo(Integer lineinfoid) { | ||
| 59 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 60 | + try { | ||
| 61 | + ttInfoDetailService.validateAssoLineInfo(lineinfoid); | ||
| 62 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 63 | + } catch (Exception exp) { | ||
| 64 | + rtn.put("status", ResponseCode.ERROR); | ||
| 65 | + rtn.put("msg", exp.getMessage()); | ||
| 66 | + } | ||
| 67 | + return rtn; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 获取时刻表明细编辑信息。 | ||
| 72 | + * @param xlid 线路id | ||
| 73 | + * @param ttid 时刻表id | ||
| 74 | + * @return | ||
| 75 | + */ | ||
| 76 | + @RequestMapping(value = "/edit/{xlid}/{ttid}", method = RequestMethod.GET) | ||
| 77 | + public Map<String, Object> getEditInfo(@PathVariable("xlid") Integer xlid, | ||
| 78 | + @PathVariable("ttid") Long ttid) { | ||
| 79 | + Map<String, Object> rtn = new HashMap<>(); | ||
| 80 | + try { | ||
| 81 | + TTInfoDetailService.EditInfo editInfo = ttInfoDetailService.getEditInfo(xlid, ttid); | ||
| 82 | + rtn.put("status", ResponseCode.SUCCESS); | ||
| 83 | + rtn.put("data", editInfo); | ||
| 84 | + } catch (Exception exp) { | ||
| 85 | + rtn.put("status", ResponseCode.ERROR); | ||
| 86 | + rtn.put("msg", exp.getMessage()); | ||
| 87 | + } | ||
| 88 | + return rtn; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | +} |
src/main/java/com/bsth/controller/sys/DutyEmployeeController.java
0 → 100644
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.sys.DutyEmployee; | ||
| 5 | +import com.bsth.service.sys.DutyEmployeeService; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/1/5. | ||
| 15 | + */ | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("dutyEmployee") | ||
| 18 | +public class DutyEmployeeController extends BaseController<DutyEmployee, Long> { | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + DutyEmployeeService dutyEmployeeService; | ||
| 22 | + | ||
| 23 | + @RequestMapping(value = "queryByLineAndTime") | ||
| 24 | + public List<DutyEmployee> getDutyEmployee(@RequestParam String lineCode, @RequestParam String startTime, @RequestParam String endTime) { | ||
| 25 | + return dutyEmployeeService.getDutyEmployee(lineCode, startTime, endTime); | ||
| 26 | + } | ||
| 27 | +} |
src/main/java/com/bsth/data/BasicData.java
| @@ -13,7 +13,6 @@ import org.slf4j.Logger; | @@ -13,7 +13,6 @@ import org.slf4j.Logger; | ||
| 13 | import org.slf4j.LoggerFactory; | 13 | import org.slf4j.LoggerFactory; |
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.boot.CommandLineRunner; | 15 | import org.springframework.boot.CommandLineRunner; |
| 16 | -import org.springframework.core.annotation.Order; | ||
| 17 | import org.springframework.stereotype.Component; | 16 | import org.springframework.stereotype.Component; |
| 18 | 17 | ||
| 19 | import java.util.*; | 18 | import java.util.*; |
| @@ -26,7 +25,6 @@ import java.util.concurrent.TimeUnit; | @@ -26,7 +25,6 @@ import java.util.concurrent.TimeUnit; | ||
| 26 | * @date 2016年8月10日 下午3:27:45 | 25 | * @date 2016年8月10日 下午3:27:45 |
| 27 | */ | 26 | */ |
| 28 | @Component | 27 | @Component |
| 29 | -@Order(value = 1) | ||
| 30 | public class BasicData implements CommandLineRunner { | 28 | public class BasicData implements CommandLineRunner { |
| 31 | 29 | ||
| 32 | //公司代码和公司名对照(K: 公司编码,V:公司名) | 30 | //公司代码和公司名对照(K: 公司编码,V:公司名) |
| @@ -83,9 +81,13 @@ public class BasicData implements CommandLineRunner { | @@ -83,9 +81,13 @@ public class BasicData implements CommandLineRunner { | ||
| 83 | 81 | ||
| 84 | @Override | 82 | @Override |
| 85 | public void run(String... arg0) throws Exception { | 83 | public void run(String... arg0) throws Exception { |
| 86 | - Application.mainServices.scheduleWithFixedDelay(dataLoader, 0, 2, TimeUnit.HOURS); | 84 | + Application.mainServices.scheduleWithFixedDelay(dataLoader, 2, 2, TimeUnit.HOURS); |
| 87 | } | 85 | } |
| 88 | 86 | ||
| 87 | + public static String getStationNameByCode(String code, String prefix){ | ||
| 88 | + String name = stationCode2NameMap.get(code); | ||
| 89 | + return name != null? name: stationCode2NameMap.get(prefix + code); | ||
| 90 | + } | ||
| 89 | 91 | ||
| 90 | @Component | 92 | @Component |
| 91 | public static class BasicDataLoader extends Thread { | 93 | public static class BasicDataLoader extends Thread { |
| @@ -259,26 +261,26 @@ public class BasicData implements CommandLineRunner { | @@ -259,26 +261,26 @@ public class BasicData implements CommandLineRunner { | ||
| 259 | /** | 261 | /** |
| 260 | * 加载运管处的站点及序号 | 262 | * 加载运管处的站点及序号 |
| 261 | * 上行从1开始,下行顺序续编 | 263 | * 上行从1开始,下行顺序续编 |
| 262 | - | ||
| 263 | - List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc(); | ||
| 264 | - if(ygcLines != null && ygcLines.size() > 0){ | ||
| 265 | - int size = ygcLines.size(); | ||
| 266 | - Object[] tempArray ; | ||
| 267 | - int num = 1; | ||
| 268 | - String key; | ||
| 269 | - String lineCode = ""; | ||
| 270 | - for (int i = 0; i < size; i ++){ | ||
| 271 | - tempArray = ygcLines.get(i); | ||
| 272 | - if(lineCode.equals("")){ | ||
| 273 | - lineCode = tempArray[0]+""; | ||
| 274 | - }else if(!lineCode.equals(tempArray[0]+"")){ | ||
| 275 | - num = 1; | ||
| 276 | - lineCode = tempArray[0]+""; | ||
| 277 | - } | ||
| 278 | - key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2]; | ||
| 279 | - tempStationName2YgcNumber.put(key,num++); | ||
| 280 | - } | ||
| 281 | - }*/ | 264 | + */ |
| 265 | + List<Object[]> ygcLines = stationRouteRepository.findAllLineWithYgc(); | ||
| 266 | + if(ygcLines != null && ygcLines.size() > 0){ | ||
| 267 | + int size = ygcLines.size(); | ||
| 268 | + Object[] tempArray ; | ||
| 269 | + int num = 1; | ||
| 270 | + String key; | ||
| 271 | + String lineCode = ""; | ||
| 272 | + for (int i = 0; i < size; i ++){ | ||
| 273 | + tempArray = ygcLines.get(i); | ||
| 274 | + if(lineCode.equals("")){ | ||
| 275 | + lineCode = tempArray[0]+""; | ||
| 276 | + }else if(!lineCode.equals(tempArray[0]+"")){ | ||
| 277 | + num = 1; | ||
| 278 | + lineCode = tempArray[0]+""; | ||
| 279 | + } | ||
| 280 | + key = tempArray[0] + "_"+tempArray[1] + "_"+tempArray[2]; | ||
| 281 | + tempStationName2YgcNumber.put(key,num++); | ||
| 282 | + } | ||
| 283 | + } | ||
| 282 | } | 284 | } |
| 283 | 285 | ||
| 284 | lineId2CodeMap = biMap; | 286 | lineId2CodeMap = biMap; |
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
| 1 | package com.bsth.data.arrival; | 1 | package com.bsth.data.arrival; |
| 2 | 2 | ||
| 3 | -import com.bsth.data.match.Arrival2Schedule; | ||
| 4 | import com.bsth.data.schedule.DayOfSchedule; | 3 | import com.bsth.data.schedule.DayOfSchedule; |
| 5 | import com.google.common.collect.ArrayListMultimap; | 4 | import com.google.common.collect.ArrayListMultimap; |
| 6 | import com.google.common.collect.ListMultimap; | 5 | import com.google.common.collect.ListMultimap; |
| @@ -59,7 +58,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ | @@ -59,7 +58,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ | ||
| 59 | 58 | ||
| 60 | @Override | 59 | @Override |
| 61 | public void run() { | 60 | public void run() { |
| 62 | - try{ | 61 | + /*try{ |
| 63 | logger.info("开始加载到离站数据, " + System.currentTimeMillis()); | 62 | logger.info("开始加载到离站数据, " + System.currentTimeMillis()); |
| 64 | List<ArrivalEntity> arrSets = dataLoader.load(); | 63 | List<ArrivalEntity> arrSets = dataLoader.load(); |
| 65 | if(null == arrSets || arrSets.size() == 0) | 64 | if(null == arrSets || arrSets.size() == 0) |
| @@ -86,7 +85,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ | @@ -86,7 +85,7 @@ public class ArrivalData_GPS implements CommandLineRunner{ | ||
| 86 | Arrival2Schedule.start(carSet); | 85 | Arrival2Schedule.start(carSet); |
| 87 | }catch(Exception e){ | 86 | }catch(Exception e){ |
| 88 | logger.error("", e); | 87 | logger.error("", e); |
| 89 | - } | 88 | + }*/ |
| 90 | } | 89 | } |
| 91 | } | 90 | } |
| 92 | 91 |
src/main/java/com/bsth/data/forecast/ForecastRealServer.java
| 1 | package com.bsth.data.forecast; | 1 | package com.bsth.data.forecast; |
| 2 | 2 | ||
| 3 | +import com.bsth.Application; | ||
| 3 | import com.bsth.data.forecast.entity.ForecastResult; | 4 | import com.bsth.data.forecast.entity.ForecastResult; |
| 4 | import com.bsth.data.forecast.entity.ForecastResult.ForecastResultItem; | 5 | import com.bsth.data.forecast.entity.ForecastResult.ForecastResultItem; |
| 5 | import com.bsth.data.forecast.entity.SimpleRoute; | 6 | import com.bsth.data.forecast.entity.SimpleRoute; |
| @@ -20,6 +21,7 @@ import java.util.ArrayList; | @@ -20,6 +21,7 @@ import java.util.ArrayList; | ||
| 20 | import java.util.HashMap; | 21 | import java.util.HashMap; |
| 21 | import java.util.List; | 22 | import java.util.List; |
| 22 | import java.util.Map; | 23 | import java.util.Map; |
| 24 | +import java.util.concurrent.TimeUnit; | ||
| 23 | 25 | ||
| 24 | /** | 26 | /** |
| 25 | * | 27 | * |
| @@ -58,7 +60,7 @@ public class ForecastRealServer implements CommandLineRunner { | @@ -58,7 +60,7 @@ public class ForecastRealServer implements CommandLineRunner { | ||
| 58 | @Override | 60 | @Override |
| 59 | public void run(String... arg0) throws Exception { | 61 | public void run(String... arg0) throws Exception { |
| 60 | //2小时更新一次站点间耗时数据 | 62 | //2小时更新一次站点间耗时数据 |
| 61 | - //Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); | 63 | + Application.mainServices.scheduleWithFixedDelay(dataLoader, 12, 120 * 60, TimeUnit.SECONDS); |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | /** | 66 | /** |
| @@ -86,7 +88,7 @@ public class ForecastRealServer implements CommandLineRunner { | @@ -86,7 +88,7 @@ public class ForecastRealServer implements CommandLineRunner { | ||
| 86 | //终点站 | 88 | //终点站 |
| 87 | String eStation = null; | 89 | String eStation = null; |
| 88 | //当前执行班次 | 90 | //当前执行班次 |
| 89 | - ScheduleRealInfo sch = dayOfSchedule.execPlanMap().get(nbbm); | 91 | + ScheduleRealInfo sch = dayOfSchedule.executeCurr(nbbm); |
| 90 | if(null != sch) | 92 | if(null != sch) |
| 91 | eStation = sch.getZdzCode(); | 93 | eStation = sch.getZdzCode(); |
| 92 | 94 |
src/main/java/com/bsth/data/gpsdata/GpsEntity.java
| @@ -67,16 +67,10 @@ public class GpsEntity { | @@ -67,16 +67,10 @@ public class GpsEntity { | ||
| 67 | /** 当前执行班次ID */ | 67 | /** 当前执行班次ID */ |
| 68 | private Long schId; | 68 | private Long schId; |
| 69 | 69 | ||
| 70 | - /** 是否异常数据 */ | ||
| 71 | - private boolean abnormal; | ||
| 72 | -/* | ||
| 73 | - private int valid;*/ | ||
| 74 | - | ||
| 75 | - private int version; | 70 | + /** 是否是不完整的数据 */ |
| 71 | + private boolean incomplete; | ||
| 76 | 72 | ||
| 77 | - /** 是否起终点站 | ||
| 78 | - private boolean sEPoint; | ||
| 79 | - */ | 73 | + private int version; |
| 80 | 74 | ||
| 81 | /** 0: 站外 1:站内 2:场内 */ | 75 | /** 0: 站外 1:站内 2:场内 */ |
| 82 | private int instation; | 76 | private int instation; |
| @@ -88,6 +82,12 @@ public class GpsEntity { | @@ -88,6 +82,12 @@ public class GpsEntity { | ||
| 88 | /** 状态 */ | 82 | /** 状态 */ |
| 89 | private String signalState = "normal"; | 83 | private String signalState = "normal"; |
| 90 | 84 | ||
| 85 | + /** 异常状态 */ | ||
| 86 | + private String abnormalStatus; | ||
| 87 | + | ||
| 88 | + /** 越界距离 */ | ||
| 89 | + private double outOfBoundDistance; | ||
| 90 | + | ||
| 91 | public Integer getCompanyCode() { | 91 | public Integer getCompanyCode() { |
| 92 | return companyCode; | 92 | return companyCode; |
| 93 | } | 93 | } |
| @@ -241,14 +241,6 @@ public class GpsEntity { | @@ -241,14 +241,6 @@ public class GpsEntity { | ||
| 241 | this.station = station; | 241 | this.station = station; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | - public boolean isAbnormal() { | ||
| 245 | - return abnormal; | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - public void setAbnormal(boolean abnormal) { | ||
| 249 | - this.abnormal = abnormal; | ||
| 250 | - } | ||
| 251 | - | ||
| 252 | public String getSignalState() { | 244 | public String getSignalState() { |
| 253 | return signalState; | 245 | return signalState; |
| 254 | } | 246 | } |
| @@ -264,4 +256,28 @@ public class GpsEntity { | @@ -264,4 +256,28 @@ public class GpsEntity { | ||
| 264 | public void setInstation(int instation) { | 256 | public void setInstation(int instation) { |
| 265 | this.instation = instation; | 257 | this.instation = instation; |
| 266 | } | 258 | } |
| 259 | + | ||
| 260 | + public String getAbnormalStatus() { | ||
| 261 | + return abnormalStatus; | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + public void setAbnormalStatus(String abnormalStatus) { | ||
| 265 | + this.abnormalStatus = abnormalStatus; | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + public boolean isIncomplete() { | ||
| 269 | + return incomplete; | ||
| 270 | + } | ||
| 271 | + | ||
| 272 | + public void setIncomplete(boolean incomplete) { | ||
| 273 | + this.incomplete = incomplete; | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + public double getOutOfBoundDistance() { | ||
| 277 | + return outOfBoundDistance; | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + public void setOutOfBoundDistance(double outOfBoundDistance) { | ||
| 281 | + this.outOfBoundDistance = outOfBoundDistance; | ||
| 282 | + } | ||
| 267 | } | 283 | } |
src/main/java/com/bsth/data/gpsdata/GpsRealData.java
| @@ -66,22 +66,41 @@ public class GpsRealData implements CommandLineRunner { | @@ -66,22 +66,41 @@ public class GpsRealData implements CommandLineRunner { | ||
| 66 | @Override | 66 | @Override |
| 67 | public void run(String... arg0) throws Exception { | 67 | public void run(String... arg0) throws Exception { |
| 68 | logger.info("gpsDataLoader,20,5"); | 68 | logger.info("gpsDataLoader,20,5"); |
| 69 | - //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 6, TimeUnit.SECONDS); | 69 | + //Application.mainServices.scheduleWithFixedDelay(gpsDataLoader, 20, 5, TimeUnit.SECONDS); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | public void put(GpsEntity gps) { | 72 | public void put(GpsEntity gps) { |
| 73 | String device = gps.getDeviceId(); | 73 | String device = gps.getDeviceId(); |
| 74 | - gpsMap.put(device, gps); | 74 | + GpsEntity old = gpsMap.get(device); |
| 75 | + | ||
| 76 | + try { | ||
| 77 | + if (!StringUtils.isEmpty(gps.getStopNo())) { | ||
| 78 | + //站点编码改变 | ||
| 79 | + if (null == old || !gps.getStopNo().equals(old.getStopNo())) { | ||
| 80 | + gps.setArrTime(gps.getTimestamp()); | ||
| 81 | + //预测到达终点时间 | ||
| 82 | + forecastRealServer.forecast(gps.getNbbm(), gps); | ||
| 83 | + } else { | ||
| 84 | + gps.setArrTime(old.getArrTime()); | ||
| 85 | + //不预测, 重新计算终点时间 | ||
| 86 | + gps.setExpectStopTime(forecastRealServer.expectStopTime(gps.getNbbm())); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + } catch (Exception e) { | ||
| 90 | + logger.error("", e); | ||
| 91 | + } | ||
| 75 | 92 | ||
| 76 | - if (StringUtils.isNotBlank(gps.getLineId())){ | 93 | + //刷新对照 |
| 94 | + gpsMap.put(device, gps); | ||
| 95 | + if (StringUtils.isNotBlank(gps.getLineId())) { | ||
| 77 | //站点名称 | 96 | //站点名称 |
| 78 | gps.setStationName(getStationName(gps)); | 97 | gps.setStationName(getStationName(gps)); |
| 79 | lineCode2Devices.put(gps.getLineId(), device); | 98 | lineCode2Devices.put(gps.getLineId(), device); |
| 80 | } | 99 | } |
| 81 | } | 100 | } |
| 82 | 101 | ||
| 83 | - public String getStationName(GpsEntity gps){ | ||
| 84 | - return BasicData.stationCode2NameMap.get(gps.getLineId() + "_" + gps.getUpDown() + gps.getStopNo()); | 102 | + public String getStationName(GpsEntity gps) { |
| 103 | + return BasicData.getStationNameByCode(gps.getStopNo(), gps.getLineId() + "_" + gps.getUpDown() + "_"); | ||
| 85 | } | 104 | } |
| 86 | 105 | ||
| 87 | /** | 106 | /** |
| @@ -103,7 +122,7 @@ public class GpsRealData implements CommandLineRunner { | @@ -103,7 +122,7 @@ public class GpsRealData implements CommandLineRunner { | ||
| 103 | for (String device : set) { | 122 | for (String device : set) { |
| 104 | gps = gpsMap.get(device); | 123 | gps = gpsMap.get(device); |
| 105 | //过滤异常GPS数据 | 124 | //过滤异常GPS数据 |
| 106 | - if (gps.isAbnormal()) | 125 | + if (gps == null || gps.isIncomplete()) |
| 107 | continue; | 126 | continue; |
| 108 | 127 | ||
| 109 | sch = dayOfSchedule.execPlanMap().get(gps.getNbbm()); | 128 | sch = dayOfSchedule.execPlanMap().get(gps.getNbbm()); |
| @@ -201,13 +220,11 @@ public class GpsRealData implements CommandLineRunner { | @@ -201,13 +220,11 @@ public class GpsRealData implements CommandLineRunner { | ||
| 201 | 220 | ||
| 202 | nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); | 221 | nbbm = BasicData.deviceId2NbbmMap.get(gps.getDeviceId()); |
| 203 | if (StringUtils.isBlank(nbbm)) | 222 | if (StringUtils.isBlank(nbbm)) |
| 204 | - gps.setAbnormal(true);//标记为异常数据 | 223 | + gps.setIncomplete(true);//标记为异常数据 |
| 205 | else | 224 | else |
| 206 | gps.setNbbm(nbbm); | 225 | gps.setNbbm(nbbm); |
| 207 | //有更新的点位 | 226 | //有更新的点位 |
| 208 | updateList.add(gps); | 227 | updateList.add(gps); |
| 209 | - //实时GPS数据集 | ||
| 210 | - gpsRealData.put(gps); | ||
| 211 | } | 228 | } |
| 212 | //分析数据 | 229 | //分析数据 |
| 213 | gpsRealAnalyse.analyse(updateList); | 230 | gpsRealAnalyse.analyse(updateList); |
src/main/java/com/bsth/data/gpsdata/arrival/GeoCacheData.java
| @@ -45,6 +45,9 @@ public class GeoCacheData { | @@ -45,6 +45,9 @@ public class GeoCacheData { | ||
| 45 | //停车场 | 45 | //停车场 |
| 46 | public static Map<String, Polygon> tccMap; | 46 | public static Map<String, Polygon> tccMap; |
| 47 | 47 | ||
| 48 | + //线路限速信息 | ||
| 49 | + private static Map<String, Double> speedLimitMap; | ||
| 50 | + | ||
| 48 | @Autowired | 51 | @Autowired |
| 49 | JdbcTemplate jdbcTemplate; | 52 | JdbcTemplate jdbcTemplate; |
| 50 | 53 | ||
| @@ -94,6 +97,14 @@ public class GeoCacheData { | @@ -94,6 +97,14 @@ public class GeoCacheData { | ||
| 94 | return null; | 97 | return null; |
| 95 | } | 98 | } |
| 96 | 99 | ||
| 100 | + public static Double speedLimit(String lineCode){ | ||
| 101 | + return speedLimitMap.get(lineCode); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public static List<LineString> getLineStringList(GpsEntity gps){ | ||
| 105 | + return sectionCacheMap.get(gps.getLineId() + "_" + gps.getUpDown()); | ||
| 106 | + } | ||
| 107 | + | ||
| 97 | public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) { | 108 | public static List<StationRoute> midwayStation(String lineCode, int directions, String sCode, String eCode) { |
| 98 | List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>(); | 109 | List<StationRoute> list = getStationRoute(lineCode, directions), rs = new ArrayList<>(); |
| 99 | 110 | ||
| @@ -113,8 +124,72 @@ public class GeoCacheData { | @@ -113,8 +124,72 @@ public class GeoCacheData { | ||
| 113 | return tccMap.get(code); | 124 | return tccMap.get(code); |
| 114 | } | 125 | } |
| 115 | 126 | ||
| 127 | + GeometryFactory geometryFactory = new GeometryFactory(); | ||
| 116 | public void loadData() { | 128 | public void loadData() { |
| 117 | - final GeometryFactory geometryFactory = new GeometryFactory(); | 129 | + loadStationRoutesData(); |
| 130 | + loadTccMapData(); | ||
| 131 | + loadSpeedLimit(); | ||
| 132 | + | ||
| 133 | + //加载路段信息 | ||
| 134 | + loadRoadsData(); | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + private void loadRoadsData() { | ||
| 138 | + String sql = "select r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText(s.GSECTION_VECTOR) as GSECTION_VECTOR, r.DIRECTIONS from bsth_c_sectionroute r INNER JOIN bsth_c_section s on r.section=s.id where r.destroy=0 and GSECTION_VECTOR is not null order by line_code,directions,sectionroute_code"; | ||
| 139 | + List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql); | ||
| 140 | + | ||
| 141 | + String polygonStr, key; | ||
| 142 | + String[] coords; | ||
| 143 | + int i, len; | ||
| 144 | + | ||
| 145 | + ArrayListMultimap<String, LineString> sectionCacheTempMap = ArrayListMultimap.create(); | ||
| 146 | + Coordinate[] cds; | ||
| 147 | + String[] temps1, temps2; | ||
| 148 | + for (Map<String, Object> tMap : secList) { | ||
| 149 | + polygonStr = tMap.get("GSECTION_VECTOR").toString(); | ||
| 150 | + key = tMap.get("LINE_CODE") + "_" + tMap.get("DIRECTIONS"); | ||
| 151 | + | ||
| 152 | + coords = polygonStr.substring(11, polygonStr.length() - 1).split(","); | ||
| 153 | + len = coords.length - 1; | ||
| 154 | + //每2个点连一条线 | ||
| 155 | + for(i = 0; i < len; i ++){ | ||
| 156 | + temps1 = coords[i].split(" "); | ||
| 157 | + temps2 = coords[i + 1].split(" "); | ||
| 158 | + | ||
| 159 | + cds = new Coordinate[2]; | ||
| 160 | + cds[0] = new Coordinate(Float.parseFloat(temps1[1]), Float.parseFloat(temps1[0])); | ||
| 161 | + cds[1] = new Coordinate(Float.parseFloat(temps2[1]), Float.parseFloat(temps2[0])); | ||
| 162 | + | ||
| 163 | + sectionCacheTempMap.put(key, geometryFactory.createLineString(cds)); | ||
| 164 | + } | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + if(sectionCacheTempMap.size() > 0) | ||
| 168 | + sectionCacheMap = sectionCacheTempMap; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + private void loadTccMapData(){ | ||
| 172 | + //加载停车场数据 | ||
| 173 | + String sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null"; | ||
| 174 | + List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql); | ||
| 175 | + Map<String, Polygon> tccTempMap = new HashMap<>(); | ||
| 176 | + | ||
| 177 | + Polygon polygon; | ||
| 178 | + for (Map<String, Object> tMap : tccList) { | ||
| 179 | + | ||
| 180 | + try { | ||
| 181 | + polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString())); | ||
| 182 | + tccTempMap.put(tMap.get("PARK_CODE").toString() | ||
| 183 | + , polygon); | ||
| 184 | + } catch (Exception e) { | ||
| 185 | + logger.error("停车场:" + tMap.get("PARK_CODE"), e); | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + if (tccTempMap.size() > 0) | ||
| 189 | + tccMap = tccTempMap; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + private void loadStationRoutesData(){ | ||
| 118 | //加载站点路由 | 193 | //加载站点路由 |
| 119 | String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code"; | 194 | String sql = "select r.LINE_CODE,r.DIRECTIONS,r.STATION_CODE,r.STATION_MARK,s.SHAPES_TYPE,s.G_LONX,s.G_LATY,ST_AsText(s.G_POLYGON_GRID) as G_POLYGON_GRID,s.RADIUS, r.STATION_ROUTE_CODE,s.STATION_NAME from bsth_c_stationroute r left join bsth_c_station s on r.station=s.id where r.destroy=0 order by r.station_route_code"; |
| 120 | List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() { | 195 | List<StationRoute> routeList = jdbcTemplate.query(sql, new RowMapper<StationRoute>() { |
| @@ -159,26 +234,17 @@ public class GeoCacheData { | @@ -159,26 +234,17 @@ public class GeoCacheData { | ||
| 159 | stationCacheMap = tempMap; | 234 | stationCacheMap = tempMap; |
| 160 | routeCodeMap = codeMap; | 235 | routeCodeMap = codeMap; |
| 161 | } | 236 | } |
| 237 | + } | ||
| 162 | 238 | ||
| 163 | - //加载停车场数据 | ||
| 164 | - sql = "select PARK_CODE, ST_AsText(G_PARK_POINT) as G_PARK_POINT from bsth_c_car_park where park_code is not null and b_park_point is not null"; | ||
| 165 | - List<Map<String, Object>> tccList = jdbcTemplate.queryForList(sql); | ||
| 166 | - Map<String, Polygon> tccTempMap = new HashMap<>(); | ||
| 167 | - | ||
| 168 | - Polygon polygon; | ||
| 169 | - for (Map<String, Object> tMap : tccList) { | ||
| 170 | - | ||
| 171 | - try { | ||
| 172 | - polygon = geometryFactory.createPolygon(parsePolygon(tMap.get("G_PARK_POINT").toString())); | ||
| 173 | - tccTempMap.put(tMap.get("PARK_CODE").toString() | ||
| 174 | - , polygon); | ||
| 175 | - } catch (Exception e) { | ||
| 176 | - logger.error("停车场:" + tMap.get("PARK_CODE"), e); | ||
| 177 | - } | 239 | + private void loadSpeedLimit(){ |
| 240 | + //加载线路限速信息 | ||
| 241 | + String sql = "select l.LINE_CODE,i.SPEED_LIMIT from bsth_c_line_information i left join bsth_c_line l on i.line=l.id where i.speed_limit is not null"; | ||
| 242 | + List<Map<String, Object>> speedMap = jdbcTemplate.queryForList(sql); | ||
| 243 | + Map<String, Double> speedTempMap = new HashMap<>(); | ||
| 244 | + for (Map<String, Object> tMap : speedMap) { | ||
| 245 | + speedTempMap.put(tMap.get("LINE_CODE").toString(), Double.parseDouble(tMap.get("SPEED_LIMIT").toString())); | ||
| 178 | } | 246 | } |
| 179 | - | ||
| 180 | - if (tccTempMap.size() > 0) | ||
| 181 | - tccMap = tccTempMap; | 247 | + speedLimitMap = speedTempMap; |
| 182 | } | 248 | } |
| 183 | 249 | ||
| 184 | private void connectStationRoute(List<StationRoute> list) { | 250 | private void connectStationRoute(List<StationRoute> list) { |
| @@ -209,6 +275,7 @@ public class GeoCacheData { | @@ -209,6 +275,7 @@ public class GeoCacheData { | ||
| 209 | 275 | ||
| 210 | /** | 276 | /** |
| 211 | * 是不是终点站 | 277 | * 是不是终点站 |
| 278 | + * | ||
| 212 | * @param lineId | 279 | * @param lineId |
| 213 | * @param upDown | 280 | * @param upDown |
| 214 | * @param stationCode | 281 | * @param stationCode |
src/main/java/com/bsth/data/gpsdata/arrival/GpsRealAnalyse.java
| 1 | package com.bsth.data.gpsdata.arrival; | 1 | package com.bsth.data.gpsdata.arrival; |
| 2 | 2 | ||
| 3 | import com.bsth.data.gpsdata.GpsEntity; | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 4 | +import com.bsth.data.gpsdata.GpsRealData; | ||
| 4 | import com.bsth.data.gpsdata.arrival.handlers.*; | 5 | import com.bsth.data.gpsdata.arrival.handlers.*; |
| 5 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | 6 | import com.bsth.data.gpsdata.arrival.utils.CircleQueue; |
| 6 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
| @@ -32,6 +33,11 @@ public class GpsRealAnalyse { | @@ -32,6 +33,11 @@ public class GpsRealAnalyse { | ||
| 32 | InOutStationSignalHandle inOutStationSignalHandle; | 33 | InOutStationSignalHandle inOutStationSignalHandle; |
| 33 | @Autowired | 34 | @Autowired |
| 34 | ReverseSignalHandle reverseSignalHandle; | 35 | ReverseSignalHandle reverseSignalHandle; |
| 36 | + @Autowired | ||
| 37 | + AbnormalStateHandle abnormalStateHandle; | ||
| 38 | + | ||
| 39 | + @Autowired | ||
| 40 | + GpsRealData gpsRealData; | ||
| 35 | 41 | ||
| 36 | //50个线程 | 42 | //50个线程 |
| 37 | static ExecutorService threadPool = Executors.newFixedThreadPool(50); | 43 | static ExecutorService threadPool = Executors.newFixedThreadPool(50); |
| @@ -45,6 +51,10 @@ public class GpsRealAnalyse { | @@ -45,6 +51,10 @@ public class GpsRealAnalyse { | ||
| 45 | try { | 51 | try { |
| 46 | //等待子线程结束 | 52 | //等待子线程结束 |
| 47 | count.await(); | 53 | count.await(); |
| 54 | + | ||
| 55 | + //加入实时gps对照 | ||
| 56 | + for(GpsEntity gps: list) | ||
| 57 | + gpsRealData.put(gps); | ||
| 48 | } catch (InterruptedException e) { | 58 | } catch (InterruptedException e) { |
| 49 | logger.error("", e); | 59 | logger.error("", e); |
| 50 | } | 60 | } |
| @@ -64,14 +74,21 @@ public class GpsRealAnalyse { | @@ -64,14 +74,21 @@ public class GpsRealAnalyse { | ||
| 64 | public void run() { | 74 | public void run() { |
| 65 | 75 | ||
| 66 | try { | 76 | try { |
| 77 | + //是否有任务 | ||
| 78 | + boolean task; | ||
| 67 | CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm()); | 79 | CircleQueue<GpsEntity> prevs = GeoCacheData.getGps(gps.getNbbm()); |
| 68 | //掉线处理 | 80 | //掉线处理 |
| 69 | offlineSignalHandle.handle(gps, prevs); | 81 | offlineSignalHandle.handle(gps, prevs); |
| 70 | //状态处理 | 82 | //状态处理 |
| 71 | - if(!correctSignalHandle.handle(gps, prevs)) | ||
| 72 | - return; | 83 | + task = correctSignalHandle.handle(gps, prevs); |
| 73 | //场,站内外判断 | 84 | //场,站内外判断 |
| 74 | stationInsideHandle.handle(gps, prevs); | 85 | stationInsideHandle.handle(gps, prevs); |
| 86 | + //异常判定(越界/超速) | ||
| 87 | + abnormalStateHandle.handle(gps, prevs); | ||
| 88 | + | ||
| 89 | + if(!task) | ||
| 90 | + return; //无任务的,到这里就结束 | ||
| 91 | + | ||
| 75 | //反向处理 | 92 | //反向处理 |
| 76 | reverseSignalHandle.handle(gps, prevs); | 93 | reverseSignalHandle.handle(gps, prevs); |
| 77 | //进出站动作处理 | 94 | //进出站动作处理 |
src/main/java/com/bsth/data/gpsdata/arrival/entity/SignalState.java
| @@ -37,8 +37,8 @@ public class SignalState { | @@ -37,8 +37,8 @@ public class SignalState { | ||
| 37 | * @return | 37 | * @return |
| 38 | */ | 38 | */ |
| 39 | public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) { | 39 | public static SignalState reverseSignalSTate(ScheduleRealInfo sch, RouteReverse reverse) { |
| 40 | - if(reverse.isVague()) | ||
| 41 | - return null; | 40 | + /*if(reverse.isVague()) |
| 41 | + return null;*/ | ||
| 42 | 42 | ||
| 43 | SignalState state = new SignalState(); | 43 | SignalState state = new SignalState(); |
| 44 | state.setSchId(sch.getId()); | 44 | state.setSchId(sch.getId()); |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/AbnormalStateHandle.java
0 → 100644
| 1 | +package com.bsth.data.gpsdata.arrival.handlers; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.gpsdata.GpsEntity; | ||
| 4 | +import com.bsth.data.gpsdata.arrival.GeoCacheData; | ||
| 5 | +import com.bsth.data.gpsdata.arrival.SignalHandle; | ||
| 6 | +import com.bsth.data.gpsdata.arrival.utils.CircleQueue; | ||
| 7 | +import com.bsth.data.gpsdata.arrival.utils.GeoUtils; | ||
| 8 | +import com.vividsolutions.jts.geom.Coordinate; | ||
| 9 | +import com.vividsolutions.jts.geom.GeometryFactory; | ||
| 10 | +import com.vividsolutions.jts.geom.LineString; | ||
| 11 | +import com.vividsolutions.jts.geom.Point; | ||
| 12 | +import org.springframework.stereotype.Component; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * GPS异常状态判定 (越界/超速) | ||
| 18 | + * Created by panzhao on 2017/1/10. | ||
| 19 | + */ | ||
| 20 | +@Component | ||
| 21 | +public class AbnormalStateHandle extends SignalHandle{ | ||
| 22 | + | ||
| 23 | + //默认限速 | ||
| 24 | + private static final double DEFAULT_SPEED_LIMIT = 60; | ||
| 25 | + //越界阈值 | ||
| 26 | + private static final double OUT_BOUNDS_THRESHOLD = 100; | ||
| 27 | + | ||
| 28 | + GeometryFactory geometryFactory = new GeometryFactory(); | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { | ||
| 32 | + | ||
| 33 | + if(overspeed(gps)) | ||
| 34 | + return true; | ||
| 35 | + | ||
| 36 | + if(outOfBounds((gps))) | ||
| 37 | + return true; | ||
| 38 | + | ||
| 39 | + return false; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 是否超速 | ||
| 44 | + * @param gps | ||
| 45 | + * @return | ||
| 46 | + */ | ||
| 47 | + public boolean overspeed(GpsEntity gps){ | ||
| 48 | + double maxSpeed = DEFAULT_SPEED_LIMIT; | ||
| 49 | + if(GeoCacheData.speedLimit(gps.getLineId()) != null) | ||
| 50 | + maxSpeed = GeoCacheData.speedLimit(gps.getLineId()); | ||
| 51 | + | ||
| 52 | + if(gps.getSpeed() > maxSpeed){ | ||
| 53 | + gps.setAbnormalStatus("overspeed"); | ||
| 54 | + return true; | ||
| 55 | + } | ||
| 56 | + return false; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 是否越界 | ||
| 61 | + * @param gps | ||
| 62 | + * @return | ||
| 63 | + */ | ||
| 64 | + public boolean outOfBounds(GpsEntity gps){ | ||
| 65 | + //场内的车不处理 | ||
| 66 | + if(gps.getInstation() == 2){ | ||
| 67 | + return false; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + List<LineString> list = GeoCacheData.getLineStringList(gps); | ||
| 71 | + Point point = geometryFactory.createPoint(new Coordinate(gps.getLat(), gps.getLon())); | ||
| 72 | + | ||
| 73 | + double min = -1, distance; | ||
| 74 | + | ||
| 75 | + for(LineString lineString : list){ | ||
| 76 | + distance = GeoUtils.getDistanceFromLine(lineString, point); | ||
| 77 | + | ||
| 78 | + if(min == -1 || min > distance) | ||
| 79 | + min = distance; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + gps.setOutOfBoundDistance(min); | ||
| 83 | + if(min > OUT_BOUNDS_THRESHOLD){ | ||
| 84 | + gps.setAbnormalStatus("outBounds"); | ||
| 85 | + return true; | ||
| 86 | + } | ||
| 87 | + return false; | ||
| 88 | + } | ||
| 89 | +} |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
| @@ -154,6 +154,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -154,6 +154,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 154 | schPrev.setZdsjActualAll(sch.getFcsjActualTime()); | 154 | schPrev.setZdsjActualAll(sch.getFcsjActualTime()); |
| 155 | 155 | ||
| 156 | sendUtils.refreshSch(schPrev); | 156 | sendUtils.refreshSch(schPrev); |
| 157 | + dayOfSchedule.save(schPrev); | ||
| 157 | } | 158 | } |
| 158 | } | 159 | } |
| 159 | } | 160 | } |
| @@ -168,6 +169,10 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -168,6 +169,10 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 168 | 169 | ||
| 169 | if(gps.getStopNo().equals(sch.getZdzCode())){ | 170 | if(gps.getStopNo().equals(sch.getZdzCode())){ |
| 170 | 171 | ||
| 172 | + //进场最多提前1.2小时 | ||
| 173 | + if(sch.getBcType().equals("in") && sch.getZdsjT() - gps.getTimestamp() > MAX_BEFORE_TIME) | ||
| 174 | + return; | ||
| 175 | + | ||
| 171 | //实达时间不覆盖 | 176 | //实达时间不覆盖 |
| 172 | if(StringUtils.isNotEmpty(sch.getZdsjActual())) | 177 | if(StringUtils.isNotEmpty(sch.getZdsjActual())) |
| 173 | return; | 178 | return; |
| @@ -211,6 +216,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -211,6 +216,7 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 211 | next.setZdsjActualAll(sch.getZdsjActualTime()); | 216 | next.setZdsjActualAll(sch.getZdsjActualTime()); |
| 212 | 217 | ||
| 213 | sendUtils.refreshSch(next); | 218 | sendUtils.refreshSch(next); |
| 219 | + dayOfSchedule.save(next); | ||
| 214 | } | 220 | } |
| 215 | } | 221 | } |
| 216 | 222 | ||
| @@ -246,4 +252,4 @@ public class InOutStationSignalHandle extends SignalHandle{ | @@ -246,4 +252,4 @@ public class InOutStationSignalHandle extends SignalHandle{ | ||
| 246 | }*/ | 252 | }*/ |
| 247 | return false; | 253 | return false; |
| 248 | } | 254 | } |
| 249 | -} | 255 | +} |
| 250 | \ No newline at end of file | 256 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata/arrival/handlers/ReverseSignalHandle.java
| @@ -38,7 +38,7 @@ public class ReverseSignalHandle extends SignalHandle { | @@ -38,7 +38,7 @@ public class ReverseSignalHandle extends SignalHandle { | ||
| 38 | if (isReverse(gps, prev)) { | 38 | if (isReverse(gps, prev)) { |
| 39 | RouteReverse reverse = reverseSearch(prevs, gps); | 39 | RouteReverse reverse = reverseSearch(prevs, gps); |
| 40 | 40 | ||
| 41 | - if (reverse.getCount() >= 4 | 41 | + if (reverse.getCount() >= 3 |
| 42 | && reverse.isClose() | 42 | && reverse.isClose() |
| 43 | && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) { | 43 | && !GeoCacheData.isEndStation(gps.getLineId(), gps.getUpDown(), reverse.getTurned())) { |
| 44 | scheduleSignalState.reverseAnalyse(reverse); | 44 | scheduleSignalState.reverseAnalyse(reverse); |
src/main/java/com/bsth/data/gpsdata/arrival/utils/GeoUtils.java
| @@ -3,10 +3,7 @@ package com.bsth.data.gpsdata.arrival.utils; | @@ -3,10 +3,7 @@ package com.bsth.data.gpsdata.arrival.utils; | ||
| 3 | import com.bsth.data.gpsdata.GpsEntity; | 3 | import com.bsth.data.gpsdata.GpsEntity; |
| 4 | import com.bsth.data.gpsdata.arrival.GeoCacheData; | 4 | import com.bsth.data.gpsdata.arrival.GeoCacheData; |
| 5 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; | 5 | import com.bsth.data.gpsdata.arrival.entity.StationRoute; |
| 6 | -import com.vividsolutions.jts.geom.Coordinate; | ||
| 7 | -import com.vividsolutions.jts.geom.GeometryFactory; | ||
| 8 | -import com.vividsolutions.jts.geom.Point; | ||
| 9 | -import com.vividsolutions.jts.geom.Polygon; | 6 | +import com.vividsolutions.jts.geom.*; |
| 10 | 7 | ||
| 11 | import java.util.List; | 8 | import java.util.List; |
| 12 | import java.util.Map; | 9 | import java.util.Map; |
| @@ -90,6 +87,36 @@ public class GeoUtils { | @@ -90,6 +87,36 @@ public class GeoUtils { | ||
| 90 | return Math.PI * degree / 180; | 87 | return Math.PI * degree / 180; |
| 91 | } | 88 | } |
| 92 | 89 | ||
| 90 | + /** | ||
| 91 | + * 计算点 到 线的距离 | ||
| 92 | + * @param line | ||
| 93 | + * @param p | ||
| 94 | + * @return | ||
| 95 | + */ | ||
| 96 | + public static double getDistanceFromLine(LineString line, Point p){ | ||
| 97 | + Point s = line.getStartPoint(); | ||
| 98 | + Point e = line.getEndPoint(); | ||
| 99 | + | ||
| 100 | + double d1 = getDistance(s, p); | ||
| 101 | + double d2 = getDistance(p, e); | ||
| 102 | + double d3 = getDistance(s, e); | ||
| 103 | + double distance = 0; | ||
| 104 | + | ||
| 105 | + double alpha = Math.acos((d1*d1 + d3*d3 - d2*d2)/(2*d1*d3)); | ||
| 106 | + double beta = Math.acos((d2*d2 + d3*d3 - d1*d1)/(2*d2*d3)); | ||
| 107 | + | ||
| 108 | + if(alpha>Math.PI/2) { | ||
| 109 | + distance = d1; | ||
| 110 | + } | ||
| 111 | + else if(beta > Math.PI/2) { | ||
| 112 | + distance = d2; | ||
| 113 | + } | ||
| 114 | + else { | ||
| 115 | + distance = Math.sin(alpha) * d1; | ||
| 116 | + } | ||
| 117 | + return distance; | ||
| 118 | + } | ||
| 119 | + | ||
| 93 | 120 | ||
| 94 | /** | 121 | /** |
| 95 | * gps 是否在某个停车场内 | 122 | * gps 是否在某个停车场内 |
src/main/java/com/bsth/data/gpsdata/arrival/utils/ScheduleSignalState.java
| @@ -100,7 +100,8 @@ public class ScheduleSignalState { | @@ -100,7 +100,8 @@ public class ScheduleSignalState { | ||
| 100 | 100 | ||
| 101 | //记录信号状态 | 101 | //记录信号状态 |
| 102 | SignalState signalState = SignalState.reverseSignalSTate(sch, reverse); | 102 | SignalState signalState = SignalState.reverseSignalSTate(sch, reverse); |
| 103 | - signalStateData.put(signalState); | 103 | + if(signalState != null) |
| 104 | + signalStateData.put(signalState); | ||
| 104 | } | 105 | } |
| 105 | } | 106 | } |
| 106 | 107 | ||
| @@ -248,4 +249,4 @@ public class ScheduleSignalState { | @@ -248,4 +249,4 @@ public class ScheduleSignalState { | ||
| 248 | SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal); | 249 | SignalState signalState = SignalState.abnormalSignalSTate(sch, signalAbnormal); |
| 249 | signalStateData.put(signalState); | 250 | signalStateData.put(signalState); |
| 250 | } | 251 | } |
| 251 | -} | 252 | +} |
| 252 | \ No newline at end of file | 253 | \ No newline at end of file |
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
| @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware { | ||
| 60 | for (String nbbm : keys) { | 60 | for (String nbbm : keys) { |
| 61 | Collections.sort(listMap.get(nbbm), comp); | 61 | Collections.sort(listMap.get(nbbm), comp); |
| 62 | threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); | 62 | threadPool.execute(new RecoveryThread(listMap.get(nbbm), count)); |
| 63 | - /*if(nbbm.equals("YT-CD008")) | 63 | + /*if(nbbm.equals("W9H-003")) |
| 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ | 64 | new RecoveryThread(listMap.get(nbbm), count).run();*/ |
| 65 | } | 65 | } |
| 66 | 66 |
src/main/java/com/bsth/data/pilot80/PilotReport.java
| @@ -77,20 +77,14 @@ public class PilotReport { | @@ -77,20 +77,14 @@ public class PilotReport { | ||
| 77 | ScheduleRealInfo outSch = dayOfSchedule.nextByBcType(nbbm, "out"); | 77 | ScheduleRealInfo outSch = dayOfSchedule.nextByBcType(nbbm, "out"); |
| 78 | //如果有对应出场班次 | 78 | //如果有对应出场班次 |
| 79 | if(outSch != null){ | 79 | if(outSch != null){ |
| 80 | - | ||
| 81 | //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 | 80 | //没有计划里程的出场班次,出场既是首发站,发送下一班次的营运指令 |
| 82 | if(outSch.getJhlc() == null) | 81 | if(outSch.getJhlc() == null) |
| 83 | outSch = dayOfSchedule.next(outSch); | 82 | outSch = dayOfSchedule.next(outSch); |
| 84 | 83 | ||
| 85 | //下发调度指令 | 84 | //下发调度指令 |
| 86 | directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); | 85 | directiveService.send60Dispatch(outSch, dayOfSchedule.doneSum(nbbm), "请出@系统"); |
| 87 | -/* d80.setRemarks("计划出场时间:" + outSch.getDfsj()); | ||
| 88 | - //当前GPS位置 | ||
| 89 | - GpsEntity gps = gpsRealData.get(d80.getDeviceId()); | ||
| 90 | - if(null != gps) | ||
| 91 | - d80.addRemarks("<br> 位置:" + coordHtmlStr(gps));*/ | ||
| 92 | - | ||
| 93 | - //sendUtils.refreshSch(outSch); | 86 | + //下发线路切换指令 |
| 87 | + directiveService.lineChange(outSch.getClZbh(), outSch.getXlBm(), "请出@系统"); | ||
| 94 | }else | 88 | }else |
| 95 | d80.setRemarks("没有出场计划"); | 89 | d80.setRemarks("没有出场计划"); |
| 96 | 90 |
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
| @@ -2,6 +2,8 @@ package com.bsth.data.schedule; | @@ -2,6 +2,8 @@ package com.bsth.data.schedule; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONArray; | 4 | import com.alibaba.fastjson.JSONArray; |
| 5 | +import com.bsth.Application; | ||
| 6 | +import com.bsth.data.BasicData; | ||
| 5 | import com.bsth.data.LineConfigData; | 7 | import com.bsth.data.LineConfigData; |
| 6 | import com.bsth.data.directive.FirstScheduleCheckThread; | 8 | import com.bsth.data.directive.FirstScheduleCheckThread; |
| 7 | import com.bsth.data.gpsdata.GpsRealData; | 9 | import com.bsth.data.gpsdata.GpsRealData; |
| @@ -33,6 +35,7 @@ import org.springframework.stereotype.Component; | @@ -33,6 +35,7 @@ import org.springframework.stereotype.Component; | ||
| 33 | import java.text.ParseException; | 35 | import java.text.ParseException; |
| 34 | import java.text.SimpleDateFormat; | 36 | import java.text.SimpleDateFormat; |
| 35 | import java.util.*; | 37 | import java.util.*; |
| 38 | +import java.util.concurrent.TimeUnit; | ||
| 36 | 39 | ||
| 37 | /** | 40 | /** |
| 38 | * @author PanZhao | 41 | * @author PanZhao |
| @@ -82,6 +85,9 @@ public class DayOfSchedule implements CommandLineRunner { | @@ -82,6 +85,9 @@ public class DayOfSchedule implements CommandLineRunner { | ||
| 82 | @Autowired | 85 | @Autowired |
| 83 | GpsRealData gpsRealData; | 86 | GpsRealData gpsRealData; |
| 84 | 87 | ||
| 88 | + @Autowired | ||
| 89 | + BasicData.BasicDataLoader basicDataLoader; | ||
| 90 | + | ||
| 85 | /** | 91 | /** |
| 86 | * 线路当前使用的排班的日期 | 92 | * 线路当前使用的排班的日期 |
| 87 | */ | 93 | */ |
| @@ -122,11 +128,12 @@ public class DayOfSchedule implements CommandLineRunner { | @@ -122,11 +128,12 @@ public class DayOfSchedule implements CommandLineRunner { | ||
| 122 | 128 | ||
| 123 | @Override | 129 | @Override |
| 124 | public void run(String... arg0) throws Exception { | 130 | public void run(String... arg0) throws Exception { |
| 131 | + basicDataLoader.loadAllData(); | ||
| 125 | //从数据库恢复排班 | 132 | //从数据库恢复排班 |
| 126 | //dataRecovery(); | 133 | //dataRecovery(); |
| 127 | 134 | ||
| 128 | //翻班线程 | 135 | //翻班线程 |
| 129 | -// Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); | 136 | + Application.mainServices.scheduleWithFixedDelay(scheduleRefreshThread, 15, 240, TimeUnit.SECONDS); |
| 130 | //入库 | 137 | //入库 |
| 131 | // Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); | 138 | // Application.mainServices.scheduleWithFixedDelay(schedulePstThread, 60, 60, TimeUnit.SECONDS); |
| 132 | //首班出场指令补发器 | 139 | //首班出场指令补发器 |
| @@ -556,8 +563,12 @@ public class DayOfSchedule implements CommandLineRunner { | @@ -556,8 +563,12 @@ public class DayOfSchedule implements CommandLineRunner { | ||
| 556 | */ | 563 | */ |
| 557 | public boolean isFirstOut(ScheduleRealInfo sch){ | 564 | public boolean isFirstOut(ScheduleRealInfo sch){ |
| 558 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); | 565 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh()); |
| 559 | - if(list.get(0).equals(sch) && sch.getBcType().equals("out")) | ||
| 560 | - return true; | 566 | + try { |
| 567 | + if(list.get(0) == sch && sch.getBcType().equals("out")) | ||
| 568 | + return true; | ||
| 569 | + } catch (IndexOutOfBoundsException e) { | ||
| 570 | + logger.error("小小的数组越界,无伤大雅!"); | ||
| 571 | + } | ||
| 561 | return false; | 572 | return false; |
| 562 | } | 573 | } |
| 563 | 574 |
src/main/java/com/bsth/entity/CarPark.java
| 1 | package com.bsth.entity; | 1 | package com.bsth.entity; |
| 2 | 2 | ||
| 3 | -import java.util.Date; | 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 4 | ||
| 5 | -import javax.persistence.Column; | ||
| 6 | -import javax.persistence.Entity; | ||
| 7 | -import javax.persistence.GeneratedValue; | ||
| 8 | -import javax.persistence.Id; | ||
| 9 | -import javax.persistence.Table; | 5 | +import javax.persistence.*; |
| 6 | +import java.util.Date; | ||
| 10 | 7 | ||
| 11 | 8 | ||
| 12 | /** | 9 | /** |
| @@ -25,6 +22,7 @@ import javax.persistence.Table; | @@ -25,6 +22,7 @@ import javax.persistence.Table; | ||
| 25 | 22 | ||
| 26 | @Entity | 23 | @Entity |
| 27 | @Table(name = "bsth_c_car_park") | 24 | @Table(name = "bsth_c_car_park") |
| 25 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) | ||
| 28 | public class CarPark { | 26 | public class CarPark { |
| 29 | 27 | ||
| 30 | @Id | 28 | @Id |
src/main/java/com/bsth/entity/Cars.java
| @@ -23,7 +23,7 @@ import java.util.Date; | @@ -23,7 +23,7 @@ import java.util.Date; | ||
| 23 | 23 | ||
| 24 | @Entity | 24 | @Entity |
| 25 | @Table(name = "bsth_c_cars") | 25 | @Table(name = "bsth_c_cars") |
| 26 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 26 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 27 | public class Cars extends BEntity implements Serializable { | 27 | public class Cars extends BEntity implements Serializable { |
| 28 | 28 | ||
| 29 | /** 主键Id */ | 29 | /** 主键Id */ |
src/main/java/com/bsth/entity/Line.java
| @@ -24,7 +24,7 @@ import java.util.Date; | @@ -24,7 +24,7 @@ import java.util.Date; | ||
| 24 | 24 | ||
| 25 | @Entity | 25 | @Entity |
| 26 | @Table(name = "bsth_c_line") | 26 | @Table(name = "bsth_c_line") |
| 27 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 27 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 28 | public class Line implements Serializable { | 28 | public class Line implements Serializable { |
| 29 | 29 | ||
| 30 | @Id | 30 | @Id |
src/main/java/com/bsth/entity/Personnel.java
| @@ -21,7 +21,7 @@ import javax.persistence.*; | @@ -21,7 +21,7 @@ import javax.persistence.*; | ||
| 21 | 21 | ||
| 22 | @Entity | 22 | @Entity |
| 23 | @Table(name = "bsth_c_personnel") | 23 | @Table(name = "bsth_c_personnel") |
| 24 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 24 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 25 | public class Personnel extends BEntity { | 25 | public class Personnel extends BEntity { |
| 26 | 26 | ||
| 27 | /** 主键Id */ | 27 | /** 主键Id */ |
src/main/java/com/bsth/entity/Station.java
| 1 | package com.bsth.entity; | 1 | package com.bsth.entity; |
| 2 | 2 | ||
| 3 | -import java.util.Date; | 3 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 4 | 4 | ||
| 5 | import javax.persistence.Column; | 5 | import javax.persistence.Column; |
| 6 | import javax.persistence.Entity; | 6 | import javax.persistence.Entity; |
| 7 | -import javax.persistence.GeneratedValue; | ||
| 8 | -import javax.persistence.GenerationType; | ||
| 9 | import javax.persistence.Id; | 7 | import javax.persistence.Id; |
| 10 | import javax.persistence.Table; | 8 | import javax.persistence.Table; |
| 9 | +import java.util.Date; | ||
| 11 | 10 | ||
| 12 | 11 | ||
| 13 | /** | 12 | /** |
| @@ -26,6 +25,7 @@ import javax.persistence.Table; | @@ -26,6 +25,7 @@ import javax.persistence.Table; | ||
| 26 | 25 | ||
| 27 | @Entity | 26 | @Entity |
| 28 | @Table(name = "bsth_c_station") | 27 | @Table(name = "bsth_c_station") |
| 28 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) | ||
| 29 | public class Station { | 29 | public class Station { |
| 30 | 30 | ||
| 31 | @Id | 31 | @Id |
src/main/java/com/bsth/entity/realcontrol/SvgAttribute.java
0 → 100644
| 1 | +package com.bsth.entity.realcontrol; | ||
| 2 | + | ||
| 3 | +import javax.persistence.Entity; | ||
| 4 | +import javax.persistence.Id; | ||
| 5 | +import javax.persistence.Table; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 主页SVG模拟图属性设置 | ||
| 9 | + * Created by panzhao on 2017/1/6. | ||
| 10 | + */ | ||
| 11 | +@Entity | ||
| 12 | +@Table(name = "bsth_c_svg_attr") | ||
| 13 | +public class SvgAttribute { | ||
| 14 | + | ||
| 15 | + @Id | ||
| 16 | + private String lineCode; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 要隐藏的站点编码 , 号分割多个 | ||
| 20 | + */ | ||
| 21 | + private String hideStations; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 站点别名 json对象字符串 | ||
| 25 | + */ | ||
| 26 | + private String nicknames; | ||
| 27 | + | ||
| 28 | + public String getLineCode() { | ||
| 29 | + return lineCode; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void setLineCode(String lineCode) { | ||
| 33 | + this.lineCode = lineCode; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public String getHideStations() { | ||
| 37 | + return hideStations; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public void setHideStations(String hideStations) { | ||
| 41 | + this.hideStations = hideStations; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public String getNicknames() { | ||
| 45 | + return nicknames; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public void setNicknames(String nicknames) { | ||
| 49 | + this.nicknames = nicknames; | ||
| 50 | + } | ||
| 51 | +} |
src/main/java/com/bsth/entity/schedule/CarConfigInfo.java
| @@ -19,7 +19,7 @@ import java.util.Date; | @@ -19,7 +19,7 @@ import java.util.Date; | ||
| 19 | @NamedAttributeNode("cl") | 19 | @NamedAttributeNode("cl") |
| 20 | }) | 20 | }) |
| 21 | }) | 21 | }) |
| 22 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 22 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 23 | public class CarConfigInfo extends BEntity implements Serializable { | 23 | public class CarConfigInfo extends BEntity implements Serializable { |
| 24 | 24 | ||
| 25 | /** 主健Id */ | 25 | /** 主健Id */ |
src/main/java/com/bsth/entity/schedule/EmployeeConfigInfo.java
| @@ -22,7 +22,7 @@ import java.io.Serializable; | @@ -22,7 +22,7 @@ import java.io.Serializable; | ||
| 22 | @NamedAttributeNode("xl") | 22 | @NamedAttributeNode("xl") |
| 23 | }) | 23 | }) |
| 24 | }) | 24 | }) |
| 25 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 25 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 26 | public class EmployeeConfigInfo extends BEntity implements Serializable { | 26 | public class EmployeeConfigInfo extends BEntity implements Serializable { |
| 27 | 27 | ||
| 28 | /** 主键Id */ | 28 | /** 主键Id */ |
src/main/java/com/bsth/entity/schedule/GuideboardInfo.java
| @@ -15,7 +15,7 @@ import javax.persistence.*; | @@ -15,7 +15,7 @@ import javax.persistence.*; | ||
| 15 | @NamedAttributeNode("xl") | 15 | @NamedAttributeNode("xl") |
| 16 | }) | 16 | }) |
| 17 | }) | 17 | }) |
| 18 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 18 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) |
| 19 | public class GuideboardInfo extends BEntity { | 19 | public class GuideboardInfo extends BEntity { |
| 20 | 20 | ||
| 21 | /** 主键Id */ | 21 | /** 主键Id */ |
src/main/java/com/bsth/entity/schedule/TTInfo.java
| 1 | package com.bsth.entity.schedule; | 1 | package com.bsth.entity.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.Line; | 3 | import com.bsth.entity.Line; |
| 4 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| 4 | 5 | ||
| 5 | import javax.persistence.*; | 6 | import javax.persistence.*; |
| 6 | import java.util.Date; | 7 | import java.util.Date; |
| @@ -17,6 +18,7 @@ import java.util.Date; | @@ -17,6 +18,7 @@ import java.util.Date; | ||
| 17 | @NamedAttributeNode("updateBy") | 18 | @NamedAttributeNode("updateBy") |
| 18 | }) | 19 | }) |
| 19 | }) | 20 | }) |
| 21 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) | ||
| 20 | public class TTInfo extends BEntity { | 22 | public class TTInfo extends BEntity { |
| 21 | 23 | ||
| 22 | /** 主键Id */ | 24 | /** 主键Id */ |
src/main/java/com/bsth/entity/schedule/TTInfoDetail.java
| @@ -3,6 +3,7 @@ package com.bsth.entity.schedule; | @@ -3,6 +3,7 @@ package com.bsth.entity.schedule; | ||
| 3 | import com.bsth.entity.CarPark; | 3 | import com.bsth.entity.CarPark; |
| 4 | import com.bsth.entity.Line; | 4 | import com.bsth.entity.Line; |
| 5 | import com.bsth.entity.Station; | 5 | import com.bsth.entity.Station; |
| 6 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| 6 | 7 | ||
| 7 | import javax.persistence.*; | 8 | import javax.persistence.*; |
| 8 | 9 | ||
| @@ -21,6 +22,7 @@ import javax.persistence.*; | @@ -21,6 +22,7 @@ import javax.persistence.*; | ||
| 21 | @NamedAttributeNode("tcc") | 22 | @NamedAttributeNode("tcc") |
| 22 | }) | 23 | }) |
| 23 | }) | 24 | }) |
| 25 | +@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"}) | ||
| 24 | public class TTInfoDetail extends BEntity { | 26 | public class TTInfoDetail extends BEntity { |
| 25 | 27 | ||
| 26 | /** 主健Id */ | 28 | /** 主健Id */ |
src/main/java/com/bsth/entity/schedule/rule/ScheduleRule1Flat.java
| 1 | package com.bsth.entity.schedule.rule; | 1 | package com.bsth.entity.schedule.rule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.Line; | 3 | import com.bsth.entity.Line; |
| 4 | +import com.bsth.entity.schedule.BEntity; | ||
| 4 | import com.bsth.entity.schedule.CarConfigInfo; | 5 | import com.bsth.entity.schedule.CarConfigInfo; |
| 5 | -import com.bsth.entity.sys.SysUser; | ||
| 6 | 6 | ||
| 7 | import javax.persistence.*; | 7 | import javax.persistence.*; |
| 8 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| @@ -35,7 +35,7 @@ import java.util.Date; | @@ -35,7 +35,7 @@ import java.util.Date; | ||
| 35 | 35 | ||
| 36 | ) | 36 | ) |
| 37 | }) | 37 | }) |
| 38 | -public class ScheduleRule1Flat { | 38 | +public class ScheduleRule1Flat extends BEntity { |
| 39 | /** 主键Id */ | 39 | /** 主键Id */ |
| 40 | @Id | 40 | @Id |
| 41 | @GeneratedValue | 41 | @GeneratedValue |
| @@ -74,19 +74,6 @@ public class ScheduleRule1Flat { | @@ -74,19 +74,6 @@ public class ScheduleRule1Flat { | ||
| 74 | /** 翻班格式(TODO:这个用在车子上的,暂时不管)*/ | 74 | /** 翻班格式(TODO:这个用在车子上的,暂时不管)*/ |
| 75 | private String fbgs; | 75 | private String fbgs; |
| 76 | 76 | ||
| 77 | - /** 创建人 */ | ||
| 78 | - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | ||
| 79 | - private SysUser createBy; | ||
| 80 | - /** 修改人 */ | ||
| 81 | - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY) | ||
| 82 | - private SysUser updateBy; | ||
| 83 | - /** 创建日期 */ | ||
| 84 | - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | ||
| 85 | - private Date createDate; | ||
| 86 | - /** 修改日期 */ | ||
| 87 | - @Column(name = "update_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") | ||
| 88 | - private Date updateDate; | ||
| 89 | - | ||
| 90 | public Long getId() { | 77 | public Long getId() { |
| 91 | return id; | 78 | return id; |
| 92 | } | 79 | } |
| @@ -175,35 +162,4 @@ public class ScheduleRule1Flat { | @@ -175,35 +162,4 @@ public class ScheduleRule1Flat { | ||
| 175 | this.fbgs = fbgs; | 162 | this.fbgs = fbgs; |
| 176 | } | 163 | } |
| 177 | 164 | ||
| 178 | - public SysUser getCreateBy() { | ||
| 179 | - return createBy; | ||
| 180 | - } | ||
| 181 | - | ||
| 182 | - public void setCreateBy(SysUser createBy) { | ||
| 183 | - this.createBy = createBy; | ||
| 184 | - } | ||
| 185 | - | ||
| 186 | - public SysUser getUpdateBy() { | ||
| 187 | - return updateBy; | ||
| 188 | - } | ||
| 189 | - | ||
| 190 | - public void setUpdateBy(SysUser updateBy) { | ||
| 191 | - this.updateBy = updateBy; | ||
| 192 | - } | ||
| 193 | - | ||
| 194 | - public Date getCreateDate() { | ||
| 195 | - return createDate; | ||
| 196 | - } | ||
| 197 | - | ||
| 198 | - public void setCreateDate(Date createDate) { | ||
| 199 | - this.createDate = createDate; | ||
| 200 | - } | ||
| 201 | - | ||
| 202 | - public Date getUpdateDate() { | ||
| 203 | - return updateDate; | ||
| 204 | - } | ||
| 205 | - | ||
| 206 | - public void setUpdateDate(Date updateDate) { | ||
| 207 | - this.updateDate = updateDate; | ||
| 208 | - } | ||
| 209 | } | 165 | } |
src/main/java/com/bsth/entity/sys/DutyEmployee.java
0 → 100644
| 1 | +package com.bsth.entity.sys; | ||
| 2 | + | ||
| 3 | +import javax.persistence.*; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 当班调度员 | ||
| 7 | + * Created by panzhao on 2017/1/5. | ||
| 8 | + */ | ||
| 9 | +@Entity | ||
| 10 | +@Table(name = "bsth_c_sys_duty_employee") | ||
| 11 | +public class DutyEmployee { | ||
| 12 | + | ||
| 13 | + @Id | ||
| 14 | + @GeneratedValue | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 员工ID | ||
| 19 | + */ | ||
| 20 | + private Integer uId; | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 员工姓名 | ||
| 24 | + */ | ||
| 25 | + private String uName; | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 线路编码 ,号分割多个 | ||
| 29 | + */ | ||
| 30 | + private String codeIdx; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 登入线调时间 | ||
| 34 | + */ | ||
| 35 | + private Long ts; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 是否主调模式进入 | ||
| 39 | + */ | ||
| 40 | + private boolean main; | ||
| 41 | + | ||
| 42 | + public Integer getuId() { | ||
| 43 | + return uId; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setuId(Integer uId) { | ||
| 47 | + this.uId = uId; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public String getuName() { | ||
| 51 | + return uName; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setuName(String uName) { | ||
| 55 | + this.uName = uName; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String getCodeIdx() { | ||
| 59 | + return codeIdx; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setCodeIdx(String codeIdx) { | ||
| 63 | + this.codeIdx = codeIdx; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public Long getTs() { | ||
| 67 | + return ts; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public void setTs(Long ts) { | ||
| 71 | + this.ts = ts; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public boolean isMain() { | ||
| 75 | + return main; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public void setMain(boolean main) { | ||
| 79 | + this.main = main; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public Long getId() { | ||
| 83 | + return id; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public void setId(Long id) { | ||
| 87 | + this.id = id; | ||
| 88 | + } | ||
| 89 | +} |
src/main/java/com/bsth/entity/sys/SessionLog.java deleted
100644 → 0
| 1 | -package com.bsth.entity.sys; | ||
| 2 | - | ||
| 3 | -import java.util.Date; | ||
| 4 | - | ||
| 5 | -import javax.persistence.Column; | ||
| 6 | -import javax.persistence.Entity; | ||
| 7 | -import javax.persistence.GeneratedValue; | ||
| 8 | -import javax.persistence.GenerationType; | ||
| 9 | -import javax.persistence.Id; | ||
| 10 | -import javax.persistence.ManyToOne; | ||
| 11 | -import javax.persistence.Table; | ||
| 12 | - | ||
| 13 | -/** | ||
| 14 | - * | ||
| 15 | - * @ClassName: SessionLog | ||
| 16 | - * @Description: TODO(session日志) | ||
| 17 | - * @author PanZhao | ||
| 18 | - * @date 2016年7月20日 下午4:46:27 | ||
| 19 | - * | ||
| 20 | - */ | ||
| 21 | -@Entity | ||
| 22 | -@Table(name = "bsth_c_sys_sessionlog") | ||
| 23 | -public class SessionLog { | ||
| 24 | - | ||
| 25 | - @Id | ||
| 26 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 27 | - private Integer id; | ||
| 28 | - | ||
| 29 | - @ManyToOne | ||
| 30 | - private SysUser user; | ||
| 31 | - | ||
| 32 | - /** 登录时间 */ | ||
| 33 | - private Date loginDate; | ||
| 34 | - | ||
| 35 | - @Column(updatable = false, name = "create_date", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | ||
| 36 | - private Date createDate; | ||
| 37 | - | ||
| 38 | - /** 登出时间 */ | ||
| 39 | - private Date logoutDate; | ||
| 40 | - | ||
| 41 | - /** 登出方式 0:主动登出, -1:其他 */ | ||
| 42 | - private int logoutType; | ||
| 43 | - | ||
| 44 | - /** 登录IP */ | ||
| 45 | - private String ip; | ||
| 46 | - | ||
| 47 | - public Integer getId() { | ||
| 48 | - return id; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - public void setId(Integer id) { | ||
| 52 | - this.id = id; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - public SysUser getUser() { | ||
| 56 | - return user; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - public void setUser(SysUser user) { | ||
| 60 | - this.user = user; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - public Date getLoginDate() { | ||
| 64 | - return loginDate; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - public void setLoginDate(Date loginDate) { | ||
| 68 | - this.loginDate = loginDate; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - public Date getCreateDate() { | ||
| 72 | - return createDate; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - public void setCreateDate(Date createDate) { | ||
| 76 | - this.createDate = createDate; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - public Date getLogoutDate() { | ||
| 80 | - return logoutDate; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - public void setLogoutDate(Date logoutDate) { | ||
| 84 | - this.logoutDate = logoutDate; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - public int getLogoutType() { | ||
| 88 | - return logoutType; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - public void setLogoutType(int logoutType) { | ||
| 92 | - this.logoutType = logoutType; | ||
| 93 | - } | ||
| 94 | - | ||
| 95 | - public String getIp() { | ||
| 96 | - return ip; | ||
| 97 | - } | ||
| 98 | - | ||
| 99 | - public void setIp(String ip) { | ||
| 100 | - this.ip = ip; | ||
| 101 | - } | ||
| 102 | -} |
src/main/java/com/bsth/entity/sys/SignControl.java deleted
100644 → 0
| 1 | -package com.bsth.entity.sys; | ||
| 2 | - | ||
| 3 | -import java.util.Date; | ||
| 4 | - | ||
| 5 | -import javax.persistence.Entity; | ||
| 6 | -import javax.persistence.GeneratedValue; | ||
| 7 | -import javax.persistence.GenerationType; | ||
| 8 | -import javax.persistence.Id; | ||
| 9 | -import javax.persistence.ManyToOne; | ||
| 10 | -import javax.persistence.Table; | ||
| 11 | - | ||
| 12 | -/** | ||
| 13 | - * | ||
| 14 | - * @ClassName: SignControl | ||
| 15 | - * @Description: TODO(进出线调记录) | ||
| 16 | - * @author PanZhao | ||
| 17 | - * @date 2016年7月20日 下午4:50:50 | ||
| 18 | - * | ||
| 19 | - */ | ||
| 20 | -@Entity | ||
| 21 | -@Table(name = "bsth_c_sys_sign") | ||
| 22 | -public class SignControl { | ||
| 23 | - | ||
| 24 | - @Id | ||
| 25 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| 26 | - private Integer id; | ||
| 27 | - | ||
| 28 | - @ManyToOne | ||
| 29 | - private SessionLog session; | ||
| 30 | - | ||
| 31 | - /** 登出线调时间 */ | ||
| 32 | - private Date outDate; | ||
| 33 | - | ||
| 34 | - /** 在线时长 */ | ||
| 35 | - private Long onLineTimel; | ||
| 36 | - | ||
| 37 | - /** 0: 主调模式, 1:监控模式 */ | ||
| 38 | - private int signType; | ||
| 39 | - | ||
| 40 | - /** 用户名 */ | ||
| 41 | - private String userName; | ||
| 42 | - | ||
| 43 | - public Integer getId() { | ||
| 44 | - return id; | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - public void setId(Integer id) { | ||
| 48 | - this.id = id; | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - public SessionLog getSession() { | ||
| 52 | - return session; | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - public void setSession(SessionLog session) { | ||
| 56 | - this.session = session; | ||
| 57 | - } | ||
| 58 | - | ||
| 59 | - public Date getOutDate() { | ||
| 60 | - return outDate; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - public void setOutDate(Date outDate) { | ||
| 64 | - this.outDate = outDate; | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - public Long getOnLineTimel() { | ||
| 68 | - return onLineTimel; | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - public void setOnLineTimel(Long onLineTimel) { | ||
| 72 | - this.onLineTimel = onLineTimel; | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - public int getSignType() { | ||
| 76 | - return signType; | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - public void setSignType(int signType) { | ||
| 80 | - this.signType = signType; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - public String getUserName() { | ||
| 84 | - return userName; | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - public void setUserName(String userName) { | ||
| 88 | - this.userName = userName; | ||
| 89 | - } | ||
| 90 | -} |
src/main/java/com/bsth/entity/sys/SysUser.java
| @@ -9,7 +9,8 @@ import java.util.Set; | @@ -9,7 +9,8 @@ import java.util.Set; | ||
| 9 | 9 | ||
| 10 | @Entity | 10 | @Entity |
| 11 | @Table(name = "bsth_c_sys_user") | 11 | @Table(name = "bsth_c_sys_user") |
| 12 | -@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) | 12 | +//@JsonIgnoreProperties(value={"hibernateLazyInitializer","handlers","fieldHandler"}) |
| 13 | +@JsonIgnoreProperties(ignoreUnknown = true) | ||
| 13 | public class SysUser { | 14 | public class SysUser { |
| 14 | 15 | ||
| 15 | @Id | 16 | @Id |
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
| @@ -18,13 +18,16 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -18,13 +18,16 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 18 | List<ScheduleRealInfo> findByLines(List<String> lines); | 18 | List<ScheduleRealInfo> findByLines(List<String> lines); |
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and bc_type not in ('in','out') order by (lpName+1),clZbh,realExecDate,fcsj") | ||
| 22 | + List<ScheduleRealInfo> scheduleDailyQp(String line,String date); | ||
| 23 | + | ||
| 21 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") | 24 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.id,s.jGh,s.clZbh,s.lpName order by (lpName+1)") |
| 22 | List<ScheduleRealInfo> queryUserInfo(String line,String date); | 25 | List<ScheduleRealInfo> queryUserInfo(String line,String date); |
| 23 | 26 | ||
| 24 | @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)") | 27 | @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)") |
| 25 | List<ScheduleRealInfo> queryUserInfo2(String line,String date); | 28 | List<ScheduleRealInfo> queryUserInfo2(String line,String date); |
| 26 | 29 | ||
| 27 | - @Query(value="select min(s.id), s.jGh,s.clZbh,s.lpName,s.jName from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.jGh,s.clZbh,s.lpName ,s.jName order by (lpName+1)") | 30 | + @Query(value="select min(s.id), s.clZbh from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY s.clZbh ") |
| 28 | List<ScheduleRealInfo> queryUserInfo3(String line,String date); | 31 | List<ScheduleRealInfo> queryUserInfo3(String line,String date); |
| 29 | 32 | ||
| 30 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") | 33 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by bcs") |
| @@ -71,7 +74,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -71,7 +74,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 71 | @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") | 74 | @Query(value="select count(jName) from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and sflj != 0") |
| 72 | int findLjbc(String jName,String clZbh,String lpName); | 75 | int findLjbc(String jName,String clZbh,String lpName); |
| 73 | 76 | ||
| 74 | - @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T') FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true) | 77 | + @Query(value="SELECT c.company,r.request_code,FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d %T'),c.inside_code FROM bsth_v_report_80 r LEFT JOIN bsth_c_cars c ON c.equipment_code = r.device_id where FROM_UNIXTIME(r.timestamp/1000,'%Y-%m-%d') = ?2 and r.line_id = ?1 and c.inside_code = ?3",nativeQuery=true) |
| 75 | List<Object[]> account(String line,String date,String code); | 78 | List<Object[]> account(String line,String date,String code); |
| 76 | 79 | ||
| 77 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') " | 80 | @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and s.scheduleDate >= str_to_date(?2,'%Y-%m-%d') " |
| @@ -79,13 +82,13 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -79,13 +82,13 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 79 | + " and clZbh like %?5% order by s.fcsj") | 82 | + " and clZbh like %?5% order by s.fcsj") |
| 80 | List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); | 83 | List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); |
| 81 | 84 | ||
| 82 | - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') order by bcs") | ||
| 83 | - List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date); | 85 | + @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsjActual") |
| 86 | + List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); | ||
| 84 | 87 | ||
| 85 | - @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and bcType='normal' order by bcs") | ||
| 86 | - List<ScheduleRealInfo> queryListWaybill2(String jName,String clZbh,String lpName,String date); | 88 | + @Query(value="select s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,fcsjActual") |
| 89 | + List<ScheduleRealInfo> queryListWaybill2(String clZbh,String date,String line); | ||
| 87 | 90 | ||
| 88 | - @Query(value="select s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') order by bcs") | 91 | + @Query(value="select s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') order by realExecDate,fcsjActual") |
| 89 | List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date); | 92 | List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date); |
| 90 | 93 | ||
| 91 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between str_to_date(?3,'%Y-%m-%d') and str_to_date(?4,'%Y-%m-%d') order by bcs") | 94 | @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between str_to_date(?3,'%Y-%m-%d') and str_to_date(?4,'%Y-%m-%d') order by bcs") |
| @@ -110,7 +113,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | @@ -110,7 +113,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository<ScheduleRealI | ||
| 110 | @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2") | 113 | @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2") |
| 111 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); | 114 | List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); |
| 112 | 115 | ||
| 113 | - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY xlBm,clZbh") | 116 | + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY realExecDate,fcsj,xlBm,clZbh") |
| 114 | List<Map<String,Object>> yesterdayDataList(String line,String date); | 117 | List<Map<String,Object>> yesterdayDataList(String line,String date); |
| 115 | 118 | ||
| 116 | @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") | 119 | @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") |
src/main/java/com/bsth/repository/realcontrol/SvgAttributeRepository.java
0 → 100644
| 1 | +package com.bsth.repository.realcontrol; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.realcontrol.SvgAttribute; | ||
| 4 | +import com.bsth.repository.BaseRepository; | ||
| 5 | +import org.springframework.data.jpa.repository.Query; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by panzhao on 2017/1/8. | ||
| 12 | + */ | ||
| 13 | +@Repository | ||
| 14 | +public interface SvgAttributeRepository extends BaseRepository<SvgAttribute, String> { | ||
| 15 | + @Query("select s from SvgAttribute s where s.lineCode in ?1") | ||
| 16 | + List<SvgAttribute> findSvgAttr(List<String> lineCodes); | ||
| 17 | +} |
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
| @@ -34,7 +34,10 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | @@ -34,7 +34,10 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | ||
| 34 | @Query("select cc from TTInfoDetail cc where cc.id=?1") | 34 | @Query("select cc from TTInfoDetail cc where cc.id=?1") |
| 35 | TTInfoDetail findOneExtend(Long aLong); | 35 | TTInfoDetail findOneExtend(Long aLong); |
| 36 | 36 | ||
| 37 | - void deleteByTtinfoId(Long ttid); | 37 | +// TODO:在findOne中 @EntityGraph 无效 |
| 38 | +// @EntityGraph(value = "tTInfoDetail_xl_lp_qdz_zdz_tcc", type = EntityGraph.EntityGraphType.FETCH) | ||
| 39 | +// @Override | ||
| 40 | +// TTInfoDetail findOne(Long aLong); | ||
| 38 | 41 | ||
| 39 | @Query(value = "select max(tt.fcno) as mx from bsth_c_s_ttinfo_detail tt where tt.xl =?1 and tt.ttinfo =?2", nativeQuery = true) | 42 | @Query(value = "select max(tt.fcno) as mx from bsth_c_s_ttinfo_detail tt where tt.xl =?1 and tt.ttinfo =?2", nativeQuery = true) |
| 40 | Long findMaxFcno(Integer xlid, Long ttinfoid); | 43 | Long findMaxFcno(Integer xlid, Long ttinfoid); |
| @@ -44,6 +47,6 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | @@ -44,6 +47,6 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon | ||
| 44 | 47 | ||
| 45 | @Modifying | 48 | @Modifying |
| 46 | @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1") | 49 | @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1") |
| 47 | - void deleteByTtinfo(Long ttinfoid); | 50 | + void deleteByTtinfoIdWithModify(Long ttinfoid); |
| 48 | 51 | ||
| 49 | } | 52 | } |
src/main/java/com/bsth/repository/sys/DutyEmployeeRepository.java
0 → 100644
| 1 | +package com.bsth.repository.sys; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.sys.DutyEmployee; | ||
| 4 | +import com.bsth.repository.BaseRepository; | ||
| 5 | +import org.springframework.data.jpa.repository.Query; | ||
| 6 | +import org.springframework.stereotype.Repository; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by panzhao on 2017/1/5. | ||
| 12 | + */ | ||
| 13 | +@Repository | ||
| 14 | +public interface DutyEmployeeRepository extends BaseRepository<DutyEmployee, Long>{ | ||
| 15 | + | ||
| 16 | + @Query("select t from DutyEmployee t where t.codeIdx like %?1% and t.ts > ?2 and t.ts < ?3") | ||
| 17 | + List<DutyEmployee> findByLineAndTime(String lineCode, long st, long et); | ||
| 18 | +} |
src/main/java/com/bsth/repository/sys/SessionLogRepository.java deleted
100644 → 0
| 1 | -package com.bsth.repository.sys; | ||
| 2 | - | ||
| 3 | -import org.springframework.stereotype.Repository; | ||
| 4 | - | ||
| 5 | -import com.bsth.entity.sys.SessionLog; | ||
| 6 | -import com.bsth.repository.BaseRepository; | ||
| 7 | - | ||
| 8 | -@Repository | ||
| 9 | -public interface SessionLogRepository extends BaseRepository<SessionLog, Integer>{ | ||
| 10 | - | ||
| 11 | -} |
src/main/java/com/bsth/service/gps/GpsServiceImpl.java
| @@ -58,7 +58,7 @@ public class GpsServiceImpl implements GpsService { | @@ -58,7 +58,7 @@ public class GpsServiceImpl implements GpsService { | ||
| 58 | 58 | ||
| 59 | int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR); | 59 | int dayOfYear = sCal.get(Calendar.DAY_OF_YEAR); |
| 60 | /* | 60 | /* |
| 61 | - * if(dayOfYear != eCal.get(Calendar.DAY_OF_YEAR)){ | 61 | + * if(dayOfYear != eCal.get(Calendar.DAY_OF_YEAR)){ |
| 62 | * System.out.println("暂时不支持跨天查询..."); return null; } | 62 | * System.out.println("暂时不支持跨天查询..."); return null; } |
| 63 | */ | 63 | */ |
| 64 | 64 | ||
| @@ -195,7 +195,7 @@ public class GpsServiceImpl implements GpsService { | @@ -195,7 +195,7 @@ public class GpsServiceImpl implements GpsService { | ||
| 195 | inv = inv.substring(0, inv.length() - 1); | 195 | inv = inv.substring(0, inv.length() - 1); |
| 196 | 196 | ||
| 197 | // 查询到离站数据 | 197 | // 查询到离站数据 |
| 198 | - //Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv); | 198 | + Map<String, ArrivalEntity> arrivalMap = findArrivalByTs(weekOfYear/* 30 */, st, et, inv); |
| 199 | 199 | ||
| 200 | String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO,DIRECTION,LINE_ID,SPEED_GPS from bsth_c_gps_info where days_year=? and device_id in (" | 200 | String sql = "select DEVICE_ID,LON,LAT,TS,INOUT_STOP,SERVICE_STATE ,STOP_NO,DIRECTION,LINE_ID,SPEED_GPS from bsth_c_gps_info where days_year=? and device_id in (" |
| 201 | + inv + ") and ts > ? and ts < ?"; | 201 | + inv + ") and ts > ? and ts < ?"; |
| @@ -239,11 +239,12 @@ public class GpsServiceImpl implements GpsService { | @@ -239,11 +239,12 @@ public class GpsServiceImpl implements GpsService { | ||
| 239 | inOutStop = rs.getInt("INOUT_STOP"); | 239 | inOutStop = rs.getInt("INOUT_STOP"); |
| 240 | map.put("inout_stop", inOutStop); | 240 | map.put("inout_stop", inOutStop); |
| 241 | 241 | ||
| 242 | - /*analyse = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS")); | ||
| 243 | - if (analyse != null) { | ||
| 244 | - map.put("inout_stop_info", analyse); | ||
| 245 | - map.put("inout_stop", analyse.getInOut()); | ||
| 246 | - }*/ | 242 | + arrival = arrivalMap.get(rs.getString("DEVICE_ID") + "_" + rs.getLong("TS")); |
| 243 | + if (arrival != null) { | ||
| 244 | + map.put("inout_stop_info", arrival); | ||
| 245 | + map.put("inout_stop", arrival.getInOut()); | ||
| 246 | + } | ||
| 247 | + | ||
| 247 | map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID"))); | 248 | map.put("nbbm", BasicData.deviceId2NbbmMap.get(rs.getString("DEVICE_ID"))); |
| 248 | map.put("state", 0); | 249 | map.put("state", 0); |
| 249 | // 上下行 | 250 | // 上下行 |
| @@ -272,11 +273,17 @@ public class GpsServiceImpl implements GpsService { | @@ -272,11 +273,17 @@ public class GpsServiceImpl implements GpsService { | ||
| 272 | 273 | ||
| 273 | rs = ps.executeQuery(); | 274 | rs = ps.executeQuery(); |
| 274 | ArrivalEntity arr; | 275 | ArrivalEntity arr; |
| 275 | - int inOut; | 276 | + int inOut, updown; |
| 277 | + String prefix, stationName, lineId; | ||
| 276 | while (rs.next()) { | 278 | while (rs.next()) { |
| 277 | - arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), rs.getString("LINE_ID"), | ||
| 278 | - rs.getInt("UP_DOWN"), rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"), | ||
| 279 | - rs.getInt("WEEKS_YEAR"), BasicData.stationCode2NameMap.get(rs.getString("STOP_NO"))); | 279 | + lineId = rs.getString("LINE_ID"); |
| 280 | + updown = rs.getInt("UP_DOWN"); | ||
| 281 | + prefix = lineId + "_" + updown + "_"; | ||
| 282 | + stationName = BasicData.getStationNameByCode(rs.getString("STOP_NO"), prefix); | ||
| 283 | + | ||
| 284 | + arr = new ArrivalEntity(rs.getString("DEVICE_ID"), rs.getLong("TS"), lineId, | ||
| 285 | + updown, rs.getString("STOP_NO"), rs.getInt("IN_OUT"), rs.getLong("CREATE_DATE"), | ||
| 286 | + rs.getInt("WEEKS_YEAR"), stationName); | ||
| 280 | 287 | ||
| 281 | // 设备号_时间戳_进出状态 为key | 288 | // 设备号_时间戳_进出状态 为key |
| 282 | // 反转进出状态 | 289 | // 反转进出状态 |
| @@ -382,7 +389,7 @@ public class GpsServiceImpl implements GpsService { | @@ -382,7 +389,7 @@ public class GpsServiceImpl implements GpsService { | ||
| 382 | 389 | ||
| 383 | gpsRealData.remove(device); | 390 | gpsRealData.remove(device); |
| 384 | rs.put("status", ResponseCode.SUCCESS); | 391 | rs.put("status", ResponseCode.SUCCESS); |
| 385 | - }catch (Exception e){ | 392 | + } catch (Exception e) { |
| 386 | rs.put("status", ResponseCode.ERROR); | 393 | rs.put("status", ResponseCode.ERROR); |
| 387 | } | 394 | } |
| 388 | return rs; | 395 | return rs; |
src/main/java/com/bsth/service/impl/BusIntervalServiceImpl.java
| @@ -11,6 +11,7 @@ import java.util.Collections; | @@ -11,6 +11,7 @@ import java.util.Collections; | ||
| 11 | import java.util.Comparator; | 11 | import java.util.Comparator; |
| 12 | import java.util.Date; | 12 | import java.util.Date; |
| 13 | import java.util.HashMap; | 13 | import java.util.HashMap; |
| 14 | +import java.util.Iterator; | ||
| 14 | import java.util.List; | 15 | import java.util.List; |
| 15 | import java.util.Map; | 16 | import java.util.Map; |
| 16 | import java.util.Set; | 17 | import java.util.Set; |
| @@ -25,6 +26,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | @@ -25,6 +26,7 @@ import com.bsth.entity.realcontrol.ScheduleRealInfo; | ||
| 25 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; | 26 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 26 | import com.bsth.service.BusIntervalService; | 27 | import com.bsth.service.BusIntervalService; |
| 27 | import com.bsth.service.schedule.PeopleCarPlanService; | 28 | import com.bsth.service.schedule.PeopleCarPlanService; |
| 29 | +import com.bsth.util.ReportUtils; | ||
| 28 | 30 | ||
| 29 | 31 | ||
| 30 | @Service | 32 | @Service |
| @@ -324,13 +326,14 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -324,13 +326,14 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 324 | 326 | ||
| 325 | String[] date1 = startDate.split("-"); | 327 | String[] date1 = startDate.split("-"); |
| 326 | String[] date2 = endDate.split("-"); | 328 | String[] date2 = endDate.split("-"); |
| 327 | - startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; | ||
| 328 | - endDate = date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; | 329 | +// startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| 330 | +// endDate = date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; | ||
| 329 | String Date = ""; | 331 | String Date = ""; |
| 330 | if(startDate.equals(endDate)) | 332 | if(startDate.equals(endDate)) |
| 331 | - Date = startDate; | 333 | + Date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| 332 | else | 334 | else |
| 333 | - Date = startDate + "--" + endDate; | 335 | + Date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日" + "--" |
| 336 | + + date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; | ||
| 334 | 337 | ||
| 335 | // String[] split = times.split("-"); | 338 | // String[] split = times.split("-"); |
| 336 | // int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]); | 339 | // int startTime = Integer.valueOf(split[0].split(":")[0])*60 + Integer.valueOf(split[0].split(":")[1]); |
| @@ -514,6 +517,24 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -514,6 +517,24 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 514 | } | 517 | } |
| 515 | } | 518 | } |
| 516 | } | 519 | } |
| 520 | + | ||
| 521 | + if(type != null && type.length() != 0 && type.equals("export")){ | ||
| 522 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 523 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 524 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 525 | + Map<String, Object> m = new HashMap<String, Object>(); | ||
| 526 | + ReportUtils ee = new ReportUtils(); | ||
| 527 | + try { | ||
| 528 | + listI.add(resList.iterator()); | ||
| 529 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | ||
| 530 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\busInterval"+statu+".xls", | ||
| 531 | + path+"export\\班次间隔统计表" + sdfSimple.format(sdfMonth.parse(startDate)) | ||
| 532 | + + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls"); | ||
| 533 | + } catch (Exception e) { | ||
| 534 | + // TODO: handle exception | ||
| 535 | + e.printStackTrace(); | ||
| 536 | + } | ||
| 537 | + } | ||
| 517 | 538 | ||
| 518 | return resList; | 539 | return resList; |
| 519 | } | 540 | } |
| @@ -672,8 +693,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -672,8 +693,8 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 672 | String[] date1 = startDate.split("-"); | 693 | String[] date1 = startDate.split("-"); |
| 673 | String[] date2 = endDate.split("-"); | 694 | String[] date2 = endDate.split("-"); |
| 674 | String date = ""; | 695 | String date = ""; |
| 675 | - startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; | ||
| 676 | - endDate = date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; | 696 | +// startDate = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| 697 | +// endDate = date2[0] + "年" + date2[1] + "月" + date2[2] + "日"; | ||
| 677 | if(startDate.equals(endDate)){ | 698 | if(startDate.equals(endDate)){ |
| 678 | date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; | 699 | date = date1[0] + "年" + date1[1] + "月" + date1[2] + "日"; |
| 679 | } else { | 700 | } else { |
| @@ -1044,6 +1065,27 @@ public class BusIntervalServiceImpl implements BusIntervalService { | @@ -1044,6 +1065,27 @@ public class BusIntervalServiceImpl implements BusIntervalService { | ||
| 1044 | modelMap.put("dataList", dataList); | 1065 | modelMap.put("dataList", dataList); |
| 1045 | } | 1066 | } |
| 1046 | 1067 | ||
| 1068 | + if(type != null && type.length() != 0 && type.equals("export")){ | ||
| 1069 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1070 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1071 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1072 | + ReportUtils ee = new ReportUtils(); | ||
| 1073 | + if(statu.equals("0")) | ||
| 1074 | + modelMap.put("lpType", "路牌数量"); | ||
| 1075 | + else if(statu.equals("1")) | ||
| 1076 | + modelMap.put("lpType", "路牌名"); | ||
| 1077 | + try { | ||
| 1078 | + listI.add(((List<Map<String, Object>>)modelMap.get("dataList")).iterator()); | ||
| 1079 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | ||
| 1080 | + ee.excelReplace(listI, new Object[] { modelMap }, path+"mould\\timeAndSpeed.xls", | ||
| 1081 | + path+"export\\行驶时间及车速统计表" + sdfSimple.format(sdfMonth.parse(startDate)) | ||
| 1082 | + + "-" + sdfSimple.format(sdfMonth.parse(endDate)) + ".xls"); | ||
| 1083 | + } catch (Exception e) { | ||
| 1084 | + // TODO: handle exception | ||
| 1085 | + e.printStackTrace(); | ||
| 1086 | + } | ||
| 1087 | + } | ||
| 1088 | + | ||
| 1047 | return modelMap; | 1089 | return modelMap; |
| 1048 | } | 1090 | } |
| 1049 | 1091 |
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| 1 | package com.bsth.service.impl; | 1 | package com.bsth.service.impl; |
| 2 | 2 | ||
| 3 | -import java.io.ByteArrayInputStream; | ||
| 4 | -import java.io.File; | ||
| 5 | -import java.io.InputStream; | ||
| 6 | -import java.text.DecimalFormat; | ||
| 7 | -import java.util.ArrayList; | ||
| 8 | -import java.util.HashMap; | ||
| 9 | -import java.util.List; | ||
| 10 | -import java.util.Map; | ||
| 11 | -import java.util.Properties; | ||
| 12 | - | ||
| 13 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | -import org.springframework.data.jpa.repository.EntityGraph; | ||
| 15 | -import org.springframework.stereotype.Service; | ||
| 16 | - | ||
| 17 | -import com.alibaba.fastjson.JSON; | ||
| 18 | -import com.alibaba.fastjson.JSONArray; | ||
| 19 | -import com.alibaba.fastjson.serializer.PropertyFilter; | ||
| 20 | import com.bsth.common.ResponseCode; | 3 | import com.bsth.common.ResponseCode; |
| 21 | import com.bsth.entity.Line; | 4 | import com.bsth.entity.Line; |
| 22 | import com.bsth.entity.Station; | 5 | import com.bsth.entity.Station; |
| @@ -30,7 +13,14 @@ import com.bsth.util.FTPClientUtils; | @@ -30,7 +13,14 @@ import com.bsth.util.FTPClientUtils; | ||
| 30 | import com.bsth.util.PackTarGZUtils; | 13 | import com.bsth.util.PackTarGZUtils; |
| 31 | import com.bsth.util.db.DBUtils_MS; | 14 | import com.bsth.util.db.DBUtils_MS; |
| 32 | import com.google.common.base.Splitter; | 15 | import com.google.common.base.Splitter; |
| 33 | -import com.google.common.collect.Lists; | 16 | +import org.springframework.beans.factory.annotation.Autowired; |
| 17 | +import org.springframework.stereotype.Service; | ||
| 18 | + | ||
| 19 | +import java.io.ByteArrayInputStream; | ||
| 20 | +import java.io.File; | ||
| 21 | +import java.io.InputStream; | ||
| 22 | +import java.text.DecimalFormat; | ||
| 23 | +import java.util.*; | ||
| 34 | 24 | ||
| 35 | /** | 25 | /** |
| 36 | * | 26 | * |
| @@ -985,6 +975,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -985,6 +975,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 985 | List<String> idx = Splitter.on(',').splitToList(lineIds); | 975 | List<String> idx = Splitter.on(',').splitToList(lineIds); |
| 986 | //路由 | 976 | //路由 |
| 987 | List<StationRoute> list = new ArrayList<>(); | 977 | List<StationRoute> list = new ArrayList<>(); |
| 978 | + | ||
| 979 | + | ||
| 988 | /** | 980 | /** |
| 989 | * in 查询符 无法和 @EntityGraph 同时配合使用,这可能是一个bug | 981 | * in 查询符 无法和 @EntityGraph 同时配合使用,这可能是一个bug |
| 990 | * 暂时只能循环单线路查询 | 982 | * 暂时只能循环单线路查询 |
| @@ -993,9 +985,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -993,9 +985,12 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 993 | for(String id : idx){ | 985 | for(String id : idx){ |
| 994 | list.addAll(repository.findByLineCode(id)); | 986 | list.addAll(repository.findByLineCode(id)); |
| 995 | } | 987 | } |
| 996 | - | 988 | + |
| 989 | + for(StationRoute sr : list){ | ||
| 990 | + sr.setLine(null); | ||
| 991 | + } | ||
| 997 | //过滤部分字段 | 992 | //过滤部分字段 |
| 998 | - String jsonStr = JSON.toJSONString(list, new PropertyFilter() { | 993 | + /*String jsonStr = JSON.toJSONString(list, new PropertyFilter() { |
| 999 | 994 | ||
| 1000 | @Override | 995 | @Override |
| 1001 | public boolean apply(Object object, String name, Object value) { | 996 | public boolean apply(Object object, String name, Object value) { |
| @@ -1003,10 +998,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | @@ -1003,10 +998,10 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ | ||
| 1003 | return false; | 998 | return false; |
| 1004 | return true; | 999 | return true; |
| 1005 | } | 1000 | } |
| 1006 | - }); | 1001 | + });*/ |
| 1007 | 1002 | ||
| 1008 | rs.put("status", ResponseCode.SUCCESS); | 1003 | rs.put("status", ResponseCode.SUCCESS); |
| 1009 | - rs.put("list", jsonStr); | 1004 | + rs.put("list", list); |
| 1010 | }catch(Exception e){ | 1005 | }catch(Exception e){ |
| 1011 | logger.error("", e); | 1006 | logger.error("", e); |
| 1012 | rs.put("status", ResponseCode.ERROR); | 1007 | rs.put("status", ResponseCode.ERROR); |
src/main/java/com/bsth/service/impl/TrafficManageServiceImpl.java
| @@ -14,7 +14,6 @@ import com.bsth.repository.schedule.*; | @@ -14,7 +14,6 @@ import com.bsth.repository.schedule.*; | ||
| 14 | import com.bsth.service.TrafficManageService; | 14 | import com.bsth.service.TrafficManageService; |
| 15 | import com.bsth.util.TimeUtils; | 15 | import com.bsth.util.TimeUtils; |
| 16 | import com.bsth.util.db.DBUtils_MS; | 16 | import com.bsth.util.db.DBUtils_MS; |
| 17 | -import com.bsth.webService.trafficManage.geotool.services.Internal; | ||
| 18 | import com.bsth.webService.trafficManage.geotool.services.InternalPortType; | 17 | import com.bsth.webService.trafficManage.geotool.services.InternalPortType; |
| 19 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; | 18 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceLocator; |
| 20 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; | 19 | import com.bsth.webService.trafficManage.org.tempuri.WebServiceSoap; |
| @@ -105,7 +104,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -105,7 +104,7 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 105 | 104 | ||
| 106 | 105 | ||
| 107 | // 运管处接口 | 106 | // 运管处接口 |
| 108 | - private InternalPortType portType = new Internal().getInternalHttpSoap11Endpoint(); | 107 | + private InternalPortType portType = null;//new Internal().getInternalHttpSoap11Endpoint(); |
| 109 | private WebServiceSoap ssop ; | 108 | private WebServiceSoap ssop ; |
| 110 | { | 109 | { |
| 111 | try { | 110 | try { |
| @@ -391,36 +390,44 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -391,36 +390,44 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 391 | Map<String,Object> map = new HashMap<String,Object>(); | 390 | Map<String,Object> map = new HashMap<String,Object>(); |
| 392 | for(Map<String,Object> schRealInfo:listGroup){ | 391 | for(Map<String,Object> schRealInfo:listGroup){ |
| 393 | if(schRealInfo != null){ | 392 | if(schRealInfo != null){ |
| 393 | + map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | ||
| 394 | + Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | ||
| 395 | + /** | ||
| 396 | + * 如果car==null,则说明该车辆是从线调中换车功能中加进去的, | ||
| 397 | + * 在cars基础信息中查不到车辆的信息,所以忽略该车辆 | ||
| 398 | + */ | ||
| 399 | + if(car == null){ | ||
| 400 | + continue; | ||
| 401 | + } | ||
| 394 | //计算总公里和空驶公里,营运公里=总公里-空驶公里 | 402 | //计算总公里和空驶公里,营运公里=总公里-空驶公里 |
| 395 | double totalKilometers = 0,emptyKilometers =0; | 403 | double totalKilometers = 0,emptyKilometers =0; |
| 396 | sf.append("<LCYH>"); | 404 | sf.append("<LCYH>"); |
| 397 | - map.put("insideCode_eq", schRealInfo.get("clZbh")+""); | ||
| 398 | - Cars car = carsRepository.findOne(new CustomerSpecs<Cars>(map)); | ||
| 399 | -// Cars car = carsRepository.findCarByClzbh(schRealInfo.getClZbh()); | ||
| 400 | sf.append("<RQ>"+date+"</RQ>"); | 405 | sf.append("<RQ>"+date+"</RQ>"); |
| 401 | sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); | 406 | sf.append("<XLBM>"+BasicData.lineCode2ShangHaiCodeMap.get(schRealInfo.get("xlBm"))+"</XLBM>"); |
| 402 | sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); | 407 | sf.append("<CPH>"+car.getCarPlate()+"</CPH>"); |
| 403 | - for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 404 | - if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | ||
| 405 | - .equals(scheduleRealInfo.getClZbh())){ | ||
| 406 | - Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 407 | - //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 408 | - if(childTaskPlans.isEmpty()){ | ||
| 409 | - if(scheduleRealInfo.getStatus() == 2){ | ||
| 410 | - totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 411 | - if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 412 | - || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 413 | - emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | 408 | + if(list != null && list.size() > 0){ |
| 409 | + for(ScheduleRealInfo scheduleRealInfo:list){ | ||
| 410 | + if((schRealInfo.get("xlBm")+"").equals(scheduleRealInfo.getXlBm()) && (schRealInfo.get("clZbh")+"") | ||
| 411 | + .equals(scheduleRealInfo.getClZbh())){ | ||
| 412 | + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks(); | ||
| 413 | + //如果没有子任务,里程就是已执行(Status=2);有子任务的,忽略主任务,子任务的烂班 | ||
| 414 | + if(childTaskPlans.isEmpty()){ | ||
| 415 | + if(scheduleRealInfo.getStatus() == 2){ | ||
| 416 | + totalKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 417 | + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out") | ||
| 418 | + || scheduleRealInfo.getBcType().equals("venting")){ | ||
| 419 | + emptyKilometers += scheduleRealInfo.getJhlc()==null?0.0:scheduleRealInfo.getJhlc(); | ||
| 420 | + } | ||
| 414 | } | 421 | } |
| 415 | - } | ||
| 416 | - }else{ | ||
| 417 | - Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 418 | - while(it.hasNext()){ | ||
| 419 | - ChildTaskPlan childTaskPlan = it.next(); | ||
| 420 | - if(!childTaskPlan.isDestroy()){ | ||
| 421 | - totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 422 | - if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 423 | - emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | 422 | + }else{ |
| 423 | + Iterator<ChildTaskPlan> it = childTaskPlans.iterator(); | ||
| 424 | + while(it.hasNext()){ | ||
| 425 | + ChildTaskPlan childTaskPlan = it.next(); | ||
| 426 | + if(!childTaskPlan.isDestroy()){ | ||
| 427 | + totalKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage(); | ||
| 428 | + if(childTaskPlan.getMileageType().equals("empty")){ | ||
| 429 | + emptyKilometers += childTaskPlan.getMileage()==null?0.0:childTaskPlan.getMileage();; | ||
| 430 | + } | ||
| 424 | } | 431 | } |
| 425 | } | 432 | } |
| 426 | } | 433 | } |
| @@ -605,8 +612,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | @@ -605,8 +612,8 @@ public class TrafficManageServiceImpl implements TrafficManageService{ | ||
| 605 | schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getQdzName())).append("</ZDXH>"); | 612 | schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getQdzName())).append("</ZDXH>"); |
| 606 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); | 613 | sBuffer.append("<JHFCSJ>").append(schedulePlanInfo.getFcsj()).append("</JHFCSJ>"); |
| 607 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); | 614 | sBuffer.append("<DDZDMC>").append(schedulePlanInfo.getZdzName()).append("</DDZDMC>"); |
| 608 | - sBuffer.append("<ZDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( | ||
| 609 | - schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getZdzName())).append("</ZDXH>"); | 615 | + sBuffer.append("<DDXH>").append(getYgcStationNumByLineCodeAndDirectionAndStationName( |
| 616 | + schedulePlanInfo.getXlBm(), schedulePlanInfo.getXlDir(), schedulePlanInfo.getZdzName())).append("</DDXH>"); | ||
| 610 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) | 617 | sBuffer.append("<JHDDSJ>").append(calcDdsj(schedulePlanInfo.getFcsj(),schedulePlanInfo.getBcsj())) |
| 611 | .append("</JHDDSJ>"); | 618 | .append("</JHDDSJ>"); |
| 612 | sBuffer.append("</BC>"); | 619 | sBuffer.append("</BC>"); |
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
| @@ -132,7 +132,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS | @@ -132,7 +132,7 @@ public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbS | ||
| 132 | t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); | 132 | t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); |
| 133 | t.setSsgsdm(map.get("company")==null?"":map.get("company").toString()); | 133 | t.setSsgsdm(map.get("company")==null?"":map.get("company").toString()); |
| 134 | t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString()); | 134 | t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString()); |
| 135 | - t.setRq(dBefore); | 135 | + t.setRq(sdf.parse(rq)); |
| 136 | repository.save(t); | 136 | repository.save(t); |
| 137 | result = "success"; | 137 | result = "success"; |
| 138 | } catch (Exception e) { | 138 | } catch (Exception e) { |
src/main/java/com/bsth/service/realcontrol/RealMapService.java
| @@ -13,4 +13,6 @@ public interface RealMapService { | @@ -13,4 +13,6 @@ public interface RealMapService { | ||
| 13 | Map<String,Object> findRouteByLine(String lineCode); | 13 | Map<String,Object> findRouteByLine(String lineCode); |
| 14 | 14 | ||
| 15 | Map<String,Object> findRouteAndStationByLine(String lineCode); | 15 | Map<String,Object> findRouteAndStationByLine(String lineCode); |
| 16 | + | ||
| 17 | + Map<String,Object> multiSectionRoute(String codeIdx); | ||
| 16 | } | 18 | } |
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
| @@ -15,7 +15,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -15,7 +15,7 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 15 | 15 | ||
| 16 | Map<String, Collection<ScheduleRealInfo>> findByLines(String lines); | 16 | Map<String, Collection<ScheduleRealInfo>> findByLines(String lines); |
| 17 | 17 | ||
| 18 | - Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj/*,String nbbm,String jsy,String spy*/); | 18 | + Map<String, Object> outgoAdjust(Long id, String remarks, String dfsj, String bcType); |
| 19 | 19 | ||
| 20 | Map<String, Object> destroy(String idsStr/*, int spaceAdjust*/, String remarks, String reason/*, int spaceNum*/); | 20 | Map<String, Object> destroy(String idsStr/*, int spaceAdjust*/, String remarks, String reason/*, int spaceNum*/); |
| 21 | 21 | ||
| @@ -61,11 +61,13 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -61,11 +61,13 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 61 | 61 | ||
| 62 | List<ScheduleRealInfo> queryUserInfo(String line,String date,String state); | 62 | List<ScheduleRealInfo> queryUserInfo(String line,String date,String state); |
| 63 | 63 | ||
| 64 | - List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName,String date); | 64 | + List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName,String date,String line); |
| 65 | + | ||
| 66 | + List<ScheduleRealInfo> exportWaybillQp(String clZbh,String date,String line); | ||
| 65 | 67 | ||
| 66 | List<Map<String,Object>> dailyInfo(String line,String date,String type); | 68 | List<Map<String,Object>> dailyInfo(String line,String date,String type); |
| 67 | 69 | ||
| 68 | - List<Object[]> historyMessage(String line,String date,String code); | 70 | + List<Object[]> historyMessage(String line,String date,String code, String type); |
| 69 | 71 | ||
| 70 | Map<Integer, Integer> trustStatus(String lineCodes); | 72 | Map<Integer, Integer> trustStatus(String lineCodes); |
| 71 | 73 | ||
| @@ -87,21 +89,25 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -87,21 +89,25 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 87 | 89 | ||
| 88 | Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate); | 90 | Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate); |
| 89 | 91 | ||
| 90 | - Map<String,Object> findKMBC(String jName,String clZbh,String lpName,String date); | 92 | + Map<String,Object> findKMBC(String jName,String clZbh,String lpName,String date,String line); |
| 93 | + | ||
| 94 | + Map<String,Object> findKMBCQp(String clZbh,String date,String line); | ||
| 91 | 95 | ||
| 92 | Map<String,Object> findKMBC2(String jName,String clZbh,String date); | 96 | Map<String,Object> findKMBC2(String jName,String clZbh,String date); |
| 93 | 97 | ||
| 94 | List<Map<String,String>> findLpName(String lpName); | 98 | List<Map<String,String>> findLpName(String lpName); |
| 95 | 99 | ||
| 96 | - List<Map<String,Object>> account(String line,String date,String code,String xlName); | 100 | + List<Map<String,Object>> account(String line,String date,String code,String xlName, String type); |
| 97 | 101 | ||
| 98 | - List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code); | 102 | + List<ScheduleRealInfo> correctForm(String line,String startDate,String endDate,String lpName,String code, String type); |
| 99 | 103 | ||
| 100 | - List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String type); | 104 | + List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); |
| 101 | 105 | ||
| 106 | + List<ScheduleRealInfo> queryListWaybillQp(String clZbh,String date,String line); | ||
| 107 | + | ||
| 102 | Map<String, Object> removeChildTask(Long taskId); | 108 | Map<String, Object> removeChildTask(Long taskId); |
| 103 | 109 | ||
| 104 | - List<Map<String,Object>> statisticsDaily(String line,String date,String xlName); | 110 | + List<Map<String,Object>> statisticsDaily(String line, String date, String xlName, String type); |
| 105 | 111 | ||
| 106 | //List<Object> scheduleDaily(String line,String date); | 112 | //List<Object> scheduleDaily(String line,String date); |
| 107 | 113 | ||
| @@ -128,4 +134,14 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | @@ -128,4 +134,14 @@ public interface ScheduleRealInfoService extends BaseService<ScheduleRealInfo, L | ||
| 128 | Map<String,Object> changeBcType(Long id, String bcType, String remarks); | 134 | Map<String,Object> changeBcType(Long id, String bcType, String remarks); |
| 129 | 135 | ||
| 130 | Map<String,Object> historySave(ScheduleRealInfo sch); | 136 | Map<String,Object> historySave(ScheduleRealInfo sch); |
| 137 | + | ||
| 138 | + Map<String, Object> MapById(Long id) ; | ||
| 139 | + | ||
| 140 | + Map<String,Object> svgAttr(String jsonStr); | ||
| 141 | + | ||
| 142 | + Map<String,Object> findSvgAttr(String idx); | ||
| 143 | + | ||
| 144 | + Map<String,Object> addRemarks(Long id, String remarks); | ||
| 145 | + | ||
| 146 | + List<Map<String, Object>> scheduleDailyQp(String line ,String date); | ||
| 131 | } | 147 | } |
src/main/java/com/bsth/service/realcontrol/impl/ChildTaskPlanServiceImpl.java
| @@ -17,65 +17,65 @@ import javax.transaction.Transactional; | @@ -17,65 +17,65 @@ import javax.transaction.Transactional; | ||
| 17 | import java.util.Map; | 17 | import java.util.Map; |
| 18 | 18 | ||
| 19 | @Service | 19 | @Service |
| 20 | -public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Long> implements ChildTaskPlanService{ | 20 | +public class ChildTaskPlanServiceImpl extends BaseServiceImpl<ChildTaskPlan, Long> implements ChildTaskPlanService { |
| 21 | 21 | ||
| 22 | /*@Autowired | 22 | /*@Autowired |
| 23 | - ScheduleRealInfoServiceImpl scheduleRealInfoService;*/ | ||
| 24 | - | ||
| 25 | - @Autowired | ||
| 26 | - ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 27 | - | ||
| 28 | - @Autowired | ||
| 29 | - ChildTaskPlanRepository childTaskPlanRepository; | ||
| 30 | - | ||
| 31 | - @Autowired | ||
| 32 | - DayOfSchedule dayOfSchedule; | ||
| 33 | - | ||
| 34 | - @Autowired | ||
| 35 | - Arrival2Schedule arrival2Schedule; | ||
| 36 | - | ||
| 37 | - @Autowired | ||
| 38 | - JdbcTemplate jdbcTemplate; | ||
| 39 | - | ||
| 40 | - @Transactional | ||
| 41 | - @Override | ||
| 42 | - public Map<String, Object> save(ChildTaskPlan t) { | ||
| 43 | - Map<String, Object> rs; | ||
| 44 | - //保存起终点名称 | ||
| 45 | - Map<String, String> map = BasicData.stationCode2NameMap; | ||
| 46 | - | ||
| 47 | - t.setStartStationName(map.get(t.getStartStation())); | ||
| 48 | - t.setEndStationName(map.get(t.getEndStation())); | ||
| 49 | - //先持久化子任务 | ||
| 50 | - rs = super.save(t); | ||
| 51 | - //再关联主任务 | ||
| 52 | - ScheduleRealInfo sch = dayOfSchedule.get(t.getSchedule().getId()); | ||
| 53 | - sch.getcTasks().add(t); | ||
| 54 | - dayOfSchedule.save(sch); | ||
| 55 | - | ||
| 56 | - rs.put("t", sch); | ||
| 57 | - | ||
| 58 | - if(sch.getZdsjActual() == null) | ||
| 59 | - arrival2Schedule.removeExpect(sch.getClZbh()); | ||
| 60 | - return rs; | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @Override | ||
| 64 | - public Map<String, Object> delete(Long id) { | ||
| 65 | - Map<String, Object> rs; | ||
| 66 | - | ||
| 67 | - ChildTaskPlan cPlan = childTaskPlanRepository.findOne(id); | ||
| 68 | - //解除和主任务关联 | ||
| 69 | - ScheduleRealInfo sch = dayOfSchedule.get(cPlan.getSchedule().getId()); | ||
| 70 | - sch.getcTasks().remove(cPlan); | ||
| 71 | - //删除关联表数据 | ||
| 72 | - jdbcTemplate.execute("delete from bsth_c_s_sp_info_real_c_tasks where bsth_c_s_sp_info_real="+sch.getId()+" and c_tasks="+cPlan.getId()); | ||
| 73 | - | ||
| 74 | - //删除子任务 | ||
| 75 | - rs = super.delete(id); | ||
| 76 | - dayOfSchedule.save(sch); | ||
| 77 | - | ||
| 78 | - rs.put("t", sch); | ||
| 79 | - return rs; | ||
| 80 | - } | 23 | + ScheduleRealInfoServiceImpl scheduleRealInfoService;*/ |
| 24 | + | ||
| 25 | + @Autowired | ||
| 26 | + ScheduleRealInfoRepository scheduleRealInfoRepository; | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + ChildTaskPlanRepository childTaskPlanRepository; | ||
| 30 | + | ||
| 31 | + @Autowired | ||
| 32 | + DayOfSchedule dayOfSchedule; | ||
| 33 | + | ||
| 34 | + @Autowired | ||
| 35 | + Arrival2Schedule arrival2Schedule; | ||
| 36 | + | ||
| 37 | + @Autowired | ||
| 38 | + JdbcTemplate jdbcTemplate; | ||
| 39 | + | ||
| 40 | + @Transactional | ||
| 41 | + @Override | ||
| 42 | + public Map<String, Object> save(ChildTaskPlan t) { | ||
| 43 | + ScheduleRealInfo sch = dayOfSchedule.get(t.getSchedule().getId()); | ||
| 44 | + Map<String, Object> rs; | ||
| 45 | + //保存起终点名称 | ||
| 46 | + String prefix = sch.getXlBm() + "_" + sch.getXlDir() + "_"; | ||
| 47 | + | ||
| 48 | + t.setStartStationName(BasicData.getStationNameByCode(t.getStartStation(), prefix)); | ||
| 49 | + t.setEndStationName(BasicData.getStationNameByCode(t.getEndStation(), prefix)); | ||
| 50 | + //先持久化子任务 | ||
| 51 | + rs = super.save(t); | ||
| 52 | + //再关联主任务 | ||
| 53 | + sch.getcTasks().add(t); | ||
| 54 | + dayOfSchedule.save(sch); | ||
| 55 | + | ||
| 56 | + rs.put("t", sch); | ||
| 57 | + | ||
| 58 | + if (sch.getZdsjActual() == null) | ||
| 59 | + arrival2Schedule.removeExpect(sch.getClZbh()); | ||
| 60 | + return rs; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public Map<String, Object> delete(Long id) { | ||
| 65 | + Map<String, Object> rs; | ||
| 66 | + | ||
| 67 | + ChildTaskPlan cPlan = childTaskPlanRepository.findOne(id); | ||
| 68 | + //解除和主任务关联 | ||
| 69 | + ScheduleRealInfo sch = dayOfSchedule.get(cPlan.getSchedule().getId()); | ||
| 70 | + sch.getcTasks().remove(cPlan); | ||
| 71 | + //删除关联表数据 | ||
| 72 | + jdbcTemplate.execute("delete from bsth_c_s_sp_info_real_c_tasks where bsth_c_s_sp_info_real=" + sch.getId() + " and c_tasks=" + cPlan.getId()); | ||
| 73 | + | ||
| 74 | + //删除子任务 | ||
| 75 | + rs = super.delete(id); | ||
| 76 | + dayOfSchedule.save(sch); | ||
| 77 | + | ||
| 78 | + rs.put("t", sch); | ||
| 79 | + return rs; | ||
| 80 | + } | ||
| 81 | } | 81 | } |
src/main/java/com/bsth/service/realcontrol/impl/RealMapServiceImpl.java
| @@ -122,7 +122,7 @@ public class RealMapServiceImpl implements RealMapService { | @@ -122,7 +122,7 @@ public class RealMapServiceImpl implements RealMapService { | ||
| 122 | rs.put("section", secList); | 122 | rs.put("section", secList); |
| 123 | 123 | ||
| 124 | //查询站点信息 | 124 | //查询站点信息 |
| 125 | - sql="select r.STATION_NAME,r.STATION_ROUTE_CODE,r.LINE_CODE,r.STATION_CODE,r.STATION_MARK,s.G_LONX,s.G_LATY, r.DIRECTIONS from bsth_c_stationroute r INNER JOIN bsth_c_station s on r.station=s.id and r.line_code=? and r.destroy=0"; | 125 | + sql = "select r.STATION_NAME,r.STATION_ROUTE_CODE,r.LINE_CODE,r.STATION_CODE,r.STATION_MARK,s.G_LONX,s.G_LATY, r.DIRECTIONS from bsth_c_stationroute r INNER JOIN bsth_c_station s on r.station=s.id and r.line_code=? and r.destroy=0"; |
| 126 | List<Map<String, Object>> stationList = jdbcTemplate.queryForList(sql, lineCode); | 126 | List<Map<String, Object>> stationList = jdbcTemplate.queryForList(sql, lineCode); |
| 127 | rs.put("station", stationList); | 127 | rs.put("station", stationList); |
| 128 | 128 | ||
| @@ -134,6 +134,31 @@ public class RealMapServiceImpl implements RealMapService { | @@ -134,6 +134,31 @@ public class RealMapServiceImpl implements RealMapService { | ||
| 134 | return rs; | 134 | return rs; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | + @Override | ||
| 138 | + public Map<String, Object> multiSectionRoute(String codeIdx) { | ||
| 139 | + Map<String, Object> rs = new HashMap<>(); | ||
| 140 | + try { | ||
| 141 | + List<String> idArray = Splitter.on(",").splitToList(codeIdx); | ||
| 142 | + //拼接in语句 | ||
| 143 | + String inStr = ""; | ||
| 144 | + for (String code : idArray) { | ||
| 145 | + inStr += (",'" + code + "'"); | ||
| 146 | + } | ||
| 147 | + inStr = " (" + inStr.substring(1) + ")"; | ||
| 148 | + | ||
| 149 | + String sql = "SELECT r.LINE_CODE,r.SECTION_CODE,r.SECTIONROUTE_CODE,s.SECTION_NAME,ST_AsText (s.GSECTION_VECTOR) AS GSECTION_VECTOR,r.DIRECTIONS FROM bsth_c_sectionroute r INNER JOIN bsth_c_section s ON r.section = s.id WHERE r.line_code in " + inStr + " AND r.destroy = 0 order by r.line_code, r.directions,r.sectionroute_code"; | ||
| 150 | + | ||
| 151 | + List<Map<String, Object>> secList = jdbcTemplate.queryForList(sql); | ||
| 152 | + rs.put("section", secList); | ||
| 153 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 154 | + } catch (DataAccessException e) { | ||
| 155 | + logger.error("", e); | ||
| 156 | + rs.put("status", ResponseCode.ERROR); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + return rs; | ||
| 160 | + } | ||
| 161 | + | ||
| 137 | /** | 162 | /** |
| 138 | * wgs 坐标数组转 百度 | 163 | * wgs 坐标数组转 百度 |
| 139 | * | 164 | * |
src/main/java/com/bsth/service/schedule/BService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | +import com.bsth.service.schedule.utils.DataToolsService; | ||
| 3 | import org.springframework.data.domain.Page; | 5 | import org.springframework.data.domain.Page; |
| 4 | import org.springframework.data.domain.Pageable; | 6 | import org.springframework.data.domain.Pageable; |
| 5 | 7 | ||
| @@ -10,8 +12,8 @@ import java.util.Map; | @@ -10,8 +12,8 @@ import java.util.Map; | ||
| 10 | /** | 12 | /** |
| 11 | * 基础service接口。 | 13 | * 基础service接口。 |
| 12 | */ | 14 | */ |
| 13 | -public interface BService<T, ID extends Serializable> { | ||
| 14 | - // CRUD 操作 | 15 | +public interface BService<T, ID extends Serializable> extends DataToolsService { |
| 16 | + //---------------- CRUD 操作 ----------------// | ||
| 15 | // Create,Update操作 | 17 | // Create,Update操作 |
| 16 | T save(T t); | 18 | T save(T t); |
| 17 | <S extends T> List<S> bulkSave(List<S> entities); // 批量保存(TODO:待测试) | 19 | <S extends T> List<S> bulkSave(List<S> entities); // 批量保存(TODO:待测试) |
| @@ -22,4 +24,5 @@ public interface BService<T, ID extends Serializable> { | @@ -22,4 +24,5 @@ public interface BService<T, ID extends Serializable> { | ||
| 22 | List<T> list(Map<String, Object> param); | 24 | List<T> list(Map<String, Object> param); |
| 23 | // Delete操作 | 25 | // Delete操作 |
| 24 | void delete(ID id) throws ScheduleException; | 26 | void delete(ID id) throws ScheduleException; |
| 27 | + | ||
| 25 | } | 28 | } |
src/main/java/com/bsth/service/schedule/CarConfigInfoService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.CarConfigInfo; | 3 | import com.bsth.entity.schedule.CarConfigInfo; |
| 4 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * Created by xu on 16/5/9. | 7 | * Created by xu on 16/5/9. |
src/main/java/com/bsth/service/schedule/CarDeviceService.java
src/main/java/com/bsth/service/schedule/CarsService.java
src/main/java/com/bsth/service/schedule/EmployeeConfigInfoService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.EmployeeConfigInfo; | 3 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 4 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * Created by xu on 16/5/10. | 7 | * Created by xu on 16/5/10. |
src/main/java/com/bsth/service/schedule/EmployeeService.java
src/main/java/com/bsth/service/schedule/GuideboardInfoService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.GuideboardInfo; | 3 | import com.bsth.entity.schedule.GuideboardInfo; |
| 4 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * Created by xu on 16/5/11. | 7 | * Created by xu on 16/5/11. |
src/main/java/com/bsth/service/schedule/PeopleCarPlanServiceImpl.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import java.math.BigDecimal; | 3 | import java.math.BigDecimal; |
| 4 | +import java.net.URLEncoder; | ||
| 4 | import java.sql.ResultSet; | 5 | import java.sql.ResultSet; |
| 5 | import java.sql.SQLException; | 6 | import java.sql.SQLException; |
| 6 | import java.text.DecimalFormat; | 7 | import java.text.DecimalFormat; |
| @@ -16,6 +17,7 @@ import java.util.List; | @@ -16,6 +17,7 @@ import java.util.List; | ||
| 16 | import java.util.Map; | 17 | import java.util.Map; |
| 17 | import java.util.Set; | 18 | import java.util.Set; |
| 18 | 19 | ||
| 20 | +import org.drools.compiler.lang.DRL5Expressions.type_return; | ||
| 19 | import org.springframework.beans.factory.annotation.Autowired; | 21 | import org.springframework.beans.factory.annotation.Autowired; |
| 20 | import org.springframework.jdbc.core.JdbcTemplate; | 22 | import org.springframework.jdbc.core.JdbcTemplate; |
| 21 | import org.springframework.jdbc.core.RowMapper; | 23 | import org.springframework.jdbc.core.RowMapper; |
| @@ -463,7 +465,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -463,7 +465,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 463 | listI.add(resList.iterator()); | 465 | listI.add(resList.iterator()); |
| 464 | String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | 466 | String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; |
| 465 | ee.excelReplace(listI, new Object[] { m }, path+"mould\\workDaily.xls", | 467 | ee.excelReplace(listI, new Object[] { m }, path+"mould\\workDaily.xls", |
| 466 | - path+"export\\营运服务日报表" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | 468 | + path+"export\\营运服务日报表"+ sdfSimple.format(sdfMonth.parse(date))+".xls"); |
| 467 | } catch (Exception e) { | 469 | } catch (Exception e) { |
| 468 | // TODO: handle exception | 470 | // TODO: handle exception |
| 469 | e.printStackTrace(); | 471 | e.printStackTrace(); |
| @@ -937,7 +939,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -937,7 +939,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 937 | tempMap.put("sjfcFirst0", "/"); | 939 | tempMap.put("sjfcFirst0", "/"); |
| 938 | tempMap.put("delayFirst0", "/"); | 940 | tempMap.put("delayFirst0", "/"); |
| 939 | } | 941 | } |
| 940 | - if(moban0.getZdsjActual() != null){ | 942 | + if(moban0.getFcsjActual() != null){ |
| 941 | String[] split = moban0.getFcsjActual().split(":"); | 943 | String[] split = moban0.getFcsjActual().split(":"); |
| 942 | long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | 944 | long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); |
| 943 | long delay = moban0.getFcsjT() - min; | 945 | long delay = moban0.getFcsjT() - min; |
| @@ -963,7 +965,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -963,7 +965,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 963 | tempMap.put("sjfcFirst1", "/"); | 965 | tempMap.put("sjfcFirst1", "/"); |
| 964 | tempMap.put("delayFirst1", "/"); | 966 | tempMap.put("delayFirst1", "/"); |
| 965 | } | 967 | } |
| 966 | - if(moban1.getZdsjActual() != null){ | 968 | + if(moban1.getFcsjActual() != null){ |
| 967 | String[] split = moban1.getFcsjActual().split(":"); | 969 | String[] split = moban1.getFcsjActual().split(":"); |
| 968 | long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); | 970 | long min = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]); |
| 969 | long delay = moban1.getFcsjT() - min; | 971 | long delay = moban1.getFcsjT() - min; |
| @@ -1011,6 +1013,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -1011,6 +1013,7 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 1011 | String line = map.get("line").toString(); | 1013 | String line = map.get("line").toString(); |
| 1012 | String date = map.get("date").toString(); | 1014 | String date = map.get("date").toString(); |
| 1013 | String code = map.get("code").toString(); | 1015 | String code = map.get("code").toString(); |
| 1016 | + String type = map.get("type").toString(); | ||
| 1014 | 1017 | ||
| 1015 | if(date.length() == 0) | 1018 | if(date.length() == 0) |
| 1016 | date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); | 1019 | date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| @@ -1041,8 +1044,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -1041,8 +1044,8 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 1041 | if(company.length() != 0){ | 1044 | if(company.length() != 0){ |
| 1042 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; | 1045 | sql += " and gs_bm = '"+company+"' and fgs_bm = '"+subCompany+"'"; |
| 1043 | } | 1046 | } |
| 1044 | - sql += " order by fcsj"; | ||
| 1045 | - | 1047 | + sql += " order by xl_name, fcsj"; |
| 1048 | + | ||
| 1046 | list = jdbcTemplate.query(sql, | 1049 | list = jdbcTemplate.query(sql, |
| 1047 | new RowMapper<Map<String, Object>>(){ | 1050 | new RowMapper<Map<String, Object>>(){ |
| 1048 | @Override | 1051 | @Override |
| @@ -1071,8 +1074,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -1071,8 +1074,13 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 1071 | e.printStackTrace(); | 1074 | e.printStackTrace(); |
| 1072 | } | 1075 | } |
| 1073 | 1076 | ||
| 1077 | + List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>(); | ||
| 1078 | + List<String> keyList = new ArrayList<String>(); | ||
| 1074 | for(Map<String, Object> m : list){ | 1079 | for(Map<String, Object> m : list){ |
| 1075 | String key = m.get("line") + "/" + m.get("clZbh") + "/" + m.get("jGh") + "/" + m.get("jName"); | 1080 | String key = m.get("line") + "/" + m.get("clZbh") + "/" + m.get("jGh") + "/" + m.get("jName"); |
| 1081 | + if(!keyList.contains(m.get("line").toString())){ | ||
| 1082 | + keyList.add(m.get("line").toString()); | ||
| 1083 | + } | ||
| 1076 | if(!keyMap.containsKey(key)) | 1084 | if(!keyMap.containsKey(key)) |
| 1077 | keyMap.put(key, new ArrayList<Map<String, Object>>()); | 1085 | keyMap.put(key, new ArrayList<Map<String, Object>>()); |
| 1078 | keyMap.get(key).add(m); | 1086 | keyMap.get(key).add(m); |
| @@ -1119,7 +1127,58 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | @@ -1119,7 +1127,58 @@ public class PeopleCarPlanServiceImpl implements PeopleCarPlanService { | ||
| 1119 | tempMap.put("sjf", sjf); | 1127 | tempMap.put("sjf", sjf); |
| 1120 | tempMap.put("wqr", wqr); | 1128 | tempMap.put("wqr", wqr); |
| 1121 | tempMap.put("workList", keyMap.get(key)); | 1129 | tempMap.put("workList", keyMap.get(key)); |
| 1122 | - resList.add(tempMap); | 1130 | + tempList.add(tempMap); |
| 1131 | + } | ||
| 1132 | + | ||
| 1133 | + for(String key : keyList){ | ||
| 1134 | + for(Map<String, Object> m : tempList){ | ||
| 1135 | + if(key.equals(m.get("line").toString())){ | ||
| 1136 | + resList.add(m); | ||
| 1137 | + } | ||
| 1138 | + } | ||
| 1139 | + } | ||
| 1140 | + | ||
| 1141 | + if(type.equals("export")){ | ||
| 1142 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1143 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1144 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1145 | + Map<String,Object> m = new HashMap<String, Object>(); | ||
| 1146 | + ReportUtils ee = new ReportUtils(); | ||
| 1147 | + try { | ||
| 1148 | + listI.add(resList.iterator()); | ||
| 1149 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | ||
| 1150 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\commandState.xls", | ||
| 1151 | + path+"export\\指令状态分析" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1152 | + } catch (Exception e) { | ||
| 1153 | + // TODO: handle exception | ||
| 1154 | + e.printStackTrace(); | ||
| 1155 | + } | ||
| 1156 | + } | ||
| 1157 | + | ||
| 1158 | + if(type.equals("export1")){ | ||
| 1159 | + SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), | ||
| 1160 | + sdfSimple = new SimpleDateFormat("yyyyMMdd"); | ||
| 1161 | + List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); | ||
| 1162 | + Map<String,Object> m = new HashMap<String, Object>(); | ||
| 1163 | + ReportUtils ee = new ReportUtils(); | ||
| 1164 | + String jsy = map.get("jsy").toString(); | ||
| 1165 | + try { | ||
| 1166 | + for(Map<String, Object> map1 : resList){ | ||
| 1167 | + if(jsy.equals(map1.get("jsy").toString())){ | ||
| 1168 | + List<Map<String, Object>> temp = (List<Map<String, Object>>)map1.get("workList"); | ||
| 1169 | + listI.add(temp.iterator()); | ||
| 1170 | + m.put("detail", "日期:" + map1.get("date") + " 公司:" + map1.get("company") | ||
| 1171 | + + " 分公司:" + map1.get("subCompany") + " 线路:" + map1.get("line") | ||
| 1172 | + + " 车辆:" + map1.get("clZbh") + " 人员:" + map1.get("jsy")); | ||
| 1173 | + } | ||
| 1174 | + } | ||
| 1175 | + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; | ||
| 1176 | + ee.excelReplace(listI, new Object[] { m }, path+"mould\\commandState1.xls", | ||
| 1177 | + path+"export\\指令状态明细" + sdfSimple.format(sdfMonth.parse(date)) + ".xls"); | ||
| 1178 | + } catch (Exception e) { | ||
| 1179 | + // TODO: handle exception | ||
| 1180 | + e.printStackTrace(); | ||
| 1181 | + } | ||
| 1123 | } | 1182 | } |
| 1124 | 1183 | ||
| 1125 | return resList; | 1184 | return resList; |
src/main/java/com/bsth/service/schedule/ScheduleRule1FlatService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | 3 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 4 | -import com.bsth.service.BaseService; | ||
| 5 | 4 | ||
| 6 | /** | 5 | /** |
| 7 | * Created by xu on 16/7/4. | 6 | * Created by xu on 16/7/4. |
| 8 | */ | 7 | */ |
| 9 | -public interface ScheduleRule1FlatService extends BaseService<ScheduleRule1Flat, Long> { | 8 | +public interface ScheduleRule1FlatService extends BService<ScheduleRule1Flat, Long> { |
| 10 | } | 9 | } |
src/main/java/com/bsth/service/schedule/ScheduleRule1FlatServiceImpl.java deleted
100644 → 0
| 1 | -package com.bsth.service.schedule; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 4 | -import com.bsth.service.impl.BaseServiceImpl; | ||
| 5 | -import org.springframework.stereotype.Service; | ||
| 6 | - | ||
| 7 | -/** | ||
| 8 | - * Created by xu on 16/7/4. | ||
| 9 | - */ | ||
| 10 | -@Service | ||
| 11 | -public class ScheduleRule1FlatServiceImpl extends BaseServiceImpl<ScheduleRule1Flat, Long> implements ScheduleRule1FlatService { | ||
| 12 | -} |
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.TTInfoDetail; | 3 | import com.bsth.entity.schedule.TTInfoDetail; |
| 4 | -import com.bsth.service.BaseService; | 4 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 5 | import org.apache.commons.lang3.StringUtils; | 5 | import org.apache.commons.lang3.StringUtils; |
| 6 | -import org.springframework.web.multipart.MultipartFile; | ||
| 7 | 6 | ||
| 8 | -import java.io.File; | ||
| 9 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
| 10 | import java.util.List; | 8 | import java.util.List; |
| 11 | 9 | ||
| 12 | /** | 10 | /** |
| 13 | * Created by xu on 16/7/2. | 11 | * Created by xu on 16/7/2. |
| 14 | */ | 12 | */ |
| 15 | -public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | ||
| 16 | - | ||
| 17 | - void deleteByTtinfo(Long ttinfoid); | 13 | +public interface TTInfoDetailService extends BService<TTInfoDetail, Long> { |
| 18 | 14 | ||
| 19 | /** | 15 | /** |
| 20 | * 发车信息内部类。 | 16 | * 发车信息内部类。 |
| @@ -34,7 +30,12 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | @@ -34,7 +30,12 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | ||
| 34 | public FcInfo() { | 30 | public FcInfo() { |
| 35 | } | 31 | } |
| 36 | 32 | ||
| 37 | - public FcInfo(String ttdid_str, String bc_type, String fcsj, String xldir, String isfb) { | 33 | + public FcInfo( |
| 34 | + String ttdid_str, | ||
| 35 | + String bc_type, | ||
| 36 | + String fcsj, | ||
| 37 | + String xldir, | ||
| 38 | + String isfb) { | ||
| 38 | this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); | 39 | this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); |
| 39 | this.bc_type = bc_type; | 40 | this.bc_type = bc_type; |
| 40 | this.fcsj = fcsj; | 41 | this.fcsj = fcsj; |
| @@ -98,6 +99,9 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | @@ -98,6 +99,9 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | ||
| 98 | /** 内容数据 */ | 99 | /** 内容数据 */ |
| 99 | private List<List<FcInfo>> contents = new ArrayList<>(); | 100 | private List<List<FcInfo>> contents = new ArrayList<>(); |
| 100 | 101 | ||
| 102 | + /** 营运描述 */ | ||
| 103 | + private String yy_desc; | ||
| 104 | + | ||
| 101 | public List<String> getHeader() { | 105 | public List<String> getHeader() { |
| 102 | return header; | 106 | return header; |
| 103 | } | 107 | } |
| @@ -113,6 +117,14 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | @@ -113,6 +117,14 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | ||
| 113 | public void setContents(List<List<FcInfo>> contents) { | 117 | public void setContents(List<List<FcInfo>> contents) { |
| 114 | this.contents = contents; | 118 | this.contents = contents; |
| 115 | } | 119 | } |
| 120 | + | ||
| 121 | + public String getYy_desc() { | ||
| 122 | + return yy_desc; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public void setYy_desc(String yy_desc) { | ||
| 126 | + this.yy_desc = yy_desc; | ||
| 127 | + } | ||
| 116 | } | 128 | } |
| 117 | 129 | ||
| 118 | /** | 130 | /** |
| @@ -121,22 +133,28 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | @@ -121,22 +133,28 @@ public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { | ||
| 121 | * @param ttid 时刻表id | 133 | * @param ttid 时刻表id |
| 122 | * @return | 134 | * @return |
| 123 | */ | 135 | */ |
| 124 | - EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception; | 136 | + EditInfo getEditInfo(Integer xlid, Long ttid) throws ScheduleException; |
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * 验证sheet(以后放到规则引擎里去做)。 | ||
| 140 | + * @param filename excel文件全路径名 | ||
| 141 | + * @param sheetname sheet名字 | ||
| 142 | + * @param lineid 线路id | ||
| 143 | + */ | ||
| 144 | + void validateExcelSheet( | ||
| 145 | + String filename, | ||
| 146 | + String sheetname, | ||
| 147 | + Integer lineid, | ||
| 148 | + String linename) throws ScheduleException; | ||
| 125 | 149 | ||
| 126 | /** | 150 | /** |
| 127 | - * 上传并导入数据,和DataImportExportService的同名方法有差别。 | ||
| 128 | - * @param datafile form上传文件 | ||
| 129 | - * @param xlmc 线路名称 | ||
| 130 | - * @param ttinfoname 时刻表名字 | ||
| 131 | - * @param tccname 停车场名字 | ||
| 132 | - * @throws Exception | 151 | + * 验证关联的线路标准信息(以后放到规则引擎里去做)。 |
| 152 | + * @param lineinfoid 线路id | ||
| 133 | */ | 153 | */ |
| 134 | - void fileDataImport(MultipartFile datafile, | ||
| 135 | - String xlmc, | ||
| 136 | - String ttinfoname, | ||
| 137 | - String tccname) throws Exception; | 154 | + void validateAssoLineInfo(Integer lineinfoid) throws ScheduleException; |
| 138 | 155 | ||
| 139 | - void fileDataImport(File file, String sheetname, String xlmc, String ttinfoname, String tccname) throws Exception; | 156 | + // TODO:这个方法可以用通用方法解决,以后改 |
| 157 | + List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); | ||
| 140 | 158 | ||
| 141 | 159 | ||
| 142 | } | 160 | } |
src/main/java/com/bsth/service/schedule/TTInfoDetailServiceImpl.java deleted
100644 → 0
| 1 | -package com.bsth.service.schedule; | ||
| 2 | - | ||
| 3 | -import com.bsth.entity.schedule.TTInfoDetail; | ||
| 4 | -import com.bsth.repository.schedule.TTInfoDetailRepository; | ||
| 5 | -import com.bsth.service.impl.BaseServiceImpl; | ||
| 6 | -import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 7 | -import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 8 | -import jxl.Sheet; | ||
| 9 | -import jxl.Workbook; | ||
| 10 | -import org.apache.commons.lang3.StringUtils; | ||
| 11 | -import org.joda.time.DateTime; | ||
| 12 | -import org.pentaho.di.trans.Trans; | ||
| 13 | -import org.pentaho.di.trans.TransMeta; | ||
| 14 | -import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | -import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 16 | -import org.springframework.stereotype.Service; | ||
| 17 | -import org.springframework.transaction.annotation.Isolation; | ||
| 18 | -import org.springframework.transaction.annotation.Propagation; | ||
| 19 | -import org.springframework.transaction.annotation.Transactional; | ||
| 20 | -import org.springframework.web.multipart.MultipartFile; | ||
| 21 | - | ||
| 22 | -import java.io.File; | ||
| 23 | -import java.util.ArrayList; | ||
| 24 | -import java.util.Arrays; | ||
| 25 | -import java.util.List; | ||
| 26 | - | ||
| 27 | -/** | ||
| 28 | - * Created by xu on 16/7/2. | ||
| 29 | - */ | ||
| 30 | -@Service | ||
| 31 | -@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 32 | -public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> implements TTInfoDetailService { | ||
| 33 | - @Autowired | ||
| 34 | - private DataImportExportService dataImportExportService; | ||
| 35 | - @Autowired | ||
| 36 | - private DataToolsProperties dataToolsProperties; | ||
| 37 | - @Autowired | ||
| 38 | - private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 39 | - | ||
| 40 | - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | ||
| 41 | - @Override | ||
| 42 | - public void deleteByTtinfo(Long ttinfoid) { | ||
| 43 | - ttInfoDetailRepository.deleteByTtinfo(ttinfoid); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * 获取待编辑的数据。 | ||
| 48 | - * @param xlid 线路id | ||
| 49 | - * @param ttid 时刻表id | ||
| 50 | - * @return | ||
| 51 | - */ | ||
| 52 | - @Override | ||
| 53 | - public EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception { | ||
| 54 | - // 1、使用ktr转换获取输出文件 | ||
| 55 | - // 1.1、获取转换用ktr | ||
| 56 | - File ktrFile = new File(this.getClass().getResource( | ||
| 57 | - dataToolsProperties.getTtinfodetailForeditktr()).toURI()); | ||
| 58 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | ||
| 59 | - Trans trans = new Trans(transMeta); | ||
| 60 | -// trans.setLogLevel(LogLevel.DEBUG); | ||
| 61 | - // 1.2、设定命名参数,TODO:之后还要添加其他命名参数 | ||
| 62 | - String outputFilePath = "ttinfodetail_" + new DateTime().toString("yyyy-MM-dd_HH-mm-ss"); | ||
| 63 | - trans.setParameterValue("tempfilepath", dataToolsProperties.getTransTempdir() + File.separator + outputFilePath); // 数据输出文件路径 | ||
| 64 | - trans.setParameterValue("xlid", String.valueOf(xlid)); | ||
| 65 | - trans.setParameterValue("ttid", String.valueOf(ttid)); | ||
| 66 | - // 1.3、执行转换 | ||
| 67 | - trans.execute(null); | ||
| 68 | - // 1.4、等待转换结束 | ||
| 69 | - trans.waitUntilFinished(); | ||
| 70 | - | ||
| 71 | - // 1.5、判定ktr错误数,注意这种错误代表部分数据错误,不会终止转换执行,一般设计ktr的时候,会有错误输出文件,TODO:以后考虑使用日志实时输出 | ||
| 72 | - if (trans.getErrors() > 0) { | ||
| 73 | - throw new Exception("转换数据部分错误,请查看相关错误输出文件!"); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - // 1.6、获取最大的发车数,用于输出数据的数量 | ||
| 77 | - Long maxfcno = ttInfoDetailRepository.findMaxFcno(xlid, ttid); | ||
| 78 | - if (maxfcno == null) | ||
| 79 | - return new EditInfo(); | ||
| 80 | - | ||
| 81 | - // 2、读取ktr生成的excel数据,组织编辑用数据返回 | ||
| 82 | - // 2-1、读取Excel文件 | ||
| 83 | - Workbook book = Workbook.getWorkbook(new File(dataToolsProperties.getTransTempdir() + | ||
| 84 | - File.separator + outputFilePath + ".xls")); | ||
| 85 | - Sheet sheet = book.getSheet(0); | ||
| 86 | - EditInfo editInfo = new EditInfo(); | ||
| 87 | - // 2-2、处理数据 | ||
| 88 | - String[] headarrays = new String[maxfcno.intValue() + 1]; | ||
| 89 | - headarrays[0] = "路牌"; | ||
| 90 | - for (int r = 1; r < sheet.getRows(); r++) { | ||
| 91 | - List<FcInfo> fcInfos = new ArrayList<>(); | ||
| 92 | - // 每行第一列都是路牌 | ||
| 93 | - fcInfos.add(new FcInfo(null, null, sheet.getCell(0, r).getContents(), null, null)); // 用fcsj放置路牌显示 | ||
| 94 | - for (int c = 1; c <= maxfcno * 6; ) { | ||
| 95 | - String ttdid_str = sheet.getCell(c, r).getContents(); // 时刻表明细id | ||
| 96 | - String fcsj = sheet.getCell(c + 1, r).getContents(); // 发车时间 | ||
| 97 | - String fzdname = sheet.getCell(c + 2, r).getContents(); // 发车站点名称 | ||
| 98 | - String bctype = sheet.getCell(c + 3, r).getContents(); // 班次类型 | ||
| 99 | - String xldir = sheet.getCell(c + 4, r).getContents(); // 线路上下行 | ||
| 100 | - String isfb = sheet.getCell(c + 5, r).getContents(); // 是否分班 | ||
| 101 | - | ||
| 102 | - FcInfo fcInfo = new FcInfo(ttdid_str, bctype, fcsj, xldir, isfb); | ||
| 103 | - | ||
| 104 | - if (StringUtils.isNotEmpty(fzdname)) | ||
| 105 | - headarrays[(int)(c / 6) + 1] = fzdname; | ||
| 106 | - fcInfos.add(fcInfo); | ||
| 107 | - | ||
| 108 | - c += 6; | ||
| 109 | - } | ||
| 110 | - editInfo.getContents().add(fcInfos); | ||
| 111 | - } | ||
| 112 | - editInfo.getHeader().addAll(Arrays.asList(headarrays)); | ||
| 113 | - | ||
| 114 | - return editInfo; | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | - @Override | ||
| 118 | - /** | ||
| 119 | - * 上传并导入数据,和DataImportExportService的同名方法有差别。 | ||
| 120 | - * @param datafile form上传文件 | ||
| 121 | - * @param xlmc 线路名称 | ||
| 122 | - * @param ttinfoname 时刻表名字 | ||
| 123 | - * @param tccname 停车场名字 | ||
| 124 | - * @throws Exception | ||
| 125 | - */ | ||
| 126 | - public void fileDataImport(MultipartFile datafile, | ||
| 127 | - String xlmc, | ||
| 128 | - String ttinfoname, | ||
| 129 | - String tccname) throws Exception { | ||
| 130 | - // 上传数据文件 | ||
| 131 | - File uploadFile = dataImportExportService.uploadFile(datafile); | ||
| 132 | - fileDataImport(uploadFile, "工作表1", xlmc, ttinfoname, tccname); | ||
| 133 | - | ||
| 134 | - } | ||
| 135 | - | ||
| 136 | - @Override | ||
| 137 | - public void fileDataImport(File uploadFile, String sheetname, String xlmc, String ttinfoname, String tccname) throws Exception { | ||
| 138 | - // 1、上传数据文件 | ||
| 139 | - System.out.println("线路名称:" + xlmc); | ||
| 140 | - System.out.println("时刻表名称:" + ttinfoname); | ||
| 141 | - System.out.println("停车场名字:" + tccname); | ||
| 142 | - System.out.println("时刻表明细上传文件:" + uploadFile); | ||
| 143 | - | ||
| 144 | - // 2、jexcelapi读取excel文件 | ||
| 145 | - Workbook book = Workbook.getWorkbook(uploadFile); | ||
| 146 | - Sheet sheet = book.getSheet(0); | ||
| 147 | - List<String> columnames = new ArrayList<>(); | ||
| 148 | - for (int i = 0; i < sheet.getColumns(); i++) { // 获取第一行,数据,作为列名 | ||
| 149 | - columnames.add(sheet.getCell(i, 0).getContents()); | ||
| 150 | - } | ||
| 151 | - | ||
| 152 | - System.out.println("表头1:" + StringUtils.join(columnames.toArray(), ",")); | ||
| 153 | - | ||
| 154 | - // 2、使用kettle运行封装数据导入逻辑的ktr转换文件 | ||
| 155 | - // 2.1、初始化kettle(组件初始化已经做了) | ||
| 156 | - // 2.2、创建转换元数据,转换 | ||
| 157 | - File ktrFile = new File(this.getClass().getResource( | ||
| 158 | - dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); | ||
| 159 | - File ktrFile2 = new File(this.getClass().getResource( | ||
| 160 | - dataToolsProperties.getTtinfodetailDatainputktr()).toURI()); | ||
| 161 | - TransMeta transMeta = new TransMeta(ktrFile.getAbsolutePath()); | ||
| 162 | - Trans trans = new Trans(transMeta); | ||
| 163 | - // 2.3、设定命名参数,用于指定数据文件,注意每个ktr必须都有以下指定的命名参数 | ||
| 164 | - trans.setParameterValue("injectktrfile", ktrFile2.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 165 | - trans.setParameterValue("filepath", uploadFile.getAbsolutePath()); // 指定导入数据文件的位置 | ||
| 166 | - trans.setParameterValue("sheetname", sheetname); // sheet工作区的名字 | ||
| 167 | - trans.setParameterValue("erroroutputdir", dataToolsProperties.getTransErrordir()); // ktr转换错误输出目录 | ||
| 168 | - trans.setParameterValue("xlname", xlmc); // 线路名称 | ||
| 169 | - trans.setParameterValue("ttinfoname", ttinfoname); // 时刻表名称 | ||
| 170 | - trans.setParameterValue("tccname", tccname); // 停车场名字 | ||
| 171 | - trans.setParameterValue("excelfieldnames", StringUtils.join(columnames.toArray(), ",")); // 时刻表excel输入字段名,以逗号连接 | ||
| 172 | - columnames.remove(0); | ||
| 173 | - trans.setParameterValue("normalizefieldnames", StringUtils.join(columnames.toArray(), ",")); // 数据范式化字段名,以逗号连接 | ||
| 174 | - | ||
| 175 | - // TODO:可以考虑设定日志输出 | ||
| 176 | - // 2.4、执行转换 | ||
| 177 | - trans.execute(null); | ||
| 178 | - // 2.5、等待转换结束 | ||
| 179 | - trans.waitUntilFinished(); | ||
| 180 | - | ||
| 181 | - // 3、判定ktr错误数,注意这种错误代表部分数据错误,不会终止转换执行,一般设计ktr的时候,会有错误输出文件,TODO:以后考虑使用日志实时输出 | ||
| 182 | - if (trans.getErrors() > 0) { | ||
| 183 | - throw new Exception("转换数据部分错误,请查看相关错误输出文件!"); | ||
| 184 | - } | ||
| 185 | - } | ||
| 186 | -} |
src/main/java/com/bsth/service/schedule/TTInfoService.java
| 1 | package com.bsth.service.schedule; | 1 | package com.bsth.service.schedule; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.TTInfo; | 3 | import com.bsth.entity.schedule.TTInfo; |
| 4 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | 5 | ||
| 5 | /** | 6 | /** |
| 6 | * Created by xu on 16/5/12. | 7 | * Created by xu on 16/5/12. |
src/main/java/com/bsth/service/schedule/ScheduleException.java renamed to src/main/java/com/bsth/service/schedule/exception/ScheduleException.java
src/main/java/com/bsth/service/schedule/impl/BServiceImpl.java
| @@ -3,16 +3,19 @@ package com.bsth.service.schedule.impl; | @@ -3,16 +3,19 @@ package com.bsth.service.schedule.impl; | ||
| 3 | import com.bsth.entity.search.CustomerSpecs; | 3 | import com.bsth.entity.search.CustomerSpecs; |
| 4 | import com.bsth.repository.BaseRepository; | 4 | import com.bsth.repository.BaseRepository; |
| 5 | import com.bsth.service.schedule.BService; | 5 | import com.bsth.service.schedule.BService; |
| 6 | -import com.bsth.service.schedule.ScheduleException; | 6 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | +import com.bsth.service.schedule.utils.DataToolsService; | ||
| 7 | import org.slf4j.Logger; | 8 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 9 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 10 | import org.springframework.beans.factory.annotation.Autowired; |
| 11 | +import org.springframework.beans.factory.annotation.Qualifier; | ||
| 10 | import org.springframework.beans.factory.annotation.Value; | 12 | import org.springframework.beans.factory.annotation.Value; |
| 11 | import org.springframework.data.domain.Page; | 13 | import org.springframework.data.domain.Page; |
| 12 | import org.springframework.data.domain.Pageable; | 14 | import org.springframework.data.domain.Pageable; |
| 13 | import org.springframework.data.jpa.domain.Specification; | 15 | import org.springframework.data.jpa.domain.Specification; |
| 14 | 16 | ||
| 15 | import javax.persistence.EntityManager; | 17 | import javax.persistence.EntityManager; |
| 18 | +import java.io.File; | ||
| 16 | import java.io.Serializable; | 19 | import java.io.Serializable; |
| 17 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
| 18 | import java.util.List; | 21 | import java.util.List; |
| @@ -29,6 +32,10 @@ public class BServiceImpl<T, ID extends Serializable> implements BService<T, ID> | @@ -29,6 +32,10 @@ public class BServiceImpl<T, ID extends Serializable> implements BService<T, ID> | ||
| 29 | @Value("${hibernate.jdbc.batch_size}") | 32 | @Value("${hibernate.jdbc.batch_size}") |
| 30 | private int batchSize; | 33 | private int batchSize; |
| 31 | 34 | ||
| 35 | + @Autowired | ||
| 36 | + @Qualifier(value = "dataToolsServiceImpl") | ||
| 37 | + private DataToolsService dataToolsService; | ||
| 38 | + | ||
| 32 | /** 日志记录器 */ | 39 | /** 日志记录器 */ |
| 33 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); | 40 | protected Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 34 | 41 | ||
| @@ -108,4 +115,19 @@ public class BServiceImpl<T, ID extends Serializable> implements BService<T, ID> | @@ -108,4 +115,19 @@ public class BServiceImpl<T, ID extends Serializable> implements BService<T, ID> | ||
| 108 | 115 | ||
| 109 | baseRepository.delete(id); | 116 | baseRepository.delete(id); |
| 110 | } | 117 | } |
| 118 | + | ||
| 119 | + @Override | ||
| 120 | + public File uploadFile(String filename, byte[] filedata) throws ScheduleException { | ||
| 121 | + return dataToolsService.uploadFile(filename, filedata); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + @Override | ||
| 125 | + public void importData(File file, Map<String, Object> params) throws ScheduleException { | ||
| 126 | + dataToolsService.importData(file, params); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Override | ||
| 130 | + public File exportData(Map<String, Object> params) throws ScheduleException { | ||
| 131 | + return dataToolsService.exportData(params); | ||
| 132 | + } | ||
| 111 | } | 133 | } |
src/main/java/com/bsth/service/schedule/impl/CarConfigInfoServiceImpl.java
| @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | ||
| 3 | import com.bsth.entity.schedule.CarConfigInfo; | 3 | import com.bsth.entity.schedule.CarConfigInfo; |
| 4 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | 4 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 5 | import com.bsth.service.schedule.CarConfigInfoService; | 5 | import com.bsth.service.schedule.CarConfigInfoService; |
| 6 | -import com.bsth.service.schedule.ScheduleException; | 6 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | import com.bsth.service.schedule.ScheduleRule1FlatService; | 7 | import com.bsth.service.schedule.ScheduleRule1FlatService; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
src/main/java/com/bsth/service/schedule/impl/CarDeviceServiceImpl.java
| @@ -4,7 +4,7 @@ import com.bsth.entity.CarDevice; | @@ -4,7 +4,7 @@ import com.bsth.entity.CarDevice; | ||
| 4 | import com.bsth.entity.Cars; | 4 | import com.bsth.entity.Cars; |
| 5 | import com.bsth.service.CarsService; | 5 | import com.bsth.service.CarsService; |
| 6 | import com.bsth.service.schedule.CarDeviceService; | 6 | import com.bsth.service.schedule.CarDeviceService; |
| 7 | -import com.bsth.service.schedule.ScheduleException; | 7 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
| 10 | import org.springframework.transaction.annotation.Transactional; | 10 | import org.springframework.transaction.annotation.Transactional; |
src/main/java/com/bsth/service/schedule/impl/CarsServiceImpl.java
| @@ -2,19 +2,91 @@ package com.bsth.service.schedule.impl; | @@ -2,19 +2,91 @@ package com.bsth.service.schedule.impl; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.Cars; | 3 | import com.bsth.entity.Cars; |
| 4 | import com.bsth.service.schedule.CarsService; | 4 | import com.bsth.service.schedule.CarsService; |
| 5 | -import com.bsth.service.schedule.ScheduleException; | 5 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 6 | +import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 6 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| 8 | import org.springframework.util.CollectionUtils; | 13 | import org.springframework.util.CollectionUtils; |
| 9 | 14 | ||
| 15 | +import java.io.File; | ||
| 16 | +import java.io.PrintWriter; | ||
| 17 | +import java.io.StringWriter; | ||
| 10 | import java.util.HashMap; | 18 | import java.util.HashMap; |
| 11 | import java.util.Map; | 19 | import java.util.Map; |
| 12 | 20 | ||
| 13 | /** | 21 | /** |
| 14 | * Created by xu on 16/12/8. | 22 | * Created by xu on 16/12/8. |
| 15 | */ | 23 | */ |
| 24 | +@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 16 | @Service(value = "carsServiceImpl_sc") | 25 | @Service(value = "carsServiceImpl_sc") |
| 17 | public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements CarsService { | 26 | public class CarsServiceImpl extends BServiceImpl<Cars, Integer> implements CarsService { |
| 27 | + /** 日志记录器 */ | ||
| 28 | + private static final Logger LOGGER = LoggerFactory.getLogger(CarsServiceImpl.class); | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + private DataToolsProperties dataToolsProperties; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public void importData(File file, Map<String, Object> params) throws ScheduleException { | ||
| 35 | + try { | ||
| 36 | + LOGGER.info("//---------------- 导入车辆基础信息 start... ----------------//"); | ||
| 37 | + // 创建ktr转换所需参数 | ||
| 38 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 39 | + File ktrFile = new File(this.getClass().getResource( | ||
| 40 | + dataToolsProperties.getCarsDatainputktr()).toURI()); | ||
| 41 | + | ||
| 42 | + // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | ||
| 43 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 44 | + ktrParms.put("filepath", file.getAbsolutePath()); | ||
| 45 | + ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | ||
| 46 | + | ||
| 47 | + super.importData(file, ktrParms); | ||
| 48 | + | ||
| 49 | + LOGGER.info("//---------------- 导入车辆基础信息 success... ----------------//"); | ||
| 50 | + } catch (Exception exp) { | ||
| 51 | + LOGGER.info("//---------------- 导入车辆基础信息 failed... ----------------//"); | ||
| 52 | + | ||
| 53 | + StringWriter sw = new StringWriter(); | ||
| 54 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 55 | + LOGGER.info(sw.toString()); | ||
| 56 | + | ||
| 57 | + throw new ScheduleException(exp.getMessage()); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public File exportData(Map<String, Object> params) throws ScheduleException { | ||
| 63 | + try { | ||
| 64 | + LOGGER.info("//---------------- 导出车辆基础信息 start... ----------------//"); | ||
| 65 | + // 创建ktr转换所需参数 | ||
| 66 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 67 | + File ktrFile = new File(this.getClass().getResource( | ||
| 68 | + dataToolsProperties.getCarsDataoutputktr()).toURI()); | ||
| 69 | + | ||
| 70 | + // 通用参数,转换文件路径,excel输出文件名 | ||
| 71 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 72 | + ktrParms.put("filename", "车辆基础信息_download-"); | ||
| 73 | + | ||
| 74 | + File file = super.exportData(ktrParms); | ||
| 75 | + | ||
| 76 | + LOGGER.info("//---------------- 导出车辆基础信息 success... ----------------//"); | ||
| 77 | + | ||
| 78 | + return file; | ||
| 79 | + | ||
| 80 | + } catch (Exception exp) { | ||
| 81 | + LOGGER.info("//---------------- 导出车辆基础信息 failed... ----------------//"); | ||
| 82 | + | ||
| 83 | + StringWriter sw = new StringWriter(); | ||
| 84 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 85 | + LOGGER.info(sw.toString()); | ||
| 86 | + | ||
| 87 | + throw new ScheduleException(exp.getMessage()); | ||
| 88 | + } | ||
| 89 | + } | ||
| 18 | 90 | ||
| 19 | @Override | 91 | @Override |
| 20 | @Transactional | 92 | @Transactional |
src/main/java/com/bsth/service/schedule/impl/EmployeeConfigInfoServiceImpl.java
| @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | ||
| 3 | import com.bsth.entity.schedule.EmployeeConfigInfo; | 3 | import com.bsth.entity.schedule.EmployeeConfigInfo; |
| 4 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | 4 | import com.bsth.entity.schedule.rule.ScheduleRule1Flat; |
| 5 | import com.bsth.service.schedule.EmployeeConfigInfoService; | 5 | import com.bsth.service.schedule.EmployeeConfigInfoService; |
| 6 | -import com.bsth.service.schedule.ScheduleException; | 6 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | import com.bsth.service.schedule.ScheduleRule1FlatService; | 7 | import com.bsth.service.schedule.ScheduleRule1FlatService; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
src/main/java/com/bsth/service/schedule/impl/EmployeeServiceImpl.java
| @@ -2,19 +2,92 @@ package com.bsth.service.schedule.impl; | @@ -2,19 +2,92 @@ package com.bsth.service.schedule.impl; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.Personnel; | 3 | import com.bsth.entity.Personnel; |
| 4 | import com.bsth.service.schedule.EmployeeService; | 4 | import com.bsth.service.schedule.EmployeeService; |
| 5 | -import com.bsth.service.schedule.ScheduleException; | 5 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 6 | +import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 6 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.transaction.annotation.Transactional; | 12 | import org.springframework.transaction.annotation.Transactional; |
| 8 | import org.springframework.util.CollectionUtils; | 13 | import org.springframework.util.CollectionUtils; |
| 9 | 14 | ||
| 15 | +import java.io.File; | ||
| 16 | +import java.io.PrintWriter; | ||
| 17 | +import java.io.StringWriter; | ||
| 10 | import java.util.HashMap; | 18 | import java.util.HashMap; |
| 11 | import java.util.Map; | 19 | import java.util.Map; |
| 12 | 20 | ||
| 13 | /** | 21 | /** |
| 14 | * Created by xu on 16/12/15. | 22 | * Created by xu on 16/12/15. |
| 15 | */ | 23 | */ |
| 24 | +@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 16 | @Service | 25 | @Service |
| 17 | public class EmployeeServiceImpl extends BServiceImpl<Personnel, Integer> implements EmployeeService { | 26 | public class EmployeeServiceImpl extends BServiceImpl<Personnel, Integer> implements EmployeeService { |
| 27 | + /** 日志记录器 */ | ||
| 28 | + private static final Logger LOGGER = LoggerFactory.getLogger(EmployeeServiceImpl.class); | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + private DataToolsProperties dataToolsProperties; | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public void importData(File file, Map<String, Object> params) throws ScheduleException { | ||
| 35 | + try { | ||
| 36 | + LOGGER.info("//---------------- 导入人员基础信息 start... ----------------//"); | ||
| 37 | + // 创建ktr转换所需参数 | ||
| 38 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 39 | + File ktrFile = new File(this.getClass().getResource( | ||
| 40 | + dataToolsProperties.getEmployeesDatainputktr()).toURI()); | ||
| 41 | + | ||
| 42 | + // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | ||
| 43 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 44 | + ktrParms.put("filepath", file.getAbsolutePath()); | ||
| 45 | + ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | ||
| 46 | + | ||
| 47 | + super.importData(file, ktrParms); | ||
| 48 | + | ||
| 49 | + LOGGER.info("//---------------- 导入人员基础信息 success... ----------------//"); | ||
| 50 | + } catch (Exception exp) { | ||
| 51 | + LOGGER.info("//---------------- 导入人员基础信息 failed... ----------------//"); | ||
| 52 | + | ||
| 53 | + StringWriter sw = new StringWriter(); | ||
| 54 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 55 | + LOGGER.info(sw.toString()); | ||
| 56 | + | ||
| 57 | + throw new ScheduleException(exp.getMessage()); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public File exportData(Map<String, Object> params) throws ScheduleException { | ||
| 63 | + try { | ||
| 64 | + LOGGER.info("//---------------- 导出人员基础信息 start... ----------------//"); | ||
| 65 | + // 创建ktr转换所需参数 | ||
| 66 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 67 | + File ktrFile = new File(this.getClass().getResource( | ||
| 68 | + dataToolsProperties.getEmployeesDataoutputktr()).toURI()); | ||
| 69 | + | ||
| 70 | + // 通用参数,转换文件路径,excel输出文件名 | ||
| 71 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 72 | + ktrParms.put("filename", "人员基础信息_download-"); | ||
| 73 | + | ||
| 74 | + File file = super.exportData(ktrParms); | ||
| 75 | + | ||
| 76 | + LOGGER.info("//---------------- 导出人员基础信息 success... ----------------//"); | ||
| 77 | + | ||
| 78 | + return file; | ||
| 79 | + | ||
| 80 | + } catch (Exception exp) { | ||
| 81 | + LOGGER.info("//---------------- 导出人员基础信息 failed... ----------------//"); | ||
| 82 | + | ||
| 83 | + StringWriter sw = new StringWriter(); | ||
| 84 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 85 | + LOGGER.info(sw.toString()); | ||
| 86 | + | ||
| 87 | + throw new ScheduleException(exp.getMessage()); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 18 | @Override | 91 | @Override |
| 19 | @Transactional | 92 | @Transactional |
| 20 | public void validate_gh(Personnel personnel) throws ScheduleException { | 93 | public void validate_gh(Personnel personnel) throws ScheduleException { |
src/main/java/com/bsth/service/schedule/impl/GuideboardInfoServiceImpl.java
| @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | @@ -3,7 +3,7 @@ package com.bsth.service.schedule.impl; | ||
| 3 | import com.bsth.entity.schedule.GuideboardInfo; | 3 | import com.bsth.entity.schedule.GuideboardInfo; |
| 4 | import com.bsth.entity.schedule.TTInfoDetail; | 4 | import com.bsth.entity.schedule.TTInfoDetail; |
| 5 | import com.bsth.service.schedule.GuideboardInfoService; | 5 | import com.bsth.service.schedule.GuideboardInfoService; |
| 6 | -import com.bsth.service.schedule.ScheduleException; | 6 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 7 | import com.bsth.service.schedule.TTInfoDetailService; | 7 | import com.bsth.service.schedule.TTInfoDetailService; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| 9 | import org.springframework.stereotype.Service; | 9 | import org.springframework.stereotype.Service; |
src/main/java/com/bsth/service/schedule/impl/RerunServiceImpl.java
| @@ -2,7 +2,7 @@ package com.bsth.service.schedule.impl; | @@ -2,7 +2,7 @@ package com.bsth.service.schedule.impl; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.schedule.rule.RerunRule; | 3 | import com.bsth.entity.schedule.rule.RerunRule; |
| 4 | import com.bsth.service.schedule.RerunService; | 4 | import com.bsth.service.schedule.RerunService; |
| 5 | -import com.bsth.service.schedule.ScheduleException; | 5 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 6 | import org.springframework.stereotype.Service; | 6 | import org.springframework.stereotype.Service; |
| 7 | import org.springframework.transaction.annotation.Transactional; | 7 | import org.springframework.transaction.annotation.Transactional; |
| 8 | 8 |
src/main/java/com/bsth/service/schedule/impl/ScheduleRule1FlatServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.schedule.impl; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.schedule.rule.ScheduleRule1Flat; | ||
| 4 | +import com.bsth.service.schedule.ScheduleRule1FlatService; | ||
| 5 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 6 | +import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 11 | +import org.springframework.stereotype.Service; | ||
| 12 | + | ||
| 13 | +import java.io.File; | ||
| 14 | +import java.io.PrintWriter; | ||
| 15 | +import java.io.StringWriter; | ||
| 16 | +import java.util.HashMap; | ||
| 17 | +import java.util.Map; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * Created by xu on 16/7/4. | ||
| 21 | + */ | ||
| 22 | +@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 23 | +@Service | ||
| 24 | +public class ScheduleRule1FlatServiceImpl extends BServiceImpl<ScheduleRule1Flat, Long> implements ScheduleRule1FlatService { | ||
| 25 | + /** 日志记录器 */ | ||
| 26 | + private static Logger LOGGER = LoggerFactory.getLogger(ScheduleRule1FlatServiceImpl.class); | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + private DataToolsProperties dataToolsProperties; | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public void importData(File file, Map<String, Object> params) throws ScheduleException { | ||
| 33 | + try { | ||
| 34 | + LOGGER.info("//---------------- 导入排版规则信息 start... ----------------//"); | ||
| 35 | + // 创建ktr转换所需参数 | ||
| 36 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 37 | + File ktrFile = new File(this.getClass().getResource( | ||
| 38 | + dataToolsProperties.getScheduleruleDatainputktr()).toURI()); | ||
| 39 | + | ||
| 40 | + // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | ||
| 41 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 42 | + ktrParms.put("filepath", file.getAbsolutePath()); | ||
| 43 | + ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | ||
| 44 | + | ||
| 45 | + super.importData(file, ktrParms); | ||
| 46 | + | ||
| 47 | + LOGGER.info("//---------------- 导入排版规则信息 success... ----------------//"); | ||
| 48 | + } catch (Exception exp) { | ||
| 49 | + LOGGER.info("//---------------- 导入排版规则信息 failed... ----------------//"); | ||
| 50 | + | ||
| 51 | + StringWriter sw = new StringWriter(); | ||
| 52 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 53 | + LOGGER.info(sw.toString()); | ||
| 54 | + | ||
| 55 | + throw new ScheduleException(exp.getMessage()); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + public File exportData(Map<String, Object> params) throws ScheduleException { | ||
| 61 | + try { | ||
| 62 | + LOGGER.info("//---------------- 导出排版规则信息 start... ----------------//"); | ||
| 63 | + // 创建ktr转换所需参数 | ||
| 64 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 65 | + File ktrFile = new File(this.getClass().getResource( | ||
| 66 | + dataToolsProperties.getScheduleruleOutput()).toURI()); | ||
| 67 | + | ||
| 68 | + // 通用参数,转换文件路径,excel输出文件名 | ||
| 69 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 70 | + ktrParms.put("filename", "排版规则信息_download-"); | ||
| 71 | + | ||
| 72 | + File file = super.exportData(ktrParms); | ||
| 73 | + | ||
| 74 | + LOGGER.info("//---------------- 导出排版规则信息 success... ----------------//"); | ||
| 75 | + | ||
| 76 | + return file; | ||
| 77 | + | ||
| 78 | + } catch (Exception exp) { | ||
| 79 | + LOGGER.info("//---------------- 导出排版规则信息 failed... ----------------//"); | ||
| 80 | + | ||
| 81 | + StringWriter sw = new StringWriter(); | ||
| 82 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 83 | + LOGGER.info(sw.toString()); | ||
| 84 | + | ||
| 85 | + throw new ScheduleException(exp.getMessage()); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | +} |
src/main/java/com/bsth/service/schedule/impl/TTInfoDetailServiceImpl.java
0 → 100644
| 1 | +package com.bsth.service.schedule.impl; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.CarPark; | ||
| 4 | +import com.bsth.entity.LineInformation; | ||
| 5 | +import com.bsth.entity.StationRoute; | ||
| 6 | +import com.bsth.entity.schedule.GuideboardInfo; | ||
| 7 | +import com.bsth.entity.schedule.TTInfoDetail; | ||
| 8 | +import com.bsth.repository.schedule.TTInfoDetailRepository; | ||
| 9 | +import com.bsth.service.CarParkService; | ||
| 10 | +import com.bsth.service.LineInformationService; | ||
| 11 | +import com.bsth.service.StationRouteService; | ||
| 12 | +import com.bsth.service.schedule.GuideboardInfoService; | ||
| 13 | +import com.bsth.service.schedule.TTInfoDetailService; | ||
| 14 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 15 | +import com.bsth.service.schedule.utils.DataToolsProperties; | ||
| 16 | +import jxl.Cell; | ||
| 17 | +import jxl.Sheet; | ||
| 18 | +import jxl.Workbook; | ||
| 19 | +import jxl.write.Label; | ||
| 20 | +import jxl.write.WritableSheet; | ||
| 21 | +import jxl.write.WritableWorkbook; | ||
| 22 | +import org.apache.commons.lang3.StringUtils; | ||
| 23 | +import org.joda.time.DateTime; | ||
| 24 | +import org.slf4j.Logger; | ||
| 25 | +import org.slf4j.LoggerFactory; | ||
| 26 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 27 | +import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| 28 | +import org.springframework.stereotype.Service; | ||
| 29 | +import org.springframework.util.CollectionUtils; | ||
| 30 | + | ||
| 31 | +import java.io.File; | ||
| 32 | +import java.io.PrintWriter; | ||
| 33 | +import java.io.StringWriter; | ||
| 34 | +import java.util.*; | ||
| 35 | +import java.util.regex.Matcher; | ||
| 36 | +import java.util.regex.Pattern; | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * Created by xu on 17/1/3. | ||
| 40 | + */ | ||
| 41 | +@Service | ||
| 42 | +@EnableConfigurationProperties(DataToolsProperties.class) | ||
| 43 | +public class TTInfoDetailServiceImpl extends BServiceImpl<TTInfoDetail, Long> implements TTInfoDetailService { | ||
| 44 | + /** 日志记录器 */ | ||
| 45 | + private static final Logger LOGGER = LoggerFactory.getLogger(TTInfoDetailServiceImpl.class); | ||
| 46 | + | ||
| 47 | + @Autowired | ||
| 48 | + private GuideboardInfoService guideboardInfoService; | ||
| 49 | + @Autowired | ||
| 50 | + private StationRouteService stationRouteService; | ||
| 51 | + @Autowired | ||
| 52 | + private LineInformationService lineInformationService; | ||
| 53 | + @Autowired | ||
| 54 | + private CarParkService carParkService; | ||
| 55 | + @Autowired | ||
| 56 | + private TTInfoDetailRepository ttInfoDetailRepository; | ||
| 57 | + @Autowired | ||
| 58 | + private DataToolsProperties dataToolsProperties; | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public TTInfoDetail findById(Long aLong) { | ||
| 62 | + return ttInfoDetailRepository.findOneExtend(aLong); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public void importData( | ||
| 67 | + File file, | ||
| 68 | + Map<String, Object> params) throws ScheduleException { | ||
| 69 | + | ||
| 70 | + try { | ||
| 71 | + LOGGER.info("//---------------- 导入时刻表明细 start... ----------------//"); | ||
| 72 | + | ||
| 73 | + String filename = file.getAbsolutePath(); // xls文件名 | ||
| 74 | + String sheetname = String.valueOf(params.get("sheetname")); // sheet名字 | ||
| 75 | + Long ttid = Long.valueOf(String.valueOf(params.get("ttid"))); // 时刻表id | ||
| 76 | + Long xlid = Long.valueOf(String.valueOf(params.get("xlid"))); // 线路id | ||
| 77 | + Integer lineid = Integer.valueOf(String.valueOf(params.get("lineinfo"))); // 线路标准id | ||
| 78 | + String xlname = String.valueOf(params.get("xlname")); // 线路名字 | ||
| 79 | + String ttname = String.valueOf(params.get("ttname")); // 时刻表名字 | ||
| 80 | + | ||
| 81 | + LOGGER.info("参数1, xls文件名={},sheet名字={}", filename, sheetname); | ||
| 82 | + LOGGER.info("参数2, 线路id={},线路名字={}", xlid, xlname); | ||
| 83 | + LOGGER.info("参数3, 时刻表id={},时刻表名字={}", ttid, ttname); | ||
| 84 | + | ||
| 85 | + LOGGER.info("转换xls文件格式成文本格式..."); | ||
| 86 | + // 1、修改已经上传的excel文件,在每个起点站后标示数字,表示第几个班次 | ||
| 87 | + // 2、由于格式问题,需要把内容都转换成字符串 | ||
| 88 | + List<String> colList = new ArrayList<>(); | ||
| 89 | + Workbook workbook = Workbook.getWorkbook(new File(filename)); | ||
| 90 | + Sheet sheet = workbook.getSheet(sheetname); | ||
| 91 | + Cell[] cells = sheet.getRow(0); | ||
| 92 | + for (int i = 0; i < cells.length; i++) { | ||
| 93 | + if (i == 0) { | ||
| 94 | + colList.add(cells[i].getContents().trim()); | ||
| 95 | + } else { | ||
| 96 | + colList.add(cells[i].getContents() + i); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + File fileCal = new File(filename + "_stringType.xls"); | ||
| 101 | + WritableWorkbook writableWorkbook = Workbook.createWorkbook(fileCal, workbook); | ||
| 102 | + WritableSheet sheet1 = writableWorkbook.getSheet(sheetname); | ||
| 103 | + for (int i = 0; i < sheet1.getColumns(); i++) { // 第一行数据 | ||
| 104 | + sheet1.addCell(new Label(i, 0, colList.get(i))); | ||
| 105 | + } | ||
| 106 | + for (int i = 1; i < sheet1.getRows(); i++) { // 第二行开始 | ||
| 107 | + Cell[] cells1 = sheet.getRow(i); | ||
| 108 | + for (int j = 0; j < cells1.length; j++) { | ||
| 109 | + sheet1.addCell(new Label(j, i, cells1[j].getContents())); | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + writableWorkbook.write(); | ||
| 113 | + writableWorkbook.close(); | ||
| 114 | + | ||
| 115 | + // 2、删除原有数据 | ||
| 116 | + // 操作在ktr内部执行 | ||
| 117 | + | ||
| 118 | + // 3、导入时刻表 | ||
| 119 | + // 获取停车场名字 | ||
| 120 | + LOGGER.info("获取停车场名字..."); | ||
| 121 | + LineInformation lineInformation = lineInformationService.findById(lineid); | ||
| 122 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 123 | + p1.put("parkCode_eq", lineInformation.getCarPark()); | ||
| 124 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 125 | + String tccname = carParkList.get(0).getParkName(); | ||
| 126 | + LOGGER.info("停车场名字={}", tccname); | ||
| 127 | + | ||
| 128 | + | ||
| 129 | + // 计算表头参数 | ||
| 130 | + Workbook book = Workbook.getWorkbook(fileCal); | ||
| 131 | + Sheet sheet_exp = book.getSheet(sheetname); | ||
| 132 | + List<String> columnames = new ArrayList<>(); | ||
| 133 | + for (int i = 0; i < sheet_exp.getColumns(); i++) { // 获取第一行,数据,作为列名 | ||
| 134 | + columnames.add(sheet_exp.getCell(i, 0).getContents()); | ||
| 135 | + } | ||
| 136 | + LOGGER.info("表头={}", StringUtils.join(columnames.toArray(), ",")); | ||
| 137 | + | ||
| 138 | + // 创建ktr转换所需参数 | ||
| 139 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 140 | + File ktrFile = new File(this.getClass().getResource( | ||
| 141 | + dataToolsProperties.getTtinfodetailMetadatainputktr()).toURI()); | ||
| 142 | + File ktrFile2 = new File(this.getClass().getResource( | ||
| 143 | + dataToolsProperties.getTtinfodetailDatainputktr()).toURI()); | ||
| 144 | + | ||
| 145 | + // 通用参数,转换文件路径,excel输入文件路径,错误输出文件路径 | ||
| 146 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 147 | + ktrParms.put("filepath", fileCal.getAbsolutePath()); | ||
| 148 | + ktrParms.put("erroroutputdir", dataToolsProperties.getTransErrordir()); | ||
| 149 | + | ||
| 150 | + // 附加参数 | ||
| 151 | + ktrParms.put("injectktrfile", ktrFile2.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 152 | + ktrParms.put("sheetname", sheetname); // sheet工作区的名字 | ||
| 153 | + ktrParms.put("xlname", xlname); // 线路名称 | ||
| 154 | + ktrParms.put("ttinfoname", ttname); // 时刻表名称 | ||
| 155 | + ktrParms.put("ttid", ttid.intValue()); // 时刻表id | ||
| 156 | + ktrParms.put("tccname", tccname); // 停车场名字 | ||
| 157 | + ktrParms.put("excelfieldnames", StringUtils.join(columnames.toArray(), ",")); // 时刻表excel输入字段名,以逗号连接 | ||
| 158 | + columnames.remove(0); | ||
| 159 | + ktrParms.put("normalizefieldnames", StringUtils.join(columnames.toArray(), ",")); // 数据范式化字段名,以逗号连接 | ||
| 160 | + | ||
| 161 | + super.importData(fileCal, ktrParms); | ||
| 162 | + | ||
| 163 | + LOGGER.info("//---------------- 导入时刻表明细 success... ----------------//"); | ||
| 164 | + } catch (Exception exp) { | ||
| 165 | + LOGGER.info("//---------------- 导入时刻表明细 failed... ----------------//"); | ||
| 166 | + | ||
| 167 | + StringWriter sw = new StringWriter(); | ||
| 168 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 169 | + LOGGER.info(sw.toString()); | ||
| 170 | + | ||
| 171 | + throw new ScheduleException(exp.getMessage()); | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + @Override | ||
| 176 | + public File exportData(Map<String, Object> params) throws ScheduleException { | ||
| 177 | + try { | ||
| 178 | + LOGGER.info("//---------------- 导出时刻表明细 start... ----------------//"); | ||
| 179 | + | ||
| 180 | + // 创建ktr转换所需参数 | ||
| 181 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 182 | + File ktrFile = new File(this.getClass().getResource( | ||
| 183 | + dataToolsProperties.getTtinfodetailMetaoutput()).toURI()); | ||
| 184 | + File ktrFile2 = new File(this.getClass().getResource( | ||
| 185 | + dataToolsProperties.getTtinfodetailOutput()).toURI()); | ||
| 186 | + | ||
| 187 | + // 通用参数,转换文件路径,excel输出文件名 | ||
| 188 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 189 | + ktrParms.put("filename", String.format("时刻表_(id=%s)_download-", String.valueOf(params.get("ttinfoid")))); | ||
| 190 | + | ||
| 191 | + // 附加参数 | ||
| 192 | + ktrParms.put("injectktrfile", ktrFile2.getAbsolutePath()); // 注入元数据的ktr文件 | ||
| 193 | + ktrParms.put("ttinfoid", String.valueOf(params.get("ttinfoid"))); | ||
| 194 | + | ||
| 195 | + File file = super.exportData(ktrParms); | ||
| 196 | + | ||
| 197 | + LOGGER.info("//---------------- 导出时刻表明细 success... ----------------//"); | ||
| 198 | + | ||
| 199 | + return file; | ||
| 200 | + } catch (Exception exp) { | ||
| 201 | + LOGGER.info("//---------------- 导出时刻表明细 failed... ----------------//"); | ||
| 202 | + | ||
| 203 | + StringWriter sw = new StringWriter(); | ||
| 204 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 205 | + LOGGER.info(sw.toString()); | ||
| 206 | + | ||
| 207 | + throw new ScheduleException(exp.getMessage()); | ||
| 208 | + } | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + @Override | ||
| 212 | + public EditInfo getEditInfo(Integer xlid, Long ttid) throws ScheduleException { | ||
| 213 | + try { | ||
| 214 | + LOGGER.info("//---------------- 时刻表编辑用数据输出 start... ----------------//"); | ||
| 215 | + | ||
| 216 | + // 创建ktr转换所需参数 | ||
| 217 | + Map<String, Object> ktrParms = new HashMap<>(); | ||
| 218 | + File ktrFile = new File(this.getClass().getResource( | ||
| 219 | + dataToolsProperties.getTtinfodetailForeditktr()).toURI()); | ||
| 220 | + | ||
| 221 | + // 通用参数,转换文件路径,excel输出文件名,错误输出文件路径 | ||
| 222 | + ktrParms.put("transpath", ktrFile.getAbsolutePath()); | ||
| 223 | + ktrParms.put("filename", "todo"); | ||
| 224 | + | ||
| 225 | + // 附加参数 | ||
| 226 | + String outputFilePath = String.format("ttinfodetail_(id=%s)_foredit-%s", | ||
| 227 | + String.valueOf(ttid), new DateTime().toString("yyyyMMddHHmmss")); | ||
| 228 | + | ||
| 229 | + ktrParms.put("tempfilepath", dataToolsProperties.getTransTempdir() + File.separator + outputFilePath); // 数据输出文件路径 | ||
| 230 | + ktrParms.put("xlid", String.valueOf(xlid)); | ||
| 231 | + ktrParms.put("ttid", String.valueOf(ttid)); | ||
| 232 | + | ||
| 233 | + super.exportData(ktrParms); | ||
| 234 | + | ||
| 235 | + // 1.6、获取最大的发车数,用于输出数据的数量 | ||
| 236 | + Long maxfcno = ttInfoDetailRepository.findMaxFcno(xlid, ttid); | ||
| 237 | + if (maxfcno == null) | ||
| 238 | + return new EditInfo(); | ||
| 239 | + | ||
| 240 | + // 2、读取ktr生成的excel数据,组织编辑用数据返回 | ||
| 241 | + // 2-1、读取Excel文件 | ||
| 242 | + Workbook book = Workbook.getWorkbook(new File(dataToolsProperties.getTransTempdir() + | ||
| 243 | + File.separator + outputFilePath + ".xls")); | ||
| 244 | + Sheet sheet = book.getSheet(0); | ||
| 245 | + EditInfo editInfo = new EditInfo(); | ||
| 246 | + // 2-2、处理数据 | ||
| 247 | + int all_bc = 0; // 总班次 | ||
| 248 | + double all_lc_ks = 0; // 总空驶里程 | ||
| 249 | + double all_lc_yy = 0; // 总营运里程 | ||
| 250 | + | ||
| 251 | + String[] headarrays = new String[maxfcno.intValue() + 3]; | ||
| 252 | + headarrays[0] = "路牌"; | ||
| 253 | + headarrays[maxfcno.intValue() + 1] = "空驶班次/空驶里程"; | ||
| 254 | + headarrays[maxfcno.intValue() + 2] = "运营班次/运营里程"; | ||
| 255 | + | ||
| 256 | + for (int r = 1; r < sheet.getRows(); r++) { | ||
| 257 | + List<FcInfo> fcInfos = new ArrayList<>(); | ||
| 258 | + // 每行第一列都是路牌 | ||
| 259 | + fcInfos.add(new FcInfo(null, null, sheet.getCell(0, r).getContents(), null, null)); // 用fcsj放置路牌显示 | ||
| 260 | + | ||
| 261 | + int bc_ks = 0; // 空驶班次 | ||
| 262 | + int bc_yy = 0; // 营运班次 | ||
| 263 | + double lc_ks = 0; // 空驶里程 | ||
| 264 | + double lc_yy = 0; // 营运里程 | ||
| 265 | + | ||
| 266 | + for (int c = 1; c <= maxfcno * 7; ) { | ||
| 267 | + String ttdid_str = sheet.getCell(c, r).getContents(); // 时刻表明细id | ||
| 268 | + String fcsj = sheet.getCell(c + 1, r).getContents(); // 发车时间 | ||
| 269 | + String jhlc = sheet.getCell(c + 2, r).getContents(); // 计划里程 | ||
| 270 | + String fzdname = sheet.getCell(c + 3, r).getContents(); // 发车站点名称 | ||
| 271 | + String bctype = sheet.getCell(c + 4, r).getContents(); // 班次类型 | ||
| 272 | + String xldir = sheet.getCell(c + 5, r).getContents(); // 线路上下行 | ||
| 273 | + String isfb = sheet.getCell(c + 6, r).getContents(); // 是否分班 | ||
| 274 | + | ||
| 275 | + FcInfo fcInfo = new FcInfo(ttdid_str, bctype, fcsj, xldir, isfb); | ||
| 276 | + | ||
| 277 | + if (StringUtils.isNotEmpty(fzdname)) | ||
| 278 | + headarrays[(int)(c / 7) + 1] = fzdname; | ||
| 279 | + fcInfos.add(fcInfo); | ||
| 280 | + | ||
| 281 | + c += 7; | ||
| 282 | + | ||
| 283 | + // 计算班次里程 | ||
| 284 | + if (StringUtils.isNotEmpty(jhlc)) { | ||
| 285 | + if ("in".equals(bctype) || "out".equals(bctype)) { | ||
| 286 | + bc_ks += 1; | ||
| 287 | + lc_ks += Double.valueOf(jhlc); | ||
| 288 | + | ||
| 289 | + all_bc += 1; | ||
| 290 | + all_lc_ks += Double.valueOf(jhlc); | ||
| 291 | + | ||
| 292 | + } else { | ||
| 293 | + bc_yy += 1; | ||
| 294 | + lc_yy += Double.valueOf(jhlc); | ||
| 295 | + | ||
| 296 | + all_bc += 1; | ||
| 297 | + all_lc_yy += Double.valueOf(jhlc); | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + | ||
| 301 | + } | ||
| 302 | + | ||
| 303 | + // 添加一列 空驶班次/空驶里程,fcsj放置数据 | ||
| 304 | + fcInfos.add(new FcInfo(null, null, String.format("%d/%.2f", bc_ks, lc_ks), null, null)); | ||
| 305 | + | ||
| 306 | + // 添加一列 营运班次/营运里程,fcsj放置数据 | ||
| 307 | + fcInfos.add(new FcInfo(null, null, String.format("%d/%.2f", bc_yy, lc_yy), null, null)); | ||
| 308 | + | ||
| 309 | + editInfo.getContents().add(fcInfos); | ||
| 310 | + } | ||
| 311 | + editInfo.getHeader().addAll(Arrays.asList(headarrays)); | ||
| 312 | + | ||
| 313 | + editInfo.setYy_desc(String.format("班次=%d,空驶里程=%.2f,营运里程=%.2f", all_bc, all_lc_ks, all_lc_yy)); | ||
| 314 | + | ||
| 315 | + LOGGER.info("//---------------- 时刻表编辑用数据输出 success... ----------------//"); | ||
| 316 | + | ||
| 317 | + return editInfo; | ||
| 318 | + } catch (Exception exp) { | ||
| 319 | + LOGGER.info("//---------------- 时刻表编辑用数据输出 failed... ----------------//"); | ||
| 320 | + | ||
| 321 | + StringWriter sw = new StringWriter(); | ||
| 322 | + exp.printStackTrace(new PrintWriter(sw)); | ||
| 323 | + LOGGER.info(sw.toString()); | ||
| 324 | + | ||
| 325 | + throw new ScheduleException(exp.getMessage()); | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + | ||
| 329 | + | ||
| 330 | + | ||
| 331 | + @Override | ||
| 332 | + public void validateExcelSheet(String filename, String sheetname, Integer lineid, String linename) throws ScheduleException { | ||
| 333 | + try { | ||
| 334 | + Workbook book = Workbook.getWorkbook(new File(filename)); | ||
| 335 | + Sheet sheet = book.getSheet(sheetname); | ||
| 336 | + if (sheet.getRows() == 0 || sheet.getColumns() == 0) { // 工作区是否为空 | ||
| 337 | + throw new Exception(String.format("%s 工作区没有数据!", sheetname)); | ||
| 338 | + } else { | ||
| 339 | + if (sheet.getRows() <= 1 || sheet.getColumns() <= 1) { | ||
| 340 | + throw new Exception(String.format("工作区至少包含2行2列的数据")); | ||
| 341 | + } else { | ||
| 342 | + Cell[] cells = sheet.getRow(0); // 获取第一行数据列 | ||
| 343 | + for (int i = 0; i < cells.length; i++) { | ||
| 344 | + String cell_con = cells[i].getContents(); | ||
| 345 | + | ||
| 346 | + if (StringUtils.isEmpty(cell_con)) { | ||
| 347 | + throw new Exception(String.format("第1行,第%d列数据不能为空", i + 1)); | ||
| 348 | + } else { | ||
| 349 | + // 正则表达式去除数字 | ||
| 350 | + cell_con = cell_con.replaceAll("[\\d+]", ""); | ||
| 351 | + | ||
| 352 | + if (i == 0) { // 第一列必须是路牌2个字 | ||
| 353 | + if (!"路牌".equals(cell_con.trim())) { | ||
| 354 | + throw new Exception("第1行,第1列数据必须是路牌2个字"); | ||
| 355 | + } | ||
| 356 | + } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | ||
| 357 | + if ((!"出场".equals(cell_con.trim())) && | ||
| 358 | + (!"进场".equals(cell_con.trim()))) { | ||
| 359 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 360 | + p1.put("line.id_eq", lineid); | ||
| 361 | + p1.put("stationName_eq", cell_con.trim()); | ||
| 362 | + p1.put("stationMark_eq", "B"); | ||
| 363 | + | ||
| 364 | + | ||
| 365 | + // TODO:这里要修改(起点站有启用撤销的标志的) | ||
| 366 | + | ||
| 367 | + List<StationRoute> stationRouteList = (List<StationRoute>) stationRouteService.list(p1); | ||
| 368 | + if (CollectionUtils.isEmpty(stationRouteList)) { | ||
| 369 | + throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中不是起点站", i + 1, cell_con.trim(), linename)); | ||
| 370 | + } else if (stationRouteList.size() > 1) { | ||
| 371 | + throw new Exception(String.format("第1行,第%d列数据%s在%s站点路由中上下行都是起点站", i + 1, cell_con.trim(), linename)); | ||
| 372 | + } | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + } | ||
| 376 | + } | ||
| 377 | + } | ||
| 378 | + | ||
| 379 | + // 验证路牌内容 | ||
| 380 | + Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | ||
| 381 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 382 | + Cell bcell = sheet.getRow(i)[0]; // 获取第1列 | ||
| 383 | + String bcell_con = bcell.getContents(); | ||
| 384 | + if (StringUtils.isEmpty(bcell_con)) { | ||
| 385 | + throw new Exception(String.format("第%d行,第1列路牌无数据", i + 1)); | ||
| 386 | + } else if (gbindexmap.get(bcell_con.trim()) != null) { | ||
| 387 | + throw new Exception(String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | ||
| 388 | + i + 1, | ||
| 389 | + gbindexmap.get(bcell_con.trim()))); | ||
| 390 | + } else { | ||
| 391 | + Map<String, Object> p2 = new HashMap<>(); | ||
| 392 | + p2.put("xl.id_eq", lineid); | ||
| 393 | + p2.put("lpName_eq", bcell_con.trim()); | ||
| 394 | + List<GuideboardInfo> guideboardInfoList = (List<GuideboardInfo>) guideboardInfoService.list(p2); | ||
| 395 | + if (CollectionUtils.isEmpty(guideboardInfoList)) { | ||
| 396 | + throw new Exception(String.format("第%d行,第1列的路牌在%s中不存在", i + 1, linename)); | ||
| 397 | + } else if (guideboardInfoList.size() > 1) { | ||
| 398 | + throw new Exception(String.format("第%d行,第1列的路牌在%s中重复", i + 1, linename)); | ||
| 399 | + } else { | ||
| 400 | + gbindexmap.put(bcell_con.trim(), i + 1); | ||
| 401 | + } | ||
| 402 | + } | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + // 班次时间验证,正则表达式,格式hh:mm或者hhmm | ||
| 406 | + String el = "^(([0-1]\\d)|(2[0-4])):[0-5]\\d$"; // hh:mm格式 | ||
| 407 | + String el2 = "^(([0-1]\\d)|(2[0-4]))[0-5]\\d$"; // hhmm格式 | ||
| 408 | + Pattern p = Pattern.compile(el); | ||
| 409 | + Pattern p2 = Pattern.compile(el2); | ||
| 410 | + | ||
| 411 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | ||
| 412 | + Cell[] bcells = sheet.getRow(i); | ||
| 413 | + for (int j = 1; j < bcells.length; j++) { // 从第2列开始 | ||
| 414 | + String bcell_con = bcells[j].getContents(); | ||
| 415 | + if (StringUtils.isNotEmpty(bcell_con)) { | ||
| 416 | + Matcher m = p.matcher(bcell_con.trim()); | ||
| 417 | + Matcher m2 = p2.matcher(bcell_con.trim()); | ||
| 418 | + if ((!m.matches()) && (!m2.matches())) { | ||
| 419 | + throw new Exception(String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hhmm", i + 1, j + 1)); | ||
| 420 | + } | ||
| 421 | + } | ||
| 422 | + } | ||
| 423 | + } | ||
| 424 | + } | ||
| 425 | + | ||
| 426 | + } | ||
| 427 | + } catch (Exception exp) { | ||
| 428 | + throw new ScheduleException(exp.getMessage()); | ||
| 429 | + } | ||
| 430 | + | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + @Override | ||
| 434 | + public void validateAssoLineInfo(Integer lineinfoid) throws ScheduleException { | ||
| 435 | + LineInformation lineInformation = lineInformationService.findById(lineinfoid); | ||
| 436 | + if (lineInformation.getUpInMileage() == null) { | ||
| 437 | + throw new ScheduleException("上行进场里程为空"); | ||
| 438 | + } else if (lineInformation.getUpInTimer() == null) { | ||
| 439 | + throw new ScheduleException("上行进场时间为空"); | ||
| 440 | + } else if (lineInformation.getUpOutMileage() == null) { | ||
| 441 | + throw new ScheduleException("上行出场里程为空"); | ||
| 442 | + } else if (lineInformation.getUpOutTimer() == null) { | ||
| 443 | + throw new ScheduleException("上行出场时间为空"); | ||
| 444 | + } else if (lineInformation.getUpMileage() == null) { | ||
| 445 | + throw new ScheduleException("上行班次里程为空"); | ||
| 446 | + } else if (lineInformation.getUpTravelTime() == null) { | ||
| 447 | + throw new ScheduleException("上行班次时间为空"); | ||
| 448 | + } else if (lineInformation.getDownInMileage() == null) { | ||
| 449 | + throw new ScheduleException("下行进场里程为空"); | ||
| 450 | + } else if (lineInformation.getDownInTimer() == null) { | ||
| 451 | + throw new ScheduleException("下行进场时间为空"); | ||
| 452 | + } else if (lineInformation.getDownOutMileage() == null) { | ||
| 453 | + throw new ScheduleException("下行出场里程为空"); | ||
| 454 | + } else if (lineInformation.getDownOutTimer() == null) { | ||
| 455 | + throw new ScheduleException("下行出场时间为空"); | ||
| 456 | + } else if (lineInformation.getDownMileage() == null) { | ||
| 457 | + throw new ScheduleException("下行班次里程为空"); | ||
| 458 | + } else if (lineInformation.getDownTravelTime() == null) { | ||
| 459 | + throw new ScheduleException("下行班次时间为空"); | ||
| 460 | + } else if (StringUtils.isEmpty(lineInformation.getCarPark())) { | ||
| 461 | + throw new ScheduleException("停车场必须选择"); | ||
| 462 | + } | ||
| 463 | + | ||
| 464 | + // 单独验证停车场信息 | ||
| 465 | + String tcccode = lineInformation.getCarPark(); | ||
| 466 | + Map<String, Object> p1 = new HashMap<>(); | ||
| 467 | + p1.put("parkCode_eq", tcccode); | ||
| 468 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | ||
| 469 | + if (CollectionUtils.isEmpty(carParkList)) { | ||
| 470 | + throw new ScheduleException(String.format("线路标准里的停车场code=%s,在停车场信息中未找到", tcccode)); | ||
| 471 | + } else if (carParkList.size() > 1) { | ||
| 472 | + throw new ScheduleException(String.format("线路标准里的停车场code=%s,在停车场信息中有重复数据", tcccode)); | ||
| 473 | + } else { | ||
| 474 | + CarPark carPark = carParkList.get(0); | ||
| 475 | + if (StringUtils.isEmpty(carPark.getParkName())) { | ||
| 476 | + throw new ScheduleException(String.format("线路标准里的停车场code=%s,在停车场信息中没有停车场名字", tcccode)); | ||
| 477 | + } | ||
| 478 | + } | ||
| 479 | + | ||
| 480 | + } | ||
| 481 | + | ||
| 482 | + @Override | ||
| 483 | + public List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId) { | ||
| 484 | + return ttInfoDetailRepository.findBcdetails(xlId, ttinfoId, lpId); | ||
| 485 | + } | ||
| 486 | +} |
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.schedule.TTInfo; | 3 | import com.bsth.entity.schedule.TTInfo; |
| 4 | -import com.bsth.service.schedule.ScheduleException; | 4 | +import com.bsth.service.schedule.exception.ScheduleException; |
| 5 | import com.bsth.service.schedule.TTInfoService; | 5 | import com.bsth.service.schedule.TTInfoService; |
| 6 | import org.apache.commons.lang3.StringUtils; | 6 | import org.apache.commons.lang3.StringUtils; |
| 7 | import org.springframework.stereotype.Service; | 7 | import org.springframework.stereotype.Service; |
src/main/java/com/bsth/service/schedule/utils/DataToolsProperties.java
| @@ -45,9 +45,6 @@ public class DataToolsProperties { | @@ -45,9 +45,6 @@ public class DataToolsProperties { | ||
| 45 | private String kvarsDbdname; | 45 | private String kvarsDbdname; |
| 46 | 46 | ||
| 47 | /**------------------------- 导入数据ktr --------------------------*/ | 47 | /**------------------------- 导入数据ktr --------------------------*/ |
| 48 | - /** 测试temp的ktr转换文件 */ | ||
| 49 | - @NotNull | ||
| 50 | - private String tempDatainputktr; | ||
| 51 | /** 车辆信息导入ktr转换 */ | 48 | /** 车辆信息导入ktr转换 */ |
| 52 | @NotNull | 49 | @NotNull |
| 53 | private String carsDatainputktr; | 50 | private String carsDatainputktr; |
| @@ -69,12 +66,16 @@ public class DataToolsProperties { | @@ -69,12 +66,16 @@ public class DataToolsProperties { | ||
| 69 | /** 时刻表明细信息导入(元数据) */ | 66 | /** 时刻表明细信息导入(元数据) */ |
| 70 | @NotNull | 67 | @NotNull |
| 71 | private String ttinfodetailMetadatainputktr; | 68 | private String ttinfodetailMetadatainputktr; |
| 72 | - /** 时刻表明细编辑用数据(TODO:之后要换成元数据形式输入) */ | 69 | + /** 时刻表明细编辑用数据 */ |
| 73 | @NotNull | 70 | @NotNull |
| 74 | private String ttinfodetailForeditktr; | 71 | private String ttinfodetailForeditktr; |
| 75 | /** 时刻表明细信息导入 */ | 72 | /** 时刻表明细信息导入 */ |
| 76 | @NotNull | 73 | @NotNull |
| 77 | private String ttinfodetailDatainputktr; | 74 | private String ttinfodetailDatainputktr; |
| 75 | + /** 排班规则信息导入 */ | ||
| 76 | + @NotNull | ||
| 77 | + private String scheduleruleDatainputktr; | ||
| 78 | + | ||
| 78 | 79 | ||
| 79 | /**------------------------- 导出数据ktr --------------------------*/ | 80 | /**------------------------- 导出数据ktr --------------------------*/ |
| 80 | /** 车辆信息导出ktr转换 */ | 81 | /** 车辆信息导出ktr转换 */ |
| @@ -84,9 +85,14 @@ public class DataToolsProperties { | @@ -84,9 +85,14 @@ public class DataToolsProperties { | ||
| 84 | @NotNull | 85 | @NotNull |
| 85 | private String employeesDataoutputktr; | 86 | private String employeesDataoutputktr; |
| 86 | /** 时刻表导出元数据ktr转换 */ | 87 | /** 时刻表导出元数据ktr转换 */ |
| 88 | + @NotNull | ||
| 87 | private String ttinfodetailMetaoutput; | 89 | private String ttinfodetailMetaoutput; |
| 88 | /** 时刻表导出数据ktr转换 */ | 90 | /** 时刻表导出数据ktr转换 */ |
| 91 | + @NotNull | ||
| 89 | private String ttinfodetailOutput; | 92 | private String ttinfodetailOutput; |
| 93 | + @NotNull | ||
| 94 | + /** 排版规则导出数据ktr转换 */ | ||
| 95 | + private String scheduleruleOutput; | ||
| 90 | 96 | ||
| 91 | // TODO: | 97 | // TODO: |
| 92 | 98 | ||
| @@ -106,14 +112,6 @@ public class DataToolsProperties { | @@ -106,14 +112,6 @@ public class DataToolsProperties { | ||
| 106 | this.transErrordir = transErrordir; | 112 | this.transErrordir = transErrordir; |
| 107 | } | 113 | } |
| 108 | 114 | ||
| 109 | - public String getTempDatainputktr() { | ||
| 110 | - return tempDatainputktr; | ||
| 111 | - } | ||
| 112 | - | ||
| 113 | - public void setTempDatainputktr(String tempDatainputktr) { | ||
| 114 | - this.tempDatainputktr = tempDatainputktr; | ||
| 115 | - } | ||
| 116 | - | ||
| 117 | public String getCarsDatainputktr() { | 115 | public String getCarsDatainputktr() { |
| 118 | return carsDatainputktr; | 116 | return carsDatainputktr; |
| 119 | } | 117 | } |
| @@ -202,6 +200,14 @@ public class DataToolsProperties { | @@ -202,6 +200,14 @@ public class DataToolsProperties { | ||
| 202 | this.ttinfodetailDatainputktr = ttinfodetailDatainputktr; | 200 | this.ttinfodetailDatainputktr = ttinfodetailDatainputktr; |
| 203 | } | 201 | } |
| 204 | 202 | ||
| 203 | + public String getScheduleruleDatainputktr() { | ||
| 204 | + return scheduleruleDatainputktr; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + public void setScheduleruleDatainputktr(String scheduleruleDatainputktr) { | ||
| 208 | + this.scheduleruleDatainputktr = scheduleruleDatainputktr; | ||
| 209 | + } | ||
| 210 | + | ||
| 205 | public String getKettleProperties() { | 211 | public String getKettleProperties() { |
| 206 | return kettleProperties; | 212 | return kettleProperties; |
| 207 | } | 213 | } |
| @@ -273,4 +279,12 @@ public class DataToolsProperties { | @@ -273,4 +279,12 @@ public class DataToolsProperties { | ||
| 273 | public void setTtinfodetailOutput(String ttinfodetailOutput) { | 279 | public void setTtinfodetailOutput(String ttinfodetailOutput) { |
| 274 | this.ttinfodetailOutput = ttinfodetailOutput; | 280 | this.ttinfodetailOutput = ttinfodetailOutput; |
| 275 | } | 281 | } |
| 282 | + | ||
| 283 | + public String getScheduleruleOutput() { | ||
| 284 | + return scheduleruleOutput; | ||
| 285 | + } | ||
| 286 | + | ||
| 287 | + public void setScheduleruleOutput(String scheduleruleOutput) { | ||
| 288 | + this.scheduleruleOutput = scheduleruleOutput; | ||
| 289 | + } | ||
| 276 | } | 290 | } |
src/main/java/com/bsth/service/schedule/utils/DataToolsService.java
0 → 100644
| 1 | +package com.bsth.service.schedule.utils; | ||
| 2 | + | ||
| 3 | +import com.bsth.service.schedule.exception.ScheduleException; | ||
| 4 | + | ||
| 5 | +import java.io.File; | ||
| 6 | +import java.util.Map; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 数据服务接口。 | ||
| 10 | + */ | ||
| 11 | +public interface DataToolsService { | ||
| 12 | + //----------------- 数据服务操作 --------------// | ||
| 13 | + // 上传文件 | ||
| 14 | + File uploadFile(String filename, byte[] filedata) throws ScheduleException; | ||
| 15 | + // 导入数据 | ||
| 16 | + void importData(File file, Map<String, Object> params) throws ScheduleException; | ||
| 17 | + // 导出数据 | ||
| 18 | + File exportData(Map<String, Object> params) throws ScheduleException; | ||
| 19 | +} |