XlybtzController.java
2 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
package com.bsth.controller.report;
import com.bsth.service.report.XlybtzService;
import com.google.common.io.Files;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.util.*;
@RestController
@RequestMapping("xlybtz")
public class XlybtzController {
@Autowired
XlybtzService xlybtzService;
public String getDataImportClasspath(){
return this.getClass().getResource("/").getPath() + "/static/pages/electricity/jdl";
}
@RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
public String uploadFile(MultipartFile file,@RequestParam int reportType,@RequestParam String date) throws Exception{
File newFile = new File(getDataImportClasspath() + File.separator + file.getOriginalFilename());
Files.write(file.getBytes(), newFile);
String type=null;
String result=null;
if(reportType==1){
type="票务";
result = xlybtzService.imporPWExcel(newFile,date);
}else if(reportType==2){
type="二维码";
result = xlybtzService.importQRCordExcel(newFile,date);
}
else if(reportType==3){
type="申城通";
result = xlybtzService.importCardExcel(newFile,date,type);
}
else if(reportType==4){
type="实体卡";
result = xlybtzService.importCardExcel(newFile,date,type);
}
else if(reportType==5){
type="保通卡";
result = xlybtzService.importCardExcel(newFile,date,type);
}
else{
result="请选择导入类型";
}
return "{\"result\":" + "\""+result+"\"}";
}
@RequestMapping(value = "/query",method = RequestMethod.GET)
public Map<String, Object> query(@RequestParam Map<String, Object> map) throws Exception{
Map<String, Object> m= xlybtzService.query(map);
return m;
}
}