package future_good

import (
	"github.com/rdlucklib/rdluck_tools/paging"
	"hongze/hz_crm_api/controllers"
	"hongze/hz_crm_api/models"
	future_good2 "hongze/hz_crm_api/models/data_manage/future_good"
	"hongze/hz_crm_api/utils"
)

// FutureGoodEdbInfoController 期货数据
type FutureGoodEdbInfoController struct {
	controllers.BaseAuthController
}

// FutureGoodEdbInfoList
// @Title 期货指标列表接口
// @Description 期货指标列表接口
// @Param   Keyword   query   string  false       "搜索关键词:期货指标ID/期货指标名称"
// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
// @Param   Exchange   query   string  false       "交易所"
// @Success 200 {object} []future_good.FutureGoodEdbInfo
// @router /edb_info/list [get]
func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	sysUser := this.SysUser
	if sysUser == nil {
		br.Msg = "请登录"
		br.ErrMsg = "请登录，SysUser Is Empty"
		br.Ret = 408
		return
	}

	var condition string
	var pars []interface{}

	// @Param   Keyword   query   string  false       "搜索关键词:期货指标ID/期货指标名称"
	keyword := this.GetString("Keyword")
	if keyword != `` {
		condition += ` AND ( future_good_edb_name like ? or future_good_edb_code like ? ) `
		pars = append(pars, "%"+keyword+"%", "%"+keyword+"%")
	}

	// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
	regionType := this.GetString("RegionType")
	if regionType != `` {
		condition += ` AND region_type = ? `
		pars = append(pars, regionType)
	}

	// @Param   Exchange   query   string  false       "交易所"
	exchange := this.GetString("Exchange")
	if exchange != `` {
		condition += ` AND exchange = ? `
		pars = append(pars, exchange)
	}

	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}
	if len(list) <= 0 {
		list = make([]*future_good2.FutureGoodEdbInfo, 0)
	}

	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = list
}

// FutureGoodEdbInfoDataList
// @Title 期货商品数据列表
// @Description 期货商品数据列表接口
// @Param   CurrentIndex   query   int  true       "当前页码"
// @Param   PageSize   query   int  true       "每页数据数"
// @Param   FutureGoodEdbInfoId   query   string  true       "指标id"
// @Param   FutureGoodEdbCode   query   string  true       "指标code"
// @Param   StartDate   query   string  true       "开始日期"
// @Param   EndDate   query   string  true       "结束日期"
// @Success 200 {object} future_good.FutureGoodEdbDataListResp
// @router /edb_info/data/list [get]
func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoDataList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	sysUser := this.SysUser
	if sysUser == nil {
		br.Msg = "请登录"
		br.ErrMsg = "请登录，SysUser Is Empty"
		br.Ret = 408
		return
	}

	pageSize, _ := this.GetInt("PageSize")
	currentIndex, _ := this.GetInt("CurrentIndex")

	var startSize int
	if pageSize <= 0 {
		pageSize = utils.PageSize20
	}
	if currentIndex <= 0 {
		currentIndex = 1
	}
	startSize = utils.StartIndex(currentIndex, pageSize)

	var condition string
	var pars []interface{}

	// @Param   FutureGoodEdbInfoId   query   string  true       "指标id"
	futureGoodEdbInfoId := this.GetString("FutureGoodEdbInfoId")
	if futureGoodEdbInfoId != `` {
		condition += ` AND future_good_edb_info_id = ? `
		pars = append(pars, futureGoodEdbInfoId)
	}
	// @Param   FutureGoodEdbCode   query   string  true       "指标code"
	futureGoodEdbCode := this.GetString("FutureGoodEdbCode")
	if futureGoodEdbCode != `` {
		condition += ` AND future_good_edb_code = ? `
		pars = append(pars, futureGoodEdbCode)
	}
	// @Param   StartDate   query   string  true       "开始日期"
	startDate := this.GetString("StartDate")
	if startDate != `` {
		condition += ` AND data_time >= ? `
		pars = append(pars, startDate)
	}
	// @Param   EndDate   query   string  true       "结束日期"
	endDate := this.GetString("EndDate")
	if endDate != `` {
		condition += ` AND data_time <= ? `
		pars = append(pars, endDate)
	}

	total, err := future_good2.GetFutureGoodEdbDataListCount(condition, pars)
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}

	list, err := future_good2.GetFutureGoodEdbDataList(condition, pars, startSize, pageSize)
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}

	// 获取用到的指标信息
	futureGoodEdbInfoList, err := future_good2.GetAllFutureGoodEdbInfoList()
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}
	futureGoodEdbInfoMap := make(map[int]*future_good2.FutureGoodEdbInfo)
	for _, v := range futureGoodEdbInfoList {
		futureGoodEdbInfoMap[v.FutureGoodEdbInfoId] = v
	}

	if len(list) > 0 {
		// 给指标数据赋值指标名称
		for _, v := range list {
			if futureGoodEdbInfo, ok := futureGoodEdbInfoMap[v.FutureGoodEdbInfoId]; ok {
				v.FutureGoodEdbName = futureGoodEdbInfo.FutureGoodEdbName
			}
		}
	}
	page := paging.GetPaging(currentIndex, pageSize, total)
	resp := future_good2.FutureGoodEdbDataListResp{
		Paging: page,
		List:   list,
	}
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = resp
}

// FutureGoodEdbInfoGroupList
// @Title 期货指标列表接口
// @Description 期货指标列表接口
// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
// @Success 200 {object} data_manage.EdbInfoListResp
// @router /edb_info/group/list [get]
func (this *FutureGoodEdbInfoController) FutureGoodEdbInfoGroupList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	sysUser := this.SysUser
	if sysUser == nil {
		br.Msg = "请登录"
		br.ErrMsg = "请登录，SysUser Is Empty"
		br.Ret = 408
		return
	}

	var condition string
	var pars []interface{}

	condition += ` AND parent_id = ? `
	pars = append(pars, 0)

	// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
	regionType := this.GetString("RegionType")
	if regionType != `` {
		condition += ` AND region_type = ? `
		pars = append(pars, regionType)
	}

	list, err := future_good2.GetFutureGoodEdbInfoGroupList(condition, pars)
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}
	if len(list) <= 0 {
		list = make([]*future_good2.FutureGoodEdbInfo, 0)
	}

	resp := []future_good2.FutureGoodEdbInfoGroupListResp{
		{
			FutureGoodEdbInfoId:   0,
			FutureGoodEdbInfoName: "国内交易所",
			Child:                 make([]future_good2.FutureGoodEdbInfoGroupListResp, 0),
		}, {
			FutureGoodEdbInfoId:   0,
			FutureGoodEdbInfoName: "海外交易所",
			Child:                 make([]future_good2.FutureGoodEdbInfoGroupListResp, 0),
		},
	}
	groupMap := make(map[string]int)
	for _, v := range list {
		tmpKey, ok := groupMap[v.Exchange]
		var tmpList future_good2.FutureGoodEdbInfoGroupListResp

		respIndex := 0
		if v.RegionType == `海外` {
			respIndex = 1
		}
		child := resp[respIndex].Child
		if !ok {
			tmpKey = len(child)
			tmpList = future_good2.FutureGoodEdbInfoGroupListResp{
				FutureGoodEdbInfoId:   tmpKey,
				FutureGoodEdbInfoName: v.Exchange,
				Child: []future_good2.FutureGoodEdbInfoGroupListResp{
					{
						FutureGoodEdbInfoId:   v.FutureGoodEdbInfoId,
						FutureGoodEdbInfoName: v.FutureGoodEdbName,
						//Child:                 make([]future_good.FutureGoodEdbInfoGroupListResp, 0),
					},
				},
			}
			child = append(child, tmpList)
			groupMap[v.Exchange] = tmpKey
		} else {
			tmpList = child[tmpKey]
			tmpList.Child = append(tmpList.Child, future_good2.FutureGoodEdbInfoGroupListResp{
				FutureGoodEdbInfoId:   v.FutureGoodEdbInfoId,
				FutureGoodEdbInfoName: v.FutureGoodEdbName,
				//Child:                 make([]future_good.FutureGoodEdbInfoGroupListResp, 0),
			})
			child[tmpKey] = tmpList
		}
		resp[respIndex].Child = child
	}
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = resp
}

// FutureGoodEdbExchangeList
// @Title 交易所列表接口
// @Description 交易所列表接口
// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
// @Success 200 {object} data_manage.EdbInfoListResp
// @router /exchange/list [get]
func (this *FutureGoodEdbInfoController) FutureGoodEdbExchangeList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	sysUser := this.SysUser
	if sysUser == nil {
		br.Msg = "请登录"
		br.ErrMsg = "请登录，SysUser Is Empty"
		br.Ret = 408
		return
	}

	var condition string
	var pars []interface{}

	condition += ` AND parent_id = ? `
	pars = append(pars, 0)

	// @Param   RegionType   query   string  false       "交易所来源，海外还是国内"
	regionType := this.GetString("RegionType")
	if regionType != `` {
		condition += ` AND region_type = ? `
		pars = append(pars, regionType)
	}

	list, err := future_good2.GetFutureGoodEdbExchangeList(condition, pars)
	if err != nil && err.Error() != utils.ErrNoRow() {
		br.Msg = "获取失败"
		br.ErrMsg = "获取数据失败，Err:" + err.Error()
		return
	}
	if len(list) <= 0 {
		list = make([]future_good2.FutureGoodExchange, 0)
	}

	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = list
}

//func init() {
//	var condition string
//	var pars []interface{}
//
//	condition += ` AND parent_id = ? `
//	pars = append(pars, 0)
//
//	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
//	if err != nil && err.Error() != utils.ErrNoRow() {
//		fmt.Println("err:", err)
//		return
//	}
//
//	monthMap := map[string]string{
//		`(1月`:  "(Jan",
//		`(2月`:  "(Feb",
//		`(3月`:  "(Mar",
//		`(4月`:  "(Apr",
//		`(5月`:  "(May",
//		`(6月`:  "(Jun",
//		`(7月`:  "(Jul",
//		`(8月`:  "(Aug",
//		`(9月`:  "(Sep",
//		`(10月`: "(Oct",
//		`(11月`: "(Nov",
//		`(12月`: "(Dec",
//	}
//	for _, v := range list {
//		fmt.Println(v)
//		var tmpCondition string
//		var tmpPars []interface{}
//
//		tmpCondition += ` AND parent_id = ? `
//		tmpPars = append(tmpPars, v.FutureGoodEdbInfoId)
//		tmpList, tmpErr := future_good2.GetFutureGoodEdbInfoList(tmpCondition, tmpPars)
//		if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
//			fmt.Println("err:", tmpErr)
//			return
//		}
//
//		for _, child := range tmpList {
//			child.FutureGoodEdbNameEn = strings.Replace(child.FutureGoodEdbNameEn, v.FutureGoodEdbName, v.FutureGoodEdbNameEn, -1)
//
//			for k, month := range monthMap {
//				if strings.Contains(child.FutureGoodEdbNameEn, k) {
//					child.FutureGoodEdbNameEn = strings.Replace(child.FutureGoodEdbNameEn, k, month, -1)
//					fmt.Println(child.FutureGoodEdbNameEn)
//					//os.Exit(-1)
//					child.Update([]string{"FutureGoodEdbNameEn"})
//				}
//			}
//		}
//	}
//
//	fmt.Println("end")
//}

//func init() {
//
//	edbCodeMap := map[string]string{
//		//"沪深300指数期货": "IF",
//		//"上证50指数期货": "IH",
//		//"中证500指数期货": "IC",
//		//"中证1000指数期货": "IM",
//		//"2年期国债期货": "TS",
//		//"5年期国债期货": "TF",
//		"10年期国债期货": "T",
//	}
//	//T03
//	suffix := "M.CFE"
//	monthList := []string{"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}
//	monthStrList := []string{"(1月)", "(2月)", "(3月)", "(4月)", "(5月)", "(6月)", "(7月)", "(8月)", "(9月)", "(10月)", "(11月)", "(12月)"}
//
//	for k, v := range edbCodeMap {
//		code := v + "CFE"
//		tmpFutureGoodEdbInfo := &future_good2.FutureGoodEdbInfo{
//			//FutureGoodEdbInfoId: 0,
//			FutureGoodEdbCode:   code,
//			FutureGoodEdbName:   k,
//			FutureGoodEdbNameEn: k,
//			ParentId:            0,
//			Exchange:            "中金所",
//			Month:               0,
//			StartDate:           "",
//			EndDate:             "",
//			MinValue:            0,
//			MaxValue:            0,
//			LatestValue:         0,
//			//LatestDate:          time.Time{},
//			ServerUrl:  "",
//			CreateTime: time.Now(),
//			ModifyTime: time.Now(),
//		}
//		err := future_good2.AddFutureGoodEdbInfo(tmpFutureGoodEdbInfo)
//		if err != nil {
//			fmt.Println("添加指标:", k, "失败,err:", err)
//			continue
//		}
//
//		for index, month := range monthList {
//			code2 := v + month + suffix
//			name := tmpFutureGoodEdbInfo.FutureGoodEdbName + monthStrList[index]
//			tmpFutureGoodEdbInfo2 := &future_good2.FutureGoodEdbInfo{
//				//FutureGoodEdbInfoId: 0,
//				FutureGoodEdbCode:   code2,
//				FutureGoodEdbName:   name,
//				FutureGoodEdbNameEn: name,
//				ParentId:            tmpFutureGoodEdbInfo.FutureGoodEdbInfoId,
//				Exchange:            "中金所",
//				Month:               0,
//				StartDate:           "",
//				EndDate:             "",
//				MinValue:            0,
//				MaxValue:            0,
//				LatestValue:         0,
//				//LatestDate:          time.Time{},
//				ServerUrl:  "",
//				CreateTime: time.Now(),
//				ModifyTime: time.Now(),
//			}
//			err = future_good2.AddFutureGoodEdbInfo(tmpFutureGoodEdbInfo2)
//			if err != nil {
//				fmt.Println("添加子指标:", name, "失败,err:", err)
//				continue
//			}
//		}
//	}
//
//	fmt.Println("end")
//}

//func init() {
//	var condition string
//	var pars []interface{}
//
//	condition += ` AND parent_id > ? AND start_date= ? `
//	pars = append(pars, 0, "0000-00-00")
//
//	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
//	if err != nil && err.Error() != utils.ErrNoRow() {
//		fmt.Println("err:", err)
//		return
//	}
//
//	for _, v := range list {
//		fmt.Println(v)
//		resp, err := future_good.AddEdbData(v.FutureGoodEdbCode)
//		if err != nil {
//			fmt.Println(v.FutureGoodEdbName, "添加 异常 ,err:", err)
//			continue
//		}
//		if resp.Ret != 200 {
//			fmt.Println(v.FutureGoodEdbName, "添加 失败 ,msg:", resp.Msg, ";errMsg:", resp.ErrMsg)
//		}
//	}
//
//	fmt.Println("end")
//}

//func init() {
//	var condition string
//	var pars []interface{}
//
//	condition += ` AND parent_id = ? AND start_date= ? `
//	pars = append(pars, 0, "0000-00-00")
//
//	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
//	if err != nil && err.Error() != utils.ErrNoRow() {
//		fmt.Println("err:", err)
//		return
//	}
//
//	for _, v := range list {
//		fmt.Println(v)
//		//v.FutureGoodEdbCode = strings.Replace(v.FutureGoodEdbCode, ".", "ZL.", -1)
//		//v.Update([]string{"FutureGoodEdbCode"})
//		resp, err := future_good.AddEdbData(v.FutureGoodEdbCode)
//		if err != nil {
//			fmt.Println(v.FutureGoodEdbName, "添加 异常 ,err:", err)
//			continue
//		}
//		if resp.Ret != 200 {
//			fmt.Println(v.FutureGoodEdbName, "添加 失败 ,msg:", resp.Msg, ";errMsg:", resp.ErrMsg)
//		}
//	}
//
//	fmt.Println("end")
//}

// 添加海外交易所
//func init() {
//	exchangeName := `新加坡证券（SGX）`
//	suffix := ".SGX"
//	type TmpStruct struct {
//		Name  string
//		Code  string
//		Year  int
//		Month int
//	}
//	str := `TSI铁矿石指数	FEF	SGX	2612`
//	list := make([]TmpStruct, 0)
//
//	strList := strings.Split(str, `
//`)
//	//fmt.Println(strList)
//	for _, v := range strList {
//		v = strings.TrimPrefix(v, "\t")
//		tmp := strings.Split(v, `	`)
//		fmt.Println(tmp)
//
//		year, err := strconv.Atoi(tmp[3][0:2])
//		if err != nil {
//			fmt.Println(err)
//			return
//		}
//		//fmt.Println(year)
//		month, err := strconv.Atoi(tmp[3][2:4])
//		if err != nil {
//			fmt.Println(err)
//			return
//		}
//		//fmt.Println(month)
//
//		tmpStruct := TmpStruct{
//			Name:  tmp[0],
//			Code:  tmp[1],
//			Year:  year,
//			Month: month,
//		}
//		list = append(list, tmpStruct)
//	}
//
//	//T03
//	//suffix := ".CMX"
//	//1、@CL0W.NMX[NYMEX美原油电子盘主力（持仓量）合约]
//	//2、@CL23J.NMX[NYMEX美原油电子盘2304]
//	//yearList := []int{2023, 2024, 2025, 2026, 2027, 2028}
//	monthList := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
//	startMonth := 3
//	//endMonth := 5
//
//	monthCodeStrList := []string{"F", "G", "H", "J", "K", "M", "N", "Q", "U", "V", "X", "Z"}
//	//monthStrList := []string{"(1月)", "(2月)", "(3月)", "(4月)", "(5月)", "(6月)", "(7月)", "(8月)", "(9月)", "(10月)", "(11月)", "(12月)"}
//
//	for k, v := range list {
//		yearList := make([]int, 0)
//		for i := 23; i <= v.Year; i++ {
//			yearList = append(yearList, i+2000)
//		}
//		//fmt.Println(yearList)
//		//return
//		endMonth := v.Month
//
//		code := v.Code + `0W` + suffix
//		tmpFutureGoodEdbInfo := &future_good2.FutureGoodEdbInfo{
//			//FutureGoodEdbInfoId: 0,
//			FutureGoodEdbCode:   code,
//			FutureGoodEdbName:   v.Name,
//			FutureGoodEdbNameEn: v.Name,
//			ParentId:            0,
//			RegionType:          `海外`,
//			Exchange:            exchangeName,
//			Year:                0,
//			Month:               0,
//			StartDate:           "",
//			EndDate:             "",
//			MinValue:            0,
//			MaxValue:            0,
//			LatestValue:         0,
//			//LatestDate:          time.Time{},
//			ServerUrl:  "",
//			CreateTime: time.Now(),
//			ModifyTime: time.Now(),
//		}
//		err := future_good2.AddFutureGoodEdbInfo(tmpFutureGoodEdbInfo)
//		if err != nil {
//			fmt.Println("添加指标:", k, "失败,err:", err)
//			continue
//		}
//
//		lastYearIndex := len(yearList) - 1
//		for yearIndex, year := range yearList {
//			for index, month := range monthList {
//				// 如果第一年的开始月份早于约定的开始月份，那么就退出这个循环，进入下一个循环
//				if yearIndex == 0 && month < startMonth {
//					continue
//				}
//				// 如果最一年的结束月份晚于约定的开始月份，那么就退出这个循环，进入下一个循环
//				if lastYearIndex == yearIndex && month > endMonth {
//					break
//				}
//				monthStr := strconv.Itoa(month)
//				if month < 10 {
//					monthStr = `0` + monthStr
//				}
//				yearStr := strconv.Itoa(year - 2000)
//				yearMonthStr := yearStr + monthStr
//
//				code2 := v.Code + yearStr + monthCodeStrList[index] + suffix
//				name := tmpFutureGoodEdbInfo.FutureGoodEdbName + `(` + yearMonthStr + `)`
//				tmpFutureGoodEdbInfo2 := &future_good2.FutureGoodEdbInfo{
//					//FutureGoodEdbInfoId: 0,
//					FutureGoodEdbCode:   code2,
//					FutureGoodEdbName:   name,
//					FutureGoodEdbNameEn: name,
//					ParentId:            tmpFutureGoodEdbInfo.FutureGoodEdbInfoId,
//					RegionType:          `海外`,
//					Exchange:            exchangeName,
//					Year:                year,
//					Month:               month,
//					StartDate:           "",
//					EndDate:             "",
//					MinValue:            0,
//					MaxValue:            0,
//					LatestValue:         0,
//					//LatestDate:          time.Time{},
//					ServerUrl:  "",
//					CreateTime: time.Now(),
//					ModifyTime: time.Now(),
//				}
//				err = future_good2.AddFutureGoodEdbInfo(tmpFutureGoodEdbInfo2)
//				if err != nil {
//					fmt.Println("添加子指标:", name, "失败,err:", err)
//					continue
//				}
//			}
//		}
//
//	}
//
//	fmt.Println("end")
//}

// 刷新海外交易所数据
//func init() {
//	var condition string
//	var pars []interface{}
//
//	//condition += ` AND parent_id > ? AND start_date= ? `
//	condition += ` AND region_type = ? AND start_date= ?  AND exchange = ? `
//	pars = append(pars, "海外", "0000-00-00", "伦敦金属（LME）")
//	//condition += ` AND region_type = ? AND start_date= ?  `
//	//pars = append(pars, "海外", "0000-00-00")
//
//	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
//	if err != nil && err.Error() != utils.ErrNoRow() {
//		fmt.Println("err:", err)
//		return
//	}
//
//	errIdList := make([]string, 0)
//	for _, v := range list {
//		fmt.Println(v)
//		resp, err := future_good.AddEdbData(v.FutureGoodEdbCode)
//		if err != nil {
//			fmt.Println(v.FutureGoodEdbName, "添加 异常 ,err:", err)
//			continue
//		}
//		if resp.Ret != 200 {
//			errIdList = append(errIdList, fmt.Sprint(v.FutureGoodEdbInfoId))
//			fmt.Println(v.FutureGoodEdbName, "添加 失败 ,msg:", resp.Msg, ";errMsg:", resp.ErrMsg)
//		}
//	}
//
//	fmt.Println("end")
//	fmt.Println(strings.Join(errIdList, ","))
//}

// 刷新海外交易所数据
//func init() {
//	var condition string
//	var pars []interface{}
//
//	//condition += ` AND parent_id > ? AND start_date= ? `
//	condition += ` AND region_type = ? AND parent_id != 0 and future_good_edb_type = 1`
//	pars = append(pars, "海外")
//	//condition += ` AND region_type = ? AND start_date= ?  `
//	//pars = append(pars, "海外", "0000-00-00")
//
//	list, err := future_good2.GetFutureGoodEdbInfoList(condition, pars)
//	if err != nil && err.Error() != utils.ErrNoRow() {
//		fmt.Println("err:", err)
//		return
//	}
//	for _, v := range list {
//		//fmt.Println(v.FutureGoodEdbName)
//		tmpList := strings.Split(v.FutureGoodEdbName, "(")
//		//fmt.Println(tmpList)
//		//fmt.Println(tmpList[1])
//		year, err := strconv.Atoi(tmpList[1][0:2])
//		if err != nil {
//			fmt.Println(err)
//			return
//		}
//		v.Year = year + 2000
//		err = v.Update([]string{"Year"})
//		if err != nil {
//			fmt.Println(err)
//			return
//		}
//	}
//	fmt.Println("end")
//}
