Commit e17a218319a1da690673034345a4c5270a5a0c83

Authored by 徐烜
2 parents 0b3f7755 5942a230

PSM-1

Too many changes to show.

To preserve performance only 1 of 3 files are displayed.

src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java
@@ -3,10 +3,13 @@ package com.bsth.controller.schedule; @@ -3,10 +3,13 @@ package com.bsth.controller.schedule;
3 import com.bsth.common.ResponseCode; 3 import com.bsth.common.ResponseCode;
4 import com.bsth.controller.BaseController; 4 import com.bsth.controller.BaseController;
5 import com.bsth.entity.CarPark; 5 import com.bsth.entity.CarPark;
  6 +import com.bsth.entity.LineInformation;
6 import com.bsth.entity.schedule.TTInfoDetail; 7 import com.bsth.entity.schedule.TTInfoDetail;
7 import com.bsth.repository.schedule.TTInfoDetailRepository; 8 import com.bsth.repository.schedule.TTInfoDetailRepository;
8 import com.bsth.service.CarParkService; 9 import com.bsth.service.CarParkService;
  10 +import com.bsth.service.LineInformationService;
9 import com.bsth.service.schedule.TTInfoDetailServiceImpl; 11 import com.bsth.service.schedule.TTInfoDetailServiceImpl;
  12 +import org.apache.commons.lang3.StringUtils;
10 import org.springframework.beans.factory.annotation.Autowired; 13 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.web.bind.annotation.*; 14 import org.springframework.web.bind.annotation.*;
12 import org.springframework.web.multipart.MultipartFile; 15 import org.springframework.web.multipart.MultipartFile;
@@ -26,27 +29,52 @@ public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> { @@ -26,27 +29,52 @@ public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> {
26 @Autowired 29 @Autowired
27 private CarParkService carParkService; 30 private CarParkService carParkService;
28 @Autowired 31 @Autowired
  32 + private LineInformationService lineInformationService;
  33 + @Autowired
29 private TTInfoDetailRepository ttInfoDetailRepository; 34 private TTInfoDetailRepository ttInfoDetailRepository;
30 35
31 @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST) 36 @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST)
32 public Map<String, Object> uploadDataAndImport( 37 public Map<String, Object> uploadDataAndImport(
33 - MultipartFile file, String xlmc, String ttinfoname, String tcccode) throws Exception { 38 + MultipartFile file, String xlmc, String ttinfoname) throws Exception {
34 Map<String, Object> resultMap = new HashMap<>(); 39 Map<String, Object> resultMap = new HashMap<>();
35 40
36 try { 41 try {
37 - // 查看停车场是否存在,不存在报错 42 + // 查找lineinformation对象,没有报错
38 Map<String, Object> param = new HashMap<>(); 43 Map<String, Object> param = new HashMap<>();
39 - param.put("parkCode_eq", tcccode);  
40 - Iterator<CarPark> carParkIterator = carParkService.list(param).iterator();  
41 - if (!carParkIterator.hasNext()) {  
42 - // 没有停车场,报错 44 + param.put("line.name_eq", xlmc);
  45 + Iterator<LineInformation> lineInformationIterator = lineInformationService.list(param).iterator();
  46 + if (!lineInformationIterator.hasNext()) {
  47 + // 没有lineinformation,报错
43 resultMap.put("status", ResponseCode.ERROR); 48 resultMap.put("status", ResponseCode.ERROR);
44 - resultMap.put("msg", "没有停车场数据,停车场代码=" + tcccode); 49 + resultMap.put("msg", "没有lineinfomation,线路名称=" + xlmc);
45 } else { 50 } else {
46 - CarPark carPark = carParkIterator.next();  
47 - ttInfoDetailService.fileDataImport(file, xlmc, ttinfoname, carPark.getParkName());  
48 - resultMap.put("status", ResponseCode.SUCCESS);  
49 - resultMap.put("msg", "导入成功"); 51 + String tcccode = lineInformationIterator.next().getCarPark();
  52 + if (StringUtils.isEmpty(tcccode)) {
  53 + // 没有停车场code,报错
  54 + resultMap.put("status", ResponseCode.ERROR);
  55 + resultMap.put("msg", "线路lineinfomation没有停车场code信息,线路名称=" + xlmc);
  56 + } else {
  57 + // 使用停车场code查找停车场
  58 + param.clear();;
  59 + param.put("parkCode_eq", tcccode);
  60 + Iterator<CarPark> carParkIterator = carParkService.list(param).iterator();
  61 + if (!carParkIterator.hasNext()) {
  62 + // 指定的停车场code没有找到停车场信息,报错
  63 + resultMap.put("status", ResponseCode.ERROR);
  64 + resultMap.put("msg", "没有找到停车场信息,停车场code=" + tcccode);
  65 + } else {
  66 + String tccname = carParkIterator.next().getParkName();
  67 + if (StringUtils.isEmpty(tccname)) {
  68 + // 没有停车场名字,报错
  69 + resultMap.put("status", ResponseCode.ERROR);
  70 + resultMap.put("msg", "停车场信息没有停车场名字,停车场code=" + tcccode);
  71 + } else {
  72 + ttInfoDetailService.fileDataImport(file, xlmc, ttinfoname, tccname);
  73 + resultMap.put("status", ResponseCode.SUCCESS);
  74 + resultMap.put("msg", "导入成功");
  75 + }
  76 + }
  77 + }
50 } 78 }
51 } catch (Exception exp) { 79 } catch (Exception exp) {
52 exp.printStackTrace(); 80 exp.printStackTrace();