TTInfoDetailController.java
3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.bsth.controller.schedule;
import com.bsth.common.ResponseCode;
import com.bsth.controller.BaseController;
import com.bsth.entity.CarPark;
import com.bsth.entity.schedule.TTInfoDetail;
import com.bsth.repository.schedule.TTInfoDetailRepository;
import com.bsth.service.CarParkService;
import com.bsth.service.schedule.TTInfoDetailServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* Created by xu on 16/7/2.
*/
@RestController
@RequestMapping("tidc")
public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> {
@Autowired
private TTInfoDetailServiceImpl ttInfoDetailService;
@Autowired
private CarParkService carParkService;
@Autowired
private TTInfoDetailRepository ttInfoDetailRepository;
@RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST)
public Map<String, Object> uploadDataAndImport(
MultipartFile file, String xlmc, String ttinfoname, String tcccode) throws Exception {
Map<String, Object> resultMap = new HashMap<>();
try {
// 查看停车场是否存在,不存在报错
Map<String, Object> param = new HashMap<>();
param.put("parkCode_eq", tcccode);
Iterator<CarPark> carParkIterator = carParkService.list(param).iterator();
if (!carParkIterator.hasNext()) {
// 没有停车场,报错
resultMap.put("status", ResponseCode.ERROR);
resultMap.put("msg", "没有停车场数据,停车场代码=" + tcccode);
} else {
CarPark carPark = carParkIterator.next();
ttInfoDetailService.fileDataImport(file, xlmc, ttinfoname, carPark.getParkName());
resultMap.put("status", ResponseCode.SUCCESS);
resultMap.put("msg", "导入成功");
}
} catch (Exception exp) {
exp.printStackTrace();
throw exp;
}
return resultMap;
}
@RequestMapping(value = "/edit/{xlid}/{ttid}", method = RequestMethod.GET)
public Object getEditInfo(
@PathVariable("xlid") Integer xlid,
@PathVariable("ttid") Long ttid) throws Exception {
// TODO:返回类型需要修正
return ttInfoDetailService.getEditInfo(xlid, ttid);
}
/**
* 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody
* @Title: save
* @Description: TODO(持久化对象)
* @param @param t
* @param @return 设定文件
* @return Map<String,Object> {status: 1(成功),-1(失败)}
* @throws
*/
@RequestMapping(method = RequestMethod.POST)
public Map<String, Object> save(@RequestBody TTInfoDetail t){
return baseService.save(t);
}
@Override
public TTInfoDetail findById(@PathVariable("id") Long aLong) {
return ttInfoDetailRepository.findOneExtend(aLong);
}
}