processor_business_logic.go 96 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483
  1. // Package ruizide
  2. // @Author gmy 2024/10/21 10:50:00
  3. package ruizide
  4. import (
  5. "encoding/json"
  6. "eta/eta_data_analysis/models"
  7. "eta/eta_data_analysis/utils"
  8. "fmt"
  9. "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. timeSplit := strings.Split(dataTimeOne, "-")
  877. formatOne, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
  878. if err != nil {
  879. return nil, err
  880. }
  881. indexInfoList = append(indexInfoList, &models.IndexInfo{
  882. IndexName: indexNameOne,
  883. IndexCode: indexCodeOne,
  884. Value: valueOne,
  885. DataTime: formatOne,
  886. })
  887. var valueTwo float64
  888. if rowData[len(rowData)-3] == "" {
  889. valueTwo = 0
  890. } else {
  891. valueTwo, err = strconv.ParseFloat(strings.ReplaceAll(rowData[len(rowData)-3], ",", ""), 64)
  892. if err != nil {
  893. return nil, err
  894. }
  895. }
  896. indexInfoList = append(indexInfoList, &models.IndexInfo{
  897. IndexName: indexNameTwo,
  898. IndexCode: indexCodeTwo,
  899. Value: valueTwo,
  900. DataTime: formatOne,
  901. })
  902. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  903. if err != nil {
  904. return nil, err
  905. }
  906. logs.Info("SupplyRevisionAnalysisChartFiveProcessor indexInfoList: %v", indexInfoList)
  907. // step_3: 指标数据
  908. dataList, err := dealData(indexInfoList)
  909. if err != nil {
  910. return nil, err
  911. }
  912. logs.Info("SupplyRevisionAnalysisChartFiveProcessor dataList: %v", dataList)
  913. return dataList, err
  914. }
  915. // SupplyRevisionAnalysisChartSixProcessor
  916. // @Description: SupplyRevisionAnalysisChartSixProcessor
  917. type SupplyRevisionAnalysisChartSixProcessor struct{}
  918. func (p *SupplyRevisionAnalysisChartSixProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  919. logs.Info("Processing SupplyRevisionAnalysisChartSixProcessor...")
  920. if rowIndex < 1 {
  921. return nil, nil
  922. }
  923. frequency := "月度"
  924. unit := "千桶每天"
  925. indexNameColSuffix := "YearMonth"
  926. indexNameColPrefix := "Country Revision Group"
  927. // step_1: 分类
  928. classifyId, err := dealClassify("cube dashboards", "Supply Revision Analysis")
  929. if err != nil {
  930. return nil, err
  931. }
  932. logs.Info("classifyId: %v", classifyId)
  933. // step_2: 指标
  934. // 指标名称
  935. indexName := "Supply Revision Analysis" + "/" + indexNameColPrefix + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  936. // 生成指标编码
  937. indexCode, err := getIndexId("Supply Revision Analysis "+indexNameColPrefix+" "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  938. indexInfoMap := make(map[string]string)
  939. indexInfoMap[indexCode] = indexName
  940. var indexInfoList []*models.IndexInfo
  941. var value float64
  942. if rowData[len(rowData)-1] == "" {
  943. value = 0
  944. } else {
  945. value, err = strconv.ParseFloat(rowData[len(rowData)-1], 64)
  946. if err != nil {
  947. return nil, err
  948. }
  949. }
  950. dataTime := rowData[0]
  951. timeSplit := strings.Split(dataTime, "-")
  952. format, err := utils.GetLastDayOfMonth(timeSplit[0] + "-" + timeSplit[1])
  953. if err != nil {
  954. return nil, err
  955. }
  956. indexInfoList = append(indexInfoList, &models.IndexInfo{
  957. IndexName: indexName,
  958. IndexCode: indexCode,
  959. Value: value,
  960. DataTime: format,
  961. })
  962. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  963. if err != nil {
  964. return nil, err
  965. }
  966. logs.Info("SupplyRevisionAnalysisChartSixProcessor indexInfoList: %v", indexInfoList)
  967. // step_3: 指标数据
  968. dataList, err := dealData(indexInfoList)
  969. if err != nil {
  970. return nil, err
  971. }
  972. logs.Info("SupplyRevisionAnalysisChartSixProcessor dataList: %v", dataList)
  973. return dataList, err
  974. }
  975. // OilSupplyAnalysisChartOneProcessor
  976. // @Description: OilSupplyAnalysisChartOneProcessor处理器
  977. type OilSupplyAnalysisChartOneProcessor struct{}
  978. func (p *OilSupplyAnalysisChartOneProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  979. logs.Info("Processing OilSupplyAnalysisChartOne...")
  980. if rowIndex < 1 {
  981. return nil, nil
  982. }
  983. frequency := "月度"
  984. unit := "千桶每天"
  985. indexNameColSuffix := "Oil And Gas Category"
  986. //indexNameColPrefix := "CountryRevisionGroup"
  987. // step_1: 分类
  988. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  989. if err != nil {
  990. return nil, err
  991. }
  992. logs.Info("classifyId: %v", classifyId)
  993. // step_2: 指标
  994. // 指标名称
  995. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  996. // 生成指标编码
  997. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  998. indexInfoMap := make(map[string]string)
  999. indexInfoMap[indexCode] = indexName
  1000. var indexInfoList []*models.IndexInfo
  1001. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1002. if err != nil {
  1003. return nil, err
  1004. }
  1005. dataTime := rowData[0]
  1006. format, err := utils.ConvertDateFormat3(dataTime)
  1007. if err != nil {
  1008. return nil, err
  1009. }
  1010. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1011. IndexName: indexName,
  1012. IndexCode: indexCode,
  1013. Value: value,
  1014. DataTime: format,
  1015. })
  1016. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1017. if err != nil {
  1018. return nil, err
  1019. }
  1020. logs.Info("OilSupplyAnalysisChartOneProcessor indexInfoList: %v", indexInfoList)
  1021. // step_3: 指标数据
  1022. dataList, err := dealData(indexInfoList)
  1023. if err != nil {
  1024. return nil, err
  1025. }
  1026. logs.Info("OilSupplyAnalysisChartOneProcessor dataList: %v", dataList)
  1027. return dataList, err
  1028. }
  1029. // OilSupplyAnalysisChartTwoProcessor
  1030. // @Description: OilSupplyAnalysisChartTwoProcessor处理器
  1031. type OilSupplyAnalysisChartTwoProcessor struct{}
  1032. func (p *OilSupplyAnalysisChartTwoProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1033. logs.Info("Processing OilSupplyAnalysisChartTwoProcessor...")
  1034. if rowIndex < 1 {
  1035. return nil, nil
  1036. }
  1037. frequency := "月度"
  1038. unit := "千桶每天"
  1039. indexNameColSuffix := "Region"
  1040. //indexNameColPrefix := "CountryRevisionGroup"
  1041. // step_1: 分类
  1042. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1043. if err != nil {
  1044. return nil, err
  1045. }
  1046. logs.Info("classifyId: %v", classifyId)
  1047. // step_2: 指标
  1048. // 指标名称
  1049. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-1]
  1050. // 生成指标编码
  1051. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-1]), " ", ""), "")
  1052. indexInfoMap := make(map[string]string)
  1053. indexInfoMap[indexCode] = indexName
  1054. var indexInfoList []*models.IndexInfo
  1055. value, err := strconv.ParseFloat(rowData[len(rowData)-2], 64)
  1056. if err != nil {
  1057. return nil, err
  1058. }
  1059. dataTime := rowData[0]
  1060. format, err := utils.ConvertDateFormat3(dataTime)
  1061. if err != nil {
  1062. return nil, err
  1063. }
  1064. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1065. IndexName: indexName,
  1066. IndexCode: indexCode,
  1067. Value: value,
  1068. DataTime: format,
  1069. })
  1070. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1071. if err != nil {
  1072. return nil, err
  1073. }
  1074. logs.Info("OilSupplyAnalysisChartTwoProcessor indexInfoList: %v", indexInfoList)
  1075. // step_3: 指标数据
  1076. dataList, err := dealData(indexInfoList)
  1077. if err != nil {
  1078. return nil, err
  1079. }
  1080. logs.Info("OilSupplyAnalysisChartTwoProcessor dataList: %v", dataList)
  1081. return dataList, err
  1082. }
  1083. // OilSupplyAnalysisChartThreeProcessor
  1084. // @Description: OilSupplyAnalysisChartThreeProcessor处理器
  1085. type OilSupplyAnalysisChartThreeProcessor struct{}
  1086. func (p *OilSupplyAnalysisChartThreeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1087. logs.Info("Processing OilSupplyAnalysisChartThreeProcessor...")
  1088. if rowIndex < 1 {
  1089. return nil, nil
  1090. }
  1091. frequency := "月度"
  1092. unit := "千桶每天"
  1093. indexNameColSuffix := "CapacityDetail"
  1094. //indexNameColPrefix := "CountryRevisionGroup"
  1095. // step_1: 分类
  1096. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1097. if err != nil {
  1098. return nil, err
  1099. }
  1100. logs.Info("classifyId: %v", classifyId)
  1101. // step_2: 指标
  1102. // 指标名称
  1103. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1104. // 生成指标编码
  1105. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1106. indexInfoMap := make(map[string]string)
  1107. indexInfoMap[indexCode] = indexName
  1108. var indexInfoList []*models.IndexInfo
  1109. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1110. if err != nil {
  1111. return nil, err
  1112. }
  1113. dataTime := rowData[0]
  1114. format, err := utils.ConvertDateFormat3(dataTime)
  1115. if err != nil {
  1116. return nil, err
  1117. }
  1118. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1119. IndexName: indexName,
  1120. IndexCode: indexCode,
  1121. Value: value,
  1122. DataTime: format,
  1123. })
  1124. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1125. if err != nil {
  1126. return nil, err
  1127. }
  1128. logs.Info("OilSupplyAnalysisChartThreeProcessor indexInfoList: %v", indexInfoList)
  1129. // step_3: 指标数据
  1130. dataList, err := dealData(indexInfoList)
  1131. if err != nil {
  1132. return nil, err
  1133. }
  1134. logs.Info("OilSupplyAnalysisChartThreeProcessor dataList: %v", dataList)
  1135. return dataList, err
  1136. }
  1137. // OilSupplyAnalysisChartFourProcessor
  1138. // @Description: OilSupplyAnalysisChartFourProcessor处理器
  1139. type OilSupplyAnalysisChartFourProcessor struct{}
  1140. func (p *OilSupplyAnalysisChartFourProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1141. logs.Info("Processing OilSupplyAnalysisChartFourProcessor...")
  1142. if rowIndex < 1 {
  1143. return nil, nil
  1144. }
  1145. frequency := "月度"
  1146. unit := "千桶每天"
  1147. indexNameColSuffix := "Oil Classification Group"
  1148. //indexNameColPrefix := "CountryRevisionGroup"
  1149. // step_1: 分类
  1150. classifyId, err := dealClassify("cube dashboards", "Oil Supply Analysis")
  1151. if err != nil {
  1152. return nil, err
  1153. }
  1154. logs.Info("classifyId: %v", classifyId)
  1155. // step_2: 指标
  1156. // 指标名称
  1157. indexName := "Oil Supply Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1158. // 生成指标编码
  1159. indexCode, err := getIndexId("Oil Supply Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1160. indexInfoMap := make(map[string]string)
  1161. indexInfoMap[indexCode] = indexName
  1162. var indexInfoList []*models.IndexInfo
  1163. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1164. if err != nil {
  1165. return nil, err
  1166. }
  1167. dataTime := rowData[0]
  1168. format, err := utils.ConvertDateFormat3(dataTime)
  1169. if err != nil {
  1170. return nil, err
  1171. }
  1172. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1173. IndexName: indexName,
  1174. IndexCode: indexCode,
  1175. Value: value,
  1176. DataTime: format,
  1177. })
  1178. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1179. if err != nil {
  1180. return nil, err
  1181. }
  1182. logs.Info("OilSupplyAnalysisChartFourProcessor indexInfoList: %v", indexInfoList)
  1183. // step_3: 指标数据
  1184. dataList, err := dealData(indexInfoList)
  1185. if err != nil {
  1186. return nil, err
  1187. }
  1188. logs.Info("OilSupplyAnalysisChartFourProcessor dataList: %v", dataList)
  1189. return dataList, err
  1190. }
  1191. // OilDemandAnalysisContinentProcessor
  1192. // @Description: OilDemandAnalysisContinentProcessor处理器
  1193. type OilDemandAnalysisContinentProcessor struct{}
  1194. func (p *OilDemandAnalysisContinentProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1195. logs.Info("Processing OilDemandAnalysisContinentProcessor...")
  1196. if rowIndex < 1 {
  1197. return nil, nil
  1198. }
  1199. frequency := "月度"
  1200. unit := "千桶每天"
  1201. indexNameColSuffix := "Continent"
  1202. //indexNameColPrefix := "CountryRevisionGroup"
  1203. // step_1: 分类
  1204. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1205. if err != nil {
  1206. return nil, err
  1207. }
  1208. logs.Info("classifyId: %v", classifyId)
  1209. // step_2: 指标
  1210. // 指标名称
  1211. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1212. // 生成指标编码
  1213. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1214. indexInfoMap := make(map[string]string)
  1215. indexInfoMap[indexCode] = indexName
  1216. var indexInfoList []*models.IndexInfo
  1217. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1218. if err != nil {
  1219. return nil, err
  1220. }
  1221. dataTime := rowData[0]
  1222. format, err := utils.ConvertDateFormat3(dataTime)
  1223. if err != nil {
  1224. return nil, err
  1225. }
  1226. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1227. IndexName: indexName,
  1228. IndexCode: indexCode,
  1229. Value: value,
  1230. DataTime: format,
  1231. })
  1232. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1233. if err != nil {
  1234. return nil, err
  1235. }
  1236. logs.Info("OilDemandAnalysisContinentProcessor indexInfoList: %v", indexInfoList)
  1237. // step_3: 指标数据
  1238. dataList, err := dealData(indexInfoList)
  1239. if err != nil {
  1240. return nil, err
  1241. }
  1242. logs.Info("OilDemandAnalysisContinentProcessor dataList: %v", dataList)
  1243. return dataList, err
  1244. }
  1245. // OilDemandAnalysisRegionProcessor
  1246. // @Description: OilDemandAnalysisRegionProcessor处理器
  1247. type OilDemandAnalysisRegionProcessor struct{}
  1248. func (p *OilDemandAnalysisRegionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1249. logs.Info("Processing OilDemandAnalysisRegionProcessor...")
  1250. if rowIndex < 1 {
  1251. return nil, nil
  1252. }
  1253. frequency := "月度"
  1254. unit := "千桶每天"
  1255. indexNameColSuffix := "Region"
  1256. //indexNameColPrefix := "CountryRevisionGroup"
  1257. // step_1: 分类
  1258. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1259. if err != nil {
  1260. return nil, err
  1261. }
  1262. logs.Info("classifyId: %v", classifyId)
  1263. // step_2: 指标
  1264. // 指标名称
  1265. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1266. // 生成指标编码
  1267. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1268. indexInfoMap := make(map[string]string)
  1269. indexInfoMap[indexCode] = indexName
  1270. var indexInfoList []*models.IndexInfo
  1271. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1272. if err != nil {
  1273. return nil, err
  1274. }
  1275. dataTime := rowData[0]
  1276. format, err := utils.ConvertDateFormat3(dataTime)
  1277. if err != nil {
  1278. return nil, err
  1279. }
  1280. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1281. IndexName: indexName,
  1282. IndexCode: indexCode,
  1283. Value: value,
  1284. DataTime: format,
  1285. })
  1286. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1287. if err != nil {
  1288. return nil, err
  1289. }
  1290. logs.Info("OilDemandAnalysisRegionProcessor indexInfoList: %v", indexInfoList)
  1291. // step_3: 指标数据
  1292. dataList, err := dealData(indexInfoList)
  1293. if err != nil {
  1294. return nil, err
  1295. }
  1296. logs.Info("OilDemandAnalysisRegionProcessor dataList: %v", dataList)
  1297. return dataList, err
  1298. }
  1299. // OilDemandAnalysisCountryProcessor
  1300. // @Description: OilDemandAnalysisCountryProcessor
  1301. type OilDemandAnalysisCountryProcessor struct{}
  1302. func (p *OilDemandAnalysisCountryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1303. logs.Info("Processing OilDemandAnalysisCountryProcessor...")
  1304. if rowIndex < 1 {
  1305. return nil, nil
  1306. }
  1307. frequency := "月度"
  1308. unit := "千桶每天"
  1309. indexNameColSuffix := "Country"
  1310. //indexNameColPrefix := "CountryRevisionGroup"
  1311. // step_1: 分类
  1312. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1313. if err != nil {
  1314. return nil, err
  1315. }
  1316. logs.Info("classifyId: %v", classifyId)
  1317. // step_2: 指标
  1318. // 指标名称
  1319. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1320. // 生成指标编码
  1321. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1322. indexInfoMap := make(map[string]string)
  1323. indexInfoMap[indexCode] = indexName
  1324. var indexInfoList []*models.IndexInfo
  1325. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1326. if err != nil {
  1327. return nil, err
  1328. }
  1329. dataTime := rowData[0]
  1330. format, err := utils.ConvertDateFormat3(dataTime)
  1331. if err != nil {
  1332. return nil, err
  1333. }
  1334. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1335. IndexName: indexName,
  1336. IndexCode: indexCode,
  1337. Value: value,
  1338. DataTime: format,
  1339. })
  1340. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1341. if err != nil {
  1342. return nil, err
  1343. }
  1344. logs.Info("OilDemandAnalysisCountryProcessor indexInfoList: %v", indexInfoList)
  1345. // step_3: 指标数据
  1346. dataList, err := dealData(indexInfoList)
  1347. if err != nil {
  1348. return nil, err
  1349. }
  1350. logs.Info("OilDemandAnalysisCountryProcessor dataList: %v", dataList)
  1351. return dataList, err
  1352. }
  1353. // OilDemandAnalysisProductCategoryProcessor
  1354. // @Description: OilDemandAnalysisProductCategoryProcessor处理器
  1355. type OilDemandAnalysisProductCategoryProcessor struct{}
  1356. func (p *OilDemandAnalysisProductCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1357. logs.Info("Processing OilDemandAnalysisProductCategoryProcessor...")
  1358. if rowIndex < 1 {
  1359. return nil, nil
  1360. }
  1361. frequency := "月度"
  1362. unit := "千桶每天"
  1363. indexNameColSuffix := "Product category"
  1364. //indexNameColPrefix := "CountryRevisionGroup"
  1365. // step_1: 分类
  1366. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1367. if err != nil {
  1368. return nil, err
  1369. }
  1370. logs.Info("classifyId: %v", classifyId)
  1371. // step_2: 指标
  1372. // 指标名称
  1373. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1374. // 生成指标编码
  1375. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1376. indexInfoMap := make(map[string]string)
  1377. indexInfoMap[indexCode] = indexName
  1378. var indexInfoList []*models.IndexInfo
  1379. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1380. if err != nil {
  1381. return nil, err
  1382. }
  1383. dataTime := rowData[0]
  1384. format, err := utils.ConvertDateFormat3(dataTime)
  1385. if err != nil {
  1386. return nil, err
  1387. }
  1388. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1389. IndexName: indexName,
  1390. IndexCode: indexCode,
  1391. Value: value,
  1392. DataTime: format,
  1393. })
  1394. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1395. if err != nil {
  1396. return nil, err
  1397. }
  1398. logs.Info("OilDemandAnalysisProductCategoryProcessor indexInfoList: %v", indexInfoList)
  1399. // step_3: 指标数据
  1400. dataList, err := dealData(indexInfoList)
  1401. if err != nil {
  1402. return nil, err
  1403. }
  1404. logs.Info("OilDemandAnalysisProductCategoryProcessor dataList: %v", dataList)
  1405. return dataList, err
  1406. }
  1407. // OilDemandAnalysisProductDetailProcessor
  1408. // @Description: OilDemandAnalysisProductDetailProcessor处理器
  1409. type OilDemandAnalysisProductDetailProcessor struct{}
  1410. func (p *OilDemandAnalysisProductDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1411. logs.Info("Processing OilDemandAnalysisProductDetailProcessor...")
  1412. if rowIndex < 1 {
  1413. return nil, nil
  1414. }
  1415. frequency := "月度"
  1416. unit := "千桶每天"
  1417. indexNameColSuffix := "Product detail"
  1418. //indexNameColPrefix := "CountryRevisionGroup"
  1419. // step_1: 分类
  1420. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1421. if err != nil {
  1422. return nil, err
  1423. }
  1424. logs.Info("classifyId: %v", classifyId)
  1425. // step_2: 指标
  1426. // 指标名称
  1427. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1428. // 生成指标编码
  1429. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1430. indexInfoMap := make(map[string]string)
  1431. indexInfoMap[indexCode] = indexName
  1432. var indexInfoList []*models.IndexInfo
  1433. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1434. if err != nil {
  1435. return nil, err
  1436. }
  1437. dataTime := rowData[0]
  1438. format, err := utils.ConvertDateFormat3(dataTime)
  1439. if err != nil {
  1440. return nil, err
  1441. }
  1442. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1443. IndexName: indexName,
  1444. IndexCode: indexCode,
  1445. Value: value,
  1446. DataTime: format,
  1447. })
  1448. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1449. if err != nil {
  1450. return nil, err
  1451. }
  1452. logs.Info("OilDemandAnalysisProductDetailProcessor indexInfoList: %v", indexInfoList)
  1453. // step_3: 指标数据
  1454. dataList, err := dealData(indexInfoList)
  1455. if err != nil {
  1456. return nil, err
  1457. }
  1458. logs.Info("OilDemandAnalysisProductDetailProcessor dataList: %v", dataList)
  1459. return dataList, err
  1460. }
  1461. // OilDemandAnalysisSectorCategoryProcessor
  1462. // @Description: OilDemandAnalysisSectorCategoryProcessor处理器
  1463. type OilDemandAnalysisSectorCategoryProcessor struct{}
  1464. func (p *OilDemandAnalysisSectorCategoryProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1465. logs.Info("Processing OilDemandAnalysisSectorCategoryProcessor...")
  1466. if rowIndex < 1 {
  1467. return nil, nil
  1468. }
  1469. frequency := "月度"
  1470. unit := "千桶每天"
  1471. indexNameColSuffix := "Sector category"
  1472. //indexNameColPrefix := "CountryRevisionGroup"
  1473. // step_1: 分类
  1474. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1475. if err != nil {
  1476. return nil, err
  1477. }
  1478. logs.Info("classifyId: %v", classifyId)
  1479. // step_2: 指标
  1480. // 指标名称
  1481. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1482. // 生成指标编码
  1483. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1484. indexInfoMap := make(map[string]string)
  1485. indexInfoMap[indexCode] = indexName
  1486. var indexInfoList []*models.IndexInfo
  1487. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1488. if err != nil {
  1489. return nil, err
  1490. }
  1491. dataTime := rowData[0]
  1492. format, err := utils.ConvertDateFormat3(dataTime)
  1493. if err != nil {
  1494. return nil, err
  1495. }
  1496. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1497. IndexName: indexName,
  1498. IndexCode: indexCode,
  1499. Value: value,
  1500. DataTime: format,
  1501. })
  1502. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1503. if err != nil {
  1504. return nil, err
  1505. }
  1506. logs.Info("OilDemandAnalysisSectorCategoryProcessor indexInfoList: %v", indexInfoList)
  1507. // step_3: 指标数据
  1508. dataList, err := dealData(indexInfoList)
  1509. if err != nil {
  1510. return nil, err
  1511. }
  1512. logs.Info("OilDemandAnalysisSectorCategoryProcessor dataList: %v", dataList)
  1513. return dataList, err
  1514. }
  1515. // OilDemandAnalysisSectorDetailProcessor
  1516. // @Description: OilDemandAnalysisSectorDetailProcessor处理器
  1517. type OilDemandAnalysisSectorDetailProcessor struct{}
  1518. func (p *OilDemandAnalysisSectorDetailProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1519. logs.Info("Processing OilDemandAnalysisSectorDetailProcessor...")
  1520. if rowIndex < 1 {
  1521. return nil, nil
  1522. }
  1523. frequency := "月度"
  1524. unit := "千桶每天"
  1525. indexNameColSuffix := "Sector detail"
  1526. //indexNameColPrefix := "CountryRevisionGroup"
  1527. // step_1: 分类
  1528. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1529. if err != nil {
  1530. return nil, err
  1531. }
  1532. logs.Info("classifyId: %v", classifyId)
  1533. // step_2: 指标
  1534. // 指标名称
  1535. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1536. // 生成指标编码
  1537. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1538. indexInfoMap := make(map[string]string)
  1539. indexInfoMap[indexCode] = indexName
  1540. var indexInfoList []*models.IndexInfo
  1541. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1542. if err != nil {
  1543. return nil, err
  1544. }
  1545. dataTime := rowData[0]
  1546. format, err := utils.ConvertDateFormat3(dataTime)
  1547. if err != nil {
  1548. return nil, err
  1549. }
  1550. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1551. IndexName: indexName,
  1552. IndexCode: indexCode,
  1553. Value: value,
  1554. DataTime: format,
  1555. })
  1556. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1557. if err != nil {
  1558. return nil, err
  1559. }
  1560. logs.Info("OilDemandAnalysisSectorDetailProcessor indexInfoList: %v", indexInfoList)
  1561. // step_3: 指标数据
  1562. dataList, err := dealData(indexInfoList)
  1563. if err != nil {
  1564. return nil, err
  1565. }
  1566. logs.Info("OilDemandAnalysisSectorDetailProcessor dataList: %v", dataList)
  1567. return dataList, err
  1568. }
  1569. // OilDemandAnalysisScenarioProcessor
  1570. // @Description: OilDemandAnalysisScenarioProcessor处理器
  1571. type OilDemandAnalysisScenarioProcessor struct{}
  1572. func (p *OilDemandAnalysisScenarioProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1573. logs.Info("Processing OilDemandAnalysisScenarioProcessor...")
  1574. if rowIndex < 1 {
  1575. return nil, nil
  1576. }
  1577. frequency := "月度"
  1578. unit := "千桶每天"
  1579. indexNameColSuffix := "Scenario"
  1580. //indexNameColPrefix := "CountryRevisionGroup"
  1581. // step_1: 分类
  1582. classifyId, err := dealClassify("cube dashboards", "Oil Demand Analysis")
  1583. if err != nil {
  1584. return nil, err
  1585. }
  1586. logs.Info("classifyId: %v", classifyId)
  1587. // step_2: 指标
  1588. // 指标名称
  1589. indexName := "Oil Demand Analysis" + "/" + indexNameColSuffix + "/" + rowData[len(rowData)-2]
  1590. // 生成指标编码
  1591. indexCode, err := getIndexId("Oil Demand Analysis "+indexNameColSuffix, strings.ReplaceAll(strings.ToLower(rowData[len(rowData)-2]), " ", ""), "")
  1592. indexInfoMap := make(map[string]string)
  1593. indexInfoMap[indexCode] = indexName
  1594. var indexInfoList []*models.IndexInfo
  1595. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1596. if err != nil {
  1597. return nil, err
  1598. }
  1599. dataTime := rowData[0]
  1600. format, err := utils.ConvertDateFormat3(dataTime)
  1601. if err != nil {
  1602. return nil, err
  1603. }
  1604. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1605. IndexName: indexName,
  1606. IndexCode: indexCode,
  1607. Value: value,
  1608. DataTime: format,
  1609. })
  1610. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1611. if err != nil {
  1612. return nil, err
  1613. }
  1614. logs.Info("OilDemandAnalysisScenarioProcessor indexInfoList: %v", indexInfoList)
  1615. // step_3: 指标数据
  1616. dataList, err := dealData(indexInfoList)
  1617. if err != nil {
  1618. return nil, err
  1619. }
  1620. logs.Info("OilDemandAnalysisScenarioProcessor dataList: %v", dataList)
  1621. return dataList, err
  1622. }
  1623. // UpstreamSupplyOilQualityApiProcessor
  1624. // @Description: UpstreamSupplyOilQualityApiProcessor处理器
  1625. type UpstreamSupplyOilQualityApiProcessor struct{}
  1626. var rzdApiFlag string
  1627. func (p *UpstreamSupplyOilQualityApiProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1628. logs.Info("Processing UpstreamSupplyOilQualityApiProcessor...")
  1629. if rowIndex <= 1 {
  1630. return nil, nil
  1631. }
  1632. if rowData[0] != "" {
  1633. rzdApiFlag = rowData[0]
  1634. } else {
  1635. rowData[0] = rzdApiFlag
  1636. }
  1637. frequency := "月度"
  1638. unit := "°"
  1639. indexNameColSuffix := "Oil Quality"
  1640. //indexNameColPrefix := "CountryRevisionGroup"
  1641. if !utils.IsNumeric(rowData[0]) {
  1642. return nil, nil
  1643. }
  1644. if rowData[1] == "Sum" {
  1645. return nil, nil
  1646. }
  1647. // step_1: 分类
  1648. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1649. if err != nil {
  1650. return nil, err
  1651. }
  1652. logs.Info("classifyId: %v", classifyId)
  1653. // step_2: 指标
  1654. // 指标名称
  1655. indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "API"
  1656. // 生成指标编码
  1657. indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("API"), "")
  1658. var indexInfoList []*models.IndexInfo
  1659. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1660. if err != nil {
  1661. return nil, err
  1662. }
  1663. dataTime := rowData[0]
  1664. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1665. if err != nil {
  1666. return nil, err
  1667. }
  1668. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1669. IndexName: indexName,
  1670. IndexCode: indexCode,
  1671. Value: value,
  1672. DataTime: format,
  1673. })
  1674. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1675. if err != nil {
  1676. return nil, err
  1677. }
  1678. logs.Info("UpstreamSupplyOilQualityApiProcessor indexInfoList: %v", indexInfoList)
  1679. // step_3: 指标数据
  1680. dataList, err := dealData(indexInfoList)
  1681. if err != nil {
  1682. return nil, err
  1683. }
  1684. logs.Info("UpstreamSupplyOilQualityApiProcessor dataList: %v", dataList)
  1685. return dataList, err
  1686. }
  1687. // OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor
  1688. // @Description: OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor处理器
  1689. type OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor struct{}
  1690. var rzdSulphurFlag string
  1691. func (p *OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1692. logs.Info("Processing OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor...")
  1693. if rowIndex <= 1 {
  1694. return nil, nil
  1695. }
  1696. if rowData[0] != "" {
  1697. rzdSulphurFlag = rowData[0]
  1698. } else {
  1699. rowData[0] = rzdSulphurFlag
  1700. }
  1701. frequency := "月度"
  1702. unit := "%wt"
  1703. indexNameColSuffix := "Oil Quality"
  1704. //indexNameColPrefix := "CountryRevisionGroup"
  1705. if !utils.IsNumeric(rowData[0]) {
  1706. return nil, nil
  1707. }
  1708. if rowData[1] == "Sum" {
  1709. return nil, nil
  1710. }
  1711. // step_1: 分类
  1712. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1713. if err != nil {
  1714. return nil, err
  1715. }
  1716. logs.Info("classifyId: %v", classifyId)
  1717. // step_2: 指标
  1718. // 指标名称
  1719. indexName := "Upstream Supply" + "/" + indexNameColSuffix + "/" + "Sulphur"
  1720. // 生成指标编码
  1721. indexCode, err := getIndexId("Upstream Supply "+indexNameColSuffix, strings.ToLower("Sulphur"), "")
  1722. var indexInfoList []*models.IndexInfo
  1723. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1724. if err != nil {
  1725. return nil, err
  1726. }
  1727. dataTime := rowData[0]
  1728. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1729. if err != nil {
  1730. return nil, err
  1731. }
  1732. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1733. IndexName: indexName,
  1734. IndexCode: indexCode,
  1735. Value: value,
  1736. DataTime: format,
  1737. })
  1738. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1739. if err != nil {
  1740. return nil, err
  1741. }
  1742. logs.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor indexInfoList: %v", indexInfoList)
  1743. // step_3: 指标数据
  1744. dataList, err := dealData(indexInfoList)
  1745. if err != nil {
  1746. return nil, err
  1747. }
  1748. logs.Info("OilMarketCubeUpstreamSupplyOilQualitySulphurProcessor dataList: %v", dataList)
  1749. return dataList, err
  1750. }
  1751. // OilMarketCubeUpstreamSupplyCapacityCapacityProcessor
  1752. // @Description: OilMarketCubeUpstreamSupplyCapacityCapacityProcessor处理器
  1753. type OilMarketCubeUpstreamSupplyCapacityCapacityProcessor struct{}
  1754. var rzdCapacityFlag string
  1755. func (p *OilMarketCubeUpstreamSupplyCapacityCapacityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1756. logs.Info("Processing OilMarketCubeUpstreamSupplyCapacityCapacityProcessor...")
  1757. if rowIndex <= 1 {
  1758. return nil, nil
  1759. }
  1760. if rowData[0] != "" {
  1761. rzdCapacityFlag = rowData[0]
  1762. } else {
  1763. rowData[0] = rzdCapacityFlag
  1764. }
  1765. frequency := "月度"
  1766. unit := "kbbl/d"
  1767. indexNameColSuffix := "Capacity"
  1768. //indexNameColPrefix := "CountryRevisionGroup"
  1769. if !utils.IsNumeric(rowData[0]) {
  1770. return nil, nil
  1771. }
  1772. if rowData[1] == "Sum" {
  1773. return nil, nil
  1774. }
  1775. // step_1: 分类
  1776. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1777. if err != nil {
  1778. return nil, err
  1779. }
  1780. logs.Info("classifyId: %v", classifyId)
  1781. // step_2: 指标
  1782. // 指标名称
  1783. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1784. // 生成指标编码
  1785. indexCode, err := getIndexId("Upstream Supply ", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1786. var indexInfoList []*models.IndexInfo
  1787. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1788. if err != nil {
  1789. return nil, err
  1790. }
  1791. dataTime := rowData[0]
  1792. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1793. if err != nil {
  1794. return nil, err
  1795. }
  1796. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1797. IndexName: indexName,
  1798. IndexCode: indexCode,
  1799. Value: value,
  1800. DataTime: format,
  1801. })
  1802. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1803. if err != nil {
  1804. return nil, err
  1805. }
  1806. logs.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor indexInfoList: %v", indexInfoList)
  1807. // step_3: 指标数据
  1808. dataList, err := dealData(indexInfoList)
  1809. if err != nil {
  1810. return nil, err
  1811. }
  1812. logs.Info("OilMarketCubeUpstreamSupplyCapacityCapacityProcessor dataList: %v", dataList)
  1813. return dataList, err
  1814. }
  1815. // OilMarketCubeUpstreamSupplyProductionProcessor
  1816. // @Description: OilMarketCubeUpstreamSupplyProductionProcessor处理器
  1817. type OilMarketCubeUpstreamSupplyProductionProcessor struct{}
  1818. var rzdProductionFlag string
  1819. func (p *OilMarketCubeUpstreamSupplyProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1820. logs.Info("Processing OilMarketCubeUpstreamSupplyProductionProcessor...")
  1821. if rowIndex <= 1 {
  1822. return nil, nil
  1823. }
  1824. if rowData[0] != "" {
  1825. rzdProductionFlag = rowData[0]
  1826. } else {
  1827. rowData[0] = rzdProductionFlag
  1828. }
  1829. frequency := "月度"
  1830. unit := "kbbl/d"
  1831. indexNameColSuffix := "Production"
  1832. //indexNameColPrefix := "CountryRevisionGroup"
  1833. if !utils.IsNumeric(rowData[0]) {
  1834. return nil, nil
  1835. }
  1836. if rowData[1] == "Sum" {
  1837. return nil, nil
  1838. }
  1839. // step_1: 分类
  1840. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1841. if err != nil {
  1842. return nil, err
  1843. }
  1844. logs.Info("classifyId: %v", classifyId)
  1845. // step_2: 指标
  1846. // 指标名称
  1847. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1848. // 生成指标编码
  1849. indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1850. var indexInfoList []*models.IndexInfo
  1851. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1852. if err != nil {
  1853. return nil, err
  1854. }
  1855. dataTime := rowData[0]
  1856. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1857. if err != nil {
  1858. return nil, err
  1859. }
  1860. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1861. IndexName: indexName,
  1862. IndexCode: indexCode,
  1863. Value: value,
  1864. DataTime: format,
  1865. })
  1866. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1867. if err != nil {
  1868. return nil, err
  1869. }
  1870. logs.Info("OilMarketCubeUpstreamSupplyProductionProcessor indexInfoList: %v", indexInfoList)
  1871. // step_3: 指标数据
  1872. dataList, err := dealData(indexInfoList)
  1873. if err != nil {
  1874. return nil, err
  1875. }
  1876. logs.Info("OilMarketCubeUpstreamSupplyProductionProcessor dataList: %v", dataList)
  1877. return dataList, err
  1878. }
  1879. // UpstreamSupplyProductionWoSeasonalityProcessor
  1880. // @Description: UpstreamSupplyProductionWoSeasonalityProcessor处理器
  1881. type UpstreamSupplyProductionWoSeasonalityProcessor struct{}
  1882. var rzdProductionWoSeasonalityFlag string
  1883. func (p *UpstreamSupplyProductionWoSeasonalityProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1884. logs.Info("Processing UpstreamSupplyProductionWoSeasonalityProcessor...")
  1885. if rowIndex <= 1 {
  1886. return nil, nil
  1887. }
  1888. if rowData[0] != "" {
  1889. rzdProductionWoSeasonalityFlag = rowData[0]
  1890. } else {
  1891. rowData[0] = rzdProductionWoSeasonalityFlag
  1892. }
  1893. frequency := "月度"
  1894. unit := "kbbl/d"
  1895. indexNameColSuffix := "Production Wo Seasonality"
  1896. //indexNameColPrefix := "CountryRevisionGroup"
  1897. if !utils.IsNumeric(rowData[0]) {
  1898. return nil, nil
  1899. }
  1900. if rowData[1] == "Sum" {
  1901. return nil, nil
  1902. }
  1903. // step_1: 分类
  1904. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1905. if err != nil {
  1906. return nil, err
  1907. }
  1908. logs.Info("classifyId: %v", classifyId)
  1909. // step_2: 指标
  1910. // 指标名称
  1911. indexName := "Upstream Supply" + "/" + indexNameColSuffix
  1912. // 生成指标编码
  1913. indexCode, err := getIndexId("Upstream Supply", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1914. var indexInfoList []*models.IndexInfo
  1915. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1916. if err != nil {
  1917. return nil, err
  1918. }
  1919. dataTime := rowData[0]
  1920. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1921. if err != nil {
  1922. return nil, err
  1923. }
  1924. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1925. IndexName: indexName,
  1926. IndexCode: indexCode,
  1927. Value: value,
  1928. DataTime: format,
  1929. })
  1930. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1931. if err != nil {
  1932. return nil, err
  1933. }
  1934. logs.Info("UpstreamSupplyProductionWoSeasonalityProcessor indexInfoList: %v", indexInfoList)
  1935. // step_3: 指标数据
  1936. dataList, err := dealData(indexInfoList)
  1937. if err != nil {
  1938. return nil, err
  1939. }
  1940. logs.Info("UpstreamSupplyProductionWoSeasonalityProcessor dataList: %v", dataList)
  1941. return dataList, err
  1942. }
  1943. // UpstreamSupplyOPECPolicyReferenceProductionProcessor
  1944. // @Description: UpstreamSupplyOPECPolicyReferenceProductionProcessor处理器
  1945. type UpstreamSupplyOPECPolicyReferenceProductionProcessor struct{}
  1946. var rzdReferenceProductionFlag string
  1947. func (p *UpstreamSupplyOPECPolicyReferenceProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  1948. logs.Info("Processing UpstreamSupplyOPECPolicyReferenceProductionProcessor...")
  1949. if rowIndex <= 1 {
  1950. return nil, nil
  1951. }
  1952. if rowData[0] != "" {
  1953. rzdReferenceProductionFlag = rowData[0]
  1954. } else {
  1955. rowData[0] = rzdReferenceProductionFlag
  1956. }
  1957. frequency := "月度"
  1958. unit := "kbbl/d"
  1959. indexNameColPrefix := "OPEC_Policy"
  1960. indexNameColSuffix := "Reference Production"
  1961. if !utils.IsNumeric(rowData[0]) {
  1962. return nil, nil
  1963. }
  1964. if rowData[1] == "Sum" {
  1965. return nil, nil
  1966. }
  1967. // step_1: 分类
  1968. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  1969. if err != nil {
  1970. return nil, err
  1971. }
  1972. logs.Info("classifyId: %v", classifyId)
  1973. // step_2: 指标
  1974. // 指标名称
  1975. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  1976. // 生成指标编码
  1977. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  1978. var indexInfoList []*models.IndexInfo
  1979. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  1980. if err != nil {
  1981. return nil, err
  1982. }
  1983. dataTime := rowData[0]
  1984. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  1985. if err != nil {
  1986. return nil, err
  1987. }
  1988. indexInfoList = append(indexInfoList, &models.IndexInfo{
  1989. IndexName: indexName,
  1990. IndexCode: indexCode,
  1991. Value: value,
  1992. DataTime: format,
  1993. })
  1994. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  1995. if err != nil {
  1996. return nil, err
  1997. }
  1998. logs.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor indexInfoList: %v", indexInfoList)
  1999. // step_3: 指标数据
  2000. dataList, err := dealData(indexInfoList)
  2001. if err != nil {
  2002. return nil, err
  2003. }
  2004. logs.Info("UpstreamSupplyOPECPolicyReferenceProductionProcessor dataList: %v", dataList)
  2005. return dataList, err
  2006. }
  2007. // UpstreamSupplyOPECPolicyTargetProductionProcessor
  2008. // @Description: UpstreamSupplyOPECPolicyTargetProductionProcessor处理器
  2009. type UpstreamSupplyOPECPolicyTargetProductionProcessor struct{}
  2010. var rzdTargetProductionFlag string
  2011. func (p *UpstreamSupplyOPECPolicyTargetProductionProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2012. logs.Info("Processing UpstreamSupplyOPECPolicyTargetProductionProcessor...")
  2013. if rowIndex <= 1 {
  2014. return nil, nil
  2015. }
  2016. if rowData[0] != "" {
  2017. rzdTargetProductionFlag = rowData[0]
  2018. } else {
  2019. rowData[0] = rzdTargetProductionFlag
  2020. }
  2021. frequency := "月度"
  2022. unit := "kbbl/d"
  2023. indexNameColPrefix := "OPEC_Policy"
  2024. indexNameColSuffix := "Target Production"
  2025. if !utils.IsNumeric(rowData[0]) {
  2026. return nil, nil
  2027. }
  2028. if rowData[1] == "Sum" {
  2029. return nil, nil
  2030. }
  2031. // step_1: 分类
  2032. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2033. if err != nil {
  2034. return nil, err
  2035. }
  2036. logs.Info("classifyId: %v", classifyId)
  2037. // step_2: 指标
  2038. // 指标名称
  2039. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2040. // 生成指标编码
  2041. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2042. var indexInfoList []*models.IndexInfo
  2043. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2044. if err != nil {
  2045. return nil, err
  2046. }
  2047. dataTime := rowData[0]
  2048. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2049. if err != nil {
  2050. return nil, err
  2051. }
  2052. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2053. IndexName: indexName,
  2054. IndexCode: indexCode,
  2055. Value: value,
  2056. DataTime: format,
  2057. })
  2058. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2059. if err != nil {
  2060. return nil, err
  2061. }
  2062. logs.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor indexInfoList: %v", indexInfoList)
  2063. // step_3: 指标数据
  2064. dataList, err := dealData(indexInfoList)
  2065. if err != nil {
  2066. return nil, err
  2067. }
  2068. logs.Info("UpstreamSupplyOPECPolicyTargetProductionProcessor dataList: %v", dataList)
  2069. return dataList, err
  2070. }
  2071. // UpstreamSupplyOPECPolicyTargetCutProcessor
  2072. // @Description: UpstreamSupplyOPECPolicyTargetCutProcessor处理器
  2073. type UpstreamSupplyOPECPolicyTargetCutProcessor struct{}
  2074. var rzdTargetCutFlag string
  2075. func (p *UpstreamSupplyOPECPolicyTargetCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2076. logs.Info("Processing UpstreamSupplyOPECPolicyTargetCutProcessor...")
  2077. if rowIndex <= 1 {
  2078. return nil, nil
  2079. }
  2080. if rowData[0] != "" {
  2081. rzdTargetCutFlag = rowData[0]
  2082. } else {
  2083. rowData[0] = rzdTargetCutFlag
  2084. }
  2085. frequency := "月度"
  2086. unit := "kbbl/d"
  2087. indexNameColPrefix := "OPEC_Policy"
  2088. indexNameColSuffix := "Target Cut"
  2089. if !utils.IsNumeric(rowData[0]) {
  2090. return nil, nil
  2091. }
  2092. if rowData[1] == "Sum" {
  2093. return nil, nil
  2094. }
  2095. // step_1: 分类
  2096. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2097. if err != nil {
  2098. return nil, err
  2099. }
  2100. logs.Info("classifyId: %v", classifyId)
  2101. // step_2: 指标
  2102. // 指标名称
  2103. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2104. // 生成指标编码
  2105. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2106. var indexInfoList []*models.IndexInfo
  2107. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2108. if err != nil {
  2109. return nil, err
  2110. }
  2111. dataTime := rowData[0]
  2112. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2113. if err != nil {
  2114. return nil, err
  2115. }
  2116. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2117. IndexName: indexName,
  2118. IndexCode: indexCode,
  2119. Value: value,
  2120. DataTime: format,
  2121. })
  2122. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2123. if err != nil {
  2124. return nil, err
  2125. }
  2126. logs.Info("UpstreamSupplyOPECPolicyTargetCutProcessor indexInfoList: %v", indexInfoList)
  2127. // step_3: 指标数据
  2128. dataList, err := dealData(indexInfoList)
  2129. if err != nil {
  2130. return nil, err
  2131. }
  2132. logs.Info("UpstreamSupplyOPECPolicyTargetCutProcessor dataList: %v", dataList)
  2133. return dataList, err
  2134. }
  2135. // UpstreamSupplyOPECPolicyActualCutProcessor
  2136. // @Description: UpstreamSupplyOPECPolicyActualCutProcessor处理器
  2137. type UpstreamSupplyOPECPolicyActualCutProcessor struct{}
  2138. var rzdActualCutFlag string
  2139. func (p *UpstreamSupplyOPECPolicyActualCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2140. logs.Info("Processing UpstreamSupplyOPECPolicyActualCutProcessor...")
  2141. if rowIndex <= 1 {
  2142. return nil, nil
  2143. }
  2144. if rowData[0] != "" {
  2145. rzdActualCutFlag = rowData[0]
  2146. } else {
  2147. rowData[0] = rzdActualCutFlag
  2148. }
  2149. frequency := "月度"
  2150. unit := "kbbl/d"
  2151. indexNameColPrefix := "OPEC_Policy"
  2152. indexNameColSuffix := "Actual Cut"
  2153. if !utils.IsNumeric(rowData[0]) {
  2154. return nil, nil
  2155. }
  2156. if rowData[1] == "Sum" {
  2157. return nil, nil
  2158. }
  2159. // step_1: 分类
  2160. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2161. if err != nil {
  2162. return nil, err
  2163. }
  2164. logs.Info("classifyId: %v", classifyId)
  2165. // step_2: 指标
  2166. // 指标名称
  2167. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2168. // 生成指标编码
  2169. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2170. var indexInfoList []*models.IndexInfo
  2171. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2172. if err != nil {
  2173. return nil, err
  2174. }
  2175. dataTime := rowData[0]
  2176. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2177. if err != nil {
  2178. return nil, err
  2179. }
  2180. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2181. IndexName: indexName,
  2182. IndexCode: indexCode,
  2183. Value: value,
  2184. DataTime: format,
  2185. })
  2186. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2187. if err != nil {
  2188. return nil, err
  2189. }
  2190. logs.Info("UpstreamSupplyOPECPolicyActualCutProcessor indexInfoList: %v", indexInfoList)
  2191. // step_3: 指标数据
  2192. dataList, err := dealData(indexInfoList)
  2193. if err != nil {
  2194. return nil, err
  2195. }
  2196. logs.Info("UpstreamSupplyOPECPolicyActualCutProcessor dataList: %v", dataList)
  2197. return dataList, err
  2198. }
  2199. // UpstreamSupplyOPECPolicyComplianceProcessor
  2200. // @Description: UpstreamSupplyOPECPolicyComplianceProcessor处理器
  2201. type UpstreamSupplyOPECPolicyComplianceProcessor struct{}
  2202. var rzdComplianceFlag string
  2203. func (p *UpstreamSupplyOPECPolicyComplianceProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2204. logs.Info("Processing UpstreamSupplyOPECPolicyComplianceProcessor...")
  2205. if rowIndex <= 1 {
  2206. return nil, nil
  2207. }
  2208. if rowData[0] != "" {
  2209. rzdComplianceFlag = rowData[0]
  2210. } else {
  2211. rowData[0] = rzdComplianceFlag
  2212. }
  2213. frequency := "月度"
  2214. unit := "kbbl/d"
  2215. indexNameColPrefix := "OPEC_Policy"
  2216. indexNameColSuffix := "Compliance"
  2217. if !utils.IsNumeric(rowData[0]) {
  2218. return nil, nil
  2219. }
  2220. if rowData[1] == "Sum" {
  2221. return nil, nil
  2222. }
  2223. // step_1: 分类
  2224. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2225. if err != nil {
  2226. return nil, err
  2227. }
  2228. logs.Info("classifyId: %v", classifyId)
  2229. // step_2: 指标
  2230. // 指标名称
  2231. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2232. // 生成指标编码
  2233. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2234. var indexInfoList []*models.IndexInfo
  2235. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2236. if err != nil {
  2237. return nil, err
  2238. }
  2239. dataTime := rowData[0]
  2240. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2241. if err != nil {
  2242. return nil, err
  2243. }
  2244. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2245. IndexName: indexName,
  2246. IndexCode: indexCode,
  2247. Value: value,
  2248. DataTime: format,
  2249. })
  2250. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2251. if err != nil {
  2252. return nil, err
  2253. }
  2254. logs.Info("UpstreamSupplyOPECPolicyComplianceProcessor indexInfoList: %v", indexInfoList)
  2255. // step_3: 指标数据
  2256. dataList, err := dealData(indexInfoList)
  2257. if err != nil {
  2258. return nil, err
  2259. }
  2260. logs.Info("UpstreamSupplyOPECPolicyComplianceProcessor dataList: %v", dataList)
  2261. return dataList, err
  2262. }
  2263. // UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor
  2264. // @Description: UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor处理器
  2265. type UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor struct{}
  2266. var rzdProductionSubjectToCutFlag string
  2267. func (p *UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2268. logs.Info("Processing UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor...")
  2269. if rowIndex <= 1 {
  2270. return nil, nil
  2271. }
  2272. if rowData[0] != "" {
  2273. rzdProductionSubjectToCutFlag = rowData[0]
  2274. } else {
  2275. rowData[0] = rzdProductionSubjectToCutFlag
  2276. }
  2277. frequency := "月度"
  2278. unit := "kbbl/d"
  2279. indexNameColPrefix := "OPEC_Policy"
  2280. indexNameColSuffix := "Production Subject To Cut"
  2281. if !utils.IsNumeric(rowData[0]) {
  2282. return nil, nil
  2283. }
  2284. if rowData[1] == "Sum" {
  2285. return nil, nil
  2286. }
  2287. // step_1: 分类
  2288. classifyId, err := dealClassify("Oil Market Cube", "Upstream Supply")
  2289. if err != nil {
  2290. return nil, err
  2291. }
  2292. logs.Info("classifyId: %v", classifyId)
  2293. // step_2: 指标
  2294. // 指标名称
  2295. indexName := "Upstream Supply" + "/" + indexNameColPrefix + "/" + indexNameColSuffix
  2296. // 生成指标编码
  2297. indexCode, err := getIndexId("Upstream Supply "+indexNameColPrefix, strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2298. var indexInfoList []*models.IndexInfo
  2299. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2300. if err != nil {
  2301. return nil, err
  2302. }
  2303. dataTime := rowData[0]
  2304. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2305. if err != nil {
  2306. return nil, err
  2307. }
  2308. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2309. IndexName: indexName,
  2310. IndexCode: indexCode,
  2311. Value: value,
  2312. DataTime: format,
  2313. })
  2314. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2315. if err != nil {
  2316. return nil, err
  2317. }
  2318. logs.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor indexInfoList: %v", indexInfoList)
  2319. // step_3: 指标数据
  2320. dataList, err := dealData(indexInfoList)
  2321. if err != nil {
  2322. return nil, err
  2323. }
  2324. logs.Info("UpstreamSupplyOPECPolicyProductionSubjectToCutProcessor dataList: %v", dataList)
  2325. return dataList, err
  2326. }
  2327. // ProductsDemandProductsDemandMeanProcessor
  2328. // @Description: ProductsDemandProductsDemandMeanProcessor处理器
  2329. type ProductsDemandProductsDemandMeanProcessor struct{}
  2330. var rzdProductsDemandMeanFlag string
  2331. func (p *ProductsDemandProductsDemandMeanProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2332. logs.Info("Processing ProductsDemandProductsDemandMeanProcessor...")
  2333. if rowIndex <= 1 {
  2334. return nil, nil
  2335. }
  2336. if rowData[0] != "" {
  2337. rzdProductsDemandMeanFlag = rowData[0]
  2338. } else {
  2339. rowData[0] = rzdProductsDemandMeanFlag
  2340. }
  2341. frequency := "月度"
  2342. unit := "kbbl/d"
  2343. //indexNameColPrefix := "OPEC_Policy"
  2344. indexNameColSuffix := "Products Demand Mean (1.0 DG) "
  2345. if !utils.IsNumeric(rowData[0]) {
  2346. return nil, nil
  2347. }
  2348. if rowData[1] == "Sum" {
  2349. return nil, nil
  2350. }
  2351. // step_1: 分类
  2352. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2353. if err != nil {
  2354. return nil, err
  2355. }
  2356. logs.Info("classifyId: %v", classifyId)
  2357. // step_2: 指标
  2358. // 指标名称
  2359. indexName := "Products Demand" + "/" + indexNameColSuffix
  2360. // 生成指标编码
  2361. indexCode, err := getIndexId("Products Demand "+"Products Demand Mean", strings.ReplaceAll(strings.ToLower("1.0dg"), " ", ""), "")
  2362. var indexInfoList []*models.IndexInfo
  2363. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2364. if err != nil {
  2365. return nil, err
  2366. }
  2367. dataTime := rowData[0]
  2368. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2369. if err != nil {
  2370. return nil, err
  2371. }
  2372. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2373. IndexName: indexName,
  2374. IndexCode: indexCode,
  2375. Value: value,
  2376. DataTime: format,
  2377. })
  2378. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2379. if err != nil {
  2380. return nil, err
  2381. }
  2382. logs.Info("ProductsDemandProductsDemandMeanProcessor indexInfoList: %v", indexInfoList)
  2383. // step_3: 指标数据
  2384. dataList, err := dealData(indexInfoList)
  2385. if err != nil {
  2386. return nil, err
  2387. }
  2388. logs.Info("ProductsDemandProductsDemandMeanProcessor dataList: %v", dataList)
  2389. return dataList, err
  2390. }
  2391. // ProductsDemandProductsDemandAddSigmaProcessor
  2392. // @Description: ProductsDemandProductsDemandAddSigmaProcessor处理器
  2393. type ProductsDemandProductsDemandAddSigmaProcessor struct{}
  2394. var rzdAddSigmaFlag string
  2395. func (p *ProductsDemandProductsDemandAddSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2396. logs.Info("Processing ProductsDemandProductsDemandAddSigmaProcessor...")
  2397. if rowIndex <= 1 {
  2398. return nil, nil
  2399. }
  2400. if rowData[0] != "" {
  2401. rzdAddSigmaFlag = rowData[0]
  2402. } else {
  2403. rowData[0] = rzdAddSigmaFlag
  2404. }
  2405. frequency := "月度"
  2406. unit := "kbbl/d"
  2407. //indexNameColPrefix := "OPEC_Policy"
  2408. indexNameColSuffix := "Products Demand +Sigma (2.2 DG) "
  2409. if !utils.IsNumeric(rowData[0]) {
  2410. return nil, nil
  2411. }
  2412. if rowData[1] == "Sum" {
  2413. return nil, nil
  2414. }
  2415. // step_1: 分类
  2416. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2417. if err != nil {
  2418. return nil, err
  2419. }
  2420. logs.Info("classifyId: %v", classifyId)
  2421. // step_2: 指标
  2422. // 指标名称
  2423. indexName := "Products Demand" + "/" + indexNameColSuffix
  2424. // 生成指标编码
  2425. indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("2.2dg"), " ", ""), "")
  2426. var indexInfoList []*models.IndexInfo
  2427. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2428. if err != nil {
  2429. return nil, err
  2430. }
  2431. dataTime := rowData[0]
  2432. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2433. if err != nil {
  2434. return nil, err
  2435. }
  2436. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2437. IndexName: indexName,
  2438. IndexCode: indexCode,
  2439. Value: value,
  2440. DataTime: format,
  2441. })
  2442. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2443. if err != nil {
  2444. return nil, err
  2445. }
  2446. logs.Info("ProductsDemandProductsDemandAddSigmaProcessor indexInfoList: %v", indexInfoList)
  2447. // step_3: 指标数据
  2448. dataList, err := dealData(indexInfoList)
  2449. if err != nil {
  2450. return nil, err
  2451. }
  2452. logs.Info("ProductsDemandProductsDemandAddSigmaProcessor dataList: %v", dataList)
  2453. return dataList, err
  2454. }
  2455. // ProductsDemandProductsDemandSubSigmaProcessor
  2456. // @Description: ProductsDemandProductsDemandSubSigmaProcessor处理器
  2457. type ProductsDemandProductsDemandSubSigmaProcessor struct{}
  2458. var rzdSubSigmaFlag string
  2459. func (p *ProductsDemandProductsDemandSubSigmaProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2460. logs.Info("Processing ProductsDemandProductsDemandSubSigmaProcessor...")
  2461. if rowIndex <= 1 {
  2462. return nil, nil
  2463. }
  2464. if rowData[0] != "" {
  2465. rzdSubSigmaFlag = rowData[0]
  2466. } else {
  2467. rowData[0] = rzdSubSigmaFlag
  2468. }
  2469. frequency := "月度"
  2470. unit := "kbbl/d"
  2471. //indexNameColPrefix := "OPEC_Policy"
  2472. indexNameColSuffix := "Products Demand -Sigma (1.8 DG) "
  2473. if !utils.IsNumeric(rowData[0]) {
  2474. return nil, nil
  2475. }
  2476. if rowData[1] == "Sum" {
  2477. return nil, nil
  2478. }
  2479. // step_1: 分类
  2480. classifyId, err := dealClassify("Oil Market Cube", "Products Demand")
  2481. if err != nil {
  2482. return nil, err
  2483. }
  2484. logs.Info("classifyId: %v", classifyId)
  2485. // step_2: 指标
  2486. // 指标名称
  2487. indexName := "Products Demand" + "/" + indexNameColSuffix
  2488. // 生成指标编码
  2489. indexCode, err := getIndexId("Products Demand "+"Products Demand Sigma", strings.ReplaceAll(strings.ToLower("1.8dg"), " ", ""), "")
  2490. var indexInfoList []*models.IndexInfo
  2491. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2492. if err != nil {
  2493. return nil, err
  2494. }
  2495. dataTime := rowData[0]
  2496. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2497. if err != nil {
  2498. return nil, err
  2499. }
  2500. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2501. IndexName: indexName,
  2502. IndexCode: indexCode,
  2503. Value: value,
  2504. DataTime: format,
  2505. })
  2506. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2507. if err != nil {
  2508. return nil, err
  2509. }
  2510. logs.Info("ProductsDemandProductsDemandSubSigmaProcessor indexInfoList: %v", indexInfoList)
  2511. // step_3: 指标数据
  2512. dataList, err := dealData(indexInfoList)
  2513. if err != nil {
  2514. return nil, err
  2515. }
  2516. logs.Info("ProductsDemandProductsDemandSubSigmaProcessor dataList: %v", dataList)
  2517. return dataList, err
  2518. }
  2519. // BalancesTotalLiquidsBalancesProcessor
  2520. // @Description: BalancesTotalLiquidsBalancesProcessor处理器
  2521. type BalancesTotalLiquidsBalancesProcessor struct{}
  2522. var rzdTotalLiquidsBalancesFlag string
  2523. func (p *BalancesTotalLiquidsBalancesProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2524. logs.Info("Processing BalancesTotalLiquidsBalancesProcessor...")
  2525. if rowIndex <= 1 {
  2526. return nil, nil
  2527. }
  2528. if rowData[0] != "" {
  2529. rzdTotalLiquidsBalancesFlag = rowData[0]
  2530. } else {
  2531. rowData[0] = rzdTotalLiquidsBalancesFlag
  2532. }
  2533. frequency := "月度"
  2534. unit := "kbbl/d"
  2535. //indexNameColPrefix := "OPEC_Policy"
  2536. indexNameColSuffix := "Total Liquids Balances"
  2537. if !utils.IsNumeric(rowData[0]) {
  2538. return nil, nil
  2539. }
  2540. if rowData[1] == "Sum" {
  2541. return nil, nil
  2542. }
  2543. // step_1: 分类
  2544. classifyId, err := dealClassify("Oil Market Cube", "Balances")
  2545. if err != nil {
  2546. return nil, err
  2547. }
  2548. logs.Info("classifyId: %v", classifyId)
  2549. // step_2: 指标
  2550. // 指标名称
  2551. indexName := "Balances" + "/" + indexNameColSuffix
  2552. // 生成指标编码
  2553. indexCode, err := getIndexId("Balances", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2554. var indexInfoList []*models.IndexInfo
  2555. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2556. if err != nil {
  2557. return nil, err
  2558. }
  2559. dataTime := rowData[0]
  2560. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2561. if err != nil {
  2562. return nil, err
  2563. }
  2564. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2565. IndexName: indexName,
  2566. IndexCode: indexCode,
  2567. Value: value,
  2568. DataTime: format,
  2569. })
  2570. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2571. if err != nil {
  2572. return nil, err
  2573. }
  2574. logs.Info("BalancesTotalLiquidsBalancesProcessor indexInfoList: %v", indexInfoList)
  2575. // step_3: 指标数据
  2576. dataList, err := dealData(indexInfoList)
  2577. if err != nil {
  2578. return nil, err
  2579. }
  2580. logs.Info("BalancesTotalLiquidsBalancesProcessor dataList: %v", dataList)
  2581. return dataList, err
  2582. }
  2583. // GeographyLatitudeProcessor
  2584. // @Description: GeographyLatitudeProcessor处理器
  2585. type GeographyLatitudeProcessor struct{}
  2586. var rzdLatitudeFlag string
  2587. func (p *GeographyLatitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2588. logs.Info("Processing GeographyLatitudeProcessor...")
  2589. if rowIndex <= 1 {
  2590. return nil, nil
  2591. }
  2592. if rowData[0] != "" {
  2593. rzdLatitudeFlag = rowData[0]
  2594. } else {
  2595. rowData[0] = rzdLatitudeFlag
  2596. }
  2597. frequency := "月度"
  2598. unit := ""
  2599. //indexNameColPrefix := "OPEC_Policy"
  2600. indexNameColSuffix := "Latitude"
  2601. if !utils.IsNumeric(rowData[0]) {
  2602. return nil, nil
  2603. }
  2604. if rowData[1] == "Sum" {
  2605. return nil, nil
  2606. }
  2607. // step_1: 分类
  2608. classifyId, err := dealClassify("Oil Market Cube", "Geography")
  2609. if err != nil {
  2610. return nil, err
  2611. }
  2612. logs.Info("classifyId: %v", classifyId)
  2613. // step_2: 指标
  2614. // 指标名称
  2615. indexName := "Geography" + "/" + indexNameColSuffix
  2616. // 生成指标编码
  2617. indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2618. var indexInfoList []*models.IndexInfo
  2619. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2620. if err != nil {
  2621. return nil, err
  2622. }
  2623. dataTime := rowData[0]
  2624. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2625. if err != nil {
  2626. return nil, err
  2627. }
  2628. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2629. IndexName: indexName,
  2630. IndexCode: indexCode,
  2631. Value: value,
  2632. DataTime: format,
  2633. })
  2634. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2635. if err != nil {
  2636. return nil, err
  2637. }
  2638. logs.Info("GeographyLatitudeProcessor indexInfoList: %v", indexInfoList)
  2639. // step_3: 指标数据
  2640. dataList, err := dealData(indexInfoList)
  2641. if err != nil {
  2642. return nil, err
  2643. }
  2644. logs.Info("GeographyLatitudeProcessor dataList: %v", dataList)
  2645. return dataList, err
  2646. }
  2647. // GeographyLongitudeProcessor
  2648. // @Description: GeographyLongitudeProcessor处理器
  2649. type GeographyLongitudeProcessor struct{}
  2650. var rzdLongitudeFlag string
  2651. func (p *GeographyLongitudeProcessor) Process(tableName string, sheetName string, rowIndex int, rowData []string) ([]models.BaseFromRzdData, error) {
  2652. logs.Info("Processing GeographyLongitudeProcessor...")
  2653. if rowIndex <= 1 {
  2654. return nil, nil
  2655. }
  2656. if rowData[0] != "" {
  2657. rzdLongitudeFlag = rowData[0]
  2658. } else {
  2659. rowData[0] = rzdLongitudeFlag
  2660. }
  2661. frequency := "月度"
  2662. unit := ""
  2663. //indexNameColPrefix := "OPEC_Policy"
  2664. indexNameColSuffix := "Longitude"
  2665. if !utils.IsNumeric(rowData[0]) {
  2666. return nil, nil
  2667. }
  2668. if rowData[1] == "Sum" {
  2669. return nil, nil
  2670. }
  2671. // step_1: 分类
  2672. classifyId, err := dealClassify("Oil Market Cube", "Geography")
  2673. if err != nil {
  2674. return nil, err
  2675. }
  2676. logs.Info("classifyId: %v", classifyId)
  2677. // step_2: 指标
  2678. // 指标名称
  2679. indexName := "Geography" + "/" + indexNameColSuffix
  2680. // 生成指标编码
  2681. indexCode, err := getIndexId("Geography", strings.ReplaceAll(strings.ToLower(indexNameColSuffix), " ", ""), "")
  2682. var indexInfoList []*models.IndexInfo
  2683. value, err := strconv.ParseFloat(rowData[len(rowData)-1], 64)
  2684. if err != nil {
  2685. return nil, err
  2686. }
  2687. dataTime := rowData[0]
  2688. format, err := utils.ConvertDateFormat6(dataTime + "-" + rowData[1])
  2689. if err != nil {
  2690. return nil, err
  2691. }
  2692. indexInfoList = append(indexInfoList, &models.IndexInfo{
  2693. IndexName: indexName,
  2694. IndexCode: indexCode,
  2695. Value: value,
  2696. DataTime: format,
  2697. })
  2698. indexInfoList, err = dealIndex(indexInfoList, frequency, unit, classifyId)
  2699. if err != nil {
  2700. return nil, err
  2701. }
  2702. logs.Info("GeographyLongitudeProcessor indexInfoList: %v", indexInfoList)
  2703. // step_3: 指标数据
  2704. dataList, err := dealData(indexInfoList)
  2705. if err != nil {
  2706. return nil, err
  2707. }
  2708. logs.Info("GeographyLongitudeProcessor dataList: %v", dataList)
  2709. return dataList, err
  2710. }
  2711. func dealData(indexInfoList []*models.IndexInfo) ([]models.BaseFromRzdData, error) {
  2712. var dataList []models.BaseFromRzdData
  2713. for _, indexInfo := range indexInfoList {
  2714. paramsLib := make(map[string]interface{})
  2715. paramsLib["IndexCode"] = indexInfo.IndexCode
  2716. paramsLib["DataTime"] = indexInfo.DataTime
  2717. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_INDEX_DATA_BY_CODE_AND_TIME)
  2718. if err != nil {
  2719. return nil, err
  2720. }
  2721. var requestResponse models.RequestResponse[models.BaseFromRzdData]
  2722. err = json.Unmarshal(postEdbLib, &requestResponse)
  2723. if err != nil {
  2724. return nil, err
  2725. }
  2726. if requestResponse.Data.BaseFromRzdIndexId == 0 {
  2727. dataOne := models.BaseFromRzdData{
  2728. BaseFromRzdIndexId: indexInfo.IndexInfoId,
  2729. CreateTime: utils.GetCurrentTime(),
  2730. DataTime: indexInfo.DataTime,
  2731. IndexCode: indexInfo.IndexCode,
  2732. ModifyTime: utils.GetCurrentTime(),
  2733. Value: math.Round(indexInfo.Value*10000) / 10000,
  2734. }
  2735. dataList = append(dataList, dataOne)
  2736. } else {
  2737. // 编辑
  2738. value := math.Round(indexInfo.Value*10000) / 10000
  2739. if requestResponse.Data.Value != value {
  2740. rzdData := requestResponse.Data
  2741. rzdData.Value = value
  2742. _, err = httpRequestFill(rzdData, utils.UPDATE_RZD_EDB_DATA)
  2743. if err != nil {
  2744. return nil, err
  2745. }
  2746. }
  2747. }
  2748. }
  2749. return dataList, nil
  2750. }
  2751. func dealIndex(indexInfoList []*models.IndexInfo, frequency string, unit string, classifyId int) ([]*models.IndexInfo, error) {
  2752. for _, index := range indexInfoList {
  2753. // 处理第一个指标
  2754. paramsLib := make(map[string]interface{})
  2755. paramsLib["indexCode"] = index.IndexCode
  2756. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_INDEX_BY_CODE)
  2757. if err != nil {
  2758. return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  2759. }
  2760. var requestResponse models.RequestResponse[models.BaseFromRzdIndex]
  2761. err = json.Unmarshal(postEdbLib, &requestResponse)
  2762. if err != nil {
  2763. return nil, err
  2764. }
  2765. if requestResponse.Data.BaseFromRzdIndexId == 0 {
  2766. indexOne := models.BaseFromRzdIndex{
  2767. CreateTime: utils.GetCurrentTime(),
  2768. ModifyTime: utils.GetCurrentTime(),
  2769. BaseFromLyClassifyId: classifyId,
  2770. IndexCode: index.IndexCode,
  2771. IndexName: index.IndexName,
  2772. Frequency: frequency,
  2773. Unit: unit,
  2774. }
  2775. // 这里避免服务器宕机 出现唯一索引异常,进行分开保存
  2776. postEdbLib, err = httpRequestFill(indexOne, utils.ADD_RZD_INDEX)
  2777. if err != nil {
  2778. return nil, fmt.Errorf("getIndexId() : Failed to get rzd index by code: %v", err)
  2779. }
  2780. var requestResponse models.RequestResponse[int]
  2781. err = json.Unmarshal(postEdbLib, &requestResponse)
  2782. if err != nil {
  2783. return nil, err
  2784. }
  2785. logs.Info("indexOneId: %v", requestResponse.Data)
  2786. index.IndexInfoId = requestResponse.Data
  2787. } else {
  2788. logs.Info("indexOneId: %v", requestResponse.Data.BaseFromRzdIndexId)
  2789. index.IndexInfoId = requestResponse.Data.BaseFromRzdIndexId
  2790. }
  2791. }
  2792. return indexInfoList, nil
  2793. }
  2794. func getIndexId(prefix string, area string, suffix string) (string, error) {
  2795. prefixWords := strings.Fields(prefix) // 分割字符串为单词
  2796. firstLetters := ""
  2797. for _, word := range prefixWords {
  2798. if len(word) > 0 {
  2799. firstLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  2800. }
  2801. }
  2802. suffixWords := strings.Fields(suffix) // 分割字符串为单词
  2803. SecondLetters := ""
  2804. for _, word := range suffixWords {
  2805. if len(word) > 0 {
  2806. SecondLetters += string(unicode.ToLower(rune(word[0]))) // 获取小写的第一个字母
  2807. }
  2808. }
  2809. indexCode := "rzd" + firstLetters + area + SecondLetters
  2810. return indexCode, nil
  2811. }
  2812. // 处理分类
  2813. func dealClassify(tableName, sheetName string) (int, error) {
  2814. // 查询一级分类是否存在
  2815. paramsLib := make(map[string]interface{})
  2816. paramsLib["classifyName"] = classifyMap[tableName]
  2817. postEdbLib, err := httpRequestFill(paramsLib, utils.GET_RZD_CLASSIFY_BY_NAME)
  2818. if err != nil {
  2819. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to get classify: %v", err)
  2820. }
  2821. var requestResponse models.RequestResponse[models.BaseFromRzdClassify]
  2822. err = json.Unmarshal(postEdbLib, &requestResponse)
  2823. if err != nil {
  2824. return 0, err
  2825. }
  2826. // 处理一级分类
  2827. var parentId int
  2828. if requestResponse.Data.BaseFromRzdClassifyId == 0 {
  2829. // 一级分类不存在,新增一级分类
  2830. paramsLib = make(map[string]interface{})
  2831. paramsLib["parentId"] = 0
  2832. paramsLib["classifyName"] = classifyMap[tableName]
  2833. postEdbLib, err = httpRequestFill(paramsLib, utils.ADD_RZD_CLASSIFY)
  2834. if err != nil {
  2835. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to add classify: %v", err)
  2836. }
  2837. var requestResponse models.RequestResponse[int]
  2838. err = json.Unmarshal(postEdbLib, &requestResponse)
  2839. if err != nil {
  2840. return 0, err
  2841. }
  2842. parentId = requestResponse.Data
  2843. } else {
  2844. // 一级分类已存在,使用其 ID
  2845. parentId = requestResponse.Data.BaseFromRzdClassifyId
  2846. }
  2847. // 查询二级分类是否存在
  2848. paramsSubLib := make(map[string]interface{})
  2849. paramsSubLib["classifyName"] = sheetName // 这里替换成实际的二级分类名称
  2850. postSubEdbLib, err := httpRequestFill(paramsSubLib, utils.GET_RZD_CLASSIFY_BY_NAME)
  2851. if err != nil {
  2852. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to get sub classify: %v", err)
  2853. }
  2854. var subRequestResponse models.RequestResponse[models.BaseFromRzdClassify]
  2855. err = json.Unmarshal(postSubEdbLib, &subRequestResponse)
  2856. if err != nil {
  2857. return 0, err
  2858. }
  2859. // 新增二级分类
  2860. var classifyId int
  2861. if subRequestResponse.Data.BaseFromRzdClassifyId == 0 {
  2862. paramsLib = make(map[string]interface{})
  2863. paramsLib["parentId"] = parentId
  2864. paramsLib["classifyName"] = sheetName
  2865. postEdbLib, err = httpRequestFill(paramsLib, utils.ADD_RZD_CLASSIFY)
  2866. if err != nil {
  2867. return 0, fmt.Errorf("AnalyticsLibraryProcessor Process() : failed to add classify: %v", err)
  2868. }
  2869. var requestResponse models.RequestResponse[int]
  2870. err = json.Unmarshal(postEdbLib, &requestResponse)
  2871. if err != nil {
  2872. return 0, err
  2873. }
  2874. classifyId = requestResponse.Data
  2875. } else {
  2876. classifyId = subRequestResponse.Data.BaseFromRzdClassifyId
  2877. }
  2878. return classifyId, nil
  2879. }