processor_business_logic.go 96 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469
  1. // Package ruizide
  2. // @Author gmy 2024/10/21 10:50:00
  3. package main
  4. import (
  5. "encoding/json"
  6. "eta/eta_data_analysis/models"
  7. "eta/eta_data_analysis/utils"
  8. "fmt"
  9. "github.com/beego/beego/v2/core/logs"
  10. "math"
  11. "strconv"
  12. "strings"
  13. "unicode"
  14. )
  15. var classifyMap = map[string]string{
  16. "Road Index": "analytics library",
  17. "Road Active Fleet": "analytics library",
  18. "Aviation Index": "analytics library",
  19. "Aviation Active Fleet": "analytics library",
  20. "Demand-Gasoline": "analytics library",
  21. "Demand - Diesel": "analytics library",
  22. "Demand - Jet Fuel": "analytics library",
  23. "Demand - Maritime Bunker": "analytics library",
  24. "Oil_Demand_Signals_Weekly_Report": "analytics library",
  25. "cube dashboards": "cube dashboards",
  26. "Oil Market Cube": "Oil Market Cube",
  27. }
  28. // RoadIndexProcessor
  29. // @Description: AnalyticsLibrary处理器
  30. type RoadIndexProcessor struct{}
  31. func (p *RoadIndexProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  32. logs.Info("Processing AnalyticsLibrary...")
  33. if tableName == "Content" {
  34. return nil, nil
  35. }
  36. if rowIndex < 4 {
  37. return nil, nil
  38. }
  39. frequency := "日度"
  40. unit := "%"
  41. indexNameColOne := "Index"
  42. indexNameColTwo := "Index 7DMA"
  43. // step_1: 分类
  44. classifyId, err := dealClassify(tableName, sheetName)
  45. if err != nil {
  46. return nil, err
  47. }
  48. logs.Info("classifyId: %v", classifyId)
  49. // step_2: 指标
  50. // 指标名称
  51. indexNameOne := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  52. indexNameTwo := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  53. // 生成指标编码
  54. indexCodeOne, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  55. indexCodeTwo, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  56. indexInfoMap := make(map[string]string)
  57. indexInfoMap[indexCodeOne] = indexNameOne
  58. indexInfoMap[indexCodeTwo] = indexNameTwo
  59. var indexInfoList []*models.IndexInfo
  60. valueOne, err := strconv.ParseFloat(rowData[len(rowData)-2], 64)
  61. if err != nil {
  62. return nil, err
  63. }
  64. dataTimeOne := rowData[1]
  65. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  66. if err != nil {
  67. return nil, err
  68. }
  69. indexInfoList = append(indexInfoList, &models.IndexInfo{
  70. IndexName: indexNameOne,
  71. IndexCode: indexCodeOne,
  72. Value: valueOne,
  73. DataTime: formatOne,
  74. })
  75. valueTwo, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  76. if err != nil {
  77. return nil, err
  78. }
  79. indexInfoList = append(indexInfoList, &models.IndexInfo{
  80. IndexName: indexNameTwo,
  81. IndexCode: indexCodeTwo,
  82. Value: valueTwo,
  83. DataTime: formatOne,
  84. })
  85. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  86. if err != nil {
  87. return nil, err
  88. }
  89. logs.Info("indexInfoList: %v", indexInfoList)
  90. // step_3: 指标数据
  91. dataList, err := dealData(indexInfoList)
  92. if err != nil {
  93. return nil, err
  94. }
  95. logs.Info("dataList: %v", dataList)
  96. return dataList, err
  97. }
  98. // RoadActiveFleetProcessor
  99. // @Description: RoadActiveFleetProcessor处理器
  100. type RoadActiveFleetProcessor struct{}
  101. func (p *RoadActiveFleetProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  102. logs.Info("Processing RoadActiveFleet...")
  103. if tableName == "Content" {
  104. return nil, nil
  105. }
  106. if rowIndex < 4 {
  107. return nil, nil
  108. }
  109. frequency := "日度"
  110. unit := "辆"
  111. indexNameColOne := "Active Fleet"
  112. indexNameColTwo := "Active Fleet 7DMA"
  113. // step_1: 分类
  114. classifyId, err := dealClassify(tableName, sheetName)
  115. if err != nil {
  116. return nil, err
  117. }
  118. logs.Info("classifyId: %v", classifyId)
  119. // step_2: 指标
  120. // 指标名称
  121. indexNameOne := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  122. indexNameTwo := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  123. // 生成指标编码
  124. indexCodeOne, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  125. indexCodeTwo, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  126. var indexInfoList []*models.IndexInfo
  127. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  128. if err != nil {
  129. return nil, err
  130. }
  131. dataTimeOne := rowData[1]
  132. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  133. if err != nil {
  134. return nil, err
  135. }
  136. indexInfoList = append(indexInfoList, &models.IndexInfo{
  137. IndexName: indexNameOne,
  138. IndexCode: indexCodeOne,
  139. Value: valueOne,
  140. DataTime: formatOne,
  141. })
  142. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  143. if err != nil {
  144. return nil, err
  145. }
  146. indexInfoList = append(indexInfoList, &models.IndexInfo{
  147. IndexName: indexNameTwo,
  148. IndexCode: indexCodeTwo,
  149. Value: valueTwo,
  150. DataTime: formatOne,
  151. })
  152. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  153. if err != nil {
  154. return nil, err
  155. }
  156. logs.Info("RoadActiveFleetProcessor indexInfoList: %v", indexInfoList)
  157. // step_3: 指标数据
  158. dataList, err := dealData(indexInfoList)
  159. if err != nil {
  160. return nil, err
  161. }
  162. logs.Info("RoadActiveFleetProcessor dataList: %v", dataList)
  163. return dataList, err
  164. }
  165. // AviationIndexProcessor
  166. // @Description: AviationIndexProcessor处理器
  167. type AviationIndexProcessor struct{}
  168. func (p *AviationIndexProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  169. logs.Info("Processing AviationIndexProcessor...")
  170. if tableName == "Content" {
  171. return nil, nil
  172. }
  173. if rowIndex < 4 {
  174. return nil, nil
  175. }
  176. frequency := "日度"
  177. unit := "%"
  178. indexNameColOne := "Index"
  179. indexNameColTwo := "Index 7DMA"
  180. // step_1: 分类
  181. classifyId, err := dealClassify(tableName, sheetName)
  182. if err != nil {
  183. return nil, err
  184. }
  185. logs.Info("classifyId: %v", classifyId)
  186. // step_2: 指标
  187. // 指标名称
  188. indexNameOne := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  189. indexNameTwo := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  190. // 生成指标编码
  191. indexCodeOne, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  192. indexCodeTwo, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  193. var indexInfoList []*models.IndexInfo
  194. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  195. if err != nil {
  196. return nil, err
  197. }
  198. dataTimeOne := rowData[1]
  199. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  200. if err != nil {
  201. return nil, err
  202. }
  203. indexInfoList = append(indexInfoList, &models.IndexInfo{
  204. IndexName: indexNameOne,
  205. IndexCode: indexCodeOne,
  206. Value: valueOne,
  207. DataTime: formatOne,
  208. })
  209. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  210. if err != nil {
  211. return nil, err
  212. }
  213. indexInfoList = append(indexInfoList, &models.IndexInfo{
  214. IndexName: indexNameTwo,
  215. IndexCode: indexCodeTwo,
  216. Value: valueTwo,
  217. DataTime: formatOne,
  218. })
  219. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  220. if err != nil {
  221. return nil, err
  222. }
  223. logs.Info("AviationIndexProcessor indexInfoList: %v", indexInfoList)
  224. // step_3: 指标数据
  225. dataList, err := dealData(indexInfoList)
  226. if err != nil {
  227. return nil, err
  228. }
  229. logs.Info("AviationIndexProcessor dataList: %v", dataList)
  230. return dataList, err
  231. }
  232. // AviationActiveFleetProcessor
  233. // @Description: AviationActiveFleetProcessor处理器
  234. type AviationActiveFleetProcessor struct{}
  235. func (p *AviationActiveFleetProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  236. logs.Info("Processing AviationActiveFleetProcessor...")
  237. if tableName == "Content" {
  238. return nil, nil
  239. }
  240. if rowIndex < 4 {
  241. return nil, nil
  242. }
  243. frequency := "日度"
  244. unit := "辆"
  245. indexNameColOne := "Active Fleet"
  246. indexNameColTwo := "Active Fleet 7DMA"
  247. // step_1: 分类
  248. classifyId, err := dealClassify(tableName, sheetName)
  249. if err != nil {
  250. return nil, err
  251. }
  252. logs.Info("classifyId: %v", classifyId)
  253. // step_2: 指标
  254. // 指标名称
  255. indexNameOne := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  256. indexNameTwo := sheetName + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  257. // 生成指标编码
  258. indexCodeOne, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  259. indexCodeTwo, err := getIndexId(sheetName, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  260. var indexInfoList []*models.IndexInfo
  261. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  262. if err != nil {
  263. return nil, err
  264. }
  265. dataTimeOne := rowData[1]
  266. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  267. if err != nil {
  268. return nil, err
  269. }
  270. indexInfoList = append(indexInfoList, &models.IndexInfo{
  271. IndexName: indexNameOne,
  272. IndexCode: indexCodeOne,
  273. Value: valueOne,
  274. DataTime: formatOne,
  275. })
  276. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  277. if err != nil {
  278. return nil, err
  279. }
  280. indexInfoList = append(indexInfoList, &models.IndexInfo{
  281. IndexName: indexNameTwo,
  282. IndexCode: indexCodeTwo,
  283. Value: valueTwo,
  284. DataTime: formatOne,
  285. })
  286. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  287. if err != nil {
  288. return nil, err
  289. }
  290. logs.Info("AviationActiveFleetProcessor indexInfoList: %v", indexInfoList)
  291. // step_3: 指标数据
  292. dataList, err := dealData(indexInfoList)
  293. if err != nil {
  294. return nil, err
  295. }
  296. logs.Info("AviationActiveFleetProcessor dataList: %v", dataList)
  297. return dataList, err
  298. }
  299. // DemandGasolineProcessor
  300. // @Description: DemandGasolineProcessor处理器
  301. type DemandGasolineProcessor struct{}
  302. func (p *DemandGasolineProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  303. logs.Info("Processing DemandGasolineProcessor...")
  304. if tableName == "Content" {
  305. return nil, nil
  306. }
  307. if rowIndex < 4 {
  308. return nil, nil
  309. }
  310. frequency := "日度"
  311. unit := "千桶每天"
  312. indexNameColOne := "Demand"
  313. indexNameColTwo := "Demand 7DMA"
  314. // step_1: 分类
  315. classifyId, err := dealClassify(tableName, sheetName)
  316. if err != nil {
  317. return nil, err
  318. }
  319. logs.Info("classifyId: %v", classifyId)
  320. // step_2: 指标
  321. // 指标名称
  322. indexNameOne := "Gasoline Demand" + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  323. indexNameTwo := "Gasoline Demand" + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  324. // 生成指标编码
  325. indexCodeOne, err := getIndexId("Gasoline Demand", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  326. indexCodeTwo, err := getIndexId("Gasoline Demand", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  327. var indexInfoList []*models.IndexInfo
  328. var valueOne float64
  329. if rowData[len(rowData)-2] == "" {
  330. valueOne = 0
  331. } else {
  332. valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  333. if err != nil {
  334. return nil, err
  335. }
  336. }
  337. dataTimeOne := rowData[1]
  338. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  339. if err != nil {
  340. return nil, err
  341. }
  342. indexInfoList = append(indexInfoList, &models.IndexInfo{
  343. IndexName: indexNameOne,
  344. IndexCode: indexCodeOne,
  345. Value: valueOne,
  346. DataTime: formatOne,
  347. })
  348. var valueTwo float64
  349. if rowData[len(rowData)-1] == "" {
  350. valueTwo = 0
  351. } else {
  352. valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  353. if err != nil {
  354. return nil, err
  355. }
  356. }
  357. indexInfoList = append(indexInfoList, &models.IndexInfo{
  358. IndexName: indexNameTwo,
  359. IndexCode: indexCodeTwo,
  360. Value: valueTwo,
  361. DataTime: formatOne,
  362. })
  363. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  364. if err != nil {
  365. return nil, err
  366. }
  367. logs.Info("DemandGasolineProcessor indexInfoList: %v", indexInfoList)
  368. // step_3: 指标数据
  369. dataList, err := dealData(indexInfoList)
  370. if err != nil {
  371. return nil, err
  372. }
  373. logs.Info("DemandGasolineProcessor dataList: %v", dataList)
  374. return dataList, err
  375. }
  376. // DemandDieselProcessor
  377. // @Description: DemandDieselProcessor处理器
  378. type DemandDieselProcessor struct{}
  379. func (p *DemandDieselProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  380. logs.Info("Processing DemandDieselProcessor...")
  381. if tableName == "Content" {
  382. return nil, nil
  383. }
  384. if rowIndex < 4 {
  385. return nil, nil
  386. }
  387. frequency := "日度"
  388. unit := "千桶每天"
  389. indexNameColOne := "Demand"
  390. indexNameColTwo := "Demand 7DMA"
  391. // step_1: 分类
  392. classifyId, err := dealClassify(tableName, sheetName)
  393. if err != nil {
  394. return nil, err
  395. }
  396. logs.Info("classifyId: %v", classifyId)
  397. // step_2: 指标
  398. // 指标名称
  399. indexNameOne := "Demand Diesel" + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  400. indexNameTwo := "Demand Diesel" + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  401. // 生成指标编码
  402. indexCodeOne, err := getIndexId("Demand Diesel", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  403. indexCodeTwo, err := getIndexId("Demand Diesel", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  404. var indexInfoList []*models.IndexInfo
  405. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  406. if err != nil {
  407. return nil, err
  408. }
  409. dataTimeOne := rowData[1]
  410. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  411. if err != nil {
  412. return nil, err
  413. }
  414. indexInfoList = append(indexInfoList, &models.IndexInfo{
  415. IndexName: indexNameOne,
  416. IndexCode: indexCodeOne,
  417. Value: valueOne,
  418. DataTime: formatOne,
  419. })
  420. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  421. if err != nil {
  422. return nil, err
  423. }
  424. indexInfoList = append(indexInfoList, &models.IndexInfo{
  425. IndexName: indexNameTwo,
  426. IndexCode: indexCodeTwo,
  427. Value: valueTwo,
  428. DataTime: formatOne,
  429. })
  430. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  431. if err != nil {
  432. return nil, err
  433. }
  434. logs.Info("DemandDieselProcessor indexInfoList: %v", indexInfoList)
  435. // step_3: 指标数据
  436. dataList, err := dealData(indexInfoList)
  437. if err != nil {
  438. return nil, err
  439. }
  440. logs.Info("DemandDieselProcessor dataList: %v", dataList)
  441. return dataList, err
  442. }
  443. // DemandJetFuelProcessor
  444. // @Description: DemandJetFuelProcessor处理器
  445. type DemandJetFuelProcessor struct{}
  446. func (p *DemandJetFuelProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  447. logs.Info("Processing DemandJetFuelProcessor...")
  448. if tableName == "Content" {
  449. return nil, nil
  450. }
  451. if rowIndex < 4 {
  452. return nil, nil
  453. }
  454. frequency := "日度"
  455. unit := "千桶每天"
  456. indexNameColOne := "Demand"
  457. indexNameColTwo := "Demand 7DMA"
  458. // step_1: 分类
  459. classifyId, err := dealClassify(tableName, sheetName)
  460. if err != nil {
  461. return nil, err
  462. }
  463. logs.Info("classifyId: %v", classifyId)
  464. // step_2: 指标
  465. // 指标名称
  466. indexNameOne := "Demand Jet Fuel" + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  467. indexNameTwo := "Demand Jet Fuel" + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  468. // 生成指标编码
  469. indexCodeOne, err := getIndexId("Demand Jet Fuel", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  470. indexCodeTwo, err := getIndexId("Demand Jet Fuel", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  471. var indexInfoList []*models.IndexInfo
  472. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  473. if err != nil {
  474. return nil, err
  475. }
  476. dataTimeOne := rowData[1]
  477. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  478. if err != nil {
  479. return nil, err
  480. }
  481. indexInfoList = append(indexInfoList, &models.IndexInfo{
  482. IndexName: indexNameOne,
  483. IndexCode: indexCodeOne,
  484. Value: valueOne,
  485. DataTime: formatOne,
  486. })
  487. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  488. if err != nil {
  489. return nil, err
  490. }
  491. indexInfoList = append(indexInfoList, &models.IndexInfo{
  492. IndexName: indexNameTwo,
  493. IndexCode: indexCodeTwo,
  494. Value: valueTwo,
  495. DataTime: formatOne,
  496. })
  497. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  498. if err != nil {
  499. return nil, err
  500. }
  501. logs.Info("DemandJetFuelProcessor indexInfoList: %v", indexInfoList)
  502. // step_3: 指标数据
  503. dataList, err := dealData(indexInfoList)
  504. if err != nil {
  505. return nil, err
  506. }
  507. logs.Info("DemandJetFuelProcessor dataList: %v", dataList)
  508. return dataList, err
  509. }
  510. // DemandMaritimeBunkerProcessor
  511. // @Description: DemandMaritimeBunkerProcessor处理器
  512. type DemandMaritimeBunkerProcessor struct{}
  513. func (p *DemandMaritimeBunkerProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  514. logs.Info("Processing DemandMaritimeBunkerProcessor...")
  515. if tableName == "Content" {
  516. return nil, nil
  517. }
  518. if rowIndex < 4 {
  519. return nil, nil
  520. }
  521. frequency := "日度"
  522. unit := "千桶每天"
  523. indexNameColOne := "Demand"
  524. indexNameColTwo := "Demand 7DMA"
  525. // step_1: 分类
  526. classifyId, err := dealClassify(tableName, sheetName)
  527. if err != nil {
  528. return nil, err
  529. }
  530. logs.Info("classifyId: %v", classifyId)
  531. // step_2: 指标
  532. // 指标名称
  533. indexNameOne := "Demand Maritime Bunker" + "/" + rowData[len(rowData)-3] + "/" + indexNameColOne
  534. indexNameTwo := "Demand Maritime Bunker" + "/" + rowData[len(rowData)-3] + "/" + indexNameColTwo
  535. // 生成指标编码
  536. indexCodeOne, err := getIndexId("Demand Maritime Bunker", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColOne)
  537. indexCodeTwo, err := getIndexId("Demand Maritime Bunker", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-3]), " ", ""), indexNameColTwo)
  538. var indexInfoList []*models.IndexInfo
  539. valueOne, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  540. if err != nil {
  541. return nil, err
  542. }
  543. dataTimeOne := rowData[1]
  544. formatOne, err := utils.ConvertDateFormat(dataTimeOne)
  545. if err != nil {
  546. return nil, err
  547. }
  548. indexInfoList = append(indexInfoList, &models.IndexInfo{
  549. IndexName: indexNameOne,
  550. IndexCode: indexCodeOne,
  551. Value: valueOne,
  552. DataTime: formatOne,
  553. })
  554. valueTwo, err := strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  555. if err != nil {
  556. return nil, err
  557. }
  558. indexInfoList = append(indexInfoList, &models.IndexInfo{
  559. IndexName: indexNameTwo,
  560. IndexCode: indexCodeTwo,
  561. Value: valueTwo,
  562. DataTime: formatOne,
  563. })
  564. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  565. if err != nil {
  566. return nil, err
  567. }
  568. logs.Info("DemandMaritimeBunkerProcessor indexInfoList: %v", indexInfoList)
  569. // step_3: 指标数据
  570. dataList, err := dealData(indexInfoList)
  571. if err != nil {
  572. return nil, err
  573. }
  574. logs.Info("DemandMaritimeBunkerProcessor dataList: %v", dataList)
  575. return dataList, err
  576. }
  577. // SupplyRevisionAnalysisChartOneProcessor
  578. // @Description: SupplyRevisionAnalysisChartOneProcessor处理器
  579. type SupplyRevisionAnalysisChartOneProcessor struct{}
  580. func (p *SupplyRevisionAnalysisChartOneProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  581. logs.Info("Processing SupplyRevisionAnalysisChartOne...")
  582. if rowIndex < 1 {
  583. return nil, nil
  584. }
  585. frequency := "季度"
  586. unit := "千桶每天"
  587. indexNameColSuffix := "YearQuarter"
  588. indexNameColPrefix := "Country Revision Group"
  589. // step_1: 分类
  590. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  591. if err != nil {
  592. return nil, err
  593. }
  594. logs.Info("classifyId: %v", classifyId)
  595. // step_2: 指标
  596. // 指标名称
  597. indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
  598. // 生成指标编码
  599. indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" Year Quarter", strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
  600. indexInfoMap := make(map[string]string)
  601. indexInfoMap[indexCode] = indexName
  602. var indexInfoList []*models.IndexInfo
  603. var value float64
  604. if rowData[len(rowData)-2] == "" {
  605. value = 0
  606. } else {
  607. value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
  608. if err != nil {
  609. return nil, err
  610. }
  611. }
  612. dataTime := rowData[0]
  613. format, err := utils.ConvertDateFormat2(dataTime)
  614. if err != nil {
  615. return nil, err
  616. }
  617. indexInfoList = append(indexInfoList, &models.IndexInfo{
  618. IndexName: indexName,
  619. IndexCode: indexCode,
  620. Value: value,
  621. DataTime: format,
  622. })
  623. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  624. if err != nil {
  625. return nil, err
  626. }
  627. logs.Info("SupplyRevisionAnalysisChartOneProcessor indexInfoList: %v", indexInfoList)
  628. // step_3: 指标数据
  629. dataList, err := dealData(indexInfoList)
  630. if err != nil {
  631. return nil, err
  632. }
  633. logs.Info("SupplyRevisionAnalysisChartOneProcessor dataList: %v", dataList)
  634. return dataList, err
  635. }
  636. // SupplyRevisionAnalysisChartTwoProcessor
  637. // @Description: SupplyRevisionAnalysisChartTwoProcessor处理器
  638. type SupplyRevisionAnalysisChartTwoProcessor struct{}
  639. func (p *SupplyRevisionAnalysisChartTwoProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  640. logs.Info("Processing SupplyRevisionAnalysisChartTwoProcessor...")
  641. if rowIndex < 1 {
  642. return nil, nil
  643. }
  644. frequency := "季度"
  645. unit := "千桶每天"
  646. indexNameColPrefix := "YearQuarter"
  647. // step_1: 分类
  648. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  649. if err != nil {
  650. return nil, err
  651. }
  652. logs.Info("classifyId: %v", classifyId)
  653. // step_2: 指标
  654. // 指标名称
  655. indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
  656. indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
  657. // 生成指标编码
  658. indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Current", "")
  659. indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "Previous", "")
  660. var indexInfoList []*models.IndexInfo
  661. var valueOne float64
  662. if rowData[len(rowData)-2] == "" {
  663. valueOne = 0
  664. } else {
  665. valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  666. if err != nil {
  667. return nil, err
  668. }
  669. }
  670. dataTimeOne := rowData[1]
  671. formatOne, err := utils.ConvertDateFormat2(dataTimeOne)
  672. if err != nil {
  673. return nil, err
  674. }
  675. indexInfoList = append(indexInfoList, &models.IndexInfo{
  676. IndexName: indexNameOne,
  677. IndexCode: indexCodeOne,
  678. Value: valueOne,
  679. DataTime: formatOne,
  680. })
  681. var valueTwo float64
  682. if rowData[len(rowData)-1] == "" {
  683. valueTwo = 0
  684. } else {
  685. valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  686. if err != nil {
  687. return nil, err
  688. }
  689. }
  690. indexInfoList = append(indexInfoList, &models.IndexInfo{
  691. IndexName: indexNameTwo,
  692. IndexCode: indexCodeTwo,
  693. Value: valueTwo,
  694. DataTime: formatOne,
  695. })
  696. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  697. if err != nil {
  698. return nil, err
  699. }
  700. logs.Info("SupplyRevisionAnalysisChartTwoProcessor indexInfoList: %v", indexInfoList)
  701. // step_3: 指标数据
  702. dataList, err := dealData(indexInfoList)
  703. if err != nil {
  704. return nil, err
  705. }
  706. logs.Info("SupplyRevisionAnalysisChartTwoProcessor dataList: %v", dataList)
  707. return dataList, err
  708. }
  709. // SupplyRevisionAnalysisChartThreeProcessor
  710. // @Description: SupplyRevisionAnalysisChartThreeProcessor
  711. type SupplyRevisionAnalysisChartThreeProcessor struct{}
  712. func (p *SupplyRevisionAnalysisChartThreeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  713. logs.Info("Processing SupplyRevisionAnalysisChartThreeProcessor...")
  714. if rowIndex < 1 {
  715. return nil, nil
  716. }
  717. frequency := "年度"
  718. unit := "千桶每天"
  719. indexNameColSuffix := "Year"
  720. indexNameColPrefix := "Country Revision Group"
  721. // step_1: 分类
  722. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  723. if err != nil {
  724. return nil, err
  725. }
  726. logs.Info("classifyId: %v", classifyId)
  727. // step_2: 指标
  728. // 指标名称
  729. indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
  730. // 生成指标编码
  731. indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
  732. indexInfoMap := make(map[string]string)
  733. indexInfoMap[indexCode] = indexName
  734. var indexInfoList []*models.IndexInfo
  735. var value float64
  736. if rowData[len(rowData)-2] == "" {
  737. value = 0
  738. } else {
  739. value, err = strconv.ParseFloat(rowData[len(rowData)-2], 64)
  740. if err != nil {
  741. return nil, err
  742. }
  743. }
  744. dataTime := rowData[0]
  745. format, err := utils.ConvertDateFormat4(dataTime)
  746. if err != nil {
  747. return nil, err
  748. }
  749. indexInfoList = append(indexInfoList, &models.IndexInfo{
  750. IndexName: indexName,
  751. IndexCode: indexCode,
  752. Value: value,
  753. DataTime: format,
  754. })
  755. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  756. if err != nil {
  757. return nil, err
  758. }
  759. logs.Info("SupplyRevisionAnalysisChartThreeProcessor indexInfoList: %v", indexInfoList)
  760. // step_3: 指标数据
  761. dataList, err := dealData(indexInfoList)
  762. if err != nil {
  763. return nil, err
  764. }
  765. logs.Info("SupplyRevisionAnalysisChartThreeProcessor dataList: %v", dataList)
  766. return dataList, err
  767. }
  768. // SupplyRevisionAnalysisChartFourProcessor
  769. // @Description: SupplyRevisionAnalysisChartFourProcessor处理器
  770. type SupplyRevisionAnalysisChartFourProcessor struct{}
  771. func (p *SupplyRevisionAnalysisChartFourProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  772. logs.Info("Processing SupplyRevisionAnalysisChartFourProcessor...")
  773. if rowIndex < 1 {
  774. return nil, nil
  775. }
  776. frequency := "年度"
  777. unit := "千桶每天"
  778. indexNameColPrefix := "Year"
  779. // step_1: 分类
  780. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  781. if err != nil {
  782. return nil, err
  783. }
  784. logs.Info("classifyId: %v", classifyId)
  785. // step_2: 指标
  786. // 指标名称
  787. indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current"
  788. indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous"
  789. // 生成指标编码
  790. indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "current", "")
  791. indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previous", "")
  792. var indexInfoList []*models.IndexInfo
  793. var valueOne float64
  794. if rowData[len(rowData)-2] == "" {
  795. valueOne = 0
  796. } else {
  797. valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  798. if err != nil {
  799. return nil, err
  800. }
  801. }
  802. dataTimeOne := rowData[0]
  803. formatOne, err := utils.ConvertDateFormat4(dataTimeOne)
  804. if err != nil {
  805. return nil, err
  806. }
  807. indexInfoList = append(indexInfoList, &models.IndexInfo{
  808. IndexName: indexNameOne,
  809. IndexCode: indexCodeOne,
  810. Value: valueOne,
  811. DataTime: formatOne,
  812. })
  813. var valueTwo float64
  814. if rowData[len(rowData)-1] == "" {
  815. valueTwo = 0
  816. } else {
  817. valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-1], ",", ""), 64)
  818. if err != nil {
  819. return nil, err
  820. }
  821. }
  822. indexInfoList = append(indexInfoList, &models.IndexInfo{
  823. IndexName: indexNameTwo,
  824. IndexCode: indexCodeTwo,
  825. Value: valueTwo,
  826. DataTime: formatOne,
  827. })
  828. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  829. if err != nil {
  830. return nil, err
  831. }
  832. logs.Info("SupplyRevisionAnalysisChartFourProcessor indexInfoList: %v", indexInfoList)
  833. // step_3: 指标数据
  834. dataList, err := dealData(indexInfoList)
  835. if err != nil {
  836. return nil, err
  837. }
  838. logs.Info("SupplyRevisionAnalysisChartFourProcessor dataList: %v", dataList)
  839. return dataList, err
  840. }
  841. // SupplyRevisionAnalysisChartFiveProcessor
  842. // @Description: SupplyRevisionAnalysisChartFiveProcessor处理器
  843. type SupplyRevisionAnalysisChartFiveProcessor struct{}
  844. func (p *SupplyRevisionAnalysisChartFiveProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  845. logs.Info("Processing SupplyRevisionAnalysisChartFiveProcessor...")
  846. if rowIndex < 1 {
  847. return nil, nil
  848. }
  849. frequency := "月度"
  850. unit := "千桶每天"
  851. indexNameColPrefix := "YearMonth"
  852. // step_1: 分类
  853. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  854. if err != nil {
  855. return nil, err
  856. }
  857. logs.Info("classifyId: %v", classifyId)
  858. // step_2: 指标
  859. // 指标名称
  860. indexNameOne := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Current/Chat5"
  861. indexNameTwo := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + "Previous/Chat5"
  862. // 生成指标编码
  863. indexCodeOne, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "currentchat5", "")
  864. indexCodeTwo, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix, "previouschat5", "")
  865. var indexInfoList []*models.IndexInfo
  866. var valueOne float64
  867. if rowData[len(rowData)-2] == "" {
  868. valueOne = 0
  869. } else {
  870. valueOne, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-2], ",", ""), 64)
  871. if err != nil {
  872. return nil, err
  873. }
  874. }
  875. dataTimeOne := rowData[len(rowData)-1]
  876. formatOne, err := utils.ConvertDateFormat5(dataTimeOne)
  877. if err != nil {
  878. return nil, err
  879. }
  880. indexInfoList = append(indexInfoList, &models.IndexInfo{
  881. IndexName: indexNameOne,
  882. IndexCode: indexCodeOne,
  883. Value: valueOne,
  884. DataTime: formatOne,
  885. })
  886. var valueTwo float64
  887. if rowData[len(rowData)-3] == "" {
  888. valueTwo = 0
  889. } else {
  890. valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-3], ",", ""), 64)
  891. if err != nil {
  892. return nil, err
  893. }
  894. }
  895. indexInfoList = append(indexInfoList, &models.IndexInfo{
  896. IndexName: indexNameTwo,
  897. IndexCode: indexCodeTwo,
  898. Value: valueTwo,
  899. DataTime: formatOne,
  900. })
  901. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  902. if err != nil {
  903. return nil, err
  904. }
  905. logs.Info("SupplyRevisionAnalysisChartFiveProcessor indexInfoList: %v", indexInfoList)
  906. // step_3: 指标数据
  907. dataList, err := dealData(indexInfoList)
  908. if err != nil {
  909. return nil, err
  910. }
  911. logs.Info("SupplyRevisionAnalysisChartFiveProcessor dataList: %v", dataList)
  912. return dataList, err
  913. }
  914. // SupplyRevisionAnalysisChartSixProcessor
  915. // @Description: SupplyRevisionAnalysisChartSixProcessor
  916. type SupplyRevisionAnalysisChartSixProcessor struct{}
  917. func (p *SupplyRevisionAnalysisChartSixProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  918. logs.Info("Processing SupplyRevisionAnalysisChartSixProcessor...")
  919. if rowIndex < 1 {
  920. return nil, nil
  921. }
  922. frequency := "月度"
  923. unit := "千桶每天"
  924. indexNameColSuffix := "YearMonth"
  925. indexNameColPrefix := "Country Revision Group"
  926. // step_1: 分类
  927. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  928. if err != nil {
  929. return nil, err
  930. }
  931. logs.Info("classifyId: %v", classifyId)
  932. // step_2: 指标
  933. // 指标名称
  934. indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  935. // 生成指标编码
  936. indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  937. indexInfoMap := make(map[string]string)
  938. indexInfoMap[indexCode] = indexName
  939. var indexInfoList []*models.IndexInfo
  940. var value float64
  941. if rowData[len(rowData)-1] == "" {
  942. value = 0
  943. } else {
  944. value, err = strconv.ParseFloat(rowData[len(rowData)-1], 64)
  945. if err != nil {
  946. return nil, err
  947. }
  948. }
  949. dataTime := rowData[0]
  950. format, err := utils.ConvertDateFormat5(dataTime)
  951. if err != nil {
  952. return nil, err
  953. }
  954. indexInfoList = append(indexInfoList, &models.IndexInfo{
  955. IndexName: indexName,
  956. IndexCode: indexCode,
  957. Value: value,
  958. DataTime: format,
  959. })
  960. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  961. if err != nil {
  962. return nil, err
  963. }
  964. logs.Info("SupplyRevisionAnalysisChartSixProcessor indexInfoList: %v", indexInfoList)
  965. // step_3: 指标数据
  966. dataList, err := dealData(indexInfoList)
  967. if err != nil {
  968. return nil, err
  969. }
  970. logs.Info("SupplyRevisionAnalysisChartSixProcessor dataList: %v", dataList)
  971. return dataList, err
  972. }
  973. // OilSupplyAnalysisChartOneProcessor
  974. // @Description: OilSupplyAnalysisChartOneProcessor处理器
  975. type OilSupplyAnalysisChartOneProcessor struct{}
  976. func (p *OilSupplyAnalysisChartOneProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  977. logs.Info("Processing OilSupplyAnalysisChartOne...")
  978. if rowIndex < 1 {
  979. return nil, nil
  980. }
  981. frequency := "月度"
  982. unit := "千桶每天"
  983. indexNameColSuffix := "Oil And Gas Category"
  984. //indexNameColPrefix := "CountryRevisionGroup"
  985. // step_1: 分类
  986. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  987. if err != nil {
  988. return nil, err
  989. }
  990. logs.Info("classifyId: %v", classifyId)
  991. // step_2: 指标
  992. // 指标名称
  993. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  994. // 生成指标编码
  995. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  996. indexInfoMap := make(map[string]string)
  997. indexInfoMap[indexCode] = indexName
  998. var indexInfoList []*models.IndexInfo
  999. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1000. if err != nil {
  1001. return nil, err
  1002. }
  1003. dataTime := rowData[0]
  1004. format, err := utils.ConvertDateFormat3(dataTime)
  1005. if err != nil {
  1006. return nil, err
  1007. }
  1008. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1009. IndexName: indexName,
  1010. IndexCode: indexCode,
  1011. Value: value,
  1012. DataTime: format,
  1013. })
  1014. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1015. if err != nil {
  1016. return nil, err
  1017. }
  1018. logs.Info("OilSupplyAnalysisChartOneProcessor indexInfoList: %v", indexInfoList)
  1019. // step_3: 指标数据
  1020. dataList, err := dealData(indexInfoList)
  1021. if err != nil {
  1022. return nil, err
  1023. }
  1024. logs.Info("OilSupplyAnalysisChartOneProcessor dataList: %v", dataList)
  1025. return dataList, err
  1026. }
  1027. // OilSupplyAnalysisChartTwoProcessor
  1028. // @Description: OilSupplyAnalysisChartTwoProcessor处理器
  1029. type OilSupplyAnalysisChartTwoProcessor struct{}
  1030. func (p *OilSupplyAnalysisChartTwoProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1031. logs.Info("Processing OilSupplyAnalysisChartTwoProcessor...")
  1032. if rowIndex < 1 {
  1033. return nil, nil
  1034. }
  1035. frequency := "月度"
  1036. unit := "千桶每天"
  1037. indexNameColSuffix := "Region"
  1038. //indexNameColPrefix := "CountryRevisionGroup"
  1039. // step_1: 分类
  1040. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1041. if err != nil {
  1042. return nil, err
  1043. }
  1044. logs.Info("classifyId: %v", classifyId)
  1045. // step_2: 指标
  1046. // 指标名称
  1047. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
  1048. // 生成指标编码
  1049. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
  1050. indexInfoMap := make(map[string]string)
  1051. indexInfoMap[indexCode] = indexName
  1052. var indexInfoList []*models.IndexInfo
  1053. value, err := strconv.ParseFloat(rowData[len(rowData)-2], 64)
  1054. if err != nil {
  1055. return nil, err
  1056. }
  1057. dataTime := rowData[0]
  1058. format, err := utils.ConvertDateFormat3(dataTime)
  1059. if err != nil {
  1060. return nil, err
  1061. }
  1062. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1063. IndexName: indexName,
  1064. IndexCode: indexCode,
  1065. Value: value,
  1066. DataTime: format,
  1067. })
  1068. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1069. if err != nil {
  1070. return nil, err
  1071. }
  1072. logs.Info("OilSupplyAnalysisChartTwoProcessor indexInfoList: %v", indexInfoList)
  1073. // step_3: 指标数据
  1074. dataList, err := dealData(indexInfoList)
  1075. if err != nil {
  1076. return nil, err
  1077. }
  1078. logs.Info("OilSupplyAnalysisChartTwoProcessor dataList: %v", dataList)
  1079. return dataList, err
  1080. }
  1081. // OilSupplyAnalysisChartThreeProcessor
  1082. // @Description: OilSupplyAnalysisChartThreeProcessor处理器
  1083. type OilSupplyAnalysisChartThreeProcessor struct{}
  1084. func (p *OilSupplyAnalysisChartThreeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1085. logs.Info("Processing OilSupplyAnalysisChartThreeProcessor...")
  1086. if rowIndex < 1 {
  1087. return nil, nil
  1088. }
  1089. frequency := "月度"
  1090. unit := "千桶每天"
  1091. indexNameColSuffix := "CapacityDetail"
  1092. //indexNameColPrefix := "CountryRevisionGroup"
  1093. // step_1: 分类
  1094. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1095. if err != nil {
  1096. return nil, err
  1097. }
  1098. logs.Info("classifyId: %v", classifyId)
  1099. // step_2: 指标
  1100. // 指标名称
  1101. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1102. // 生成指标编码
  1103. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1104. indexInfoMap := make(map[string]string)
  1105. indexInfoMap[indexCode] = indexName
  1106. var indexInfoList []*models.IndexInfo
  1107. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1108. if err != nil {
  1109. return nil, err
  1110. }
  1111. dataTime := rowData[0]
  1112. format, err := utils.ConvertDateFormat3(dataTime)
  1113. if err != nil {
  1114. return nil, err
  1115. }
  1116. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1117. IndexName: indexName,
  1118. IndexCode: indexCode,
  1119. Value: value,
  1120. DataTime: format,
  1121. })
  1122. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1123. if err != nil {
  1124. return nil, err
  1125. }
  1126. logs.Info("OilSupplyAnalysisChartThreeProcessor indexInfoList: %v", indexInfoList)
  1127. // step_3: 指标数据
  1128. dataList, err := dealData(indexInfoList)
  1129. if err != nil {
  1130. return nil, err
  1131. }
  1132. logs.Info("OilSupplyAnalysisChartThreeProcessor dataList: %v", dataList)
  1133. return dataList, err
  1134. }
  1135. // OilSupplyAnalysisChartFourProcessor
  1136. // @Description: OilSupplyAnalysisChartFourProcessor处理器
  1137. type OilSupplyAnalysisChartFourProcessor struct{}
  1138. func (p *OilSupplyAnalysisChartFourProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1139. logs.Info("Processing OilSupplyAnalysisChartFourProcessor...")
  1140. if rowIndex < 1 {
  1141. return nil, nil
  1142. }
  1143. frequency := "月度"
  1144. unit := "千桶每天"
  1145. indexNameColSuffix := "Oil Classification Group"
  1146. //indexNameColPrefix := "CountryRevisionGroup"
  1147. // step_1: 分类
  1148. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1149. if err != nil {
  1150. return nil, err
  1151. }
  1152. logs.Info("classifyId: %v", classifyId)
  1153. // step_2: 指标
  1154. // 指标名称
  1155. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1156. // 生成指标编码
  1157. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1158. indexInfoMap := make(map[string]string)
  1159. indexInfoMap[indexCode] = indexName
  1160. var indexInfoList []*models.IndexInfo
  1161. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1162. if err != nil {
  1163. return nil, err
  1164. }
  1165. dataTime := rowData[0]
  1166. format, err := utils.ConvertDateFormat3(dataTime)
  1167. if err != nil {
  1168. return nil, err
  1169. }
  1170. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1171. IndexName: indexName,
  1172. IndexCode: indexCode,
  1173. Value: value,
  1174. DataTime: format,
  1175. })
  1176. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1177. if err != nil {
  1178. return nil, err
  1179. }
  1180. logs.Info("OilSupplyAnalysisChartFourProcessor indexInfoList: %v", indexInfoList)
  1181. // step_3: 指标数据
  1182. dataList, err := dealData(indexInfoList)
  1183. if err != nil {
  1184. return nil, err
  1185. }
  1186. logs.Info("OilSupplyAnalysisChartFourProcessor dataList: %v", dataList)
  1187. return dataList, err
  1188. }
  1189. // OilDemandAnalysisContinentProcessor
  1190. // @Description: OilDemandAnalysisContinentProcessor处理器
  1191. type OilDemandAnalysisContinentProcessor struct{}
  1192. func (p *OilDemandAnalysisContinentProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1193. logs.Info("Processing OilDemandAnalysisContinentProcessor...")
  1194. if rowIndex < 1 {
  1195. return nil, nil
  1196. }
  1197. frequency := "月度"
  1198. unit := "千桶每天"
  1199. indexNameColSuffix := "Continent"
  1200. //indexNameColPrefix := "CountryRevisionGroup"
  1201. // step_1: 分类
  1202. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1203. if err != nil {
  1204. return nil, err
  1205. }
  1206. logs.Info("classifyId: %v", classifyId)
  1207. // step_2: 指标
  1208. // 指标名称
  1209. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1210. // 生成指标编码
  1211. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1212. indexInfoMap := make(map[string]string)
  1213. indexInfoMap[indexCode] = indexName
  1214. var indexInfoList []*models.IndexInfo
  1215. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1216. if err != nil {
  1217. return nil, err
  1218. }
  1219. dataTime := rowData[0]
  1220. format, err := utils.ConvertDateFormat3(dataTime)
  1221. if err != nil {
  1222. return nil, err
  1223. }
  1224. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1225. IndexName: indexName,
  1226. IndexCode: indexCode,
  1227. Value: value,
  1228. DataTime: format,
  1229. })
  1230. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1231. if err != nil {
  1232. return nil, err
  1233. }
  1234. logs.Info("OilDemandAnalysisContinentProcessor indexInfoList: %v", indexInfoList)
  1235. // step_3: 指标数据
  1236. dataList, err := dealData(indexInfoList)
  1237. if err != nil {
  1238. return nil, err
  1239. }
  1240. logs.Info("OilDemandAnalysisContinentProcessor dataList: %v", dataList)
  1241. return dataList, err
  1242. }
  1243. // OilDemandAnalysisRegionProcessor
  1244. // @Description: OilDemandAnalysisRegionProcessor处理器
  1245. type OilDemandAnalysisRegionProcessor struct{}
  1246. func (p *OilDemandAnalysisRegionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1247. logs.Info("Processing OilDemandAnalysisRegionProcessor...")
  1248. if rowIndex < 1 {
  1249. return nil, nil
  1250. }
  1251. frequency := "月度"
  1252. unit := "千桶每天"
  1253. indexNameColSuffix := "Region"
  1254. //indexNameColPrefix := "CountryRevisionGroup"
  1255. // step_1: 分类
  1256. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1257. if err != nil {
  1258. return nil, err
  1259. }
  1260. logs.Info("classifyId: %v", classifyId)
  1261. // step_2: 指标
  1262. // 指标名称
  1263. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1264. // 生成指标编码
  1265. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1266. indexInfoMap := make(map[string]string)
  1267. indexInfoMap[indexCode] = indexName
  1268. var indexInfoList []*models.IndexInfo
  1269. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1270. if err != nil {
  1271. return nil, err
  1272. }
  1273. dataTime := rowData[0]
  1274. format, err := utils.ConvertDateFormat3(dataTime)
  1275. if err != nil {
  1276. return nil, err
  1277. }
  1278. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1279. IndexName: indexName,
  1280. IndexCode: indexCode,
  1281. Value: value,
  1282. DataTime: format,
  1283. })
  1284. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1285. if err != nil {
  1286. return nil, err
  1287. }
  1288. logs.Info("OilDemandAnalysisRegionProcessor indexInfoList: %v", indexInfoList)
  1289. // step_3: 指标数据
  1290. dataList, err := dealData(indexInfoList)
  1291. if err != nil {
  1292. return nil, err
  1293. }
  1294. logs.Info("OilDemandAnalysisRegionProcessor dataList: %v", dataList)
  1295. return dataList, err
  1296. }
  1297. // OilDemandAnalysisCountryProcessor
  1298. // @Description: OilDemandAnalysisCountryProcessor
  1299. type OilDemandAnalysisCountryProcessor struct{}
  1300. func (p *OilDemandAnalysisCountryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1301. logs.Info("Processing OilDemandAnalysisCountryProcessor...")
  1302. if rowIndex < 1 {
  1303. return nil, nil
  1304. }
  1305. frequency := "月度"
  1306. unit := "千桶每天"
  1307. indexNameColSuffix := "Country"
  1308. //indexNameColPrefix := "CountryRevisionGroup"
  1309. // step_1: 分类
  1310. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1311. if err != nil {
  1312. return nil, err
  1313. }
  1314. logs.Info("classifyId: %v", classifyId)
  1315. // step_2: 指标
  1316. // 指标名称
  1317. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1318. // 生成指标编码
  1319. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1320. indexInfoMap := make(map[string]string)
  1321. indexInfoMap[indexCode] = indexName
  1322. var indexInfoList []*models.IndexInfo
  1323. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1324. if err != nil {
  1325. return nil, err
  1326. }
  1327. dataTime := rowData[0]
  1328. format, err := utils.ConvertDateFormat3(dataTime)
  1329. if err != nil {
  1330. return nil, err
  1331. }
  1332. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1333. IndexName: indexName,
  1334. IndexCode: indexCode,
  1335. Value: value,
  1336. DataTime: format,
  1337. })
  1338. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1339. if err != nil {
  1340. return nil, err
  1341. }
  1342. logs.Info("OilDemandAnalysisCountryProcessor indexInfoList: %v", indexInfoList)
  1343. // step_3: 指标数据
  1344. dataList, err := dealData(indexInfoList)
  1345. if err != nil {
  1346. return nil, err
  1347. }
  1348. logs.Info("OilDemandAnalysisCountryProcessor dataList: %v", dataList)
  1349. return dataList, err
  1350. }
  1351. // OilDemandAnalysisProductCategoryProcessor
  1352. // @Description: OilDemandAnalysisProductCategoryProcessor处理器
  1353. type OilDemandAnalysisProductCategoryProcessor struct{}
  1354. func (p *OilDemandAnalysisProductCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1355. logs.Info("Processing OilDemandAnalysisProductCategoryProcessor...")
  1356. if rowIndex < 1 {
  1357. return nil, nil
  1358. }
  1359. frequency := "月度"
  1360. unit := "千桶每天"
  1361. indexNameColSuffix := "Product category"
  1362. //indexNameColPrefix := "CountryRevisionGroup"
  1363. // step_1: 分类
  1364. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1365. if err != nil {
  1366. return nil, err
  1367. }
  1368. logs.Info("classifyId: %v", classifyId)
  1369. // step_2: 指标
  1370. // 指标名称
  1371. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1372. // 生成指标编码
  1373. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1374. indexInfoMap := make(map[string]string)
  1375. indexInfoMap[indexCode] = indexName
  1376. var indexInfoList []*models.IndexInfo
  1377. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1378. if err != nil {
  1379. return nil, err
  1380. }
  1381. dataTime := rowData[0]
  1382. format, err := utils.ConvertDateFormat3(dataTime)
  1383. if err != nil {
  1384. return nil, err
  1385. }
  1386. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1387. IndexName: indexName,
  1388. IndexCode: indexCode,
  1389. Value: value,
  1390. DataTime: format,
  1391. })
  1392. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1393. if err != nil {
  1394. return nil, err
  1395. }
  1396. logs.Info("OilDemandAnalysisProductCategoryProcessor indexInfoList: %v", indexInfoList)
  1397. // step_3: 指标数据
  1398. dataList, err := dealData(indexInfoList)
  1399. if err != nil {
  1400. return nil, err
  1401. }
  1402. logs.Info("OilDemandAnalysisProductCategoryProcessor dataList: %v", dataList)
  1403. return dataList, err
  1404. }
  1405. // OilDemandAnalysisProductDetailProcessor
  1406. // @Description: OilDemandAnalysisProductDetailProcessor处理器
  1407. type OilDemandAnalysisProductDetailProcessor struct{}
  1408. func (p *OilDemandAnalysisProductDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1409. logs.Info("Processing OilDemandAnalysisProductDetailProcessor...")
  1410. if rowIndex < 1 {
  1411. return nil, nil
  1412. }
  1413. frequency := "月度"
  1414. unit := "千桶每天"
  1415. indexNameColSuffix := "Product detail"
  1416. //indexNameColPrefix := "CountryRevisionGroup"
  1417. // step_1: 分类
  1418. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1419. if err != nil {
  1420. return nil, err
  1421. }
  1422. logs.Info("classifyId: %v", classifyId)
  1423. // step_2: 指标
  1424. // 指标名称
  1425. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1426. // 生成指标编码
  1427. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1428. indexInfoMap := make(map[string]string)
  1429. indexInfoMap[indexCode] = indexName
  1430. var indexInfoList []*models.IndexInfo
  1431. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1432. if err != nil {
  1433. return nil, err
  1434. }
  1435. dataTime := rowData[0]
  1436. format, err := utils.ConvertDateFormat3(dataTime)
  1437. if err != nil {
  1438. return nil, err
  1439. }
  1440. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1441. IndexName: indexName,
  1442. IndexCode: indexCode,
  1443. Value: value,
  1444. DataTime: format,
  1445. })
  1446. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1447. if err != nil {
  1448. return nil, err
  1449. }
  1450. logs.Info("OilDemandAnalysisProductDetailProcessor indexInfoList: %v", indexInfoList)
  1451. // step_3: 指标数据
  1452. dataList, err := dealData(indexInfoList)
  1453. if err != nil {
  1454. return nil, err
  1455. }
  1456. logs.Info("OilDemandAnalysisProductDetailProcessor dataList: %v", dataList)
  1457. return dataList, err
  1458. }
  1459. // OilDemandAnalysisSectorCategoryProcessor
  1460. // @Description: OilDemandAnalysisSectorCategoryProcessor处理器
  1461. type OilDemandAnalysisSectorCategoryProcessor struct{}
  1462. func (p *OilDemandAnalysisSectorCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1463. logs.Info("Processing OilDemandAnalysisSectorCategoryProcessor...")
  1464. if rowIndex < 1 {
  1465. return nil, nil
  1466. }
  1467. frequency := "月度"
  1468. unit := "千桶每天"
  1469. indexNameColSuffix := "Sector category"
  1470. //indexNameColPrefix := "CountryRevisionGroup"
  1471. // step_1: 分类
  1472. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1473. if err != nil {
  1474. return nil, err
  1475. }
  1476. logs.Info("classifyId: %v", classifyId)
  1477. // step_2: 指标
  1478. // 指标名称
  1479. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1480. // 生成指标编码
  1481. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1482. indexInfoMap := make(map[string]string)
  1483. indexInfoMap[indexCode] = indexName
  1484. var indexInfoList []*models.IndexInfo
  1485. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1486. if err != nil {
  1487. return nil, err
  1488. }
  1489. dataTime := rowData[0]
  1490. format, err := utils.ConvertDateFormat3(dataTime)
  1491. if err != nil {
  1492. return nil, err
  1493. }
  1494. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1495. IndexName: indexName,
  1496. IndexCode: indexCode,
  1497. Value: value,
  1498. DataTime: format,
  1499. })
  1500. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1501. if err != nil {
  1502. return nil, err
  1503. }
  1504. logs.Info("OilDemandAnalysisSectorCategoryProcessor indexInfoList: %v", indexInfoList)
  1505. // step_3: 指标数据
  1506. dataList, err := dealData(indexInfoList)
  1507. if err != nil {
  1508. return nil, err
  1509. }
  1510. logs.Info("OilDemandAnalysisSectorCategoryProcessor dataList: %v", dataList)
  1511. return dataList, err
  1512. }
  1513. // OilDemandAnalysisSectorDetailProcessor
  1514. // @Description: OilDemandAnalysisSectorDetailProcessor处理器
  1515. type OilDemandAnalysisSectorDetailProcessor struct{}
  1516. func (p *OilDemandAnalysisSectorDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1517. logs.Info("Processing OilDemandAnalysisSectorDetailProcessor...")
  1518. if rowIndex < 1 {
  1519. return nil, nil
  1520. }
  1521. frequency := "月度"
  1522. unit := "千桶每天"
  1523. indexNameColSuffix := "Sector detail"
  1524. //indexNameColPrefix := "CountryRevisionGroup"
  1525. // step_1: 分类
  1526. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1527. if err != nil {
  1528. return nil, err
  1529. }
  1530. logs.Info("classifyId: %v", classifyId)
  1531. // step_2: 指标
  1532. // 指标名称
  1533. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1534. // 生成指标编码
  1535. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1536. indexInfoMap := make(map[string]string)
  1537. indexInfoMap[indexCode] = indexName
  1538. var indexInfoList []*models.IndexInfo
  1539. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1540. if err != nil {
  1541. return nil, err
  1542. }
  1543. dataTime := rowData[0]
  1544. format, err := utils.ConvertDateFormat3(dataTime)
  1545. if err != nil {
  1546. return nil, err
  1547. }
  1548. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1549. IndexName: indexName,
  1550. IndexCode: indexCode,
  1551. Value: value,
  1552. DataTime: format,
  1553. })
  1554. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1555. if err != nil {
  1556. return nil, err
  1557. }
  1558. logs.Info("OilDemandAnalysisSectorDetailProcessor indexInfoList: %v", indexInfoList)
  1559. // step_3: 指标数据
  1560. dataList, err := dealData(indexInfoList)
  1561. if err != nil {
  1562. return nil, err
  1563. }
  1564. logs.Info("OilDemandAnalysisSectorDetailProcessor dataList: %v", dataList)
  1565. return dataList, err
  1566. }
  1567. // OilDemandAnalysisScenarioProcessor
  1568. // @Description: OilDemandAnalysisScenarioProcessor处理器
  1569. type OilDemandAnalysisScenarioProcessor struct{}
  1570. func (p *OilDemandAnalysisScenarioProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1571. logs.Info("Processing OilDemandAnalysisScenarioProcessor...")
  1572. if rowIndex < 1 {
  1573. return nil, nil
  1574. }
  1575. frequency := "月度"
  1576. unit := "千桶每天"
  1577. indexNameColSuffix := "Scenario"
  1578. //indexNameColPrefix := "CountryRevisionGroup"
  1579. // step_1: 分类
  1580. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1581. if err != nil {
  1582. return nil, err
  1583. }
  1584. logs.Info("classifyId: %v", classifyId)
  1585. // step_2: 指标
  1586. // 指标名称
  1587. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1588. // 生成指标编码
  1589. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1590. indexInfoMap := make(map[string]string)
  1591. indexInfoMap[indexCode] = indexName
  1592. var indexInfoList []*models.IndexInfo
  1593. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1594. if err != nil {
  1595. return nil, err
  1596. }
  1597. dataTime := rowData[0]
  1598. format, err := utils.ConvertDateFormat3(dataTime)
  1599. if err != nil {
  1600. return nil, err
  1601. }
  1602. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1603. IndexName: indexName,
  1604. IndexCode: indexCode,
  1605. Value: value,
  1606. DataTime: format,
  1607. })
  1608. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1609. if err != nil {
  1610. return nil, err
  1611. }
  1612. logs.Info("OilDemandAnalysisScenarioProcessor indexInfoList: %v", indexInfoList)
  1613. // step_3: 指标数据
  1614. dataList, err := dealData(indexInfoList)
  1615. if err != nil {
  1616. return nil, err
  1617. }
  1618. logs.Info("OilDemandAnalysisScenarioProcessor dataList: %v", dataList)
  1619. return dataList, err
  1620. }
  1621. // UpstreamSupplyOilQualityApiProcessor
  1622. // @Description: UpstreamSupplyOilQualityApiProcessor处理器
  1623. type UpstreamSupplyOilQualityApiProcessor struct{}
  1624. var rzdApiFlag string
  1625. func (p *UpstreamSupplyOilQualityApiProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1626. logs.Info("Processing UpstreamSupplyOilQualityApiProcessor...")
  1627. if rowIndex <= 1 {
  1628. return nil, nil
  1629. }
  1630. if rowData[0] != "" {
  1631. rzdApiFlag = rowData[0]
  1632. } else {
  1633. rowData[0] = rzdApiFlag
  1634. }
  1635. frequency := "月度"
  1636. unit := "°"
  1637. indexNameColSuffix := "Oil Quality"
  1638. //indexNameColPrefix := "CountryRevisionGroup"
  1639. if !utils.IsNumeric(rowData[0]) {
  1640. return nil, nil
  1641. }
  1642. if rowData[1] == "Sum" {
  1643. return nil, nil
  1644. }
  1645. // step_1: 分类
  1646. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1647. if err != nil {
  1648. return nil, err
  1649. }
  1650. logs.Info("classifyId: %v", classifyId)
  1651. // step_2: 指标
  1652. // 指标名称
  1653. indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "API"
  1654. // 生成指标编码
  1655. indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("API"), "")
  1656. var indexInfoList []*models.IndexInfo
  1657. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1658. if err != nil {
  1659. return nil, err
  1660. }
  1661. dataTime := rowData[0]
  1662. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1663. if err != nil {
  1664. return nil, err
  1665. }
  1666. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1667. IndexName: indexName,
  1668. IndexCode: indexCode,
  1669. Value: value,
  1670. DataTime: format,
  1671. })
  1672. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1673. if err != nil {
  1674. return nil, err
  1675. }
  1676. logs.Info("UpstreamSupplyOilQualityApiProcessor indexInfoList: %v", indexInfoList)
  1677. // step_3: 指标数据
  1678. dataList, err := dealData(indexInfoList)
  1679. if err != nil {
  1680. return nil, err
  1681. }
  1682. logs.Info("UpstreamSupplyOilQualityApiProcessor dataList: %v", dataList)
  1683. return dataList, err
  1684. }
  1685. // OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor
  1686. // @Description: OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor处理器
  1687. type OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor struct{}
  1688. var rzdSulphurFlag string
  1689. func (p *OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1690. logs.Info("Processing OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor...")
  1691. if rowIndex <= 1 {
  1692. return nil, nil
  1693. }
  1694. if rowData[0] != "" {
  1695. rzdSulphurFlag = rowData[0]
  1696. } else {
  1697. rowData[0] = rzdSulphurFlag
  1698. }
  1699. frequency := "月度"
  1700. unit := "%wt"
  1701. indexNameColSuffix := "Oil Quality"
  1702. //indexNameColPrefix := "CountryRevisionGroup"
  1703. if !utils.IsNumeric(rowData[0]) {
  1704. return nil, nil
  1705. }
  1706. if rowData[1] == "Sum" {
  1707. return nil, nil
  1708. }
  1709. // step_1: 分类
  1710. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1711. if err != nil {
  1712. return nil, err
  1713. }
  1714. logs.Info("classifyId: %v", classifyId)
  1715. // step_2: 指标
  1716. // 指标名称
  1717. indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "Sulphur"
  1718. // 生成指标编码
  1719. indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("Sulphur"), "")
  1720. var indexInfoList []*models.IndexInfo
  1721. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1722. if err != nil {
  1723. return nil, err
  1724. }
  1725. dataTime := rowData[0]
  1726. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1727. if err != nil {
  1728. return nil, err
  1729. }
  1730. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1731. IndexName: indexName,
  1732. IndexCode: indexCode,
  1733. Value: value,
  1734. DataTime: format,
  1735. })
  1736. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1737. if err != nil {
  1738. return nil, err
  1739. }
  1740. logs.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor indexInfoList: %v", indexInfoList)
  1741. // step_3: 指标数据
  1742. dataList, err := dealData(indexInfoList)
  1743. if err != nil {
  1744. return nil, err
  1745. }
  1746. logs.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor dataList: %v", dataList)
  1747. return dataList, err
  1748. }
  1749. // OilMarketCubeUpstreamSupplyCapacityCapacityProcessor
  1750. // @Description: OilMarketCubeUpstreamSupplyCapacityCapacityProcessor处理器
  1751. type OilMarketCubeUpstreamSupplyCapacityCapacityProcessor struct{}
  1752. var rzdCapacityFlag string
  1753. func (p *OilMarketCubeUpstreamSupplyCapacityCapacityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1754. logs.Info("Processing OilMarketCubeUpstreamSupplyCapacityCapacityProcessor...")
  1755. if rowIndex <= 1 {
  1756. return nil, nil
  1757. }
  1758. if rowData[0] != "" {
  1759. rzdCapacityFlag = rowData[0]
  1760. } else {
  1761. rowData[0] = rzdCapacityFlag
  1762. }
  1763. frequency := "月度"
  1764. unit := "kbbl/d"
  1765. indexNameColSuffix := "Capacity"
  1766. //indexNameColPrefix := "CountryRevisionGroup"
  1767. if !utils.IsNumeric(rowData[0]) {
  1768. return nil, nil
  1769. }
  1770. if rowData[1] == "Sum" {
  1771. return nil, nil
  1772. }
  1773. // step_1: 分类
  1774. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1775. if err != nil {
  1776. return nil, err
  1777. }
  1778. logs.Info("classifyId: %v", classifyId)
  1779. // step_2: 指标
  1780. // 指标名称
  1781. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1782. // 生成指标编码
  1783. indexCode, err := getIndexId("Upstream Supply ", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1784. var indexInfoList []*models.IndexInfo
  1785. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1786. if err != nil {
  1787. return nil, err
  1788. }
  1789. dataTime := rowData[0]
  1790. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1791. if err != nil {
  1792. return nil, err
  1793. }
  1794. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1795. IndexName: indexName,
  1796. IndexCode: indexCode,
  1797. Value: value,
  1798. DataTime: format,
  1799. })
  1800. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1801. if err != nil {
  1802. return nil, err
  1803. }
  1804. logs.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor indexInfoList: %v", indexInfoList)
  1805. // step_3: 指标数据
  1806. dataList, err := dealData(indexInfoList)
  1807. if err != nil {
  1808. return nil, err
  1809. }
  1810. logs.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor dataList: %v", dataList)
  1811. return dataList, err
  1812. }
  1813. // OilMarketCubeUpstreamSupplyProductionProcessor
  1814. // @Description: OilMarketCubeUpstreamSupplyProductionProcessor处理器
  1815. type OilMarketCubeUpstreamSupplyProductionProcessor struct{}
  1816. var rzdProductionFlag string
  1817. func (p *OilMarketCubeUpstreamSupplyProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1818. logs.Info("Processing OilMarketCubeUpstreamSupplyProductionProcessor...")
  1819. if rowIndex <= 1 {
  1820. return nil, nil
  1821. }
  1822. if rowData[0] != "" {
  1823. rzdProductionFlag = rowData[0]
  1824. } else {
  1825. rowData[0] = rzdProductionFlag
  1826. }
  1827. frequency := "月度"
  1828. unit := "kbbl/d"
  1829. indexNameColSuffix := "Production"
  1830. //indexNameColPrefix := "CountryRevisionGroup"
  1831. if !utils.IsNumeric(rowData[0]) {
  1832. return nil, nil
  1833. }
  1834. if rowData[1] == "Sum" {
  1835. return nil, nil
  1836. }
  1837. // step_1: 分类
  1838. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1839. if err != nil {
  1840. return nil, err
  1841. }
  1842. logs.Info("classifyId: %v", classifyId)
  1843. // step_2: 指标
  1844. // 指标名称
  1845. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1846. // 生成指标编码
  1847. indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1848. var indexInfoList []*models.IndexInfo
  1849. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1850. if err != nil {
  1851. return nil, err
  1852. }
  1853. dataTime := rowData[0]
  1854. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1855. if err != nil {
  1856. return nil, err
  1857. }
  1858. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1859. IndexName: indexName,
  1860. IndexCode: indexCode,
  1861. Value: value,
  1862. DataTime: format,
  1863. })
  1864. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1865. if err != nil {
  1866. return nil, err
  1867. }
  1868. logs.Info("OilMarketCubeUpstreamSupplyProductionProcessor indexInfoList: %v", indexInfoList)
  1869. // step_3: 指标数据
  1870. dataList, err := dealData(indexInfoList)
  1871. if err != nil {
  1872. return nil, err
  1873. }
  1874. logs.Info("OilMarketCubeUpstreamSupplyProductionProcessor dataList: %v", dataList)
  1875. return dataList, err
  1876. }
  1877. // UpstreamSupplyProductionWoSeasonalityProcessor
  1878. // @Description: UpstreamSupplyProductionWoSeasonalityProcessor处理器
  1879. type UpstreamSupplyProductionWoSeasonalityProcessor struct{}
  1880. var rzdProductionWoSeasonalityFlag string
  1881. func (p *UpstreamSupplyProductionWoSeasonalityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1882. logs.Info("Processing UpstreamSupplyProductionWoSeasonalityProcessor...")
  1883. if rowIndex <= 1 {
  1884. return nil, nil
  1885. }
  1886. if rowData[0] != "" {
  1887. rzdProductionWoSeasonalityFlag = rowData[0]
  1888. } else {
  1889. rowData[0] = rzdProductionWoSeasonalityFlag
  1890. }
  1891. frequency := "月度"
  1892. unit := "kbbl/d"
  1893. indexNameColSuffix := "Production Wo Seasonality"
  1894. //indexNameColPrefix := "CountryRevisionGroup"
  1895. if !utils.IsNumeric(rowData[0]) {
  1896. return nil, nil
  1897. }
  1898. if rowData[1] == "Sum" {
  1899. return nil, nil
  1900. }
  1901. // step_1: 分类
  1902. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1903. if err != nil {
  1904. return nil, err
  1905. }
  1906. logs.Info("classifyId: %v", classifyId)
  1907. // step_2: 指标
  1908. // 指标名称
  1909. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1910. // 生成指标编码
  1911. indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1912. var indexInfoList []*models.IndexInfo
  1913. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1914. if err != nil {
  1915. return nil, err
  1916. }
  1917. dataTime := rowData[0]
  1918. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1919. if err != nil {
  1920. return nil, err
  1921. }
  1922. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1923. IndexName: indexName,
  1924. IndexCode: indexCode,
  1925. Value: value,
  1926. DataTime: format,
  1927. })
  1928. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1929. if err != nil {
  1930. return nil, err
  1931. }
  1932. logs.Info("UpstreamSupplyProductionWoSeasonalityProcessor indexInfoList: %v", indexInfoList)
  1933. // step_3: 指标数据
  1934. dataList, err := dealData(indexInfoList)
  1935. if err != nil {
  1936. return nil, err
  1937. }
  1938. logs.Info("UpstreamSupplyProductionWoSeasonalityProcessor dataList: %v", dataList)
  1939. return dataList, err
  1940. }
  1941. // UpstreamSupplyOPECPolicyReferenceProductionProcessor
  1942. // @Description: UpstreamSupplyOPECPolicyReferenceProductionProcessor处理器
  1943. type UpstreamSupplyOPECPolicyReferenceProductionProcessor struct{}
  1944. var rzdReferenceProductionFlag string
  1945. func (p *UpstreamSupplyOPECPolicyReferenceProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1946. logs.Info("Processing UpstreamSupplyOPECPolicyReferenceProductionProcessor...")
  1947. if rowIndex <= 1 {
  1948. return nil, nil
  1949. }
  1950. if rowData[0] != "" {
  1951. rzdReferenceProductionFlag = rowData[0]
  1952. } else {
  1953. rowData[0] = rzdReferenceProductionFlag
  1954. }
  1955. frequency := "月度"
  1956. unit := "kbbl/d"
  1957. indexNameColPrefix := "OPEC_Policy"
  1958. indexNameColSuffix := "Reference Production"
  1959. if !utils.IsNumeric(rowData[0]) {
  1960. return nil, nil
  1961. }
  1962. if rowData[1] == "Sum" {
  1963. return nil, nil
  1964. }
  1965. // step_1: 分类
  1966. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1967. if err != nil {
  1968. return nil, err
  1969. }
  1970. logs.Info("classifyId: %v", classifyId)
  1971. // step_2: 指标
  1972. // 指标名称
  1973. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1974. // 生成指标编码
  1975. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1976. var indexInfoList []*models.IndexInfo
  1977. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1978. if err != nil {
  1979. return nil, err
  1980. }
  1981. dataTime := rowData[0]
  1982. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1983. if err != nil {
  1984. return nil, err
  1985. }
  1986. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1987. IndexName: indexName,
  1988. IndexCode: indexCode,
  1989. Value: value,
  1990. DataTime: format,
  1991. })
  1992. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1993. if err != nil {
  1994. return nil, err
  1995. }
  1996. logs.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor indexInfoList: %v", indexInfoList)
  1997. // step_3: 指标数据
  1998. dataList, err := dealData(indexInfoList)
  1999. if err != nil {
  2000. return nil, err
  2001. }
  2002. logs.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor dataList: %v", dataList)
  2003. return dataList, err
  2004. }
  2005. // UpstreamSupplyOPECPolicyTargetProductionProcessor
  2006. // @Description: UpstreamSupplyOPECPolicyTargetProductionProcessor处理器
  2007. type UpstreamSupplyOPECPolicyTargetProductionProcessor struct{}
  2008. var rzdTargetProductionFlag string
  2009. func (p *UpstreamSupplyOPECPolicyTargetProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2010. logs.Info("Processing UpstreamSupplyOPECPolicyTargetProductionProcessor...")
  2011. if rowIndex <= 1 {
  2012. return nil, nil
  2013. }
  2014. if rowData[0] != "" {
  2015. rzdTargetProductionFlag = rowData[0]
  2016. } else {
  2017. rowData[0] = rzdTargetProductionFlag
  2018. }
  2019. frequency := "月度"
  2020. unit := "kbbl/d"
  2021. indexNameColPrefix := "OPEC_Policy"
  2022. indexNameColSuffix := "Target Production"
  2023. if !utils.IsNumeric(rowData[0]) {
  2024. return nil, nil
  2025. }
  2026. if rowData[1] == "Sum" {
  2027. return nil, nil
  2028. }
  2029. // step_1: 分类
  2030. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2031. if err != nil {
  2032. return nil, err
  2033. }
  2034. logs.Info("classifyId: %v", classifyId)
  2035. // step_2: 指标
  2036. // 指标名称
  2037. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2038. // 生成指标编码
  2039. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2040. var indexInfoList []*models.IndexInfo
  2041. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2042. if err != nil {
  2043. return nil, err
  2044. }
  2045. dataTime := rowData[0]
  2046. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2047. if err != nil {
  2048. return nil, err
  2049. }
  2050. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2051. IndexName: indexName,
  2052. IndexCode: indexCode,
  2053. Value: value,
  2054. DataTime: format,
  2055. })
  2056. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2057. if err != nil {
  2058. return nil, err
  2059. }
  2060. logs.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor indexInfoList: %v", indexInfoList)
  2061. // step_3: 指标数据
  2062. dataList, err := dealData(indexInfoList)
  2063. if err != nil {
  2064. return nil, err
  2065. }
  2066. logs.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor dataList: %v", dataList)
  2067. return dataList, err
  2068. }
  2069. // UpstreamSupplyOPECPolicyTargetCutProcessor
  2070. // @Description: UpstreamSupplyOPECPolicyTargetCutProcessor处理器
  2071. type UpstreamSupplyOPECPolicyTargetCutProcessor struct{}
  2072. var rzdTargetCutFlag string
  2073. func (p *UpstreamSupplyOPECPolicyTargetCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2074. logs.Info("Processing UpstreamSupplyOPECPolicyTargetCutProcessor...")
  2075. if rowIndex <= 1 {
  2076. return nil, nil
  2077. }
  2078. if rowData[0] != "" {
  2079. rzdTargetCutFlag = rowData[0]
  2080. } else {
  2081. rowData[0] = rzdTargetCutFlag
  2082. }
  2083. frequency := "月度"
  2084. unit := "kbbl/d"
  2085. indexNameColPrefix := "OPEC_Policy"
  2086. indexNameColSuffix := "Target Cut"
  2087. if !utils.IsNumeric(rowData[0]) {
  2088. return nil, nil
  2089. }
  2090. if rowData[1] == "Sum" {
  2091. return nil, nil
  2092. }
  2093. // step_1: 分类
  2094. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2095. if err != nil {
  2096. return nil, err
  2097. }
  2098. logs.Info("classifyId: %v", classifyId)
  2099. // step_2: 指标
  2100. // 指标名称
  2101. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2102. // 生成指标编码
  2103. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2104. var indexInfoList []*models.IndexInfo
  2105. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2106. if err != nil {
  2107. return nil, err
  2108. }
  2109. dataTime := rowData[0]
  2110. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2111. if err != nil {
  2112. return nil, err
  2113. }
  2114. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2115. IndexName: indexName,
  2116. IndexCode: indexCode,
  2117. Value: value,
  2118. DataTime: format,
  2119. })
  2120. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2121. if err != nil {
  2122. return nil, err
  2123. }
  2124. logs.Info("UpstreamSupplyOPECPolicyTargetCutProcessor indexInfoList: %v", indexInfoList)
  2125. // step_3: 指标数据
  2126. dataList, err := dealData(indexInfoList)
  2127. if err != nil {
  2128. return nil, err
  2129. }
  2130. logs.Info("UpstreamSupplyOPECPolicyTargetCutProcessor dataList: %v", dataList)
  2131. return dataList, err
  2132. }
  2133. // UpstreamSupplyOPECPolicyActualCutProcessor
  2134. // @Description: UpstreamSupplyOPECPolicyActualCutProcessor处理器
  2135. type UpstreamSupplyOPECPolicyActualCutProcessor struct{}
  2136. var rzdActualCutFlag string
  2137. func (p *UpstreamSupplyOPECPolicyActualCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2138. logs.Info("Processing UpstreamSupplyOPECPolicyActualCutProcessor...")
  2139. if rowIndex <= 1 {
  2140. return nil, nil
  2141. }
  2142. if rowData[0] != "" {
  2143. rzdActualCutFlag = rowData[0]
  2144. } else {
  2145. rowData[0] = rzdActualCutFlag
  2146. }
  2147. frequency := "月度"
  2148. unit := "kbbl/d"
  2149. indexNameColPrefix := "OPEC_Policy"
  2150. indexNameColSuffix := "Actual Cut"
  2151. if !utils.IsNumeric(rowData[0]) {
  2152. return nil, nil
  2153. }
  2154. if rowData[1] == "Sum" {
  2155. return nil, nil
  2156. }
  2157. // step_1: 分类
  2158. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2159. if err != nil {
  2160. return nil, err
  2161. }
  2162. logs.Info("classifyId: %v", classifyId)
  2163. // step_2: 指标
  2164. // 指标名称
  2165. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2166. // 生成指标编码
  2167. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2168. var indexInfoList []*models.IndexInfo
  2169. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2170. if err != nil {
  2171. return nil, err
  2172. }
  2173. dataTime := rowData[0]
  2174. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2175. if err != nil {
  2176. return nil, err
  2177. }
  2178. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2179. IndexName: indexName,
  2180. IndexCode: indexCode,
  2181. Value: value,
  2182. DataTime: format,
  2183. })
  2184. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2185. if err != nil {
  2186. return nil, err
  2187. }
  2188. logs.Info("UpstreamSupplyOPECPolicyActualCutProcessor indexInfoList: %v", indexInfoList)
  2189. // step_3: 指标数据
  2190. dataList, err := dealData(indexInfoList)
  2191. if err != nil {
  2192. return nil, err
  2193. }
  2194. logs.Info("UpstreamSupplyOPECPolicyActualCutProcessor dataList: %v", dataList)
  2195. return dataList, err
  2196. }
  2197. // UpstreamSupplyOPECPolicyComplianceProcessor
  2198. // @Description: UpstreamSupplyOPECPolicyComplianceProcessor处理器
  2199. type UpstreamSupplyOPECPolicyComplianceProcessor struct{}
  2200. var rzdComplianceFlag string
  2201. func (p *UpstreamSupplyOPECPolicyComplianceProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2202. logs.Info("Processing UpstreamSupplyOPECPolicyComplianceProcessor...")
  2203. if rowIndex <= 1 {
  2204. return nil, nil
  2205. }
  2206. if rowData[0] != "" {
  2207. rzdComplianceFlag = rowData[0]
  2208. } else {
  2209. rowData[0] = rzdComplianceFlag
  2210. }
  2211. frequency := "月度"
  2212. unit := "kbbl/d"
  2213. indexNameColPrefix := "OPEC_Policy"
  2214. indexNameColSuffix := "Compliance"
  2215. if !utils.IsNumeric(rowData[0]) {
  2216. return nil, nil
  2217. }
  2218. if rowData[1] == "Sum" {
  2219. return nil, nil
  2220. }
  2221. // step_1: 分类
  2222. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2223. if err != nil {
  2224. return nil, err
  2225. }
  2226. logs.Info("classifyId: %v", classifyId)
  2227. // step_2: 指标
  2228. // 指标名称
  2229. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2230. // 生成指标编码
  2231. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2232. var indexInfoList []*models.IndexInfo
  2233. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2234. if err != nil {
  2235. return nil, err
  2236. }
  2237. dataTime := rowData[0]
  2238. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2239. if err != nil {
  2240. return nil, err
  2241. }
  2242. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2243. IndexName: indexName,
  2244. IndexCode: indexCode,
  2245. Value: value,
  2246. DataTime: format,
  2247. })
  2248. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2249. if err != nil {
  2250. return nil, err
  2251. }
  2252. logs.Info("UpstreamSupplyOPECPolicyComplianceProcessor indexInfoList: %v", indexInfoList)
  2253. // step_3: 指标数据
  2254. dataList, err := dealData(indexInfoList)
  2255. if err != nil {
  2256. return nil, err
  2257. }
  2258. logs.Info("UpstreamSupplyOPECPolicyComplianceProcessor dataList: %v", dataList)
  2259. return dataList, err
  2260. }
  2261. // UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor
  2262. // @Description: UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor处理器
  2263. type UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor struct{}
  2264. var rzdProductionSubjectToCutFlag string
  2265. func (p *UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2266. logs.Info("Processing UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor...")
  2267. if rowIndex <= 1 {
  2268. return nil, nil
  2269. }
  2270. if rowData[0] != "" {
  2271. rzdProductionSubjectToCutFlag = rowData[0]
  2272. } else {
  2273. rowData[0] = rzdProductionSubjectToCutFlag
  2274. }
  2275. frequency := "月度"
  2276. unit := "kbbl/d"
  2277. indexNameColPrefix := "OPEC_Policy"
  2278. indexNameColSuffix := "Production Subject To Cut"
  2279. if !utils.IsNumeric(rowData[0]) {
  2280. return nil, nil
  2281. }
  2282. if rowData[1] == "Sum" {
  2283. return nil, nil
  2284. }
  2285. // step_1: 分类
  2286. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2287. if err != nil {
  2288. return nil, err
  2289. }
  2290. logs.Info("classifyId: %v", classifyId)
  2291. // step_2: 指标
  2292. // 指标名称
  2293. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2294. // 生成指标编码
  2295. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2296. var indexInfoList []*models.IndexInfo
  2297. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2298. if err != nil {
  2299. return nil, err
  2300. }
  2301. dataTime := rowData[0]
  2302. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2303. if err != nil {
  2304. return nil, err
  2305. }
  2306. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2307. IndexName: indexName,
  2308. IndexCode: indexCode,
  2309. Value: value,
  2310. DataTime: format,
  2311. })
  2312. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2313. if err != nil {
  2314. return nil, err
  2315. }
  2316. logs.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor indexInfoList: %v", indexInfoList)
  2317. // step_3: 指标数据
  2318. dataList, err := dealData(indexInfoList)
  2319. if err != nil {
  2320. return nil, err
  2321. }
  2322. logs.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor dataList: %v", dataList)
  2323. return dataList, err
  2324. }
  2325. // ProductsDemandProductsDemandMeanProcessor
  2326. // @Description: ProductsDemandProductsDemandMeanProcessor处理器
  2327. type ProductsDemandProductsDemandMeanProcessor struct{}
  2328. var rzdProductsDemandMeanFlag string
  2329. func (p *ProductsDemandProductsDemandMeanProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2330. logs.Info("Processing ProductsDemandProductsDemandMeanProcessor...")
  2331. if rowIndex <= 1 {
  2332. return nil, nil
  2333. }
  2334. if rowData[0] != "" {
  2335. rzdProductsDemandMeanFlag = rowData[0]
  2336. } else {
  2337. rowData[0] = rzdProductsDemandMeanFlag
  2338. }
  2339. frequency := "月度"
  2340. unit := "kbbl/d"
  2341. //indexNameColPrefix := "OPEC_Policy"
  2342. indexNameColSuffix := "Products Demand Mean (1.0 DG) "
  2343. if !utils.IsNumeric(rowData[0]) {
  2344. return nil, nil
  2345. }
  2346. if rowData[1] == "Sum" {
  2347. return nil, nil
  2348. }
  2349. // step_1: 分类
  2350. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2351. if err != nil {
  2352. return nil, err
  2353. }
  2354. logs.Info("classifyId: %v", classifyId)
  2355. // step_2: 指标
  2356. // 指标名称
  2357. indexName := "Products Demand" + "/" + indexNameColSuffix
  2358. // 生成指标编码
  2359. indexCode, err := getIndexId("Products Demand "+"Products Demand Mean", strings.ReplaceAll(strings.ToLower("1.0dg"), " ", ""), "")
  2360. var indexInfoList []*models.IndexInfo
  2361. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2362. if err != nil {
  2363. return nil, err
  2364. }
  2365. dataTime := rowData[0]
  2366. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2367. if err != nil {
  2368. return nil, err
  2369. }
  2370. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2371. IndexName: indexName,
  2372. IndexCode: indexCode,
  2373. Value: value,
  2374. DataTime: format,
  2375. })
  2376. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2377. if err != nil {
  2378. return nil, err
  2379. }
  2380. logs.Info("ProductsDemandProductsDemandMeanProcessor indexInfoList: %v", indexInfoList)
  2381. // step_3: 指标数据
  2382. dataList, err := dealData(indexInfoList)
  2383. if err != nil {
  2384. return nil, err
  2385. }
  2386. logs.Info("ProductsDemandProductsDemandMeanProcessor dataList: %v", dataList)
  2387. return dataList, err
  2388. }
  2389. // ProductsDemandProductsDemandAddSigmaProcessor
  2390. // @Description: ProductsDemandProductsDemandAddSigmaProcessor处理器
  2391. type ProductsDemandProductsDemandAddSigmaProcessor struct{}
  2392. var rzdAddSigmaFlag string
  2393. func (p *ProductsDemandProductsDemandAddSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2394. logs.Info("Processing ProductsDemandProductsDemandAddSigmaProcessor...")
  2395. if rowIndex <= 1 {
  2396. return nil, nil
  2397. }
  2398. if rowData[0] != "" {
  2399. rzdAddSigmaFlag = rowData[0]
  2400. } else {
  2401. rowData[0] = rzdAddSigmaFlag
  2402. }
  2403. frequency := "月度"
  2404. unit := "kbbl/d"
  2405. //indexNameColPrefix := "OPEC_Policy"
  2406. indexNameColSuffix := "Products Demand +Sigma (2.2 DG) "
  2407. if !utils.IsNumeric(rowData[0]) {
  2408. return nil, nil
  2409. }
  2410. if rowData[1] == "Sum" {
  2411. return nil, nil
  2412. }
  2413. // step_1: 分类
  2414. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2415. if err != nil {
  2416. return nil, err
  2417. }
  2418. logs.Info("classifyId: %v", classifyId)
  2419. // step_2: 指标
  2420. // 指标名称
  2421. indexName := "Products Demand" + "/" + indexNameColSuffix
  2422. // 生成指标编码
  2423. indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("2.2dg"), " ", ""), "")
  2424. var indexInfoList []*models.IndexInfo
  2425. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2426. if err != nil {
  2427. return nil, err
  2428. }
  2429. dataTime := rowData[0]
  2430. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2431. if err != nil {
  2432. return nil, err
  2433. }
  2434. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2435. IndexName: indexName,
  2436. IndexCode: indexCode,
  2437. Value: value,
  2438. DataTime: format,
  2439. })
  2440. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2441. if err != nil {
  2442. return nil, err
  2443. }
  2444. logs.Info("ProductsDemandProductsDemandAddSigmaProcessor indexInfoList: %v", indexInfoList)
  2445. // step_3: 指标数据
  2446. dataList, err := dealData(indexInfoList)
  2447. if err != nil {
  2448. return nil, err
  2449. }
  2450. logs.Info("ProductsDemandProductsDemandAddSigmaProcessor dataList: %v", dataList)
  2451. return dataList, err
  2452. }
  2453. // ProductsDemandProductsDemandSubSigmaProcessor
  2454. // @Description: ProductsDemandProductsDemandSubSigmaProcessor处理器
  2455. type ProductsDemandProductsDemandSubSigmaProcessor struct{}
  2456. var rzdSubSigmaFlag string
  2457. func (p *ProductsDemandProductsDemandSubSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2458. logs.Info("Processing ProductsDemandProductsDemandSubSigmaProcessor...")
  2459. if rowIndex <= 1 {
  2460. return nil, nil
  2461. }
  2462. if rowData[0] != "" {
  2463. rzdSubSigmaFlag = rowData[0]
  2464. } else {
  2465. rowData[0] = rzdSubSigmaFlag
  2466. }
  2467. frequency := "月度"
  2468. unit := "kbbl/d"
  2469. //indexNameColPrefix := "OPEC_Policy"
  2470. indexNameColSuffix := "Products Demand -Sigma (1.8 DG) "
  2471. if !utils.IsNumeric(rowData[0]) {
  2472. return nil, nil
  2473. }
  2474. if rowData[1] == "Sum" {
  2475. return nil, nil
  2476. }
  2477. // step_1: 分类
  2478. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2479. if err != nil {
  2480. return nil, err
  2481. }
  2482. logs.Info("classifyId: %v", classifyId)
  2483. // step_2: 指标
  2484. // 指标名称
  2485. indexName := "Products Demand" + "/" + indexNameColSuffix
  2486. // 生成指标编码
  2487. indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("1.8dg"), " ", ""), "")
  2488. var indexInfoList []*models.IndexInfo
  2489. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2490. if err != nil {
  2491. return nil, err
  2492. }
  2493. dataTime := rowData[0]
  2494. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2495. if err != nil {
  2496. return nil, err
  2497. }
  2498. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2499. IndexName: indexName,
  2500. IndexCode: indexCode,
  2501. Value: value,
  2502. DataTime: format,
  2503. })
  2504. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2505. if err != nil {
  2506. return nil, err
  2507. }
  2508. logs.Info("ProductsDemandProductsDemandSubSigmaProcessor indexInfoList: %v", indexInfoList)
  2509. // step_3: 指标数据
  2510. dataList, err := dealData(indexInfoList)
  2511. if err != nil {
  2512. return nil, err
  2513. }
  2514. logs.Info("ProductsDemandProductsDemandSubSigmaProcessor dataList: %v", dataList)
  2515. return dataList, err
  2516. }
  2517. // BalancesTotalLiquidsBalancesProcessor
  2518. // @Description: BalancesTotalLiquidsBalancesProcessor处理器
  2519. type BalancesTotalLiquidsBalancesProcessor struct{}
  2520. var rzdTotalLiquidsBalancesFlag string
  2521. func (p *BalancesTotalLiquidsBalancesProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2522. logs.Info("Processing BalancesTotalLiquidsBalancesProcessor...")
  2523. if rowIndex <= 1 {
  2524. return nil, nil
  2525. }
  2526. if rowData[0] != "" {
  2527. rzdTotalLiquidsBalancesFlag = rowData[0]
  2528. } else {
  2529. rowData[0] = rzdTotalLiquidsBalancesFlag
  2530. }
  2531. frequency := "月度"
  2532. unit := "kbbl/d"
  2533. //indexNameColPrefix := "OPEC_Policy"
  2534. indexNameColSuffix := "Total Liquids Balances"
  2535. if !utils.IsNumeric(rowData[0]) {
  2536. return nil, nil
  2537. }
  2538. if rowData[1] == "Sum" {
  2539. return nil, nil
  2540. }
  2541. // step_1: 分类
  2542. classifyId, err := dealClassify("Oil Market Cube", "Balances")
  2543. if err != nil {
  2544. return nil, err
  2545. }
  2546. logs.Info("classifyId: %v", classifyId)
  2547. // step_2: 指标
  2548. // 指标名称
  2549. indexName := "Balances" + "/" + indexNameColSuffix
  2550. // 生成指标编码
  2551. indexCode, err := getIndexId("Balances", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2552. var indexInfoList []*models.IndexInfo
  2553. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2554. if err != nil {
  2555. return nil, err
  2556. }
  2557. dataTime := rowData[0]
  2558. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2559. if err != nil {
  2560. return nil, err
  2561. }
  2562. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2563. IndexName: indexName,
  2564. IndexCode: indexCode,
  2565. Value: value,
  2566. DataTime: format,
  2567. })
  2568. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2569. if err != nil {
  2570. return nil, err
  2571. }
  2572. logs.Info("BalancesTotalLiquidsBalancesProcessor indexInfoList: %v", indexInfoList)
  2573. // step_3: 指标数据
  2574. dataList, err := dealData(indexInfoList)
  2575. if err != nil {
  2576. return nil, err
  2577. }
  2578. logs.Info("BalancesTotalLiquidsBalancesProcessor dataList: %v", dataList)
  2579. return dataList, err
  2580. }
  2581. // GeographyLatitudeProcessor
  2582. // @Description: GeographyLatitudeProcessor处理器
  2583. type GeographyLatitudeProcessor struct{}
  2584. var rzdLatitudeFlag string
  2585. func (p *GeographyLatitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2586. logs.Info("Processing GeographyLatitudeProcessor...")
  2587. if rowIndex <= 1 {
  2588. return nil, nil
  2589. }
  2590. if rowData[0] != "" {
  2591. rzdLatitudeFlag = rowData[0]
  2592. } else {
  2593. rowData[0] = rzdLatitudeFlag
  2594. }
  2595. frequency := "月度"
  2596. unit := ""
  2597. //indexNameColPrefix := "OPEC_Policy"
  2598. indexNameColSuffix := "Latitude"
  2599. if !utils.IsNumeric(rowData[0]) {
  2600. return nil, nil
  2601. }
  2602. if rowData[1] == "Sum" {
  2603. return nil, nil
  2604. }
  2605. // step_1: 分类
  2606. classifyId, err := dealClassify("Oil Market Cube", "Geography")
  2607. if err != nil {
  2608. return nil, err
  2609. }
  2610. logs.Info("classifyId: %v", classifyId)
  2611. // step_2: 指标
  2612. // 指标名称
  2613. indexName := "Geography" + "/" + indexNameColSuffix
  2614. // 生成指标编码
  2615. indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2616. var indexInfoList []*models.IndexInfo
  2617. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2618. if err != nil {
  2619. return nil, err
  2620. }
  2621. dataTime := rowData[0]
  2622. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2623. if err != nil {
  2624. return nil, err
  2625. }
  2626. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2627. IndexName: indexName,
  2628. IndexCode: indexCode,
  2629. Value: value,
  2630. DataTime: format,
  2631. })
  2632. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2633. if err != nil {
  2634. return nil, err
  2635. }
  2636. logs.Info("GeographyLatitudeProcessor indexInfoList: %v", indexInfoList)
  2637. // step_3: 指标数据
  2638. dataList, err := dealData(indexInfoList)
  2639. if err != nil {
  2640. return nil, err
  2641. }
  2642. logs.Info("GeographyLatitudeProcessor dataList: %v", dataList)
  2643. return dataList, err
  2644. }
  2645. // GeographyLongitudeProcessor
  2646. // @Description: GeographyLongitudeProcessor处理器
  2647. type GeographyLongitudeProcessor struct{}
  2648. var rzdLongitudeFlag string
  2649. func (p *GeographyLongitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2650. logs.Info("Processing GeographyLongitudeProcessor...")
  2651. if rowIndex <= 1 {
  2652. return nil, nil
  2653. }
  2654. if rowData[0] != "" {
  2655. rzdLongitudeFlag = rowData[0]
  2656. } else {
  2657. rowData[0] = rzdLongitudeFlag
  2658. }
  2659. frequency := "月度"
  2660. unit := ""
  2661. //indexNameColPrefix := "OPEC_Policy"
  2662. indexNameColSuffix := "Longitude"
  2663. if !utils.IsNumeric(rowData[0]) {
  2664. return nil, nil
  2665. }
  2666. if rowData[1] == "Sum" {
  2667. return nil, nil
  2668. }
  2669. // step_1: 分类
  2670. classifyId, err := dealClassify("Oil Market Cube", "Geography")
  2671. if err != nil {
  2672. return nil, err
  2673. }
  2674. logs.Info("classifyId: %v", classifyId)
  2675. // step_2: 指标
  2676. // 指标名称
  2677. indexName := "Geography" + "/" + indexNameColSuffix
  2678. // 生成指标编码
  2679. indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2680. var indexInfoList []*models.IndexInfo
  2681. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2682. if err != nil {
  2683. return nil, err
  2684. }
  2685. dataTime := rowData[0]
  2686. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2687. if err != nil {
  2688. return nil, err
  2689. }
  2690. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2691. IndexName: indexName,
  2692. IndexCode: indexCode,
  2693. Value: value,
  2694. DataTime: format,
  2695. })
  2696. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2697. if err != nil {
  2698. return nil, err
  2699. }
  2700. logs.Info("GeographyLongitudeProcessor indexInfoList: %v", indexInfoList)
  2701. // step_3: 指标数据
  2702. dataList, err := dealData(indexInfoList)
  2703. if err != nil {
  2704. return nil, err
  2705. }
  2706. logs.Info("GeographyLongitudeProcessor dataList: %v", dataList)
  2707. return dataList, err
  2708. }
  2709. func dealData(indexInfoList []*models.IndexInfo) ([]models.BaseFromRzdData, error) {
  2710. var dataList []models.BaseFromRzdData
  2711. for _, indexInfo := range indexInfoList {
  2712. paramsLib := make(map[string]interface{})
  2713. paramsLib["IndexCode"] = indexInfo.IndexCode
  2714. paramsLib["DataTime"] = indexInfo.DataTime
  2715. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_INDEX_DATA_BY_CODE_AND_TIME)
  2716. if err != nil {
  2717. return nil, err
  2718. }
  2719. var requestResponse models.RequestResponse[models.BaseFromRzdData]
  2720. err = json.Unmarshal(postEdbLib, &requestResponse)
  2721. if err != nil {
  2722. return nil, err
  2723. }
  2724. if requestResponse.Data.BaseFromRzdIndexId == 0 {
  2725. dataOne := models.BaseFromRzdData{
  2726. BaseFromRzdIndexId: indexInfo.IndexInfoId,
  2727. CreateTime: utils.GetCurrentTime(),
  2728. DataTime: indexInfo.DataTime,
  2729. IndexCode: indexInfo.IndexCode,
  2730. ModifyTime: utils.GetCurrentTime(),
  2731. Value: math.Round(indexInfo.Value*10000) / 10000,
  2732. }
  2733. dataList = append(dataList, dataOne)
  2734. }
  2735. }
  2736. return dataList, nil
  2737. }
  2738. func dealIndex(indexInfoList []*models.IndexInfo, frequency string, unit string, classifyId int) ([]*models.IndexInfo, error) {
  2739. for _, index := range indexInfoList {
  2740. // 处理第一个指标
  2741. paramsLib := make(map[string]interface{})
  2742. paramsLib["indexCode"] = index.IndexCode
  2743. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_INDEX_BY_CODE)
  2744. if err != nil {
  2745. return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  2746. }
  2747. var requestResponse models.RequestResponse[models.BaseFromRzdIndex]
  2748. err = json.Unmarshal(postEdbLib, &requestResponse)
  2749. if err != nil {
  2750. return nil, err
  2751. }
  2752. if requestResponse.Data.BaseFromRzdIndexId == 0 {
  2753. indexOne := models.BaseFromRzdIndex{
  2754. CreateTime: utils.GetCurrentTime(),
  2755. ModifyTime: utils.GetCurrentTime(),
  2756. BaseFromLyClassifyId: classifyId,
  2757. IndexCode: index.IndexCode,
  2758. IndexName: index.IndexName,
  2759. Frequency: frequency,
  2760. Unit: unit,
  2761. }
  2762. // 这里避免服务器宕机 出现唯一索引异常,进行分开保存
  2763. postEdbLib, err = httpRequestFill(indexOne, utils.ADD_RZD_INDEX)
  2764. if err != nil {
  2765. return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  2766. }
  2767. var requestResponse models.RequestResponse[int]
  2768. err = json.Unmarshal(postEdbLib, &requestResponse)
  2769. if err != nil {
  2770. return nil, err
  2771. }
  2772. logs.Info("indexOneId: %v", requestResponse.Data)
  2773. index.IndexInfoId = requestResponse.Data
  2774. } else {
  2775. logs.Info("indexOneId: %v", requestResponse.Data.BaseFromRzdIndexId)
  2776. index.IndexInfoId = requestResponse.Data.BaseFromRzdIndexId
  2777. }
  2778. }
  2779. return indexInfoList, nil
  2780. }
  2781. func getIndexId(prefix string, area string, suffix string) (string, error) {
  2782. prefixWords := strings.Fields(prefix) // 分割字符串为单词
  2783. firstLetters := ""
  2784. for _, word := range prefixWords {
  2785. if len(word) > 0 {
  2786. firstLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  2787. }
  2788. }
  2789. suffixWords := strings.Fields(suffix) // 分割字符串为单词
  2790. SecondLetters := ""
  2791. for _, word := range suffixWords {
  2792. if len(word) > 0 {
  2793. SecondLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  2794. }
  2795. }
  2796. indexCode := "rzd" + firstLetters + area + SecondLetters
  2797. return indexCode, nil
  2798. }
  2799. // 处理分类
  2800. func dealClassify(tableName, sheetName string) (int, error) {
  2801. // 查询一级分类是否存在
  2802. paramsLib := make(map[string]interface{})
  2803. paramsLib["classifyName"] = classifyMap[tableName]
  2804. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_CLASSIFY_BY_NAME)
  2805. if err != nil {
  2806. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to get classify: %v", err)
  2807. }
  2808. var requestResponse models.RequestResponse[models.BaseFromRzdClassify]
  2809. err = json.Unmarshal(postEdbLib, &requestResponse)
  2810. if err != nil {
  2811. return 0, err
  2812. }
  2813. // 处理一级分类
  2814. var parentId int
  2815. if requestResponse.Data.BaseFromRzdClassifyId == 0 {
  2816. // 一级分类不存在,新增一级分类
  2817. paramsLib = make(map[string]interface{})
  2818. paramsLib["parentId"] = 0
  2819. paramsLib["classifyName"] = classifyMap[tableName]
  2820. postEdbLib, err = httpRequestFill(paramsLib, utils.ADD_RZD_CLASSIFY)
  2821. if err != nil {
  2822. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to add classify: %v", err)
  2823. }
  2824. var requestResponse models.RequestResponse[int]
  2825. err = json.Unmarshal(postEdbLib, &requestResponse)
  2826. if err != nil {
  2827. return 0, err
  2828. }
  2829. parentId = requestResponse.Data
  2830. } else {
  2831. // 一级分类已存在,使用其 ID
  2832. parentId = requestResponse.Data.BaseFromRzdClassifyId
  2833. }
  2834. // 查询二级分类是否存在
  2835. paramsSubLib := make(map[string]interface{})
  2836. paramsSubLib["classifyName"] = sheetName // 这里替换成实际的二级分类名称
  2837. postSubEdbLib, err := httpRequestFill(paramsSubLib, utils.GET_RZD_CLASSIFY_BY_NAME)
  2838. if err != nil {
  2839. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to get sub classify: %v", err)
  2840. }
  2841. var subRequestResponse models.RequestResponse[models.BaseFromRzdClassify]
  2842. err = json.Unmarshal(postSubEdbLib, &subRequestResponse)
  2843. if err != nil {
  2844. return 0, err
  2845. }
  2846. // 新增二级分类
  2847. var classifyId int
  2848. if subRequestResponse.Data.BaseFromRzdClassifyId == 0 {
  2849. paramsLib = make(map[string]interface{})
  2850. paramsLib["parentId"] = parentId
  2851. paramsLib["classifyName"] = sheetName
  2852. postEdbLib, err = httpRequestFill(paramsLib, utils.ADD_RZD_CLASSIFY)
  2853. if err != nil {
  2854. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to add classify: %v", err)
  2855. }
  2856. var requestResponse models.RequestResponse[int]
  2857. err = json.Unmarshal(postEdbLib, &requestResponse)
  2858. if err != nil {
  2859. return 0, err
  2860. }
  2861. classifyId = requestResponse.Data
  2862. } else {
  2863. classifyId = subRequestResponse.Data.BaseFromRzdClassifyId
  2864. }
  2865. return classifyId, nil
  2866. }