edb_info_refresh.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. package data
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "eta/eta_api/models/data_manage"
  6. "eta/eta_api/models/data_manage/edb_refresh"
  7. "eta/eta_api/models/data_manage/edb_refresh/request"
  8. "eta/eta_api/utils"
  9. "fmt"
  10. "strings"
  11. "time"
  12. )
  13. // 所有刷新配置key
  14. var allDefaultEdbRefreshConfigKey = `edb_refresh_config:default:all:`
  15. // GetAllDefaultEdbRefreshConfigListBySourceList
  16. // @Description: 获取默认的所有刷新配置列表
  17. // @author: Roc
  18. // @datetime 2024-01-10 15:03:36
  19. // @param source int
  20. // @param subSource int
  21. // @return list []*edb_refresh.EdbRefreshDefaultConfig
  22. // @return err error
  23. func GetAllDefaultEdbRefreshConfigListBySourceList(source, subSource int) (list []*edb_refresh.EdbRefreshDefaultConfig, err error) {
  24. key := getAllDefaultEdbRefreshConfigKey(source, subSource)
  25. if utils.Re == nil {
  26. if utils.Re == nil && utils.Rc.IsExist(key) {
  27. if data, err1 := utils.Rc.RedisBytes(key); err1 == nil {
  28. err = json.Unmarshal(data, &list)
  29. return
  30. }
  31. }
  32. }
  33. list, err = edb_refresh.GetAllListBySourceList(source, subSource)
  34. if err != nil {
  35. return
  36. }
  37. // 将数据加入缓存
  38. if utils.Re == nil {
  39. data, _ := json.Marshal(list)
  40. utils.Rc.Put(key, data, 2*time.Hour)
  41. }
  42. return
  43. }
  44. // SaveEdbRefreshDefaultConfig
  45. // @Description: 设置默认的指标刷新配置接口
  46. // @author: Roc
  47. // @datetime 2024-01-10 15:11:19
  48. // @param source int
  49. // @param subSource int
  50. // @param frequency string
  51. // @param list []request.RefreshConfigReq
  52. // @return err error
  53. // @return errMsg string
  54. // @return isSendEmail bool
  55. func SaveEdbRefreshDefaultConfig(source, subSource int, frequency string, list []request.RefreshConfigReq) (err error, errMsg string, isSendEmail bool) {
  56. isSendEmail = true
  57. errMsg = `保存失败`
  58. if source <= 0 {
  59. errMsg = "来源不能为空"
  60. err = errors.New(errMsg)
  61. isSendEmail = false
  62. return
  63. }
  64. // 非有色的来源,频度不能为空
  65. if source != utils.DATA_SOURCE_YS && frequency == `` {
  66. errMsg = "频度不能为空"
  67. err = errors.New(errMsg)
  68. isSendEmail = false
  69. return
  70. }
  71. lenConf := len(list)
  72. if lenConf == 0 {
  73. errMsg = "至少需要一个刷新配置"
  74. err = errors.New(errMsg)
  75. isSendEmail = false
  76. return
  77. }
  78. if lenConf > 5 {
  79. errMsg = "刷新时间设置最多不超过5个"
  80. err = errors.New(errMsg)
  81. isSendEmail = false
  82. return
  83. }
  84. tmpArr := []string{"每周", "每旬", "每月", "每季", "每半年", "每年"}
  85. // 配置的map,避免同一种类型配置同一个时间
  86. configMap := make(map[string]string)
  87. for _, v := range list {
  88. if utils.InArrayByStr(tmpArr, v.RefreshFrequency) && v.RefreshFrequencyDay < 0 {
  89. errMsg = "请选择具体日期"
  90. err = errors.New(errMsg)
  91. isSendEmail = false
  92. return
  93. }
  94. if v.RefreshTime == "" {
  95. errMsg = "请选择具体时间"
  96. err = errors.New(errMsg)
  97. isSendEmail = false
  98. return
  99. }
  100. // 配置的map,避免同一种类型配置同一个时间
  101. key := fmt.Sprint(v.RefreshFrequency, "_", v.RefreshFrequencyDay, "_", v.RefreshTime)
  102. if _, ok := configMap[key]; ok {
  103. errMsg = "刷新频率和日期不能重复"
  104. err = errors.New(errMsg)
  105. isSendEmail = false
  106. return
  107. }
  108. configMap[key] = key
  109. }
  110. addList := make([]*edb_refresh.EdbRefreshDefaultConfig, 0)
  111. for _, v := range list {
  112. addList = append(addList, &edb_refresh.EdbRefreshDefaultConfig{
  113. Source: source,
  114. SubSource: subSource,
  115. Frequency: frequency,
  116. RefreshFrequency: v.RefreshFrequency,
  117. RefreshFrequencyDay: v.RefreshFrequencyDay,
  118. RefreshAllData: v.RefreshAllData,
  119. RefreshTime: v.RefreshTime,
  120. RefreshDataNum: v.RefreshDataNum,
  121. ModifyTime: time.Now(),
  122. CreateTime: time.Now(),
  123. })
  124. }
  125. // 保存
  126. err = edb_refresh.SaveEdbRefreshDefaultConfig(source, subSource, frequency, addList)
  127. // 清除缓存
  128. {
  129. key := getAllDefaultEdbRefreshConfigKey(source, subSource)
  130. if utils.Re == nil {
  131. _ = utils.Rc.Delete(key)
  132. }
  133. }
  134. return
  135. }
  136. // SaveEdbRefreshConfig
  137. // @Description: 设置指标刷新配置接口
  138. // @author: Roc
  139. // @datetime 2024-01-10 15:41:45
  140. // @param source int
  141. // @param subSource int
  142. // @param classifyId string
  143. // @param terminalCode string
  144. // @param frequency string
  145. // @param keyword string
  146. // @param status string
  147. // @param sysUserIdStr string
  148. // @param isSelectAll bool
  149. // @param list []request.RefreshConfigReq
  150. // @param edbSelectIdList []int
  151. // @param sysUserId int
  152. // @param sysUserRealName string
  153. // @return err error
  154. // @return errMsg string
  155. // @return isSendEmail bool
  156. func SaveEdbRefreshConfig(source, subSource int, classifyId, terminalCode, frequency, keyword, status, sysUserIdStr string, isSelectAll bool, list []request.RefreshConfigReq, edbSelectIdList []int, sysUserId int, sysUserRealName string) (err error, errMsg string, isSendEmail bool) {
  157. isSendEmail = true
  158. errMsg = `保存失败`
  159. if source <= 0 {
  160. errMsg = "来源不能为空"
  161. err = errors.New(errMsg)
  162. isSendEmail = false
  163. return
  164. }
  165. lenConf := len(list)
  166. if lenConf == 0 {
  167. errMsg = "至少需要一个刷新配置"
  168. err = errors.New(errMsg)
  169. isSendEmail = false
  170. return
  171. }
  172. if lenConf > 5 {
  173. errMsg = "刷新时间设置最多不超过5个"
  174. err = errors.New(errMsg)
  175. isSendEmail = false
  176. return
  177. }
  178. tmpArr := []string{"每周", "每旬", "每月", "每季", "每半年", "每年"}
  179. // 配置的map,避免同一种类型配置同一个时间
  180. configMap := make(map[string]string)
  181. for _, v := range list {
  182. if utils.InArrayByStr(tmpArr, v.RefreshFrequency) && v.RefreshFrequencyDay < 0 {
  183. errMsg = "请选择具体日期"
  184. err = errors.New(errMsg)
  185. isSendEmail = false
  186. return
  187. }
  188. if v.RefreshTime == "" {
  189. errMsg = "请选择具体时间"
  190. err = errors.New(errMsg)
  191. isSendEmail = false
  192. return
  193. }
  194. // 配置的map,避免同一种类型配置同一个时间
  195. key := fmt.Sprint(v.RefreshFrequency, "_", v.RefreshFrequencyDay, "_", v.RefreshTime)
  196. if _, ok := configMap[key]; ok {
  197. errMsg = "刷新频率和日期不能重复"
  198. err = errors.New(errMsg)
  199. isSendEmail = false
  200. return
  201. }
  202. configMap[key] = key
  203. }
  204. edbIdList := make([]int, 0)
  205. // 指标id列表
  206. if isSelectAll {
  207. // 如果是列表全选
  208. _, edbList, tmpErr := GetList(source, subSource, classifyId, terminalCode, sysUserIdStr, frequency, keyword, status, 0, 100000, "", "")
  209. if tmpErr != nil && tmpErr.Error() != utils.ErrNoRow() {
  210. err = tmpErr
  211. return
  212. }
  213. // 不配置的指标id
  214. notIdMap := make(map[int]int, 0)
  215. for _, v := range edbSelectIdList {
  216. notIdMap[v] = v
  217. }
  218. for _, v := range edbList {
  219. _, ok := notIdMap[v.EdbInfoId]
  220. // 在不配置的指标id列表内的话,那就过滤
  221. if ok {
  222. continue
  223. }
  224. // 加入到待配置的指标列表id
  225. edbIdList = append(edbIdList, v.EdbInfoId)
  226. }
  227. } else {
  228. edbIdList = edbSelectIdList
  229. }
  230. if len(edbIdList) <= 0 {
  231. errMsg = "指标不能为空"
  232. err = errors.New(errMsg)
  233. isSendEmail = false
  234. return
  235. }
  236. // 待添加的配置关系数据
  237. addMappingList := make([]*edb_refresh.EdbRefreshMapping, 0)
  238. // 待添加的日期配置项
  239. addConfigList := make([]*edb_refresh.EdbRefreshConfig, 0)
  240. for _, v := range list {
  241. item, tmpErr := edb_refresh.GetEdbRefreshConfigListByCondition(v.RefreshFrequency, v.RefreshTime, v.RefreshFrequencyDay, v.RefreshAllData, v.RefreshDataNum)
  242. if tmpErr != nil {
  243. if tmpErr.Error() != utils.ErrNoRow() {
  244. err = tmpErr
  245. return
  246. }
  247. addConfigList = append(addConfigList, &edb_refresh.EdbRefreshConfig{
  248. RefreshFrequency: v.RefreshFrequency,
  249. RefreshFrequencyDay: v.RefreshFrequencyDay,
  250. RefreshTime: v.RefreshTime,
  251. RefreshAllData: v.RefreshAllData,
  252. RefreshDataNum: v.RefreshDataNum,
  253. ModifyTime: time.Now(),
  254. CreateTime: time.Now(),
  255. })
  256. continue
  257. }
  258. for _, edbId := range edbIdList {
  259. addMappingList = append(addMappingList, &edb_refresh.EdbRefreshMapping{
  260. EdbRefreshMappingId: 0,
  261. Source: source,
  262. SubSource: subSource,
  263. EdbInfoId: edbId,
  264. EdbRefreshConfigId: item.EdbRefreshConfigId,
  265. SysUserId: sysUserId,
  266. SysUserRealName: sysUserRealName,
  267. ModifyTime: time.Now(),
  268. CreateTime: time.Now(),
  269. })
  270. }
  271. }
  272. // 保存
  273. err = edb_refresh.SaveEdbRefreshConfig(source, subSource, sysUserId, sysUserRealName, addConfigList, addMappingList, edbIdList)
  274. return
  275. }
  276. // HandleRefreshTime
  277. // @Description: 处理刷新时间的显示
  278. // @author: Roc
  279. // @datetime 2024-01-10 17:00:03
  280. // @param source int
  281. // @param subSource int
  282. // @param list []*data_manage.BaseRefreshEdbInfo
  283. // @return newList []*data_manage.BaseRefreshEdbInfo
  284. // @return err error
  285. // @return errMsg string
  286. // @return isSendEmail bool
  287. func HandleRefreshTime(source, subSource int, list []*data_manage.BaseRefreshEdbInfo) (newList []*data_manage.BaseRefreshEdbInfo, err error, errMsg string, isSendEmail bool) {
  288. isSendEmail = true
  289. errMsg = "获取失败"
  290. newList = list
  291. // 默认刷新配置
  292. defaultEdbRefreshConfigMap := make(map[string]string)
  293. {
  294. // 获取默认配置
  295. allDefaultEdbRefreshConfigList, tmpErr := GetAllDefaultEdbRefreshConfigListBySourceList(source, subSource)
  296. if tmpErr != nil {
  297. err = tmpErr
  298. return
  299. }
  300. defaultEdbRefreshConfigListMap := make(map[string][]string)
  301. for _, v := range allDefaultEdbRefreshConfigList {
  302. tmp, ok := defaultEdbRefreshConfigListMap[v.Frequency]
  303. if !ok {
  304. tmp = make([]string, 0)
  305. }
  306. defaultEdbRefreshConfigListMap[v.Frequency] = append(tmp, GetRefreshStr(v.RefreshFrequency, v.RefreshFrequencyDay, v.RefreshTime))
  307. }
  308. for k, v := range defaultEdbRefreshConfigListMap {
  309. defaultEdbRefreshConfigMap[k] = strings.Join(v, ",")
  310. }
  311. }
  312. edbInfoIdList := make([]int, 0)
  313. for _, v := range newList {
  314. edbInfoIdList = append(edbInfoIdList, v.EdbInfoId)
  315. }
  316. // 指标的刷新时间配置
  317. edbRefreshConfigMap := make(map[int]string)
  318. {
  319. // 获取指标的单独配置
  320. configList, tmpErr := edb_refresh.GetEdbRefreshConfigAndEdbListBySourceAndeEdbInfoId(source, subSource, edbInfoIdList)
  321. if tmpErr != nil {
  322. err = tmpErr
  323. return
  324. }
  325. edbRefreshConfigListMap := make(map[int][]string)
  326. for _, v := range configList {
  327. tmp, ok := edbRefreshConfigListMap[v.EdbInfoId]
  328. if !ok {
  329. tmp = make([]string, 0)
  330. }
  331. edbRefreshConfigListMap[v.EdbInfoId] = append(tmp, GetRefreshStr(v.RefreshFrequency, v.RefreshFrequencyDay, v.RefreshTime))
  332. }
  333. for k, v := range edbRefreshConfigListMap {
  334. edbRefreshConfigMap[k] = strings.Join(v, ",")
  335. }
  336. }
  337. // 处理刷新时间
  338. for _, v := range newList {
  339. refreshTime, ok := edbRefreshConfigMap[v.EdbInfoId]
  340. if ok {
  341. v.RefreshTime = refreshTime
  342. continue
  343. }
  344. if source == utils.DATA_SOURCE_YS {
  345. v.RefreshTime = defaultEdbRefreshConfigMap[``]
  346. } else {
  347. v.RefreshTime = defaultEdbRefreshConfigMap[v.Frequency]
  348. }
  349. }
  350. return
  351. }
  352. // GetList
  353. // @Description: 获取指标列表
  354. // @author: Roc
  355. // @datetime 2024-01-08 15:14:16
  356. // @param source int
  357. // @param subSource int
  358. // @param classifyId string
  359. // @param terminalCode string
  360. // @param sysUserId string
  361. // @param frequency string
  362. // @param keyword string
  363. // @param startSize int
  364. // @param pageSize int
  365. // @return total int
  366. // @return list []*data_manage.BaseRefreshEdbInfo
  367. // @return err error
  368. func GetList(source, subSource int, classifyId, terminalCode, sysUserId, frequency, keyword, status string, startSize, pageSize int, sortParam, sortType string) (total int, list []*data_manage.BaseRefreshEdbInfo, err error) {
  369. var pars []interface{}
  370. var condition string
  371. list = make([]*data_manage.BaseRefreshEdbInfo, 0)
  372. isStop := -1
  373. if status == `暂停` {
  374. isStop = 1
  375. } else if status == "启用" {
  376. isStop = 0
  377. }
  378. switch source {
  379. case utils.DATA_SOURCE_MYSTEEL_CHEMICAL: // 钢联
  380. if classifyId != `` {
  381. classifyIdSlice := strings.Split(classifyId, ",")
  382. condition += ` AND base_from_mysteel_chemical_classify_id IN (` + utils.GetOrmInReplace(len(classifyIdSlice)) + `)`
  383. pars = append(pars, classifyIdSlice)
  384. }
  385. if terminalCode != `` {
  386. condition += " AND terminal_code = ? "
  387. pars = append(pars, terminalCode)
  388. }
  389. if sysUserId != `` {
  390. sysUserIdSlice := strings.Split(sysUserId, ",")
  391. condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
  392. pars = append(pars, sysUserIdSlice)
  393. }
  394. if frequency != `` {
  395. frequencySlice := strings.Split(frequency, ",")
  396. condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencySlice)) + `)`
  397. pars = append(pars, frequencySlice)
  398. }
  399. if keyword != `` {
  400. keywordSlice := strings.Split(keyword, " ")
  401. if len(keywordSlice) > 0 {
  402. tmpConditionSlice := make([]string, 0)
  403. tmpConditionSlice = append(tmpConditionSlice, ` index_name like ? or index_code like ? `)
  404. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  405. for _, v := range keywordSlice {
  406. if v == ` ` || v == `` {
  407. continue
  408. }
  409. tmpConditionSlice = append(tmpConditionSlice, ` index_name like ? or index_code like ? `)
  410. pars = utils.GetLikeKeywordPars(pars, v, 2)
  411. }
  412. condition += ` AND (` + strings.Join(tmpConditionSlice, " or ") + `)`
  413. } else {
  414. condition += ` index_name like ? or index_code like ? `
  415. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  416. }
  417. }
  418. if isStop >= 0 {
  419. condition += " AND is_stop = ? "
  420. pars = append(pars, isStop)
  421. }
  422. sortStr := ``
  423. if sortParam != `` {
  424. sortStr = fmt.Sprintf("%s %s,base_from_mysteel_chemical_index_id desc ", sortParam, sortType)
  425. }
  426. total, list, err = data_manage.GetMysteelChemicalBaseInfoList(condition, pars, sortStr, startSize, pageSize)
  427. case utils.DATA_SOURCE_YS: // 有色
  428. if classifyId != `` {
  429. classifyIdSlice := strings.Split(classifyId, ",")
  430. condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdSlice)) + `)`
  431. pars = append(pars, classifyIdSlice)
  432. }
  433. if terminalCode != `` {
  434. condition += " AND terminal_code = ? "
  435. pars = append(pars, terminalCode)
  436. }
  437. if frequency != `` {
  438. frequencySlice := strings.Split(frequency, ",")
  439. condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencySlice)) + `)`
  440. pars = append(pars, frequencySlice)
  441. }
  442. if keyword != `` {
  443. keywordSlice := strings.Split(keyword, " ")
  444. if len(keywordSlice) > 0 {
  445. tmpConditionSlice := make([]string, 0)
  446. tmpConditionSlice = append(tmpConditionSlice, ` index_name like ? or index_code like ? `)
  447. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  448. for _, v := range keywordSlice {
  449. if v == ` ` || v == `` {
  450. continue
  451. }
  452. tmpConditionSlice = append(tmpConditionSlice, ` index_name like ? or index_code like ? `)
  453. pars = utils.GetLikeKeywordPars(pars, v, 2)
  454. }
  455. condition += ` AND (` + strings.Join(tmpConditionSlice, " or ") + `)`
  456. } else {
  457. condition += ` index_name like ? or index_code like ? `
  458. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  459. }
  460. }
  461. if isStop >= 0 {
  462. condition += " AND is_stop = ? "
  463. pars = append(pars, isStop)
  464. }
  465. sortStr := ``
  466. if sortParam != `` {
  467. sortStr = fmt.Sprintf("%s %s,base_from_smm_index_id desc ", sortParam, sortType)
  468. }
  469. total, list, err = data_manage.GetSmmBaseInfoList(condition, pars, sortStr, startSize, pageSize)
  470. default:
  471. condition += ` AND source = ? AND sub_source = ? `
  472. pars = append(pars, source, subSource)
  473. if isStop >= 0 {
  474. condition += " AND no_update = ? "
  475. pars = append(pars, isStop)
  476. }
  477. if classifyId != `` {
  478. classifyIdSlice := strings.Split(classifyId, ",")
  479. condition += ` AND classify_id IN (` + utils.GetOrmInReplace(len(classifyIdSlice)) + `)`
  480. pars = append(pars, classifyIdSlice)
  481. }
  482. if terminalCode != `` {
  483. condition += " AND terminal_code = ? "
  484. pars = append(pars, terminalCode)
  485. }
  486. if sysUserId != `` {
  487. sysUserIdSlice := strings.Split(sysUserId, ",")
  488. condition += ` AND sys_user_id IN (` + utils.GetOrmInReplace(len(sysUserIdSlice)) + `)`
  489. pars = append(pars, sysUserIdSlice)
  490. }
  491. if frequency != `` {
  492. frequencySlice := strings.Split(frequency, ",")
  493. condition += ` AND frequency IN (` + utils.GetOrmInReplace(len(frequencySlice)) + `)`
  494. pars = append(pars, frequencySlice)
  495. }
  496. if keyword != `` {
  497. keywordSlice := strings.Split(keyword, " ")
  498. if len(keywordSlice) > 0 {
  499. tmpConditionSlice := make([]string, 0)
  500. tmpConditionSlice = append(tmpConditionSlice, ` edb_name like ? or edb_code like ? `)
  501. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  502. for _, v := range keywordSlice {
  503. if v == ` ` || v == `` {
  504. continue
  505. }
  506. tmpConditionSlice = append(tmpConditionSlice, ` edb_name like ? or edb_code like ? `)
  507. pars = utils.GetLikeKeywordPars(pars, v, 2)
  508. }
  509. condition += ` AND (` + strings.Join(tmpConditionSlice, " or ") + `)`
  510. } else {
  511. condition += ` edb_name like ? or edb_code like ? `
  512. pars = utils.GetLikeKeywordPars(pars, keyword, 2)
  513. }
  514. }
  515. sortStr := ``
  516. if sortParam != `` {
  517. sortStr = fmt.Sprintf("%s %s,edb_info_id desc ", sortParam, sortType)
  518. }
  519. total, list, err = data_manage.GetEdbBaseInfoList(condition, pars, sortStr, startSize, pageSize)
  520. }
  521. return
  522. }
  523. // getAllDefaultEdbRefreshConfigKey
  524. // @Description: 获取默认的所有刷新配置key
  525. // @author: Roc
  526. // @datetime 2024-01-10 15:02:49
  527. // @param source int
  528. // @param subSource int
  529. // @return string
  530. func getAllDefaultEdbRefreshConfigKey(source, subSource int) string {
  531. return allDefaultEdbRefreshConfigKey + fmt.Sprintf("%d_%d", source, subSource)
  532. }
  533. // GetRefreshStr
  534. // @Description: 获取刷新配置的中文字符串
  535. // @author: Roc
  536. // @datetime 2024-01-10 16:05:10
  537. // @param refreshFrequency string
  538. // @param refreshFrequencyDay int
  539. // @param refreshTime string
  540. // @return string
  541. func GetRefreshStr(refreshFrequency string, refreshFrequencyDay int, refreshTime string) string {
  542. refreshDayStr := ``
  543. //if refreshFrequency != "每自然日" && refreshFrequency != "每交易日"
  544. switch refreshFrequency {
  545. case "每自然日", "每交易日":
  546. case "每周":
  547. switch refreshFrequencyDay {
  548. case 0:
  549. refreshDayStr = "日"
  550. case 1:
  551. refreshDayStr = "一"
  552. case 2:
  553. refreshDayStr = "二"
  554. case 3:
  555. refreshDayStr = "三"
  556. case 4:
  557. refreshDayStr = "四"
  558. case 5:
  559. refreshDayStr = "五"
  560. case 6:
  561. refreshDayStr = "六"
  562. case 7:
  563. refreshDayStr = "日"
  564. }
  565. default:
  566. if refreshFrequencyDay > 0 {
  567. refreshDayStr = fmt.Sprintf("第%d天", refreshFrequencyDay)
  568. } else {
  569. refreshDayStr = `最后一天`
  570. }
  571. }
  572. return refreshFrequency + refreshDayStr + " " + refreshTime
  573. }