Ver Fonte

新增液位发送接口,去重复

hfxc226 há 3 meses atrás
pai
commit
a6db826197

+ 8 - 0
platform-service/src/main/java/com/platform/service/remote/impl/RemoteOpcServiceImpl.java

@@ -354,6 +354,14 @@ public class RemoteOpcServiceImpl extends BaseServiceImpl<RemoteOpcMapper, Remot
         // 发送到采购系统
         if (!CollectionUtils.isEmpty(list)) {
             list = list.stream().distinct().collect(Collectors.toList());
+            // 使用Stream进行去重,按照位号去重
+            Map<String, RemoteOpcVO> uniquePersons = list.stream()
+                    .collect(Collectors.toMap(
+                            RemoteOpcVO::getPositionNum, // 按照名字去重
+                            person -> person, // 保留Person对象
+                            (existing, replacement) -> existing // 如果名字重复,保留已有对象
+                    ));
+            list = new ArrayList<>(uniquePersons.values());
             String url = ConfigCache.getLabelByValueAllowNull(SysConfigEnum.PURCHASE_SYSTEM_URL_YEWEI.name());
             if (StringUtil.isEmpty(url)) {
                 throw new BusinessException("请配置采购系统液位接收地址");