LsylbController.java
4.91 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
package com.bsth.controller.oil;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
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.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.Lsylb;
import com.bsth.entity.oil.Ylb;
import com.bsth.service.oil.LsylbService;
import com.bsth.util.Arith;
import com.bsth.util.ReportUtils;
@RestController
@RequestMapping("lsylb")
public class LsylbController extends BaseController<Ylb, Integer>{
@Autowired
LsylbService lsylbService;
@RequestMapping(value = "/lsylbList",method = RequestMethod.GET)
public List<Lsylb> lsylbList(@RequestParam Map<String, Object> map){
List<Lsylb> ylbList=lsylbService.listYlb(map);
return ylbList;
}
@RequestMapping(value = "/sumLsylb",method = RequestMethod.GET)
public Map<String, Object> sumLsylb(@RequestParam Map<String, Object> map){
Map<String, Object> list=lsylbService.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<Lsylb> lsylb= lsylbService.listYlb(map);
String nylx=map.get("nylx").toString();
// (new CustomerSpecs<Ylb>(map)).iterator();
List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
for (Lsylb y : lsylb) {
Map<String, Object> m = new HashMap<String, Object>();
m.put("rq", sdfMonth.format(y.getRq()));
m.put("gsname",y.getGsname() );
m.put("fgsname", y.getFgsname());
m.put("xlname", y.getXlname()==null?"":y.getXlname());
m.put("nbbm", y.getNbbm());
m.put("jsy", y.getJsy());
m.put("name", y.getName());
m.put("czlc", "0");
m.put("jzlc", "0");
m.put("sh", y.getSh()==null?"0":y.getSh());
String shyy ="无";
if(nylx.equals("0")){
m.put("jzl", y.getJzl()==null?"0":y.getJzl());
m.put("czyl", y.getCzyl()==null?"0":y.getCzyl());
m.put("jzyl", y.getJzyl()==null?"0":y.getJzyl());
m.put("yh", y.getYh()==null?"0":y.getYh());
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("zyh", Arith.add(m.get("sh"), m.get("yh")));
String rylx="";
if(y.getRylx()!=null){
if(y.getRylx().equals("0")){rylx="0号柴油";}
if(y.getRylx().equals("1")){rylx="负10号柴油";}
}
m.put("rylx", rylx);
}else{
m.put("cdl", y.getJzl()==null?"0":y.getJzl());
m.put("czcd", y.getCzyl()==null?"0":y.getCzyl());
m.put("jzcd", y.getJzyl()==null?"0":y.getJzyl());
m.put("hd", y.getYh()==null?"0":y.getYh());
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("zyh", Arith.add(m.get("sh"), m.get("hd")));
m.put("rdlx", "");
}
m.put("shyy", shyy);
m.put("ns", y.getNs()==null?"0":y.getNs());
m.put("zlc", y.getZlc()==null?"0":y.getZlc());
m.put("bglyh", y.getBglyh());
resList.add(m);
}
try {
map.put("sheetName", map.get("rq"));
listI.add(resList.iterator());
String xls="";
String name="";
if(nylx.equals("0")){
xls="list.xls";
name="进出场存油量.xls";
}else{
xls="listDl.xls";
name="进出场存电量.xls";
}
String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
ee.excelReplace(listI, new Object[] { map }, path+"mould/"+xls,
path+"export/"+map.get("rq").toString()+ name);
} catch (Exception e) {
e.printStackTrace();
}
return resList;
}
}