CwjyController.java
3.67 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.bsth.controller.oil;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
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.common.ResponseCode;
import com.bsth.controller.BaseController;
import com.bsth.data.BasicData;
import com.bsth.entity.Line;
import com.bsth.entity.oil.Cwjy;
import com.bsth.entity.oil.Ylxxb;
import com.bsth.entity.sys.SysUser;
import com.bsth.security.util.SecurityUtils;
import com.bsth.service.oil.CwjyService;
import com.bsth.util.PageObject;
import com.google.common.io.Files;
@RestController
@RequestMapping("cwjy")
public class CwjyController extends BaseController<Cwjy, Integer>{
@Autowired
private CwjyService service;
@RequestMapping(method = RequestMethod.POST)
public Map<String, Object> save(Cwjy t){
SysUser sysUser = SecurityUtils.getCurrentUser();
t.setCreateDate(new Date());
t.setXgr(sysUser.getUserName());
t.setNbbm(t.getNbbm().trim().toUpperCase());
Line line=BasicData.nbbm2LineMap.get(t.getNbbm());
t.setLine(line == null?"" : line.getLineCode());
Map<String, Object> map = new HashMap<>();
try {
map=service.save(t);
}catch (Exception e) {
// TODO: handle exception
if(e.getMessage().indexOf("PK_CWJYUK")>0){
map.put("fage", "存在相同数据,数据已经过滤");
}
}
return map;
}
@RequestMapping(value = "/checkNbbm",method = RequestMethod.GET)
public int checkNbbm(Cwjy t){
return service.checkNbbm(t);
}
@RequestMapping(value = "/queryList",method = RequestMethod.GET)
public List<Ylxxb> queryList(@RequestParam Map<String, Object> map){
List<Ylxxb> pagequery=null;
map.put("curPage", map.get("page").toString());
map.put("pageData","10");
pagequery=service.Pagequery(map);
return pagequery;
}
@RequestMapping(value = "/cwjyList",method = RequestMethod.GET)
public List<Ylxxb> cwjyList(@RequestParam Map<String, Object> map){
List<Ylxxb> cwjyList=service.cwjyList(map);
return cwjyList;
}
@RequestMapping(value="/bynbbm",method = RequestMethod.GET)
public Ylxxb bynbbm(@RequestParam Map<String, Object> map){
return service.bynbbm(map);
}
/**
*
* @Title: save
* @Description: TODO(持久化对象)
* @param @param t
* @param @return 设定文件
* @return Map<String,Object> {status: 1(成功),-1(失败)}
* @throws
*/
@RequestMapping(value="/savejzl",method = RequestMethod.POST)
public Map<String, Object> savejzl(@RequestParam Map<String, Object> map){
Map<String, Object> maps=new HashMap<>();
try {
maps = service.savejzl(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return maps;
}
/*
* 场外加油导入
*/
@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 = service.importExcel(newFile, gsbm_, gsName);
return "{\"result\":" + "\""+result+"\"}";
}
public String getDataImportClasspath(){
return this.getClass().getResource("/").getPath() + "/static/pages/oil";
}
}