SystemConf.java 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. package com.yihu.wlyy.util;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.util.Properties;
  5. import org.apache.commons.lang3.StringUtils;
  6. public class SystemConf {
  7. // 别处登录
  8. public static final int LOGIN_OTHER = 999;
  9. // 登录超时
  10. public static final int LOGIN_TIMEOUT = 998;
  11. // 未登录
  12. public static final int NOT_LOGIN = 997;
  13. private static final String SERVER_IP = "server_ip";
  14. private static final String SERVER_PORT = "server_port";
  15. private static final String SERVER_DOMAIN = "server_domain";
  16. // 消息推送服务器地址
  17. private static final String MSG_PUSH_SERVER = "msg_push_server";
  18. //微信端websocket服务地址
  19. private static final String WEIXIN_WEBSOCKET_SERVER = "weixin_websocket_server";
  20. // 服务器地址
  21. private static final String SERVER_URL = "server_url";
  22. // 图片资源服务器地址
  23. private static final String IMAGE_SERVER = "image_server";
  24. // 语音资源服务器地址
  25. private static final String VOICE_SERVER = "voice_server";
  26. // 聊天咨询服务器地址
  27. private static final String CHAT_SERVER = "chat_server";
  28. // 文件保存临时路径
  29. private static final String TEMP_PATH = "upload_temp_path";
  30. // 聊天文件保存路径
  31. private static final String CHAT_FILE_PATH = "chat_file_path";
  32. // 图片存放地址
  33. private static final String IMAGE_PATH = "image_path";
  34. // 语音存在地址
  35. private static final String VOICE_PATH = "voice_path";
  36. private static final String appId = "appId";
  37. private static final String appSecret = "appSecret";
  38. // 血糖餐前最小值
  39. public static final double HEALTH_STANDARD_ST_MIN_BEFORE = 4;
  40. // 血糖餐前最大值
  41. public static final double HEALTH_STANDARD_ST_MAX_BEFORE = 7;
  42. // 血糖餐后最小值
  43. public static final double HEALTH_STANDARD_ST_MIN_AFTER = 4;
  44. // 血糖餐后最大值
  45. public static final double HEALTH_STANDARD_ST_MAX_AFTER = 11.1;
  46. // 舒张压最小值
  47. public static final double HEALTH_STANDARD_SZY_MIN = 60;
  48. // 舒张压最大值
  49. public static final double HEALTH_STANDARD_SZY_MAX = 90;
  50. // 收缩压最小值
  51. public static final double HEALTH_STANDARD_SSY_MIN = 90;
  52. // 收缩压最大值
  53. public static final double HEALTH_STANDARD_SSY_MAX = 140;
  54. // 同一ip最大短信数
  55. public static final int MAX_SMS_IP = 10;
  56. // 同一手机号大最短信数
  57. public static final int MAX_SMS_MOBILE = 5;
  58. // 发送短信验证码间隔(分钟)
  59. public static final int SMS_INTERVAL = 2;
  60. private static Object lock = new Object();
  61. // 全局系统配置信息
  62. private static SystemConf systemConf;
  63. // 系统配置文件
  64. private Properties systemProperties;
  65. public static SystemConf getInstance() {
  66. if (systemConf == null) {
  67. synchronized (lock) {
  68. systemConf = new SystemConf();
  69. }
  70. }
  71. return systemConf;
  72. }
  73. /**
  74. * 加载系统配置文件
  75. * @return
  76. */
  77. public Properties getSystemProperties() {
  78. if (systemProperties == null) {
  79. InputStream is = null;
  80. try {
  81. is = this.getClass().getResourceAsStream("/system.properties");
  82. systemProperties = new Properties();
  83. systemProperties.load(is);
  84. } catch (IOException e1) {
  85. e1.printStackTrace();
  86. } finally {
  87. if (is != null) {
  88. try {
  89. is.close();
  90. } catch (IOException e) {
  91. e.printStackTrace();
  92. }
  93. }
  94. }
  95. }
  96. return systemProperties;
  97. }
  98. /**
  99. * 短信接口地址
  100. */
  101. public String getSmsUrl(){
  102. return getSystemProperties().getProperty("yihu_sms_url");
  103. }
  104. /**
  105. * 短信企业编号
  106. */
  107. public String getSmsCode(){
  108. return getSystemProperties().getProperty("yihu_sms_code");
  109. }
  110. /**
  111. * 短信用户名
  112. */
  113. public String getSmsName(){
  114. return getSystemProperties().getProperty("yihu_sms_name");
  115. }
  116. /**
  117. * 短信登录密码
  118. */
  119. public String getSmsPassword(){
  120. return getSystemProperties().getProperty("yihu_sms_password");
  121. };
  122. /**
  123. * 挂号接口地址
  124. */
  125. public String getGuahaoUrl(){
  126. return getSystemProperties().getProperty("yihu_guahao_url");
  127. }
  128. /**
  129. * 挂号接口对接appid
  130. */
  131. public String getGuahaoAppid(){
  132. return getSystemProperties().getProperty("yihu_guahao_appid");
  133. }
  134. /**
  135. * 挂号接口对接app secret
  136. */
  137. public String getGuahaoSecret(){
  138. return getSystemProperties().getProperty("yihu_guahao_secret");
  139. }
  140. /**
  141. * 获取服务IP地址/域名
  142. * @return
  143. */
  144. public String getServerIp() {
  145. return getSystemProperties().getProperty(SERVER_IP);
  146. }
  147. /**
  148. * 获取服务端口号
  149. * @return
  150. */
  151. public String getServerPort() {
  152. return getSystemProperties().getProperty(SERVER_PORT);
  153. }
  154. /**
  155. * 获取服务资源名
  156. * @return
  157. */
  158. public String getServerDomain() {
  159. return getSystemProperties().getProperty(SERVER_DOMAIN);
  160. }
  161. /**
  162. * 获取图片资源服务器地址
  163. * @return
  164. */
  165. public String getImageServer() {
  166. return getSystemProperties().getProperty(IMAGE_SERVER);
  167. }
  168. /**
  169. * 获取语音资源服务器地址
  170. * @return
  171. */
  172. public String getVoiceServer() {
  173. return getSystemProperties().getProperty(VOICE_SERVER);
  174. }
  175. /**
  176. * 获取聊天附件服务器地址
  177. * @return
  178. */
  179. public String getChatServer() {
  180. return getSystemProperties().getProperty(CHAT_SERVER);
  181. }
  182. /**
  183. * 获取文件保存的临时路径
  184. * @return
  185. */
  186. public String getTempPath() {
  187. return getSystemProperties().getProperty(TEMP_PATH);
  188. }
  189. /**
  190. * 获取图片存在地址
  191. * @return
  192. */
  193. public String getImagePath() {
  194. return getSystemProperties().getProperty(IMAGE_PATH);
  195. }
  196. /**
  197. * 获取语音存放地址
  198. * @return
  199. */
  200. public String getVoicePath() {
  201. return getSystemProperties().getProperty(VOICE_PATH);
  202. }
  203. /**
  204. * 聊天附件保存路径
  205. * @return
  206. */
  207. public String getChatPath() {
  208. return getSystemProperties().getProperty(CHAT_FILE_PATH);
  209. }
  210. /**
  211. * 获取消息推送服务器
  212. * @return
  213. */
  214. public String getMsgPushServer() {
  215. return getSystemProperties().getProperty(MSG_PUSH_SERVER);
  216. }
  217. public String getWeixinWebsocketServer() {
  218. return getSystemProperties().getProperty(WEIXIN_WEBSOCKET_SERVER);
  219. }
  220. public String getServerUrlStr() {
  221. String temp = getSystemProperties().getProperty(SERVER_URL);
  222. if (StringUtils.isEmpty(temp)) {
  223. temp = "http://www.xmtyw.cn/wlyy/";
  224. }
  225. return temp;
  226. }
  227. public String getAppId(){
  228. String temp = getSystemProperties().getProperty(appId);
  229. if (StringUtils.isEmpty(temp)) {
  230. temp = "wxad04e9c4c5255acf";
  231. }
  232. return temp;
  233. }
  234. public String getAppSecret(){
  235. String temp = getSystemProperties().getProperty(appSecret);
  236. if (StringUtils.isEmpty(temp)) {
  237. temp = "ae77c48ccf1af5d07069f5153d1ac8d3";
  238. }
  239. return temp;
  240. }
  241. /**
  242. * 获取服务全路径
  243. * @return
  244. */
  245. public String getServerUrl() {
  246. String port = getServerPort();
  247. port = StringUtils.isEmpty(port) ? "" : ":" + port;
  248. String domain = getServerDomain();
  249. domain = StringUtils.isEmpty(port) ? "" : "/" + domain;
  250. return "http://" + getServerIp() + port + domain + "/";
  251. }
  252. public static void main(String[] args) {
  253. System.out.println(getInstance().getServerUrl());
  254. }
  255. /******************************** 挂号配置 ********************************************/
  256. /**
  257. * 获取厦门预约服务地址
  258. */
  259. public String getXMGuahaoUrl() {
  260. return getSystemProperties().getProperty("guahao_url");
  261. }
  262. /**
  263. * 获取厦门预约服务命名空间
  264. */
  265. public String getXMGuahaoNamespace() {
  266. return getSystemProperties().getProperty("guahao_namespace");
  267. }
  268. /****************************************************************************************/
  269. /**
  270. * 基卫服务地址
  271. */
  272. public String getJwUrl() {
  273. return getSystemProperties().getProperty("sign_check_upload");
  274. }
  275. /********************************* EHR配置 **********************************************/
  276. /**
  277. * 是否启用EHR演示
  278. */
  279. public Boolean getEhrUsed() {
  280. return Boolean.valueOf(getSystemProperties().getProperty("ehr_used"));
  281. }
  282. /**
  283. * EHR档案服务地址
  284. */
  285. public String getEhrServices() {
  286. return getSystemProperties().getProperty("ehr_services");
  287. }
  288. /**
  289. * EHR底层地址
  290. */
  291. public String getEhrServicesBase() {
  292. return getSystemProperties().getProperty("ehr_services_base");
  293. }
  294. /**************************************************************************************/
  295. }