base_from_smm.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. package models
  2. import (
  3. "eta/eta_index_lib/utils"
  4. "fmt"
  5. "strconv"
  6. "strings"
  7. "time"
  8. "github.com/beego/beego/v2/client/orm"
  9. )
  10. type BaseFromSmmData struct {
  11. SmmDataId int `orm:"column(smm_data_id);pk"`
  12. BaseFromSmmIndexId int
  13. IndexCode string
  14. DataTime string
  15. Value string
  16. CreateTime time.Time
  17. ModifyTime time.Time
  18. DataTimestamp int64
  19. }
  20. func (s *BaseFromSmmData) Update(cols []string) (err error) {
  21. o := orm.NewOrm()
  22. _, err = o.Update(s, cols...)
  23. return
  24. }
  25. func AddBaseFromSmmData(item []*BaseFromSmmData) (err error) {
  26. o := orm.NewOrm()
  27. _, err = o.InsertMulti(500, item)
  28. return
  29. }
  30. func GetBaseFromSmmDataByCondition(condition string, pars []interface{}) (list []*BaseFromSmmData, err error) {
  31. o := orm.NewOrm()
  32. sql := `SELECT * FROM base_from_smm_data WHERE 1=1 `
  33. if condition != "" {
  34. sql += condition
  35. }
  36. _, err = o.Raw(sql, pars).QueryRows(&list)
  37. return
  38. }
  39. func UpdateBaseFromSmmDataListByIndexCode(items []*BaseFromSmmData) (err error) {
  40. o := orm.NewOrm()
  41. sql := `UPDATE base_from_smm_data SET value=? WHERE index_code=? AND data_time=? `
  42. stmt, err := o.Raw(sql).Prepare()
  43. if err != nil {
  44. return
  45. }
  46. defer stmt.Close()
  47. for _, item := range items {
  48. _, err = stmt.Exec(item.Value, item.IndexCode, item.DataTime)
  49. if err != nil {
  50. return
  51. }
  52. }
  53. return
  54. }
  55. func GetBaseFromSmmDataByIds(smmDataIds []int) (list []*BaseFromSmmData, err error) {
  56. if len(smmDataIds) == 0 {
  57. return
  58. }
  59. o := orm.NewOrm()
  60. sql := `SELECT * FROM base_from_smm_data WHERE 1=1 AND base_from_smm_index_id in (` + utils.GetOrmInReplace(len(smmDataIds)) + `)`
  61. _, err = o.Raw(sql, smmDataIds).QueryRows(&list)
  62. return
  63. }
  64. func GetBaseFromSmmDataByCodeAndDate(indexCode string, dataTime string) (item *BaseFromSmmData, err error) {
  65. o := orm.NewOrm()
  66. sql := `SELECT * FROM base_from_smm_data WHERE 1=1 AND index_code=? AND data_time=? `
  67. err = o.Raw(sql, indexCode, dataTime).QueryRow(&item)
  68. return
  69. }
  70. // 新增有色指标数据
  71. func AddEdbDataFromSmm(edbCode string, smmBaseDataAll []*BaseFromSmmData) (err error) {
  72. o := orm.NewOrm()
  73. var isAdd bool
  74. addSql := ` INSERT INTO edb_data_ys(edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
  75. existMap := make(map[string]string)
  76. for _, sv := range smmBaseDataAll {
  77. eDate := sv.DataTime
  78. dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
  79. if err != nil {
  80. return err
  81. }
  82. timestamp := dataTime.UnixNano() / 1e6
  83. timeStr := fmt.Sprintf("%d", timestamp)
  84. if _, ok := existMap[eDate]; !ok {
  85. addSql += GetAddSql("0", edbCode, eDate, timeStr, sv.Value)
  86. isAdd = true
  87. }
  88. existMap[eDate] = sv.Value
  89. }
  90. if isAdd {
  91. addSql = strings.TrimRight(addSql, ",")
  92. utils.FileLog.Info("addSql:" + addSql)
  93. _, err = o.Raw(addSql).Exec()
  94. if err != nil {
  95. return err
  96. }
  97. }
  98. return
  99. }
  100. // RefreshEdbDataFromSmm 刷新有色指标数据
  101. func RefreshEdbDataFromSmm(edbInfoId int, edbCode, startDate string) (err error) {
  102. source := utils.DATA_SOURCE_YS
  103. subSource := utils.DATA_SUB_SOURCE_EDB
  104. o := orm.NewOrm()
  105. if err != nil {
  106. return
  107. }
  108. edbInfoIdStr := strconv.Itoa(edbInfoId)
  109. //计算数据
  110. var condition string
  111. var pars []interface{}
  112. if edbCode != "" {
  113. condition += " AND index_code=? "
  114. pars = append(pars, edbCode)
  115. }
  116. if startDate != "" {
  117. condition += " AND data_time>=? "
  118. pars = append(pars, startDate)
  119. }
  120. smmDataList, err := GetBaseFromSmmDataByCondition(condition, pars)
  121. if err != nil {
  122. return
  123. }
  124. // 真实数据的最大日期 , 插入规则配置的日期
  125. var realDataMaxDate, edbDataInsertConfigDate time.Time
  126. var edbDataInsertConfig *EdbDataInsertConfig
  127. var isFindConfigDateRealData bool //是否找到配置日期的实际数据的值
  128. {
  129. edbDataInsertConfig, err = GetEdbDataInsertConfigByEdbId(edbInfoId)
  130. if err != nil && err.Error() != utils.ErrNoRow() {
  131. return
  132. }
  133. if edbDataInsertConfig != nil {
  134. edbDataInsertConfigDate = edbDataInsertConfig.Date
  135. }
  136. }
  137. var existCondition string
  138. var existPars []interface{}
  139. existCondition += " AND edb_info_id=? "
  140. existPars = append(existPars, edbInfoId)
  141. if startDate != "" {
  142. existCondition += " AND data_time>=? "
  143. existPars = append(existPars, startDate)
  144. }
  145. existList, err := GetEdbDataByCondition(source, subSource, existCondition, existPars)
  146. if err != nil {
  147. return err
  148. }
  149. existMap := make(map[string]*EdbInfoSearchData)
  150. for _, v := range existList {
  151. existMap[v.DataTime] = v
  152. }
  153. addSql := ` INSERT INTO edb_data_ys(edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
  154. var isAdd bool
  155. for _, v := range smmDataList {
  156. item := v
  157. eDate := item.DataTime
  158. dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
  159. if err != nil {
  160. return err
  161. }
  162. if findItem, ok := existMap[v.DataTime]; !ok {
  163. sValue := item.Value
  164. timestamp := dataTime.UnixNano() / 1e6
  165. timeStr := fmt.Sprintf("%d", timestamp)
  166. addSql += GetAddSql(edbInfoIdStr, edbCode, eDate, timeStr, sValue)
  167. isAdd = true
  168. } else {
  169. if findItem != nil && utils.SubFloatToString(findItem.Value, 30) != item.Value {
  170. err = ModifyEdbDataById(source, subSource, findItem.EdbDataId, item.Value)
  171. if err != nil {
  172. return err
  173. }
  174. }
  175. }
  176. // 下面代码主要目的是处理掉手动插入的数据判断
  177. {
  178. if realDataMaxDate.IsZero() || dataTime.After(realDataMaxDate) {
  179. realDataMaxDate = dataTime
  180. }
  181. if edbDataInsertConfigDate.IsZero() || dataTime.Equal(edbDataInsertConfigDate) {
  182. isFindConfigDateRealData = true
  183. }
  184. }
  185. }
  186. // 处理手工数据补充的配置
  187. HandleConfigInsertEdbData(realDataMaxDate, edbDataInsertConfig, edbInfoId, source, subSource, existMap, isFindConfigDateRealData)
  188. if isAdd {
  189. addSql = strings.TrimRight(addSql, ",")
  190. _, err = o.Raw(addSql).Exec()
  191. if err != nil {
  192. fmt.Println("RefreshEdbDataFromSmm add Err", err.Error())
  193. return
  194. }
  195. }
  196. return
  197. }
  198. type BaseFromSmmIndex struct {
  199. BaseFromSmmIndexId int64 `orm:"column(base_from_smm_index_id);pk"`
  200. ClassifyId int
  201. Interface string
  202. Name string
  203. IndexCode string
  204. IndexName string
  205. Type1 string `orm:"column(type_1)"`
  206. Type2 string `orm:"column(type_2)"`
  207. Type3 string `orm:"column(type_3)"`
  208. Frequency string
  209. Unit string
  210. ApiStartTime string
  211. ApiUpdateTime string
  212. StartTime string
  213. FinishTime string
  214. BaseFileName string
  215. RenameFileName string
  216. StartDate string
  217. EndDate string
  218. TerminalCode string `description:"编码"`
  219. CreateTime time.Time
  220. ModifyTime time.Time
  221. DataState string
  222. ReleaseTime string
  223. }
  224. func (d *BaseFromSmmIndex) AddBaseFromSmmIndex() (lastId int64, err error) {
  225. o := orm.NewOrm()
  226. lastId, err = o.Insert(d)
  227. return
  228. }
  229. func (d *BaseFromSmmIndex) GetSmmIndexItem(indexCode string) (item *BaseFromSmmIndex, err error) {
  230. o := orm.NewOrm()
  231. sql := ` SELECT * FROM base_from_smm_index WHERE index_code=? `
  232. fmt.Println(sql, indexCode)
  233. err = o.Raw(sql, indexCode).QueryRow(&item)
  234. return
  235. }
  236. // Add 新增
  237. func (m *BaseFromSmmIndex) Add() (err error) {
  238. o := orm.NewOrm()
  239. _, err = o.Insert(m)
  240. return
  241. }
  242. func GetBaseFromSmmDataBySmmCode(smmCode string) (list []*BaseFromSmmData, err error) {
  243. o := orm.NewOrm()
  244. sql := ` SELECT * FROM base_from_smm_data WHERE index_code=? `
  245. _, err = o.Raw(sql, smmCode).QueryRows(&list)
  246. return
  247. }
  248. func ModifySmmIndexSort(baseFromSmmIndexId int64) (err error) {
  249. o := orm.NewOrm()
  250. sql := ` UPDATE base_from_smm_index SET sort=? WHERE base_from_smm_index_id=? `
  251. _, err = o.Raw(sql, baseFromSmmIndexId, baseFromSmmIndexId).Exec()
  252. return
  253. }
  254. func GetSmmIndexInfoMaxAndMinInfo(indexCode string) (item *EdbInfoMaxAndMinInfo, err error) {
  255. o := orm.NewOrm()
  256. sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date,MIN(value) AS min_value,MAX(value) AS max_value FROM base_from_smm_data WHERE index_code=? `
  257. err = o.Raw(sql, indexCode).QueryRow(&item)
  258. if err != nil {
  259. return
  260. }
  261. // 获取最新值
  262. var latest_value float64
  263. sql = ` SELECT value AS latest_value FROM base_from_smm_data WHERE index_code=? ORDER BY data_time DESC LIMIT 1 `
  264. err = o.Raw(sql, indexCode).QueryRow(&latest_value)
  265. if err != nil {
  266. return
  267. }
  268. item.LatestValue = latest_value
  269. return
  270. }
  271. func ModifySmmIndexMaxAndMinInfo(indexCode string, item *EdbInfoMaxAndMinInfo) (err error) {
  272. o := orm.NewOrm()
  273. sql := ` UPDATE base_from_smm_index SET start_date=?,end_date=?,end_value=?,modify_time=NOW() WHERE index_code=? `
  274. _, err = o.Raw(sql, item.MinDate, item.MaxDate, item.LatestValue, indexCode).Exec()
  275. return
  276. }
  277. // HandleSmmExcelDataReq SMM的excel数据
  278. type HandleSmmExcelDataReq struct {
  279. BaseFilePath string
  280. RenameFilePath string
  281. IndexName string
  282. Source string
  283. IndexCode string
  284. Unit string
  285. Frequency string
  286. ExcelDataMap map[string]string
  287. TerminalCode string `description:"编码"`
  288. }
  289. // MultiUpdateBaseFromSmmDataValue 批量更新SMM指标数据
  290. func MultiUpdateBaseFromSmmDataValue(items []*BaseFromSmmData) (err error) {
  291. if len(items) == 0 {
  292. return
  293. }
  294. o := orm.NewOrm()
  295. sql := `UPDATE base_from_smm_data SET value = ?, modify_time = NOW() WHERE index_code = ? AND data_time = ? LIMIT 1`
  296. p, err := o.Raw(sql).Prepare()
  297. if err != nil {
  298. return
  299. }
  300. defer func() {
  301. _ = p.Close()
  302. }()
  303. for _, v := range items {
  304. if v.IndexCode == "" || v.DataTime == "" {
  305. continue
  306. }
  307. _, err = p.Exec(v.Value, v.IndexCode, v.DataTime)
  308. if err != nil {
  309. return
  310. }
  311. }
  312. return
  313. }
  314. type AddSmmIndexToDataSourceResp struct {
  315. EdbCode string `description:"指标编码"`
  316. ClassifyId int `description:"指标分类"`
  317. SysUserId int `description:"操作人id"`
  318. SysUserRealName string `description:"操作人真实名称"`
  319. }
  320. func (m *BaseFromSmmIndex) GetIndexItem(indexCode string) (item *BaseFromSmmIndex, err error) {
  321. o := orm.NewOrm()
  322. sql := `SELECT * FROM base_from_smm_index WHERE index_code = ? `
  323. err = o.Raw(sql, indexCode).QueryRow(&item)
  324. return
  325. }
  326. // 修改
  327. func (m *BaseFromSmmIndex) Update(updateParams, whereParam map[string]interface{}) (err error) {
  328. to := orm.NewOrm()
  329. ptrStructOrTableName := "base_from_smm_index"
  330. qs := to.QueryTable(ptrStructOrTableName)
  331. for expr, exprV := range whereParam {
  332. qs = qs.Filter(expr, exprV)
  333. }
  334. _, err = qs.Update(updateParams)
  335. return
  336. }
  337. // BridgeZhongJiIndexDataParams 桥接服务-获取中基指标数据入参
  338. type BridgeZhongJiIndexDataParams struct {
  339. EdbCode string `json:"edb_code" form:"edb_code" description:"指标编码"`
  340. }
  341. type BridgeZhongJiIndexListParams struct {
  342. Page int `json:"page" form:"page" description:"页码"`
  343. PageSize int `json:"page_size" form:"page_size" description:"每页指标个数,每页不能超过500条,超过会固定为500"`
  344. }
  345. type BaseFromSmmDataList struct {
  346. Data []*BaseFromSmmData
  347. IndexCode string
  348. }
  349. type UpdateRule struct {
  350. RuleDesc string `json:"rule_desc"`
  351. Notice string `json:"notice"`
  352. ReleaseTime string `json:"release_time"`
  353. RuleInfo UpdateRuleInfo `json:"rule_info"`
  354. }
  355. type UpdateRuleInfo struct {
  356. UpdCal string `json:"upd_cal"`
  357. UpdCalUnit string `json:"upd_cal_unit"`
  358. PeriodOffset int `json:"period_offset"`
  359. UpdCount int `json:"upd_count"`
  360. }
  361. type DataItem struct {
  362. QuotaID string `json:"quota_id"`
  363. QuotaName string `json:"quota_name"`
  364. Mark string `json:"mark"`
  365. Unit string `json:"unit"`
  366. ValueType string `json:"value_type"`
  367. Source string `json:"source"`
  368. ListOrder int `json:"list_order"`
  369. DataStart string `json:"data_start"`
  370. DataEnd string `json:"data_end"`
  371. Frequency string `json:"frequency"`
  372. Precision int `json:"precision"`
  373. TypeCode string `json:"type_code"`
  374. TypeName string `json:"type_name"`
  375. TypeCodeAll string `json:"type_code_all"`
  376. TypeAll string `json:"type_all"`
  377. Tags string `json:"tags"`
  378. AuthStart string `json:"auth_start"`
  379. AuthFinish string `json:"auth_finish"`
  380. AuthLang string `json:"auth_lang"`
  381. AuthModule string `json:"auth_module"`
  382. DataDur string `json:"data_dur"`
  383. Spec string `json:"spec"`
  384. Area string `json:"area"`
  385. DataState string `json:"data_state"`
  386. UpdateRule UpdateRule `json:"update_rule"`
  387. }
  388. type ListData struct {
  389. Total int `json:"total"`
  390. CurrentPage int `json:"current_page"`
  391. PageSize int `json:"page_size"`
  392. PageCount int `json:"page_count"`
  393. Data []DataItem `json:"data"`
  394. }
  395. type SmmIndexListResponse struct {
  396. Code int `json:"code"`
  397. Msg string `json:"msg"`
  398. Data ListData `json:"data"`
  399. }
  400. type SmmListResp struct {
  401. Code int `json:"code"`
  402. Msg string `json:"msg"`
  403. Data SmmIndexListResponse `json:"data"`
  404. }
  405. func AddBaseFromSmmIndex(list []*BaseFromSmmIndex) (lastId int64, err error) {
  406. o := orm.NewOrm()
  407. _, err = o.InsertMulti(len(list), list)
  408. return
  409. }
  410. // BridgeZhongJiIndexLatestDataParams 桥接服务-获取中基更新指标数据入参
  411. type BridgeZhongJiIndexLatestDataParams struct {
  412. EdbCode string `json:"edb_code" form:"edb_code" description:"指标编码"`
  413. LastTime int64 `json:"last_time" form:"last_time" description:"上次更新时间戳(秒)"`
  414. }
  415. func GetBaseFromSmmIndex() (list []*BaseFromSmmIndex, err error) {
  416. o := orm.NewOrm()
  417. sql := ` SELECT * FROM base_from_smm_index`
  418. _, err = o.Raw(sql).QueryRows(&list)
  419. return
  420. }
  421. func ModifyBaseFromSmmIndex(item *BaseFromSmmIndex) (err error) {
  422. o := orm.NewOrm()
  423. sql := ` UPDATE base_from_smm_index SET end_date = ?, modify_time=NOW(), data_state= ? `
  424. _, err = o.Raw(sql, item.EndDate, item.DataState).Exec()
  425. return
  426. }
  427. func (m *BaseFromSmmIndex) UpdateCols(cols []string) (err error) {
  428. o := orm.NewOrm()
  429. _, err = o.Update(m, cols...)
  430. return
  431. }
  432. func ModifyBaseFromSmmIndexDate(item *BaseFromSmmIndex) (err error) {
  433. o := orm.NewOrm()
  434. sql := ` UPDATE base_from_smm_index SET end_date = ?, modify_time=NOW(), data_state= ? WHERE base_from_smm_index_id=?`
  435. _, err = o.Raw(sql, item.EndDate, item.DataState, item.BaseFromSmmIndexId).Exec()
  436. return
  437. }
  438. type SmmLatestDataResponse struct {
  439. Code int `json:"code"`
  440. Msg string `json:"msg"`
  441. Data SmmLatestResp `json:"data"`
  442. }
  443. type SmmLatestResp struct {
  444. Code int `json:"code"`
  445. Msg string `json:"msg"`
  446. Data SmmLatestData `json:"data"`
  447. }
  448. type SmmLatestData struct {
  449. DataLen int `json:"data_len"`
  450. DataList []Datum `json:"data_list"`
  451. }
  452. type Datum struct {
  453. QuotaID string `json:"quota_id"`
  454. Date string `json:"date"`
  455. Value string `json:"value"`
  456. Mark string `json:"mark"`
  457. Create string `json:"create"`
  458. Update string `json:"update"`
  459. }
  460. // RefreshEdbDataFromSmmToEdb 刷新有色指标数据
  461. func RefreshEdbDataFromSmmToEdb(edbInfoId int, edbCode, startDate string, smmDataList []*BaseFromSmmData) (err error) {
  462. source := utils.DATA_SOURCE_YS
  463. subSource := utils.DATA_SUB_SOURCE_EDB
  464. o := orm.NewOrm()
  465. if err != nil {
  466. return
  467. }
  468. edbInfoIdStr := strconv.Itoa(edbInfoId)
  469. //计算数据
  470. var condition string
  471. var pars []interface{}
  472. if edbCode != "" {
  473. condition += " AND index_code=? "
  474. pars = append(pars, edbCode)
  475. }
  476. if startDate != "" {
  477. condition += " AND data_time>=? "
  478. pars = append(pars, startDate)
  479. }
  480. // 真实数据的最大日期 , 插入规则配置的日期
  481. var realDataMaxDate, edbDataInsertConfigDate time.Time
  482. var edbDataInsertConfig *EdbDataInsertConfig
  483. var isFindConfigDateRealData bool //是否找到配置日期的实际数据的值
  484. {
  485. edbDataInsertConfig, err = GetEdbDataInsertConfigByEdbId(edbInfoId)
  486. if err != nil && err.Error() != utils.ErrNoRow() {
  487. return
  488. }
  489. if edbDataInsertConfig != nil {
  490. edbDataInsertConfigDate = edbDataInsertConfig.Date
  491. }
  492. }
  493. var existCondition string
  494. var existPars []interface{}
  495. existCondition += " AND edb_info_id=? "
  496. existPars = append(existPars, edbInfoId)
  497. if startDate != "" {
  498. existCondition += " AND data_time>=? "
  499. existPars = append(existPars, startDate)
  500. }
  501. existList, err := GetEdbDataByCondition(source, subSource, existCondition, existPars)
  502. if err != nil {
  503. return err
  504. }
  505. existMap := make(map[string]*EdbInfoSearchData)
  506. for _, v := range existList {
  507. existMap[v.DataTime] = v
  508. }
  509. addSql := ` INSERT INTO edb_data_ys(edb_info_id,edb_code,data_time,value,create_time,modify_time,data_timestamp) values `
  510. var isAdd bool
  511. for _, v := range smmDataList {
  512. item := v
  513. eDate := item.DataTime
  514. dataTime, err := time.ParseInLocation(utils.FormatDate, eDate, time.Local)
  515. if err != nil {
  516. return err
  517. }
  518. if findItem, ok := existMap[v.DataTime]; !ok {
  519. sValue := item.Value
  520. timestamp := dataTime.UnixNano() / 1e6
  521. timeStr := fmt.Sprintf("%d", timestamp)
  522. addSql += GetAddSql(edbInfoIdStr, edbCode, eDate, timeStr, sValue)
  523. isAdd = true
  524. } else {
  525. if findItem != nil && utils.SubFloatToString(findItem.Value, 30) != item.Value {
  526. err = ModifyEdbDataById(source, subSource, findItem.EdbDataId, item.Value)
  527. if err != nil {
  528. return err
  529. }
  530. }
  531. }
  532. // 下面代码主要目的是处理掉手动插入的数据判断
  533. {
  534. if realDataMaxDate.IsZero() || dataTime.After(realDataMaxDate) {
  535. realDataMaxDate = dataTime
  536. }
  537. if edbDataInsertConfigDate.IsZero() || dataTime.Equal(edbDataInsertConfigDate) {
  538. isFindConfigDateRealData = true
  539. }
  540. }
  541. }
  542. // 处理手工数据补充的配置
  543. HandleConfigInsertEdbData(realDataMaxDate, edbDataInsertConfig, edbInfoId, source, subSource, existMap, isFindConfigDateRealData)
  544. if isAdd {
  545. addSql = strings.TrimRight(addSql, ",")
  546. _, err = o.Raw(addSql).Exec()
  547. if err != nil {
  548. fmt.Println("RefreshEdbDataFromSmm add Err", err.Error())
  549. return
  550. }
  551. }
  552. return
  553. }
  554. type BaseFromSmmRecord struct {
  555. BaseFromSmmRecordId int64 `orm:"column(base_from_smm_record_id);pk"`
  556. BaseFromSmmIndexId int64
  557. OldIndexName string `description:"原始名称"`
  558. NewIndexName string `description:"新的名称"`
  559. CreateTime time.Time `description:"记录创建时间"`
  560. Timestamp int64 `description:"记录创建时间戳"`
  561. }
  562. func AddBaseFromSmmRecord(item *BaseFromSmmRecord) (err error) {
  563. o := orm.NewOrm()
  564. _, err = o.Insert(item)
  565. return
  566. }