|
@@ -0,0 +1,484 @@
|
|
|
+/**
|
|
|
+ * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
|
|
+ */
|
|
|
+package com.jeeplus.sys.utils;
|
|
|
+
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import com.jeeplus.security.util.DaoAuthenticationProvider;
|
|
|
+import org.apache.ibatis.io.Resources;
|
|
|
+import org.springframework.core.io.DefaultResourceLoader;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Properties;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 全局配置类
|
|
|
+ * @author jeeplus
|
|
|
+ * @version 2014-06-25
|
|
|
+ */
|
|
|
+public class Global {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前对象实例
|
|
|
+ */
|
|
|
+ private static Global global = new Global();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存全局属性值
|
|
|
+ */
|
|
|
+ private static Map<String, String> map = Maps.newHashMap();
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示/隐藏
|
|
|
+ */
|
|
|
+ public static final String SHOW = "1";
|
|
|
+ public static final String HIDE = "0";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 是/否
|
|
|
+ */
|
|
|
+ public static final String YES = "1";
|
|
|
+ public static final String NO = "0";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对/错
|
|
|
+ */
|
|
|
+ public static final String TRUE = "true";
|
|
|
+ public static final String FALSE = "false";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传文件基础虚拟路径
|
|
|
+ */
|
|
|
+ public static final String USERFILES_BASE_URL = "/userfiles/";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前对象实例
|
|
|
+ */
|
|
|
+ public static Global getInstance() {
|
|
|
+ return global;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取配置
|
|
|
+ * @see {fns:getConfig('adminPath')}
|
|
|
+ */
|
|
|
+ public static String getConfig(String key) {
|
|
|
+ String value = null;
|
|
|
+ Properties prop = new Properties();
|
|
|
+ try {
|
|
|
+ ClassLoader classLoader = DaoAuthenticationProvider.class.getClassLoader();// 读取属性文件xxxxx.properties
|
|
|
+ InputStream in = classLoader.getResourceAsStream("application-production.yml");
|
|
|
+ prop.load(in); /// 加载属性列表
|
|
|
+ Iterator it = prop.stringPropertyNames().iterator();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ if (it.next().equals(key)) {
|
|
|
+ value = prop.getProperty(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ in.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取管理端根路径
|
|
|
+ */
|
|
|
+ public static String getAdminPath() {
|
|
|
+ return getConfig("adminPath");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAliyunUrl() {
|
|
|
+ return getConfig("aliyunDownloadUrl");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAliDownloadUrl() {
|
|
|
+ return getConfig("aliyunUrl");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getEndpoint() {
|
|
|
+ return getConfig("endpoint");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAccessKeyId() {
|
|
|
+ return getConfig("accessKeyId");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAccessKeySecret() {
|
|
|
+ return getConfig("accessKeySecret");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getBucketName() {
|
|
|
+ return getConfig("bucketName");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getQzBucketName() {
|
|
|
+ return getConfig("qzBucketName");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAvatarDir() {
|
|
|
+ return getConfig("avatarDir");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getNotifyDir() {
|
|
|
+ return getConfig("notifyDir");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getReportDir() {
|
|
|
+ return getConfig("reportDir");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getRqcode() {
|
|
|
+ return getConfig("rqcode");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getGoout() {
|
|
|
+ return getConfig("goout");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getLeave() {
|
|
|
+ return getConfig("leave");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getOvertimeform() {
|
|
|
+ return getConfig("overtimeform");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getSealform() {
|
|
|
+ return getConfig("sealform");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getWorkReimbur() {return getConfig("workReimbur");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getEvection() {
|
|
|
+ return getConfig("evection");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getOaBuy() {
|
|
|
+ return getConfig("oaBuy");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getOaAll() {
|
|
|
+ return getConfig("oaAll");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getIm() {
|
|
|
+ return getConfig("im");
|
|
|
+ }/**
|
|
|
+ */
|
|
|
+ public static String getWorkContractInfo() {
|
|
|
+ return getConfig("workContractInfo");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getNotifyData() {
|
|
|
+ return getConfig("notifyData");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getAppData() {
|
|
|
+ return getConfig("appData");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getLogo() {
|
|
|
+ return getConfig("logo");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getPhoto() {
|
|
|
+ return getConfig("photo");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getUserEvaluation(){return getConfig("userEvaluation");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkBidingDocument() {return getConfig("workBidingDocument");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkEngineeringProject() {return getConfig("workEngineeringProject");}
|
|
|
+
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullExecute() {return getConfig("workFullExecute");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullMeetingminutes() {return getConfig("workFullMeetingminutes");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullDesignchange(){return getConfig("workFullDesignchange");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullConstructsheet(){return getConfig("workFullConstructsheet");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullProprietorsheet(){return getConfig("workFullProprietorsheet");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkFullSupervisorsheet(){return getConfig("workFullSupervisorsheet");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkProjectReport() {return getConfig("workProjectReport");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkProjectBasis() {return getConfig("workProjectBasis");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkProjectRemote() {return getConfig("workProjectRemote");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkProjectSummary() {return getConfig("workProjectSummary");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkProjectOther() {return getConfig("workProjectOther");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getWorkVisa() {return getConfig("workVisa");}
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getOfficehonor() {return getConfig("Officehonor");}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getJobResume() {return getConfig("jobResume");}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getSatisfaction() {return getConfig("satisfaction");}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getCertificate() {return getConfig("certificate");}
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public static String getJudgeAttachment() {return getConfig("judgeAttachment");}
|
|
|
+ /**
|
|
|
+ * 获取前端根路径
|
|
|
+ */
|
|
|
+ public static String getFrontPath() {
|
|
|
+ return getConfig("frontPath");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取URL后缀
|
|
|
+ */
|
|
|
+ public static String getUrlSuffix() {
|
|
|
+ return getConfig("urlSuffix");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取电子签章文件路径
|
|
|
+ */
|
|
|
+ public static String getISignature() {
|
|
|
+ return getConfig("iSignature");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ */
|
|
|
+ public static String getOSSUrl() {
|
|
|
+ return getConfig("oSSUrl");
|
|
|
+ }
|
|
|
+ public static String getContractNumPath() {
|
|
|
+ return getConfig("contract_num_path");
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 是否是演示模式,演示模式下不能修改用户、岗位、密码、菜单、授权
|
|
|
+ */
|
|
|
+ public static Boolean isDemoMode() {
|
|
|
+ String dm = getConfig("demoMode");
|
|
|
+ return "true".equals(dm) || "1".equals(dm);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在修改系统用户和岗位时是否同步到Activiti
|
|
|
+ */
|
|
|
+ public static Boolean isSynActivitiIndetity() {
|
|
|
+ String dm = getConfig("activiti.isSynActivitiIndetity");
|
|
|
+ return "true".equals(dm) || "1".equals(dm);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面获取常量
|
|
|
+ * @see {fns:getConst('YES')}
|
|
|
+ */
|
|
|
+ public static Object getConst(String field) {
|
|
|
+ try {
|
|
|
+ return Global.class.getField(field).get(null);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 异常代表无配置,这里什么也不做
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取工程路径
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getProjectPath(){
|
|
|
+ // 如果配置了工程路径,则直接返回,否则自动获取。
|
|
|
+ String projectPath = Global.getConfig("projectPath");
|
|
|
+ if (StringUtils.isNotBlank(projectPath)){
|
|
|
+ return projectPath;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ File file = new DefaultResourceLoader().getResource("").getFile();
|
|
|
+ if (file != null){
|
|
|
+ while(true){
|
|
|
+ File f = new File(file.getPath() + File.separator + "src" + File.separator + "main");
|
|
|
+ if (f == null || f.exists()){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (file.getParentFile() != null){
|
|
|
+ file = file.getParentFile();
|
|
|
+ }else{
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ projectPath = file.toString();
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return projectPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取短信SMS信息
|
|
|
+ */
|
|
|
+ public static String getSmsUserid() {
|
|
|
+ return getConfig("sms_userid");
|
|
|
+ }
|
|
|
+ public static String getSmsAccount() {
|
|
|
+ return getConfig("sms_account");
|
|
|
+ }
|
|
|
+ public static String getSmsPassword() {
|
|
|
+ return getConfig("sms_password");
|
|
|
+ }
|
|
|
+ public static String getSmsMobile() {
|
|
|
+ return getConfig("sms_mobile");
|
|
|
+ }
|
|
|
+ public static String getSmsContent() {
|
|
|
+ return getConfig("sms_content");
|
|
|
+ }
|
|
|
+ public static String getSmsSendTime() {
|
|
|
+ return getConfig("sms_sendTime");
|
|
|
+ }
|
|
|
+ public static String getSmsAction() {
|
|
|
+ return getConfig("sms_action");
|
|
|
+ }
|
|
|
+ public static String getSmsCheckcontent() {
|
|
|
+ return getConfig("sms_checkcontent");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据库连接信息
|
|
|
+ */
|
|
|
+ public static String getJdbcUserName() {
|
|
|
+ return getConfig("jdbc.username");
|
|
|
+ }
|
|
|
+ public static String getJdbcPassword() {
|
|
|
+ return getConfig("jdbc.password");
|
|
|
+ }
|
|
|
+ public static String getJdbcUrl() {
|
|
|
+ return getConfig("jdbc.url");
|
|
|
+ }
|
|
|
+ public static String getJdbcDriver() {
|
|
|
+ return getConfig("jdbc.driver");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取容联云账户信息
|
|
|
+ */
|
|
|
+ public static String getRongUserid() {
|
|
|
+ return getConfig("rong_userid");
|
|
|
+ }
|
|
|
+ public static String getRongToken() {
|
|
|
+ return getConfig("rong_token");
|
|
|
+ }
|
|
|
+ //应用id
|
|
|
+ public static String getAppId() {
|
|
|
+ return getConfig("app_id");
|
|
|
+ }
|
|
|
+ //模板id
|
|
|
+ public static String getTemplateId() {
|
|
|
+ return getConfig("template_id");
|
|
|
+ }
|
|
|
+ //短信发送方式(1:旧的 2:容联云通讯)
|
|
|
+ public static String getCodeType() {
|
|
|
+ return getConfig("code_type");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getOpenOfficeAddr() {
|
|
|
+ return getConfig("open_office_addr");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static int getOpenOfficePort() {
|
|
|
+ String openOfficePort = getConfig("open_office_port");
|
|
|
+ return StringUtils.isBlank(openOfficePort)?8100:Integer.valueOf(openOfficePort);
|
|
|
+ }
|
|
|
+ public static String getOpenfireServer() {
|
|
|
+ String openOfficePort = getConfig("openfire.server");
|
|
|
+ return StringUtils.isBlank(openOfficePort)?"oa-pre.ssruihua.com":openOfficePort;
|
|
|
+ }
|
|
|
+ public static String getSysNotify() {
|
|
|
+ String sysNotify = getConfig("sys.notify");
|
|
|
+ return StringUtils.isBlank(sysNotify)?"http://cdn.gangwaninfo.com/jeeplus-resource-data/static/sys/notify.png":sysNotify;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getStaffBasicFilePath() {
|
|
|
+ return getConfig("staff_basic_file_path");
|
|
|
+ }
|
|
|
+ public static String getDbName() {
|
|
|
+ return getConfig("db.name");
|
|
|
+ }
|
|
|
+ public static String getVersion() {
|
|
|
+ return getConfig("app_version");
|
|
|
+ }
|
|
|
+ public static String getTestVersion() {
|
|
|
+ return getConfig("app_version_test");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getProjectTemplatePath() {
|
|
|
+ return getConfig("project.plan.template.path");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getYyApiCode(){
|
|
|
+ return getConfig("yy_apicode");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getYyMhUrl(){
|
|
|
+ return getConfig("yy_mhcxurl");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getYyShUrl(){
|
|
|
+ return getConfig("yy_shcxurl");
|
|
|
+ }
|
|
|
+}
|