|
@@ -4,16 +4,13 @@ import java.math.BigDecimal;
|
4
|
4
|
import java.text.ParseException;
|
5
|
5
|
import java.text.SimpleDateFormat;
|
6
|
6
|
import java.util.*;
|
7
|
|
-import java.util.stream.Collectors;
|
8
|
7
|
import javax.servlet.http.HttpServletResponse;
|
9
|
8
|
|
10
|
9
|
import com.alibaba.fastjson2.JSONArray;
|
11
|
10
|
import com.alibaba.fastjson2.JSONObject;
|
12
|
11
|
import com.ruoyi.common.utils.DateUtils;
|
13
|
12
|
import com.ruoyi.oa.domain.CmcCarApproval;
|
14
|
|
-import com.ruoyi.oa.domain.CmcProject;
|
15
|
13
|
import com.ruoyi.oa.service.ICmcCarApprovalService;
|
16
|
|
-import com.ruoyi.system.service.ISysUserService;
|
17
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
15
|
|
19
|
16
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -92,8 +89,9 @@ public class CmcCarController extends BaseController
|
92
|
89
|
JSONObject yearObject = new JSONObject();
|
93
|
90
|
JSONArray statusArray = new JSONArray();
|
94
|
91
|
JSONObject statusObject = new JSONObject();
|
|
92
|
+ JSONArray usageArray = new JSONArray();
|
|
93
|
+ JSONObject usageObject = new JSONObject();
|
95
|
94
|
JSONArray approvalArray = new JSONArray();
|
96
|
|
- JSONObject approvalObject = new JSONObject();
|
97
|
95
|
CmcCar cmcCar = new CmcCar();
|
98
|
96
|
cmcCar.setStatus("0");
|
99
|
97
|
statusObject.put("已派出", cmcCarService.selectCmcCarList(cmcCar).size());
|
|
@@ -113,6 +111,7 @@ public class CmcCarController extends BaseController
|
113
|
111
|
cmcCarApproval.setApplyDate(new SimpleDateFormat("yyyy").parse(String.valueOf(i)));
|
114
|
112
|
List<CmcCarApproval> yearList = cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval);
|
115
|
113
|
yearObject.put(String.valueOf(i), yearList.size());
|
|
114
|
+ getCarUsageStatistic(cmcCarApproval, usageObject);
|
116
|
115
|
}
|
117
|
116
|
cmcCarApproval.setApplyDate(null);
|
118
|
117
|
}
|
|
@@ -121,13 +120,16 @@ public class CmcCarController extends BaseController
|
121
|
120
|
//输入年份派车次数
|
122
|
121
|
yearObject.put(new SimpleDateFormat("yyyy").format(cmcCarApproval.getApplyDate()), cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
123
|
122
|
}
|
124
|
|
- getCarApprovalStatistic(cmcCarApproval, approvalObject);
|
|
123
|
+ getCarUsageStatistic(cmcCarApproval, usageObject);
|
|
124
|
+ getCarApprovalStatistic(cmcCarApproval, approvalArray);
|
125
|
125
|
yearArray.add(yearObject);
|
126
|
126
|
statusArray.add(statusObject);
|
127
|
|
- approvalArray.add(approvalObject);
|
|
127
|
+ usageArray.add(usageObject);
|
128
|
128
|
jsonObject.put("year", yearArray);
|
129
|
|
- jsonObject.put("status",statusArray);
|
130
|
|
- jsonObject.put("approval",approvalArray);
|
|
129
|
+ jsonObject.put("status", statusArray);
|
|
130
|
+ jsonObject.put("usage", usageArray);
|
|
131
|
+ jsonObject.put("approval", approvalArray);
|
|
132
|
+ jsonObject.getJSONArray("approval").sort((a,b)->((JSONObject)b).getIntValue("count") - ((JSONObject)a).getIntValue("count"));
|
131
|
133
|
return success(jsonObject);
|
132
|
134
|
}
|
133
|
135
|
|
|
@@ -191,15 +193,32 @@ public class CmcCarController extends BaseController
|
191
|
193
|
}
|
192
|
194
|
|
193
|
195
|
//各车辆派出次数
|
194
|
|
- public void getCarApprovalStatistic(CmcCarApproval cmcCarApproval, JSONObject approvalObject) {
|
195
|
|
- //类型太多,循环效率不高-直接用Java特性进行分组统计
|
196
|
|
- Map<Object, Long> typeGroup = cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).stream().collect(Collectors.groupingBy(item -> Optional.ofNullable(item.getCars()), Collectors.counting()));
|
197
|
|
- List<Map.Entry<Object, Long>> typeList = new ArrayList<>(typeGroup.entrySet());
|
198
|
|
- typeList.sort(Map.Entry.comparingByValue());
|
199
|
|
- typeList.forEach((item) -> {
|
200
|
|
- if (item.getKey() != Optional.empty())
|
201
|
|
- approvalObject.put(item.toString().substring(item.toString().indexOf("[") + 1, item.toString().indexOf("]")), item.getValue());
|
202
|
|
- });
|
|
196
|
+ public void getCarApprovalStatistic(CmcCarApproval cmcCarApproval, JSONArray approvalArray) {
|
|
197
|
+ for (CmcCar cmcCar : cmcCarService.selectCmcCarList(new CmcCar())) {
|
|
198
|
+ cmcCarApproval.setCars(cmcCar.getCarId().toString());
|
|
199
|
+ int count = cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size();
|
|
200
|
+ if (count > 0) {
|
|
201
|
+ JSONObject approvalObject = new JSONObject();
|
|
202
|
+ approvalObject.put("name", cmcCar.getLicensePlate());
|
|
203
|
+ approvalObject.put("count", count);
|
|
204
|
+ approvalArray.add(approvalObject);
|
|
205
|
+ }
|
|
206
|
+ }
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ //各车辆派出次数
|
|
210
|
+ public void getCarUsageStatistic(CmcCarApproval cmcCarApproval, JSONObject usageObject) {
|
|
211
|
+ cmcCarApproval.setCarUsage("0");
|
|
212
|
+ usageObject.put("项目用车", cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
|
213
|
+ cmcCarApproval.setCarUsage("1");
|
|
214
|
+ usageObject.put("非项目用车", cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
|
215
|
+ cmcCarApproval.setCarUsage("2");
|
|
216
|
+ usageObject.put("工会用车", cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
|
217
|
+ cmcCarApproval.setCarUsage("3");
|
|
218
|
+ usageObject.put("党委用车", cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
|
219
|
+ cmcCarApproval.setCarUsage("4");
|
|
220
|
+ usageObject.put("团委用车", cmcCarApprovalService.selectCmcCarApprovalList(cmcCarApproval).size());
|
|
221
|
+ cmcCarApproval.setCarUsage(null);
|
203
|
222
|
}
|
204
|
223
|
|
205
|
224
|
}
|