YlbController.java
9.14 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
package com.bsth.controller.oil;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.annotation.PathVariable;
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 com.bsth.controller.BaseController;
import com.bsth.entity.oil.Ylb;
import com.bsth.entity.sys.SysUser;
import com.bsth.security.util.SecurityUtils;
import com.bsth.service.oil.YlbService;
import com.bsth.util.ReportUtils;
import com.google.common.base.Splitter;
@RestController
@RequestMapping("ylb")
public class YlbController extends BaseController<Ylb, Integer>{
@Autowired
YlbService yblService;
@RequestMapping(value = "/saveYlb",method = RequestMethod.POST)
public Map<String, Object> saveYlb(Ylb t){
// SysUser user = SecurityUtils.getCurrentUser();
t.setCreatetime(new Date());
// Ylb t=new Ylb();
return yblService.saveYlb(t);
}
/**
* 把加油(YLXXB)的数据加入
* @param map
* @return
*/
@RequestMapping(value = "/obtain",method = RequestMethod.GET)
public Map<String, Object> obtain(@RequestParam Map<String, Object> map) throws Exception{
Map<String, Object> list =new HashMap<String, Object>();
try {
list = yblService.obtain(map);
} catch (Exception e) {
// TODO Auto-generated catch block
throw e;
}
System.out.println();
return list;
}
@RequestMapping(value = "/saveYlbList",method = RequestMethod.POST)
public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){
Map<String, Object> list=new HashMap<String, Object>();
try {
list = yblService.saveYlbList(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
/**
* 拆分油量
* @param map
* @return
*/
@RequestMapping(value = "/sort",method = RequestMethod.POST)
public Map<String, Object> sort(@RequestParam Map<String, Object> map){
Map<String, Object> list=new HashMap<String, Object>();
try {
list=yblService.sort(map);
} catch (Exception e) {
// TODO: handle exception
}
return list;
}
/**
* 进场油量等于出场油量
* @param map
* @return
*/
@RequestMapping(value = "/outAndIn",method = RequestMethod.GET)
public Map<String, Object> outAndIn(@RequestParam Map<String, Object> map) throws Exception{
Map<String, Object> list=new HashMap<String, Object>();
try {
list=yblService.outAndIn(map);
} catch (Exception e) {
// TODO: handle exception
}
return list;
}
/**
* 核对油量(有加油没里程)
* @param map
* @return
*/
@RequestMapping(value = "/checkYl",method = RequestMethod.GET)
public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){
Map<String, Object> list=new HashMap<String, Object>();
try {
list=yblService.checkYl(map);
} catch (Exception e) {
// TODO: handle exception
}
return list;
}
/**
*
* @Title: list
* @Description: TODO(多条件分页查询)
* @param @param map 查询条件
* @param @param page 页码
* @param @param size 每页显示数量
* @throws
*/
@RequestMapping(method = RequestMethod.GET)
public Page<Ylb> list(@RequestParam Map<String, Object> map,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size,
@RequestParam(defaultValue = "id") String order,
@RequestParam(defaultValue = "DESC") String direction){
Direction d;
map.put("xlbm_like", map.get("xlbm_like").toString().trim());
String rq=map.get("rq").toString();
int lx=Integer.parseInt(map.get("sxtj").toString().trim());
if(lx>0){
map.put("nbbm_in", yblService.checkNbmmNum(rq, map.get("ssgsdm_like").toString(),
map.get("fgsdm_like").toString(), map.get("xlbm_like").toString(),
map.get("nbbm_eq").toString(),lx));
}
// try {
if(!(rq=="")){
//
// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
// Calendar calendar = new GregorianCalendar();
// calendar.setTime(sdf.parse(rq));
// calendar.add(calendar.DATE,1);
// Date date=calendar.getTime();
map.put("rq_eq", rq);
// map.put("rq_lt", sdf.format(date));
// System.out.println(rq);
// System.out.println(sdf.format(date));
}
// } catch (ParseException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
if(null != direction && direction.equals("ASC"))
d = Direction.ASC;
else
d = Direction.DESC;
// 允许多个字段排序,order可以写单个字段,也可以写多个字段
// 多个字段格式:{col1},{col2},{col3},....,{coln}
// 每个字段的排序方向都是一致,这个以后再看要不要改
List<String> list = Splitter.on(",").trimResults().splitToList(order);
return baseService.list(map, new PageRequest(page, size, new Sort(d, list)));
}
/**
*
* @Title: list
* @Description: TODO(多条件分页查询)
* @param @param map 查询条件
* @param @param page 页码
* @param @param size 每页显示数量
* @throws
*/
@RequestMapping(value = "/ylbList",method = RequestMethod.GET)
public List<Ylb> ylbList(@RequestParam Map<String, Object> map){
List<Ylb> ylbList=yblService.listYlb(map);
return ylbList;
}
@RequestMapping(value = "/deleteIds", method = RequestMethod.POST)
public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) {
Map<String, Object> maps=new HashMap<String, Object>();
try {
maps= yblService.deleteIds(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return maps;
}
@RequestMapping(value="/oilListMonth")
public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){
return yblService.oilListMonth(line, date);
}
@RequestMapping(value = "/checkJsy",method = RequestMethod.GET)
public String checkJsy(@RequestParam Map<String, Object> map){
String list=yblService.checkJsy(map);
return list;
}
@RequestMapping(value = "/sumYlb",method = RequestMethod.GET)
public Map<String, Object> sumYlb(@RequestParam Map<String, Object> map){
Map<String, Object> list=yblService.sumYlb(map);
return list;
}
@RequestMapping(value = "/listExport",method = RequestMethod.POST)
public List<Map<String, Object>> listExport(@RequestParam Map<String, Object> map){
SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
sdfSimple = new SimpleDateFormat("yyyyMMdd");
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
ReportUtils ee = new ReportUtils();
List<Ylb> ylb= yblService.listYlb(map);
// (new CustomerSpecs<Ylb>(map)).iterator();
List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
for (Ylb y : ylb) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("rq", y.getRq());
m.put("gsname",y.getGsname() );
m.put("fgsname", y.getFgsname());
m.put("xlname", y.getXlname());
m.put("nbbm", y.getNbbm());
m.put("jsy", y.getJsy());
m.put("name", y.getName());
m.put("jzl", y.getJzl());
m.put("czlc", y.getCzlc());
m.put("jzlc", y.getJzlc());
m.put("czyl", y.getCzyl());
m.put("jzyl", y.getJzyl());
m.put("yh", y.getYh());
String rylx="";
if(y.getRylx()!=null){
if(y.getRylx().equals("0")){rylx="0号柴油";}
if(y.getRylx().equals("1")){rylx="负10号柴油";}
}
m.put("rylx", rylx);
m.put("ns", y.getNs());
String shyy ="无";
if(y.getShyy()!=null){
if(shyy.equals("1")){shyy="票务用油";}
else if(shyy.equals("2")){shyy="保养用油";}
else if(shyy.equals("3")){shyy="报废车用油";}
else if(shyy.equals("4")){shyy="其它用油";}
else if(shyy.equals("5")){shyy="人保部";}
else if(shyy.equals("6")){shyy="车队";}
else if(shyy.equals("7")){shyy="车间(高保)";}
else if(shyy.equals("8")){shyy="车间(小修)";}
else{shyy ="无";}
}
m.put("shyy", shyy);
m.put("sh", y.getSh());
m.put("zlc", y.getZlc());
m.put("bglyh", y.getBglyh());
resList.add(m);
}
try {
listI.add(resList.iterator());
String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
ee.excelReplace(listI, new Object[] { map }, path+"mould/list.xls",
path+"export/"+map.get("rq").toString()+ "进出场存油量.xls");
} catch (Exception e) {
e.printStackTrace();
}
return resList;
}
}