|
@@ -381,6 +381,27 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
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));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据停车场编号获取当前车场入场数
|
|
|
+ *
|
|
|
+ * @param parkCode 停车场编号
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Double getCurrentParkInNum(String parkCode) {
|
|
|
+ List<String> parkCodeList = Arrays.asList(parkCode);
|
|
|
+ if (StringUtils.isBlank(parkCode)) {
|
|
|
+ parkCodeList = ParkUtils.getParkCodeList();
|
|
|
+ }
|
|
|
+ AtomicReference<Integer> inCountResult = new AtomicReference<>(0);
|
|
|
+ parkCodeList.forEach(code -> {
|
|
|
+ String format = LocalDateTimeUtil.format(LocalDateTime.now(), DatePattern.PURE_DATE_PATTERN);
|
|
|
+ JSONObject inObj = mongoTemplate.findById(code + "_" + format, JSONObject.class, ParkType.IN.getCode());
|
|
|
+ Double inCount = inObj == null ? 0 : inObj.getDouble("count");
|
|
|
+ inCountResult.set(inCount.intValue() + inCountResult.get());
|
|
|
+ });
|
|
|
+ return inCountResult.get().doubleValue();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 今日车场流量分析分页查询折线
|
|
|
*
|
|
@@ -654,24 +675,27 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
parkCodeList = ParkUtils.getParkCodeList();
|
|
|
}
|
|
|
List<Levi> list = new ArrayList<>();
|
|
|
- Levi result = Levi.by("cwzzl", "0%").set("tcwds", "0").set("yzcws", "0").set("kxcws", "0");
|
|
|
+ Levi result = Levi.by("cwzzl", "0.00").set("tcwds", "0").set("yzcws", "0").set("kxcws", "0");
|
|
|
JSONObject obj = mongoTemplate.findById("parkSpaceLatest", JSONObject.class, "parkSpace");
|
|
|
if (obj == null) {
|
|
|
return ResponseBuilder.ok(result);
|
|
|
}
|
|
|
JSONObject data = obj != null ? obj.getJSONObject("data") : new JSONObject();
|
|
|
+ AtomicReference<Integer> inCountResult = new AtomicReference<>(0);
|
|
|
parkCodeList.forEach(code -> {
|
|
|
if (data.getJSONObject(code) != null) {
|
|
|
+ Double currentParkInNum = getCurrentParkInNum(code);
|
|
|
JSONObject jsonObject = data.getJSONObject(code);
|
|
|
Levi set = Levi.by("parkName", jsonObject.getString("parkName")).set("tcwds", jsonObject.getInteger("totalSpace")).set("kxcws", jsonObject.getInteger("remainSpace")).set("yzcws", jsonObject.getInteger("totalSpace") - jsonObject.getInteger("remainSpace"));
|
|
|
- set.set("cwzzl", EnergyUtils.getPercent(Double.parseDouble(set.getStr("yzcws")), Double.parseDouble(set.getStr("tcwds"))));
|
|
|
+ set.set("cwzzl", EnergyUtils.divide(currentParkInNum, Double.parseDouble(set.getStr("tcwds")), 2));
|
|
|
list.add(set);
|
|
|
result.set("tcwds", (Integer.parseInt(result.getStr("tcwds")) + jsonObject.getInteger("totalSpace") + ""))
|
|
|
.set("kxcws", (Integer.parseInt(result.getStr("kxcws")) + jsonObject.getInteger("remainSpace") + ""));
|
|
|
result.set("yzcws", (Integer.parseInt(result.getStr("tcwds")) - Integer.parseInt(result.getStr("kxcws"))) + "");
|
|
|
- result.set("cwzzl", EnergyUtils.getPercent(Double.parseDouble(result.getStr("yzcws")), Double.parseDouble(result.getStr("tcwds"))));
|
|
|
+ inCountResult.set(currentParkInNum.intValue() + inCountResult.get());
|
|
|
}
|
|
|
});
|
|
|
+ result.set("cwzzl", EnergyUtils.divide(inCountResult.get().doubleValue(), Double.parseDouble(result.getStr("tcwds")), 2));
|
|
|
result.set("list", list);
|
|
|
return ResponseBuilder.ok(result);
|
|
|
}
|
|
@@ -699,10 +723,10 @@ public class ParkSystemServiceImpl implements ParkSystemService {
|
|
|
if (data.getJSONObject(code) != null) {
|
|
|
JSONObject jsonObject = data.getJSONObject(code);
|
|
|
Levi set = Levi.by("parkName", parkCodeMap.get(code)).set("tcwds", jsonObject.getInteger("totalSpace")).set("kxcws", jsonObject.getInteger("remainSpace")).set("yzcws", jsonObject.getInteger("totalSpace") - jsonObject.getInteger("remainSpace"));
|
|
|
- set.set("cwzzl", EnergyUtils.getPercent(Double.parseDouble(set.getStr("yzcws")), Double.parseDouble(set.getStr("tcwds"))));
|
|
|
+ set.set("cwzzl", EnergyUtils.divide(getCurrentParkInNum(code), Double.parseDouble(set.getStr("tcwds")), 2));
|
|
|
list.add(set);
|
|
|
} else {
|
|
|
- list.add(Levi.by("parkName", parkCodeMap.get(code)).set("tcwds", 0).set("kxcws", 0).set("yzcws", 0).set("cwzzl", "0%"));
|
|
|
+ list.add(Levi.by("parkName", parkCodeMap.get(code)).set("tcwds", 0).set("kxcws", 0).set("yzcws", 0).set("cwzzl", "0.00"));
|
|
|
}
|
|
|
});
|
|
|
}
|