package com.yihu.wlyy.util; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @Component public class SystemConf { // 别处登录 public static final int LOGIN_OTHER = 999; // 登录超时 public static final int LOGIN_TIMEOUT = 998; // 未登录 public static final int NOT_LOGIN = 997; // 文件保存临时路径 private static final String TEMP_PATH = "upload_temp_path"; // 血糖餐前最小值 public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4; // 血糖餐前最大值 public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7; // 血糖餐后最小值 public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4; // 血糖餐后最大值 public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1; // 舒张压最小值 public static final double HEALTH_STANDARD_SZY_MIN = 60; // 舒张压最大值 public static final double HEALTH_STANDARD_SZY_MAX = 90; // 收缩压最小值 public static final double HEALTH_STANDARD_SSY_MIN = 90; // 收缩压最大值 public static final double HEALTH_STANDARD_SSY_MAX = 140; // 同一手机号大最短信数 public static final int MAX_SMS_MOBILE = 5; // 发送短信验证码间隔(分钟) public static final int SMS_INTERVAL = 2; private static Object lock = new Object(); // 全局系统配置信息 private static SystemConf systemConf; // 系统配置文件 private Properties systemProperties; //im列表 private String imListGet; public static SystemConf getInstance() { if (systemConf == null) { synchronized (lock) { systemConf = new SystemConf(); } } return systemConf; } /** * 加载系统配置文件 * * @return */ public Properties getSystemProperties() { if (systemProperties == null) { InputStream is = null; try { is = this.getClass().getResourceAsStream("/system.properties"); systemProperties = new Properties(); systemProperties.load(is); } catch (IOException e1) { e1.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } } } return systemProperties; } /** * 短信接口地址 */ public String getSmsUrl() { return getSystemProperties().getProperty("yihu_sms_url"); } /** * 短信企业编号 */ public String getSmsCode() { return getSystemProperties().getProperty("yihu_sms_code"); } /** * 短信用户名 */ public String getSmsName() { return getSystemProperties().getProperty("yihu_sms_name"); } /** * 短信登录密码 */ public String getSmsPassword() { return getSystemProperties().getProperty("yihu_sms_password"); } ; /** * 挂号接口地址 */ public String getGuahaoUrl() { return getSystemProperties().getProperty("yihu_guahao_url"); } /** * 挂号接口对接appid */ public String getGuahaoAppid() { return getSystemProperties().getProperty("yihu_guahao_appid"); } /** * 挂号接口对接app secret */ public String getGuahaoSecret() { return getSystemProperties().getProperty("yihu_guahao_secret"); } /** * IM地址 * * @return */ @Value("${im.im_list_get}") private String im_list_get; public String getImListGet() { return im_list_get; } /** * 获取文件保存的临时路径 * * @return */ public String getTempPath() { return getSystemProperties().getProperty(TEMP_PATH); } /** * 获取图片存在地址 * * @return */ @Value("${images.path}") private String imagesPath; public String getImagePath() { return imagesPath; } @Value("${wechat.appId}") private String appId; @Value("${wechat.appSecret}") private String appSecret; @Value("${wechat.accId}") private String accId; public String getAppId() { return appId; } public String getAccId() { return accId; } public String getAppSecret() { return appSecret; } /** * 获取服务全路径 * * @return */ @Value("${server.server_url}") private String server_url; public String getServerUrl() { return server_url; } public String getServerUrlStr() { return server_url; } /******************************** 挂号配置 ********************************************/ /** * 获取厦门预约服务地址 */ public String getXMGuahaoUrl() { return getSystemProperties().getProperty("guahao_url"); } /** * 获取厦门预约服务命名空间 */ public String getXMGuahaoNamespace() { return getSystemProperties().getProperty("guahao_namespace"); } /****************************************************************************************/ @Value("${sign.check_upload}") private String sign_check_upload; /** * 基卫服务地址 */ public String getJwUrl() { return getSystemProperties().getProperty("sign_check_upload"); } /********************************* EHR配置 **********************************************/ /** * 是否启用EHR演示 */ public Boolean getEhrUsed() { return Boolean.valueOf(getSystemProperties().getProperty("ehr_used")); } /** * EHR档案服务地址 */ public String getEhrServices() { return getSystemProperties().getProperty("ehr_services"); } /** * EHR底层地址 */ public String getEhrServicesBase() { return getSystemProperties().getProperty("ehr_services_base"); } /**************************************************************************************/ /********************************* * 健康之路开放平台 配置 **********************************************/ @Value("${yihu.yihu_OpenPlatform_url}") private String yihu_OpenPlatform_url; @Value("${yihu.yihu_OpenPlatform_appId}") private String yihu_OpenPlatform_appId; @Value("${yihu.yihu_OpenPlatform_secret}") private String yihu_OpenPlatform_secret; /** * 健康之路开放平台url */ public String getYihuOpenPlatformUrl() { return yihu_OpenPlatform_url; } /** * 健康之路开放平台渠道号 */ public String getYihuOpenPlatformAppId() { return yihu_OpenPlatform_appId; } /** * 健康之路开放平台秘钥 */ public String getYihuOpenPlatformSecret() { return yihu_OpenPlatform_secret; } /**************************************************************************************/ /** * 获取IM数据库名 * * @return */ @Value("${im.data_base_name}") private String im_dataBase_name; public String getImDataBaseName() { return im_dataBase_name; } }