You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.1 KiB
Java
78 lines
2.1 KiB
Java
package com.docus.server.collection.config;
|
|
|
|
import com.docus.infrastructure.core.utils.TableJsonRead;
|
|
import lombok.Data;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 系统映射配置
|
|
*
|
|
* @author wyb
|
|
*/
|
|
public class SystemMappingConfig {
|
|
private static final String CONFIG_FILE_PATH = "dataConfig";
|
|
private static final String CONFIG_FILE_NAME = "System-Mapping.json";
|
|
private static volatile boolean FLUSH;
|
|
private static volatile SystemMappingConfig INSTANCE;
|
|
private final List<SystemMapping> systemMappingList;
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "SystemMappingConfig{" +
|
|
"systemMappingList=" + systemMappingList +
|
|
'}';
|
|
}
|
|
|
|
private SystemMappingConfig() {
|
|
TableJsonRead jsonRead = new TableJsonRead();
|
|
List<SystemMapping> list = jsonRead.Read(CONFIG_FILE_PATH, CONFIG_FILE_NAME, ArrayList.class);
|
|
this.systemMappingList = list;
|
|
}
|
|
|
|
public static SystemMappingConfig getInstance() {
|
|
if (INSTANCE == null || FLUSH) {
|
|
synchronized (SystemMappingConfig.class) {
|
|
if (INSTANCE == null || FLUSH) {
|
|
INSTANCE = new SystemMappingConfig();
|
|
}
|
|
}
|
|
}
|
|
return INSTANCE;
|
|
}
|
|
|
|
/**
|
|
* 配置文件有更新,适用于不是程序动态改变的配置文件
|
|
*/
|
|
public static void flush() {
|
|
FLUSH = true;
|
|
}
|
|
|
|
public List<SystemMapping> getSystemMappingList() {
|
|
return systemMappingList;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
SystemMappingConfig instance = getInstance();
|
|
System.out.println(instance);
|
|
SystemMappingConfig instance2 = getInstance();
|
|
System.out.println(instance == instance2);
|
|
SystemMappingConfig.flush();
|
|
SystemMappingConfig instance3 = getInstance();
|
|
System.out.println(instance3 == instance2);
|
|
}
|
|
|
|
@Data
|
|
public static class SystemMapping {
|
|
/**
|
|
* 医院系统标识
|
|
*/
|
|
private String hospital;
|
|
/**
|
|
* 无纸化医院标识
|
|
*/
|
|
private String wzh;
|
|
}
|
|
}
|