|
@@ -2,6 +2,8 @@ package services
|
|
|
|
|
|
import (
|
|
|
"context"
|
|
|
+ "eta/eta_task/models"
|
|
|
+ "eta/eta_task/models/data_manage"
|
|
|
"eta/eta_task/models/data_manage/edb_refresh"
|
|
|
"eta/eta_task/services/alarm_msg"
|
|
|
"eta/eta_task/services/data"
|
|
@@ -53,7 +55,9 @@ func ConfigRefreshData(cont context.Context) (err error) {
|
|
|
wg.Done()
|
|
|
continue
|
|
|
}
|
|
|
- go BaseRefreshData(&wg, edbList[0].Source, edbList[0].SubSource, edbList)
|
|
|
+ if len(edbList) != 0 {
|
|
|
+ go BaseRefreshData(&wg, edbList[0].Source, edbList[0].SubSource, edbList)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
wg.Wait()
|
|
@@ -111,6 +115,21 @@ func getDefaultRefreshData(now time.Time) (sourceEdbInfoListMap map[string][]*ed
|
|
|
//刷新频率,枚举值:每自然日、每交易日、每周、每旬、每月、每季、每半年、每年
|
|
|
refreshFrequencyList := []string{"每自然日", "每交易日", "每周", "每旬", "每月", "每季", "每半年", "每年"}
|
|
|
|
|
|
+ conf, err := models.GetBusinessConf()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ utils.FileLog.Info("获取业务配置失败,Err:" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取钢联化工的数据获取方式
|
|
|
+ mySteelChemicalDataMethod := "excel"
|
|
|
+ if v, ok := conf["MySteelDataMethod"]; ok {
|
|
|
+ if v == "api" {
|
|
|
+ mySteelChemicalDataMethod = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ utils.FileLog.Info("获取业务配置,MySteelDataMethod:" + mySteelChemicalDataMethod)
|
|
|
// 获取各个刷新频率的配置
|
|
|
for _, refreshFrequency := range refreshFrequencyList {
|
|
|
// 获取刷新频率条件
|
|
@@ -124,9 +143,14 @@ func getDefaultRefreshData(now time.Time) (sourceEdbInfoListMap map[string][]*ed
|
|
|
pars = append(pars, refreshFrequency, currTimeStr)
|
|
|
|
|
|
// 这两个是excel的数据源,他是从公共机更新的,需要过滤掉
|
|
|
- condition += ` AND source not in (?,?)`
|
|
|
- pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS)
|
|
|
-
|
|
|
+ if mySteelChemicalDataMethod == "api" {
|
|
|
+ // 钢联化工使用api的方式获取数据的,不需要过滤
|
|
|
+ condition += ` AND source not in (?)`
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_YS)
|
|
|
+ } else {
|
|
|
+ condition += ` AND source not in (?,?)`
|
|
|
+ pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS)
|
|
|
+ }
|
|
|
tmpList, tmpErr := edb_refresh.GetListByCondition(condition, pars)
|
|
|
if tmpErr != nil {
|
|
|
err = tmpErr
|
|
@@ -164,7 +188,45 @@ func getDefaultRefreshData(now time.Time) (sourceEdbInfoListMap map[string][]*ed
|
|
|
for source, subSourceFrequencyListMap := range refreshDataFrequencyListMap {
|
|
|
switch source {
|
|
|
case utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS:
|
|
|
- // 这种不处理
|
|
|
+ // 只处理钢联化工使用api方式获取数据的情况
|
|
|
+ if mySteelChemicalDataMethod == "api" {
|
|
|
+ for subSource, frequencyList := range subSourceFrequencyListMap {
|
|
|
+ items, tmpErr := data_manage.GetBaseFromMysteelChemicalIndexItems(frequencyList)
|
|
|
+ if tmpErr != nil {
|
|
|
+ errMsgList = append(errMsgList, fmt.Sprint("source:", source, "subSource:", subSource, "frequencyList:", strings.Join(frequencyList, ","), "err:", tmpErr.Error()))
|
|
|
+ }
|
|
|
+ indexList := make([]*edb_refresh.EdbInfoListAndRefreshConfig, 0)
|
|
|
+
|
|
|
+ for _, v := range items {
|
|
|
+ tmpConf := new(edb_refresh.EdbInfoListAndRefreshConfig)
|
|
|
+ // 数据刷新的期数
|
|
|
+ dataRefreshNum := utils.DATA_REFRESH
|
|
|
+ key := fmt.Sprintf("%d_%d_%s", utils.DATA_SOURCE_MYSTEEL_CHEMICAL, 0, v.Frequency)
|
|
|
+ if edbRefreshDefaultConfig, ok := refreshDataNumMap[key]; ok {
|
|
|
+ if edbRefreshDefaultConfig.RefreshAllData == 1 { // 刷新所有数据期数
|
|
|
+ dataRefreshNum = 0
|
|
|
+ } else if edbRefreshDefaultConfig.RefreshDataNum > 0 { //
|
|
|
+ dataRefreshNum = edbRefreshDefaultConfig.RefreshDataNum
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tmpConf.EdbCode = v.IndexCode
|
|
|
+ tmpConf.EdbName = v.IndexName
|
|
|
+ tmpConf.Source = utils.DATA_SOURCE_MYSTEEL_CHEMICAL
|
|
|
+ tmpConf.Frequency = v.Frequency
|
|
|
+ tmpConf.Unit = v.Unit
|
|
|
+ tmpConf.StartDate, err = time.Parse(utils.FormatDate, v.StartDate)
|
|
|
+ tmpConf.EndDate, err = time.Parse(utils.FormatDate, v.EndDate)
|
|
|
+ tmpConf.ClassifyId = int(v.BaseFromMysteelChemicalClassifyId)
|
|
|
+ tmpConf.DataRefreshNum = dataRefreshNum
|
|
|
+ tmpConf.EdbInfoId = v.EdbInfoId
|
|
|
+ indexList = append(indexList, tmpConf)
|
|
|
+ }
|
|
|
+
|
|
|
+ key := fmt.Sprint(source, "_", subSource)
|
|
|
+ sourceEdbInfoListMap[key] = indexList
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 其他情况不处理
|
|
|
default:
|
|
|
for subSource, frequencyList := range subSourceFrequencyListMap {
|
|
|
edbList, tmpErr := edb_refresh.GetDefaultRefreshEdbInfoListBySourceAndSubSource(source, subSource, frequencyList)
|
|
@@ -248,8 +310,27 @@ func getConfigRefreshData(now time.Time) (sourceEdbInfoListMap map[string][]*edb
|
|
|
configIdList = append(configIdList, v.EdbRefreshConfigId)
|
|
|
configIdEdbRefreshConfigMap[v.EdbRefreshConfigId] = v
|
|
|
}
|
|
|
+ conf, err := models.GetBusinessConf()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- edbInfoList, err := edb_refresh.GetConfigRefreshEdbInfoListBySourceAndSubSource([]int{utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS}, configIdList)
|
|
|
+ // 获取钢联化工的数据获取方式
|
|
|
+ mySteelChemicalDataMethod := "excel"
|
|
|
+ if v, ok := conf["MySteelDataMethod"]; ok {
|
|
|
+ if v == "api" {
|
|
|
+ mySteelChemicalDataMethod = v
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 当钢联的数据获取方式是api时,不用过滤
|
|
|
+ var sourceList []int
|
|
|
+ if mySteelChemicalDataMethod == "api" {
|
|
|
+ sourceList = []int{utils.DATA_SOURCE_YS}
|
|
|
+ } else {
|
|
|
+ sourceList = []int{utils.DATA_SOURCE_MYSTEEL_CHEMICAL, utils.DATA_SOURCE_YS}
|
|
|
+ }
|
|
|
+ edbInfoList, err := edb_refresh.GetConfigRefreshEdbInfoListBySourceAndSubSource(sourceList, configIdList)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|