123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- package utils
- import (
- "encoding/json"
- "fmt"
- beego "github.com/beego/beego/v2/adapter"
- "github.com/beego/beego/v2/server/web"
- "strconv"
- )
- var (
- RunMode string
- MYSQL_URL string
- MYSQL_URL_RDDP string
- MYSQL_URL_EDB string
- MYSQL_URL_DATA string
- MYSQL_URL_GL string
- MYSQL_URL_ETA string
- MYSQL_WEEKLY_URL string
- REDIS_CACHE string
-
- Re error
- Rc RedisClient
- )
- var (
- LogPath string
- LogFile string
- BinLogPath string
- BinLogFile string
- LogMaxDays int
- )
- var (
- APPNAME string
- EmailSendToUsers string
- RefreshEdbInfoEmailSendToUsers string
-
- AlarmMsgUrl string
- )
- var (
- EDB_LIB_URL string
- EDB_LIB_URL_LIST []EtaLibUrlList
- APP_EDB_LIB_NAME_EN string
- EDB_LIB_Md5_KEY string
- )
- type EtaLibUrlList struct {
- Url string
- }
- var (
- APPID string
- SECRET string
- )
- var (
- WxAppId string
- WxAppSecret string
- TemplateId string
- RemindTemplateId string
- AppointmentRemindTemplateId string
- YbCommonTemplateId string
- SendWxTemplateEnable string
- WxYbAppId string
-
- AdminWxAppId string
- AdminWxAppSecret string
- )
- var (
- SendWxTemplateMsgUrl string
- )
- var (
- BusinessCode string
- WindServerUrl string
- LtServerUrl string
- PbServerUrl string
- )
- var (
- ES_URL string
- ES_USERNAME string
- ES_PASSWORD string
- )
- var (
- EsReportIndexName string
- EsEnglishReportIndexName string
- SmartReportIndexName string
- EsExcelIndexName string
- EsDataSourceIndexName string
- )
- var (
- XfHostUrl string
- )
- var (
- TemplateIdByProduct string
- )
- var (
- Bucketname string
- Endpoint string
- Imghost string
- UploadDir string
- Upload_Audio_Dir string
- AccessKeyId string
- AccessKeySecret string
- )
- var (
-
- IsXy string
- IsPCSG string
- )
- var (
- EtaBridgeUrl string
- EtaBridgeAppNameEn string
- EtaBridgeMd5Key string
- EtaBridgeDesKey string
- SyncUserPath string
- SyncUserTime string
- SyncIndexPath string
- SyncIndexTime string
- SyncIndexClassifyTime string
- SyncCrmIndexPath string
- SyncCrmIndexTime string
- SyncCrmAssetPkgCd string
- SyncCrmDataSourceType string
- SyncCrmIndexNum int
- )
- var (
- EtaHubUrl string
- )
- var (
- PbRefreshFrequency string
- PbRefreshOpen string
- )
- var HzDataApi string
- var (
- RefreshCalculateEdbTaskTime string
- )
- func init() {
- tmpRunMode, err := web.AppConfig.String("run_mode")
- if err != nil {
- panic("配置文件读取run_mode错误 " + err.Error())
- }
- RunMode = tmpRunMode
- if RunMode == "" {
- localIp, err := GetLocalIP()
- fmt.Println("localIp:", localIp)
- if localIp == "10.0.0.123" {
- RunMode = "debug"
- } else {
- RunMode = "release"
- }
-
- configPath := `/home/code/config/eta_task/conf/app.conf`
- err = web.LoadAppConfig("ini", configPath)
- if err != nil {
- fmt.Println("web.LoadAppConfig Err:" + err.Error())
- }
- }
- config, err := web.AppConfig.GetSection(RunMode)
- if err != nil {
- panic("配置文件读取错误 " + err.Error())
- }
- beego.Info(RunMode + " 模式")
- MYSQL_URL = config["mysql_url"]
- MYSQL_URL_RDDP = config["mysql_url_rddp"]
- MYSQL_URL_EDB = config["mysql_url_edb"]
- MYSQL_URL_DATA = config["mysql_url_data"]
- MYSQL_URL_GL = config["mysql_url_gl"]
- MYSQL_URL_ETA = config["mysql_url_eta"]
-
- MYSQL_WEEKLY_URL = config["mysql_url_weekly"]
- REDIS_CACHE = config["beego_cache"]
- if len(REDIS_CACHE) <= 0 {
- panic(any("redis链接参数没有配置"))
- }
-
-
-
-
-
-
- redisClient, err := initRedis(config["redis_type"], config["beego_cache"])
- if err != nil {
- fmt.Println("redis链接异常:", err)
- panic(any(Re))
- }
- Rc = redisClient
-
- appNameCn, err := web.AppConfig.String("app_name_cn")
- if err != nil {
- panic(any("配置文件读取app_name_cn错误 " + err.Error()))
- }
- APPNAME = appNameCn
- {
- LogPath = config["log_path"]
- LogFile = config["log_file"]
- BinLogPath = config["binlog_path"]
- BinLogFile = config["binlog_file"]
- logMaxDaysStr := config["log_max_day"]
- LogMaxDays, _ = strconv.Atoi(logMaxDaysStr)
- }
-
- EmailSendToUsers = config["email_send_to_users"]
-
- RefreshEdbInfoEmailSendToUsers = config["refresh_edb_info_email_send_to_users"]
-
- AlarmMsgUrl = config["alarm_msg_url"]
-
- {
- EDB_LIB_URL = config["edb_lib_url"]
- APP_EDB_LIB_NAME_EN = config["app_edb_lib_name_en"]
- EDB_LIB_Md5_KEY = config["edb_lib_md5_key"]
- if EDB_LIB_URL == "" {
- EDB_LIB_URL = "http://127.0.0.1:8300/edbapi/"
- } else {
- err = json.Unmarshal([]byte(EDB_LIB_URL), &EDB_LIB_URL_LIST)
- if err != nil {
- fmt.Println("eta_lib_url 配置错误,请检查,Err:" + err.Error())
- }
- }
- }
- APPID = config["appid"]
- SECRET = config["secret"]
-
- BusinessCode = config["business_code"]
-
- WindServerUrl = config["wind_server_url"]
- LtServerUrl = config["lt_server_url"]
- PbServerUrl = config["pb_server_url"]
-
- {
- ES_URL = config["es_url"]
- ES_USERNAME = config["es_username"]
- ES_PASSWORD = config["es_password"]
- }
-
- {
- EsReportIndexName = config["es_report_index_name"]
- EsEnglishReportIndexName = config["es_english_report_index_name"]
- SmartReportIndexName = config["es_smart_report_index_name"]
- }
-
- {
- XfHostUrl = config["xf_host_url"]
- }
-
- {
- Endpoint = config["endpoint"]
- Bucketname = config["bucket_name"]
- Imghost = config["img_host"]
- UploadDir = config["upload_dir"]
- Upload_Audio_Dir = config["upload_audio_dir"]
- AccessKeyId = config["access_key_id"]
- AccessKeySecret = config["access_key_secret"]
- }
-
- {
- SendWxTemplateEnable = config["send_wx_template_enable"]
- }
-
- {
- IsXy = config["is_xy"]
- IsPCSG = config["is_pcsg"]
- }
-
- {
- EtaBridgeUrl = config["eta_bridge_url"]
- EtaBridgeAppNameEn = config["eta_bridge_app_name_en"]
- EtaBridgeMd5Key = config["eta_bridge_md5_key"]
- EtaBridgeDesKey = config["eta_bridge_des_key"]
- SyncUserPath = config["sync_user_path"]
- SyncUserTime = config["sync_user_time"]
- SyncIndexPath = config["sync_index_path"]
- SyncIndexTime = config["sync_index_time"]
- SyncIndexClassifyTime = config["sync_index_classify_time"]
- SyncCrmIndexPath = config["sync_crm_index_path"]
- SyncCrmIndexTime = config["sync_crm_index_time"]
- SyncCrmAssetPkgCd = config["sync_crm_asset_pkg_cd"]
- SyncCrmDataSourceType = config["sync_crm_data_source_type"]
- syncCrmIndexNumStr := config["sync_crm_index_num"]
- if syncCrmIndexNumStr != `` {
- SyncCrmIndexNum, _ = strconv.Atoi(syncCrmIndexNumStr)
- }
- if SyncCrmIndexNum <= 0 {
- SyncCrmIndexNum = 2000
- }
- }
-
- {
- EtaHubUrl = config["eta_hub_url"]
- }
- HzDataApi = config["hz_data_api"]
- if HzDataApi == "" {
- HzDataApi = "https://hzdataapi.hzinsights.com/hzdataapi/"
- }
-
- PbRefreshFrequency = config["pb_refresh_frequency"]
-
- PbRefreshOpen = config["pb_refresh_open"]
-
- RefreshCalculateEdbTaskTime = config["refresh_calculate_edb_task_time"]
-
- initEs()
- }
|