processor_business_logic.go 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057
  1. // Package ruizide
  2. // @Author gmy 2024/10/21 10:50:00
  3. package ruizide
  4. import (
  5. "encoding/json"
  6. "eta/eta_data_analysis/models"
  7. "eta/eta_data_analysis/utils"
  8. "fmt"
  9. "strings"
  10. "unicode"
  11. )
  12. // // OilDemandAnalysisContinentProcessor
  13. // // @Description: OilDemandAnalysisContinentProcessor处理器
  14. // type OilDemandAnalysisContinentProcessor struct{}
  15. //
  16. // func (p *OilDemandAnalysisContinentProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  17. // utils.FileLog.Info("Processing OilDemandAnalysisContinentProcessor...")
  18. // if rowIndex < 1 {
  19. // return nil, nil
  20. // }
  21. //
  22. // frequency := "月度"
  23. // unit := "千桶每天"
  24. // indexNameColSuffix := "Continent"
  25. // //indexNameColPrefix := "CountryRevisionGroup"
  26. //
  27. // // step_1: 分类
  28. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  29. // if err != nil {
  30. // return nil, err
  31. // }
  32. // utils.FileLog.Info("classifyId: %v", classifyId)
  33. //
  34. // // step_2: 指标
  35. // // 指标名称
  36. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  37. //
  38. // // 生成指标编码
  39. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  40. //
  41. // indexInfoMap := make(map[string]string)
  42. // indexInfoMap[indexCode] = indexName
  43. //
  44. // var indexInfoList []*models.IndexInfo
  45. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  46. // if err != nil {
  47. // return nil, err
  48. // }
  49. //
  50. // dataTime := rowData[0]
  51. // format, err := utils.ConvertDateFormat3(dataTime)
  52. // if err != nil {
  53. // return nil, err
  54. // }
  55. //
  56. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  57. // IndexName: indexName,
  58. // IndexCode: indexCode,
  59. // Value: value,
  60. // DataTime: format,
  61. // })
  62. //
  63. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  64. // if err != nil {
  65. // return nil, err
  66. // }
  67. // utils.FileLog.Info("OilDemandAnalysisContinentProcessor indexInfoList: %v", indexInfoList)
  68. //
  69. // // step_3: 指标数据
  70. // dataList, err := dealData(indexInfoList)
  71. // if err != nil {
  72. // return nil, err
  73. // }
  74. // utils.FileLog.Info("OilDemandAnalysisContinentProcessor dataList: %v", dataList)
  75. //
  76. // return dataList, err
  77. // }
  78. //
  79. // // OilDemandAnalysisRegionProcessor
  80. // // @Description: OilDemandAnalysisRegionProcessor处理器
  81. // type OilDemandAnalysisRegionProcessor struct{}
  82. //
  83. // func (p *OilDemandAnalysisRegionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  84. // utils.FileLog.Info("Processing OilDemandAnalysisRegionProcessor...")
  85. // if rowIndex < 1 {
  86. // return nil, nil
  87. // }
  88. //
  89. // frequency := "月度"
  90. // unit := "千桶每天"
  91. // indexNameColSuffix := "Region"
  92. // //indexNameColPrefix := "CountryRevisionGroup"
  93. //
  94. // // step_1: 分类
  95. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  96. // if err != nil {
  97. // return nil, err
  98. // }
  99. // utils.FileLog.Info("classifyId: %v", classifyId)
  100. //
  101. // // step_2: 指标
  102. // // 指标名称
  103. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  104. //
  105. // // 生成指标编码
  106. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  107. //
  108. // indexInfoMap := make(map[string]string)
  109. // indexInfoMap[indexCode] = indexName
  110. //
  111. // var indexInfoList []*models.IndexInfo
  112. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  113. // if err != nil {
  114. // return nil, err
  115. // }
  116. //
  117. // dataTime := rowData[0]
  118. // format, err := utils.ConvertDateFormat3(dataTime)
  119. // if err != nil {
  120. // return nil, err
  121. // }
  122. //
  123. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  124. // IndexName: indexName,
  125. // IndexCode: indexCode,
  126. // Value: value,
  127. // DataTime: format,
  128. // })
  129. //
  130. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  131. // if err != nil {
  132. // return nil, err
  133. // }
  134. // utils.FileLog.Info("OilDemandAnalysisRegionProcessor indexInfoList: %v", indexInfoList)
  135. //
  136. // // step_3: 指标数据
  137. // dataList, err := dealData(indexInfoList)
  138. // if err != nil {
  139. // return nil, err
  140. // }
  141. // utils.FileLog.Info("OilDemandAnalysisRegionProcessor dataList: %v", dataList)
  142. //
  143. // return dataList, err
  144. // }
  145. //
  146. // // OilDemandAnalysisCountryProcessor
  147. // // @Description: OilDemandAnalysisCountryProcessor
  148. // type OilDemandAnalysisCountryProcessor struct{}
  149. //
  150. // func (p *OilDemandAnalysisCountryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  151. // utils.FileLog.Info("Processing OilDemandAnalysisCountryProcessor...")
  152. // if rowIndex < 1 {
  153. // return nil, nil
  154. // }
  155. //
  156. // frequency := "月度"
  157. // unit := "千桶每天"
  158. // indexNameColSuffix := "Country"
  159. // //indexNameColPrefix := "CountryRevisionGroup"
  160. //
  161. // // step_1: 分类
  162. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  163. // if err != nil {
  164. // return nil, err
  165. // }
  166. // utils.FileLog.Info("classifyId: %v", classifyId)
  167. //
  168. // // step_2: 指标
  169. // // 指标名称
  170. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  171. //
  172. // // 生成指标编码
  173. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  174. //
  175. // indexInfoMap := make(map[string]string)
  176. // indexInfoMap[indexCode] = indexName
  177. //
  178. // var indexInfoList []*models.IndexInfo
  179. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  180. // if err != nil {
  181. // return nil, err
  182. // }
  183. //
  184. // dataTime := rowData[0]
  185. // format, err := utils.ConvertDateFormat3(dataTime)
  186. // if err != nil {
  187. // return nil, err
  188. // }
  189. //
  190. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  191. // IndexName: indexName,
  192. // IndexCode: indexCode,
  193. // Value: value,
  194. // DataTime: format,
  195. // })
  196. //
  197. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  198. // if err != nil {
  199. // return nil, err
  200. // }
  201. // utils.FileLog.Info("OilDemandAnalysisCountryProcessor indexInfoList: %v", indexInfoList)
  202. //
  203. // // step_3: 指标数据
  204. // dataList, err := dealData(indexInfoList)
  205. // if err != nil {
  206. // return nil, err
  207. // }
  208. // utils.FileLog.Info("OilDemandAnalysisCountryProcessor dataList: %v", dataList)
  209. //
  210. // return dataList, err
  211. // }
  212. //
  213. // // OilDemandAnalysisProductCategoryProcessor
  214. // // @Description: OilDemandAnalysisProductCategoryProcessor处理器
  215. // type OilDemandAnalysisProductCategoryProcessor struct{}
  216. //
  217. // func (p *OilDemandAnalysisProductCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  218. // utils.FileLog.Info("Processing OilDemandAnalysisProductCategoryProcessor...")
  219. // if rowIndex < 1 {
  220. // return nil, nil
  221. // }
  222. //
  223. // frequency := "月度"
  224. // unit := "千桶每天"
  225. // indexNameColSuffix := "Product category"
  226. // //indexNameColPrefix := "CountryRevisionGroup"
  227. //
  228. // // step_1: 分类
  229. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  230. // if err != nil {
  231. // return nil, err
  232. // }
  233. // utils.FileLog.Info("classifyId: %v", classifyId)
  234. //
  235. // // step_2: 指标
  236. // // 指标名称
  237. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  238. //
  239. // // 生成指标编码
  240. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  241. //
  242. // indexInfoMap := make(map[string]string)
  243. // indexInfoMap[indexCode] = indexName
  244. //
  245. // var indexInfoList []*models.IndexInfo
  246. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  247. // if err != nil {
  248. // return nil, err
  249. // }
  250. //
  251. // dataTime := rowData[0]
  252. // format, err := utils.ConvertDateFormat3(dataTime)
  253. // if err != nil {
  254. // return nil, err
  255. // }
  256. //
  257. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  258. // IndexName: indexName,
  259. // IndexCode: indexCode,
  260. // Value: value,
  261. // DataTime: format,
  262. // })
  263. //
  264. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  265. // if err != nil {
  266. // return nil, err
  267. // }
  268. // utils.FileLog.Info("OilDemandAnalysisProductCategoryProcessor indexInfoList: %v", indexInfoList)
  269. //
  270. // // step_3: 指标数据
  271. // dataList, err := dealData(indexInfoList)
  272. // if err != nil {
  273. // return nil, err
  274. // }
  275. // utils.FileLog.Info("OilDemandAnalysisProductCategoryProcessor dataList: %v", dataList)
  276. //
  277. // return dataList, err
  278. // }
  279. //
  280. // // OilDemandAnalysisProductDetailProcessor
  281. // // @Description: OilDemandAnalysisProductDetailProcessor处理器
  282. // type OilDemandAnalysisProductDetailProcessor struct{}
  283. //
  284. // func (p *OilDemandAnalysisProductDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  285. // utils.FileLog.Info("Processing OilDemandAnalysisProductDetailProcessor...")
  286. // if rowIndex < 1 {
  287. // return nil, nil
  288. // }
  289. //
  290. // frequency := "月度"
  291. // unit := "千桶每天"
  292. // indexNameColSuffix := "Product detail"
  293. // //indexNameColPrefix := "CountryRevisionGroup"
  294. //
  295. // // step_1: 分类
  296. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  297. // if err != nil {
  298. // return nil, err
  299. // }
  300. // utils.FileLog.Info("classifyId: %v", classifyId)
  301. //
  302. // // step_2: 指标
  303. // // 指标名称
  304. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  305. //
  306. // // 生成指标编码
  307. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  308. //
  309. // indexInfoMap := make(map[string]string)
  310. // indexInfoMap[indexCode] = indexName
  311. //
  312. // var indexInfoList []*models.IndexInfo
  313. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  314. // if err != nil {
  315. // return nil, err
  316. // }
  317. //
  318. // dataTime := rowData[0]
  319. // format, err := utils.ConvertDateFormat3(dataTime)
  320. // if err != nil {
  321. // return nil, err
  322. // }
  323. //
  324. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  325. // IndexName: indexName,
  326. // IndexCode: indexCode,
  327. // Value: value,
  328. // DataTime: format,
  329. // })
  330. //
  331. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  332. // if err != nil {
  333. // return nil, err
  334. // }
  335. // utils.FileLog.Info("OilDemandAnalysisProductDetailProcessor indexInfoList: %v", indexInfoList)
  336. //
  337. // // step_3: 指标数据
  338. // dataList, err := dealData(indexInfoList)
  339. // if err != nil {
  340. // return nil, err
  341. // }
  342. // utils.FileLog.Info("OilDemandAnalysisProductDetailProcessor dataList: %v", dataList)
  343. //
  344. // return dataList, err
  345. // }
  346. //
  347. // // OilDemandAnalysisSectorCategoryProcessor
  348. // // @Description: OilDemandAnalysisSectorCategoryProcessor处理器
  349. // type OilDemandAnalysisSectorCategoryProcessor struct{}
  350. //
  351. // func (p *OilDemandAnalysisSectorCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  352. // utils.FileLog.Info("Processing OilDemandAnalysisSectorCategoryProcessor...")
  353. // if rowIndex < 1 {
  354. // return nil, nil
  355. // }
  356. //
  357. // frequency := "月度"
  358. // unit := "千桶每天"
  359. // indexNameColSuffix := "Sector category"
  360. // //indexNameColPrefix := "CountryRevisionGroup"
  361. //
  362. // // step_1: 分类
  363. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  364. // if err != nil {
  365. // return nil, err
  366. // }
  367. // utils.FileLog.Info("classifyId: %v", classifyId)
  368. //
  369. // // step_2: 指标
  370. // // 指标名称
  371. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  372. //
  373. // // 生成指标编码
  374. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  375. //
  376. // indexInfoMap := make(map[string]string)
  377. // indexInfoMap[indexCode] = indexName
  378. //
  379. // var indexInfoList []*models.IndexInfo
  380. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  381. // if err != nil {
  382. // return nil, err
  383. // }
  384. //
  385. // dataTime := rowData[0]
  386. // format, err := utils.ConvertDateFormat3(dataTime)
  387. // if err != nil {
  388. // return nil, err
  389. // }
  390. //
  391. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  392. // IndexName: indexName,
  393. // IndexCode: indexCode,
  394. // Value: value,
  395. // DataTime: format,
  396. // })
  397. //
  398. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  399. // if err != nil {
  400. // return nil, err
  401. // }
  402. // utils.FileLog.Info("OilDemandAnalysisSectorCategoryProcessor indexInfoList: %v", indexInfoList)
  403. //
  404. // // step_3: 指标数据
  405. // dataList, err := dealData(indexInfoList)
  406. // if err != nil {
  407. // return nil, err
  408. // }
  409. // utils.FileLog.Info("OilDemandAnalysisSectorCategoryProcessor dataList: %v", dataList)
  410. //
  411. // return dataList, err
  412. // }
  413. //
  414. // // OilDemandAnalysisSectorDetailProcessor
  415. // // @Description: OilDemandAnalysisSectorDetailProcessor处理器
  416. // type OilDemandAnalysisSectorDetailProcessor struct{}
  417. //
  418. // func (p *OilDemandAnalysisSectorDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  419. // utils.FileLog.Info("Processing OilDemandAnalysisSectorDetailProcessor...")
  420. // if rowIndex < 1 {
  421. // return nil, nil
  422. // }
  423. //
  424. // frequency := "月度"
  425. // unit := "千桶每天"
  426. // indexNameColSuffix := "Sector detail"
  427. // //indexNameColPrefix := "CountryRevisionGroup"
  428. //
  429. // // step_1: 分类
  430. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  431. // if err != nil {
  432. // return nil, err
  433. // }
  434. // utils.FileLog.Info("classifyId: %v", classifyId)
  435. //
  436. // // step_2: 指标
  437. // // 指标名称
  438. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  439. //
  440. // // 生成指标编码
  441. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  442. //
  443. // indexInfoMap := make(map[string]string)
  444. // indexInfoMap[indexCode] = indexName
  445. //
  446. // var indexInfoList []*models.IndexInfo
  447. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  448. // if err != nil {
  449. // return nil, err
  450. // }
  451. //
  452. // dataTime := rowData[0]
  453. // format, err := utils.ConvertDateFormat3(dataTime)
  454. // if err != nil {
  455. // return nil, err
  456. // }
  457. //
  458. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  459. // IndexName: indexName,
  460. // IndexCode: indexCode,
  461. // Value: value,
  462. // DataTime: format,
  463. // })
  464. //
  465. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  466. // if err != nil {
  467. // return nil, err
  468. // }
  469. // utils.FileLog.Info("OilDemandAnalysisSectorDetailProcessor indexInfoList: %v", indexInfoList)
  470. //
  471. // // step_3: 指标数据
  472. // dataList, err := dealData(indexInfoList)
  473. // if err != nil {
  474. // return nil, err
  475. // }
  476. // utils.FileLog.Info("OilDemandAnalysisSectorDetailProcessor dataList: %v", dataList)
  477. //
  478. // return dataList, err
  479. // }
  480. //
  481. // // OilDemandAnalysisScenarioProcessor
  482. // // @Description: OilDemandAnalysisScenarioProcessor处理器
  483. // type OilDemandAnalysisScenarioProcessor struct{}
  484. //
  485. // func (p *OilDemandAnalysisScenarioProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  486. // utils.FileLog.Info("Processing OilDemandAnalysisScenarioProcessor...")
  487. // if rowIndex < 1 {
  488. // return nil, nil
  489. // }
  490. //
  491. // frequency := "月度"
  492. // unit := "千桶每天"
  493. // indexNameColSuffix := "Scenario"
  494. // //indexNameColPrefix := "CountryRevisionGroup"
  495. //
  496. // // step_1: 分类
  497. // classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  498. // if err != nil {
  499. // return nil, err
  500. // }
  501. // utils.FileLog.Info("classifyId: %v", classifyId)
  502. //
  503. // // step_2: 指标
  504. // // 指标名称
  505. // indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  506. //
  507. // // 生成指标编码
  508. // indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  509. //
  510. // indexInfoMap := make(map[string]string)
  511. // indexInfoMap[indexCode] = indexName
  512. //
  513. // var indexInfoList []*models.IndexInfo
  514. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  515. // if err != nil {
  516. // return nil, err
  517. // }
  518. //
  519. // dataTime := rowData[0]
  520. // format, err := utils.ConvertDateFormat3(dataTime)
  521. // if err != nil {
  522. // return nil, err
  523. // }
  524. //
  525. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  526. // IndexName: indexName,
  527. // IndexCode: indexCode,
  528. // Value: value,
  529. // DataTime: format,
  530. // })
  531. //
  532. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  533. // if err != nil {
  534. // return nil, err
  535. // }
  536. // utils.FileLog.Info("OilDemandAnalysisScenarioProcessor indexInfoList: %v", indexInfoList)
  537. //
  538. // // step_3: 指标数据
  539. // dataList, err := dealData(indexInfoList)
  540. // if err != nil {
  541. // return nil, err
  542. // }
  543. // utils.FileLog.Info("OilDemandAnalysisScenarioProcessor dataList: %v", dataList)
  544. //
  545. // return dataList, err
  546. // }
  547. //
  548. // // UpstreamSupplyOilQualityApiProcessor
  549. // // @Description: UpstreamSupplyOilQualityApiProcessor处理器
  550. // type UpstreamSupplyOilQualityApiProcessor struct{}
  551. //
  552. // var rzdApiFlag string
  553. //
  554. // func (p *UpstreamSupplyOilQualityApiProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  555. // utils.FileLog.Info("Processing UpstreamSupplyOilQualityApiProcessor...")
  556. // if rowIndex <= 1 {
  557. // return nil, nil
  558. // }
  559. //
  560. // if rowData[0] != "" {
  561. // rzdApiFlag = rowData[0]
  562. // } else {
  563. // rowData[0] = rzdApiFlag
  564. // }
  565. //
  566. // frequency := "月度"
  567. // unit := "°"
  568. // indexNameColSuffix := "Oil Quality"
  569. // //indexNameColPrefix := "CountryRevisionGroup"
  570. //
  571. // if !utils.IsNumeric(rowData[0]) {
  572. // return nil, nil
  573. // }
  574. // if rowData[1] == "Sum" {
  575. // return nil, nil
  576. // }
  577. //
  578. // // step_1: 分类
  579. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  580. // if err != nil {
  581. // return nil, err
  582. // }
  583. // utils.FileLog.Info("classifyId: %v", classifyId)
  584. //
  585. // // step_2: 指标
  586. // // 指标名称
  587. // indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "API"
  588. //
  589. // // 生成指标编码
  590. // indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("API"), "")
  591. //
  592. // var indexInfoList []*models.IndexInfo
  593. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  594. // if err != nil {
  595. // return nil, err
  596. // }
  597. //
  598. // dataTime := rowData[0]
  599. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  600. // if err != nil {
  601. // return nil, err
  602. // }
  603. //
  604. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  605. // IndexName: indexName,
  606. // IndexCode: indexCode,
  607. // Value: value,
  608. // DataTime: format,
  609. // })
  610. //
  611. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  612. // if err != nil {
  613. // return nil, err
  614. // }
  615. // utils.FileLog.Info("UpstreamSupplyOilQualityApiProcessor indexInfoList: %v", indexInfoList)
  616. //
  617. // // step_3: 指标数据
  618. // dataList, err := dealData(indexInfoList)
  619. // if err != nil {
  620. // return nil, err
  621. // }
  622. // utils.FileLog.Info("UpstreamSupplyOilQualityApiProcessor dataList: %v", dataList)
  623. //
  624. // return dataList, err
  625. // }
  626. //
  627. // // OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor
  628. // // @Description: OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor处理器
  629. // type OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor struct{}
  630. //
  631. // var rzdSulphurFlag string
  632. //
  633. // func (p *OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  634. // utils.FileLog.Info("Processing OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor...")
  635. // if rowIndex <= 1 {
  636. // return nil, nil
  637. // }
  638. //
  639. // if rowData[0] != "" {
  640. // rzdSulphurFlag = rowData[0]
  641. // } else {
  642. // rowData[0] = rzdSulphurFlag
  643. // }
  644. //
  645. // frequency := "月度"
  646. // unit := "%wt"
  647. // indexNameColSuffix := "Oil Quality"
  648. // //indexNameColPrefix := "CountryRevisionGroup"
  649. //
  650. // if !utils.IsNumeric(rowData[0]) {
  651. // return nil, nil
  652. // }
  653. // if rowData[1] == "Sum" {
  654. // return nil, nil
  655. // }
  656. //
  657. // // step_1: 分类
  658. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  659. // if err != nil {
  660. // return nil, err
  661. // }
  662. // utils.FileLog.Info("classifyId: %v", classifyId)
  663. //
  664. // // step_2: 指标
  665. // // 指标名称
  666. // indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "Sulphur"
  667. //
  668. // // 生成指标编码
  669. // indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("Sulphur"), "")
  670. //
  671. // var indexInfoList []*models.IndexInfo
  672. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  673. // if err != nil {
  674. // return nil, err
  675. // }
  676. //
  677. // dataTime := rowData[0]
  678. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  679. // if err != nil {
  680. // return nil, err
  681. // }
  682. //
  683. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  684. // IndexName: indexName,
  685. // IndexCode: indexCode,
  686. // Value: value,
  687. // DataTime: format,
  688. // })
  689. //
  690. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  691. // if err != nil {
  692. // return nil, err
  693. // }
  694. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor indexInfoList: %v", indexInfoList)
  695. //
  696. // // step_3: 指标数据
  697. // dataList, err := dealData(indexInfoList)
  698. // if err != nil {
  699. // return nil, err
  700. // }
  701. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor dataList: %v", dataList)
  702. //
  703. // return dataList, err
  704. // }
  705. //
  706. // // OilMarketCubeUpstreamSupplyCapacityCapacityProcessor
  707. // // @Description: OilMarketCubeUpstreamSupplyCapacityCapacityProcessor处理器
  708. // type OilMarketCubeUpstreamSupplyCapacityCapacityProcessor struct{}
  709. //
  710. // var rzdCapacityFlag string
  711. //
  712. // func (p *OilMarketCubeUpstreamSupplyCapacityCapacityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  713. // utils.FileLog.Info("Processing OilMarketCubeUpstreamSupplyCapacityCapacityProcessor...")
  714. // if rowIndex <= 1 {
  715. // return nil, nil
  716. // }
  717. //
  718. // if rowData[0] != "" {
  719. // rzdCapacityFlag = rowData[0]
  720. // } else {
  721. // rowData[0] = rzdCapacityFlag
  722. // }
  723. //
  724. // frequency := "月度"
  725. // unit := "kbbl/d"
  726. // indexNameColSuffix := "Capacity"
  727. // //indexNameColPrefix := "CountryRevisionGroup"
  728. //
  729. // if !utils.IsNumeric(rowData[0]) {
  730. // return nil, nil
  731. // }
  732. // if rowData[1] == "Sum" {
  733. // return nil, nil
  734. // }
  735. //
  736. // // step_1: 分类
  737. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  738. // if err != nil {
  739. // return nil, err
  740. // }
  741. // utils.FileLog.Info("classifyId: %v", classifyId)
  742. //
  743. // // step_2: 指标
  744. // // 指标名称
  745. // indexName := "Upstream Supply" + "/" + indexNameColSuffix
  746. //
  747. // // 生成指标编码
  748. // indexCode, err := getIndexId("Upstream Supply ", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  749. //
  750. // var indexInfoList []*models.IndexInfo
  751. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  752. // if err != nil {
  753. // return nil, err
  754. // }
  755. //
  756. // dataTime := rowData[0]
  757. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  758. // if err != nil {
  759. // return nil, err
  760. // }
  761. //
  762. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  763. // IndexName: indexName,
  764. // IndexCode: indexCode,
  765. // Value: value,
  766. // DataTime: format,
  767. // })
  768. //
  769. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  770. // if err != nil {
  771. // return nil, err
  772. // }
  773. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor indexInfoList: %v", indexInfoList)
  774. //
  775. // // step_3: 指标数据
  776. // dataList, err := dealData(indexInfoList)
  777. // if err != nil {
  778. // return nil, err
  779. // }
  780. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor dataList: %v", dataList)
  781. //
  782. // return dataList, err
  783. // }
  784. //
  785. // // OilMarketCubeUpstreamSupplyProductionProcessor
  786. // // @Description: OilMarketCubeUpstreamSupplyProductionProcessor处理器
  787. // type OilMarketCubeUpstreamSupplyProductionProcessor struct{}
  788. //
  789. // var rzdProductionFlag string
  790. //
  791. // func (p *OilMarketCubeUpstreamSupplyProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  792. // utils.FileLog.Info("Processing OilMarketCubeUpstreamSupplyProductionProcessor...")
  793. // if rowIndex <= 1 {
  794. // return nil, nil
  795. // }
  796. //
  797. // if rowData[0] != "" {
  798. // rzdProductionFlag = rowData[0]
  799. // } else {
  800. // rowData[0] = rzdProductionFlag
  801. // }
  802. //
  803. // frequency := "月度"
  804. // unit := "kbbl/d"
  805. // indexNameColSuffix := "Production"
  806. // //indexNameColPrefix := "CountryRevisionGroup"
  807. //
  808. // if !utils.IsNumeric(rowData[0]) {
  809. // return nil, nil
  810. // }
  811. // if rowData[1] == "Sum" {
  812. // return nil, nil
  813. // }
  814. //
  815. // // step_1: 分类
  816. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  817. // if err != nil {
  818. // return nil, err
  819. // }
  820. // utils.FileLog.Info("classifyId: %v", classifyId)
  821. //
  822. // // step_2: 指标
  823. // // 指标名称
  824. // indexName := "Upstream Supply" + "/" + indexNameColSuffix
  825. //
  826. // // 生成指标编码
  827. // indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  828. //
  829. // var indexInfoList []*models.IndexInfo
  830. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  831. // if err != nil {
  832. // return nil, err
  833. // }
  834. //
  835. // dataTime := rowData[0]
  836. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  837. // if err != nil {
  838. // return nil, err
  839. // }
  840. //
  841. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  842. // IndexName: indexName,
  843. // IndexCode: indexCode,
  844. // Value: value,
  845. // DataTime: format,
  846. // })
  847. //
  848. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  849. // if err != nil {
  850. // return nil, err
  851. // }
  852. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyProductionProcessor indexInfoList: %v", indexInfoList)
  853. //
  854. // // step_3: 指标数据
  855. // dataList, err := dealData(indexInfoList)
  856. // if err != nil {
  857. // return nil, err
  858. // }
  859. // utils.FileLog.Info("OilMarketCubeUpstreamSupplyProductionProcessor dataList: %v", dataList)
  860. //
  861. // return dataList, err
  862. // }
  863. //
  864. // // UpstreamSupplyProductionWoSeasonalityProcessor
  865. // // @Description: UpstreamSupplyProductionWoSeasonalityProcessor处理器
  866. // type UpstreamSupplyProductionWoSeasonalityProcessor struct{}
  867. //
  868. // var rzdProductionWoSeasonalityFlag string
  869. //
  870. // func (p *UpstreamSupplyProductionWoSeasonalityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  871. // utils.FileLog.Info("Processing UpstreamSupplyProductionWoSeasonalityProcessor...")
  872. // if rowIndex <= 1 {
  873. // return nil, nil
  874. // }
  875. //
  876. // if rowData[0] != "" {
  877. // rzdProductionWoSeasonalityFlag = rowData[0]
  878. // } else {
  879. // rowData[0] = rzdProductionWoSeasonalityFlag
  880. // }
  881. //
  882. // frequency := "月度"
  883. // unit := "kbbl/d"
  884. // indexNameColSuffix := "Production Wo Seasonality"
  885. // //indexNameColPrefix := "CountryRevisionGroup"
  886. //
  887. // if !utils.IsNumeric(rowData[0]) {
  888. // return nil, nil
  889. // }
  890. // if rowData[1] == "Sum" {
  891. // return nil, nil
  892. // }
  893. //
  894. // // step_1: 分类
  895. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  896. // if err != nil {
  897. // return nil, err
  898. // }
  899. // utils.FileLog.Info("classifyId: %v", classifyId)
  900. //
  901. // // step_2: 指标
  902. // // 指标名称
  903. // indexName := "Upstream Supply" + "/" + indexNameColSuffix
  904. //
  905. // // 生成指标编码
  906. // indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  907. //
  908. // var indexInfoList []*models.IndexInfo
  909. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  910. // if err != nil {
  911. // return nil, err
  912. // }
  913. //
  914. // dataTime := rowData[0]
  915. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  916. // if err != nil {
  917. // return nil, err
  918. // }
  919. //
  920. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  921. // IndexName: indexName,
  922. // IndexCode: indexCode,
  923. // Value: value,
  924. // DataTime: format,
  925. // })
  926. //
  927. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  928. // if err != nil {
  929. // return nil, err
  930. // }
  931. // utils.FileLog.Info("UpstreamSupplyProductionWoSeasonalityProcessor indexInfoList: %v", indexInfoList)
  932. //
  933. // // step_3: 指标数据
  934. // dataList, err := dealData(indexInfoList)
  935. // if err != nil {
  936. // return nil, err
  937. // }
  938. // utils.FileLog.Info("UpstreamSupplyProductionWoSeasonalityProcessor dataList: %v", dataList)
  939. //
  940. // return dataList, err
  941. // }
  942. //
  943. // // UpstreamSupplyOPECPolicyReferenceProductionProcessor
  944. // // @Description: UpstreamSupplyOPECPolicyReferenceProductionProcessor处理器
  945. // type UpstreamSupplyOPECPolicyReferenceProductionProcessor struct{}
  946. //
  947. // var rzdReferenceProductionFlag string
  948. //
  949. // func (p *UpstreamSupplyOPECPolicyReferenceProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  950. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyReferenceProductionProcessor...")
  951. // if rowIndex <= 1 {
  952. // return nil, nil
  953. // }
  954. //
  955. // if rowData[0] != "" {
  956. // rzdReferenceProductionFlag = rowData[0]
  957. // } else {
  958. // rowData[0] = rzdReferenceProductionFlag
  959. // }
  960. //
  961. // frequency := "月度"
  962. // unit := "kbbl/d"
  963. // indexNameColPrefix := "OPEC_Policy"
  964. // indexNameColSuffix := "Reference Production"
  965. //
  966. // if !utils.IsNumeric(rowData[0]) {
  967. // return nil, nil
  968. // }
  969. // if rowData[1] == "Sum" {
  970. // return nil, nil
  971. // }
  972. //
  973. // // step_1: 分类
  974. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  975. // if err != nil {
  976. // return nil, err
  977. // }
  978. // utils.FileLog.Info("classifyId: %v", classifyId)
  979. //
  980. // // step_2: 指标
  981. // // 指标名称
  982. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  983. //
  984. // // 生成指标编码
  985. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  986. //
  987. // var indexInfoList []*models.IndexInfo
  988. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  989. // if err != nil {
  990. // return nil, err
  991. // }
  992. //
  993. // dataTime := rowData[0]
  994. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  995. // if err != nil {
  996. // return nil, err
  997. // }
  998. //
  999. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1000. // IndexName: indexName,
  1001. // IndexCode: indexCode,
  1002. // Value: value,
  1003. // DataTime: format,
  1004. // })
  1005. //
  1006. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1007. // if err != nil {
  1008. // return nil, err
  1009. // }
  1010. // utils.FileLog.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor indexInfoList: %v", indexInfoList)
  1011. //
  1012. // // step_3: 指标数据
  1013. // dataList, err := dealData(indexInfoList)
  1014. // if err != nil {
  1015. // return nil, err
  1016. // }
  1017. // utils.FileLog.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor dataList: %v", dataList)
  1018. //
  1019. // return dataList, err
  1020. // }
  1021. //
  1022. // // UpstreamSupplyOPECPolicyTargetProductionProcessor
  1023. // // @Description: UpstreamSupplyOPECPolicyTargetProductionProcessor处理器
  1024. // type UpstreamSupplyOPECPolicyTargetProductionProcessor struct{}
  1025. //
  1026. // var rzdTargetProductionFlag string
  1027. //
  1028. // func (p *UpstreamSupplyOPECPolicyTargetProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1029. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyTargetProductionProcessor...")
  1030. // if rowIndex <= 1 {
  1031. // return nil, nil
  1032. // }
  1033. //
  1034. // if rowData[0] != "" {
  1035. // rzdTargetProductionFlag = rowData[0]
  1036. // } else {
  1037. // rowData[0] = rzdTargetProductionFlag
  1038. // }
  1039. //
  1040. // frequency := "月度"
  1041. // unit := "kbbl/d"
  1042. // indexNameColPrefix := "OPEC_Policy"
  1043. // indexNameColSuffix := "Target Production"
  1044. //
  1045. // if !utils.IsNumeric(rowData[0]) {
  1046. // return nil, nil
  1047. // }
  1048. // if rowData[1] == "Sum" {
  1049. // return nil, nil
  1050. // }
  1051. //
  1052. // // step_1: 分类
  1053. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1054. // if err != nil {
  1055. // return nil, err
  1056. // }
  1057. // utils.FileLog.Info("classifyId: %v", classifyId)
  1058. //
  1059. // // step_2: 指标
  1060. // // 指标名称
  1061. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1062. //
  1063. // // 生成指标编码
  1064. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1065. //
  1066. // var indexInfoList []*models.IndexInfo
  1067. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1068. // if err != nil {
  1069. // return nil, err
  1070. // }
  1071. //
  1072. // dataTime := rowData[0]
  1073. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1074. // if err != nil {
  1075. // return nil, err
  1076. // }
  1077. //
  1078. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1079. // IndexName: indexName,
  1080. // IndexCode: indexCode,
  1081. // Value: value,
  1082. // DataTime: format,
  1083. // })
  1084. //
  1085. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1086. // if err != nil {
  1087. // return nil, err
  1088. // }
  1089. // utils.FileLog.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor indexInfoList: %v", indexInfoList)
  1090. //
  1091. // // step_3: 指标数据
  1092. // dataList, err := dealData(indexInfoList)
  1093. // if err != nil {
  1094. // return nil, err
  1095. // }
  1096. // utils.FileLog.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor dataList: %v", dataList)
  1097. //
  1098. // return dataList, err
  1099. // }
  1100. //
  1101. // // UpstreamSupplyOPECPolicyTargetCutProcessor
  1102. // // @Description: UpstreamSupplyOPECPolicyTargetCutProcessor处理器
  1103. // type UpstreamSupplyOPECPolicyTargetCutProcessor struct{}
  1104. //
  1105. // var rzdTargetCutFlag string
  1106. //
  1107. // func (p *UpstreamSupplyOPECPolicyTargetCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1108. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyTargetCutProcessor...")
  1109. // if rowIndex <= 1 {
  1110. // return nil, nil
  1111. // }
  1112. //
  1113. // if rowData[0] != "" {
  1114. // rzdTargetCutFlag = rowData[0]
  1115. // } else {
  1116. // rowData[0] = rzdTargetCutFlag
  1117. // }
  1118. //
  1119. // frequency := "月度"
  1120. // unit := "kbbl/d"
  1121. // indexNameColPrefix := "OPEC_Policy"
  1122. // indexNameColSuffix := "Target Cut"
  1123. //
  1124. // if !utils.IsNumeric(rowData[0]) {
  1125. // return nil, nil
  1126. // }
  1127. // if rowData[1] == "Sum" {
  1128. // return nil, nil
  1129. // }
  1130. //
  1131. // // step_1: 分类
  1132. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1133. // if err != nil {
  1134. // return nil, err
  1135. // }
  1136. // utils.FileLog.Info("classifyId: %v", classifyId)
  1137. //
  1138. // // step_2: 指标
  1139. // // 指标名称
  1140. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1141. //
  1142. // // 生成指标编码
  1143. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1144. //
  1145. // var indexInfoList []*models.IndexInfo
  1146. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1147. // if err != nil {
  1148. // return nil, err
  1149. // }
  1150. //
  1151. // dataTime := rowData[0]
  1152. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1153. // if err != nil {
  1154. // return nil, err
  1155. // }
  1156. //
  1157. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1158. // IndexName: indexName,
  1159. // IndexCode: indexCode,
  1160. // Value: value,
  1161. // DataTime: format,
  1162. // })
  1163. //
  1164. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1165. // if err != nil {
  1166. // return nil, err
  1167. // }
  1168. // utils.FileLog.Info("UpstreamSupplyOPECPolicyTargetCutProcessor indexInfoList: %v", indexInfoList)
  1169. //
  1170. // // step_3: 指标数据
  1171. // dataList, err := dealData(indexInfoList)
  1172. // if err != nil {
  1173. // return nil, err
  1174. // }
  1175. // utils.FileLog.Info("UpstreamSupplyOPECPolicyTargetCutProcessor dataList: %v", dataList)
  1176. //
  1177. // return dataList, err
  1178. // }
  1179. //
  1180. // // UpstreamSupplyOPECPolicyActualCutProcessor
  1181. // // @Description: UpstreamSupplyOPECPolicyActualCutProcessor处理器
  1182. // type UpstreamSupplyOPECPolicyActualCutProcessor struct{}
  1183. //
  1184. // var rzdActualCutFlag string
  1185. //
  1186. // func (p *UpstreamSupplyOPECPolicyActualCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1187. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyActualCutProcessor...")
  1188. // if rowIndex <= 1 {
  1189. // return nil, nil
  1190. // }
  1191. //
  1192. // if rowData[0] != "" {
  1193. // rzdActualCutFlag = rowData[0]
  1194. // } else {
  1195. // rowData[0] = rzdActualCutFlag
  1196. // }
  1197. //
  1198. // frequency := "月度"
  1199. // unit := "kbbl/d"
  1200. // indexNameColPrefix := "OPEC_Policy"
  1201. // indexNameColSuffix := "Actual Cut"
  1202. //
  1203. // if !utils.IsNumeric(rowData[0]) {
  1204. // return nil, nil
  1205. // }
  1206. // if rowData[1] == "Sum" {
  1207. // return nil, nil
  1208. // }
  1209. //
  1210. // // step_1: 分类
  1211. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1212. // if err != nil {
  1213. // return nil, err
  1214. // }
  1215. // utils.FileLog.Info("classifyId: %v", classifyId)
  1216. //
  1217. // // step_2: 指标
  1218. // // 指标名称
  1219. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1220. //
  1221. // // 生成指标编码
  1222. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1223. //
  1224. // var indexInfoList []*models.IndexInfo
  1225. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1226. // if err != nil {
  1227. // return nil, err
  1228. // }
  1229. //
  1230. // dataTime := rowData[0]
  1231. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1232. // if err != nil {
  1233. // return nil, err
  1234. // }
  1235. //
  1236. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1237. // IndexName: indexName,
  1238. // IndexCode: indexCode,
  1239. // Value: value,
  1240. // DataTime: format,
  1241. // })
  1242. //
  1243. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1244. // if err != nil {
  1245. // return nil, err
  1246. // }
  1247. // utils.FileLog.Info("UpstreamSupplyOPECPolicyActualCutProcessor indexInfoList: %v", indexInfoList)
  1248. //
  1249. // // step_3: 指标数据
  1250. // dataList, err := dealData(indexInfoList)
  1251. // if err != nil {
  1252. // return nil, err
  1253. // }
  1254. // utils.FileLog.Info("UpstreamSupplyOPECPolicyActualCutProcessor dataList: %v", dataList)
  1255. //
  1256. // return dataList, err
  1257. // }
  1258. //
  1259. // // UpstreamSupplyOPECPolicyComplianceProcessor
  1260. // // @Description: UpstreamSupplyOPECPolicyComplianceProcessor处理器
  1261. // type UpstreamSupplyOPECPolicyComplianceProcessor struct{}
  1262. //
  1263. // var rzdComplianceFlag string
  1264. //
  1265. // func (p *UpstreamSupplyOPECPolicyComplianceProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1266. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyComplianceProcessor...")
  1267. // if rowIndex <= 1 {
  1268. // return nil, nil
  1269. // }
  1270. //
  1271. // if rowData[0] != "" {
  1272. // rzdComplianceFlag = rowData[0]
  1273. // } else {
  1274. // rowData[0] = rzdComplianceFlag
  1275. // }
  1276. //
  1277. // frequency := "月度"
  1278. // unit := "kbbl/d"
  1279. // indexNameColPrefix := "OPEC_Policy"
  1280. // indexNameColSuffix := "Compliance"
  1281. //
  1282. // if !utils.IsNumeric(rowData[0]) {
  1283. // return nil, nil
  1284. // }
  1285. // if rowData[1] == "Sum" {
  1286. // return nil, nil
  1287. // }
  1288. //
  1289. // // step_1: 分类
  1290. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1291. // if err != nil {
  1292. // return nil, err
  1293. // }
  1294. // utils.FileLog.Info("classifyId: %v", classifyId)
  1295. //
  1296. // // step_2: 指标
  1297. // // 指标名称
  1298. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1299. //
  1300. // // 生成指标编码
  1301. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1302. //
  1303. // var indexInfoList []*models.IndexInfo
  1304. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1305. // if err != nil {
  1306. // return nil, err
  1307. // }
  1308. //
  1309. // dataTime := rowData[0]
  1310. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1311. // if err != nil {
  1312. // return nil, err
  1313. // }
  1314. //
  1315. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1316. // IndexName: indexName,
  1317. // IndexCode: indexCode,
  1318. // Value: value,
  1319. // DataTime: format,
  1320. // })
  1321. //
  1322. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1323. // if err != nil {
  1324. // return nil, err
  1325. // }
  1326. // utils.FileLog.Info("UpstreamSupplyOPECPolicyComplianceProcessor indexInfoList: %v", indexInfoList)
  1327. //
  1328. // // step_3: 指标数据
  1329. // dataList, err := dealData(indexInfoList)
  1330. // if err != nil {
  1331. // return nil, err
  1332. // }
  1333. // utils.FileLog.Info("UpstreamSupplyOPECPolicyComplianceProcessor dataList: %v", dataList)
  1334. //
  1335. // return dataList, err
  1336. // }
  1337. //
  1338. // // UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor
  1339. // // @Description: UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor处理器
  1340. // type UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor struct{}
  1341. //
  1342. // var rzdProductionSubjectToCutFlag string
  1343. //
  1344. // func (p *UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1345. // utils.FileLog.Info("Processing UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor...")
  1346. // if rowIndex <= 1 {
  1347. // return nil, nil
  1348. // }
  1349. //
  1350. // if rowData[0] != "" {
  1351. // rzdProductionSubjectToCutFlag = rowData[0]
  1352. // } else {
  1353. // rowData[0] = rzdProductionSubjectToCutFlag
  1354. // }
  1355. //
  1356. // frequency := "月度"
  1357. // unit := "kbbl/d"
  1358. // indexNameColPrefix := "OPEC_Policy"
  1359. // indexNameColSuffix := "Production Subject To Cut"
  1360. //
  1361. // if !utils.IsNumeric(rowData[0]) {
  1362. // return nil, nil
  1363. // }
  1364. // if rowData[1] == "Sum" {
  1365. // return nil, nil
  1366. // }
  1367. //
  1368. // // step_1: 分类
  1369. // classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1370. // if err != nil {
  1371. // return nil, err
  1372. // }
  1373. // utils.FileLog.Info("classifyId: %v", classifyId)
  1374. //
  1375. // // step_2: 指标
  1376. // // 指标名称
  1377. // indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1378. //
  1379. // // 生成指标编码
  1380. // indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1381. //
  1382. // var indexInfoList []*models.IndexInfo
  1383. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1384. // if err != nil {
  1385. // return nil, err
  1386. // }
  1387. //
  1388. // dataTime := rowData[0]
  1389. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1390. // if err != nil {
  1391. // return nil, err
  1392. // }
  1393. //
  1394. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1395. // IndexName: indexName,
  1396. // IndexCode: indexCode,
  1397. // Value: value,
  1398. // DataTime: format,
  1399. // })
  1400. //
  1401. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1402. // if err != nil {
  1403. // return nil, err
  1404. // }
  1405. // utils.FileLog.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor indexInfoList: %v", indexInfoList)
  1406. //
  1407. // // step_3: 指标数据
  1408. // dataList, err := dealData(indexInfoList)
  1409. // if err != nil {
  1410. // return nil, err
  1411. // }
  1412. // utils.FileLog.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor dataList: %v", dataList)
  1413. //
  1414. // return dataList, err
  1415. // }
  1416. //
  1417. // // ProductsDemandProductsDemandMeanProcessor
  1418. // // @Description: ProductsDemandProductsDemandMeanProcessor处理器
  1419. // type ProductsDemandProductsDemandMeanProcessor struct{}
  1420. //
  1421. // var rzdProductsDemandMeanFlag string
  1422. //
  1423. // func (p *ProductsDemandProductsDemandMeanProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1424. // utils.FileLog.Info("Processing ProductsDemandProductsDemandMeanProcessor...")
  1425. // if rowIndex <= 1 {
  1426. // return nil, nil
  1427. // }
  1428. //
  1429. // if rowData[0] != "" {
  1430. // rzdProductsDemandMeanFlag = rowData[0]
  1431. // } else {
  1432. // rowData[0] = rzdProductsDemandMeanFlag
  1433. // }
  1434. //
  1435. // frequency := "月度"
  1436. // unit := "kbbl/d"
  1437. // //indexNameColPrefix := "OPEC_Policy"
  1438. // indexNameColSuffix := "Products Demand Mean (1.0 DG) "
  1439. //
  1440. // if !utils.IsNumeric(rowData[0]) {
  1441. // return nil, nil
  1442. // }
  1443. // if rowData[1] == "Sum" {
  1444. // return nil, nil
  1445. // }
  1446. //
  1447. // // step_1: 分类
  1448. // classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  1449. // if err != nil {
  1450. // return nil, err
  1451. // }
  1452. // utils.FileLog.Info("classifyId: %v", classifyId)
  1453. //
  1454. // // step_2: 指标
  1455. // // 指标名称
  1456. // indexName := "Products Demand" + "/" + indexNameColSuffix
  1457. //
  1458. // // 生成指标编码
  1459. // indexCode, err := getIndexId("Products Demand "+"Products Demand Mean", strings.ReplaceAll(strings.ToLower("1.0dg"), " ", ""), "")
  1460. //
  1461. // var indexInfoList []*models.IndexInfo
  1462. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1463. // if err != nil {
  1464. // return nil, err
  1465. // }
  1466. //
  1467. // dataTime := rowData[0]
  1468. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1469. // if err != nil {
  1470. // return nil, err
  1471. // }
  1472. //
  1473. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1474. // IndexName: indexName,
  1475. // IndexCode: indexCode,
  1476. // Value: value,
  1477. // DataTime: format,
  1478. // })
  1479. //
  1480. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1481. // if err != nil {
  1482. // return nil, err
  1483. // }
  1484. // utils.FileLog.Info("ProductsDemandProductsDemandMeanProcessor indexInfoList: %v", indexInfoList)
  1485. //
  1486. // // step_3: 指标数据
  1487. // dataList, err := dealData(indexInfoList)
  1488. // if err != nil {
  1489. // return nil, err
  1490. // }
  1491. // utils.FileLog.Info("ProductsDemandProductsDemandMeanProcessor dataList: %v", dataList)
  1492. //
  1493. // return dataList, err
  1494. // }
  1495. //
  1496. // // ProductsDemandProductsDemandAddSigmaProcessor
  1497. // // @Description: ProductsDemandProductsDemandAddSigmaProcessor处理器
  1498. // type ProductsDemandProductsDemandAddSigmaProcessor struct{}
  1499. //
  1500. // var rzdAddSigmaFlag string
  1501. //
  1502. // func (p *ProductsDemandProductsDemandAddSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1503. // utils.FileLog.Info("Processing ProductsDemandProductsDemandAddSigmaProcessor...")
  1504. // if rowIndex <= 1 {
  1505. // return nil, nil
  1506. // }
  1507. //
  1508. // if rowData[0] != "" {
  1509. // rzdAddSigmaFlag = rowData[0]
  1510. // } else {
  1511. // rowData[0] = rzdAddSigmaFlag
  1512. // }
  1513. //
  1514. // frequency := "月度"
  1515. // unit := "kbbl/d"
  1516. // //indexNameColPrefix := "OPEC_Policy"
  1517. // indexNameColSuffix := "Products Demand +Sigma (2.2 DG) "
  1518. //
  1519. // if !utils.IsNumeric(rowData[0]) {
  1520. // return nil, nil
  1521. // }
  1522. // if rowData[1] == "Sum" {
  1523. // return nil, nil
  1524. // }
  1525. //
  1526. // // step_1: 分类
  1527. // classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  1528. // if err != nil {
  1529. // return nil, err
  1530. // }
  1531. // utils.FileLog.Info("classifyId: %v", classifyId)
  1532. //
  1533. // // step_2: 指标
  1534. // // 指标名称
  1535. // indexName := "Products Demand" + "/" + indexNameColSuffix
  1536. //
  1537. // // 生成指标编码
  1538. // indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("2.2dg"), " ", ""), "")
  1539. //
  1540. // var indexInfoList []*models.IndexInfo
  1541. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1542. // if err != nil {
  1543. // return nil, err
  1544. // }
  1545. //
  1546. // dataTime := rowData[0]
  1547. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1548. // if err != nil {
  1549. // return nil, err
  1550. // }
  1551. //
  1552. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1553. // IndexName: indexName,
  1554. // IndexCode: indexCode,
  1555. // Value: value,
  1556. // DataTime: format,
  1557. // })
  1558. //
  1559. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1560. // if err != nil {
  1561. // return nil, err
  1562. // }
  1563. // utils.FileLog.Info("ProductsDemandProductsDemandAddSigmaProcessor indexInfoList: %v", indexInfoList)
  1564. //
  1565. // // step_3: 指标数据
  1566. // dataList, err := dealData(indexInfoList)
  1567. // if err != nil {
  1568. // return nil, err
  1569. // }
  1570. // utils.FileLog.Info("ProductsDemandProductsDemandAddSigmaProcessor dataList: %v", dataList)
  1571. //
  1572. // return dataList, err
  1573. // }
  1574. //
  1575. // // ProductsDemandProductsDemandSubSigmaProcessor
  1576. // // @Description: ProductsDemandProductsDemandSubSigmaProcessor处理器
  1577. // type ProductsDemandProductsDemandSubSigmaProcessor struct{}
  1578. //
  1579. // var rzdSubSigmaFlag string
  1580. //
  1581. // func (p *ProductsDemandProductsDemandSubSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1582. // utils.FileLog.Info("Processing ProductsDemandProductsDemandSubSigmaProcessor...")
  1583. // if rowIndex <= 1 {
  1584. // return nil, nil
  1585. // }
  1586. //
  1587. // if rowData[0] != "" {
  1588. // rzdSubSigmaFlag = rowData[0]
  1589. // } else {
  1590. // rowData[0] = rzdSubSigmaFlag
  1591. // }
  1592. //
  1593. // frequency := "月度"
  1594. // unit := "kbbl/d"
  1595. // //indexNameColPrefix := "OPEC_Policy"
  1596. // indexNameColSuffix := "Products Demand -Sigma (1.8 DG) "
  1597. //
  1598. // if !utils.IsNumeric(rowData[0]) {
  1599. // return nil, nil
  1600. // }
  1601. // if rowData[1] == "Sum" {
  1602. // return nil, nil
  1603. // }
  1604. //
  1605. // // step_1: 分类
  1606. // classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  1607. // if err != nil {
  1608. // return nil, err
  1609. // }
  1610. // utils.FileLog.Info("classifyId: %v", classifyId)
  1611. //
  1612. // // step_2: 指标
  1613. // // 指标名称
  1614. // indexName := "Products Demand" + "/" + indexNameColSuffix
  1615. //
  1616. // // 生成指标编码
  1617. // indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("1.8dg"), " ", ""), "")
  1618. //
  1619. // var indexInfoList []*models.IndexInfo
  1620. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1621. // if err != nil {
  1622. // return nil, err
  1623. // }
  1624. //
  1625. // dataTime := rowData[0]
  1626. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1627. // if err != nil {
  1628. // return nil, err
  1629. // }
  1630. //
  1631. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1632. // IndexName: indexName,
  1633. // IndexCode: indexCode,
  1634. // Value: value,
  1635. // DataTime: format,
  1636. // })
  1637. //
  1638. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1639. // if err != nil {
  1640. // return nil, err
  1641. // }
  1642. // utils.FileLog.Info("ProductsDemandProductsDemandSubSigmaProcessor indexInfoList: %v", indexInfoList)
  1643. //
  1644. // // step_3: 指标数据
  1645. // dataList, err := dealData(indexInfoList)
  1646. // if err != nil {
  1647. // return nil, err
  1648. // }
  1649. // utils.FileLog.Info("ProductsDemandProductsDemandSubSigmaProcessor dataList: %v", dataList)
  1650. //
  1651. // return dataList, err
  1652. // }
  1653. //
  1654. // // BalancesTotalLiquidsBalancesProcessor
  1655. // // @Description: BalancesTotalLiquidsBalancesProcessor处理器
  1656. // type BalancesTotalLiquidsBalancesProcessor struct{}
  1657. //
  1658. // var rzdTotalLiquidsBalancesFlag string
  1659. //
  1660. // func (p *BalancesTotalLiquidsBalancesProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1661. // utils.FileLog.Info("Processing BalancesTotalLiquidsBalancesProcessor...")
  1662. // if rowIndex <= 1 {
  1663. // return nil, nil
  1664. // }
  1665. //
  1666. // if rowData[0] != "" {
  1667. // rzdTotalLiquidsBalancesFlag = rowData[0]
  1668. // } else {
  1669. // rowData[0] = rzdTotalLiquidsBalancesFlag
  1670. // }
  1671. //
  1672. // frequency := "月度"
  1673. // unit := "kbbl/d"
  1674. // //indexNameColPrefix := "OPEC_Policy"
  1675. // indexNameColSuffix := "Total Liquids Balances"
  1676. //
  1677. // if !utils.IsNumeric(rowData[0]) {
  1678. // return nil, nil
  1679. // }
  1680. // if rowData[1] == "Sum" {
  1681. // return nil, nil
  1682. // }
  1683. //
  1684. // // step_1: 分类
  1685. // classifyId, err := dealClassify("Oil Market Cube", "Balances")
  1686. // if err != nil {
  1687. // return nil, err
  1688. // }
  1689. // utils.FileLog.Info("classifyId: %v", classifyId)
  1690. //
  1691. // // step_2: 指标
  1692. // // 指标名称
  1693. // indexName := "Balances" + "/" + indexNameColSuffix
  1694. //
  1695. // // 生成指标编码
  1696. // indexCode, err := getIndexId("Balances", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1697. //
  1698. // var indexInfoList []*models.IndexInfo
  1699. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1700. // if err != nil {
  1701. // return nil, err
  1702. // }
  1703. //
  1704. // dataTime := rowData[0]
  1705. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1706. // if err != nil {
  1707. // return nil, err
  1708. // }
  1709. //
  1710. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1711. // IndexName: indexName,
  1712. // IndexCode: indexCode,
  1713. // Value: value,
  1714. // DataTime: format,
  1715. // })
  1716. //
  1717. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1718. // if err != nil {
  1719. // return nil, err
  1720. // }
  1721. // utils.FileLog.Info("BalancesTotalLiquidsBalancesProcessor indexInfoList: %v", indexInfoList)
  1722. //
  1723. // // step_3: 指标数据
  1724. // dataList, err := dealData(indexInfoList)
  1725. // if err != nil {
  1726. // return nil, err
  1727. // }
  1728. // utils.FileLog.Info("BalancesTotalLiquidsBalancesProcessor dataList: %v", dataList)
  1729. //
  1730. // return dataList, err
  1731. // }
  1732. //
  1733. // // GeographyLatitudeProcessor
  1734. // // @Description: GeographyLatitudeProcessor处理器
  1735. // type GeographyLatitudeProcessor struct{}
  1736. //
  1737. // var rzdLatitudeFlag string
  1738. //
  1739. // func (p *GeographyLatitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1740. // utils.FileLog.Info("Processing GeographyLatitudeProcessor...")
  1741. // if rowIndex <= 1 {
  1742. // return nil, nil
  1743. // }
  1744. //
  1745. // if rowData[0] != "" {
  1746. // rzdLatitudeFlag = rowData[0]
  1747. // } else {
  1748. // rowData[0] = rzdLatitudeFlag
  1749. // }
  1750. //
  1751. // frequency := "月度"
  1752. // unit := ""
  1753. // //indexNameColPrefix := "OPEC_Policy"
  1754. // indexNameColSuffix := "Latitude"
  1755. //
  1756. // if !utils.IsNumeric(rowData[0]) {
  1757. // return nil, nil
  1758. // }
  1759. // if rowData[1] == "Sum" {
  1760. // return nil, nil
  1761. // }
  1762. //
  1763. // // step_1: 分类
  1764. // classifyId, err := dealClassify("Oil Market Cube", "Geography")
  1765. // if err != nil {
  1766. // return nil, err
  1767. // }
  1768. // utils.FileLog.Info("classifyId: %v", classifyId)
  1769. //
  1770. // // step_2: 指标
  1771. // // 指标名称
  1772. // indexName := "Geography" + "/" + indexNameColSuffix
  1773. //
  1774. // // 生成指标编码
  1775. // indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1776. //
  1777. // var indexInfoList []*models.IndexInfo
  1778. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1779. // if err != nil {
  1780. // return nil, err
  1781. // }
  1782. //
  1783. // dataTime := rowData[0]
  1784. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1785. // if err != nil {
  1786. // return nil, err
  1787. // }
  1788. //
  1789. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1790. // IndexName: indexName,
  1791. // IndexCode: indexCode,
  1792. // Value: value,
  1793. // DataTime: format,
  1794. // })
  1795. //
  1796. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1797. // if err != nil {
  1798. // return nil, err
  1799. // }
  1800. // utils.FileLog.Info("GeographyLatitudeProcessor indexInfoList: %v", indexInfoList)
  1801. //
  1802. // // step_3: 指标数据
  1803. // dataList, err := dealData(indexInfoList)
  1804. // if err != nil {
  1805. // return nil, err
  1806. // }
  1807. // utils.FileLog.Info("GeographyLatitudeProcessor dataList: %v", dataList)
  1808. //
  1809. // return dataList, err
  1810. // }
  1811. //
  1812. // // GeographyLongitudeProcessor
  1813. // // @Description: GeographyLongitudeProcessor处理器
  1814. // type GeographyLongitudeProcessor struct{}
  1815. //
  1816. // var rzdLongitudeFlag string
  1817. //
  1818. // func (p *GeographyLongitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1819. // utils.FileLog.Info("Processing GeographyLongitudeProcessor...")
  1820. // if rowIndex <= 1 {
  1821. // return nil, nil
  1822. // }
  1823. //
  1824. // if rowData[0] != "" {
  1825. // rzdLongitudeFlag = rowData[0]
  1826. // } else {
  1827. // rowData[0] = rzdLongitudeFlag
  1828. // }
  1829. //
  1830. // frequency := "月度"
  1831. // unit := ""
  1832. // //indexNameColPrefix := "OPEC_Policy"
  1833. // indexNameColSuffix := "Longitude"
  1834. //
  1835. // if !utils.IsNumeric(rowData[0]) {
  1836. // return nil, nil
  1837. // }
  1838. // if rowData[1] == "Sum" {
  1839. // return nil, nil
  1840. // }
  1841. //
  1842. // // step_1: 分类
  1843. // classifyId, err := dealClassify("Oil Market Cube", "Geography")
  1844. // if err != nil {
  1845. // return nil, err
  1846. // }
  1847. // utils.FileLog.Info("classifyId: %v", classifyId)
  1848. //
  1849. // // step_2: 指标
  1850. // // 指标名称
  1851. // indexName := "Geography" + "/" + indexNameColSuffix
  1852. //
  1853. // // 生成指标编码
  1854. // indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1855. //
  1856. // var indexInfoList []*models.IndexInfo
  1857. // value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1858. // if err != nil {
  1859. // return nil, err
  1860. // }
  1861. //
  1862. // dataTime := rowData[0]
  1863. // format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1864. // if err != nil {
  1865. // return nil, err
  1866. // }
  1867. //
  1868. // indexInfoList = append(indexInfoList, &models.IndexInfo{
  1869. // IndexName: indexName,
  1870. // IndexCode: indexCode,
  1871. // Value: value,
  1872. // DataTime: format,
  1873. // })
  1874. //
  1875. // indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1876. // if err != nil {
  1877. // return nil, err
  1878. // }
  1879. // utils.FileLog.Info("GeographyLongitudeProcessor indexInfoList: %v", indexInfoList)
  1880. //
  1881. // // step_3: 指标数据
  1882. // dataList, err := dealData(indexInfoList)
  1883. // if err != nil {
  1884. // return nil, err
  1885. // }
  1886. // utils.FileLog.Info("GeographyLongitudeProcessor dataList: %v", dataList)
  1887. //
  1888. // return dataList, err
  1889. // }
  1890. //
  1891. // func dealIndex(indexInfoList []*models.IndexInfo, frequency string, unit string, classifyId int) ([]*models.IndexInfo, error) {
  1892. // for _, index := range indexInfoList {
  1893. // // 处理第一个指标
  1894. // paramsLib := make(map[string]interface{})
  1895. // paramsLib["indexCode"] = index.IndexCode
  1896. // postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_INDEX_BY_CODE)
  1897. // if err != nil {
  1898. // return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  1899. // }
  1900. // var requestResponse models.RequestResponse[models.BaseFromRzdIndex]
  1901. // err = json.Unmarshal(postEdbLib, &requestResponse)
  1902. // if err != nil {
  1903. // return nil, err
  1904. // }
  1905. // if requestResponse.Data.BaseFromRzdIndexId == 0 {
  1906. // indexOne := models.BaseFromRzdIndex{
  1907. // CreateTime: utils.GetCurrentTime(),
  1908. // ModifyTime: utils.GetCurrentTime(),
  1909. // BaseFromLyClassifyId: classifyId,
  1910. // IndexCode: index.IndexCode,
  1911. // IndexName: index.IndexName,
  1912. // Frequency: frequency,
  1913. // Unit: unit,
  1914. // }
  1915. // // 这里避免服务器宕机 出现唯一索引异常,进行分开保存
  1916. // postEdbLib, err = httpRequestFill(indexOne, utils.ADD_RZD_INDEX)
  1917. // if err != nil {
  1918. // return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  1919. // }
  1920. // var requestResponse models.RequestResponse[int]
  1921. // err = json.Unmarshal(postEdbLib, &requestResponse)
  1922. // if err != nil {
  1923. // return nil, err
  1924. // }
  1925. // utils.FileLog.Info("indexOneId: %v", requestResponse.Data)
  1926. // //index.IndexInfoId = requestResponse.Data
  1927. // } else {
  1928. // utils.FileLog.Info("indexOneId: %v", requestResponse.Data.BaseFromRzdIndexId)
  1929. // //index.IndexInfoId = requestResponse.Data.BaseFromRzdIndexId
  1930. // }
  1931. // }
  1932. // return indexInfoList, nil
  1933. // }
  1934. func getIndexId(prefix string, area string, suffix string) (indexCode string) {
  1935. prefixWords := strings.Fields(prefix) // 分割字符串为单词
  1936. firstLetters := ""
  1937. for _, word := range prefixWords {
  1938. if len(word) > 0 {
  1939. firstLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  1940. }
  1941. }
  1942. suffixWords := strings.Fields(suffix) // 分割字符串为单词
  1943. SecondLetters := ""
  1944. for _, word := range suffixWords {
  1945. if len(word) > 0 {
  1946. SecondLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  1947. }
  1948. }
  1949. indexCode = "rzd" + firstLetters + area + SecondLetters
  1950. return
  1951. }
  1952. // 处理分类
  1953. type BatchAddClassifyType struct {
  1954. List []models.AddRzdClassify
  1955. }
  1956. func dealClassify(tableName string, sheetNames []string) (classifyList map[string]int, err error) {
  1957. var rzdClassifyList []models.AddRzdClassify
  1958. var parentId int
  1959. classifyList = make(map[string]int)
  1960. rzdMapStruct := classifyMap[tableName]
  1961. // 查询一级分类是否存在
  1962. if classify, ok := RzdClassifyMap[rzdMapStruct.ClassifyName]; !ok {
  1963. parentClassify := models.AddRzdClassify{
  1964. ClassifyName: rzdMapStruct.ClassifyName,
  1965. Sort: rzdMapStruct.Sort,
  1966. ParentId: 0,
  1967. }
  1968. rzdClassifyList = append(rzdClassifyList, parentClassify)
  1969. resp, httpErr := httpRequestFill(BatchAddClassifyType{
  1970. List: rzdClassifyList,
  1971. }, utils.BATCH_ADD_RZD_CLASSYFY)
  1972. if httpErr != nil {
  1973. err = fmt.Errorf("添加睿咨得分类失败: %v", err)
  1974. return
  1975. }
  1976. var rzdResp models.RequestResponse[[]models.BaseFromRzdClassify]
  1977. jsonErr := json.Unmarshal(resp, &rzdResp)
  1978. if jsonErr != nil {
  1979. err = fmt.Errorf("解析添加睿咨得分类失败: %v", err)
  1980. return
  1981. }
  1982. if rzdResp.Ret != 200 {
  1983. err = fmt.Errorf("添加睿咨得分类失败: %v", err)
  1984. return
  1985. }
  1986. parentId = rzdResp.Data[0].BaseFromRzdClassifyId
  1987. classifyList[tableName] = rzdResp.Data[0].BaseFromRzdClassifyId
  1988. } else {
  1989. parentId = classify.BaseFromRzdClassifyId
  1990. classifyList[tableName] = classify.BaseFromRzdClassifyId
  1991. }
  1992. rzdClassifyList = []models.AddRzdClassify{}
  1993. //处理二级分类
  1994. for _, sheetName := range sheetNames {
  1995. if sheetName == "Content" {
  1996. continue
  1997. }
  1998. rzdMapStruct = classifyMap[sheetName]
  1999. if classify, ok := RzdClassifyMap[rzdMapStruct.ClassifyName]; !ok {
  2000. rzdClassifyList = append(rzdClassifyList, models.AddRzdClassify{
  2001. ClassifyName: rzdMapStruct.ClassifyName,
  2002. Sort: rzdMapStruct.Sort,
  2003. ParentId: parentId,
  2004. })
  2005. } else {
  2006. classifyList[sheetName] = classify.BaseFromRzdClassifyId
  2007. }
  2008. }
  2009. if len(rzdClassifyList) > 0 {
  2010. resp, httpErr := httpRequestFill(BatchAddClassifyType{
  2011. List: rzdClassifyList}, utils.BATCH_ADD_RZD_CLASSYFY)
  2012. if httpErr != nil {
  2013. err = fmt.Errorf("添加睿咨得分类失败: %v", err)
  2014. return
  2015. }
  2016. var rzdResp models.RequestResponse[[]models.BaseFromRzdClassify]
  2017. jsonErr := json.Unmarshal(resp, &rzdResp)
  2018. if jsonErr != nil {
  2019. err = fmt.Errorf("解析添加睿咨得分类失败: %v", err)
  2020. return
  2021. }
  2022. if rzdResp.Ret != 200 {
  2023. err = fmt.Errorf("添加睿咨得分类失败: %v", err)
  2024. return
  2025. }
  2026. for _, classify := range rzdResp.Data {
  2027. classifyList[classify.ClassifyName] = classify.BaseFromRzdClassifyId
  2028. }
  2029. }
  2030. return
  2031. }
  2032. // 处理分类
  2033. func getRzdClassifyList() (list []*models.BaseFromRzdClassify, err error) {
  2034. //查询睿咨得分类
  2035. postEdbLib, httpErr := httpRequestFill(nil, utils.GET_RZD_CLASSIFY)
  2036. if httpErr != nil {
  2037. err = fmt.Errorf("获取睿咨得分类数据失败: %v", httpErr)
  2038. return
  2039. }
  2040. var requestResponse models.RequestResponse[[]*models.BaseFromRzdClassify]
  2041. jsonErr := json.Unmarshal(postEdbLib, &requestResponse)
  2042. if jsonErr != nil {
  2043. err = fmt.Errorf("获取睿咨得分类数据失败,解析JSON数据失败: %v", jsonErr)
  2044. return
  2045. }
  2046. if requestResponse.Ret != 200 {
  2047. err = fmt.Errorf("获取睿咨得分类数据失败,请求应答异常: %v", requestResponse.ErrMsg)
  2048. return
  2049. }
  2050. return requestResponse.Data, nil
  2051. }