edb_info.go 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  1. package data
  2. import (
  3. "context"
  4. "errors"
  5. "eta/eta_task/models/data_manage"
  6. "eta/eta_task/services/alarm_msg"
  7. "eta/eta_task/utils"
  8. "fmt"
  9. "strconv"
  10. "strings"
  11. "sync"
  12. "time"
  13. )
  14. // RefreshDataFromThs 刷新同花顺数据
  15. func RefreshDataFromThs(wg *sync.WaitGroup) (err error) {
  16. errMsgList := make([]string, 0)
  17. defer func() {
  18. if err != nil {
  19. fmt.Println("RefreshDataFromThs Err:" + err.Error())
  20. go alarm_msg.SendAlarmMsg("RefreshDataFromThs ErrMsg:"+err.Error(), 3)
  21. }
  22. if len(errMsgList) > 0 {
  23. errMsg := "RefreshDataFromThs Err:" + strings.Join(errMsgList, "\n")
  24. fmt.Println(errMsg)
  25. go alarm_msg.SendAlarmMsg(errMsg, 3)
  26. }
  27. wg.Done()
  28. }()
  29. var condition string
  30. var pars []interface{}
  31. condition += " AND source=? "
  32. pars = append(pars, utils.DATA_SOURCE_THS)
  33. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  34. if err != nil {
  35. err = errors.New("GetEdbInfoByCondition:" + err.Error())
  36. return
  37. }
  38. for _, v := range items {
  39. startDate := ""
  40. if v.Frequency == "日度" {
  41. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  42. } else if v.Frequency == "周度" {
  43. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  44. } else if v.Frequency == "月度" {
  45. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  46. } else if v.Frequency == "季度" {
  47. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  48. } else if v.Frequency == "年度" {
  49. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  50. } else {
  51. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  52. }
  53. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  54. if err != nil {
  55. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  56. continue
  57. }
  58. if resp.Ret != 200 {
  59. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  60. continue
  61. }
  62. }
  63. return err
  64. }
  65. // RefreshDataFromWind 刷新万得数据
  66. func RefreshDataFromWind(wg *sync.WaitGroup) (err error) {
  67. errMsgList := make([]string, 0)
  68. defer func() {
  69. if err != nil {
  70. fmt.Println("RefreshDataFromWind Err:" + err.Error())
  71. go alarm_msg.SendAlarmMsg("RefreshDataFromWind ErrMsg:"+err.Error(), 3)
  72. }
  73. if len(errMsgList) > 0 {
  74. errMsg := "RefreshDataFromWind Err:" + strings.Join(errMsgList, "\n")
  75. fmt.Println(errMsg)
  76. go alarm_msg.SendAlarmMsg(errMsg, 3)
  77. }
  78. wg.Done()
  79. }()
  80. var condition string
  81. var pars []interface{}
  82. condition += ` AND source=? AND no_update = 0 `
  83. pars = append(pars, utils.DATA_SOURCE_WIND)
  84. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  85. if err != nil {
  86. return err
  87. }
  88. for _, v := range items {
  89. startDate := ""
  90. if v.Frequency == "日度" {
  91. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  92. } else if v.Frequency == "周度" {
  93. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  94. } else if v.Frequency == "月度" {
  95. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  96. } else if v.Frequency == "季度" {
  97. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  98. } else if v.Frequency == "年度" {
  99. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  100. } else {
  101. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  102. }
  103. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  104. if err != nil {
  105. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  106. continue
  107. }
  108. if resp.Ret != 200 {
  109. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  110. continue
  111. }
  112. }
  113. fmt.Println("wind刷新结束")
  114. return err
  115. }
  116. // RefreshDataFromPb 刷新彭博数据
  117. func RefreshDataFromPb(wg *sync.WaitGroup) (err error) {
  118. errMsgList := make([]string, 0)
  119. defer func() {
  120. if err != nil {
  121. fmt.Println("RefreshDataFromPb Err:" + err.Error())
  122. go alarm_msg.SendAlarmMsg("RefreshDataFromPb ErrMsg:"+err.Error(), 3)
  123. }
  124. if len(errMsgList) > 0 {
  125. errMsg := "RefreshDataFromPb Err:" + strings.Join(errMsgList, "\n")
  126. fmt.Println(errMsg)
  127. go alarm_msg.SendAlarmMsg(errMsg, 3)
  128. }
  129. wg.Done()
  130. }()
  131. if utils.PbRefreshOpen == "0" {
  132. return
  133. }
  134. var condition string
  135. var pars []interface{}
  136. var frequencyStr string
  137. if utils.PbRefreshFrequency == "" {
  138. frequencyStr = "'日度','周度'"
  139. } else {
  140. frequencyStr = utils.PbRefreshFrequency
  141. }
  142. condition += " AND source=? AND frequency in (" + frequencyStr + ") "
  143. pars = append(pars, utils.DATA_SOURCE_PB)
  144. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  145. if err != nil {
  146. return errors.New("GetEdbInfoByCondition:" + err.Error())
  147. }
  148. nowDate := time.Now().Format(utils.FormatDate)
  149. sunDay := int(time.Now().Weekday())
  150. for _, v := range items {
  151. startDate := ""
  152. if v.Frequency == "日度" {
  153. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  154. if v.EndDate.Format(utils.FormatDate) == nowDate {
  155. continue
  156. }
  157. } else if v.Frequency == "周度" {
  158. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  159. if sunDay != 0 {
  160. continue
  161. }
  162. } else if v.Frequency == "月度" {
  163. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  164. } else if v.Frequency == "季度" {
  165. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  166. } else if v.Frequency == "年度" {
  167. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  168. } else {
  169. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  170. }
  171. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  172. if err != nil {
  173. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  174. continue
  175. }
  176. if resp.Ret != 200 {
  177. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  178. continue
  179. }
  180. }
  181. return err
  182. }
  183. // RefreshDataFromPbFinance 刷新彭博财务指标数据
  184. func RefreshDataFromPbFinance(wg *sync.WaitGroup) (err error) {
  185. errMsgList := make([]string, 0)
  186. defer func() {
  187. if err != nil {
  188. fmt.Println("RefreshDataFromPb Err:" + err.Error())
  189. //go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromPb ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  190. go alarm_msg.SendAlarmMsg("RefreshDataFromPb ErrMsg:"+err.Error(), 3)
  191. }
  192. if len(errMsgList) > 0 {
  193. errMsg := "RefreshDataFromPbFinance Err:" + strings.Join(errMsgList, "\n")
  194. fmt.Println(errMsg)
  195. go alarm_msg.SendAlarmMsg(errMsg, 3)
  196. }
  197. wg.Done()
  198. }()
  199. var condition string
  200. var pars []interface{}
  201. condition += " AND source=? "
  202. pars = append(pars, utils.DATA_SOURCE_PB_FINANCE)
  203. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  204. if err != nil {
  205. return errors.New("GetEdbInfoByCondition:" + err.Error())
  206. }
  207. for _, v := range items {
  208. startDate := ""
  209. if v.Frequency == "日度" {
  210. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  211. } else if v.Frequency == "周度" {
  212. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  213. } else if v.Frequency == "月度" {
  214. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  215. } else if v.Frequency == "季度" {
  216. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  217. } else if v.Frequency == "年度" {
  218. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  219. } else {
  220. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  221. }
  222. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  223. if err != nil {
  224. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  225. continue
  226. }
  227. if resp.Ret != 200 {
  228. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  229. continue
  230. }
  231. }
  232. return err
  233. }
  234. // RefreshDataFromCalculateAll 刷新所有计算指标
  235. func RefreshDataFromCalculateAll() (err error) {
  236. errMsgList := make([]string, 0)
  237. defer func() {
  238. if err != nil {
  239. errMsg := "刷新所有计算指标失败 ErrMsg:" + err.Error()
  240. utils.FileLog.Info(errMsg)
  241. go alarm_msg.SendAlarmMsg(errMsg, 3)
  242. }
  243. if len(errMsgList) > 0 {
  244. utils.FileLog.Info("刷新所有计算指标失败 ErrMsg:" + strings.Join(errMsgList, "\n"))
  245. go alarm_msg.SendAlarmMsg("刷新所有计算指标失败 ErrMsg:"+strings.Join(errMsgList, "\n"), 3)
  246. }
  247. }()
  248. var condition string
  249. var pars []interface{}
  250. // 查询 普通指标的计算指标
  251. condition += " AND edb_type=? AND edb_info_type=? AND no_update=0"
  252. pars = append(pars, 2, 0)
  253. condition += " AND edb_info_id NOT IN( SELECT edb_info_id FROM edb_info_calculate_mapping WHERE from_edb_info_id>edb_info_id) "
  254. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  255. if err != nil {
  256. return err
  257. }
  258. nowStr := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
  259. startDateOfWeek := utils.GetNowWeekMonday()
  260. endDateOfWeek := utils.GetNowWeekLastDay()
  261. for _, v := range items {
  262. if v.Frequency == "日度" {
  263. if v.EndDate.Format(utils.FormatDate) == nowStr {
  264. continue
  265. }
  266. } else if v.Frequency == "周度" {
  267. if !v.EndDate.Before(startDateOfWeek) && !v.EndDate.After(endDateOfWeek) {
  268. continue
  269. }
  270. }
  271. source := v.Source
  272. startDate := v.StartDate.Format(utils.FormatDate)
  273. if startDate == "0001-01-01" {
  274. continue
  275. }
  276. fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source)
  277. fmt.Println("RefreshEdbCalculateData", v.EdbInfoId, v.EdbCode, startDate)
  278. result, tmpErr := RefreshEdbCalculateData(v.EdbInfoId, v.EdbCode, startDate)
  279. if tmpErr != nil {
  280. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;err:%s", v.EdbInfoId, v.EdbCode, tmpErr.Error()))
  281. continue
  282. }
  283. if result.Ret != 200 {
  284. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;msg:%s;errMsg:%s", v.EdbInfoId, v.EdbCode, result.Msg, result.ErrMsg))
  285. //return err
  286. continue
  287. }
  288. }
  289. return err
  290. }
  291. // RefreshBasePredictDataAll 刷新所有的基础预测指标
  292. func RefreshBasePredictDataAll() (err error) {
  293. errMsgList := make([]string, 0)
  294. defer func() {
  295. if err != nil {
  296. errMsg := "刷新所有计算指标失败 ErrMsg:" + err.Error()
  297. utils.FileLog.Info(errMsg)
  298. go alarm_msg.SendAlarmMsg(errMsg, 3)
  299. }
  300. if len(errMsgList) > 0 {
  301. utils.FileLog.Info("刷新所有基础预测指标失败 ErrMsg:" + strings.Join(errMsgList, "\n"))
  302. go alarm_msg.SendAlarmMsg("刷新所有基础预测指标失败 ErrMsg:"+strings.Join(errMsgList, "\n"), 3)
  303. }
  304. }()
  305. var condition string
  306. var pars []interface{}
  307. // 查询 普通指标的计算指标
  308. condition += " AND edb_type=? AND edb_info_type=? "
  309. pars = append(pars, 1, 1)
  310. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  311. if err != nil {
  312. errMsgList = append(errMsgList, fmt.Sprintf("获取基础预测指标列表失败;err:%s", err.Error()))
  313. return err
  314. }
  315. for _, v := range items {
  316. source := v.Source
  317. startDate := v.StartDate.Format(utils.FormatDate)
  318. if startDate == "0001-01-01" {
  319. continue
  320. }
  321. fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source, "======RefreshBasePredictDataAll:", startDate)
  322. result, tmpErr := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  323. if tmpErr != nil {
  324. errMsgList = append(errMsgList, fmt.Sprintf("刷新基础预测指标失败1,指标ID:%d;指标编码:%s;err:%s", v.EdbInfoId, v.EdbCode, tmpErr.Error()))
  325. continue
  326. }
  327. if result.Ret != 200 {
  328. errMsgList = append(errMsgList, fmt.Sprintf("刷新基础预测指标失败2,指标ID:%d;指标编码:%s;报错提示信息msg:%s;报错信息err:%s", v.EdbInfoId, v.EdbCode, result.ErrMsg, result.Msg))
  329. continue
  330. }
  331. }
  332. return err
  333. }
  334. // RefreshPredictDataFromCalculateAll 刷新所有预测计算指标
  335. func RefreshPredictDataFromCalculateAll() (err error) {
  336. errMsgList := make([]string, 0)
  337. defer func() {
  338. if err != nil {
  339. errMsg := "刷新所有计算预测指标失败 ErrMsg:" + err.Error()
  340. utils.FileLog.Info(errMsg)
  341. go alarm_msg.SendAlarmMsg(errMsg, 3)
  342. }
  343. if len(errMsgList) > 0 {
  344. utils.FileLog.Info("刷新所有计算预测指标失败 Err:" + strings.Join(errMsgList, "\n"))
  345. go alarm_msg.SendAlarmMsg("刷新所有计算预测指标失败 Err:"+strings.Join(errMsgList, "\n"), 3)
  346. }
  347. }()
  348. var condition string
  349. var pars []interface{}
  350. // 查询 普通指标的计算指标
  351. condition += " AND edb_type=? AND edb_info_type=? "
  352. pars = append(pars, 2, 1)
  353. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  354. if err != nil {
  355. return err
  356. }
  357. for _, v := range items {
  358. source := v.Source
  359. startDate := v.StartDate.Format(utils.FormatDate)
  360. if startDate == "0001-01-01" {
  361. continue
  362. }
  363. fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source, "======RefreshPredictEdbCalculateData:", startDate)
  364. result, tmpErr := RefreshPredictEdbCalculateData(v.EdbInfoId, v.EdbCode, startDate)
  365. if tmpErr != nil {
  366. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;err:%s", v.EdbInfoId, v.EdbCode, tmpErr.Error()))
  367. continue
  368. }
  369. if result.Ret != 200 {
  370. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;msg:%s;errMsg:%s", v.EdbInfoId, v.EdbCode, result.Msg, result.ErrMsg))
  371. continue
  372. }
  373. }
  374. return err
  375. }
  376. // RefreshDataFromManual 刷新手工指标数据
  377. func RefreshDataFromManual(wg *sync.WaitGroup) (err error) {
  378. errMsgList := make([]string, 0)
  379. defer func() {
  380. if err != nil {
  381. fmt.Println("RefreshDataFromManual Err:" + err.Error())
  382. go alarm_msg.SendAlarmMsg("RefreshDataFromManual ErrMsg:"+err.Error(), 3)
  383. }
  384. if len(errMsgList) > 0 {
  385. errMsg := "RefreshDataFromManual Err:" + strings.Join(errMsgList, "\n")
  386. fmt.Println(errMsg)
  387. go alarm_msg.SendAlarmMsg(errMsg, 3)
  388. }
  389. wg.Done()
  390. }()
  391. var condition string
  392. var pars []interface{}
  393. condition += " AND source=? "
  394. pars = append(pars, utils.DATA_SOURCE_MANUAL)
  395. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  396. if err != nil {
  397. return errors.New("GetEdbInfoByCondition:" + err.Error())
  398. }
  399. for _, v := range items {
  400. startDate := v.StartDate.Format(utils.FormatDate)
  401. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  402. if err != nil {
  403. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  404. continue
  405. }
  406. if resp.Ret != 200 {
  407. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  408. continue
  409. }
  410. }
  411. return err
  412. }
  413. func ResetEdbInfoIsUpdate(cont context.Context) (err error) {
  414. go data_manage.ResetEdbInfoIsUpdate()
  415. return nil
  416. }
  417. // RefreshDataFromGoogleTravel RefreshDataFromEic 刷新谷歌出行数据
  418. func RefreshDataFromGoogleTravel(wg *sync.WaitGroup) (err error) {
  419. errMsgList := make([]string, 0)
  420. defer func() {
  421. if err != nil {
  422. fmt.Println("RefreshDataFromGoogleTravel Err:" + err.Error())
  423. go alarm_msg.SendAlarmMsg("RefreshDataFromGoogleTravel ErrMsg:"+err.Error(), 3)
  424. }
  425. if len(errMsgList) > 0 {
  426. tips := fmt.Sprintf("RefreshDataFromGoogleTravel ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  427. fmt.Println(tips)
  428. utils.FileLog.Info(tips)
  429. go alarm_msg.SendAlarmMsg(tips, 3)
  430. }
  431. wg.Done()
  432. }()
  433. var condition string
  434. var pars []interface{}
  435. condition += " AND source=? "
  436. pars = append(pars, utils.DATA_SOURCE_GOOGLE_TRAVEL)
  437. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  438. if err != nil {
  439. return errors.New("GetEdbInfoByCondition:" + err.Error())
  440. }
  441. for _, v := range items {
  442. startDate := ""
  443. if v.Frequency == "日度" {
  444. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  445. } else if v.Frequency == "周度" {
  446. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  447. } else if v.Frequency == "月度" {
  448. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  449. } else if v.Frequency == "季度" {
  450. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  451. } else if v.Frequency == "年度" {
  452. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  453. } else {
  454. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  455. }
  456. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  457. if err != nil {
  458. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  459. continue
  460. }
  461. if resp.Ret != 200 {
  462. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  463. continue
  464. }
  465. }
  466. return err
  467. }
  468. // RefreshDataFromEiaSteo 刷新eia steo 报告数据
  469. func RefreshDataFromEiaSteo(wg *sync.WaitGroup) (err error) {
  470. errMsgList := make([]string, 0)
  471. defer func() {
  472. if err != nil {
  473. fmt.Println("RefreshDataFromEiaSteo Err:" + err.Error())
  474. go alarm_msg.SendAlarmMsg("RefreshDataFromEiaSteo ErrMsg:"+err.Error(), 3)
  475. }
  476. if len(errMsgList) > 0 {
  477. tips := fmt.Sprintf("RefreshDataFromEiaSteo ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  478. fmt.Println(tips)
  479. utils.FileLog.Info(tips)
  480. go alarm_msg.SendAlarmMsg(tips, 3)
  481. }
  482. wg.Done()
  483. }()
  484. var condition string
  485. var pars []interface{}
  486. condition += " AND source=? "
  487. pars = append(pars, utils.DATA_SOURCE_EIA_STEO)
  488. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  489. if err != nil {
  490. return errors.New("GetEdbInfoByCondition:" + err.Error())
  491. }
  492. for _, v := range items {
  493. startDate := ""
  494. if v.Frequency == "日度" {
  495. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  496. } else if v.Frequency == "周度" {
  497. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  498. } else if v.Frequency == "月度" {
  499. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  500. } else if v.Frequency == "季度" {
  501. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  502. } else if v.Frequency == "年度" {
  503. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  504. } else {
  505. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  506. }
  507. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  508. if err != nil {
  509. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  510. continue
  511. }
  512. if resp.Ret != 200 {
  513. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  514. continue
  515. }
  516. }
  517. return err
  518. }
  519. // RefreshDataFromYs 刷新有色数据
  520. func RefreshDataFromYs(wg *sync.WaitGroup) (err error) {
  521. errMsgList := make([]string, 0)
  522. defer func() {
  523. if err != nil {
  524. fmt.Println("RefreshDataFromYs Err:" + err.Error())
  525. //go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "RefreshDataFromYs ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  526. go alarm_msg.SendAlarmMsg("RefreshDataFromYs ErrMsg:"+err.Error(), 3)
  527. }
  528. if len(errMsgList) > 0 {
  529. errMsg := "RefreshDataFromYs Err:" + strings.Join(errMsgList, "\n")
  530. fmt.Println(errMsg)
  531. go alarm_msg.SendAlarmMsg(errMsg, 3)
  532. }
  533. wg.Done()
  534. }()
  535. var condition string
  536. var pars []interface{}
  537. condition += " AND source=? "
  538. pars = append(pars, utils.DATA_SOURCE_YS)
  539. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  540. if err != nil {
  541. return errors.New("GetEdbInfoByCondition:" + err.Error())
  542. }
  543. for _, v := range items {
  544. startDate := ""
  545. if v.Frequency == "日度" {
  546. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  547. } else if v.Frequency == "周度" {
  548. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  549. } else if v.Frequency == "月度" {
  550. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  551. } else if v.Frequency == "季度" {
  552. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  553. } else if v.Frequency == "年度" {
  554. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  555. } else {
  556. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  557. }
  558. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  559. if err != nil {
  560. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  561. continue
  562. }
  563. if resp.Ret != 200 {
  564. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  565. continue
  566. }
  567. }
  568. return err
  569. }
  570. // 刷新钢联数据
  571. func RefreshDataFromGl(wg *sync.WaitGroup) (err error) {
  572. errMsgList := make([]string, 0)
  573. defer func() {
  574. if err != nil {
  575. fmt.Println("RefreshDataFromGl Err:" + err.Error())
  576. go alarm_msg.SendAlarmMsg("RefreshDataFromGl ErrMsg:"+err.Error(), 3)
  577. }
  578. if len(errMsgList) > 0 {
  579. tips := fmt.Sprintf("RefreshDataFromGl ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  580. fmt.Println(tips)
  581. utils.FileLog.Info(tips)
  582. go alarm_msg.SendAlarmMsg(tips, 3)
  583. }
  584. wg.Done()
  585. }()
  586. var condition string
  587. var pars []interface{}
  588. condition += " AND source=? "
  589. pars = append(pars, utils.DATA_SOURCE_GL)
  590. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  591. if err != nil {
  592. return errors.New("GetEdbInfoByCondition:" + err.Error())
  593. }
  594. for _, v := range items {
  595. startDate := ""
  596. if v.Frequency == "日度" {
  597. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  598. } else if v.Frequency == "周度" {
  599. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  600. } else if v.Frequency == "月度" {
  601. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  602. } else if v.Frequency == "季度" {
  603. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  604. } else if v.Frequency == "年度" {
  605. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  606. } else {
  607. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  608. }
  609. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  610. if err != nil {
  611. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  612. continue
  613. }
  614. if resp.Ret != 200 {
  615. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  616. continue
  617. }
  618. }
  619. return err
  620. }
  621. // RefreshDataFromLt 刷新路透数据
  622. func RefreshDataFromLt(wg *sync.WaitGroup) (err error) {
  623. errMsgList := make([]string, 0)
  624. defer func() {
  625. if len(errMsgList) > 0 {
  626. tips := fmt.Sprintf("RefreshDataFromLt ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  627. fmt.Println(tips)
  628. utils.FileLog.Info(tips)
  629. go alarm_msg.SendAlarmMsg(tips, 3)
  630. }
  631. utils.FileLog.Info("RefreshDataFromLt刷新结束")
  632. wg.Done()
  633. }()
  634. var condition string
  635. var pars []interface{}
  636. condition += " AND source=? "
  637. pars = append(pars, utils.DATA_SOURCE_LT)
  638. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  639. if err != nil {
  640. errMsgList = append(errMsgList, "GetEdbInfoByCondition:"+err.Error())
  641. return errors.New("GetEdbInfoByCondition:" + err.Error())
  642. }
  643. for _, v := range items {
  644. fmt.Println(v.EdbCode, v.Frequency, v.EndDate)
  645. startDate := v.StartDate.Format(utils.FormatDate)
  646. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  647. if err != nil {
  648. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  649. continue
  650. }
  651. if resp.Ret != 200 {
  652. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  653. continue
  654. }
  655. }
  656. return err
  657. }
  658. // RefreshDataFromCoal 刷新煤炭网数据
  659. func RefreshDataFromCoal(wg *sync.WaitGroup) (err error) {
  660. errMsgList := make([]string, 0)
  661. defer func() {
  662. if err != nil {
  663. fmt.Println("RefreshDataFromCoal Err:" + err.Error())
  664. go alarm_msg.SendAlarmMsg("RefreshDataFromCoal ErrMsg:"+err.Error(), 3)
  665. }
  666. if len(errMsgList) > 0 {
  667. tips := fmt.Sprintf("RefreshDataFromCoal ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  668. fmt.Println(tips)
  669. utils.FileLog.Info(tips)
  670. go alarm_msg.SendAlarmMsg(tips, 3)
  671. }
  672. wg.Done()
  673. }()
  674. var condition string
  675. var pars []interface{}
  676. condition += " AND source=? "
  677. pars = append(pars, utils.DATA_SOURCE_COAL)
  678. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  679. if err != nil {
  680. return errors.New("GetEdbInfoByCondition:" + err.Error())
  681. }
  682. for _, v := range items {
  683. startDate := ""
  684. if v.Frequency == "日度" {
  685. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  686. } else if v.Frequency == "周度" {
  687. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  688. } else if v.Frequency == "月度" {
  689. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  690. } else if v.Frequency == "季度" {
  691. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  692. } else if v.Frequency == "年度" {
  693. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  694. } else {
  695. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  696. }
  697. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  698. if err != nil {
  699. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  700. continue
  701. }
  702. if resp.Ret != 200 {
  703. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  704. continue
  705. }
  706. }
  707. return err
  708. }
  709. // RefreshDataFromMysteelChemical 刷新钢联化工数据
  710. func RefreshDataFromMysteelChemical(wg *sync.WaitGroup) (err error) {
  711. errMsgList := make([]string, 0)
  712. defer func() {
  713. if err != nil {
  714. fmt.Println("RefreshDataFromMysteelChemical Err:" + err.Error())
  715. go alarm_msg.SendAlarmMsg("RefreshDataFromMysteelChemical ErrMsg:"+err.Error(), 3)
  716. }
  717. if len(errMsgList) > 0 {
  718. tips := fmt.Sprintf("RefreshDataFromMysteelChemical ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  719. fmt.Println(tips)
  720. utils.FileLog.Info(tips)
  721. go alarm_msg.SendAlarmMsg(tips, 3)
  722. }
  723. wg.Done()
  724. }()
  725. var condition string
  726. var pars []interface{}
  727. condition += " AND source=? AND no_update = 0 "
  728. pars = append(pars, utils.DATA_SOURCE_MYSTEEL_CHEMICAL)
  729. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  730. if err != nil {
  731. return errors.New("GetEdbInfoByCondition:" + err.Error())
  732. }
  733. for _, v := range items {
  734. startDate := ""
  735. if v.Frequency == "日度" {
  736. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  737. } else if v.Frequency == "周度" {
  738. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  739. } else if v.Frequency == "月度" {
  740. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  741. } else if v.Frequency == "季度" {
  742. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  743. } else if v.Frequency == "年度" {
  744. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  745. } else {
  746. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  747. }
  748. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  749. if err != nil {
  750. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  751. continue
  752. }
  753. if resp.Ret != 200 {
  754. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  755. continue
  756. }
  757. }
  758. return err
  759. }
  760. // RefreshDataFromComTrade 刷新 UN 数据
  761. func RefreshDataFromComTrade(wg *sync.WaitGroup) (err error) {
  762. errMsgList := make([]string, 0)
  763. defer func() {
  764. if err != nil {
  765. fmt.Println("RefreshDataFromComTrade Err:" + err.Error())
  766. go alarm_msg.SendAlarmMsg("RefreshDataFromComTrade ErrMsg:"+err.Error(), 3)
  767. }
  768. if len(errMsgList) > 0 {
  769. tips := fmt.Sprintf("RefreshDataFromComTrade ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  770. fmt.Println(tips)
  771. utils.FileLog.Info(tips)
  772. go alarm_msg.SendAlarmMsg(tips, 3)
  773. }
  774. wg.Done()
  775. }()
  776. var condition string
  777. var pars []interface{}
  778. condition += " AND source=? "
  779. pars = append(pars, utils.DATA_SOURCE_COM_TRADE)
  780. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  781. if err != nil {
  782. return errors.New("GetEdbInfoByCondition:" + err.Error())
  783. }
  784. for _, v := range items {
  785. startDate := ""
  786. if v.Frequency == "日度" {
  787. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  788. } else if v.Frequency == "周度" {
  789. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  790. } else if v.Frequency == "月度" {
  791. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  792. } else if v.Frequency == "季度" {
  793. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  794. } else if v.Frequency == "年度" {
  795. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  796. } else {
  797. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  798. }
  799. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  800. if err != nil {
  801. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  802. continue
  803. }
  804. if resp.Ret != 200 {
  805. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  806. continue
  807. }
  808. }
  809. return err
  810. }
  811. // RefreshDataFromSci 刷新 卓创 数据
  812. func RefreshDataFromSci(wg *sync.WaitGroup) (err error) {
  813. errMsgList := make([]string, 0)
  814. defer func() {
  815. if err != nil {
  816. fmt.Println("RefreshDataFromSci Err:" + err.Error())
  817. go alarm_msg.SendAlarmMsg("RefreshDataFromSci ErrMsg:"+err.Error(), 3)
  818. }
  819. if len(errMsgList) > 0 {
  820. tips := fmt.Sprintf("RefreshDataFromSci ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  821. fmt.Println(tips)
  822. utils.FileLog.Info(tips)
  823. go alarm_msg.SendAlarmMsg(tips, 3)
  824. }
  825. wg.Done()
  826. }()
  827. var condition string
  828. var pars []interface{}
  829. condition += " AND source=? "
  830. pars = append(pars, utils.DATA_SOURCE_SCI)
  831. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  832. if err != nil {
  833. return errors.New("GetEdbInfoByCondition:" + err.Error())
  834. }
  835. for _, v := range items {
  836. startDate := ""
  837. if v.Frequency == "日度" {
  838. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  839. } else if v.Frequency == "周度" {
  840. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  841. } else if v.Frequency == "月度" {
  842. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  843. } else if v.Frequency == "季度" {
  844. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  845. } else if v.Frequency == "年度" {
  846. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  847. } else {
  848. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  849. }
  850. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  851. if err != nil {
  852. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  853. continue
  854. }
  855. if resp.Ret != 200 {
  856. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  857. continue
  858. }
  859. }
  860. return err
  861. }
  862. // RefreshDataFromNationalStatistics 刷新统计局数据
  863. func RefreshDataFromNationalStatistics(wg *sync.WaitGroup) (err error) {
  864. errMsgList := make([]string, 0)
  865. defer func() {
  866. if err != nil {
  867. fmt.Println("RefreshDataFromNationalStatistics Err:" + err.Error())
  868. go alarm_msg.SendAlarmMsg("RefreshDataFromNationalStatistics ErrMsg:"+err.Error(), 3)
  869. }
  870. if len(errMsgList) > 0 {
  871. tips := fmt.Sprintf("RefreshDataFromNationalStatistics ErrMsg: %s", strings.Join(errMsgList, `<br/>`))
  872. fmt.Println(tips)
  873. utils.FileLog.Info(tips)
  874. go alarm_msg.SendAlarmMsg(tips, 3)
  875. }
  876. wg.Done()
  877. }()
  878. var condition string
  879. var pars []interface{}
  880. condition += ` AND source = ? `
  881. pars = append(pars, utils.DATA_SOURCE_NATIONAL_STATISTICS)
  882. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  883. if err != nil {
  884. return errors.New("GetEdbInfoByCondition:" + err.Error())
  885. }
  886. for _, v := range items {
  887. startDate := ""
  888. if v.Frequency == "日度" {
  889. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  890. } else if v.Frequency == "周度" {
  891. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  892. } else if v.Frequency == "月度" {
  893. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  894. } else if v.Frequency == "季度" {
  895. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  896. } else if v.Frequency == "年度" {
  897. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  898. } else {
  899. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  900. }
  901. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  902. if err != nil {
  903. errMsgList = append(errMsgList, "RefreshEdbData Err:"+err.Error())
  904. continue
  905. }
  906. if resp.Ret != 200 {
  907. errMsgList = append(errMsgList, "RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  908. continue
  909. }
  910. }
  911. return err
  912. }
  913. // RefreshDataFromEic 刷欧洲天然气数据
  914. func RefreshDataFromEic(wg *sync.WaitGroup) (err error) {
  915. defer func() {
  916. if err != nil {
  917. fmt.Println("RefreshDataFromEic Err:" + err.Error())
  918. go alarm_msg.SendAlarmMsg("RefreshDataFromEic ErrMsg:"+err.Error(), 3)
  919. }
  920. wg.Done()
  921. }()
  922. var condition string
  923. var pars []interface{}
  924. condition += " AND source=? "
  925. pars = append(pars, utils.DATA_SOURCE_GIE)
  926. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  927. if err != nil {
  928. return errors.New("GetEdbInfoByCondition:" + err.Error())
  929. }
  930. for _, v := range items {
  931. startDate := ""
  932. if v.Frequency == "日度" {
  933. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  934. } else if v.Frequency == "周度" {
  935. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  936. } else if v.Frequency == "月度" {
  937. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  938. } else if v.Frequency == "季度" {
  939. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  940. } else if v.Frequency == "年度" {
  941. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  942. } else {
  943. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  944. }
  945. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  946. if err != nil {
  947. return errors.New("RefreshEdbData Err:" + err.Error())
  948. }
  949. if resp.Ret != 200 {
  950. return errors.New("RefreshEdbData Err:" + resp.Msg + ";ErrMsg:" + resp.ErrMsg)
  951. }
  952. }
  953. return err
  954. }
  955. // RefreshJiaYueDataFromBridge 嘉悦物产-刷新数据宝指标
  956. func RefreshJiaYueDataFromBridge(cont context.Context) (err error) {
  957. utils.FileLog.Info(fmt.Sprintf("嘉悦-开始刷新数据宝指标: %s", time.Now().Format(utils.FormatDateTime)))
  958. defer func() {
  959. if err != nil {
  960. tips := fmt.Sprintf("RefreshJiaYueDataFromBridge ErrMsg: %s", err.Error())
  961. utils.FileLog.Info(tips)
  962. go alarm_msg.SendAlarmMsg(tips, 3)
  963. }
  964. utils.FileLog.Info(fmt.Sprintf("嘉悦-结束刷新数据宝指标: %s", time.Now().Format(utils.FormatDateTime)))
  965. }()
  966. // 获取来自桥接服务的指标来源
  967. cond := ` AND from_bridge = 1`
  968. pars := make([]interface{}, 0)
  969. sources, e := data_manage.GetEdbSourceItemsByCondition(cond, pars, []string{}, "")
  970. if e != nil {
  971. err = fmt.Errorf("获取来自桥接服务的数据源失败, err: %s", e.Error())
  972. return
  973. }
  974. sourceArr := make([]string, 0)
  975. for _, v := range sources {
  976. if v.EdbSourceId <= 0 {
  977. continue
  978. }
  979. sourceArr = append(sourceArr, strconv.Itoa(v.EdbSourceId))
  980. }
  981. if len(sourceArr) == 0 {
  982. utils.FileLog.Info("RefreshJiaYueDataFromBridge 无数据来源")
  983. return
  984. }
  985. // 获取指标
  986. edbCond := fmt.Sprintf(` AND source IN (%s)`, utils.GetOrmInReplace(len(sourceArr)))
  987. edbPars := make([]interface{}, 0)
  988. edbPars = append(edbPars, sourceArr)
  989. items, e := data_manage.GetEdbInfoByCondition(edbCond, edbPars, 0)
  990. if e != nil {
  991. err = fmt.Errorf("GetEdbInfoByCondition err: %s", e.Error())
  992. return
  993. }
  994. for _, v := range items {
  995. startDate := ""
  996. if v.Frequency == "日度" {
  997. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  998. } else if v.Frequency == "周度" {
  999. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  1000. } else if v.Frequency == "月度" {
  1001. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  1002. } else if v.Frequency == "季度" {
  1003. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  1004. } else if v.Frequency == "年度" {
  1005. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  1006. } else {
  1007. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1008. }
  1009. resp, e := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1010. if e != nil {
  1011. utils.FileLog.Info(fmt.Sprintf("RefreshEdbData err: %s", e.Error()))
  1012. //err = fmt.Errorf("RefreshEdbData err: %s", e.Error())
  1013. continue
  1014. }
  1015. if resp.Ret != 200 {
  1016. utils.FileLog.Info(fmt.Sprintf("RefreshEdbData indexCode: %s, err: %s, errMsg: %s", v.EdbCode, resp.Msg, resp.ErrMsg))
  1017. //err = fmt.Errorf("RefreshEdbData Err: %s; ErrMsg: %s", resp.Msg, resp.ErrMsg)
  1018. continue
  1019. }
  1020. }
  1021. return
  1022. }
  1023. // RefreshDataFromFubao 刷新富宝数据
  1024. func RefreshDataFromFubao(wg *sync.WaitGroup) (err error) {
  1025. errMsgList := make([]string, 0)
  1026. defer func() {
  1027. if err != nil {
  1028. fmt.Println("RefreshDataFromFubao Err:" + err.Error())
  1029. go alarm_msg.SendAlarmMsg("RefreshDataFromFubao ErrMsg:"+err.Error(), 3)
  1030. }
  1031. if len(errMsgList) > 0 {
  1032. errMsg := "RefreshDataFromFubao Err:" + strings.Join(errMsgList, "\n")
  1033. fmt.Println(errMsg)
  1034. go alarm_msg.SendAlarmMsg(errMsg, 3)
  1035. }
  1036. wg.Done()
  1037. }()
  1038. var condition string
  1039. var pars []interface{}
  1040. condition += ` AND source=? AND no_update = 0 `
  1041. pars = append(pars, utils.DATA_SOURCE_FUBAO)
  1042. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1043. if err != nil {
  1044. return err
  1045. }
  1046. for _, v := range items {
  1047. startDate := ""
  1048. if v.Frequency == "日度" {
  1049. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1050. } else if v.Frequency == "周度" {
  1051. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  1052. } else if v.Frequency == "月度" {
  1053. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  1054. } else if v.Frequency == "季度" {
  1055. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  1056. } else if v.Frequency == "年度" {
  1057. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  1058. } else {
  1059. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1060. }
  1061. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1062. if err != nil {
  1063. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  1064. continue
  1065. }
  1066. if resp.Ret != 200 {
  1067. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  1068. continue
  1069. }
  1070. }
  1071. fmt.Println("Fubao刷新结束")
  1072. return err
  1073. }
  1074. // RefreshDataFromBloomberg 刷新Bloomberg
  1075. func RefreshDataFromBloomberg(wg *sync.WaitGroup) (err error) {
  1076. errMsgList := make([]string, 0)
  1077. defer func() {
  1078. if err != nil {
  1079. fmt.Println("RefreshDataFromBloomberg Err:" + err.Error())
  1080. go alarm_msg.SendAlarmMsg("RefreshDataFromBloomberg ErrMsg:"+err.Error(), 3)
  1081. }
  1082. if len(errMsgList) > 0 {
  1083. errMsg := "RefreshDataFromBloomberg Err:" + strings.Join(errMsgList, "\n")
  1084. fmt.Println(errMsg)
  1085. go alarm_msg.SendAlarmMsg(errMsg, 3)
  1086. }
  1087. wg.Done()
  1088. }()
  1089. var condition string
  1090. var pars []interface{}
  1091. condition += ` AND source = ? AND no_update = 0 `
  1092. pars = append(pars, utils.DATA_SOURCE_BLOOMBERG)
  1093. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1094. if err != nil {
  1095. return err
  1096. }
  1097. for _, v := range items {
  1098. startDate := ""
  1099. if v.Frequency == "日度" {
  1100. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1101. } else if v.Frequency == "周度" {
  1102. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  1103. } else if v.Frequency == "月度" {
  1104. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  1105. } else if v.Frequency == "季度" {
  1106. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  1107. } else if v.Frequency == "年度" {
  1108. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  1109. } else {
  1110. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1111. }
  1112. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1113. if err != nil {
  1114. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  1115. continue
  1116. }
  1117. if resp.Ret != 200 {
  1118. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  1119. continue
  1120. }
  1121. }
  1122. fmt.Println("Bloomberg刷新结束")
  1123. return err
  1124. }
  1125. // RefreshDataFromCCF 刷新CCF化纤信息
  1126. func RefreshDataFromCCF(wg *sync.WaitGroup) (err error) {
  1127. errMsgList := make([]string, 0)
  1128. defer func() {
  1129. if err != nil {
  1130. tips := fmt.Sprintf("RefreshDataFromCCF err: %v", err)
  1131. utils.FileLog.Info(tips)
  1132. go alarm_msg.SendAlarmMsg(tips, 3)
  1133. }
  1134. if len(errMsgList) > 0 {
  1135. tips := fmt.Sprintf("RefreshDataFromCCF ErrMsg: %s", strings.Join(errMsgList, "\n"))
  1136. utils.FileLog.Info(tips)
  1137. go alarm_msg.SendAlarmMsg(tips, 3)
  1138. }
  1139. wg.Done()
  1140. }()
  1141. var condition string
  1142. var pars []interface{}
  1143. condition += ` AND source = ? AND no_update = 0 `
  1144. pars = append(pars, utils.DATA_SOURCE_CCF)
  1145. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1146. if err != nil {
  1147. return err
  1148. }
  1149. for _, v := range items {
  1150. startDate := ""
  1151. if v.Frequency == "日度" {
  1152. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1153. } else if v.Frequency == "周度" {
  1154. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  1155. } else if v.Frequency == "月度" {
  1156. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  1157. } else if v.Frequency == "季度" {
  1158. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  1159. } else if v.Frequency == "年度" {
  1160. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  1161. } else {
  1162. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1163. }
  1164. resp, err := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1165. if err != nil {
  1166. errMsgList = append(errMsgList, v.EdbCode+"RefreshEdbData Err:"+err.Error())
  1167. continue
  1168. }
  1169. if resp.Ret != 200 {
  1170. errMsgList = append(errMsgList, v.EdbCode+";RefreshEdbData Err:"+resp.Msg+";ErrMsg:"+resp.ErrMsg)
  1171. continue
  1172. }
  1173. }
  1174. fmt.Println("CCF化纤信息刷新结束")
  1175. return err
  1176. }
  1177. // RefreshBaseDataFromSource
  1178. // @Description: 刷新基础数据
  1179. // @author: Roc
  1180. // @datetime 2024-08-01 18:10:03
  1181. // @param wg *sync.WaitGroup
  1182. // @param source int
  1183. // @return err error
  1184. func RefreshBaseDataFromSource(wg *sync.WaitGroup, source int) (err error) {
  1185. errMsgList := make([]string, 0)
  1186. defer func() {
  1187. if err != nil {
  1188. errMsg := fmt.Sprintf("刷新基础数据失败,来源:%d,ErrMsg:%s", source, err.Error())
  1189. utils.FileLog.Info(errMsg)
  1190. go alarm_msg.SendAlarmMsg(errMsg, 3)
  1191. }
  1192. if len(errMsgList) > 0 {
  1193. errMsg := fmt.Sprintf("刷新基础数据失败,来源:%d,ErrMsg:%s", source, strings.Join(errMsgList, "\n"))
  1194. utils.FileLog.Info(errMsg)
  1195. go alarm_msg.SendAlarmMsg(errMsg, 3)
  1196. }
  1197. wg.Done()
  1198. }()
  1199. var condition string
  1200. var pars []interface{}
  1201. condition += " AND source=? "
  1202. pars = append(pars, source)
  1203. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1204. if err != nil {
  1205. return errors.New("GetEdbInfoByCondition:" + err.Error())
  1206. }
  1207. for _, v := range items {
  1208. startDate := ""
  1209. if v.Frequency == "日度" {
  1210. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1211. } else if v.Frequency == "周度" {
  1212. startDate = v.EndDate.AddDate(0, 0, -(utils.DATA_REFRESH * 7)).Format(utils.FormatDate)
  1213. } else if v.Frequency == "月度" {
  1214. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH, 0).Format(utils.FormatDate)
  1215. } else if v.Frequency == "季度" {
  1216. startDate = v.EndDate.AddDate(0, -utils.DATA_REFRESH*3, 0).Format(utils.FormatDate)
  1217. } else if v.Frequency == "年度" {
  1218. startDate = v.EndDate.AddDate(-utils.DATA_REFRESH, 0, 0).Format(utils.FormatDate)
  1219. } else {
  1220. startDate = v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1221. }
  1222. resp, tmpErr := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1223. if err != nil {
  1224. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;err:%s", v.EdbInfoId, v.EdbCode, tmpErr.Error()))
  1225. continue
  1226. }
  1227. if resp.Ret != 200 {
  1228. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;msg:%s;errMsg:%s", v.EdbInfoId, v.EdbCode, resp.Msg, resp.ErrMsg))
  1229. continue
  1230. }
  1231. }
  1232. return err
  1233. }
  1234. // RefreshDataFromTradeAnalysis 刷新持仓分析指标
  1235. func RefreshDataFromTradeAnalysis(wg *sync.WaitGroup) (err error) {
  1236. utils.FileLog.Info(fmt.Sprintf("持仓分析指标刷新开始: %s", time.Now().Format(utils.FormatDateTime)))
  1237. errMsgList := make([]string, 0)
  1238. defer func() {
  1239. if err != nil {
  1240. tips := fmt.Sprintf("RefreshDataFromTradeAnalysis err: %v", err)
  1241. utils.FileLog.Info(tips)
  1242. go alarm_msg.SendAlarmMsg(tips, 3)
  1243. }
  1244. if len(errMsgList) > 0 {
  1245. tips := fmt.Sprintf("RefreshDataFromTradeAnalysis ErrMsg: %s", strings.Join(errMsgList, "\n"))
  1246. utils.FileLog.Info(tips)
  1247. go alarm_msg.SendAlarmMsg(tips, 3)
  1248. }
  1249. wg.Done()
  1250. }()
  1251. var condition string
  1252. var pars []interface{}
  1253. condition += ` AND source = ? AND no_update = 0 `
  1254. pars = append(pars, utils.DATA_SOURCE_TRADE_ANALYSIS)
  1255. items, e := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1256. if e != nil {
  1257. err = fmt.Errorf("获取持仓分析指标失败, %v", e)
  1258. return
  1259. }
  1260. for _, v := range items {
  1261. // 持仓分析指标只有日度
  1262. startDate := v.EndDate.AddDate(0, 0, -utils.DATA_REFRESH).Format(utils.FormatDate)
  1263. resp, e := RefreshEdbData(v.EdbInfoId, v.Source, v.SubSource, v.EdbCode, startDate)
  1264. if e != nil {
  1265. errMsgList = append(errMsgList, fmt.Sprintf("EdbCode: %s, RefreshEdbData err: %v", v.EdbCode, e))
  1266. continue
  1267. }
  1268. if resp.Ret != 200 {
  1269. errMsgList = append(errMsgList, fmt.Sprintf("EdbCode: %s, RefreshEdbData err: %v, errMsg: %s", v.EdbCode, e, resp.ErrMsg))
  1270. continue
  1271. }
  1272. }
  1273. utils.FileLog.Info(fmt.Sprintf("持仓分析指标刷新结束: %s", time.Now().Format(utils.FormatDateTime)))
  1274. return err
  1275. }
  1276. // 刷新计算指标-当比当前计算指标id大的依赖指标刷新完之后,再进行指标刷新
  1277. func RefreshDataFromCalculateAfter() (err error) {
  1278. errMsgList := make([]string, 0)
  1279. defer func() {
  1280. if err != nil {
  1281. errMsg := "刷新所有计算指标失败 ErrMsg:" + err.Error()
  1282. utils.FileLog.Info(errMsg)
  1283. go alarm_msg.SendAlarmMsg(errMsg, 3)
  1284. }
  1285. if len(errMsgList) > 0 {
  1286. utils.FileLog.Info("刷新所有计算指标失败 ErrMsg:" + strings.Join(errMsgList, "\n"))
  1287. go alarm_msg.SendAlarmMsg("刷新所有计算指标失败 ErrMsg:"+strings.Join(errMsgList, "\n"), 3)
  1288. }
  1289. }()
  1290. var condition string
  1291. var pars []interface{}
  1292. // 查询 普通指标的计算指标
  1293. condition += " AND edb_type=? AND edb_info_type=? AND no_update=0"
  1294. pars = append(pars, 2, 0)
  1295. condition += " AND edb_info_id IN( SELECT edb_info_id FROM edb_info_calculate_mapping WHERE from_edb_info_id>edb_info_id) "
  1296. items, err := data_manage.GetEdbInfoByCondition(condition, pars, 0)
  1297. if err != nil {
  1298. return err
  1299. }
  1300. nowStr := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
  1301. startDateOfWeek := utils.GetNowWeekMonday()
  1302. endDateOfWeek := utils.GetNowWeekLastDay()
  1303. for _, v := range items {
  1304. if v.Frequency == "日度" {
  1305. if v.EndDate.Format(utils.FormatDate) == nowStr {
  1306. continue
  1307. }
  1308. } else if v.Frequency == "周度" {
  1309. if !v.EndDate.Before(startDateOfWeek) && !v.EndDate.After(endDateOfWeek) {
  1310. continue
  1311. }
  1312. }
  1313. source := v.Source
  1314. startDate := v.StartDate.Format(utils.FormatDate)
  1315. if startDate == "0001-01-01" {
  1316. continue
  1317. }
  1318. fmt.Println(v.EdbInfoId, v.EdbCode, v.EdbName, v.SourceName, source)
  1319. fmt.Println("RefreshEdbCalculateData", v.EdbInfoId, v.EdbCode, startDate)
  1320. result, tmpErr := RefreshEdbCalculateData(v.EdbInfoId, v.EdbCode, startDate)
  1321. if tmpErr != nil {
  1322. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;err:%s", v.EdbInfoId, v.EdbCode, tmpErr.Error()))
  1323. continue
  1324. }
  1325. if result.Ret != 200 {
  1326. errMsgList = append(errMsgList, fmt.Sprintf("指标ID:%d;指标编码:%s;msg:%s;errMsg:%s", v.EdbInfoId, v.EdbCode, result.Msg, result.ErrMsg))
  1327. //return err
  1328. continue
  1329. }
  1330. }
  1331. return err
  1332. }