Quellcode durchsuchen

fix: 持仓分析表格刷新

hsun vor 1 Monat
Ursprung
Commit
73b6654058

+ 101 - 26
controllers/trade_analysis/trade_analysis_correlation.go

@@ -131,6 +131,21 @@ func (this *TradeAnalysisCorrelationController) Save() {
 	}
 	extraConfig := string(configByte)
 
+	// 表格数据
+	tableData, e := tradeAnalysisService.GetCorrelationTableRowsDataByConfig(req.TableConfig)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("获取表格数据失败, %v", e)
+		return
+	}
+	contentByte, e := json.Marshal(tableData)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格数据JSON格式化失败, %v", e)
+		return
+	}
+	excelContent := string(contentByte)
+
 	// 新增表格
 	var excelId int
 	if req.ExcelInfoId <= 0 {
@@ -143,6 +158,7 @@ func (this *TradeAnalysisCorrelationController) Save() {
 			ExcelClassifyId:    req.ClassifyId,
 			SysUserId:          sysUser.AdminId,
 			SysUserRealName:    sysUser.RealName,
+			Content:            excelContent,
 			ExtraConfig:        extraConfig,
 			UpdateUserId:       sysUser.AdminId,
 			UpdateUserRealName: sysUser.RealName,
@@ -171,11 +187,12 @@ func (this *TradeAnalysisCorrelationController) Save() {
 		}
 		excelItem.ExcelName = req.TableName
 		excelItem.ExcelClassifyId = req.ClassifyId
+		excelItem.Content = excelContent
 		excelItem.ExtraConfig = extraConfig
 		excelItem.UpdateUserId = sysUser.AdminId
 		excelItem.UpdateUserRealName = sysUser.RealName
 		excelItem.ModifyTime = time.Now()
-		updateCols := []string{"ExcelName", "ExcelClassifyId", "ExtraConfig", "UpdateUserId", "UpdateUserRealName", "ModifyTime"}
+		updateCols := []string{"ExcelName", "ExcelClassifyId", "ExtraConfig", "Content", "UpdateUserId", "UpdateUserRealName", "ModifyTime"}
 		if e = excelItem.Update(updateCols); e != nil {
 			br.Msg = "操作失败"
 			br.ErrMsg = fmt.Sprintf("更新表格信息失败, %v", e)
@@ -246,20 +263,23 @@ func (this *TradeAnalysisCorrelationController) Detail() {
 		br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
 		return
 	}
-	// 校验配置
-	pass, tips := tradeAnalysisService.CheckAnalysisCorrelationExtraConfig(tableConfig)
-	if !pass {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("表格配置有误, Msg: %s", tips)
-		return
-	}
 
 	// 根据配置获取表格行数据
-	tableRows, e := tradeAnalysisService.GetCorrelationTableRowsDataByConfig(tableConfig)
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
-		return
+	tableRows := make([]*tradeAnalysisModel.CorrelationTableData, 0)
+	if excelItem.Content != "" {
+		if e = json.Unmarshal([]byte(excelItem.Content), &tableRows); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+	} else {
+		// 根据配置获取表格行数据
+		tableRows, e = tradeAnalysisService.GetCorrelationTableRowsDataByConfig(tableConfig)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+			return
+		}
 	}
 
 	// 响应
@@ -338,6 +358,7 @@ func (this *TradeAnalysisCorrelationController) SaveAs() {
 		ExcelClassifyId:    req.ClassifyId,
 		SysUserId:          sysUser.AdminId,
 		SysUserRealName:    sysUser.RealName,
+		Content:            excelItem.Content,
 		ExtraConfig:        excelItem.ExtraConfig,
 		UpdateUserId:       sysUser.AdminId,
 		UpdateUserRealName: sysUser.RealName,
@@ -390,8 +411,20 @@ func (this *TradeAnalysisCorrelationController) Refresh() {
 		return
 	}
 
+	cacheKey := fmt.Sprintf("%s_%d", utils.CACHE_EXCEL_REFRESH, req.ExcelInfoId)
+	if utils.Rc.IsExist(cacheKey) {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "系统处理中,请勿频繁操作"
+		return
+	}
+	utils.Rc.SetNX(cacheKey, 1, 2*time.Minute)
+	defer func() {
+		_ = utils.Rc.Delete(cacheKey)
+	}()
+
 	// 获取表格信息
-	_, e := excel.GetExcelInfoById(req.ExcelInfoId)
+	item, e := excel.GetExcelInfoById(req.ExcelInfoId)
 	if e != nil {
 		if e.Error() == utils.ErrNoRow() {
 			br.Msg = "表格不存在, 请刷新页面"
@@ -402,7 +435,39 @@ func (this *TradeAnalysisCorrelationController) Refresh() {
 		return
 	}
 
-	// TODO:刷个啥呢...
+	// 获取表格内容
+	var tableConfig tradeAnalysisModel.CorrelationTableExtraConfig
+	if item.ExtraConfig == "" {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格配置为空, ExcelId: %d", item.ExcelInfoId)
+		return
+	}
+	if e = json.Unmarshal([]byte(item.ExtraConfig), &tableConfig); e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格配置解析失败, ExcelId: %d, Err: %v", item.ExcelInfoId, e)
+		return
+	}
+	tableData, e := tradeAnalysisService.GetCorrelationTableRowsDataByConfig(tableConfig)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("获取表格数据失败, %v", e)
+		return
+	}
+	content, e := json.Marshal(tableData)
+	if e != nil {
+		br.Msg = "表格数据JSON格式化失败"
+		br.ErrMsg = fmt.Sprintf("表格数据JSON格式化失败, %v", e)
+		return
+	}
+	item.Content = string(content)
+
+	// 更新内容
+	updateCols := []string{"Content", "ModifyTime"}
+	if e = item.Update(updateCols); e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("更新表格数据失败, %v", e)
+		return
+	}
 
 	br.Ret = 200
 	br.Success = true
@@ -513,17 +578,27 @@ func (this *TradeAnalysisCorrelationController) Download() {
 	}
 
 	// 根据配置获取表格行数据
-	var tableConfig tradeAnalysisModel.CorrelationTableExtraConfig
-	if e = json.Unmarshal([]byte(excelItem.ExtraConfig), &tableConfig); e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
-		return
-	}
-	tableRows, e := tradeAnalysisService.GetCorrelationTableRowsDataByConfig(tableConfig)
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
-		return
+	tableRows := make([]*tradeAnalysisModel.CorrelationTableData, 0)
+	if excelItem.Content != "" {
+		if e = json.Unmarshal([]byte(excelItem.Content), &tableRows); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+	} else {
+		// 根据配置获取表格行数据
+		var tableConfig tradeAnalysisModel.CorrelationTableExtraConfig
+		if e = json.Unmarshal([]byte(excelItem.ExtraConfig), &tableConfig); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+		tableRows, e = tradeAnalysisService.GetCorrelationTableRowsDataByConfig(tableConfig)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+			return
+		}
 	}
 
 	// 生成excel

+ 102 - 27
controllers/trade_analysis/trade_analysis_table.go

@@ -151,6 +151,21 @@ func (this *TradeAnalysisTableController) Save() {
 	}
 	extraConfig := string(configByte)
 
+	// 表格数据
+	tableRows, e := tradeAnalysisService.GetTableRowsDataByConfig(req.TableConfig)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+		return
+	}
+	contentByte, e := json.Marshal(tableRows)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格数据JSON格式化失败, %v", e)
+		return
+	}
+	excelContent := string(contentByte)
+
 	// 新增表格
 	var excelId int
 	if req.ExcelInfoId <= 0 {
@@ -163,6 +178,7 @@ func (this *TradeAnalysisTableController) Save() {
 			ExcelClassifyId:    req.ClassifyId,
 			SysUserId:          sysUser.AdminId,
 			SysUserRealName:    sysUser.RealName,
+			Content:            excelContent,
 			ExtraConfig:        extraConfig,
 			UpdateUserId:       sysUser.AdminId,
 			UpdateUserRealName: sysUser.RealName,
@@ -191,11 +207,12 @@ func (this *TradeAnalysisTableController) Save() {
 		}
 		excelItem.ExcelName = req.TableName
 		excelItem.ExcelClassifyId = req.ClassifyId
+		excelItem.Content = excelContent
 		excelItem.ExtraConfig = extraConfig
 		excelItem.UpdateUserId = sysUser.AdminId
 		excelItem.UpdateUserRealName = sysUser.RealName
 		excelItem.ModifyTime = time.Now()
-		updateCols := []string{"ExcelName", "ExcelClassifyId", "ExtraConfig", "UpdateUserId", "UpdateUserRealName", "ModifyTime"}
+		updateCols := []string{"ExcelName", "ExcelClassifyId", "ExtraConfig", "Content", "UpdateUserId", "UpdateUserRealName", "ModifyTime"}
 		if e = excelItem.Update(updateCols); e != nil {
 			br.Msg = "操作失败"
 			br.ErrMsg = fmt.Sprintf("更新表格信息失败, %v", e)
@@ -319,20 +336,23 @@ func (this *TradeAnalysisTableController) Detail() {
 		br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
 		return
 	}
-	// 校验配置
-	pass, tips := tradeAnalysisService.CheckAnalysisTableExtraConfig(tableConfig)
-	if !pass {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("表格配置有误, Msg: %s", tips)
-		return
-	}
 
-	// 根据配置获取表格行数据
-	tableRows, e := tradeAnalysisService.GetTableRowsDataByConfig(tableConfig)
-	if e != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
-		return
+	// 表格数据
+	tableRows := make([]*tradeAnalysisModel.TableRowData, 0)
+	if excelItem.Content != "" {
+		if e = json.Unmarshal([]byte(excelItem.Content), &tableRows); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+	} else {
+		// 根据配置获取表格行数据
+		tableRows, e = tradeAnalysisService.GetTableRowsDataByConfig(tableConfig)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+			return
+		}
 	}
 
 	// 响应
@@ -438,6 +458,7 @@ func (this *TradeAnalysisTableController) SaveAs() {
 		ExcelClassifyId:    req.ClassifyId,
 		SysUserId:          sysUser.AdminId,
 		SysUserRealName:    sysUser.RealName,
+		Content:            excelItem.Content,
 		ExtraConfig:        excelItem.ExtraConfig,
 		UpdateUserId:       sysUser.AdminId,
 		UpdateUserRealName: sysUser.RealName,
@@ -535,8 +556,20 @@ func (this *TradeAnalysisTableController) Refresh() {
 		return
 	}
 
+	cacheKey := fmt.Sprintf("%s_%d", utils.CACHE_EXCEL_REFRESH, req.ExcelInfoId)
+	if utils.Rc.IsExist(cacheKey) {
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "系统处理中,请勿频繁操作"
+		return
+	}
+	utils.Rc.SetNX(cacheKey, 1, 2*time.Minute)
+	defer func() {
+		_ = utils.Rc.Delete(cacheKey)
+	}()
+
 	// 获取表格信息
-	_, e := excel.GetExcelInfoById(req.ExcelInfoId)
+	item, e := excel.GetExcelInfoById(req.ExcelInfoId)
 	if e != nil {
 		if e.Error() == utils.ErrNoRow() {
 			br.Msg = "表格不存在, 请刷新页面"
@@ -547,7 +580,39 @@ func (this *TradeAnalysisTableController) Refresh() {
 		return
 	}
 
-	// TODO:刷个啥呢...
+	// 获取表格内容
+	var tableConfig tradeAnalysisModel.TableExtraConfig
+	if item.ExtraConfig == "" {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格配置为空, ExcelId: %d", item.ExcelInfoId)
+		return
+	}
+	if e = json.Unmarshal([]byte(item.ExtraConfig), &tableConfig); e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("表格配置解析失败, ExcelId: %d, Err: %v", item.ExcelInfoId, e)
+		return
+	}
+	tableData, e := tradeAnalysisService.GetTableRowsDataByConfig(tableConfig)
+	if e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+		return
+	}
+	content, e := json.Marshal(tableData)
+	if e != nil {
+		br.Msg = "表格数据JSON格式化失败"
+		br.ErrMsg = fmt.Sprintf("表格数据JSON格式化失败, %v", e)
+		return
+	}
+	item.Content = string(content)
+
+	// 更新内容
+	updateCols := []string{"Content", "ModifyTime"}
+	if e = item.Update(updateCols); e != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = fmt.Sprintf("更新表格数据失败, %v", e)
+		return
+	}
 
 	br.Ret = 200
 	br.Success = true
@@ -688,18 +753,28 @@ func (this *TradeAnalysisTableController) Download() {
 		return
 	}
 
-	// 根据配置获取表格行数据
+	// 表格数据
+	tableRows := make([]*tradeAnalysisModel.TableRowData, 0)
 	var tableConfig tradeAnalysisModel.TableExtraConfig
-	if e = json.Unmarshal([]byte(excelItem.ExtraConfig), &tableConfig); e != nil {
-		br.Msg = "下载失败"
-		br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
-		return
-	}
-	tableRows, e := tradeAnalysisService.GetTableRowsDataByConfig(tableConfig)
-	if e != nil {
-		br.Msg = "下载失败"
-		br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
-		return
+	if excelItem.Content != "" {
+		if e = json.Unmarshal([]byte(excelItem.Content), &tableRows); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+	} else {
+		// 根据配置获取表格行数据
+		if e = json.Unmarshal([]byte(excelItem.ExtraConfig), &tableConfig); e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("解析表格配置失败, err: %v, config: %s", e, excelItem.ExtraConfig)
+			return
+		}
+		tableRows, e = tradeAnalysisService.GetTableRowsDataByConfig(tableConfig)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = fmt.Sprintf("获取表格行数据失败, %v", e)
+			return
+		}
 	}
 
 	// 生成excel

+ 5 - 366
models/data_manage/trade_analysis/trade_analysis.go

@@ -21,11 +21,11 @@ const (
 	WarehouseDefaultFrequency = "日度"
 
 	GuangZhouTopCompanyAliasName = "日成交持仓排名" // 广期所TOP20对应的公司名称
-	GuangZhouSeatNameBuy         = "持买单量"    // 广期所指标名称中的多单名称
-	GuangZhouSeatNameSold        = "持卖单量"    // 广期所指标名称中的空单名称
-	GuangZhouTopSeatNameBuy      = "持买单量总计"  // 广期所指标名称中的TOP20多单名称
-	GuangZhouTopSeatNameSold     = "持卖单量总计"  // 广期所指标名称中的TOP20空单名称
-	GuangZhouTopSeatNameDeal     = "成交量总计"   // 广期所指标名称中的TOP20成交量名称
+	GuangZhouSeatNameBuy         = "持买单量"       // 广期所指标名称中的多单名称
+	GuangZhouSeatNameSold        = "持卖单量"       // 广期所指标名称中的空单名称
+	GuangZhouTopSeatNameBuy      = "持买单量总计"   // 广期所指标名称中的TOP20多单名称
+	GuangZhouTopSeatNameSold     = "持卖单量总计"   // 广期所指标名称中的TOP20空单名称
+	GuangZhouTopSeatNameDeal     = "成交量总计"     // 广期所指标名称中的TOP20成交量名称
 )
 
 const (
@@ -231,99 +231,6 @@ type OriginTradeData struct {
 	ValType      int       `description:"数据类型: 1-多单; 2-空单"`
 }
 
-// GetTradeDataByClassifyAndCompany 根据品种和公司名称获取持仓数据
-//func GetTradeDataByClassifyAndCompany(exchange string, classifyNames, contracts, companies []string, startDate, endDate time.Time) (items []*OriginTradeData, err error) {
-//	if exchange == "" {
-//		err = fmt.Errorf("数据表名称有误")
-//		return
-//	}
-//	if len(contracts) == 0 || len(classifyNames) == 0 || len(companies) == 0 {
-//		return
-//	}
-//	condBuy := fmt.Sprintf(`classify_name IN (%s) AND classify_type IN (%s)`, utils.GetOrmInReplace(len(classifyNames)), utils.GetOrmInReplace(len(contracts)))
-//	parsBuy := make([]interface{}, 0)
-//	parsBuy = append(parsBuy, classifyNames, contracts)
-//
-//	condSold := fmt.Sprintf(`classify_name IN (%s) AND classify_type IN (%s)`, utils.GetOrmInReplace(len(classifyNames)), utils.GetOrmInReplace(len(contracts)))
-//	parsSold := make([]interface{}, 0)
-//	parsSold = append(parsSold, classifyNames, contracts)
-//
-//	if !startDate.IsZero() && !endDate.IsZero() {
-//		st := startDate.Format(utils.FormatDate)
-//		ed := endDate.Format(utils.FormatDate)
-//		condBuy += fmt.Sprintf(` AND (data_time BETWEEN ? AND ?)`)
-//		parsBuy = append(parsBuy, st, ed)
-//		condSold += fmt.Sprintf(` AND (data_time BETWEEN ? AND ?)`)
-//		parsSold = append(parsSold, st, ed)
-//	}
-//
-//	// 是否含有TOP20
-//	var hasTop bool
-//	var condCompanies []string
-//	for _, v := range companies {
-//		if v == TradeFuturesCompanyTop20 {
-//			hasTop = true
-//			continue
-//		}
-//		condCompanies = append(condCompanies, v)
-//	}
-//	if !hasTop {
-//		if len(condCompanies) == 0 {
-//			err = fmt.Errorf("查询条件-期货公司异常")
-//			return
-//		}
-//		condBuy += fmt.Sprintf(` AND buy_short_name IN (%s)`, utils.GetOrmInReplace(len(condCompanies)))
-//		parsBuy = append(parsBuy, condCompanies)
-//		condSold += fmt.Sprintf(` AND sold_short_name IN (%s)`, utils.GetOrmInReplace(len(condCompanies)))
-//		parsSold = append(parsSold, condCompanies)
-//	} else {
-//		if len(condCompanies) > 0 {
-//			condBuy += fmt.Sprintf(` AND (rank = 999 OR buy_short_name IN (%s))`, utils.GetOrmInReplace(len(condCompanies)))
-//			condSold += fmt.Sprintf(` AND (rank = 999 OR sold_short_name IN (%s))`, utils.GetOrmInReplace(len(condCompanies)))
-//			parsBuy = append(parsBuy, condCompanies)
-//			parsSold = append(parsSold, condCompanies)
-//		} else {
-//			condBuy += ` AND rank = 999`
-//			condSold += ` AND rank = 999`
-//		}
-//	}
-//
-//	tableName := fmt.Sprintf("base_from_trade_%s_index", exchange)
-//	sql := `SELECT
-//			rank,
-//			buy_short_name AS company_name,
-//			buy_value AS val,
-//			buy_change AS val_change,
-//			classify_name,
-//			classify_type,
-//			data_time,
-//			1 AS val_type
-//		FROM
-//			%s
-//		WHERE
-//			%s
-//		UNION ALL
-//		(
-//		SELECT
-//			rank,
-//			sold_short_name,
-//			sold_value,
-//			sold_change,
-//			classify_name,
-//			classify_type,
-//			data_time,
-//			2 AS val_type
-//		FROM
-//			%s
-//		WHERE
-//			%s
-//		)`
-//	sql = fmt.Sprintf(sql, tableName, condBuy, tableName, condSold)
-//	o := orm.NewOrmUsingDB("data")
-//	_, err = o.Raw(sql, parsBuy, parsSold).QueryRows(&items)
-//	return
-//}
-
 // BaseFromTradeCommonIndex 郑商所/大商所/上期所/上期能源指标表通用字段
 type BaseFromTradeCommonIndex struct {
 	Rank          int       `description:"排名"`
@@ -396,88 +303,6 @@ func GetZhengzhouTradeDataByContracts(classifyNames []string, startDate, endDate
 	return
 }
 
-// GetTradeZhengzhouDataByClassifyAndCompany 郑商所-根据品种和公司名称获取持仓数据
-//func GetTradeZhengzhouDataByClassifyAndCompany(exchange string, contracts, companies []string) (items []*OriginTradeData, err error) {
-//	if exchange == "" {
-//		err = fmt.Errorf("数据表名称有误")
-//		return
-//	}
-//	if len(contracts) == 0 || len(companies) == 0 {
-//		return
-//	}
-//	condBuy := fmt.Sprintf(`classify_name IN (%s)`, utils.GetOrmInReplace(len(contracts)))
-//	parsBuy := make([]interface{}, 0)
-//	parsBuy = append(parsBuy, contracts)
-//
-//	condSold := fmt.Sprintf(`classify_name IN (%s)`, utils.GetOrmInReplace(len(contracts)))
-//	parsSold := make([]interface{}, 0)
-//	parsSold = append(parsSold, contracts)
-//
-//	// 是否含有TOP20
-//	var hasTop bool
-//	var condCompanies []string
-//	for _, v := range companies {
-//		if v == TradeFuturesCompanyTop20 {
-//			hasTop = true
-//			continue
-//		}
-//		condCompanies = append(condCompanies, v)
-//	}
-//	if !hasTop {
-//		if len(condCompanies) == 0 {
-//			err = fmt.Errorf("查询条件-期货公司异常")
-//			return
-//		}
-//		condBuy += fmt.Sprintf(` AND buy_short_name IN (%s)`, utils.GetOrmInReplace(len(condCompanies)))
-//		parsBuy = append(parsBuy, condCompanies)
-//		condSold += fmt.Sprintf(` AND sold_short_name IN (%s)`, utils.GetOrmInReplace(len(condCompanies)))
-//		parsSold = append(parsSold, condCompanies)
-//	} else {
-//		if len(condCompanies) > 0 {
-//			condBuy += fmt.Sprintf(` AND (rank = 999 OR buy_short_name IN (%s))`, utils.GetOrmInReplace(len(condCompanies)))
-//			condSold += fmt.Sprintf(` AND (rank = 999 OR sold_short_name IN (%s))`, utils.GetOrmInReplace(len(condCompanies)))
-//			parsBuy = append(parsBuy, condCompanies)
-//			parsSold = append(parsSold, condCompanies)
-//		} else {
-//			condBuy += ` AND rank = 999`
-//			condSold += ` AND rank = 999`
-//		}
-//	}
-//
-//	tableName := fmt.Sprintf("base_from_trade_%s_index", exchange)
-//	sql := `SELECT
-//			rank,
-//			buy_short_name AS company_name,
-//			buy_value AS val,
-//			buy_change AS val_change,
-//			classify_name AS classify_type,
-//			data_time,
-//			1 AS val_type
-//		FROM
-//			%s
-//		WHERE
-//			%s
-//		UNION ALL
-//		(
-//		SELECT
-//			rank,
-//			sold_short_name,
-//			sold_value,
-//			sold_change,
-//			classify_name AS classify_type,
-//			data_time,
-//			2 AS val_type
-//		FROM
-//			%s
-//		WHERE
-//			%s
-//		)`
-//	sql = fmt.Sprintf(sql, tableName, condBuy, tableName, condSold)
-//	o := orm.NewOrmUsingDB("data")
-//	_, err = o.Raw(sql, parsBuy, parsSold).QueryRows(&items)
-//	return
-//}
-
 // ContractCompanyTradeData [合约-期货公司]持仓数据
 type ContractCompanyTradeData struct {
 	Exchange     string                          `description:"交易所"`
@@ -507,140 +332,6 @@ type ContractCompanyTradeDataList struct {
 	PureBuyChangeType int       `description:"净多单持仓增减类型: 0-无值; 1-原始值; 2-推算值"`
 }
 
-// GetLastTradeDataByClassify 获取[合约]末位多空单数据
-//func GetLastTradeDataByClassify(exchange string, classifyNames, contracts []string) (items []*OriginTradeData, err error) {
-//	if exchange == "" {
-//		err = fmt.Errorf("数据表名称有误")
-//		return
-//	}
-//	if len(classifyNames) == 0 || len(contracts) == 0 {
-//		return
-//	}
-//	classifyReplacer := utils.GetOrmInReplace(len(classifyNames))
-//	contractReplacer := utils.GetOrmInReplace(len(contracts))
-//
-//	tableName := fmt.Sprintf("base_from_trade_%s_index", exchange)
-//	sql := `SELECT
-//			tpt.rank,
-//			tpt.buy_short_name AS company_name,
-//			tpt.buy_value AS val,
-//			tpt.buy_change AS val_change,
-//			tpt.classify_name,
-//			tpt.classify_type,
-//			tpt.data_time,
-//			1 AS val_type
-//		FROM
-//			%s tpt
-//		JOIN
-//			(
-//				SELECT
-//					data_time, classify_type, MAX(rank) AS max_rank
-//				FROM
-//					%s
-//				WHERE
-//					classify_name IN (%s) AND classify_type IN (%s) AND buy_short_name <> ''
-//				GROUP BY
-//					data_time,
-//					classify_type
-//			) sub
-//		ON
-//			tpt.data_time = sub.data_time AND tpt.classify_type = sub.classify_type AND tpt.rank = sub.max_rank
-//		WHERE
-//			tpt.classify_name IN (%s) AND tpt.classify_type IN (%s)
-//		UNION ALL
-//		(
-//		SELECT
-//			tpt.rank, tpt.sold_short_name, tpt.sold_value, tpt.sold_change, tpt.classify_name, tpt.classify_type, tpt.data_time, 2 AS val_type
-//		FROM
-//			%s tpt
-//		JOIN
-//			(
-//				SELECT
-//					data_time, classify_type, MAX(rank) AS max_rank
-//				FROM
-//					%s
-//				WHERE
-//					classify_name IN (%s) AND classify_type IN (%s) AND sold_short_name <> ''
-//				GROUP BY
-//					data_time, classify_type
-//			) sub
-//		ON
-//			tpt.data_time = sub.data_time AND tpt.classify_type = sub.classify_type AND tpt.rank = sub.max_rank
-//		WHERE
-//			tpt.classify_name IN (%s) AND tpt.classify_type IN (%s)
-//		)`
-//	sql = fmt.Sprintf(sql, tableName, tableName, classifyReplacer, contractReplacer, classifyReplacer, contractReplacer, tableName, tableName, classifyReplacer, contractReplacer, classifyReplacer, contractReplacer)
-//	o := orm.NewOrmUsingDB("data")
-//	_, err = o.Raw(sql, classifyNames, contracts, classifyNames, contracts, classifyNames, contracts, classifyNames, contracts).QueryRows(&items)
-//	return
-//}
-
-// GetLastTradeZhengzhouDataByClassify 郑商所-获取[合约]末位多空单数据
-//func GetLastTradeZhengzhouDataByClassify(exchange string, contracts []string) (items []*OriginTradeData, err error) {
-//	if exchange == "" {
-//		err = fmt.Errorf("数据表名称有误")
-//		return
-//	}
-//	if len(contracts) == 0 {
-//		return
-//	}
-//	contractReplacer := utils.GetOrmInReplace(len(contracts))
-//
-//	tableName := fmt.Sprintf("base_from_trade_%s_index", exchange)
-//	sql := `SELECT
-//			tpt.rank,
-//			tpt.buy_short_name AS company_name,
-//			tpt.buy_value AS val,
-//			tpt.buy_change AS val_change,
-//  			tpt.classify_name AS classify_type,
-//			tpt.data_time,
-//			1 AS val_type
-//		FROM
-//			%s tpt
-//		JOIN
-//			(
-//				SELECT
-//					data_time, classify_name, MAX(rank) AS max_rank
-//				FROM
-//					%s
-//				WHERE
-//					classify_name IN (%s) AND buy_short_name <> ''
-//				GROUP BY
-//					data_time,
-//					classify_name
-//			) sub
-//		ON
-//			tpt.data_time = sub.data_time AND tpt.classify_name = sub.classify_name AND tpt.rank = sub.max_rank
-//		WHERE
-//			tpt.classify_name IN (%s)
-//		UNION ALL
-//		(
-//		SELECT
-//			tpt.rank, tpt.sold_short_name, tpt.sold_value, tpt.sold_change, tpt.classify_name AS classify_type, tpt.data_time, 2 AS val_type
-//		FROM
-//			%s tpt
-//		JOIN
-//			(
-//				SELECT
-//					data_time, classify_name, MAX(rank) AS max_rank
-//				FROM
-//					%s
-//				WHERE
-//					classify_name IN (%s) AND sold_short_name <> ''
-//				GROUP BY
-//					data_time, classify_name
-//			) sub
-//		ON
-//			tpt.data_time = sub.data_time AND tpt.classify_name = sub.classify_name AND tpt.rank = sub.max_rank
-//		WHERE
-//			tpt.classify_name IN (%s)
-//		)`
-//	sql = fmt.Sprintf(sql, tableName, tableName, contractReplacer, contractReplacer, tableName, tableName, contractReplacer, contractReplacer)
-//	o := orm.NewOrmUsingDB("data")
-//	_, err = o.Raw(sql, contracts, contracts, contracts, contracts).QueryRows(&items)
-//	return
-//}
-
 type BaseFromTradeGuangzhouIndex struct {
 	BaseFromTradeGuangzhouIndexId    int       `orm:"column(base_from_trade_guangzhou_index_id);pk"`
 	BaseFromTradeGuangzhouClassifyId int       `description:"分类id"`
@@ -654,20 +345,6 @@ type BaseFromTradeGuangzhouIndex struct {
 	ModifyTime                       time.Time `description:"修改日期"`
 }
 
-//func GetBaseFromTradeGuangzhouIndexByClassifyId(classifyId int, contractIds []int) (list []*BaseFromTradeGuangzhouIndex, err error) {
-//	o := orm.NewOrmUsingDB("data")
-//	cond := ` base_from_trade_guangzhou_classify_id = ?`
-//	pars := make([]interface{}, 0)
-//	pars = append(pars, classifyId)
-//	if len(contractIds) > 0 {
-//		cond += fmt.Sprintf(` AND base_from_trade_guangzhou_contract_id IN (%s)`, utils.GetOrmInReplace(len(contractIds)))
-//		pars = append(pars, contractIds)
-//	}
-//	sql := fmt.Sprintf(`SELECT * FROM base_from_trade_guangzhou_index WHERE 1=1 %s `, cond)
-//	_, err = o.Raw(sql, pars).QueryRows(&list)
-//	return
-//}
-
 func GetBaseFromTradeGuangzhouIndex(classifyIds []int, contracts []string, indexKeyword string) (list []*BaseFromTradeGuangzhouIndex, err error) {
 	o := orm.NewOrmUsingDB("data")
 	cond := ``
@@ -726,38 +403,6 @@ func GetBaseFromTradeGuangzhouDataByIndexIds(indexIds []int, startDate, endDate
 	return
 }
 
-// GetBaseFromTradeGuangzhouMinDataByIndexIds 获取指标中的末位数据
-//func GetBaseFromTradeGuangzhouMinDataByIndexIds(indexIds []int) (list []*BaseFromTradeGuangzhouData, err error) {
-//	indexLen := len(indexIds)
-//	if indexLen == 0 {
-//		return
-//	}
-//	o := orm.NewOrmUsingDB("data")
-//	sql := fmt.Sprintf(`SELECT
-//			t1.data_time,
-//			t1.min_value AS value
-//		FROM
-//			(
-//				SELECT
-//					data_time,
-//					MIN(value) AS min_value
-//				FROM
-//					base_from_trade_guangzhou_data
-//				WHERE
-//					base_from_trade_guangzhou_index_id IN (%s)
-//				GROUP BY
-//					data_time
-//			) t1
-//		JOIN
-//			base_from_trade_guangzhou_data t2
-//		ON
-//			t1.data_time = t2.data_time AND t1.min_value = t2.value AND t2.base_from_trade_guangzhou_index_id IN (%s)
-//		GROUP BY
-//			t1.data_time`, utils.GetOrmInReplace(indexLen), utils.GetOrmInReplace(indexLen))
-//	_, err = o.Raw(sql, indexIds, indexIds).QueryRows(&list)
-//	return
-//}
-
 // ContractTopRankData TOP20合约排名数据
 type ContractTopRankData struct {
 	Exchange      string    `description:"交易所"`
@@ -823,9 +468,3 @@ type ContractCompanyTradeEdbData struct {
 	DataTime time.Time `description:"数据日期"`
 	Val      int       `description:"数据值"`
 }
-
-// ContractCompanyTradeEdbData [合约-期货公司]指标数据
-//type ContractCompanyTradeEdbData struct {
-//	DataTime time.Time `description:"数据日期"`
-//	Val      int       `description:"数据值"`
-//}

+ 2 - 15
services/data/trade_analysis/trade_analysis_correlation.go

@@ -3,7 +3,6 @@ package trade_analysis
 import (
 	"eta/eta_api/models/data_manage"
 	tradeAnalysisModel "eta/eta_api/models/data_manage/trade_analysis"
-	"eta/eta_api/services/data"
 	"eta/eta_api/utils"
 	"fmt"
 	"time"
@@ -74,15 +73,7 @@ func GetCorrelationTableRowsDataByConfig(tableConfig tradeAnalysisModel.Correlat
 			return
 		}
 		baseEdbData := make([]*data_manage.EdbDataList, 0)
-		switch baseEdb.EdbInfoCategoryType {
-		case 0:
-			baseEdbData, e = data_manage.GetEdbDataList(baseEdb.Source, baseEdb.SubSource, baseEdb.EdbInfoId, "", "")
-		case 1:
-			_, baseEdbData, _, _, e, _ = data.GetPredictDataListByPredictEdbInfoId(baseEdb.EdbInfoId, "", "", false)
-		default:
-			err = fmt.Errorf("标的指标类型异常: %d", baseEdb.EdbInfoCategoryType)
-			return
-		}
+		baseEdbData, e = data_manage.GetEdbDataList(baseEdb.Source, baseEdb.SubSource, baseEdb.EdbInfoId, "", "")
 		if e != nil {
 			err = fmt.Errorf("获取标的指标数据失败, %v", e)
 			return
@@ -94,18 +85,16 @@ func GetCorrelationTableRowsDataByConfig(tableConfig tradeAnalysisModel.Correlat
 			}
 			baseDateData[t] = v.Value
 		}
-		//fmt.Println(baseDateData)
 	}
 
 	// 根据配置取出需要查询的合约
 	baseDate := time.Now() // 取合约以当日为基准(如主力合约为当日的主力合约)
-	//baseDate = time.Date(2024, 8, 12, 0, 0, 0, 0, time.Local) // TODO:测试数据
+	//baseDate = time.Date(2024, 8, 12, 0, 0, 0, 0, time.Local)
 	contracts, e := GetTopContractsByType(tableConfig.ContractType, tableConfig.Exchange, tableConfig.ClassifyName, baseDate)
 	if e != nil {
 		err = fmt.Errorf("获取持仓相关性合约失败, %v", e)
 		return
 	}
-	//fmt.Println(contracts)
 
 	// [合约+期货公司]持仓数据
 	tradeData, e := GetCorrelationTableTradeData(tableConfig.Exchange, []string{tableConfig.ClassifyName}, contracts, tableConfig.CompanyNames, tableConfig.PredictRatio)
@@ -113,7 +102,6 @@ func GetCorrelationTableRowsDataByConfig(tableConfig tradeAnalysisModel.Correlat
 		err = fmt.Errorf("获取[合约+期货公司]持仓数据失败, %v", e)
 		return
 	}
-	//fmt.Println(tradeData)
 
 	// 持仓数据转为指标
 	tradeEdbList, tradeEdbDataMap, e := TransTradeData2EdbData(tradeData, tableConfig.ContractPosition)
@@ -121,7 +109,6 @@ func GetCorrelationTableRowsDataByConfig(tableConfig tradeAnalysisModel.Correlat
 		err = fmt.Errorf("[合约+期货公司]持仓数据转为指标失败, %v", e)
 		return
 	}
-	//fmt.Println(tradeEdbList)
 
 	// 遍历相关性配置(目前最多有两个滚动相关性), 遍历指标, 分别计算滚动相关性
 	maxPre := 10 // 需要展示的以标的指标日期为准往前推N个交易日的滚动相关性

+ 0 - 425
services/data/trade_analysis/trade_analysis_data.go

@@ -145,146 +145,6 @@ func FormatCompanyTradeData2EdbMappings(companyTradeData []*tradeAnalysisModel.C
 }
 
 func GetWarehouseTradeData(exchange, classifyName string, contracts, companies []string, predictRatio float64) (companyTradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
-	// 各原始数据表期货公司名称不一致
-	//companyMap := make(map[string]string)
-	//{
-	//	ob := new(tradeAnalysisModel.TradeFuturesCompany)
-	//	list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
-	//	if e != nil {
-	//		err = fmt.Errorf("获取期货公司名称失败: %v", e)
-	//		return
-	//	}
-	//	switch exchange {
-	//	case "zhengzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ZhengzhouName
-	//		}
-	//	case "dalian":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.DalianName
-	//		}
-	//	case "shanghai":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ShanghaiName
-	//		}
-	//	case "cffex":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.CffexName
-	//		}
-	//	case "ine":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.IneName
-	//		}
-	//	case "guangzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.GuangzhouName
-	//		}
-	//	}
-	//}
-	//var queryCompanies []string
-	//for _, v := range companies {
-	//	if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
-	//		queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
-	//		continue
-	//	}
-	//	companyName, ok := companyMap[v]
-	//	if !ok {
-	//		utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
-	//		continue
-	//	}
-	//	queryCompanies = append(queryCompanies, companyName)
-	//}
-	//
-	//// 郑商所/广期所查询方式不一样
-	//var tradeAnalysis TradeAnalysisInterface
-	//switch exchange {
-	//case tradeAnalysisModel.TradeExchangeZhengzhou:
-	//	tradeAnalysis = &ZhengzhouTradeAnalysis{}
-	//case tradeAnalysisModel.TradeExchangeGuangzhou:
-	//	tradeAnalysis = &GuangzhouTradeAnalysis{}
-	//default:
-	//	tradeAnalysis = &BaseTradeAnalysis{}
-	//}
-	//
-	//// 获取多单/空单原始数据
-	////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, []string{classifyName}, contracts, queryCompanies, time.Time{}, time.Time{})
-	////if e != nil {
-	////	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	////	return
-	////}
-	//originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, []string{classifyName}, contracts, queryCompanies, time.Time{}, time.Time{})
-	//if e != nil {
-	//	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	//	return
-	//}
-	//
-	//keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
-	//keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
-	//keyDateDataExist := make(map[string]bool)
-	//for _, v := range originList {
-	//	// Rank999-对应的是TOP20
-	//	companyName := v.CompanyName
-	//	//if v.Rank == 999 {
-	//	//	companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
-	//	//}
-	//
-	//	k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
-	//	if keyItems[k] == nil {
-	//		keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
-	//		keyItems[k].CompanyName = companyName
-	//		keyItems[k].ClassifyType = v.ClassifyType
-	//		keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
-	//	}
-	//
-	//	kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
-	//	if keyDateData[kd] == nil {
-	//		keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
-	//		keyDateData[kd].Date = v.DataTime
-	//	}
-	//	if v.ValType == 1 {
-	//		keyDateData[kd].BuyVal = v.Val
-	//		keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		keyDateData[kd].BuyChange = v.ValChange
-	//		keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//	}
-	//	if v.ValType == 2 {
-	//		keyDateData[kd].SoldVal = v.Val
-	//		keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		keyDateData[kd].SoldChange = v.ValChange
-	//		keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//	}
-	//	if !keyDateDataExist[kd] {
-	//		keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
-	//		keyDateDataExist[kd] = true
-	//	}
-	//}
-	//
-	//// 获取[合约]每日的末位多空单
-	//contractLastBuyDateVal := make(map[string]map[time.Time]int)
-	//contractLastSoldDateVal := make(map[string]map[time.Time]int)
-	//{
-	//	//lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, []string{classifyName}, contracts)
-	//	//if e != nil {
-	//	//	err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
-	//	//	return
-	//	//}
-	//	for _, v := range lastOriginList {
-	//		if v.ValType == 1 {
-	//			if contractLastBuyDateVal[v.ClassifyType] == nil {
-	//				contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//			}
-	//			contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//			continue
-	//		}
-	//		if contractLastSoldDateVal[v.ClassifyType] == nil {
-	//			contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//		}
-	//		contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//	}
-	//}
-
-	//func GetContractCompanyTradeData(exchange string, classifyNames, contracts, companies []string, startDate, endDate time.Time) (contractTradeData map[string]*tradeAnalysisModel.ContractCompanyTradeData, lastBuyVal, lastSoldVal map[string]map[time.Time]int, err error)
-
 	// 获取合约持仓数据
 	contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, []string{classifyName}, contracts, companies, time.Time{}, time.Time{})
 	if e != nil {
@@ -698,144 +558,6 @@ func GetTopContractRank(exchange string, classifyNames []string, dataDate time.T
 
 // GetTableTradeData 获取多空分析表格持仓数据
 func GetTableTradeData(exchange string, classifyNames, contracts, companies []string, predictRatio float64, startDate, endDate time.Time, contractType int) (companyTradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
-	// 各原始数据表期货公司名称不一致
-	//companyMap := make(map[string]string)
-	//{
-	//	ob := new(tradeAnalysisModel.TradeFuturesCompany)
-	//	list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
-	//	if e != nil {
-	//		err = fmt.Errorf("获取期货公司名称失败: %v", e)
-	//		return
-	//	}
-	//	switch exchange {
-	//	case "zhengzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ZhengzhouName
-	//		}
-	//	case "dalian":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.DalianName
-	//		}
-	//	case "shanghai":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ShanghaiName
-	//		}
-	//	case "cffex":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.CffexName
-	//		}
-	//	case "ine":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.IneName
-	//		}
-	//	case "guangzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.GuangzhouName
-	//		}
-	//	}
-	//}
-	//var queryCompanies []string
-	//for _, v := range companies {
-	//	if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
-	//		queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
-	//		continue
-	//	}
-	//	companyName, ok := companyMap[v]
-	//	if !ok {
-	//		utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
-	//		continue
-	//	}
-	//	queryCompanies = append(queryCompanies, companyName)
-	//}
-	//
-	//// 郑商所/广期所查询方式不一样
-	//var tradeAnalysis TradeAnalysisInterface
-	//switch exchange {
-	//case tradeAnalysisModel.TradeExchangeZhengzhou:
-	//	tradeAnalysis = &ZhengzhouTradeAnalysis{}
-	//case tradeAnalysisModel.TradeExchangeGuangzhou:
-	//	tradeAnalysis = &GuangzhouTradeAnalysis{}
-	//default:
-	//	tradeAnalysis = &BaseTradeAnalysis{}
-	//}
-	//
-	//// 获取多单/空单原始数据, 取基准时间前后五天的数据, 填充数据后, 取出基准日期作为结果
-	////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, classifyNames, contracts, queryCompanies, baseDate.AddDate(0, 0, -5), baseDate.AddDate(0, 0, 5))
-	////if e != nil {
-	////	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	////	return
-	////}
-	//originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, classifyNames, contracts, queryCompanies, baseDate.AddDate(0, 0, -5), baseDate.AddDate(0, 0, 5))
-	//if e != nil {
-	//	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	//	return
-	//}
-	//
-	//keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
-	//keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
-	//keyDateDataExist := make(map[string]bool)
-	//for _, v := range originList {
-	//	// Rank999-对应的是TOP20
-	//	companyName := v.CompanyName
-	//	//if v.Rank == 999 {
-	//	//	companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
-	//	//}
-	//
-	//	k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
-	//	if keyItems[k] == nil {
-	//		keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
-	//		keyItems[k].CompanyName = companyName
-	//		keyItems[k].ClassifyType = v.ClassifyType
-	//		keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
-	//	}
-	//
-	//	kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
-	//	if keyDateData[kd] == nil {
-	//		keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
-	//		keyDateData[kd].Date = v.DataTime
-	//	}
-	//	if v.ValType == 1 {
-	//		keyDateData[kd].BuyVal = v.Val
-	//		keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		keyDateData[kd].BuyChange = v.ValChange
-	//		keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//	}
-	//	if v.ValType == 2 {
-	//		keyDateData[kd].SoldVal = v.Val
-	//		keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		keyDateData[kd].SoldChange = v.ValChange
-	//		keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//	}
-	//	if !keyDateDataExist[kd] {
-	//		keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
-	//		keyDateDataExist[kd] = true
-	//	}
-	//}
-	//
-	//// 获取[合约]每日的末位多空单
-	//contractLastBuyDateVal := make(map[string]map[time.Time]int)
-	//contractLastSoldDateVal := make(map[string]map[time.Time]int)
-	//{
-	//	//lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, classifyNames, contracts)
-	//	//if e != nil {
-	//	//	err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
-	//	//	return
-	//	//}
-	//	for _, v := range lastOriginList {
-	//		if v.ValType == 1 {
-	//			if contractLastBuyDateVal[v.ClassifyType] == nil {
-	//				contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//			}
-	//			contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//			continue
-	//		}
-	//		if contractLastSoldDateVal[v.ClassifyType] == nil {
-	//			contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//		}
-	//		contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//	}
-	//}
-
 	// 获取合约持仓数据
 	contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, classifyNames, contracts, companies, startDate, endDate)
 	if e != nil {
@@ -950,149 +672,6 @@ func GetTableTradeData(exchange string, classifyNames, contracts, companies []st
 
 // GetCorrelationTableTradeData 获取相关性表格持仓数据
 func GetCorrelationTableTradeData(exchange string, classifyNames, contracts, companies []string, predictRatio float64) (tradeData []*tradeAnalysisModel.ContractCompanyTradeData, err error) {
-	// 各原始数据表期货公司名称不一致
-	//companyMap := make(map[string]string)
-	//{
-	//	ob := new(tradeAnalysisModel.TradeFuturesCompany)
-	//	list, e := ob.GetItemsByCondition(``, make([]interface{}, 0), []string{}, "")
-	//	if e != nil {
-	//		err = fmt.Errorf("获取期货公司名称失败: %v", e)
-	//		return
-	//	}
-	//	switch exchange {
-	//	case "zhengzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ZhengzhouName
-	//		}
-	//	case "dalian":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.DalianName
-	//		}
-	//	case "shanghai":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.ShanghaiName
-	//		}
-	//	case "cffex":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.CffexName
-	//		}
-	//	case "ine":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.IneName
-	//		}
-	//	case "guangzhou":
-	//		for _, v := range list {
-	//			companyMap[v.CompanyName] = v.GuangzhouName
-	//		}
-	//	}
-	//}
-	//var queryCompanies []string
-	//for _, v := range companies {
-	//	if v == tradeAnalysisModel.TradeFuturesCompanyTop20 {
-	//		queryCompanies = append(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20)
-	//		continue
-	//	}
-	//	companyName, ok := companyMap[v]
-	//	if !ok {
-	//		utils.FileLog.Info(fmt.Sprintf("交易所%s公司名称映射不存在: %s", exchange, v))
-	//		continue
-	//	}
-	//	queryCompanies = append(queryCompanies, companyName)
-	//}
-	//
-	//// 郑商所/广期所查询方式不一样
-	//var tradeAnalysis TradeAnalysisInterface
-	//switch exchange {
-	//case tradeAnalysisModel.TradeExchangeZhengzhou:
-	//	tradeAnalysis = &ZhengzhouTradeAnalysis{}
-	//case tradeAnalysisModel.TradeExchangeGuangzhou:
-	//	tradeAnalysis = &GuangzhouTradeAnalysis{}
-	//default:
-	//	tradeAnalysis = &BaseTradeAnalysis{}
-	//}
-	//
-	//// 获取多单/空单原始数据
-	////originList, e := tradeAnalysis.GetTradeDataByClassifyAndCompany(exchange, classifyNames, contracts, queryCompanies, time.Time{}, time.Time{})
-	////if e != nil {
-	////	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	////	return
-	////}
-	//originList, _, lastOriginList, e := tradeAnalysis.GetTradeDataByContracts(exchange, classifyNames, contracts, queryCompanies, time.Time{}, time.Time{})
-	//if e != nil {
-	//	err = fmt.Errorf("获取多空单原始数据失败, %v", e)
-	//	return
-	//}
-	//
-	//// [合约-期货公司]数据分组
-	//keyItems := make(map[string]*tradeAnalysisModel.ContractCompanyTradeData)
-	//{
-	//	keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
-	//	keyDateDataExist := make(map[string]bool)
-	//	for _, v := range originList {
-	//		// Rank999-对应的是TOP20
-	//		companyName := v.CompanyName
-	//		if v.Rank == 999 {
-	//			companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
-	//		}
-	//
-	//		k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
-	//		if keyItems[k] == nil {
-	//			keyItems[k] = new(tradeAnalysisModel.ContractCompanyTradeData)
-	//			keyItems[k].Exchange = exchange
-	//			keyItems[k].CompanyName = companyName
-	//			keyItems[k].ClassifyName = v.ClassifyName
-	//			keyItems[k].ClassifyType = v.ClassifyType
-	//			keyItems[k].DataList = make([]*tradeAnalysisModel.ContractCompanyTradeDataList, 0)
-	//		}
-	//
-	//		kd := fmt.Sprintf("%s-%s", k, v.DataTime.Format(utils.FormatDate))
-	//		if keyDateData[kd] == nil {
-	//			keyDateData[kd] = new(tradeAnalysisModel.ContractCompanyTradeDataList)
-	//			keyDateData[kd].Date = v.DataTime
-	//		}
-	//		if v.ValType == 1 {
-	//			keyDateData[kd].BuyVal = v.Val
-	//			keyDateData[kd].BuyValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//			keyDateData[kd].BuyChange = v.ValChange
-	//			keyDateData[kd].BuyChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		}
-	//		if v.ValType == 2 {
-	//			keyDateData[kd].SoldVal = v.Val
-	//			keyDateData[kd].SoldValType = tradeAnalysisModel.TradeDataTypeOrigin
-	//			keyDateData[kd].SoldChange = v.ValChange
-	//			keyDateData[kd].SoldChangeType = tradeAnalysisModel.TradeDataTypeOrigin
-	//		}
-	//		if !keyDateDataExist[kd] {
-	//			keyItems[k].DataList = append(keyItems[k].DataList, keyDateData[kd])
-	//			keyDateDataExist[kd] = true
-	//		}
-	//	}
-	//}
-	//
-	//// 获取[合约]每日的末位多空单
-	//contractLastBuyDateVal := make(map[string]map[time.Time]int)
-	//contractLastSoldDateVal := make(map[string]map[time.Time]int)
-	//{
-	//	//lastOriginList, e := tradeAnalysis.GetLastTradeDataByClassify(exchange, classifyNames, contracts)
-	//	//if e != nil {
-	//	//	err = fmt.Errorf("获取末位多空单原始数据失败, %v", e)
-	//	//	return
-	//	//}
-	//	for _, v := range lastOriginList {
-	//		if v.ValType == 1 {
-	//			if contractLastBuyDateVal[v.ClassifyType] == nil {
-	//				contractLastBuyDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//			}
-	//			contractLastBuyDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//			continue
-	//		}
-	//		if contractLastSoldDateVal[v.ClassifyType] == nil {
-	//			contractLastSoldDateVal[v.ClassifyType] = make(map[time.Time]int)
-	//		}
-	//		contractLastSoldDateVal[v.ClassifyType][v.DataTime] = v.Val
-	//	}
-	//}
-
 	// 获取合约持仓数据
 	contractTradeData, lastBuyVal, lastSoldVal, e := GetContractCompanyTradeData(exchange, classifyNames, contracts, companies, time.Time{}, time.Time{})
 	if e != nil {
@@ -1245,11 +824,7 @@ func GetContractCompanyTradeData(exchange string, classifyNames, contracts, comp
 		keyDateData := make(map[string]*tradeAnalysisModel.ContractCompanyTradeDataList)
 		keyDateDataExist := make(map[string]bool)
 		for _, v := range originList {
-			// Rank999-对应的是TOP20
 			companyName := v.CompanyName
-			//if v.Rank == 999 {
-			//	companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
-			//}
 
 			k := fmt.Sprintf("%s-%s", v.ClassifyType, companyName)
 			if contractTradeData[k] == nil {

+ 0 - 174
services/data/trade_analysis/trade_analysis_interface.go

@@ -13,21 +13,11 @@ import (
 type TradeAnalysisInterface interface {
 	GetTradeDataByContracts(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items []*tradeAnalysisModel.OriginTradeData, topItems, lastItems []*tradeAnalysisModel.OriginTradeData, err error)
 	GetContractTopRankData(exchange string, classifyNames []string, dataDate time.Time) (items []*tradeAnalysisModel.ContractTopRankData, err error)
-	//GetTradeDataByClassifyAndCompany(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items []*tradeAnalysisModel.OriginTradeData, err error)
-	//GetLastTradeDataByClassify(exchange string, classifyName, contracts []string) (items []*tradeAnalysisModel.OriginTradeData, err error) // 获取品种末位数据
 }
 
 // BaseTradeAnalysis 通用交易所
 type BaseTradeAnalysis struct{}
 
-//func (b *BaseTradeAnalysis) GetTradeDataByClassifyAndCompany(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	return tradeAnalysisModel.GetTradeDataByClassifyAndCompany(exchange, classifyNames, contracts, queryCompanies, startDate, endDate)
-//}
-
-//func (b *BaseTradeAnalysis) GetLastTradeDataByClassify(exchange string, classifyName, contracts []string) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	return tradeAnalysisModel.GetLastTradeDataByClassify(exchange, classifyName, contracts)
-//}
-
 // GetTradeDataByContracts 根据合约获取公司的持仓数据、TOP20数据以及每日的末位数据
 func (b *BaseTradeAnalysis) GetTradeDataByContracts(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items, topItems, lastItems []*tradeAnalysisModel.OriginTradeData, err error) {
 	// 根据合约获取数据
@@ -167,14 +157,6 @@ func (b *BaseTradeAnalysis) GetContractTopRankData(exchange string, classifyName
 // ZhengzhouTradeAnalysis 郑商所
 type ZhengzhouTradeAnalysis struct{}
 
-//func (z *ZhengzhouTradeAnalysis) GetTradeDataByClassifyAndCompany(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	return tradeAnalysisModel.GetTradeZhengzhouDataByClassifyAndCompany(exchange, contracts, queryCompanies)
-//}
-
-//func (z *ZhengzhouTradeAnalysis) GetLastTradeDataByClassify(exchange string, classifyName, contracts []string) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	return tradeAnalysisModel.GetLastTradeZhengzhouDataByClassify(exchange, contracts)
-//}
-
 func (z *ZhengzhouTradeAnalysis) GetTradeDataByContracts(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items, topItems, lastItems []*tradeAnalysisModel.OriginTradeData, err error) {
 	// 根据合约获取数据
 	originData, e := tradeAnalysisModel.GetZhengzhouTradeDataByContracts(contracts, startDate, endDate)
@@ -193,153 +175,6 @@ func (z *ZhengzhouTradeAnalysis) GetContractTopRankData(exchange string, classif
 // GuangzhouTradeAnalysis 广期所
 type GuangzhouTradeAnalysis struct{}
 
-//func (g *GuangzhouTradeAnalysis) GetTradeDataByClassifyAndCompany(exchange string, classifyNames []string, contracts, queryCompanies []string, startDate, endDate time.Time) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	classifyIdMap := map[string]int{"si": 7, "lc": 8}
-//
-//	// TODO:
-//	items = make([]*tradeAnalysisModel.OriginTradeData, 0)
-//	for _, classifyName := range classifyNames {
-//		classifyId := classifyIdMap[classifyName]
-//		if classifyId == 0 {
-//			err = fmt.Errorf("品种有误")
-//			return
-//		}
-//
-//		// TOP20
-//		seatNameArr := []string{tradeAnalysisModel.GuangZhouSeatNameBuy, tradeAnalysisModel.GuangZhouSeatNameSold}
-//		if utils.InArrayByStr(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20) {
-//			seatNameArr = append(seatNameArr, tradeAnalysisModel.GuangZhouTopSeatNameBuy, tradeAnalysisModel.GuangZhouTopSeatNameSold)
-//		}
-//
-//		// 查询品种下所有指标
-//		indexes, e := tradeAnalysisModel.GetBaseFromTradeGuangzhouIndexByClassifyId(classifyId)
-//		if e != nil {
-//			err = fmt.Errorf("获取广期所指标失败, %v", e)
-//			return
-//		}
-//		var indexIds []int
-//		indexInfo := make(map[int]*tradeAnalysisModel.OriginTradeData)
-//		for _, v := range indexes {
-//			// eg.永安期货_si2401_持买单量
-//			nameArr := strings.Split(v.IndexName, "_")
-//			if len(nameArr) != 3 {
-//				continue
-//			}
-//			companyName := nameArr[0]
-//			if nameArr[0] == tradeAnalysisModel.GuangZhouTopCompanyAliasName {
-//				companyName = tradeAnalysisModel.TradeFuturesCompanyTop20
-//			}
-//			if !utils.InArrayByStr(seatNameArr, nameArr[2]) {
-//				continue
-//			}
-//			if !utils.InArrayByStr(queryCompanies, companyName) {
-//				continue
-//			}
-//			if !utils.InArrayByStr(contracts, nameArr[1]) {
-//				continue
-//			}
-//			indexIds = append(indexIds, v.BaseFromTradeGuangzhouIndexId)
-//			if indexInfo[v.BaseFromTradeGuangzhouIndexId] == nil {
-//				if tradeAnalysisModel.GuangzhouSeatNameValType[nameArr[2]] == 0 {
-//					continue
-//				}
-//				indexInfo[v.BaseFromTradeGuangzhouIndexId] = new(tradeAnalysisModel.OriginTradeData)
-//				indexInfo[v.BaseFromTradeGuangzhouIndexId].CompanyName = companyName
-//				indexInfo[v.BaseFromTradeGuangzhouIndexId].ClassifyName = classifyName
-//				indexInfo[v.BaseFromTradeGuangzhouIndexId].ClassifyType = nameArr[1]
-//				indexInfo[v.BaseFromTradeGuangzhouIndexId].ValType = tradeAnalysisModel.GuangzhouSeatNameValType[nameArr[2]]
-//			}
-//		}
-//		if len(indexIds) == 0 {
-//			continue
-//		}
-//
-//		// 查询指标数据
-//		indexesData, e := tradeAnalysisModel.GetBaseFromTradeGuangzhouDataByIndexIds(indexIds)
-//		if e != nil {
-//			err = fmt.Errorf("获取广期所指标数据失败, %v", e)
-//			return
-//		}
-//		for _, v := range indexesData {
-//			info, ok := indexInfo[v.BaseFromTradeGuangzhouIndexId]
-//			if !ok {
-//				continue
-//			}
-//			items = append(items, &tradeAnalysisModel.OriginTradeData{
-//				CompanyName:  info.CompanyName,
-//				Val:          int(v.Value),
-//				ValChange:    int(v.QtySub),
-//				DataTime:     v.DataTime,
-//				ClassifyName: info.ClassifyName,
-//				ClassifyType: info.ClassifyType,
-//				ValType:      info.ValType,
-//			})
-//		}
-//	}
-//	return
-//}
-
-//func (g *GuangzhouTradeAnalysis) GetLastTradeDataByClassify(exchange string, classifyNames, contracts []string) (items []*tradeAnalysisModel.OriginTradeData, err error) {
-//	classifyIdMap := map[string]int{"si": 7, "lc": 8}
-//	for _, classifyName := range classifyNames {
-//		classifyId := classifyIdMap[classifyName]
-//		if classifyId == 0 {
-//			err = fmt.Errorf("品种有误")
-//			return
-//		}
-//		seatNameArr := []string{tradeAnalysisModel.GuangZhouSeatNameBuy, tradeAnalysisModel.GuangZhouSeatNameSold}
-//
-//		// 查询品种下所有指标
-//		indexes, e := tradeAnalysisModel.GetBaseFromTradeGuangzhouIndexByClassifyId(classifyId)
-//		if e != nil {
-//			err = fmt.Errorf("获取广期所指标失败, %v", e)
-//			return
-//		}
-//
-//		// 获取各合约下的指标
-//		contractIndexIds := make(map[string][]int)
-//		for _, v := range indexes {
-//			// eg.永安期货_si2401_持买单量
-//			nameArr := strings.Split(v.IndexName, "_")
-//			if len(nameArr) != 3 {
-//				continue
-//			}
-//			if !utils.InArrayByStr(contracts, nameArr[1]) {
-//				continue
-//			}
-//			if !utils.InArrayByStr(seatNameArr, nameArr[2]) {
-//				continue
-//			}
-//			if tradeAnalysisModel.GuangzhouSeatNameValType[nameArr[2]] == 0 {
-//				continue
-//			}
-//			k := fmt.Sprintf("%s-%d", nameArr[1], tradeAnalysisModel.GuangzhouSeatNameValType[nameArr[2]])
-//			contractIndexIds[k] = append(contractIndexIds[k], v.BaseFromTradeGuangzhouIndexId)
-//		}
-//
-//		// ps.如果后面如果有空可以优化一下这里, 把末位数据每天写进一张表里面
-//		for k, v := range contractIndexIds {
-//			keyArr := strings.Split(k, "-")
-//			contract := keyArr[0]
-//			valType, _ := strconv.Atoi(keyArr[1])
-//			lastVales, e := tradeAnalysisModel.GetBaseFromTradeGuangzhouMinDataByIndexIds(v)
-//			if e != nil {
-//				err = fmt.Errorf("获取合约末位数据失败, %v", e)
-//				return
-//			}
-//			for _, vv := range lastVales {
-//				items = append(items, &tradeAnalysisModel.OriginTradeData{
-//					Val:          int(vv.Value),
-//					DataTime:     vv.DataTime,
-//					ClassifyType: contract,
-//					ValType:      valType,
-//				})
-//			}
-//		}
-//	}
-//	return
-//}
-
 func (g *GuangzhouTradeAnalysis) GetTradeDataByContracts(exchange string, classifyNames, contracts, queryCompanies []string, startDate, endDate time.Time) (items, topItems, lastItems []*tradeAnalysisModel.OriginTradeData, err error) {
 	items, topItems, lastItems = make([]*tradeAnalysisModel.OriginTradeData, 0), make([]*tradeAnalysisModel.OriginTradeData, 0), make([]*tradeAnalysisModel.OriginTradeData, 0)
 
@@ -363,9 +198,6 @@ func (g *GuangzhouTradeAnalysis) GetTradeDataByContracts(exchange string, classi
 
 	// 过滤掉成交量,只取买单卖单
 	seatNameArr := []string{tradeAnalysisModel.GuangZhouSeatNameBuy, tradeAnalysisModel.GuangZhouSeatNameSold, tradeAnalysisModel.GuangZhouTopSeatNameBuy, tradeAnalysisModel.GuangZhouTopSeatNameSold}
-	//if utils.InArrayByStr(queryCompanies, tradeAnalysisModel.TradeFuturesCompanyTop20) {
-	//	seatNameArr = append(seatNameArr, tradeAnalysisModel.GuangZhouTopSeatNameBuy, tradeAnalysisModel.GuangZhouTopSeatNameSold)
-	//}
 	indexInfo := make(map[int]*tradeAnalysisModel.OriginTradeData)
 
 	// 查询公司中是否含TOP20
@@ -375,8 +207,6 @@ func (g *GuangzhouTradeAnalysis) GetTradeDataByContracts(exchange string, classi
 	}
 	isTopIndex := make(map[int]bool)
 
-	//contractIndexIds := make(map[string][]int) // [合约+方向-指标ID]
-	//indexIdContract := make(map[int]string)    // [指标ID-合约_方向]
 	for _, v := range indexes {
 		// eg.永安期货_si2401_持买单量
 		nameArr := strings.Split(v.IndexName, "_")
@@ -411,10 +241,6 @@ func (g *GuangzhouTradeAnalysis) GetTradeDataByContracts(exchange string, classi
 			indexInfo[v.BaseFromTradeGuangzhouIndexId].ClassifyType = nameArr[1]
 			indexInfo[v.BaseFromTradeGuangzhouIndexId].ValType = contractType
 		}
-
-		//k := fmt.Sprintf("%s-%d", nameArr[1], tradeAnalysisModel.GuangzhouSeatNameValType[nameArr[2]])
-		//contractIndexIds[k] = append(contractIndexIds[k], v.BaseFromTradeGuangzhouIndexId)
-		//indexIdContract[v.BaseFromTradeGuangzhouIndexId] = k
 	}
 	if len(indexIds) == 0 {
 		return

+ 0 - 1
services/data/trade_analysis/trade_analysis_table.go

@@ -153,7 +153,6 @@ func GetTableRowsDataByConfig(tableConfig tradeAnalysisModel.TableExtraConfig) (
 		err = fmt.Errorf("获取基准日期失败, %v", e)
 		return
 	}
-	//fmt.Println(baseDate)
 
 	// 查询基准日期TOP20合约排名, 根据类型取出合约数
 	exchangeContracts := make(map[string][]*tradeAnalysisModel.ContractTopRankData) // 交易所最终取的合约

+ 2 - 0
utils/constants.go

@@ -246,6 +246,8 @@ const (
 	CACHE_EDB_TERMINAL_CODE_URL      = "edb:terminal_code:edb_code:"     // 指标与终端关系的缓存
 
 	CACHE_KEY_REPLACE_EDB = "eta:replace_edb" //系统用户操作日志队列
+
+	CACHE_EXCEL_REFRESH = "CACHE_EXCEL_REFRESH" // 表格刷新
 )
 
 // 模板消息推送类型