瀏覽代碼

fix:象屿接口

Roc 1 年之前
父節點
當前提交
7036758c8b

+ 44 - 0
models/data_manage/edb_classify.go

@@ -0,0 +1,44 @@
+package data_manage
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type EdbClassify struct {
+	ClassifyID         int64     `orm:"column(classify_id);pk"`
+	ClassifyType       uint32    `orm:"column:classify_type;default:0;comment:'分类类型,0:普通指标分类,1:预测指标分类'"`
+	ClassifyName       string    `orm:"column:classify_name;not null;default:'';comment:'分类名称'"`
+	ParentID           int64     `orm:"column:parent_id;not null;default:0;comment:'父级id'"`
+	HasData            int32     `orm:"column:has_data;default:0;comment:'是否存在指标数据:1有,2:无'"`
+	CreateTime         time.Time `orm:"column:create_time"`
+	ModifyTime         time.Time `orm:"column:modify_time"`
+	SysUserID          int64     `orm:"column:sys_user_id;comment:'创建人id'"`
+	SysUserRealName    string    `orm:"column:sys_user_real_name;size:50;comment:'创建人姓名'"`
+	Level              int64     `orm:"column:level;default:0;comment:'层级'"`
+	UniqueCode         string    `orm:"column:unique_code;size:50"`
+	Sort               uint32    `orm:"column:sort;unsigned;default:10;comment:'排序字段,越小越靠前,默认值:10'"`
+	RootID             int64     `orm:"column:root_id;not null;default:0;comment:'顶级ID'"`
+	LastModifyUserID   uint32    `orm:"column:last_modify_user_id;unsigned;not null;default:0;comment:'最后修改人ID'"`
+	LastModifyUserName string    `orm:"column:last_modify_user_real_name;size:64;not null;default:'';comment:'最后修改人姓名'"`
+}
+
+// GetAllEdbClassifyListByCondition
+// @Description: 获取分类列表
+// @author: Roc
+// @datetime 2024-02-29 10:55:38
+// @param condition string
+// @param pars []interface{}
+// @return item []*EdbInfoUpdateLog
+// @return err error
+func GetAllEdbClassifyListByCondition(condition string, pars []interface{}) (item []*EdbClassify, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM edb_classify WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY classify_id ASC `
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	return
+}

+ 33 - 0
models/data_manage/edb_info.go

@@ -210,3 +210,36 @@ func DeleteEdbDataByIdAndSource(edbDataId, source int) (err error) {
 	_, err = o.Raw(sql, edbDataId).Exec()
 	return
 }
+
+type EdbInfoClassify struct {
+	EdbInfoId       int    `orm:"column(edb_info_id);pk"`
+	SourceName      string `description:"来源名称"`
+	Source          int    `description:"来源id"`
+	EdbCode         string `description:"指标编码"`
+	ClassifyId      int    `description:"分类id"`
+	SysUserId       int
+	SysUserRealName string
+	UniqueCode      string `description:"指标唯一编码"`
+	CreateTime      time.Time
+	ModifyTime      time.Time
+}
+
+// GetAllEdbInfoClassifyListByCondition
+// @Description: 获取指标与分类的关系列表
+// @author: Roc
+// @datetime 2024-02-29 10:55:38
+// @param condition string
+// @param pars []interface{}
+// @return item []*EdbInfoUpdateLog
+// @return err error
+func GetAllEdbInfoClassifyListByCondition(condition string, pars []interface{}) (item []*EdbInfoClassify, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM edb_info WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY edb_info_id ASC `
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	return
+}

+ 51 - 0
models/data_manage/edb_info_update_log.go

@@ -0,0 +1,51 @@
+package data_manage
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type EdbInfoUpdateLog struct {
+	Id                     int       `orm:"column(id);pk"`
+	EdbInfoId              int       `description:"指标id"`
+	SourceName             string    `description:"来源名称"`
+	Source                 int       `description:"来源id"`
+	EdbCode                string    `description:"指标编码"`
+	EdbName                string    `description:"指标名称"`
+	EdbNameSource          string    `description:"指标名称来源"`
+	Frequency              string    `description:"频率"`
+	Unit                   string    `description:"单位"`
+	StartDate              string    `description:"起始日期"`
+	EndDate                string    `description:"终止日期"`
+	ClassifyId             int       `description:"分类id"`
+	SysUserId              int       `description:"创建人"`
+	SysUserRealName        string    `description:"创建人名称"`
+	UpdateSysUserId        int       `description:"变更人"`
+	UpdateSysUserRealName  string    `description:"变更人名称"`
+	EdbModifyTime          string    `description:"指标修改时间"`
+	UniqueCode             string    `description:"唯一编码"`
+	LatestDate             string    `description:"数据最新日期"`
+	LatestValue            float64   `description:"数据最新值"`
+	TerminalCode           string    `gorm:"column:terminal_code;default:'';comment:'终端编码,用于配置在机器上'"`
+	CreateTime             time.Time `gorm:"column:create_time;default:null;comment:'创建时间,即指标刷新/更新操作时间点'"`
+	DataUpdateTime         time.Time `gorm:"column:data_update_time;default:null;comment:'最近一次数据发生变化的时间'"`
+	ErDataUpdateDate       time.Time `gorm:"column:er_data_update_date;default:null;comment:'本次更新,数据发生变化的最早日期'"`
+	UpdateResult           int32     `gorm:"column:update_result;default:null;comment:'本次刷新操作结果:1成功,2失败'"`
+	UpdateFailedReason     string    `gorm:"column:update_failed_reason;default:null;comment:'刷新失败原因'"`
+	DataUpdateResult       int32     `gorm:"column:data_update_result;not null;default:0;comment:'数据更新结果:1成功,2失败'"`
+	DataUpdateFailedReason string    `description:"数据未正常更新原因"`
+	IsSourceRefresh        int       `description:"终端刷新到数据源的刷新操作:0否,1是"`
+	UpdateType             int       `description:"变更类型,0:数据明细变更,1:基础信息变更, 2:新增指标"`
+}
+
+func GetEdbInfoUpdateLogByCondition(condition string, pars []interface{}) (item []*EdbInfoUpdateLog, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM edb_info_update_log WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY id ASC limit 0,10  `
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+
+	return
+}

+ 94 - 0
services/eta_bridge/eta_bridge.go

@@ -0,0 +1,94 @@
+package eta_bridge
+
+import (
+	"encoding/json"
+	"errors"
+	"eta/eta_task/utils"
+	"fmt"
+	"io"
+	"net/http"
+	"strings"
+)
+
+// BaseEtaBridgeDataResp 基础返回参数
+type BaseEtaBridgeDataResp struct {
+	Code int    `json:"code" description:"状态码"`
+	Msg  string `json:"msg" description:"提示信息"`
+	//Data GetCrmTokenData `json:"data" description:"返回数据"`
+}
+
+// HttpEtaBridgePost
+// @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 HttpEtaBridgePost(urlStr string, param interface{}) (bResult []byte, err error, errMsg string) {
+	if utils.EtaBridgeUrl == "" {
+		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.EtaBridgeUrl + "/api" + 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
+	}
+
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+
+	checkToken := utils.MD5(utils.EtaBridgeAppNameEn + utils.EtaBridgeMd5Key)
+	req.Header.Set("Authorization", checkToken)
+	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
+	}
+	// 生产环境解密, 注意有个坑前后的双引号
+	if utils.RunMode == "release" {
+		str := string(bResult)
+		str = strings.Trim(str, `"`)
+		bResult = utils.DesBase64Decrypt([]byte(str), utils.EtaBridgeDesKey)
+	}
+
+	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("第三方登录(向桥接服务换取token):\n" + string(bResult))
+		return
+	}
+	if result.Code != 200 {
+		errMsg = result.Msg
+		err = fmt.Errorf("result: %s", string(bResult))
+		return
+	}
+
+	return
+}

+ 419 - 0
services/eta_bridge/xy.go

@@ -0,0 +1,419 @@
+package eta_bridge
+
+import (
+	"context"
+	"eta/eta_task/models/data_manage"
+	"eta/eta_task/services/alarm_msg"
+	"eta/eta_task/utils"
+	"fmt"
+)
+
+// PushIndexValueParamReq
+// @Description: 业务报文
+type PushBaseParamReq struct {
+	SerialID    string      `json:"serialID" description:"流水号"`
+	TableCode   string      `json:"tableCode" description:"数据表编码"`
+	Total       int         `json:"total" description:"本次落表数据总数"`
+	IsEmailWarn int         `json:"isEmailWarn" description:"是否发送预警邮件,(1-是 0-否)"`
+	Data        interface{} `json:"data" description:"报文体"`
+}
+
+// PushDataParamReq
+// @Description: 业务报文
+type PushDataParamReq struct {
+	SerialID    string      `json:"serialID" description:"流水号"`
+	TableCode   string      `json:"tableCode" description:"数据表编码"`
+	Total       int         `json:"total" description:"本次落表数据总数"`
+	IsEmailWarn int         `json:"isEmailWarn" description:"是否发送预警邮件,(1-是 0-否)"`
+	Data        interface{} `json:"data" description:"报文体,指标数据列表"`
+}
+
+// PushDataParamDataReq
+// @Description: 指标数据结构
+type PushDataParamDataReq struct {
+	SourceIndexCode string `json:"source_index_code" description:"上游来源指标ID"`
+	IndexCode       string `json:"index_code" description:""`
+	IndexName       string `json:"index_name" description:""`
+	IndexShortName  string `json:"index_short_name" description:""`
+	FrequenceName   string `json:"frequence_name" description:""`
+	UnitName        string `json:"unit_name" description:""`
+	//CountryName          string `json:"country_name" description:""`
+	//ProvinceName         string `json:"province_name" description:""`
+	//AreaName             string `json:"area_name" description:""`
+	//CityName             string `json:"city_name" description:""`
+	//CountyName           string `json:"county_name" description:""`
+	//RegionName           string `json:"region_name" description:""`
+	//CompanyName          string `json:"company_name" description:""`
+	//BreedName            string `json:"breed_name" description:""`
+	//MaterialName         string `json:"material_name" description:""`
+	//SpecName             string `json:"spec_name" description:""`
+	//MarketName           string `json:"market_name" description:""`
+	//DerivativeType       string `json:"derivative_type" description:""`
+	//ContractName         string `json:"contract_name" description:""`
+	//AuthKindName         string `json:"auth_kind_name" description:""`
+	//CustomSmallClassName string `json:"custom_small_class_name" description:""`
+	AssetBeginDate   string `json:"asset_begin_date" description:""`
+	AssetEndDate     string `json:"asset_end_date" description:""`
+	CreateUser       string `json:"create_user" description:""`
+	IndexCreateTime  string `json:"index_create_time" description:""`
+	UpdateUser       string `json:"update_user" description:""`
+	DetailUpdateTime string `json:"detail_update_time" description:""`
+	IndexUpdateTime  string `json:"index_update_time" description:""`
+	//DutyDept             string `json:"duty_dept" description:""`
+	//BusinessDept         string `json:"business_dept" description:""`
+	OrginSource    string `json:"orgin_source" description:""`
+	OrginSysSource string `json:"orgin_sys_source" description:""`
+	SysSource      string `json:"sys_source" description:""`
+	SourceType     string `json:"source_type" description:""`
+	//EtlTime              string `json:"etl_time" description:""`
+	Status int `json:"status" description:""`
+}
+
+// SyncIndexList
+// @Description: 定时同步ETA指标信息变更数据至第三方
+// @author: Roc
+// @datetime 2024-02-28 14:00:45
+// @param cont context.Context
+// @return err error
+func SyncIndexList(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			tips := "SyncIndexList-定时同步ETA指标信息变更数据至第三方失败, ErrMsg:\n" + err.Error()
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+	condition += " AND update_type in (?,?) "
+	pars = append(pars, 1, 2)
+
+	list, err := data_manage.GetEdbInfoUpdateLogByCondition(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	dataList := make([]PushDataParamDataReq, 0)
+	for _, v := range list {
+		dataList = append(dataList, PushDataParamDataReq{
+			SourceIndexCode:  v.EdbCode,
+			IndexCode:        fmt.Sprint(v.Source, "_", v.EdbCode),
+			IndexName:        v.EdbName,
+			IndexShortName:   v.EdbName, //todo
+			FrequenceName:    v.Frequency,
+			UnitName:         v.Unit,
+			AssetBeginDate:   v.StartDate,
+			AssetEndDate:     v.EndDate,
+			CreateUser:       v.SysUserRealName,
+			IndexCreateTime:  v.CreateTime.Format(utils.FormatDateTime), //todo
+			UpdateUser:       v.UpdateSysUserRealName,
+			DetailUpdateTime: v.CreateTime.Format(utils.FormatDateTime), //todo
+			IndexUpdateTime:  v.CreateTime.Format(utils.FormatDateTime), //todo
+			OrginSource:      v.SourceName,                              // todo
+			OrginSysSource:   v.SourceName,
+			SysSource:        "产研平台", //todo
+			SourceType:       "RPA",  //TODO
+			Status:           1,
+		})
+	}
+
+	lenData := len(dataList)
+	if lenData <= 0 {
+		return
+	}
+
+	req := PushBaseParamReq{
+		SerialID:    utils.GetRandString(32), //todo
+		TableCode:   "",
+		Total:       lenData,
+		IsEmailWarn: 0,
+		Data:        dataList,
+	}
+
+	uri := "/xy/index/pushIndexData"
+	_, e, errMsg := HttpEtaBridgePost(uri, req)
+	if e != nil {
+		err = fmt.Errorf("postRefreshEdbData err: %s", e.Error())
+		fmt.Println(err)
+		return
+	}
+	fmt.Println(errMsg)
+	//if res != nil && res.Ret != 200 {
+	//	err = fmt.Errorf("postRefreshEdbData fail")
+	//	return
+	//}
+	return
+}
+
+// PushIndexValueParamReq
+// @Description: 业务报文
+type PushIndexValueParamReq struct {
+	SerialID    string                  `json:"serialID" description:"流水号"`
+	TableCode   string                  `json:"tableCode" description:"数据表编码"`
+	Total       int                     `json:"total" description:"本次落表数据总数"`
+	IsEmailWarn int                     `json:"isEmailWarn" description:"是否发送预警邮件,(1-是 0-否)"`
+	Data        []PushIndexValueItemReq `json:"data" description:"报文体,指标日期值数据列表"`
+}
+
+// PushIndexValueItemReq
+// @Description: 指标日期值数据结构
+type PushIndexValueItemReq struct {
+	Id           string `json:"id"`
+	IndexCode    string `json:"index_code" description:"指标代码"`
+	Value        string `json:"value" description:"数值"`
+	BusinessDate string `json:"business_date" description:"业务日期(数据日期)"`
+	CreateTime   string `json:"create_time" description:"数据进入ETA的时间"`
+	UpdateTime   string `json:"update_time" description:"eta库中修改数据的时间"`
+	Status       string `json:"status" description:"逻辑删除使用,0-禁用,1-启用"`
+}
+
+// SyncIndexValueList
+// @Description: 定时同步ETA指标日期值的变更数据至第三方
+// @author: Roc
+// @datetime 2024-02-28 14:00:45
+// @param cont context.Context
+// @return err error
+func SyncIndexValueList(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			tips := "SyncIndexList-定时同步ETA指标信息变更数据至第三方失败, ErrMsg:\n" + err.Error()
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+	condition += " AND update_type = ? "
+	pars = append(pars, 0)
+
+	list, err := data_manage.GetEdbInfoUpdateLogByCondition(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	dataList := make([]PushIndexValueItemReq, 0)
+	for _, v := range list {
+		dataList = append(dataList, PushIndexValueItemReq{
+			Id:           utils.MD5(fmt.Sprint(v.Source, "_", v.SourceName, "_", v.Id)),
+			IndexCode:    fmt.Sprint(v.Source, "_", v.EdbCode),
+			Value:        fmt.Sprint(v.LatestValue),
+			BusinessDate: v.LatestDate,
+			CreateTime:   v.EdbModifyTime,
+			UpdateTime:   v.CreateTime.Format(utils.FormatDateTime), //todo,
+			Status:       "1",
+		})
+	}
+
+	lenData := len(dataList)
+	if lenData <= 0 {
+		return
+	}
+
+	req := PushBaseParamReq{
+		SerialID:    utils.GetRandString(32), //todo
+		TableCode:   "",
+		Total:       lenData,
+		IsEmailWarn: 0,
+		Data:        dataList,
+	}
+
+	uri := "/xy/index/pushIndexValue"
+	_, e, errMsg := HttpEtaBridgePost(uri, req)
+	if e != nil {
+		err = fmt.Errorf("postRefreshEdbData err: %s", e.Error())
+		fmt.Println(err)
+		return
+	}
+	fmt.Println(errMsg)
+	//if res != nil && res.Ret != 200 {
+	//	err = fmt.Errorf("postRefreshEdbData fail")
+	//	return
+	//}
+	return
+}
+
+// PushClassifyItemReq
+// @Description: 指标分类数据结构
+type PushClassifyItemReq struct {
+	ClassifyId      int    `json:"classify_id" description:"自增id"`
+	ClassifyType    int    `json:"classify_type" description:"分类类型,0:普通指标分类,1:预测指标分类"`
+	ClassifyName    string `json:"classify_name" description:"分类名称"`
+	ParentId        int    `json:"parent_id" description:"父级id"`
+	HasData         int    `json:"has_data" description:"是否存在指标数据,1:有,2:无"`
+	CreateTime      string `json:"create_time" description:"创建时间"`
+	UpdateTime      string `json:"update_time" description:"修改时间"`
+	SysUserId       int    `json:"sys_user_id" description:"创建人id"`
+	SysUserRealName string `json:"sys_user_real_name" description:"创建人姓名"`
+	Level           int    `json:"level" description:"层级"`
+	UniqueCode      string `json:"unique_code" description:"唯一编码"`
+	SortColumn      int    `json:"sort_column" description:"排序字段,越小越靠前,默认值:10"`
+}
+
+// SyncClassifyList
+// @Description: 定时同步ETA分类数据至第三方
+// @author: Roc
+// @datetime 2024-02-28 14:00:45
+// @param cont context.Context
+// @return err error
+func SyncClassifyList(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			tips := "SyncIndexList-定时同步ETA指标信息变更数据至第三方失败, ErrMsg:\n" + err.Error()
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+
+	list, err := data_manage.GetAllEdbClassifyListByCondition(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	dataLimitList := make([][]PushClassifyItemReq, 0)
+
+	dataList := make([]PushClassifyItemReq, 0)
+	for _, v := range list {
+		dataList = append(dataList, PushClassifyItemReq{
+			ClassifyId:      int(v.ClassifyID),
+			ClassifyType:    int(v.ClassifyType),
+			ClassifyName:    v.ClassifyName,
+			ParentId:        int(v.ParentID),
+			HasData:         int(v.HasData),
+			CreateTime:      v.CreateTime.Format(utils.FormatDateTime),
+			UpdateTime:      v.ModifyTime.Format(utils.FormatDateTime),
+			SysUserId:       int(v.SysUserID),
+			SysUserRealName: v.SysUserRealName,
+			Level:           int(v.Level),
+			UniqueCode:      v.UniqueCode,
+			SortColumn:      int(v.Sort),
+		})
+		if len(dataList) >= 100 {
+			dataLimitList = append(dataLimitList, dataList)
+			dataList = make([]PushClassifyItemReq, 0)
+		}
+	}
+
+	lenData := len(dataList)
+	if lenData > 0 {
+		dataLimitList = append(dataLimitList, dataList)
+	}
+
+	if len(dataLimitList) < 0 {
+		fmt.Println("无分类数据推送")
+		return
+	}
+
+	for k, tmpDataList := range dataLimitList {
+		req := PushBaseParamReq{
+			SerialID:    utils.GetRandString(32), //todo
+			TableCode:   "",
+			Total:       len(tmpDataList),
+			IsEmailWarn: 0,
+			Data:        tmpDataList,
+		}
+
+		uri := "/xy/index/pushClassify"
+		_, e, _ := HttpEtaBridgePost(uri, req)
+		if e != nil {
+			err = fmt.Errorf("第%d组分类数据推送失败,postRefreshEdbData err: %s", k+1, e.Error())
+			fmt.Println(err)
+			continue
+		}
+	}
+
+	return
+}
+
+// PushEdbClassifyItemReq
+// @Description: 指标与目录的关系请求结构
+type PushEdbClassifyItemReq struct {
+	Id         string `json:"id" description:"唯一主键"`
+	ClassifyId int    `json:"classify_id" description:"目录分类ID"`
+	IndexCode  string `json:"index_code" description:"指标ID"`
+	CreateTime string `json:"create_time" description:"创建时间"`
+	CreateUser string `json:"create_user" description:"创建人"`
+	UpdateTime string `json:"update_time" description:"修改时间"`
+	UpdateUser string `json:"update_user" description:"修改人"`
+}
+
+// SyncEdbClassifyList
+// @Description: 定时同步ETA指标与分类的关系至第三方
+// @author: Roc
+// @datetime 2024-02-28 14:00:45
+// @param cont context.Context
+// @return err error
+func SyncEdbClassifyList(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			tips := "SyncIndexList-定时同步ETA指标信息变更数据至第三方失败, ErrMsg:\n" + err.Error()
+			utils.FileLog.Info(tips)
+			go alarm_msg.SendAlarmMsg(tips, 3)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+
+	list, err := data_manage.GetAllEdbInfoClassifyListByCondition(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	dataLimitList := make([][]PushEdbClassifyItemReq, 0)
+
+	dataList := make([]PushEdbClassifyItemReq, 0)
+	for _, v := range list {
+		dataList = append(dataList, PushEdbClassifyItemReq{
+			Id:         fmt.Sprint(v.EdbInfoId),
+			ClassifyId: v.ClassifyId,
+			IndexCode:  fmt.Sprint(v.Source, "_", v.EdbCode),
+			CreateTime: v.CreateTime.Format(utils.FormatDateTime), //todo
+			CreateUser: v.SysUserRealName,
+			UpdateTime: v.ModifyTime.Format(utils.FormatDateTime), //todo
+			UpdateUser: v.SysUserRealName,
+		})
+		if len(dataList) >= 100 {
+			dataLimitList = append(dataLimitList, dataList)
+			dataList = make([]PushEdbClassifyItemReq, 0)
+		}
+	}
+
+	lenData := len(dataList)
+	if lenData > 0 {
+		dataLimitList = append(dataLimitList, dataList)
+	}
+
+	if len(dataLimitList) < 0 {
+		fmt.Println("无分类数据推送")
+		return
+	}
+
+	for k, tmpDataList := range dataLimitList {
+		req := PushBaseParamReq{
+			SerialID:    utils.GetRandString(32), //todo
+			TableCode:   "",
+			Total:       len(tmpDataList),
+			IsEmailWarn: 0,
+			Data:        tmpDataList,
+		}
+
+		uri := "/xy/index/pushEdbClassify"
+		_, e, _ := HttpEtaBridgePost(uri, req)
+		if e != nil {
+			err = fmt.Errorf("第%d组分类数据推送失败,postRefreshEdbData err: %s", k+1, e.Error())
+			fmt.Println(err)
+			continue
+		}
+	}
+
+	return
+}

+ 3 - 0
services/task.go

@@ -27,6 +27,8 @@ func Task() {
 	setEdbSourceStatTask := task.NewTask("setEdbSourceStatTask", "0 20 19,23 * * *", data_stat.SetEdbSourceStatTask)
 	task.AddTask("数据源统计表", setEdbSourceStatTask)
 
+	XyTask()
+
 	task.StartTask()
 	fmt.Println("task end")
 }
@@ -113,6 +115,7 @@ func releaseTask() {
 		syncZhongJiIndexList := task.NewTask("syncZhongJiIndexList", "0 0 17 * * *", data.SyncZhongJiIndexList)
 		task.AddTask("定时同步中基宁波SMM指标列表", syncZhongJiIndexList)
 	}
+
 }
 
 func RefreshData(cont context.Context) (err error) {

+ 21 - 0
services/task_xy.go

@@ -0,0 +1,21 @@
+package services
+
+import (
+	"eta/eta_task/utils"
+)
+
+func XyTask() {
+	if utils.IsXy != "1" {
+		return
+	}
+
+	//eta_bridge.SyncIndexList(nil)
+	//eta_bridge.SyncIndexValueList(nil)
+	//eta_bridge.SyncClassifyList(nil)
+	//eta_bridge.SyncEdbClassifyList(nil)
+	//return
+
+	// 每天同步一次指标列表
+	//syncIndex := task.NewTask("syncZhongJiIndexList", "0 0 17 * * *", eta_bridge.SyncIndexList)
+	//task.AddTask("定时同步指标列表", syncIndex)
+}

+ 25 - 0
utils/config.go

@@ -115,6 +115,18 @@ var (
 	AccessKeySecret  string
 )
 
+var (
+	// 是否xy
+	IsXy string
+)
+
+var (
+	EtaBridgeUrl       string // 桥接服务地址
+	EtaBridgeAppNameEn string // 桥接服务英文名称-鉴权用
+	EtaBridgeMd5Key    string // 桥接服务Md5密钥-鉴权用
+	EtaBridgeDesKey    string // 桥接服务Des密钥-解密数据用
+)
+
 var HzDataApi string
 
 func init() {
@@ -238,6 +250,19 @@ func init() {
 		SendWxTemplateEnable = config["send_wx_template_enable"]
 	}
 
+	// 客户信息
+	{
+		IsXy = config["is_xy"]
+	}
+
+	// 桥接服务
+	{
+		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密钥-解密数据用
+	}
+
 	HzDataApi = config["hz_data_api"]
 	if HzDataApi == "" {
 		HzDataApi = "https://hzdataapi.hzinsights.com/hzdataapi/"

+ 187 - 0
utils/des3.go

@@ -0,0 +1,187 @@
+// 加密工具类,用了3des和base64
+package utils
+
+import (
+	"bytes"
+	"crypto/cipher"
+	"crypto/des"
+	"encoding/base64"
+	"encoding/hex"
+	"errors"
+	"strings"
+)
+
+// des3 + base64 encrypt
+func DesBase64Encrypt(origData []byte, desKey string) []byte {
+	result, err := TripleDesEncrypt(origData, []byte(desKey))
+	if err != nil {
+		panic(any(err))
+	}
+	return []byte(base64.StdEncoding.EncodeToString(result))
+}
+
+func DesBase64Decrypt(crypted []byte, desKey string) []byte {
+	result, _ := base64.StdEncoding.DecodeString(string(crypted))
+	remain := len(result) % 8
+	if remain > 0 {
+		mod := 8 - remain
+		for i := 0; i < mod; i++ {
+			result = append(result, 0)
+		}
+	}
+	origData, err := TripleDesDecrypt(result, []byte(desKey))
+	if err != nil {
+		panic(any(err))
+	}
+	return origData
+}
+
+// 3DES加密
+func TripleDesEncrypt(origData, key []byte) ([]byte, error) {
+	block, err := des.NewTripleDESCipher(key)
+	if err != nil {
+		return nil, err
+	}
+	origData = PKCS5Padding(origData, block.BlockSize())
+	// origData = ZeroPadding(origData, block.BlockSize())
+	blockMode := cipher.NewCBCEncrypter(block, key[:8])
+	crypted := make([]byte, len(origData))
+	blockMode.CryptBlocks(crypted, origData)
+	return crypted, nil
+}
+
+// 3DES解密
+func TripleDesDecrypt(crypted, key []byte) ([]byte, error) {
+	block, err := des.NewTripleDESCipher(key)
+	if err != nil {
+		return nil, err
+	}
+	blockMode := cipher.NewCBCDecrypter(block, key[:8])
+	origData := make([]byte, len(crypted))
+	// origData := crypted
+	blockMode.CryptBlocks(origData, crypted)
+	origData = PKCS5UnPadding(origData)
+	// origData = ZeroUnPadding(origData)
+	return origData, nil
+}
+
+func ZeroPadding(ciphertext []byte, blockSize int) []byte {
+	padding := blockSize - len(ciphertext)%blockSize
+	padtext := bytes.Repeat([]byte{0}, padding)
+	return append(ciphertext, padtext...)
+}
+
+func ZeroUnPadding(origData []byte) []byte {
+	length := len(origData)
+	unpadding := int(origData[length-1])
+	return origData[:(length - unpadding)]
+}
+
+func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
+	padding := blockSize - len(ciphertext)%blockSize
+	padtext := bytes.Repeat([]byte{byte(padding)}, padding)
+	return append(ciphertext, padtext...)
+}
+
+func PKCS5UnPadding(origData []byte) []byte {
+	length := len(origData)
+	// 去掉最后一个字节 unpadding 次
+	unpadding := int(origData[length-1])
+	return origData[:(length - unpadding)]
+}
+
+// DES加密
+func DesEncrypt(content string, key string) string {
+	contents := []byte(content)
+	keys := []byte(key)
+	block, err := des.NewCipher(keys)
+	if err != nil {
+		return ""
+	}
+	contents = PKCS5Padding(contents, block.BlockSize())
+	blockMode := cipher.NewCBCEncrypter(block, keys)
+	crypted := make([]byte, len(contents))
+	blockMode.CryptBlocks(crypted, contents)
+	return byteToHexString(crypted)
+}
+
+func byteToHexString(bytes []byte) string {
+	str := ""
+	for i := 0; i < len(bytes); i++ {
+		sTemp := hex.EncodeToString([]byte{bytes[i]})
+		if len(sTemp) < 2 {
+			str += string(0)
+		}
+		str += strings.ToUpper(sTemp)
+	}
+	return str
+}
+
+// DES解密
+func DesDecrypt(content string, key string) string {
+	contentBytes, err := hex.DecodeString(content)
+	if err != nil {
+		return "字符串转换16进制数组失败" + err.Error()
+	}
+	keys := []byte(key)
+	block, err := des.NewCipher(keys)
+	if err != nil {
+		return "解密失败" + err.Error()
+	}
+	blockMode := cipher.NewCBCDecrypter(block, keys)
+	origData := contentBytes
+	blockMode.CryptBlocks(origData, contentBytes)
+	origData = ZeroUnPadding(origData)
+	return string(origData)
+}
+
+// DES ECB PKCK5Padding
+func EntryptDesECB(data, key []byte) (string, error) {
+	if len(key) > 8 {
+		key = key[:8]
+	}
+	block, err := des.NewCipher(key)
+	if err != nil {
+		return "", errors.New("des.NewCipher " + err.Error())
+	}
+	bs := block.BlockSize()
+	data = PKCS5Padding(data, bs)
+	if len(data)%bs != 0 {
+		return "", errors.New("EntryptDesECB Need a multiple of the blocksize")
+	}
+	out := make([]byte, len(data))
+	dst := out
+	for len(data) > 0 {
+		block.Encrypt(dst, data[:bs])
+		data = data[bs:]
+		dst = dst[bs:]
+	}
+	return base64.StdEncoding.EncodeToString(out), nil
+}
+
+func DecryptDESECB(d string, key []byte) ([]byte, error) {
+	data, err := base64.StdEncoding.DecodeString(d)
+	if err != nil {
+		return nil, errors.New("decodebase64 " + err.Error())
+	}
+	if len(key) > 8 {
+		key = key[:8]
+	}
+	block, err := des.NewCipher(key)
+	if err != nil {
+		return nil, errors.New("des.NewCipher " + err.Error())
+	}
+	bs := block.BlockSize()
+	if len(data)%bs != 0 {
+		return nil, errors.New("DecryptDES crypto/cipher: input not full blocks")
+	}
+	out := make([]byte, len(data))
+	dst := out
+	for len(data) > 0 {
+		block.Decrypt(dst, data[:bs])
+		data = data[bs:]
+		dst = dst[bs:]
+	}
+	out = PKCS5UnPadding(out)
+	return out, nil
+}