Browse Source

解决java.lang.IllegalStateException:Duplicate key异常问题

skyline 1 year ago
parent
commit
a180ddbd5a
1 changed files with 1 additions and 6 deletions
  1. 1 6
      service/src/main/java/com/kym/service/cache/KymCache.java

+ 1 - 6
service/src/main/java/com/kym/service/cache/KymCache.java

@@ -220,12 +220,7 @@ public enum KymCache {
             // 缓存平台数据
             PlatformCache.INSTANCE.putPlatformName2Config(platformService.lambdaQuery().eq(Platform::getEnv, env).list().stream().collect(Collectors.toMap(Platform::getPlatformName, platform -> platform)));
             PlatformCache.INSTANCE.putConnectorId2PlatformName(equipmentRelations.stream().collect(Collectors.toMap(EquipmentRelation::getConnectorId, EquipmentRelation::getPlatformName)));
-//            PlatformCache.INSTANCE.putStationId2PlatformName(equipmentRelations.stream().collect(Collectors.toMap(EquipmentRelation::getStationId, EquipmentRelation::getPlatformName)));
-            var stationList = List.of("1657", "1889", "1897", "1959", "1966", "1997", "2042", "2064", "2144", "2156", "2191", "2041");
-            stationList.forEach(stationId -> {
-                PlatformCache.INSTANCE.putStationId2PlatformName(Map.of(stationId, "EN_PLUS"));
-            });
-
+            PlatformCache.INSTANCE.putStationId2PlatformName(equipmentRelations.stream().collect(Collectors.toMap(EquipmentRelation::getStationId, EquipmentRelation::getPlatformName, (oldValue, newValue) -> oldValue)));
             DynamicDataSourceContextHolder.poll();
         }
     }