浏览代码

Merge remote-tracking branch 'origin/custom_v2/240520' into custom

Roc 10 月之前
父节点
当前提交
5fc6d03a7a

+ 70 - 0
models/data_manage/business_sys_interaction_log.go

@@ -0,0 +1,70 @@
+package data_manage
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// BusinessSysInteractionLog 商家系统交互记录表
+type BusinessSysInteractionLog struct {
+	ID             uint32    `orm:"column(id);pk" gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
+	InteractionKey string    `gorm:"unique;column:interaction_key;type:varchar(128);not null;default:''" json:"interactionKey"` // 记录Key
+	InteractionVal string    `gorm:"column:interaction_val;type:text;default:null" json:"interactionVal"`                       // 记录值
+	Remark         string    `gorm:"column:remark;type:varchar(128);not null;default:''" json:"remark"`                         // 备注
+	ModifyTime     time.Time `gorm:"column:modify_time;type:datetime;default:null" json:"modifyTime"`                           // 修改日期
+	CreateTime     time.Time `gorm:"column:create_time;type:datetime;default:null" json:"createTime"`                           // 创建时间
+}
+
+// TableName get sql table name.获取数据库表名
+func (m *BusinessSysInteractionLog) TableName() string {
+	return "business_sys_interaction_log"
+}
+
+// BusinessSysInteractionLogColumns get sql column name.获取数据库列名
+var BusinessSysInteractionLogColumns = struct {
+	ID             string
+	InteractionKey string
+	InteractionVal string
+	Remark         string
+	ModifyTime     string
+	CreateTime     string
+}{
+	ID:             "id",
+	InteractionKey: "interaction_key",
+	InteractionVal: "interaction_val",
+	Remark:         "remark",
+	ModifyTime:     "modify_time",
+	CreateTime:     "create_time",
+}
+
+// Create 添加数据
+func (m *BusinessSysInteractionLog) Create() (err error) {
+	o := orm.NewOrm()
+	id, err := o.Insert(m)
+	if err != nil {
+		return
+	}
+	m.ID = uint32(id)
+
+	return
+}
+
+// Update 更新数据
+func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(m, cols...)
+
+	return
+}
+
+var BinlogFileNameKey = "binlog_filename"            // binlog文件名
+var BinlogPositionKey = "binlog_binlog_position"     // binlog位置
+var CrmIndexLastUpdateTime = "crm_index_update_time" // crm数据
+
+// GetBusinessSysInteractionLogByKey 根据记录key获取数据
+func GetBusinessSysInteractionLogByKey(key string) (item *BusinessSysInteractionLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM business_sys_interaction_log WHERE 1=1 AND interaction_key = ? LIMIT 1`
+	err = o.Raw(sql, key).QueryRow(&item)
+	return
+}

+ 1 - 0
models/db.go

@@ -126,6 +126,7 @@ func initEdbDataTable() {
 		new(data_manage.BaseFromIcpiIndex),
 		new(data_manage.BaseFromIcpiClassify),
 		new(data_manage.BaseFromIcpiData),
+		new(data_manage.BusinessSysInteractionLog), // 商家系统交互记录表
 	)
 }
 

+ 36 - 3
services/eta_bridge/eta_bridge.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"eta/eta_task/utils"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"io"
 	"net/http"
 	"strings"
@@ -109,10 +110,10 @@ func HttpEtaBridgeGet(urlStr string) (bResult []byte, err error, errMsg string)
 		return
 	}
 
-	postUrl := utils.EtaBridgeUrl + "/api" + urlStr
+	getUrl := utils.EtaBridgeUrl + "/api" + urlStr
 
 	client := &http.Client{}
-	req, e := http.NewRequest("GET", postUrl, nil)
+	req, e := http.NewRequest("GET", getUrl, nil)
 	if e != nil {
 		err = fmt.Errorf("http create request err: %s", e.Error())
 		return
@@ -150,7 +151,7 @@ func HttpEtaBridgeGet(urlStr string) (bResult []byte, err error, errMsg string)
 	result := new(BaseEtaBridgeDataResp)
 	if e = json.Unmarshal(bResult, &result); e != nil {
 		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(bResult))
-		utils.FileLog.Info("桥接服务get请求失败:\n" + string(bResult))
+		utils.FileLog.Info("桥接服务get请求失败,url", getUrl, ":\n", string(bResult))
 		return
 	}
 	if result.Code != 200 {
@@ -161,3 +162,35 @@ func HttpEtaBridgeGet(urlStr string) (bResult []byte, err error, errMsg string)
 
 	return
 }
+
+// EtaBridgeDataRespAndBusinessData 基础返回参数
+type EtaBridgeDataRespAndBusinessData struct {
+	Code int                 `json:"code" description:"状态码"`
+	Msg  string              `json:"msg" description:"提示信息"`
+	Data GetBusinessDataResp `json:"data" description:"返回数据"`
+}
+
+type GetBusinessDataResp struct {
+	List   []PushBusinessIndex
+	Paging *paging.PagingItem `description:"分页数据"`
+}
+
+// PushBusinessIndex
+// @Description:  添加外部指标(商家)请求
+type PushBusinessIndex struct {
+	IndexCode            string            `description:"指标编码"`
+	IndexName            string            `description:"指标名称"`
+	Unit                 string            `description:"单位"`
+	Frequency            string            `description:"频度"`
+	SourceName           string            `description:"数据来源名称"`
+	Remark               string            `description:"备注字段"`
+	DetailDataCreateTime string            `description:"明细数据入库时间"`
+	DataList             []AddBusinessData `description:"指标数据"`
+}
+
+// AddBusinessData
+// @Description: 外部指标(商家系统)数据
+type AddBusinessData struct {
+	Value float64 `description:"值"`
+	Date  string  `description:"日期"`
+}

+ 12 - 0
services/eta_bridge/handle_data.go

@@ -58,6 +58,10 @@ func handleInsert(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIn
 		if edbInfo.EdbType == 2 {
 			return
 		}
+		// 自有数据不处理
+		if edbInfo.Source == utils.DATA_SOURCE_BUSINESS {
+			return
+		}
 
 		// 获取数据源中指标的基础信息
 		origInfo := getOrigInfo(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbCode, edbInfo.EdbName)
@@ -192,6 +196,10 @@ func handleDelete(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIn
 		if edbInfo.EdbType == 2 {
 			return
 		}
+		// 自有数据不处理
+		if edbInfo.Source == utils.DATA_SOURCE_BUSINESS {
+			return
+		}
 
 		// 获取数据源中指标的基础信息
 		origInfo := getOrigInfo(edbInfo.Source, edbInfo.SubSource, edbInfo.EdbCode, edbInfo.EdbName)
@@ -327,6 +335,10 @@ func handleUpdate(edbUpdateLog *data_manage.EdbUpdateLog) (pushIndexData *PushIn
 		if oldEdbInfo.EdbType == 2 {
 			return
 		}
+		// 自有数据不处理
+		if oldEdbInfo.Source == utils.DATA_SOURCE_BUSINESS {
+			return
+		}
 
 		var newEdbInfo *data_manage.EdbInfoItem
 		err = json.Unmarshal([]byte(newData), &newEdbInfo)

+ 181 - 0
services/eta_bridge/xy.go

@@ -5,9 +5,11 @@ import (
 	"encoding/json"
 	"eta/eta_task/models/data_manage"
 	"eta/eta_task/services/alarm_msg"
+	"eta/eta_task/services/eta_hub"
 	"eta/eta_task/utils"
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/uuid"
+	"net/url"
 	"strings"
 	"sync"
 	"time"
@@ -519,3 +521,182 @@ func min(a, b int) int {
 	}
 	return b
 }
+
+// 同步crm指标信息锁
+var lockGetCrmIndex sync.Mutex
+
+// SyncXyCrmIndex
+// @Description: 定时同步CRM指标信息
+// @author: Roc
+// @datetime 2024-5-22 10:46:08
+// @param cont context.Context
+// @return err error
+func SyncXyCrmIndex(cont context.Context) (err error) {
+	lockGetCrmIndex.Lock()
+	errMsgList := make([]string, 0)
+	defer func() {
+		if err != nil {
+			tips := "SyncXyCrmIndex-定时同步CRM数据到ETA平台失败, ErrMsg:\n" + err.Error()
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+		if len(errMsgList) > 0 {
+			tips := "SyncXyCrmIndex-定时同步CRM数据到ETA平台失败, ErrMsg:\n" + strings.Join(errMsgList, "\n")
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+		lockGetCrmIndex.Unlock()
+		fmt.Println("end SyncXyCrmIndex")
+	}()
+
+	// 未配置资产包合数据分区,那么就不执行
+	if utils.SyncCrmAssetPkgCd == `` || utils.SyncCrmDataSourceType == `` {
+		return
+	}
+
+	var lastUpdateTimeStr string                                   // 上一次更新的时间
+	nowTimeStr := time.Now().Format(utils.FormatDateTimeUnSpaceV2) // 这次更新的时间
+
+	key := data_manage.CrmIndexLastUpdateTime
+	sysInteractionLog, err := data_manage.GetBusinessSysInteractionLogByKey(key)
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			return
+		}
+		//lastUpdateTime := time.Now().Format("2006-01-02 15:04:05")
+	} else {
+		if sysInteractionLog.InteractionVal != `` {
+			lastUpdateTimeStr = sysInteractionLog.InteractionVal
+		}
+	}
+
+	syncCrmAssetPkgCd := utils.SyncCrmAssetPkgCd
+	syncCrmAssetPkgCdList := strings.Split(syncCrmAssetPkgCd, ",")
+
+	for _, assetPkgCd := range syncCrmAssetPkgCdList {
+		err, errMsgList = syncCrmIndex(assetPkgCd, 1, utils.SyncCrmIndexNum, lastUpdateTimeStr)
+	}
+
+	// 修改最后的更新时间
+	modifyCrmIndexLastUpdateTime(nowTimeStr)
+
+	return
+}
+
+// syncCrmIndex
+// @Description: 开始同步CRM指标信息
+// @author: Roc
+// @datetime 2024-05-17 15:55:11
+// @param assetPkgCd string
+// @param currIndex int
+// @param pageSize int
+// @param lastUpdateTimeStr string
+// @return err error
+// @return errMsgList []string
+func syncCrmIndex(assetPkgCd string, currIndex, pageSize int, baseLastUpdateTimeStr string) (err error, errMsgList []string) {
+	errMsgList = make([]string, 0)
+
+	lastUpdateTimeStr := baseLastUpdateTimeStr
+	if lastUpdateTimeStr != `` {
+		lastUpdateTimeStr = url.QueryEscape(lastUpdateTimeStr)
+	}
+	uri := fmt.Sprintf("%s/getCrmData?index_pkg_code=%s&data_source_type=%s&current_index=%d&page_size=%d&detail_last_update_start_time=%s", utils.SyncCrmIndexPath, assetPkgCd, utils.SyncCrmDataSourceType, currIndex, pageSize, lastUpdateTimeStr)
+	bResult, err, _ := HttpEtaBridgeGet(uri)
+	if err != nil {
+		return
+	}
+
+	result := new(EtaBridgeDataRespAndBusinessData)
+	err = json.Unmarshal(bResult, &result)
+	if err != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", err.Error(), string(bResult))
+		utils.FileLog.Info("桥接服务get请求失败:\n" + string(bResult))
+		return
+	}
+
+	//totalPage := result.Data.Paging.Pages
+
+	for _, v := range result.Data.List {
+		tmpErr := pushCrmDataToHub(v)
+		if tmpErr != nil {
+			errMsgList = append(errMsgList, tmpErr.Error())
+		}
+
+	}
+
+	// 如果还有下一页,那么就继续请求下一页
+	if currIndex < result.Data.Paging.Pages {
+		_, tmpErrMsgList := syncCrmIndex(assetPkgCd, currIndex+1, utils.SyncCrmIndexNum, baseLastUpdateTimeStr)
+		errMsgList = append(errMsgList, tmpErrMsgList...)
+	}
+
+	return
+}
+
+// pushCrmDataToHub
+// @Description: 调用hub服务,将数据推送到eta
+// @author: Roc
+// @datetime 2024-05-17 15:55:24
+// @param data interface{}
+// @return err error
+func pushCrmDataToHub(data interface{}) (err error) {
+	uri := `/edb/push`
+	_, err, _ = eta_hub.HttpEtaHubPost(uri, data)
+
+	//result := new(EtaBridgeDataRespAndBusinessData)
+	//err = json.Unmarshal(bResult, &result)
+	//if err != nil {
+	//	err = fmt.Errorf("result unmarshal err: %s\nresult: %s", err.Error(), string(bResult))
+	//	utils.FileLog.Info("桥接服务get请求失败:\n" + string(bResult))
+	//	return
+	//}
+
+	return
+}
+
+// modifyCrmIndexLastUpdateTime
+// @Description: 修改crm指标的最近拉取的时间
+// @author: Roc
+// @datetime 2024-05-17 11:32:32
+// @param fileName string
+// @param position uint32
+// @return err error
+func modifyCrmIndexLastUpdateTime(lastUpdateTime string) {
+	var err error
+	defer func() {
+		if err != nil {
+			utils.FileLog.Error("修改binlog文件名称和位置异常,lastUpdateTime", lastUpdateTime, ",err:", err)
+		}
+	}()
+
+	// fileName 变更
+	key := data_manage.CrmIndexLastUpdateTime
+	fileNameLog, err := data_manage.GetBusinessSysInteractionLogByKey(key)
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			return
+		}
+		err = nil
+		fileNameLog = &data_manage.BusinessSysInteractionLog{
+			//ID:             0,
+			InteractionKey: key,
+			InteractionVal: lastUpdateTime,
+			Remark:         "crm拉取数据的最近更新时间",
+			ModifyTime:     time.Now(),
+			CreateTime:     time.Now(),
+		}
+		err = fileNameLog.Create()
+		if err != nil {
+			return
+		}
+	} else {
+		fileNameLog.InteractionVal = lastUpdateTime
+		fileNameLog.ModifyTime = time.Now()
+		err = fileNameLog.Update([]string{"InteractionVal", "ModifyTime"})
+		if err != nil {
+			return
+		}
+	}
+
+	return
+}

+ 194 - 0
services/eta_hub/edb.go

@@ -0,0 +1,194 @@
+package eta_hub
+
+import (
+	"encoding/json"
+	"errors"
+	"eta/eta_task/utils"
+	"fmt"
+	"io"
+	"net/http"
+	"sort"
+	"strings"
+	"time"
+)
+
+// BaseEtaHubDataResp 基础返回参数
+type BaseEtaHubDataResp struct {
+	Ret         int
+	Msg         string
+	ErrMsg      string
+	ErrCode     string
+	Data        interface{}
+	Success     bool `description:"true 执行成功,false 执行失败"`
+	IsSendEmail bool `json:"-" description:"true 发送邮件,false 不发送邮件"`
+	IsAddLog    bool `json:"-" description:"true 新增操作日志,false 不新增操作日志" `
+}
+
+// HttpEtaHubPost
+// @Description: eta-bridge的post请求
+// @author: Roc
+// @datetime 2024-02-28 16:55:02
+// @param urlStr string
+// @param postData string
+// @param param interface{}
+// @return bResult []byte
+// @return err error
+// @return errMsg string
+func HttpEtaHubPost(urlStr string, param interface{}) (bResult []byte, err error, errMsg string) {
+	if utils.EtaHubUrl == "" {
+		errMsg = `未配置第三方的桥接服务地址`
+		err = errors.New(errMsg)
+		return
+	}
+	data, e := json.Marshal(param)
+	if e != nil {
+		err = fmt.Errorf("data json marshal err: %s", e.Error())
+		return
+	}
+
+	postUrl := utils.EtaHubUrl + "/v1" + urlStr
+
+	body := io.NopCloser(strings.NewReader(string(data)))
+	client := &http.Client{}
+	req, e := http.NewRequest("POST", postUrl, body)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	// 随机字符串
+	nonce := utils.GetRandStringNoSpecialChar(16)
+	timestamp := fmt.Sprint(time.Now().Second())
+	sign := GetSign(nonce, timestamp)
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("nonce", nonce)
+	req.Header.Set("timestamp", timestamp)
+	req.Header.Set("appid", utils.APPID)
+	req.Header.Set("signature", sign)
+
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	bResult, e = io.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(bResult) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+
+	result := new(BaseEtaHubDataResp)
+	if e = json.Unmarshal(bResult, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(bResult))
+		utils.FileLog.Info("桥接服务post请求失败:\n" + string(bResult))
+		return
+	}
+	if result.Ret != 200 {
+		errMsg = result.Msg
+		err = fmt.Errorf("result: %s", string(bResult))
+		return
+	}
+
+	return
+}
+
+// HttpEtaHubGet
+// @Description: eta-bridge的get请求
+// @author: Roc
+// @datetime 2024-02-28 16:55:02
+// @param urlStr string
+// @param postData string
+// @return bResult []byte
+// @return err error
+// @return errMsg string
+func HttpEtaHubGet(urlStr string) (bResult []byte, err error, errMsg string) {
+	if utils.EtaHubUrl == "" {
+		errMsg = `未配置第三方的桥接服务地址`
+		err = errors.New(errMsg)
+		return
+	}
+
+	postUrl := utils.EtaHubUrl + "/v1" + urlStr
+
+	client := &http.Client{}
+	req, e := http.NewRequest("GET", postUrl, nil)
+	if e != nil {
+		err = fmt.Errorf("http create request err: %s", e.Error())
+		return
+	}
+
+	contentType := "application/json;charset=utf-8"
+	// 随机字符串
+	nonce := utils.GetRandStringNoSpecialChar(16)
+	timestamp := fmt.Sprint(time.Now().Second())
+	sign := GetSign(nonce, timestamp)
+
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("nonce", nonce)
+	req.Header.Set("timestamp", timestamp)
+	req.Header.Set("appid", utils.APPID)
+	req.Header.Set("signature", sign)
+
+	resp, e := client.Do(req)
+	if e != nil {
+		err = fmt.Errorf("http client do err: %s", e.Error())
+		return
+	}
+	defer func() {
+		_ = resp.Body.Close()
+	}()
+	bResult, e = io.ReadAll(resp.Body)
+	if e != nil {
+		err = fmt.Errorf("resp body read err: %s", e.Error())
+		return
+	}
+	if len(bResult) == 0 {
+		err = fmt.Errorf("resp body is empty")
+		return
+	}
+
+	result := new(BaseEtaHubDataResp)
+	if e = json.Unmarshal(bResult, &result); e != nil {
+		err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(bResult))
+		utils.FileLog.Info("桥接服务get请求失败:\n" + string(bResult))
+		return
+	}
+	if result.Ret != 200 {
+		errMsg = result.Msg
+		err = fmt.Errorf("result: %s", string(bResult))
+		return
+	}
+
+	return
+}
+
+func GetSign(nonce, timestamp string) (sign string) {
+	signStrMap := map[string]string{
+		"nonce":     nonce,
+		"timestamp": timestamp,
+		"appid":     utils.APPID,
+	}
+	keys := make([]string, 0, len(signStrMap))
+	for k := range signStrMap {
+		keys = append(keys, k)
+	}
+	sort.Strings(keys)
+	var signStr string
+	for _, k := range keys {
+		signStr += k + "=" + signStrMap[k] + "&"
+	}
+	signStr = strings.Trim(signStr, "&")
+	//fmt.Println("signStr:" + signStr)
+	sign = utils.HmacSha256ToBase64(utils.SECRET, signStr)
+	//fmt.Println("sign:" + sign)
+	return
+}

+ 10 - 0
services/task_xy.go

@@ -47,4 +47,14 @@ func XyTask() {
 		syncIndex := task.NewTask("syncIndex", syncIndexTime, eta_bridge.SyncIndex)
 		task.AddTask("定时同步指标信息", syncIndex)
 	}
+
+	if utils.SyncCrmIndexPath != `` {
+		// 每小时同步一次指标列表
+		syncIndexTime := utils.SyncCrmIndexTime
+		if syncIndexTime == `` {
+			syncIndexTime = "0 0 * * * *"
+		}
+		syncXyCrmIndex := task.NewTask("syncXyCrmIndex", syncIndexTime, eta_bridge.SyncXyCrmIndex)
+		task.AddTask("定时同步crm指标信息", syncXyCrmIndex)
+	}
 }

+ 16 - 0
utils/common.go

@@ -4,6 +4,7 @@ import (
 	"crypto/hmac"
 	"crypto/md5"
 	"crypto/sha1"
+	"crypto/sha256"
 	"encoding/base64"
 	"encoding/hex"
 	"encoding/json"
@@ -935,3 +936,18 @@ func GetTimeSubDay(t1, t2 time.Time) int {
 
 	return day
 }
+
+// HmacSha256 计算HmacSha256
+// key 是加密所使用的key
+// data 是加密的内容
+func HmacSha256(key string, data string) []byte {
+	mac := hmac.New(sha256.New, []byte(key))
+	_, _ = mac.Write([]byte(data))
+
+	return mac.Sum(nil)
+}
+
+// HmacSha256ToBase64 将加密后的二进制转Base64字符串
+func HmacSha256ToBase64(key string, data string) string {
+	return base64.URLEncoding.EncodeToString(HmacSha256(key, data))
+}

+ 35 - 9
utils/config.go

@@ -131,6 +131,15 @@ var (
 	SyncIndexPath         string // 桥接服务-指标同步服务地址
 	SyncIndexTime         string // 桥接服务-指标同步的时间配置
 	SyncIndexClassifyTime string // 桥接服务-指标分类同步的时间配置
+	SyncCrmIndexPath      string // 桥接服务-crm指标同步服务地址
+	SyncCrmIndexTime      string // 桥接服务-crm指标同步的时间配置
+	SyncCrmAssetPkgCd     string // 桥接服务-crm资产包配置
+	SyncCrmDataSourceType string // 桥接服务-crm内部来源系统参数配置
+	SyncCrmIndexNum       int    // 桥接服务-每次同步crm数据的数量
+)
+
+var (
+	EtaHubUrl string // 公共服务地址
 )
 
 var (
@@ -275,15 +284,32 @@ func init() {
 
 	// 桥接服务
 	{
-		EtaBridgeUrl = config["eta_bridge_url"]                    // 桥接服务地址
-		EtaBridgeAppNameEn = config["eta_bridge_app_name_en"]      // 桥接服务英文名称-鉴权用
-		EtaBridgeMd5Key = config["eta_bridge_md5_key"]             // 桥接服务Md5密钥-鉴权用
-		EtaBridgeDesKey = config["eta_bridge_des_key"]             // 桥接服务Des密钥-解密数据用
-		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"] // 桥接服务-指标分类同步的时间配置
+		EtaBridgeUrl = config["eta_bridge_url"]                     // 桥接服务地址
+		EtaBridgeAppNameEn = config["eta_bridge_app_name_en"]       // 桥接服务英文名称-鉴权用
+		EtaBridgeMd5Key = config["eta_bridge_md5_key"]              // 桥接服务Md5密钥-鉴权用
+		EtaBridgeDesKey = config["eta_bridge_des_key"]              // 桥接服务Des密钥-解密数据用
+		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"]            // 桥接服务-crm指标同步服务地址
+		SyncCrmIndexTime = config["sync_crm_index_time"]            // 桥接服务-crm指标同步的时间配置
+		SyncCrmAssetPkgCd = config["sync_crm_asset_pkg_cd"]         // 桥接服务-crm资产包配置
+		SyncCrmDataSourceType = config["sync_crm_data_source_type"] // 桥接服务-crm内部来源系统参数配置
+
+		syncCrmIndexNumStr := config["sync_crm_index_num"] // 桥接服务-每次同步crm数据的数量
+		if syncCrmIndexNumStr != `` {
+			SyncCrmIndexNum, _ = strconv.Atoi(syncCrmIndexNumStr)
+		}
+		if SyncCrmIndexNum <= 0 {
+			SyncCrmIndexNum = 2000
+		}
+	}
+
+	// 公共服务
+	{
+		EtaHubUrl = config["eta_hub_url"] // 公共服务地址
 	}
 
 	HzDataApi = config["hz_data_api"]

+ 15 - 13
utils/constants.go

@@ -2,19 +2,20 @@ package utils
 
 // 常量定义
 const (
-	FormatTime             = "15:04:05"                //时间格式
-	FormatDate             = "2006-01-02"              //日期格式
-	FormatDateUnSpace      = "20060102"                //日期格式
-	FormatDateTime         = "2006-01-02 15:04:05"     //完整时间格式
-	HlbFormatDateTime      = "2006-01-02_15:04:05.999" //完整时间格式
-	FormatDateTimeMinute   = "2006-01-02 15:04"        //时间格式只精确到分钟
-	FormatDateTimeUnSpace  = "20060102150405"          //完整时间格式
-	FormatMonthDateUnSpace = "200601"                  //年月格式
-	PageSize15             = 15                        //列表页每页数据量
-	PageSize5              = 5
-	PageSize10             = 10
-	PageSize20             = 20
-	PageSize30             = 30
+	FormatTime              = "15:04:05"                //时间格式
+	FormatDate              = "2006-01-02"              //日期格式
+	FormatDateUnSpace       = "20060102"                //日期格式
+	FormatDateTime          = "2006-01-02 15:04:05"     //完整时间格式
+	HlbFormatDateTime       = "2006-01-02_15:04:05.999" //完整时间格式
+	FormatDateTimeMinute    = "2006-01-02 15:04"        //时间格式只精确到分钟
+	FormatDateTimeUnSpace   = "20060102150405"          //完整时间格式
+	FormatDateTimeUnSpaceV2 = "20060102 15:04:05"       //完整时间格式,日期与时间中间空格隔开
+	FormatMonthDateUnSpace  = "200601"                  //年月格式
+	PageSize15              = 15                        //列表页每页数据量
+	PageSize5               = 5
+	PageSize10              = 10
+	PageSize20              = 20
+	PageSize30              = 30
 )
 
 // 手机号,电子邮箱正则
@@ -103,6 +104,7 @@ const (
 	DATA_SOURCE_GFEX                                 = 78       // 广州期货交易所->78
 	DATA_SOURCE_ICPI                                 = 79       // ICPI消费价格指数->79
 	DATA_SOURCE_BLOOMBERG                            = 83       // bloomberg彭博数据
+	DATA_SOURCE_BUSINESS                             = 84       // 来源于自有数据
 )
 
 // 数据刷新频率