processor_business_logic.go 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378
  1. // Package fenwei
  2. // @Author gmy 2024/8/20 14:47:00
  3. package fenwei
  4. import (
  5. "encoding/json"
  6. "eta/eta_data_analysis/models"
  7. "eta/eta_data_analysis/utils"
  8. "fmt"
  9. "strings"
  10. )
  11. // ThermalCoalSupplyProcessor 动力煤供应量
  12. type ThermalCoalSupplyProcessor struct {
  13. BaseProcessor
  14. }
  15. func (p *ThermalCoalSupplyProcessor) GenerateRequestParams(currentTime string) map[string]string {
  16. params := models.RequestParams{
  17. Category: nil,
  18. CheckedDims: map[string][]string{
  19. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"},
  20. },
  21. DateRange: "20190820-" + currentTime,
  22. ProductCode: "FW4002D",
  23. QuotaName: "monthly_value,monthly_accumulation",
  24. SplitTypeKey: "province",
  25. IsTotal: 0,
  26. DataType: nil,
  27. IsSeason: 1,
  28. }
  29. // 将结构体转换为 JSON 字符串
  30. paramsJSON, _ := json.Marshal(params)
  31. // 返回为 map[string]string 类型
  32. return map[string]string{
  33. "params": string(paramsJSON),
  34. }
  35. }
  36. func (p *ThermalCoalSupplyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  37. responseData := fillFenWeiNetResponseData(data)
  38. var indexInfoList []models.FenWeiNetIndexInfo
  39. productName := "动力煤供应量"
  40. for _, data := range responseData {
  41. var frequency string
  42. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  43. frequency = "月度"
  44. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  45. frequency = "周度"
  46. } else {
  47. frequency = "日度"
  48. }
  49. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  50. IndexName: productName + data.ProvinceName + "/汾渭",
  51. Unit: data.MonthlyValueChnUnit,
  52. Frequency: frequency,
  53. TerminalCode: utils.TerminalCode,
  54. ClassifyName: productName,
  55. DataTime: data.DataDate,
  56. Value: data.MonthlyValue,
  57. })
  58. }
  59. return indexInfoList, nil
  60. }
  61. // CokingCleanCoalSupplyProcessor 炼焦精煤供应量
  62. type CokingCleanCoalSupplyProcessor struct {
  63. BaseProcessor
  64. }
  65. func (p *CokingCleanCoalSupplyProcessor) GenerateRequestParams(currentTime string) map[string]string {
  66. params := models.RequestParams{
  67. Category: nil,
  68. CheckedDims: map[string][]string{
  69. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"},
  70. "coal_type": {"13", "10", "9", "8", "7", "5", "3"},
  71. },
  72. DateRange: "20190820-" + currentTime,
  73. ProductCode: "FW4001D",
  74. QuotaName: "monthly_value,monthly_accumulation",
  75. SplitTypeKey: "coal_type",
  76. IsTotal: 0,
  77. DataType: nil,
  78. IsSeason: 1,
  79. }
  80. // 将结构体转换为 JSON 字符串
  81. paramsJSON, _ := json.Marshal(params)
  82. // 返回为 map[string]string 类型
  83. return map[string]string{
  84. "params": string(paramsJSON),
  85. }
  86. }
  87. func (p *CokingCleanCoalSupplyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  88. responseData := fillFenWeiNetResponseData(data)
  89. var indexInfoList []models.FenWeiNetIndexInfo
  90. productName := "炼焦精煤供应量"
  91. for _, data := range responseData {
  92. var frequency string
  93. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  94. frequency = "月度"
  95. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  96. frequency = "周度"
  97. } else {
  98. frequency = data.MonthlyValueChnName
  99. }
  100. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  101. IndexName: productName + data.CoalTypeName + "/汾渭",
  102. Unit: data.MonthlyValueChnUnit,
  103. Frequency: frequency,
  104. TerminalCode: utils.TerminalCode,
  105. ClassifyName: productName,
  106. DataTime: data.DataDate,
  107. Value: data.MonthlyValue,
  108. })
  109. }
  110. return indexInfoList, nil
  111. }
  112. // RawCoalProvinceProductionProcessor 原煤分省分煤种产量
  113. type RawCoalProvinceProductionProcessor struct {
  114. BaseProcessor
  115. }
  116. func (p *RawCoalProvinceProductionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  117. params := models.RequestParams{
  118. Category: nil,
  119. CheckedDims: map[string][]string{
  120. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"},
  121. "coal_type": {"14", "6", "40", "21"},
  122. },
  123. DateRange: "20190820-" + currentTime,
  124. ProductCode: "FW3050D",
  125. QuotaName: "monthly_value,monthly_accumulation",
  126. SplitTypeKey: "coal_type",
  127. IsTotal: 0,
  128. DataType: nil,
  129. IsSeason: 1,
  130. }
  131. // 将结构体转换为 JSON 字符串
  132. paramsJSON, _ := json.Marshal(params)
  133. // 返回为 map[string]string 类型
  134. return map[string]string{
  135. "params": string(paramsJSON),
  136. }
  137. }
  138. func (p *RawCoalProvinceProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  139. responseData := fillFenWeiNetResponseData(data)
  140. var indexInfoList []models.FenWeiNetIndexInfo
  141. productName := "原煤分省分煤种产量"
  142. for _, data := range responseData {
  143. var frequency string
  144. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  145. frequency = "月度"
  146. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  147. frequency = "周度"
  148. } else {
  149. frequency = data.MonthlyValueChnName
  150. }
  151. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  152. IndexName: productName + data.CoalTypeName + "/汾渭",
  153. Unit: data.MonthlyValueChnUnit,
  154. Frequency: frequency,
  155. TerminalCode: utils.TerminalCode,
  156. ClassifyName: productName,
  157. DataTime: data.DataDate,
  158. Value: data.MonthlyValue,
  159. })
  160. }
  161. return indexInfoList, nil
  162. }
  163. // StateOwnedKeyCoalMineRawCoalProductionProcessor 国有重点煤矿原煤产量
  164. type StateOwnedKeyCoalMineRawCoalProductionProcessor struct {
  165. BaseProcessor
  166. }
  167. func (p *StateOwnedKeyCoalMineRawCoalProductionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  168. params := models.RequestParams{
  169. Category: nil,
  170. CheckedDims: map[string][]string{
  171. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "2", "27", "28"},
  172. },
  173. DateRange: "20190820-" + currentTime,
  174. ProductCode: "FW3007D",
  175. QuotaName: "monthly_value,monthly_accumulation",
  176. SplitTypeKey: "province",
  177. IsTotal: 0,
  178. DataType: nil,
  179. IsSeason: 1,
  180. }
  181. // 将结构体转换为 JSON 字符串
  182. paramsJSON, _ := json.Marshal(params)
  183. // 返回为 map[string]string 类型
  184. return map[string]string{
  185. "params": string(paramsJSON),
  186. }
  187. }
  188. func (p *StateOwnedKeyCoalMineRawCoalProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  189. responseData := fillFenWeiNetResponseData(data)
  190. var indexInfoList []models.FenWeiNetIndexInfo
  191. productName := "国有重点煤矿原煤产量"
  192. for _, data := range responseData {
  193. var frequency string
  194. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  195. frequency = "月度"
  196. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  197. frequency = "周度"
  198. } else {
  199. frequency = data.MonthlyValueChnName
  200. }
  201. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  202. IndexName: productName + data.ProvinceName + "/汾渭",
  203. Unit: data.MonthlyValueChnUnit,
  204. Frequency: frequency,
  205. TerminalCode: utils.TerminalCode,
  206. ClassifyName: productName,
  207. DataTime: data.DataDate,
  208. Value: data.MonthlyValue,
  209. })
  210. }
  211. return indexInfoList, nil
  212. }
  213. // CokingBituminousCoalProductionProcessor 炼焦烟煤分煤种产量
  214. type CokingBituminousCoalProductionProcessor struct {
  215. BaseProcessor
  216. }
  217. func (p *CokingBituminousCoalProductionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  218. params := models.RequestParams{
  219. Category: nil,
  220. CheckedDims: map[string][]string{
  221. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "18", "3", "10", "5", "2", "37"},
  222. "coal_type": {"13", "10", "9", "8", "7", "5", "3"},
  223. },
  224. DateRange: "20190820-" + currentTime,
  225. ProductCode: "FW3001D",
  226. QuotaName: "monthly_value,monthly_accumulation",
  227. SplitTypeKey: "coal_type",
  228. IsTotal: 0,
  229. DataType: nil,
  230. IsSeason: 1,
  231. }
  232. // 将结构体转换为 JSON 字符串
  233. paramsJSON, _ := json.Marshal(params)
  234. // 返回为 map[string]string 类型
  235. return map[string]string{
  236. "params": string(paramsJSON),
  237. }
  238. }
  239. func (p *CokingBituminousCoalProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  240. responseData := fillFenWeiNetResponseData(data)
  241. var indexInfoList []models.FenWeiNetIndexInfo
  242. productName := "炼焦烟煤分煤种产量"
  243. for _, data := range responseData {
  244. var frequency string
  245. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  246. frequency = "月度"
  247. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  248. frequency = "周度"
  249. } else {
  250. frequency = data.MonthlyValueChnName
  251. }
  252. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  253. IndexName: productName + data.CoalTypeName + "/汾渭",
  254. Unit: data.MonthlyValueChnUnit,
  255. Frequency: frequency,
  256. TerminalCode: utils.TerminalCode,
  257. ClassifyName: productName,
  258. DataTime: data.DataDate,
  259. Value: data.MonthlyValue,
  260. })
  261. }
  262. return indexInfoList, nil
  263. }
  264. // ThermalCoalInventorySocietyProcessor 动力煤库存-全社会
  265. type ThermalCoalInventorySocietyProcessor struct {
  266. BaseProcessor
  267. }
  268. func (p *ThermalCoalInventorySocietyProcessor) GenerateRequestParams(currentTime string) map[string]string {
  269. params := models.RequestParams{
  270. Category: "79",
  271. CheckedDims: map[string][]string{
  272. "product_item_code": {"FW8004D-1"},
  273. },
  274. DateRange: "20190820-" + currentTime,
  275. ProductCode: "FW8004D",
  276. QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value",
  277. SplitTypeKey: "",
  278. DataType: nil,
  279. IsSeason: 1,
  280. }
  281. // 将结构体转换为 JSON 字符串
  282. paramsJSON, _ := json.Marshal(params)
  283. // 返回为 map[string]string 类型
  284. return map[string]string{
  285. "params": string(paramsJSON),
  286. }
  287. }
  288. func (p *ThermalCoalInventorySocietyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  289. responseDataMap := fillFenWeiNetResponseMapData(data)
  290. var indexInfoList []models.FenWeiNetIndexInfo
  291. productName := "动力煤库存-全社会"
  292. for productCategoryName, responseDataList := range responseDataMap {
  293. if productCategoryName != productName {
  294. continue
  295. }
  296. for _, data := range responseDataList {
  297. var frequency string
  298. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  299. frequency = "月度"
  300. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  301. frequency = "周度"
  302. } else {
  303. frequency = data.MonthlyValueChnName
  304. }
  305. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  306. IndexName: productName + "/汾渭",
  307. Unit: data.MonthlyValueChnUnit,
  308. Frequency: frequency,
  309. TerminalCode: utils.TerminalCode,
  310. ClassifyName: productName,
  311. DataTime: data.DataDate,
  312. Value: data.MonthlyValue,
  313. })
  314. }
  315. }
  316. return indexInfoList, nil
  317. }
  318. // ThermalCoalInventoryProductionProcessor 动力煤库存-生产企业
  319. type ThermalCoalInventoryProductionProcessor struct {
  320. BaseProcessor
  321. }
  322. func (p *ThermalCoalInventoryProductionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  323. params := models.RequestParams{
  324. Category: "116",
  325. CheckedDims: map[string][]string{
  326. "product_item_code": {"FW8004D-2"},
  327. },
  328. DateRange: "20190820-" + currentTime,
  329. ProductCode: "FW8004D",
  330. QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value",
  331. SplitTypeKey: "",
  332. DataType: nil,
  333. IsSeason: 1,
  334. }
  335. // 将结构体转换为 JSON 字符串
  336. paramsJSON, _ := json.Marshal(params)
  337. // 返回为 map[string]string 类型
  338. return map[string]string{
  339. "params": string(paramsJSON),
  340. }
  341. }
  342. func (p *ThermalCoalInventoryProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  343. responseDataMap := fillFenWeiNetResponseMapData(data)
  344. var indexInfoList []models.FenWeiNetIndexInfo
  345. productName := "动力煤库存-生产企业"
  346. for productCategoryName, responseDataList := range responseDataMap {
  347. if productCategoryName != productName {
  348. continue
  349. }
  350. for _, data := range responseDataList {
  351. var frequency string
  352. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  353. frequency = "月度"
  354. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  355. frequency = "周度"
  356. } else {
  357. frequency = data.MonthlyValueChnName
  358. }
  359. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  360. IndexName: productName + "/汾渭",
  361. Unit: data.WeekValueChnUnit,
  362. Frequency: frequency,
  363. TerminalCode: utils.TerminalCode,
  364. ClassifyName: productName,
  365. DataTime: data.DataDate,
  366. Value: data.MonthlyValue,
  367. })
  368. }
  369. }
  370. return indexInfoList, nil
  371. }
  372. // ThermalCoalInventorySixPowerPlantProcessor 动力煤库存-六大电厂
  373. type ThermalCoalInventorySixPowerPlantProcessor struct {
  374. BaseProcessor
  375. }
  376. func (p *ThermalCoalInventorySixPowerPlantProcessor) GenerateRequestParams(currentTime string) map[string]string {
  377. params := models.RequestParams{
  378. Category: "118",
  379. CheckedDims: map[string][]string{
  380. "product_item_code": {"FW8004D-125500", "FW8004D-112534", "FW8004D-112548", "FW8004D-112549", "FW8004D-1129", "FW8004D-125", "FW8004D-125382", "FW8004D-125383"},
  381. },
  382. DateRange: "20190820-" + currentTime,
  383. ProductCode: "FW8004D",
  384. QuotaName: "stock,avaliable_days,daily_consumption,monthly_value,inventory_index,week_value",
  385. SplitTypeKey: "",
  386. DataType: nil,
  387. IsSeason: 1,
  388. }
  389. // 将结构体转换为 JSON 字符串
  390. paramsJSON, _ := json.Marshal(params)
  391. // 返回为 map[string]string 类型
  392. return map[string]string{
  393. "params": string(paramsJSON),
  394. }
  395. }
  396. func (p *ThermalCoalInventorySixPowerPlantProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  397. responseDataMap := fillFenWeiNetResponseMapData(data)
  398. var indexInfoList []models.FenWeiNetIndexInfo
  399. productName := "动力煤库存"
  400. for productCategoryName, responseDataList := range responseDataMap {
  401. for _, data := range responseDataList {
  402. var frequency string
  403. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  404. frequency = "月度"
  405. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  406. frequency = "周度"
  407. } else {
  408. frequency = "日度"
  409. }
  410. classifyName := "动力煤库存-六大电厂"
  411. // 库存
  412. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  413. IndexName: productName + productCategoryName + data.StockChnName + "/汾渭",
  414. Unit: data.StockChnUnit,
  415. Frequency: frequency,
  416. TerminalCode: utils.TerminalCode,
  417. ClassifyName: classifyName,
  418. DataTime: data.DataDate,
  419. Value: data.Stock,
  420. })
  421. // 可用天数
  422. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  423. IndexName: productName + productCategoryName + data.AvaliableDaysChnName + "/汾渭",
  424. Unit: data.AvaliableDaysChnUnit,
  425. Frequency: frequency,
  426. TerminalCode: utils.TerminalCode,
  427. ClassifyName: classifyName,
  428. DataTime: data.DataDate,
  429. Value: data.AvaliableDays,
  430. })
  431. // 日耗
  432. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  433. IndexName: productName + productCategoryName + data.DailyConsumptionChnName + "/汾渭",
  434. Unit: data.DailyConsumptionChnUnit,
  435. Frequency: frequency,
  436. TerminalCode: utils.TerminalCode,
  437. ClassifyName: classifyName,
  438. DataTime: data.DataDate,
  439. Value: data.DailyConsumption,
  440. })
  441. }
  442. }
  443. return indexInfoList, nil
  444. }
  445. // CokingCoalInventorySocietyProcessor 炼焦煤库存-全社会
  446. type CokingCoalInventorySocietyProcessor struct {
  447. BaseProcessor
  448. }
  449. func (p *CokingCoalInventorySocietyProcessor) GenerateRequestParams(currentTime string) map[string]string {
  450. params := models.RequestParams{
  451. Category: "79",
  452. CheckedDims: map[string][]string{
  453. "product_item_code": {"FW8005D-1"},
  454. },
  455. DateRange: "20190820-" + currentTime,
  456. ProductCode: "FW8005D",
  457. QuotaName: "stock,monthly_value,inventory_index,week_value",
  458. SplitTypeKey: "",
  459. DataType: nil,
  460. IsSeason: 1,
  461. }
  462. // 将结构体转换为 JSON 字符串
  463. paramsJSON, _ := json.Marshal(params)
  464. // 返回为 map[string]string 类型
  465. return map[string]string{
  466. "params": string(paramsJSON),
  467. }
  468. }
  469. func (p *CokingCoalInventorySocietyProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  470. responseDataMap := fillFenWeiNetResponseMapData(data)
  471. var indexInfoList []models.FenWeiNetIndexInfo
  472. productName := "炼焦煤库存-全社会"
  473. for productCategoryName, responseDataList := range responseDataMap {
  474. if productCategoryName == "合计" {
  475. continue
  476. }
  477. for _, data := range responseDataList {
  478. var frequency string
  479. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  480. frequency = "月度"
  481. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  482. frequency = "周度"
  483. } else {
  484. frequency = data.MonthlyValueChnName
  485. }
  486. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  487. IndexName: productCategoryName + "/汾渭",
  488. Unit: data.MonthlyValueChnUnit,
  489. Frequency: frequency,
  490. TerminalCode: utils.TerminalCode,
  491. ClassifyName: productName,
  492. DataTime: data.DataDate,
  493. Value: data.MonthlyValue,
  494. })
  495. }
  496. }
  497. return indexInfoList, nil
  498. }
  499. // CokingCoalInventoryProductionProcessor 炼焦煤库存-生产企业
  500. type CokingCoalInventoryProductionProcessor struct {
  501. BaseProcessor
  502. }
  503. func (p *CokingCoalInventoryProductionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  504. params := models.RequestParams{
  505. Category: "116",
  506. CheckedDims: map[string][]string{
  507. "product_item_code": {"FW8005D-2"},
  508. },
  509. DateRange: "20190820-" + currentTime,
  510. ProductCode: "FW8005D",
  511. QuotaName: "stock,monthly_value,inventory_index,week_value",
  512. SplitTypeKey: "",
  513. DataType: nil,
  514. IsSeason: 1,
  515. }
  516. // 将结构体转换为 JSON 字符串
  517. paramsJSON, _ := json.Marshal(params)
  518. // 返回为 map[string]string 类型
  519. return map[string]string{
  520. "params": string(paramsJSON),
  521. }
  522. }
  523. func (p *CokingCoalInventoryProductionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  524. responseDataMap := fillFenWeiNetResponseMapData(data)
  525. var indexInfoList []models.FenWeiNetIndexInfo
  526. productName := "炼焦煤库存-生产企业"
  527. for productCategoryName, responseDataList := range responseDataMap {
  528. if productCategoryName == "合计" {
  529. continue
  530. }
  531. for _, data := range responseDataList {
  532. var frequency string
  533. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  534. frequency = "月度"
  535. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  536. frequency = "周度"
  537. } else {
  538. frequency = data.MonthlyValueChnName
  539. }
  540. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  541. IndexName: productCategoryName + "/汾渭",
  542. Unit: data.WeekValueChnUnit,
  543. Frequency: frequency,
  544. TerminalCode: utils.TerminalCode,
  545. ClassifyName: productName,
  546. DataTime: data.DataDate,
  547. Value: data.WeekValue,
  548. })
  549. }
  550. }
  551. return indexInfoList, nil
  552. }
  553. // CokingCoalInventoryDownstreamProcessor 炼焦煤库存-下游企业
  554. type CokingCoalInventoryDownstreamProcessor struct {
  555. BaseProcessor
  556. }
  557. func (p *CokingCoalInventoryDownstreamProcessor) GenerateRequestParams(currentTime string) map[string]string {
  558. params := models.RequestParams{
  559. Category: "117",
  560. CheckedDims: map[string][]string{
  561. "product_item_code": {"FW8005D-3", "FW8005D-5"},
  562. },
  563. DateRange: "20190820-" + currentTime,
  564. ProductCode: "FW8005D",
  565. QuotaName: "stock,monthly_value,inventory_index,week_value",
  566. SplitTypeKey: "",
  567. DataType: nil,
  568. IsSeason: 1,
  569. }
  570. // 将结构体转换为 JSON 字符串
  571. paramsJSON, _ := json.Marshal(params)
  572. // 返回为 map[string]string 类型
  573. return map[string]string{
  574. "params": string(paramsJSON),
  575. }
  576. }
  577. func (p *CokingCoalInventoryDownstreamProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  578. responseDataMap := fillFenWeiNetResponseMapData(data)
  579. var indexInfoList []models.FenWeiNetIndexInfo
  580. productName := "炼焦煤库存-下游企业"
  581. for productCategoryName, responseDataList := range responseDataMap {
  582. if productCategoryName == "合计" {
  583. continue
  584. }
  585. for _, data := range responseDataList {
  586. frequency := "周度"
  587. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  588. IndexName: productCategoryName + "/汾渭",
  589. Unit: data.StockChnUnit,
  590. Frequency: frequency,
  591. TerminalCode: utils.TerminalCode,
  592. ClassifyName: productName,
  593. DataTime: data.DataDate,
  594. Value: data.Stock,
  595. })
  596. }
  597. }
  598. return indexInfoList, nil
  599. }
  600. // NationalCoalMineInventoryProcessor 全国煤矿库存
  601. type NationalCoalMineInventoryProcessor struct {
  602. BaseProcessor
  603. }
  604. func (p *NationalCoalMineInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string {
  605. params := models.RequestParams{
  606. Category: nil,
  607. CheckedDims: map[string][]string{},
  608. DateRange: "20190820-" + currentTime,
  609. ProductCode: "FW8001D",
  610. QuotaName: "monthly_value",
  611. SplitTypeKey: "",
  612. DataType: nil,
  613. IsSeason: 1,
  614. }
  615. // 将结构体转换为 JSON 字符串
  616. paramsJSON, _ := json.Marshal(params)
  617. // 返回为 map[string]string 类型
  618. return map[string]string{
  619. "params": string(paramsJSON),
  620. }
  621. }
  622. func (p *NationalCoalMineInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  623. responseData := fillFenWeiNetResponseData(data)
  624. var indexInfoList []models.FenWeiNetIndexInfo
  625. productName := "全国煤矿库存"
  626. for _, data := range responseData {
  627. var frequency string
  628. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  629. frequency = "月度"
  630. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  631. frequency = "周度"
  632. } else {
  633. frequency = "日度"
  634. }
  635. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  636. IndexName: productName + "/汾渭",
  637. Unit: data.MonthlyValueChnUnit,
  638. Frequency: frequency,
  639. TerminalCode: utils.TerminalCode,
  640. ClassifyName: productName,
  641. DataTime: data.DataDate,
  642. Value: data.MonthlyValue,
  643. })
  644. }
  645. return indexInfoList, nil
  646. }
  647. // StateOwnedKeyCoalMineInventoryProcessor 国有重点煤矿库存
  648. type StateOwnedKeyCoalMineInventoryProcessor struct {
  649. BaseProcessor
  650. }
  651. func (p *StateOwnedKeyCoalMineInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string {
  652. params := models.RequestParams{
  653. Category: nil,
  654. CheckedDims: map[string][]string{
  655. "province": {"20", "16", "21", "6", "19", "23", "8", "1", "7", "17", "9", "15", "11", "22", "24", "4", "25", "12", "14", "13", "2", "27", "28"},
  656. },
  657. DateRange: "20190820-" + currentTime,
  658. ProductCode: "FW8003D",
  659. QuotaName: "monthly_value",
  660. SplitTypeKey: "province",
  661. IsTotal: "",
  662. DataType: nil,
  663. IsSeason: 1,
  664. }
  665. // 将结构体转换为 JSON 字符串
  666. paramsJSON, _ := json.Marshal(params)
  667. // 返回为 map[string]string 类型
  668. return map[string]string{
  669. "params": string(paramsJSON),
  670. }
  671. }
  672. func (p *StateOwnedKeyCoalMineInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  673. responseData := fillFenWeiNetResponseData(data)
  674. var indexInfoList []models.FenWeiNetIndexInfo
  675. productName := "国有重点煤矿库存"
  676. for _, data := range responseData {
  677. var frequency string
  678. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  679. frequency = "月度"
  680. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  681. frequency = "周度"
  682. } else {
  683. frequency = "日度"
  684. }
  685. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  686. IndexName: productName + data.ProvinceName + "/汾渭",
  687. Unit: data.MonthlyValueChnUnit,
  688. Frequency: frequency,
  689. TerminalCode: utils.TerminalCode,
  690. ClassifyName: productName,
  691. DataTime: data.DataDate,
  692. Value: data.MonthlyValue,
  693. })
  694. }
  695. return indexInfoList, nil
  696. }
  697. // CokeInventoryProcessor 焦炭库存
  698. type CokeInventoryProcessor struct {
  699. BaseProcessor
  700. }
  701. func (p *CokeInventoryProcessor) GenerateRequestParams(currentTime string) map[string]string {
  702. params := models.RequestParams{
  703. Category: nil,
  704. CheckedDims: map[string][]string{
  705. "product_item_code": {"FW1405D-1", "FW1405D-2", "FW1405D-3", "FW1405D-4", "FW1405D-5", "FW1405D-6", "FW1405D-7"},
  706. },
  707. DateRange: "20190820-" + currentTime,
  708. ProductCode: "FW1405D",
  709. QuotaName: "stock,inventory_index",
  710. SplitTypeKey: "",
  711. DataType: nil,
  712. IsSeason: 1,
  713. }
  714. // 将结构体转换为 JSON 字符串
  715. paramsJSON, _ := json.Marshal(params)
  716. // 返回为 map[string]string 类型
  717. return map[string]string{
  718. "params": string(paramsJSON),
  719. }
  720. }
  721. func (p *CokeInventoryProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  722. responseDataMap := fillFenWeiNetResponseMapData(data)
  723. var indexInfoList []models.FenWeiNetIndexInfo
  724. productName := "焦炭库存"
  725. for productCategoryName, responseDataList := range responseDataMap {
  726. utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList)))
  727. for _, data := range responseDataList {
  728. var frequency string
  729. productCodeMap := map[string]struct{}{
  730. "FW1405D-1": {},
  731. "FW1405D-2": {},
  732. "FW1405D-3": {},
  733. "FW1405D-6": {},
  734. "FW1405D-7": {},
  735. }
  736. if _, ok := productCodeMap[data.ProductItemCode]; ok {
  737. frequency = "周度"
  738. } else {
  739. frequency = "日度"
  740. }
  741. var unit string
  742. if data.InventoryIndexChnUnit != "" {
  743. unit = data.InventoryIndexChnUnit
  744. } else {
  745. unit = data.StockChnUnit
  746. }
  747. var value float64
  748. if data.InventoryIndex != 0 {
  749. value = data.InventoryIndex
  750. } else {
  751. value = data.Stock
  752. }
  753. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  754. IndexName: productName + productCategoryName + "/汾渭",
  755. Unit: unit,
  756. Frequency: frequency,
  757. TerminalCode: utils.TerminalCode,
  758. ClassifyName: productName,
  759. DataTime: data.DataDate,
  760. Value: value,
  761. })
  762. }
  763. }
  764. return indexInfoList, nil
  765. }
  766. // PortDataInventoryNorthernPortProcessor 港口数据-库存-北方港口
  767. type PortDataInventoryNorthernPortProcessor struct {
  768. BaseProcessor
  769. }
  770. func (p *PortDataInventoryNorthernPortProcessor) GenerateRequestParams(currentTime string) map[string]string {
  771. params := models.RequestParams{
  772. Category: "79",
  773. CheckedDims: map[string][]string{
  774. "code": {"2332", "2333", "2335", "2334", "2337", "2339", "2340", "2341", "2342"},
  775. },
  776. DateRange: "20190820-" + currentTime,
  777. ProductCode: "FW1203D",
  778. QuotaName: "stock",
  779. SplitTypeKey: "product_item_code",
  780. IsTotal: 0,
  781. DataType: nil,
  782. Type: 2,
  783. IsSeason: 1,
  784. }
  785. // 将结构体转换为 JSON 字符串
  786. paramsJSON, _ := json.Marshal(params)
  787. // 返回为 map[string]string 类型
  788. return map[string]string{
  789. "params": string(paramsJSON),
  790. }
  791. }
  792. func (p *PortDataInventoryNorthernPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  793. responseData := fillFenWeiNetResponseData(data)
  794. var indexInfoList []models.FenWeiNetIndexInfo
  795. productName := "港口数据-库存-北方港口"
  796. for _, data := range responseData {
  797. var frequency string
  798. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  799. frequency = "月度"
  800. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  801. frequency = "周度"
  802. } else {
  803. frequency = "日度"
  804. }
  805. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  806. IndexName: productName + data.ProductItemName + "/汾渭",
  807. Unit: data.StockChnUnit,
  808. Frequency: frequency,
  809. TerminalCode: utils.TerminalCode,
  810. ClassifyName: productName,
  811. DataTime: data.DataDate,
  812. Value: data.Stock,
  813. })
  814. }
  815. return indexInfoList, nil
  816. }
  817. // PortDataInventoryInlandPortProcessor 港口数据-库存-江内港口
  818. type PortDataInventoryInlandPortProcessor struct {
  819. BaseProcessor
  820. }
  821. func (p *PortDataInventoryInlandPortProcessor) GenerateRequestParams(currentTime string) map[string]string {
  822. params := models.RequestParams{
  823. Category: "79",
  824. CheckedDims: map[string][]string{
  825. "code": {"2321", "2320", "2324", "2323", "2322", "2325"},
  826. },
  827. DateRange: "20190820-" + currentTime,
  828. ProductCode: "FW1203D",
  829. QuotaName: "stock",
  830. SplitTypeKey: "product_item_code",
  831. IsTotal: 0,
  832. DataType: nil,
  833. Type: 2,
  834. IsSeason: 1,
  835. }
  836. // 将结构体转换为 JSON 字符串
  837. paramsJSON, _ := json.Marshal(params)
  838. // 返回为 map[string]string 类型
  839. return map[string]string{
  840. "params": string(paramsJSON),
  841. }
  842. }
  843. func (p *PortDataInventoryInlandPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  844. responseData := fillFenWeiNetResponseData(data)
  845. var indexInfoList []models.FenWeiNetIndexInfo
  846. productName := "港口数据-库存-江内港口"
  847. for _, data := range responseData {
  848. var frequency = "周度"
  849. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  850. IndexName: productName + data.ProductItemName + "/汾渭",
  851. Unit: data.StockChnUnit,
  852. Frequency: frequency,
  853. TerminalCode: utils.TerminalCode,
  854. ClassifyName: productName,
  855. DataTime: data.DataDate,
  856. Value: data.Stock,
  857. })
  858. }
  859. return indexInfoList, nil
  860. }
  861. // PortDataDispatchNorthernPortProcessor 港口数据-调度-北方港口
  862. type PortDataDispatchNorthernPortProcessor struct {
  863. BaseProcessor
  864. }
  865. func (p *PortDataDispatchNorthernPortProcessor) GenerateRequestParams(currentTime string) map[string]string {
  866. params := models.RequestParams{
  867. Category: "120",
  868. CheckedDims: map[string][]string{
  869. "code": {"2364", "2365", "2366", "2363", "2367", "2368"},
  870. "port": {"2", "4", "7", "9", "11", "326", "327", "329", "330"},
  871. },
  872. DateRange: "20190820-" + currentTime,
  873. ProductCode: "FW1203D",
  874. QuotaName: "vehicle,ship,tons",
  875. SplitTypeKey: "product_item_code,port",
  876. IsTotal: 1,
  877. DataType: nil,
  878. Type: 2,
  879. IsSeason: 1,
  880. }
  881. // 将结构体转换为 JSON 字符串
  882. paramsJSON, _ := json.Marshal(params)
  883. // 返回为 map[string]string 类型
  884. return map[string]string{
  885. "params": string(paramsJSON),
  886. }
  887. }
  888. func (p *PortDataDispatchNorthernPortProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  889. responseData := fillFenWeiNetResponseData(data)
  890. var indexInfoList []models.FenWeiNetIndexInfo
  891. productName := "港口数据-调度-北方港口"
  892. for _, data := range responseData {
  893. var frequency = "日度"
  894. var unit string
  895. if data.VehicleChnUnit != "" {
  896. unit = data.VehicleChnUnit
  897. } else if data.TonsChnUnit != "" {
  898. unit = data.TonsChnUnit
  899. } else {
  900. unit = data.ShipChnUnit
  901. }
  902. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  903. IndexName: productName + "-" + data.PortName + data.ProductItemName + "/汾渭",
  904. Unit: unit,
  905. Frequency: frequency,
  906. TerminalCode: utils.TerminalCode,
  907. ClassifyName: productName,
  908. DataTime: data.DataDate,
  909. Value: data.Tons,
  910. })
  911. }
  912. return indexInfoList, nil
  913. }
  914. // PortDataThroughputProcessor 港口数据-运量
  915. type PortDataThroughputProcessor struct {
  916. BaseProcessor
  917. }
  918. func (p *PortDataThroughputProcessor) GenerateRequestParams(currentTime string) map[string]string {
  919. params := models.RequestParams{
  920. Category: "30",
  921. CheckedDims: map[string][]string{
  922. "code": {"2362"},
  923. "port_son": {"44", "43", "42", "41", "40", "39"},
  924. },
  925. DateRange: "20190820-" + currentTime,
  926. ProductCode: "FW1203D",
  927. QuotaName: "transport_volume",
  928. SplitTypeKey: "port_son",
  929. IsTotal: 0,
  930. DataType: nil,
  931. Type: 2,
  932. IsSeason: 1,
  933. }
  934. // 将结构体转换为 JSON 字符串
  935. paramsJSON, _ := json.Marshal(params)
  936. // 返回为 map[string]string 类型
  937. return map[string]string{
  938. "params": string(paramsJSON),
  939. }
  940. }
  941. func (p *PortDataThroughputProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  942. responseData := fillFenWeiNetResponseData(data)
  943. var indexInfoList []models.FenWeiNetIndexInfo
  944. productName := "港口数据-运量"
  945. for _, data := range responseData {
  946. var frequency = "日度"
  947. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  948. IndexName: productName + data.PortSonName + "/汾渭",
  949. Unit: data.TransportVolumeChnUnit,
  950. Frequency: frequency,
  951. TerminalCode: utils.TerminalCode,
  952. ClassifyName: productName,
  953. DataTime: data.DataDate,
  954. Value: data.TransportVolume,
  955. })
  956. }
  957. return indexInfoList, nil
  958. }
  959. // DaqinLineDailyThroughputProcessor 大秦线日运量
  960. type DaqinLineDailyThroughputProcessor struct {
  961. BaseProcessor
  962. }
  963. func (p *DaqinLineDailyThroughputProcessor) GenerateRequestParams(currentTime string) map[string]string {
  964. params := models.RequestParams{
  965. Category: nil,
  966. CheckedDims: map[string][]string{},
  967. DateRange: "20190820-" + currentTime,
  968. ProductCode: "FW1107D",
  969. QuotaName: "stock",
  970. SplitTypeKey: "",
  971. DataType: nil,
  972. IsSeason: 1,
  973. }
  974. // 将结构体转换为 JSON 字符串
  975. paramsJSON, _ := json.Marshal(params)
  976. // 返回为 map[string]string 类型
  977. return map[string]string{
  978. "params": string(paramsJSON),
  979. }
  980. }
  981. func (p *DaqinLineDailyThroughputProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  982. responseData := fillFenWeiNetResponseData(data)
  983. var indexInfoList []models.FenWeiNetIndexInfo
  984. productName := "大秦线日运量"
  985. for _, data := range responseData {
  986. var frequency = "日度"
  987. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  988. IndexName: productName + data.StockChnName + "/汾渭",
  989. Unit: data.StockChnUnit,
  990. Frequency: frequency,
  991. TerminalCode: utils.TerminalCode,
  992. ClassifyName: productName,
  993. DataTime: data.DataDate,
  994. Value: data.Stock,
  995. })
  996. }
  997. return indexInfoList, nil
  998. }
  999. // ThermalCoalPortPriceProcessor 动力煤港口价格
  1000. type ThermalCoalPortPriceProcessor struct {
  1001. BaseProcessor
  1002. }
  1003. func (p *ThermalCoalPortPriceProcessor) GenerateRequestParams(currentTime string) map[string]string {
  1004. params := models.RequestParams{
  1005. Category: nil,
  1006. CheckedDims: map[string][]string{
  1007. "product_item_code": {"FW2001P-1001", "FW2001P-1002", "FW2001P-1004", "FW2001P-1005", "FW2001P-1003", "FW2001P-1171"},
  1008. },
  1009. DateRange: "20190820-" + currentTime,
  1010. ProductCode: "FW2310R",
  1011. QuotaName: "price_rmb,price_index_mom",
  1012. SplitTypeKey: "",
  1013. DataType: nil,
  1014. IsSeason: 1,
  1015. }
  1016. // 将结构体转换为 JSON 字符串
  1017. paramsJSON, _ := json.Marshal(params)
  1018. // 返回为 map[string]string 类型
  1019. return map[string]string{
  1020. "params": string(paramsJSON),
  1021. }
  1022. }
  1023. func (p *ThermalCoalPortPriceProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  1024. responseDataMap := fillFenWeiNetResponseAStratumMapData(data)
  1025. var indexInfoList []models.FenWeiNetIndexInfo
  1026. productName := "动力煤港口价格"
  1027. for productCategoryName, responseDataList := range responseDataMap {
  1028. utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList)))
  1029. for _, data := range responseDataList {
  1030. var frequency = "日度"
  1031. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  1032. IndexName: productName + productCategoryName + "-" + data.PriceRmbChnName + "/汾渭",
  1033. Unit: data.PriceRmbChnUnit,
  1034. Frequency: frequency,
  1035. TerminalCode: utils.TerminalCode,
  1036. ClassifyName: productName,
  1037. DataTime: data.DataDate,
  1038. Value: data.PriceRmb,
  1039. })
  1040. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  1041. IndexName: productName + productCategoryName + "-" + data.PriceIndexMomChnName + "/汾渭",
  1042. Unit: data.PriceIndexMomChnUnit,
  1043. Frequency: frequency,
  1044. TerminalCode: utils.TerminalCode,
  1045. ClassifyName: productName,
  1046. DataTime: data.DataDate,
  1047. Value: data.PriceIndexMom,
  1048. })
  1049. }
  1050. }
  1051. return indexInfoList, nil
  1052. }
  1053. // ThermalCoalConsumptionProcessor 动力煤消费量
  1054. type ThermalCoalConsumptionProcessor struct {
  1055. BaseProcessor
  1056. }
  1057. func (p *ThermalCoalConsumptionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  1058. params := models.RequestParams{
  1059. Category: nil,
  1060. CheckedDims: map[string][]string{
  1061. "product_item_code": {"FW5002D-1", "FW5002D-2", "FW5002D-3", "FW5002D-4", "FW5002D-5", "FW5002D-6", "FW5002D-7"},
  1062. },
  1063. DateRange: "20190820-" + currentTime,
  1064. ProductCode: "FW5002D",
  1065. QuotaName: "monthly_value,monthly_accumulation",
  1066. SplitTypeKey: "",
  1067. DataType: nil,
  1068. IsSeason: 1,
  1069. }
  1070. // 将结构体转换为 JSON 字符串
  1071. paramsJSON, _ := json.Marshal(params)
  1072. // 返回为 map[string]string 类型
  1073. return map[string]string{
  1074. "params": string(paramsJSON),
  1075. }
  1076. }
  1077. func (p *ThermalCoalConsumptionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  1078. responseDataMap := fillFenWeiNetResponseMapData(data)
  1079. var indexInfoList []models.FenWeiNetIndexInfo
  1080. productName := "动力煤消费量"
  1081. for productCategoryName, responseDataList := range responseDataMap {
  1082. utils.FileLog.Info(fmt.Sprintf("productName: %s, responseDataList:size: %v", productName, len(responseDataList)))
  1083. for _, data := range responseDataList {
  1084. var frequency string
  1085. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  1086. frequency = "月度"
  1087. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  1088. frequency = "周度"
  1089. } else {
  1090. frequency = "日度"
  1091. }
  1092. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  1093. IndexName: productName + productCategoryName + "/汾渭",
  1094. Unit: data.MonthlyValueChnUnit,
  1095. Frequency: frequency,
  1096. TerminalCode: utils.TerminalCode,
  1097. ClassifyName: productName,
  1098. DataTime: data.DataDate,
  1099. Value: data.MonthlyValue,
  1100. })
  1101. }
  1102. }
  1103. return indexInfoList, nil
  1104. }
  1105. // CokingCleanCoalConsumptionProcessor 炼焦精煤消费量
  1106. type CokingCleanCoalConsumptionProcessor struct {
  1107. BaseProcessor
  1108. }
  1109. func (p *CokingCleanCoalConsumptionProcessor) GenerateRequestParams(currentTime string) map[string]string {
  1110. params := models.RequestParams{
  1111. Category: nil,
  1112. CheckedDims: map[string][]string{},
  1113. DateRange: "20190820-" + currentTime,
  1114. ProductCode: "FW5001D",
  1115. QuotaName: "monthly_value,monthly_accumulation",
  1116. SplitTypeKey: "",
  1117. DataType: nil,
  1118. IsSeason: 1,
  1119. }
  1120. // 将结构体转换为 JSON 字符串
  1121. paramsJSON, _ := json.Marshal(params)
  1122. // 返回为 map[string]string 类型
  1123. return map[string]string{
  1124. "params": string(paramsJSON),
  1125. }
  1126. }
  1127. func (p *CokingCleanCoalConsumptionProcessor) ProcessResponse(data string) ([]models.FenWeiNetIndexInfo, error) {
  1128. responseData := fillFenWeiNetResponseData(data)
  1129. var indexInfoList []models.FenWeiNetIndexInfo
  1130. productName := "炼焦精煤消费量"
  1131. for _, data := range responseData {
  1132. var frequency string
  1133. if data.MonthlyValueChnName != "" && strings.Contains(data.MonthlyValueChnName, "月度") {
  1134. frequency = "月度"
  1135. } else if data.WeekValueChnName != "" && strings.Contains(data.WeekValueChnName, "周度") {
  1136. frequency = "周度"
  1137. } else {
  1138. frequency = "日度"
  1139. }
  1140. indexInfoList = append(indexInfoList, models.FenWeiNetIndexInfo{
  1141. IndexName: productName + "/汾渭",
  1142. Unit: data.MonthlyValueChnUnit,
  1143. Frequency: frequency,
  1144. TerminalCode: utils.TerminalCode,
  1145. ClassifyName: productName,
  1146. DataTime: data.DataDate,
  1147. Value: data.MonthlyValue,
  1148. })
  1149. }
  1150. return indexInfoList, nil
  1151. }
  1152. func fillFenWeiNetResponseData(data string) []models.FenWeiNetResponse {
  1153. var result models.FenWeiNetResponseWrapper
  1154. err := json.Unmarshal([]byte(data), &result)
  1155. if err != nil {
  1156. return nil
  1157. }
  1158. responseData := result.Data.Data
  1159. return responseData
  1160. }
  1161. func fillFenWeiNetResponseMapData(data string) map[string][]models.FenWeiNetResponse {
  1162. var result models.FenWeiNetResponseMapWrapper
  1163. err := json.Unmarshal([]byte(data), &result)
  1164. if err != nil {
  1165. return nil
  1166. }
  1167. responseData := result.Data.Data
  1168. return responseData
  1169. }
  1170. func fillFenWeiNetResponseAStratumMapData(data string) map[string][]models.FenWeiNetResponse {
  1171. var result models.FenWeiNetResponseAStratumMapWrapper
  1172. err := json.Unmarshal([]byte(data), &result)
  1173. if err != nil {
  1174. return nil
  1175. }
  1176. responseData := result.Data
  1177. return responseData
  1178. }