|
@@ -72,32 +72,6 @@ type Edbdata struct {
|
|
ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
|
|
ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
|
|
}
|
|
}
|
|
|
|
|
|
-func MultiAddEdbdata(edbDataList []*Edbdata) (err error) {
|
|
|
|
- if len(edbDataList) == 0 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
- err = o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
|
|
|
- holder := make([]string, 0)
|
|
|
|
- tradeCodeList := make([]string, 0)
|
|
|
|
- for _, v := range edbDataList {
|
|
|
|
- holder = append(holder, "?")
|
|
|
|
- tradeCodeList = append(tradeCodeList, v.TradeCode)
|
|
|
|
- }
|
|
|
|
- sql := "DELETE FROM edbdata WHERE TRADE_CODE in (" + strings.Join(holder, ",") + ")"
|
|
|
|
- _, err := txOrm.Raw(sql, tradeCodeList).Exec()
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- _, err = txOrm.InsertMulti(500, edbDataList)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- return nil
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetDataInfo(tradeCode, creteDate string) (item *Edbdata, err error) {
|
|
func GetDataInfo(tradeCode, creteDate string) (item *Edbdata, err error) {
|
|
sql := " SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? "
|
|
sql := " SELECT * FROM edbdata WHERE TRADE_CODE=? AND DT=? "
|
|
o := orm.NewOrmUsingDB("edb")
|
|
o := orm.NewOrmUsingDB("edb")
|
|
@@ -165,40 +139,25 @@ func DeleteAllEdbData(tradeCode string) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-// DeleteAllEdbDataByTradeCodeList 根据指标code删除数据
|
|
|
|
-func DeleteAllEdbDataByTradeCodeList(tradeCodeList []string) (err error) {
|
|
|
|
- if len(tradeCodeList) == 0 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
- var holder []string
|
|
|
|
- for range tradeCodeList {
|
|
|
|
- holder = append(holder, "?")
|
|
|
|
- }
|
|
|
|
- sql := ` DELETE FROM edbdata WHERE TRADE_CODE in (` + strings.Join(holder, ",") + `) `
|
|
|
|
- _, err = o.Raw(sql, tradeCodeList).Exec()
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
type Edbinfo struct {
|
|
type Edbinfo struct {
|
|
- TradeCode string `orm:"column(TRADE_CODE);pk" description:"指标code"`
|
|
|
|
- SecName string `orm:"column(SEC_NAME);" description:"指标名称"`
|
|
|
|
- Unit string `orm:"column(UNIT);" description:"单位"`
|
|
|
|
- Remark string `orm:"column(REMARK);" description:"备注"`
|
|
|
|
- Frequency string `orm:"column(frequency)" description:"频度"`
|
|
|
|
- ClassifyId int `orm:"column(classify_id)" description:"分类id"`
|
|
|
|
- ClassifyName string `orm:"-" description:"分类名称"`
|
|
|
|
- CreateDate string `orm:"column(create_date)" description:"创建时间"`
|
|
|
|
- UserId int `orm:"column(user_id)" description:"录入用户id"`
|
|
|
|
- UserName string `orm:"column(user_name)" description:"录入用户名称"`
|
|
|
|
- NoticeTime string `orm:"column(notice_time)" description:"通知时间"`
|
|
|
|
- Mobile string `orm:"column(mobile)" description:"录入者手机号"`
|
|
|
|
- Sort int `orm:"column(sort)" description:"排序"`
|
|
|
|
- ModifyTime string `description:"最近一次更新时间"`
|
|
|
|
- IsJoinEdb int8 `description:"指标库是否已添加:0-否;1-是"`
|
|
|
|
- StartDate string `description:"数据开始日期"`
|
|
|
|
- EndDate string `description:"数据结束日期"`
|
|
|
|
- LatestValue float64 `description:"指标最新值"`
|
|
|
|
|
|
+ TradeCode string `orm:"column(TRADE_CODE);pk" description:"指标code"`
|
|
|
|
+ SecName string `orm:"column(SEC_NAME);" description:"指标名称"`
|
|
|
|
+ Unit string `orm:"column(UNIT);" description:"单位"`
|
|
|
|
+ Remark string `orm:"column(REMARK);" description:"备注"`
|
|
|
|
+ Frequency string `orm:"column(frequency)" description:"频度"`
|
|
|
|
+ ClassifyId int `orm:"column(classify_id)" description:"分类id"`
|
|
|
|
+ ClassifyName string `orm:"-" description:"分类名称"`
|
|
|
|
+ CreateDate string `orm:"column(create_date)" description:"创建时间"`
|
|
|
|
+ UserId int `orm:"column(user_id)" description:"录入用户id"`
|
|
|
|
+ UserName string `orm:"column(user_name)" description:"录入用户名称"`
|
|
|
|
+ NoticeTime string `orm:"column(notice_time)" description:"通知时间"`
|
|
|
|
+ Mobile string `orm:"column(mobile)" description:"录入者手机号"`
|
|
|
|
+ Sort int `orm:"column(sort)" description:"排序"`
|
|
|
|
+ ModifyTime string `description:"最近一次更新时间"`
|
|
|
|
+ IsJoinEdb int8 `description:"指标库是否已添加:0-否;1-是"`
|
|
|
|
+ StartDate string `description:"数据开始日期"`
|
|
|
|
+ EndDate string `description:"数据结束日期"`
|
|
|
|
+ LatestValue float64 `description:"指标最新值"`
|
|
}
|
|
}
|
|
|
|
|
|
func DeleteEdbinfoByTraceCodeList(tradeCodeList []string) (err error) {
|
|
func DeleteEdbinfoByTraceCodeList(tradeCodeList []string) (err error) {
|
|
@@ -353,24 +312,6 @@ func GetEdbinfoBySecName(secName string) (item *Edbinfo, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetEdbinfoBySecNameList(secNameList []string) (items []*Edbinfo, err error) {
|
|
|
|
- if len(secNameList) == 0 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- sql := `SELECT * FROM edbinfo WHERE left(TRADE_CODE,1)='W' AND REMARK='手动' `
|
|
|
|
- if len(secNameList) > 0 {
|
|
|
|
- var holder []string
|
|
|
|
- for range secNameList {
|
|
|
|
- holder = append(holder, "?")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- sql += " AND SEC_NAME IN (" + strings.Join(holder, ",") + ") "
|
|
|
|
- }
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
- _, err = o.Raw(sql, secNameList).QueryRows(&items)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func GetEdbinfoByTradeCode(tradeCode string) (item *Edbinfo, err error) {
|
|
func GetEdbinfoByTradeCode(tradeCode string) (item *Edbinfo, err error) {
|
|
sql := `SELECT * FROM edbinfo WHERE TRADE_CODE=? `
|
|
sql := `SELECT * FROM edbinfo WHERE TRADE_CODE=? `
|
|
o := orm.NewOrmUsingDB("edb")
|
|
o := orm.NewOrmUsingDB("edb")
|
|
@@ -401,12 +342,6 @@ func AddEdbinfo(tradeCode, secName, unit, remark, frequency, noticeTime string,
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func MultiAddEdbinfoV2(edbInfoList []*Edbinfo) (err error) {
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
- _, err = o.InsertMulti(len(edbInfoList), edbInfoList)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func AddEdbinfoUser(tradeCode, mobile string) (err error) {
|
|
func AddEdbinfoUser(tradeCode, mobile string) (err error) {
|
|
o := orm.NewOrmUsingDB("edb")
|
|
o := orm.NewOrmUsingDB("edb")
|
|
sql := `INSERT INTO edbinfo_user(TRADE_CODE, mobile) VALUES (?,?)`
|
|
sql := `INSERT INTO edbinfo_user(TRADE_CODE, mobile) VALUES (?,?)`
|
|
@@ -414,18 +349,6 @@ func AddEdbinfoUser(tradeCode, mobile string) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-type EdbinfoUser struct {
|
|
|
|
- EdbinfoUserId int `orm:"pk" description:"主键"`
|
|
|
|
- TradeCode string `orm:"column(TRADE_CODE);" description:"指标code"`
|
|
|
|
- Mobile string `orm:"column(mobile);" description:"手机号"`
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-func MultiAddEdbinfoUser(edbInfoUserList []*EdbinfoUser) (err error) {
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
- _, err = o.InsertMulti(len(edbInfoUserList), edbInfoUserList)
|
|
|
|
- return
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
type EdbinfoEditReq struct {
|
|
type EdbinfoEditReq struct {
|
|
TradeCode string `description:"指标code"`
|
|
TradeCode string `description:"指标code"`
|
|
SecName string `description:"指标名称"`
|
|
SecName string `description:"指标名称"`
|
|
@@ -1339,7 +1262,6 @@ type EdbInfoItem struct {
|
|
ModifyDate string `description:"待更新日期"`
|
|
ModifyDate string `description:"待更新日期"`
|
|
ModifyTime string `description:"最近一次更新时间"`
|
|
ModifyTime string `description:"最近一次更新时间"`
|
|
Status string `description:"状态:未完成/完成"`
|
|
Status string `description:"状态:未完成/完成"`
|
|
- Sort int `description:"排序"`
|
|
|
|
IsJoinEdb int8 `description:"指标库是否已添加:0-否;1-是"`
|
|
IsJoinEdb int8 `description:"指标库是否已添加:0-否;1-是"`
|
|
StartDate string `description:"数据开始日期"`
|
|
StartDate string `description:"数据开始日期"`
|
|
EndDate string `description:"数据结束日期"`
|
|
EndDate string `description:"数据结束日期"`
|
|
@@ -1398,57 +1320,6 @@ left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-// GetTargetItemList 获取指标列表数据
|
|
|
|
-func GetTargetItemListSort(classifyId, edbShowType int, frequency, keyword, tradeCode string, classifyIdStrList []string) (items []*EdbInfoItem, err error) {
|
|
|
|
- o := orm.NewOrmUsingDB("edb")
|
|
|
|
-
|
|
|
|
- pars := make([]interface{}, 0)
|
|
|
|
-
|
|
|
|
- sql := ` SELECT a.*,'' modify_date,'' STATUS FROM edbinfo AS a `
|
|
|
|
- if edbShowType != 0 {
|
|
|
|
- sql = ` SELECT a.*,b.DT,'' modify_date,'' STATUS FROM edbinfo AS a
|
|
|
|
-left join edbdata b on a.TRADE_CODE=b.TRADE_CODE `
|
|
|
|
- }
|
|
|
|
- sql += ` WHERE LEFT(a.TRADE_CODE,1)='W' AND a.REMARK='手动' AND a.classify_id>0 `
|
|
|
|
-
|
|
|
|
- //如果没有分类id集合列表,那么就没有数据了,不用往下执行了,直接返回好了
|
|
|
|
- if len(classifyIdStrList) <= 0 {
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- if len(classifyIdStrList) > 0 {
|
|
|
|
- sql += ` AND a.classify_id in (` + strings.Join(classifyIdStrList, ",") + `) `
|
|
|
|
- }
|
|
|
|
- if classifyId > 0 {
|
|
|
|
- sql += ` AND a.classify_id=` + strconv.Itoa(classifyId) + ` `
|
|
|
|
- }
|
|
|
|
- //频度
|
|
|
|
- if frequency != "" {
|
|
|
|
- sql += ` AND a.frequency="` + frequency + `" `
|
|
|
|
- }
|
|
|
|
- //关键字
|
|
|
|
- if keyword != "" {
|
|
|
|
- sql += ` AND (a.SEC_NAME like ? or a.TRADE_CODE like ? )`
|
|
|
|
- pars = utils.GetLikeKeywordPars(pars, keyword, 2)
|
|
|
|
- }
|
|
|
|
- //指定指标
|
|
|
|
- if tradeCode != "" {
|
|
|
|
- sql += ` AND a.TRADE_CODE = "` + tradeCode + `" `
|
|
|
|
- }
|
|
|
|
- //指标里面是否有数据
|
|
|
|
- switch edbShowType {
|
|
|
|
- case 1:
|
|
|
|
- sql += ` AND b.CLOSE is not null `
|
|
|
|
- case 2:
|
|
|
|
- sql += ` AND b.CLOSE is null `
|
|
|
|
- }
|
|
|
|
- sql += ` GROUP BY a.TRADE_CODE `
|
|
|
|
-
|
|
|
|
- sql = sql + ` ORDER BY sort ASC, CONVERT(a.SEC_NAME USING gbk ) COLLATE gbk_chinese_ci ASC `
|
|
|
|
- _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
|
- return
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// GetLzItemList 模糊查询隆众数据库指标列表
|
|
// GetLzItemList 模糊查询隆众数据库指标列表
|
|
func GetLzItemList(keyword string) (items []*data_manage.LongzhongSurveyProduct, err error) {
|
|
func GetLzItemList(keyword string) (items []*data_manage.LongzhongSurveyProduct, err error) {
|
|
o := orm.NewOrmUsingDB("edb")
|
|
o := orm.NewOrmUsingDB("edb")
|