SystemConf.java 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. package com.yihu.wlyy.util;
  2. import org.apache.commons.lang3.StringUtils;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.stereotype.Component;
  5. import java.io.IOException;
  6. import java.io.InputStream;
  7. import java.util.Properties;
  8. @Component
  9. public class SystemConf {
  10. // 别处登录
  11. public static final int LOGIN_OTHER = 999;
  12. // 登录超时
  13. public static final int LOGIN_TIMEOUT = 998;
  14. // 未登录
  15. public static final int NOT_LOGIN = 997;
  16. // 文件保存临时路径
  17. private static final String TEMP_PATH = "upload_temp_path";
  18. // 血糖餐前最小值
  19. public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
  20. // 血糖餐前最大值
  21. public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
  22. // 血糖餐后最小值
  23. public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
  24. // 血糖餐后最大值
  25. public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
  26. // 舒张压最小值
  27. public static final double HEALTH_STANDARD_SZY_MIN = 60;
  28. // 舒张压最大值
  29. public static final double HEALTH_STANDARD_SZY_MAX = 90;
  30. // 收缩压最小值
  31. public static final double HEALTH_STANDARD_SSY_MIN = 90;
  32. // 收缩压最大值
  33. public static final double HEALTH_STANDARD_SSY_MAX = 140;
  34. // 同一手机号大最短信数
  35. public static final int MAX_SMS_MOBILE = 5;
  36. // 发送短信验证码间隔(分钟)
  37. public static final int SMS_INTERVAL = 2;
  38. private static Object lock = new Object();
  39. // 全局系统配置信息
  40. private static SystemConf systemConf;
  41. // 系统配置文件
  42. private Properties systemProperties;
  43. //im列表
  44. private String imListGet;
  45. public static SystemConf getInstance() {
  46. if (systemConf == null) {
  47. synchronized (lock) {
  48. systemConf = new SystemConf();
  49. }
  50. }
  51. return systemConf;
  52. }
  53. /**
  54. * 加载系统配置文件
  55. *
  56. * @return
  57. */
  58. public Properties getSystemProperties() {
  59. if (systemProperties == null) {
  60. InputStream is = null;
  61. try {
  62. is = this.getClass().getResourceAsStream("/system.properties");
  63. systemProperties = new Properties();
  64. systemProperties.load(is);
  65. } catch (IOException e1) {
  66. e1.printStackTrace();
  67. } finally {
  68. if (is != null) {
  69. try {
  70. is.close();
  71. } catch (IOException e) {
  72. e.printStackTrace();
  73. }
  74. }
  75. }
  76. }
  77. return systemProperties;
  78. }
  79. /**
  80. * 短信接口地址
  81. */
  82. public String getSmsUrl() {
  83. return getSystemProperties().getProperty("yihu_sms_url");
  84. }
  85. /**
  86. * 短信企业编号
  87. */
  88. public String getSmsCode() {
  89. return getSystemProperties().getProperty("yihu_sms_code");
  90. }
  91. /**
  92. * 短信用户名
  93. */
  94. public String getSmsName() {
  95. return getSystemProperties().getProperty("yihu_sms_name");
  96. }
  97. /**
  98. * 短信登录密码
  99. */
  100. public String getSmsPassword() {
  101. return getSystemProperties().getProperty("yihu_sms_password");
  102. }
  103. ;
  104. /**
  105. * 挂号接口地址
  106. */
  107. public String getGuahaoUrl() {
  108. return getSystemProperties().getProperty("yihu_guahao_url");
  109. }
  110. /**
  111. * 挂号接口对接appid
  112. */
  113. public String getGuahaoAppid() {
  114. return getSystemProperties().getProperty("yihu_guahao_appid");
  115. }
  116. /**
  117. * 挂号接口对接app secret
  118. */
  119. public String getGuahaoSecret() {
  120. return getSystemProperties().getProperty("yihu_guahao_secret");
  121. }
  122. /**
  123. * IM地址
  124. *
  125. * @return
  126. */
  127. @Value("${im.im_list_get}")
  128. private String im_list_get;
  129. public String getImListGet() {
  130. return im_list_get;
  131. }
  132. /**
  133. * 获取文件保存的临时路径
  134. *
  135. * @return
  136. */
  137. public String getTempPath() {
  138. return getSystemProperties().getProperty(TEMP_PATH);
  139. }
  140. /**
  141. * 获取图片存在地址
  142. *
  143. * @return
  144. */
  145. @Value("${images.path}")
  146. private String imagesPath;
  147. public String getImagePath() {
  148. return imagesPath;
  149. }
  150. @Value("${wechat.appId}")
  151. private String appId;
  152. @Value("${wechat.appSecret}")
  153. private String appSecret;
  154. @Value("${wechat.accId}")
  155. private String accId;
  156. public String getAppId() {
  157. return appId;
  158. }
  159. public String getAccId() {
  160. return accId;
  161. }
  162. public String getAppSecret() {
  163. return appSecret;
  164. }
  165. /**
  166. * 获取服务全路径
  167. *
  168. * @return
  169. */
  170. @Value("${server.server_url}")
  171. private String server_url;
  172. public String getServerUrl() {
  173. return server_url;
  174. }
  175. public String getServerUrlStr() {
  176. return server_url;
  177. }
  178. /******************************** 挂号配置 ********************************************/
  179. /**
  180. * 获取厦门预约服务地址
  181. */
  182. public String getXMGuahaoUrl() {
  183. return getSystemProperties().getProperty("guahao_url");
  184. }
  185. /**
  186. * 获取厦门预约服务命名空间
  187. */
  188. public String getXMGuahaoNamespace() {
  189. return getSystemProperties().getProperty("guahao_namespace");
  190. }
  191. /****************************************************************************************/
  192. @Value("${sign.check_upload}")
  193. private String sign_check_upload;
  194. /**
  195. * 基卫服务地址
  196. */
  197. public String getJwUrl() {
  198. return getSystemProperties().getProperty("sign_check_upload");
  199. }
  200. /********************************* EHR配置 **********************************************/
  201. /**
  202. * 是否启用EHR演示
  203. */
  204. public Boolean getEhrUsed() {
  205. return Boolean.valueOf(getSystemProperties().getProperty("ehr_used"));
  206. }
  207. /**
  208. * EHR档案服务地址
  209. */
  210. public String getEhrServices() {
  211. return getSystemProperties().getProperty("ehr_services");
  212. }
  213. /**
  214. * EHR底层地址
  215. */
  216. public String getEhrServicesBase() {
  217. return getSystemProperties().getProperty("ehr_services_base");
  218. }
  219. /**************************************************************************************/
  220. /*********************************
  221. * 健康之路开放平台 配置
  222. **********************************************/
  223. @Value("${yihu.yihu_OpenPlatform_url}")
  224. private String yihu_OpenPlatform_url;
  225. @Value("${yihu.yihu_OpenPlatform_appId}")
  226. private String yihu_OpenPlatform_appId;
  227. @Value("${yihu.yihu_OpenPlatform_secret}")
  228. private String yihu_OpenPlatform_secret;
  229. /**
  230. * 健康之路开放平台url
  231. */
  232. public String getYihuOpenPlatformUrl() {
  233. return yihu_OpenPlatform_url;
  234. }
  235. /**
  236. * 健康之路开放平台渠道号
  237. */
  238. public String getYihuOpenPlatformAppId() {
  239. return yihu_OpenPlatform_appId;
  240. }
  241. /**
  242. * 健康之路开放平台秘钥
  243. */
  244. public String getYihuOpenPlatformSecret() {
  245. return yihu_OpenPlatform_secret;
  246. }
  247. /**************************************************************************************/
  248. /**
  249. * 获取IM数据库名
  250. *
  251. * @return
  252. */
  253. @Value("${im.data_base_name}")
  254. private String im_dataBase_name;
  255. public String getImDataBaseName() {
  256. return im_dataBase_name;
  257. }
  258. }