台湾展会用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

50 lines
1.5 KiB

package com.yvan.logisticsModel;
import com.google.common.collect.Maps;
import com.yvan.logisticsEnv.LogisticsEnv;
import java.util.Map;
/**
* 物流运行时服务类
*/
public class LogisticsRuntimeService {
public static final LogisticsRuntimeService INSTANCE = new LogisticsRuntimeService();
private static final Object LOCK = new Object();
private final Map<Long, LogisticsRuntime> runtimeMap = Maps.newHashMap();
/**
* 根据 EnvCode 查找物流运行时实例
*/
public LogisticsRuntime findByEnvCode(long envId) {
synchronized (LOCK) {
return runtimeMap.get(envId);
}
}
/**
* 根据项目UUID和目录代码查找物流运行时实例
*/
public LogisticsRuntime findByProjectFloor(String projectUUID, String catalogCode) {
for (LogisticsRuntime runtime : runtimeMap.values()) {
if (projectUUID.equals(runtime.projectUUID) && catalogCode.equals(runtime.catalogCode)) {
return runtime;
}
}
return null;
}
public void createEnv(long envId) {
synchronized (LOCK) {
if (runtimeMap.containsKey(envId)) {
return;
}
LogisticsEnv env = new LogisticsEnv();
env.setEnvId(envId);
env.setVirtual(envId != 1L);
LogisticsRuntime runtime = new LogisticsRuntime(env);
runtimeMap.put(env.getEnvId(), runtime);
}
}
}