| 123456789101112131415161718192021222324252627282930313233343536 |
- package com.persagy.iottransfer.config;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.util.Map;
- import java.util.concurrent.ConcurrentHashMap;
- /**
- * @description:iot-project address and projectid map
- * @author:lgy
- * @data:2021/8/27 14:48
- */
- @Service
- public class ProjectClent {
- public final Map<String, String> addressProjectMap = new ConcurrentHashMap<>();
- @Autowired
- IotProperties iotProperties;
- public String getProject(String address) {
- return addressProjectMap.get(address);
- }
- public String getProject(String address, String message) {
- if (addressProjectMap.containsKey(address)) {
- return addressProjectMap.get(address);
- }
- for (IotProperties.Project project : iotProperties.projects) {
- if (message.contains(project.getId())) {
- addressProjectMap.put(address, project.getId());
- }
- }
- return addressProjectMap.get(address);
- }
- }
|