|
@@ -83,7 +83,10 @@ public class ParkUtils {
|
|
|
* @return
|
|
|
*/
|
|
|
public static List<Map> setDataField(Object obj, String pkId, String collectionName, boolean flag, String orderKey, Levi<String, String> other) {
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
+ return setDataField(obj, pkId, collectionName, flag, orderKey, other, LocalDateTime.now());
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Map> setDataField(Object obj, String pkId, String collectionName, boolean flag, String orderKey, Levi<String, String> other, LocalDateTime now) {
|
|
|
int hour = now.getHour();
|
|
|
String format = LocalDateTimeUtil.format(now, DatePattern.PURE_DATE_PATTERN);
|
|
|
Map dayMap = mongoTemplate.findById(pkId + "_" + format, Map.class, collectionName);
|
|
@@ -119,6 +122,7 @@ public class ParkUtils {
|
|
|
return hourList;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取封装后的结果集
|
|
|
*
|
|
@@ -152,6 +156,20 @@ public class ParkUtils {
|
|
|
return getInsertMap(params, null);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取某批推送的时间点
|
|
|
+ *
|
|
|
+ * @param list 推送数据
|
|
|
+ * @param timeKey 时间字段
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static LocalDateTime getResultLocalDateTime(List<Map> list, String timeKey) {
|
|
|
+ if (CollUtil.isNotEmpty(list)) {
|
|
|
+ return LocalDateTimeUtil.parse(list.get(0).get(timeKey).toString(), DatePattern.NORM_DATETIME_PATTERN);
|
|
|
+ }
|
|
|
+ return LocalDateTime.now();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 初始化入场或出场数据
|
|
|
*
|
|
@@ -164,7 +182,7 @@ public class ParkUtils {
|
|
|
if (MapUtil.isNotEmpty(insertMap)) {
|
|
|
insertMap.keySet().forEach(key -> {
|
|
|
// 按小时存入数据用于统计
|
|
|
- ParkUtils.setDataField(insertMap.get(key), key, type.getCode(), false, type.getSort(), Levi.by("pno", pno).set("ts", params.get("ts")));
|
|
|
+ ParkUtils.setDataField(insertMap.get(key), key, type.getCode(), false, type.getSort(), Levi.by("pno", pno).set("ts", params.get("ts")), getResultLocalDateTime(insertMap.get(key), type.getSort()));
|
|
|
// 按车场存入数据 实时统计当前车场内所有车辆信息
|
|
|
Query query = new Query();
|
|
|
query.addCriteria(Criteria.where("_id").is(key));
|
|
@@ -288,6 +306,22 @@ public class ParkUtils {
|
|
|
List<Map> maps = obj.getJSONArray("data").toJavaList(Map.class);
|
|
|
maps.forEach(x -> result.set(x.get("parkCode").toString(), x.get("parkName").toString()));
|
|
|
}
|
|
|
+ // 清理冗余的历史关联关系
|
|
|
+ JSONObject relevanceObj = mongoTemplate.findById("relevanceParkProject", JSONObject.class, "relevanceParkProject");
|
|
|
+ JSONObject relevanceData = relevanceObj != null ? relevanceObj.getJSONObject("data") : new JSONObject();
|
|
|
+ // 清除所有已经不存在的车场
|
|
|
+ Iterator<String> iterator = relevanceData.keySet().iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ String next = relevanceData.getString(iterator.next());
|
|
|
+ if (!result.containsKey(next)) {
|
|
|
+ iterator.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Query q = new Query();
|
|
|
+ q.addCriteria(Criteria.where("_id").is("relevanceParkProject"));
|
|
|
+ Update u = new Update();
|
|
|
+ u.set("data", relevanceData);
|
|
|
+ mongoTemplate.upsert(q, u, "relevanceParkProject");
|
|
|
Query query = new Query();
|
|
|
query.addCriteria(Criteria.where("_id").is("parkCodeList"));
|
|
|
Update update = new Update();
|
|
@@ -378,7 +412,6 @@ public class ParkUtils {
|
|
|
List<Map> list = params.stream().filter(x -> x.get("carNumber").toString().startsWith("无")).collect(Collectors.toList());
|
|
|
List<Map> maps = data.getJSONArray(ParkExceptionType.A.getCode()) == null ? new ArrayList<>() : data.getJSONArray(ParkExceptionType.A.getCode()).toJavaList(Map.class);
|
|
|
maps.addAll(list);
|
|
|
- log.info("异常处理之前:" + JSON.toJSONString(maps));
|
|
|
List<Map> feesTime = ParkUtils.sortDateList(maps, ParkType.IN.getSort(), true);
|
|
|
if (CollUtil.isNotEmpty(feesTime)) {
|
|
|
feesTime.forEach(x -> {
|
|
@@ -386,7 +419,6 @@ public class ParkUtils {
|
|
|
x.put("operator", x.get("inOperator"));
|
|
|
});
|
|
|
}
|
|
|
- log.info("异常处理之后:" + JSON.toJSONString(feesTime));
|
|
|
data.put(ParkExceptionType.A.getCode(), feesTime);
|
|
|
update.set("data", data);
|
|
|
update.set(ParkExceptionType.A.getCode() + "Count", feesTime.size());
|