JdTestController.java
5.18 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
package com.bsth.controller.jdtest;
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.data.BasicData;
import com.bsth.entity.oil.Ylb;
import com.bsth.entity.oil.Ylxxb;
import com.bsth.entity.sys.Dictionary;
import com.bsth.service.jdtest.JdtestService;
import com.bsth.service.oil.YlbService;
import com.bsth.service.sys.DictionaryService;
import com.bsth.util.Arith;
import com.bsth.util.ReportUtils;
@RestController
@RequestMapping("jdtest")
public class JdTestController extends BaseController<Ylb, Integer>{
@Autowired
YlbService ylbService;
@Autowired
DictionaryService dictionaryService;
@Autowired
JdtestService jdtestService;
/*
* 油量平衡表导出
*/
@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");
Map<String, Object> dMap=new HashMap<>();
dMap.put("dGroup_eq", "oilType");
Iterator<Dictionary> it= dictionaryService.list(dMap).iterator();
while (it.hasNext()) {
Dictionary d=it.next();
dMap.put(d.getdCode(), d.getdName());
}
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
ReportUtils ee = new ReportUtils();
List<Ylb> ylb= ylbService.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", 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("jzl", y.getJzl()<=0?"0":y.getJzl());
m.put("czlc", "0");
m.put("jzlc", "0");
m.put("czyl", y.getCzyl()<=0?"0":y.getCzyl());
m.put("jzyl", y.getJzyl()<=0?"0":y.getJzyl());
m.put("yh", y.getYh()<=0?"0":y.getYh());
String rylx="";
if(y.getRylx()!=null){
if(dMap.get(y.getRylx())==null){
rylx="";
}else{
rylx=dMap.get(y.getRylx()).toString();
}
}
m.put("rylx", rylx);
m.put("ns", y.getNs()==null?"0":y.getNs());
String shyy ="$$$$$${txt-4226}";
if(y.getShyy()!=null){
shyy=y.getShyy();
if(shyy.equals("1")){shyy="$$$$$${txt-2788}";}
else if(shyy.equals("2")){shyy="$$$$$${txt-2787}";}
else if(shyy.equals("3")){shyy="$$$$$${txt-2032}";}
else if(shyy.equals("4")){shyy="$$$$$${txt-2785}";}
else if(shyy.equals("5")){shyy="$$$$$${txt-3541}";}
else if(shyy.equals("6")){shyy="$$$$$${txt-3978}";}
else if(shyy.equals("7")){shyy="$$$$$${txt-3976}";}
else if(shyy.equals("8")){shyy="$$$$$${txt-3975}";}
else{shyy ="$$$$$${txt-4226}";}
}
m.put("shyy", shyy);
m.put("sh", y.getSh()<=0?"0":y.getSh());
m.put("zlc", y.getZlc()<=0?"0":y.getZlc());
m.put("bglyh", y.getBglyh());
m.put("zyh", Arith.add(y.getSh(), y.getYh()));
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/list.xls",
path+"export/"+map.get("rq").toString()+ "$$$$$${txt-1596}.xls");
} catch (Exception e) {
e.printStackTrace();
}
return resList;
}
/*
* 场外加油匹配当天线路数据
*/
@RequestMapping(value = "/cwjyList",method = RequestMethod.GET)
public List<Ylxxb> cwjyList(@RequestParam Map<String, Object> map){
List<Ylxxb> cwjyList=jdtestService.cwjyList(map);
return cwjyList;
}
/*
* 油量路单报表
*/
@RequestMapping(value="/daily",method = RequestMethod.GET)
public List<Map<String, Object>> daily(@RequestParam Map<String, Object> map){
List<Map<String, Object>> list=jdtestService.daily(map);
if(map.get("type").toString().equals("export")){
List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
ReportUtils ee = new ReportUtils();
Map<String, Object> m=new HashMap<>();
try {
String lineName = map.get("lineName").toString();
String date = map.get("date").toString();
m.put("line", lineName);
m.put("date", date);
listI.add(list.iterator());
String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
ee.excelReplace(listI, new Object[] { m }, path + "mould/jd_daily.xls",
path + "export/" + date
+ "-" + lineName + "-$$$$$${txt-1897}.xls");
} catch (Exception e) {
e.printStackTrace();
}
}
return list;
}
}