|
@@ -243,6 +243,20 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
String formatOld = LocalDateTimeUtil.format(LocalDateTimeUtil.offset(LocalDateTime.now(), -1, ChronoUnit.DAYS), DatePattern.PURE_DATE_PATTERN);
|
|
|
JSONObject inObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.IN.getCode());
|
|
|
JSONObject outObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.OUT.getCode());
|
|
|
+ JSONObject exceptionObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.EXCEPTION.getCode());
|
|
|
+ JSONObject exceptionData = exceptionObj != null ? exceptionObj.getJSONObject("data") : null;
|
|
|
+ JSONObject exceptionObjOld = mongoTemplate.findById(code + "_" + formatOld, JSONObject.class, ParkType.EXCEPTION.getCode());
|
|
|
+ ParkExceptionType.codeList().forEach(x -> exceptionCountResult.set((exceptionObj == null ? 0 : (exceptionObj.getDouble(x + "Count") == null ? 0 : exceptionObj.getDouble(x + "Count").intValue())) + exceptionCountResult.get()));
|
|
|
+ ParkExceptionType.codeList().forEach(x -> exceptionCountOldResult.set((exceptionObjOld == null ? 0 : (exceptionObjOld.getDouble(x + "Count") == null ? 0 : exceptionObjOld.getDouble(x + "Count").intValue())) + exceptionCountOldResult.get()));
|
|
|
+ System.out.println("当前车场:" + code + " 异常数量:" + exceptionCountResult);
|
|
|
+ List<Map> exceptionResult = new ArrayList<>();
|
|
|
+ if (exceptionData != null) {
|
|
|
+ exceptionData.keySet().forEach(x -> exceptionResult.addAll((List<Map>) exceptionData.get(x)));
|
|
|
+ }
|
|
|
+ for (int i = 0; i < indexs.size(); i++) {
|
|
|
+ Levi levi = result.get(i);
|
|
|
+ levi.set("exception", levi.getInt("exception") + ParkUtils.getExceptionDataListByHour(exceptionResult, indexs.get(i)).size());
|
|
|
+ }
|
|
|
if (inObj == null && outObj == null) {
|
|
|
return;
|
|
|
}
|
|
@@ -250,11 +264,6 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
JSONObject inObjOld = mongoTemplate.findById(code + "_" + formatOld, JSONObject.class, ParkType.IN.getCode());
|
|
|
JSONArray outObjList = outObj != null ? outObj.getJSONArray("data") : null;
|
|
|
JSONObject outObjOld = mongoTemplate.findById(code + "_" + formatOld, JSONObject.class, ParkType.OUT.getCode());
|
|
|
- JSONObject exceptionObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.EXCEPTION.getCode());
|
|
|
- JSONObject exceptionData = exceptionObj != null ? exceptionObj.getJSONObject("data") : null;
|
|
|
- JSONObject exceptionObjOld = mongoTemplate.findById(code + "_" + formatOld, JSONObject.class, ParkType.EXCEPTION.getCode());
|
|
|
- ParkExceptionType.codeList().forEach(x -> exceptionCountResult.set(exceptionObj == null ? 0 : (exceptionObj.getDouble(x + "Count") == null ? 0 : exceptionObj.getDouble(x + "Count").intValue()) + exceptionCountResult.get()));
|
|
|
- ParkExceptionType.codeList().forEach(x -> exceptionCountOldResult.set(exceptionObjOld == null ? 0 : (exceptionObjOld.getDouble(x + "Count") == null ? 0 : exceptionObjOld.getDouble(x + "Count").intValue()) + exceptionCountOldResult.get()));
|
|
|
Double inCount = inObj == null ? 0 : inObj.getDouble("count");
|
|
|
Double inCountOld = inObjOld == null ? 0 : inObjOld.getDouble("count");
|
|
|
Double outCount = outObj == null ? 0 : outObj.getDouble("count");
|
|
@@ -263,15 +272,10 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
inCountOldResult.set(inCountOld.intValue() + inCountOldResult.get());
|
|
|
outCountResult.set(outCount.intValue() + outCountResult.get());
|
|
|
outCountOldResult.set(outCountOld.intValue() + outCountOldResult.get());
|
|
|
- List<Map> exceptionResult = new ArrayList<>();
|
|
|
- if (exceptionData != null) {
|
|
|
- exceptionData.keySet().forEach(x -> exceptionResult.addAll((List<Map>) exceptionData.get(x)));
|
|
|
- }
|
|
|
for (int i = 0; i < indexs.size(); i++) {
|
|
|
Levi levi = result.get(i);
|
|
|
levi.set("in", levi.getInt("in") + (inObjList == null ? 0 : inObjList.getJSONObject(indexs.get(i)).getJSONArray("data").size()));
|
|
|
levi.set("out", levi.getInt("out") + (outObjList == null ? 0 : outObjList.getJSONObject(indexs.get(i)).getJSONArray("data").size()));
|
|
|
- levi.set("exception", levi.getInt("exception") + ParkUtils.getExceptionDataListByHour(exceptionResult, indexs.get(i)).size());
|
|
|
}
|
|
|
});
|
|
|
return ResponseBuilder.ok(Levi.by("inCount", inCountResult.get()).set("outCount", outCountResult.get()).set("exceptionCount", exceptionCountResult.get()).set("inPercent", EnergyUtils.getPercent(inCountResult.get().doubleValue(), inCountOldResult.get().doubleValue())).set("outPercent", EnergyUtils.getPercent(outCountResult.get().doubleValue(), outCountOldResult.get().doubleValue())).set("exceptionPercent", EnergyUtils.getPercent(exceptionCountResult.get().doubleValue(), exceptionCountOldResult.get().doubleValue())).set("list", result));
|
|
@@ -368,6 +372,7 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
return ResponseBuilder.ok(PageBean.<Map>builder().total(resStream.get().count()).row(resultsList).build());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 入场车辆通车时间段统计
|
|
|
*
|