DlbController.java
7.92 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
package com.bsth.controller.oil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
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.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.Dlb;
import com.bsth.entity.oil.Ylb;
import com.bsth.service.oil.DlbService;
import com.bsth.util.Arith;
import com.bsth.util.ReportUtils;
import com.google.common.base.Splitter;
@RestController
@RequestMapping("dlb")
public class DlbController extends BaseController<Dlb, Integer>{
@Autowired
DlbService service;
/**
*
* @Title: list
* @Description: TODO(多条件分页查询)
* @param @param map 查询条件
* @param @param page 页码
* @param @param size 每页显示数量
* @throws
*/
@RequestMapping(method = RequestMethod.GET)
public Page<Dlb> 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());
// try {
String rq=map.get("rq").toString();
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)));
}
@RequestMapping(value = "/dlbList",method = RequestMethod.GET)
public List<Dlb> dlbList(@RequestParam Map<String, Object> map){
List<Dlb> list=service.listDlb(map);
return list;
}
@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 = service.obtain(map);
} catch (Exception e) {
// TODO Auto-generated catch block
throw e;
}
return list;
}
/**
* 保存电量
* @param map
* @return
*/
@RequestMapping(value = "/sort",method = RequestMethod.GET)
public Map<String, Object> sort(@RequestParam Map<String, Object> map){
Map<String, Object> list=service.sort(map);
return list;
}
/**
* 核对电量(有加电没里程)
* @param map
* @return
*/
@RequestMapping(value = "/checkDl",method = RequestMethod.GET)
public Map<String, Object> checkDl(@RequestParam Map<String, Object> map){
Map<String, Object> list=service.checkDl(map);
return list;
}
@RequestMapping(value = "/sumYlb",method = RequestMethod.GET)
public Map<String, Object> sumYlb(@RequestParam Map<String, Object> map){
Map<String, Object> list=service.sumYlb(map);
return list;
}
@RequestMapping(value = "/saveDlbList",method = RequestMethod.POST)
public Map<String, Object> saveDlbList(@RequestParam Map<String, Object> map){
Map<String, Object> list=new HashMap<String, Object>();
try {
list = service.saveDlbList(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
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<Dlb> dlb= service.listDlb(map);
// (new CustomerSpecs<Ylb>(map)).iterator();
List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
for (Dlb y : dlb) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("rq", y.getRq());
m.put("gsname",y.getGsname() );
m.put("fgsname", y.getFgsname());
if(y.getLinename()==null){
m.put("xlname", y.getXlname()==null?"":y.getXlname());
}else{
m.put("xlname", y.getLinename());
}
m.put("nbbm", y.getNbbm());
m.put("jsy", y.getJsy());
m.put("name", y.getName());
m.put("cdl", y.getCdl()<=0?"0":y.getCdl());
m.put("czcd", y.getCzcd()<=0?"0":y.getCzcd()+"%");
m.put("jzcd", y.getJzcd()<=0?"0":y.getJzcd()+"%");
m.put("czlc", y.getCzlc()<=0?"0":y.getCzlc());
m.put("jzlc", y.getJzlc()<=0?"0":y.getJzlc());
m.put("hd", y.getHd()<=0?"0":y.getHd());
String shyy ="无";
if(y.getShyy()!=null){
shyy=y.getShyy();
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("ns", y.getNs()<=0?"0":y.getNs());
m.put("shyy", shyy);
m.put("sh", y.getSh()<=0?"0":y.getSh());
m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
m.put("rdlx", "");
m.put("bglyh", y.getBglyh());
m.put("zdh", Arith.add(y.getSh(), y.getHd()));
resList.add(m);
}
try {
map.put("sheetName", map.get("rq"));
listI.add(resList.iterator());
String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
ee.excelReplace(listI, new Object[] { map }, path+"mould/listDl.xls",
path+"export/"+map.get("rq").toString()+ "Entry and exit power.xls");
} catch (Exception e) {
e.printStackTrace();
}
return resList;
}
@RequestMapping(value = "/checkJsy",method = RequestMethod.GET)
public String checkJsy(@RequestParam Map<String, Object> map){
String list=service.checkJsy(map);
return list;
}
@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= service.deleteIds(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return maps;
}
@RequestMapping(value = "/saveDlb",method = RequestMethod.POST)
public Map<String, Object> saveDlb(Dlb t){
// SysUser user = SecurityUtils.getCurrentUser();
t.setCreatetime(new Date());
// Ylb t=new Ylb();
return service.saveDlb(t);
}
@RequestMapping(value = "/updateJsy",method = RequestMethod.GET)
public Map<String, Object> updateJsy(@RequestParam Map<String, Object> map){
return service.update(map);
}
}