JqlController.java
1.63 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
package com.bsth.controller.oil;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.bsth.controller.BaseController;
import com.bsth.entity.oil.Jql;
import com.bsth.service.oil.JqlService;
import com.google.common.io.Files;
@RestController
@RequestMapping("jql")
public class JqlController extends BaseController<Jql, Integer> {
@Autowired
JqlService jqlService;
public String getDataImportClasspath(){
return this.getClass().getResource("/").getPath() + "/static/pages/hydrogen/jql";
}
@RequestMapping(value = "/uploadFile",method = RequestMethod.POST)
public String uploadFile(MultipartFile file, String gsbm_, String gsName,
String fgsbm_, String fgsName) throws Exception{
Map<String, Object> map = new HashMap<String, Object>();
File newFile = new File(
getDataImportClasspath() + File.separator +
file.getOriginalFilename());
Files.write(file.getBytes(), newFile);
String result = jqlService.importExcel(newFile, gsbm_, gsName, fgsbm_, fgsName);
return "{\"result\":" + "\""+result+"\"}";
}
@RequestMapping(value = "/query",method = RequestMethod.GET)
public Map<String, Object> query(@RequestParam Map<String, Object> map) throws Exception{
return jqlService.query(map);
}
}