processor_business_logic.go 41 KB

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