week30.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188
  1. package base_from_yongyi_v2
  2. import (
  3. "eta/eta_data_analysis/models"
  4. "eta/eta_data_analysis/utils"
  5. "fmt"
  6. "github.com/xuri/excelize/v2"
  7. "strconv"
  8. "strings"
  9. "time"
  10. )
  11. // HandleYongyiExcelWeekly21 仔猪、母猪
  12. func HandleYongyiExcelWeekly21(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  13. defer func() {
  14. if err != nil {
  15. //fmt.Printf("HandleYongyiExcelWeekly21 仔猪、母猪 ErrMsg: %s\n", err.Error())
  16. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly21 仔猪、母猪 ErrMsg: %s", err.Error()))
  17. }
  18. }()
  19. rows, e := f.GetRows(sheetName)
  20. if e != nil {
  21. err = fmt.Errorf("f GetRows err: %s", e.Error())
  22. return
  23. }
  24. // 获取指标分类
  25. classifyName, classifySort, frequency, unit, _, namePrefixPingin := GetBaseInfo(sheetName)
  26. // 遍历行读取
  27. indexList = make([]*models.YongyiExcelIndex, 0)
  28. provinceMap := make(map[int]string)
  29. sort := 0
  30. fmt.Println("最大行")
  31. // 指标名称
  32. indexMap := make(map[string]*models.YongyiExcelIndex)
  33. for i, row := range rows {
  34. //fmt.Printf("当前第%d行 \n", i)
  35. if i == 0 {
  36. continue
  37. } else if i == 1 { //表示表头
  38. // 处理 index指标表
  39. for k, text := range row {
  40. if text != "" {
  41. text = strings.TrimSpace(text)
  42. provinceMap[k] = text
  43. }
  44. }
  45. } else { //数据列
  46. date := ""
  47. name := ""
  48. for k, text := range row {
  49. //fmt.Printf("当前第%d列 \n", k)
  50. if k == 0 {
  51. text = strings.TrimSpace(text)
  52. var dateT time.Time
  53. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  54. if e != nil {
  55. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  56. continue
  57. }
  58. date = dateT.Format(utils.FormatDate)
  59. fmt.Println(date)
  60. continue
  61. } else if k == 1 {
  62. name = text
  63. continue
  64. } else {
  65. // 判断出不是字符的,则过滤
  66. if text == "" {
  67. continue
  68. }
  69. if strings.Contains(text, "%") {
  70. text = strings.Replace(text, "%", "", 1)
  71. }
  72. _, e := strconv.ParseFloat(text, 64)
  73. if e != nil {
  74. // utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  75. continue
  76. }
  77. }
  78. province, ok2 := provinceMap[k]
  79. if !ok2 {
  80. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  81. return
  82. }
  83. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, province)
  84. // 处理指标名称
  85. fullIndexName := fmt.Sprintf("%s/%s/%s", "仔猪价", name, province)
  86. provincePingyin := utils.GetFullPingYin(province)
  87. namePingin := utils.GetFirstPingYin(name)
  88. fullIndexNamePingyin := namePrefixPingin + utils.GetFirstPingYin("仔猪价") + namePingin + provincePingyin
  89. if strings.Contains(name, "二元母猪价") {
  90. fullIndexName = fmt.Sprintf("%s/%s", name, province)
  91. fullIndexNamePingyin = "yyzx" + namePingin + provincePingyin
  92. }
  93. indexItem, okIndex := indexMap[fullIndexName]
  94. if !okIndex {
  95. // 新增指标
  96. indexItem = new(models.YongyiExcelIndex)
  97. indexItem.IndexName = fullIndexName
  98. indexItem.ClassifyName = classifyName
  99. indexItem.ClassifySort = classifySort
  100. indexItem.IndexCode = fullIndexNamePingyin
  101. indexItem.Frequency = frequency
  102. indexItem.Sort = sort
  103. indexItem.Unit = unit
  104. indexItem.ExcelDataMap = make(map[string]string)
  105. sort++
  106. }
  107. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  108. indexItem.ExcelDataMap[date] = text
  109. indexMap[fullIndexName] = indexItem
  110. continue
  111. }
  112. }
  113. }
  114. for _, v := range indexMap {
  115. indexList = append(indexList, v)
  116. }
  117. return
  118. }
  119. // HandleYongyiExcelWeekly22 周度-河南屠宰白条成本
  120. func HandleYongyiExcelWeekly22(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  121. defer func() {
  122. if err != nil {
  123. //fmt.Printf("HandleYongyiExcelWeekly22 周度-河南屠宰白条成本 ErrMsg: %s\n", err.Error())
  124. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly22 周度-河南屠宰白条成本 ErrMsg: %s", err.Error()))
  125. }
  126. }()
  127. rows, e := f.GetRows(sheetName)
  128. if e != nil {
  129. err = fmt.Errorf("f GetRows err: %s", e.Error())
  130. return
  131. }
  132. // 获取指标分类
  133. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  134. // 遍历行读取
  135. indexList = make([]*models.YongyiExcelIndex, 0)
  136. nameMap := make(map[int]string)
  137. sort := 0
  138. // 指标名称
  139. indexMap := make(map[string]*models.YongyiExcelIndex)
  140. for i, row := range rows {
  141. //fmt.Printf("当前第%d行 \n", i)
  142. if i == 0 {
  143. continue
  144. } else if i == 1 { //表示表头
  145. // 处理 index指标表
  146. for k, text := range row {
  147. if text != "" {
  148. text = strings.TrimSpace(text)
  149. nameMap[k] = text
  150. }
  151. }
  152. } else { //数据列
  153. date := ""
  154. for k, text := range row {
  155. //fmt.Printf("当前第%d列 \n", k)
  156. if k == 0 {
  157. text = strings.TrimSpace(text)
  158. var dateT time.Time
  159. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  160. if e != nil {
  161. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  162. continue
  163. }
  164. date = dateT.Format(utils.FormatDate)
  165. fmt.Println(date)
  166. continue
  167. } else {
  168. // 判断出不是字符的,则过滤
  169. if text == "" {
  170. continue
  171. }
  172. if strings.Contains(text, "%") {
  173. text = strings.Replace(text, "%", "", 1)
  174. }
  175. _, e := strconv.ParseFloat(text, 64)
  176. if e != nil {
  177. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  178. continue
  179. }
  180. }
  181. name, ok2 := nameMap[k]
  182. if !ok2 {
  183. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  184. return
  185. }
  186. nameSlice := strings.Split(name, "(")
  187. unitNew := unit
  188. if len(nameSlice) > 1 {
  189. name = nameSlice[0]
  190. }
  191. nameSlice = strings.Split(name, "\n")
  192. if len(nameSlice) > 1 {
  193. name = nameSlice[0]
  194. }
  195. switch name {
  196. case "生猪重量", "净白条重":
  197. unitNew = "kg"
  198. case "生猪结算", "白条成本", "6个等级白条均价":
  199. unitNew = "元/kg"
  200. case "副产品回", "屠宰费用", "白条头均利润":
  201. unitNew = "元/头"
  202. }
  203. if name == "预冷损耗" {
  204. continue
  205. }
  206. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, name)
  207. // 处理指标名称
  208. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, name)
  209. namePingin := utils.GetFirstPingYin(name)
  210. fullIndexNamePingyin := namePrefixPingin + namePingin
  211. indexItem, okIndex := indexMap[fullIndexName]
  212. if !okIndex {
  213. // 新增指标
  214. indexItem = new(models.YongyiExcelIndex)
  215. indexItem.IndexName = fullIndexName
  216. indexItem.ClassifyName = classifyName
  217. indexItem.ClassifySort = classifySort
  218. indexItem.IndexCode = fullIndexNamePingyin
  219. indexItem.Frequency = frequency
  220. indexItem.Sort = sort
  221. indexItem.Unit = unitNew
  222. indexItem.ExcelDataMap = make(map[string]string)
  223. sort++
  224. }
  225. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  226. indexItem.ExcelDataMap[date] = text
  227. indexMap[fullIndexName] = indexItem
  228. continue
  229. }
  230. }
  231. }
  232. for _, v := range indexMap {
  233. indexList = append(indexList, v)
  234. }
  235. return
  236. }
  237. // HandleYongyiExcelWeekly23 周度-淘汰母猪价格
  238. func HandleYongyiExcelWeekly23(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  239. defer func() {
  240. if err != nil {
  241. //fmt.Printf("HandleYongyiExcelWeekly23 周度-淘汰母猪价格 ErrMsg: %s\n", err.Error())
  242. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly23 周度-淘汰母猪价格 ErrMsg: %s", err.Error()))
  243. }
  244. }()
  245. rows, e := f.GetRows(sheetName)
  246. if e != nil {
  247. err = fmt.Errorf("f GetRows err: %s", e.Error())
  248. return
  249. }
  250. // 获取指标分类
  251. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  252. // 遍历行读取
  253. indexList = make([]*models.YongyiExcelIndex, 0)
  254. provinceMap := make(map[int]string)
  255. sort := 0
  256. fmt.Println("最大行")
  257. // 指标名称
  258. indexMap := make(map[string]*models.YongyiExcelIndex)
  259. for i, row := range rows {
  260. //fmt.Printf("当前第%d行 \n", i)
  261. if i == 0 {
  262. continue
  263. } else if i == 1 { //表示表头
  264. // 处理 index指标表
  265. for k, text := range row {
  266. if text != "" {
  267. text = strings.TrimSpace(text)
  268. provinceMap[k] = text
  269. }
  270. }
  271. } else { //数据列
  272. date := ""
  273. for k, text := range row {
  274. //fmt.Printf("当前第%d列 \n", k)
  275. if k == 0 {
  276. continue
  277. } else if k == 1 {
  278. text = strings.TrimSpace(text)
  279. var dateT time.Time
  280. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  281. if e != nil {
  282. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  283. continue
  284. }
  285. date = dateT.Format(utils.FormatDate)
  286. fmt.Println(date)
  287. continue
  288. } else {
  289. // 判断出不是字符的,则过滤
  290. if text == "" {
  291. continue
  292. }
  293. if strings.Contains(text, "%") {
  294. text = strings.Replace(text, "%", "", 1)
  295. }
  296. _, e := strconv.ParseFloat(text, 64)
  297. if e != nil {
  298. //utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  299. continue
  300. }
  301. }
  302. province, ok2 := provinceMap[k]
  303. if !ok2 {
  304. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  305. return
  306. }
  307. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, province)
  308. // 处理指标名称
  309. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, province)
  310. provincePingyin := utils.GetFullPingYin(province)
  311. fullIndexNamePingyin := namePrefixPingin + provincePingyin
  312. indexItem, okIndex := indexMap[fullIndexName]
  313. if !okIndex {
  314. // 新增指标
  315. indexItem = new(models.YongyiExcelIndex)
  316. indexItem.IndexName = fullIndexName
  317. indexItem.ClassifyName = classifyName
  318. indexItem.ClassifySort = classifySort
  319. indexItem.IndexCode = fullIndexNamePingyin
  320. indexItem.Frequency = frequency
  321. indexItem.Sort = sort
  322. indexItem.Unit = unit
  323. indexItem.ExcelDataMap = make(map[string]string)
  324. sort++
  325. }
  326. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  327. indexItem.ExcelDataMap[date] = text
  328. indexMap[fullIndexName] = indexItem
  329. continue
  330. }
  331. }
  332. }
  333. for _, v := range indexMap {
  334. indexList = append(indexList, v)
  335. }
  336. return
  337. }
  338. // HandleYongyiExcelWeekly24 鲜销率
  339. func HandleYongyiExcelWeekly24(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  340. defer func() {
  341. if err != nil {
  342. //fmt.Printf("HandleYongyiExcelWeekly24 鲜销率 ErrMsg: %s\n", err.Error())
  343. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly24 鲜销率 ErrMsg: %s", err.Error()))
  344. }
  345. }()
  346. rows, e := f.GetRows(sheetName)
  347. if e != nil {
  348. err = fmt.Errorf("f GetRows err: %s", e.Error())
  349. return
  350. }
  351. // 获取指标分类
  352. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  353. // 遍历行读取
  354. indexList = make([]*models.YongyiExcelIndex, 0)
  355. provinceMap := make(map[int]string)
  356. sort := 0
  357. fmt.Println("最大行")
  358. // 指标名称
  359. indexMap := make(map[string]*models.YongyiExcelIndex)
  360. for i, row := range rows {
  361. //fmt.Printf("当前第%d行 \n", i)
  362. if i <= 1 || i > 2 && i <= 5 {
  363. continue
  364. } else if i == 2 { //表示表头
  365. // 处理 index指标表
  366. for k, text := range row {
  367. if text != "" {
  368. text = strings.TrimSpace(text)
  369. provinceMap[k] = text
  370. }
  371. }
  372. } else { //数据列
  373. date := ""
  374. for k, text := range row {
  375. //fmt.Printf("当前第%d列 \n", k)
  376. if k == 0 {
  377. continue
  378. } else if k == 1 {
  379. text = strings.TrimSpace(text)
  380. var dateT time.Time
  381. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  382. if e != nil {
  383. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  384. continue
  385. }
  386. date = dateT.Format(utils.FormatDate)
  387. fmt.Println(date)
  388. continue
  389. } else {
  390. // 判断出不是字符的,则过滤
  391. if text == "" {
  392. continue
  393. }
  394. if strings.Contains(text, "%") {
  395. text = strings.Replace(text, "%", "", 1)
  396. }
  397. _, e := strconv.ParseFloat(text, 64)
  398. if e != nil {
  399. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  400. continue
  401. }
  402. }
  403. province, ok2 := provinceMap[k]
  404. if !ok2 {
  405. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  406. return
  407. }
  408. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, province)
  409. // 处理指标名称
  410. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, province)
  411. provincePingyin := utils.GetFullPingYin(province)
  412. fullIndexNamePingyin := namePrefixPingin + provincePingyin
  413. indexItem, okIndex := indexMap[fullIndexName]
  414. if !okIndex {
  415. // 新增指标
  416. indexItem = new(models.YongyiExcelIndex)
  417. indexItem.IndexName = fullIndexName
  418. indexItem.ClassifyName = classifyName
  419. indexItem.ClassifySort = classifySort
  420. indexItem.IndexCode = fullIndexNamePingyin
  421. indexItem.Frequency = frequency
  422. indexItem.Sort = sort
  423. indexItem.Unit = unit
  424. indexItem.ExcelDataMap = make(map[string]string)
  425. sort++
  426. }
  427. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  428. indexItem.ExcelDataMap[date] = text
  429. indexMap[fullIndexName] = indexItem
  430. continue
  431. }
  432. }
  433. }
  434. for _, v := range indexMap {
  435. indexList = append(indexList, v)
  436. }
  437. return
  438. }
  439. // HandleYongyiExcelWeekly25 周度-猪肉产品价格
  440. func HandleYongyiExcelWeekly25(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  441. defer func() {
  442. if err != nil {
  443. //fmt.Printf("HandleYongyiExcelWeekly25 周度-猪肉产品价格 ErrMsg: %s\n", err.Error())
  444. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly25 周度-猪肉产品价格 ErrMsg: %s", err.Error()))
  445. }
  446. }()
  447. rows, e := f.GetRows(sheetName)
  448. if e != nil {
  449. err = fmt.Errorf("f GetRows err: %s", e.Error())
  450. return
  451. }
  452. // 获取指标分类
  453. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  454. // 遍历行读取
  455. indexList = make([]*models.YongyiExcelIndex, 0)
  456. provinceMap := make(map[int]string)
  457. sort := 0
  458. fmt.Println("最大行")
  459. // 指标名称
  460. indexMap := make(map[string]*models.YongyiExcelIndex)
  461. for i, row := range rows {
  462. //fmt.Printf("当前第%d行 \n", i)
  463. if i == 0 {
  464. continue
  465. } else if i == 1 { //表示表头
  466. // 处理 index指标表
  467. for k, text := range row {
  468. if text != "" {
  469. text = strings.TrimSpace(text)
  470. provinceMap[k] = text
  471. }
  472. }
  473. } else { //数据列
  474. date := ""
  475. name := ""
  476. for k, text := range row {
  477. //fmt.Printf("当前第%d列 \n", k)
  478. if k == 0 {
  479. continue
  480. } else if k == 1 {
  481. text = strings.TrimSpace(text)
  482. dateSlice := strings.Split(text, "(")
  483. if len(dateSlice) > 1 {
  484. text = dateSlice[0]
  485. }
  486. var dateT time.Time
  487. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  488. if e != nil {
  489. dateT, e = time.ParseInLocation("01-02-06", text, time.Local)
  490. if e != nil {
  491. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  492. continue
  493. }
  494. }
  495. date = dateT.Format(utils.FormatDate)
  496. fmt.Println(date)
  497. continue
  498. } else if k == 2 {
  499. name = text
  500. continue
  501. } else {
  502. // 判断出不是字符的,则过滤
  503. if text == "" {
  504. continue
  505. }
  506. if strings.Contains(text, "%") {
  507. text = strings.Replace(text, "%", "", 1)
  508. }
  509. _, e := strconv.ParseFloat(text, 64)
  510. if e != nil {
  511. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  512. continue
  513. }
  514. }
  515. province, ok2 := provinceMap[k]
  516. if !ok2 {
  517. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  518. return
  519. }
  520. if strings.Contains(name, "二元母猪价") {
  521. continue
  522. }
  523. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, province)
  524. // 处理指标名称
  525. fullIndexName := fmt.Sprintf("%s/%s/%s", namePrefix, name, province)
  526. provincePingyin := utils.GetFullPingYin(province)
  527. namePingin := utils.GetFirstPingYin(name)
  528. fullIndexNamePingyin := namePrefixPingin + namePingin + provincePingyin
  529. if strings.Contains(name, "二元母猪价") {
  530. fullIndexName = fmt.Sprintf("%s/%s", name, province)
  531. fullIndexNamePingyin = "yyzx" + namePingin + provincePingyin
  532. }
  533. indexItem, okIndex := indexMap[fullIndexName]
  534. if !okIndex {
  535. // 新增指标
  536. indexItem = new(models.YongyiExcelIndex)
  537. indexItem.IndexName = fullIndexName
  538. indexItem.ClassifyName = classifyName
  539. indexItem.ClassifySort = classifySort
  540. indexItem.IndexCode = fullIndexNamePingyin
  541. indexItem.Frequency = frequency
  542. indexItem.Sort = sort
  543. indexItem.Unit = unit
  544. indexItem.ExcelDataMap = make(map[string]string)
  545. sort++
  546. }
  547. indexItem.ExcelDataMap[date] = text
  548. indexMap[fullIndexName] = indexItem
  549. continue
  550. }
  551. }
  552. }
  553. for _, v := range indexMap {
  554. //fmt.Printf("IndexName: %s \n", v.IndexName)
  555. //fmt.Printf("IndexCode: %s \n", v.IndexCode)
  556. indexList = append(indexList, v)
  557. }
  558. return
  559. }
  560. // HandleYongyiExcelWeekly26 周度-淘汰母猪价格
  561. func HandleYongyiExcelWeekly26(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  562. defer func() {
  563. if err != nil {
  564. //fmt.Printf("HandleYongyiExcelWeekly26 周度-屠宰企业日度屠宰量 ErrMsg: %s\n", err.Error())
  565. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly26 周度-屠宰企业日度屠宰量 ErrMsg: %s", err.Error()))
  566. }
  567. }()
  568. rows, e := f.GetRows(sheetName)
  569. if e != nil {
  570. err = fmt.Errorf("f GetRows err: %s", e.Error())
  571. return
  572. }
  573. // 获取指标分类
  574. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  575. // 遍历行读取
  576. indexList = make([]*models.YongyiExcelIndex, 0)
  577. provinceMap := make(map[int]string)
  578. sort := 0
  579. fmt.Println("最大行")
  580. // 指标名称
  581. indexMap := make(map[string]*models.YongyiExcelIndex)
  582. for i, row := range rows {
  583. //fmt.Printf("当前第%d行 \n", i)
  584. if i == 0 { //表示表头
  585. // 处理 index指标表
  586. for k, text := range row {
  587. if text != "" {
  588. text = strings.TrimSpace(text)
  589. provinceMap[k] = text
  590. }
  591. }
  592. } else { //数据列
  593. date := ""
  594. for k, text := range row {
  595. //fmt.Printf("当前第%d列 \n", k)
  596. if k == 0 {
  597. text = strings.TrimSpace(text)
  598. var dateT time.Time
  599. dateT, e = time.ParseInLocation("2006/1/2", text, time.Local)
  600. if e != nil {
  601. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  602. continue
  603. }
  604. date = dateT.Format(utils.FormatDate)
  605. fmt.Println(date)
  606. continue
  607. } else {
  608. // 判断出不是字符的,则过滤
  609. if text == "" {
  610. continue
  611. }
  612. if strings.Contains(text, "%") {
  613. text = strings.Replace(text, "%", "", 1)
  614. }
  615. _, e := strconv.ParseFloat(text, 64)
  616. if e != nil {
  617. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  618. continue
  619. }
  620. }
  621. province, ok2 := provinceMap[k]
  622. if !ok2 {
  623. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  624. return
  625. }
  626. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, province)
  627. // 处理指标名称
  628. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, province)
  629. provincePingyin := utils.GetFullPingYin(province)
  630. fullIndexNamePingyin := namePrefixPingin + provincePingyin
  631. if strings.Contains(province, "合计") {
  632. province = "合计"
  633. fullIndexName = fmt.Sprintf("%s/%s", namePrefix, province)
  634. provincePingyin = utils.GetFirstPingYin(province)
  635. fullIndexNamePingyin = namePrefixPingin + provincePingyin
  636. }
  637. indexItem, okIndex := indexMap[fullIndexName]
  638. if !okIndex {
  639. // 新增指标
  640. indexItem = new(models.YongyiExcelIndex)
  641. indexItem.IndexName = fullIndexName
  642. indexItem.ClassifyName = classifyName
  643. indexItem.ClassifySort = classifySort
  644. indexItem.IndexCode = fullIndexNamePingyin
  645. indexItem.Frequency = frequency
  646. indexItem.Sort = sort
  647. indexItem.Unit = unit
  648. indexItem.ExcelDataMap = make(map[string]string)
  649. sort++
  650. }
  651. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  652. indexItem.ExcelDataMap[date] = text
  653. indexMap[fullIndexName] = indexItem
  654. continue
  655. }
  656. }
  657. }
  658. for _, v := range indexMap {
  659. indexList = append(indexList, v)
  660. }
  661. return
  662. }
  663. // HandleYongyiExcelWeekly27 周度-屠宰新2022.10.28
  664. func HandleYongyiExcelWeekly27(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  665. defer func() {
  666. if err != nil {
  667. //fmt.Printf("HandleYongyiExcelWeekly27 周度-屠宰新2022.10.28 ErrMsg: %s\n", err.Error())
  668. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly27 周度-屠宰新2022.10.28 ErrMsg: %s", err.Error()))
  669. }
  670. }()
  671. rows, e := f.GetRows(sheetName)
  672. if e != nil {
  673. err = fmt.Errorf("f GetRows err: %s", e.Error())
  674. return
  675. }
  676. // 获取指标分类
  677. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  678. // 遍历行读取
  679. indexList = make([]*models.YongyiExcelIndex, 0)
  680. nameMap := make(map[int]string)
  681. sort := 0
  682. fmt.Println("最大行")
  683. // 指标名称
  684. indexMap := make(map[string]*models.YongyiExcelIndex)
  685. for i, row := range rows {
  686. //fmt.Printf("当前第%d行 \n", i)
  687. if i == 0 {
  688. continue
  689. } else if i == 1 { //表示表头
  690. // 处理 index指标表
  691. for k, text := range row {
  692. if text != "" {
  693. text = strings.TrimSpace(text)
  694. nameMap[k] = text
  695. }
  696. }
  697. } else { //数据列
  698. date := ""
  699. for k, text := range row {
  700. //fmt.Printf("当前第%d列 \n", k)
  701. if k == 0 {
  702. continue
  703. } else if k == 1 {
  704. text = strings.TrimSpace(text)
  705. var dateT time.Time
  706. //判断是否是数字,如果是数字,另外单独处理
  707. if dateFloat, e := strconv.ParseFloat(text, 64); e == nil {
  708. dateT, e = excelize.ExcelDateToTime(dateFloat, false)
  709. if e != nil {
  710. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  711. continue
  712. }
  713. } else {
  714. dateT, e = time.ParseInLocation("2006年1月2日", text, time.Local)
  715. if e != nil {
  716. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  717. continue
  718. }
  719. }
  720. date = dateT.Format(utils.FormatDate)
  721. fmt.Println(date)
  722. continue
  723. } else {
  724. // 判断出不是字符的,则过滤
  725. if text == "" {
  726. continue
  727. }
  728. if strings.Contains(text, "%") {
  729. text = strings.Replace(text, "%", "", 1)
  730. }
  731. _, e := strconv.ParseFloat(text, 64)
  732. if e != nil {
  733. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  734. continue
  735. }
  736. }
  737. name, ok2 := nameMap[k]
  738. if !ok2 {
  739. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  740. return
  741. }
  742. if name != "规模屠宰厂全国前10家" && name != "各省规模屠宰厂100家" && name != "县区+乡镇宰杀 70家" {
  743. continue
  744. }
  745. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, name)
  746. // 处理指标名称不同规模屠宰厂宰杀量/县区+乡镇宰杀 70家
  747. name = strings.Replace(name, " ", "", -1)
  748. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, name)
  749. namePingin := utils.GetFirstPingYin(name)
  750. fullIndexNamePingyin := namePrefixPingin + namePingin
  751. indexItem, okIndex := indexMap[fullIndexName]
  752. if !okIndex {
  753. // 新增指标
  754. indexItem = new(models.YongyiExcelIndex)
  755. indexItem.IndexName = fullIndexName
  756. indexItem.ClassifyName = classifyName
  757. indexItem.ClassifySort = classifySort
  758. indexItem.IndexCode = fullIndexNamePingyin
  759. indexItem.Frequency = frequency
  760. indexItem.Sort = sort
  761. indexItem.Unit = unit
  762. indexItem.ExcelDataMap = make(map[string]string)
  763. sort++
  764. }
  765. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  766. indexItem.ExcelDataMap[date] = text
  767. indexMap[fullIndexName] = indexItem
  768. continue
  769. }
  770. }
  771. }
  772. for _, v := range indexMap {
  773. indexList = append(indexList, v)
  774. }
  775. return
  776. }
  777. // HandleYongyiExcelWeekly28 月度-淘汰母猪屠宰厂宰杀量
  778. func HandleYongyiExcelWeekly28(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  779. defer func() {
  780. if err != nil {
  781. //fmt.Printf("HandleYongyiExcelWeekly28 月度-淘汰母猪屠宰厂宰杀量 ErrMsg: %s\n", err.Error())
  782. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly28 月度-淘汰母猪屠宰厂宰杀量 ErrMsg: %s", err.Error()))
  783. }
  784. }()
  785. rows, e := f.GetRows(sheetName)
  786. if e != nil {
  787. err = fmt.Errorf("f GetRows err: %s", e.Error())
  788. return
  789. }
  790. // 获取指标分类
  791. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  792. // 遍历行读取
  793. indexList = make([]*models.YongyiExcelIndex, 0)
  794. provinceMap := make(map[int]string)
  795. nameMap := make(map[int]string)
  796. sort := 0
  797. fmt.Println("最大行")
  798. // 指标名称
  799. indexMap := make(map[string]*models.YongyiExcelIndex)
  800. mergeCellMap, err := GetMergeCells(f, sheetName)
  801. if err != nil {
  802. err = fmt.Errorf("获取合并单元格失败, sheetName: %s", sheetName)
  803. return
  804. }
  805. for i, row := range rows {
  806. //fmt.Printf("当前第%d行 \n", i)
  807. currentMergeCells, mergeOk := mergeCellMap[i]
  808. if i == 0 { //表示表头
  809. // 处理 index指标表
  810. for k, text := range row {
  811. if text != "" {
  812. text = strings.TrimSpace(text)
  813. if mergeOk {
  814. for j, v := range currentMergeCells {
  815. provinceMap[j] = v
  816. nameMap[j] = v
  817. }
  818. }
  819. provinceMap[k] = text
  820. }
  821. }
  822. } else if i == 1 { //表示表头
  823. // 处理 index指标表
  824. for k, text := range row {
  825. if text != "" {
  826. text = strings.TrimSpace(text)
  827. nameMap[k] = text
  828. }
  829. }
  830. } else { //数据列
  831. date := ""
  832. for k, text := range row {
  833. //fmt.Printf("当前第%d列 \n", k)
  834. if k == 0 {
  835. text = strings.TrimSpace(text)
  836. var dateT time.Time
  837. dateT, e = time.ParseInLocation("2006年1月", text, time.Local)
  838. if e != nil {
  839. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  840. continue
  841. }
  842. // 查询当月的最后一天
  843. monthDate := dateT.Format(utils.FormatYearMonthDate)
  844. firstDayStr := monthDate + "-01"
  845. tmpT, _ := time.ParseInLocation(utils.FormatDate, firstDayStr, time.Local)
  846. date = tmpT.AddDate(0, 1, -1).Format(utils.FormatDate)
  847. fmt.Println(date)
  848. continue
  849. } else if k == 1 {
  850. continue
  851. } else {
  852. // 判断出不是字符的,则过滤
  853. if text == "" {
  854. continue
  855. }
  856. if strings.Contains(text, "%") {
  857. text = strings.Replace(text, "%", "", 1)
  858. }
  859. _, e := strconv.ParseFloat(text, 64)
  860. if e != nil {
  861. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  862. continue
  863. }
  864. }
  865. province, ok2 := provinceMap[k]
  866. if !ok2 {
  867. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  868. return
  869. }
  870. name, ok1 := nameMap[k]
  871. if !ok1 {
  872. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  873. return
  874. }
  875. if strings.Contains(name, "环比") {
  876. continue
  877. }
  878. //fmt.Printf("当前第%d行第%d列, 当前省份: %s \n", i, k, province)
  879. // 处理指标名称
  880. fullIndexName := fmt.Sprintf("%s/%s%s", namePrefix, province, name)
  881. provincePingyin := utils.GetFullPingYin(province)
  882. namePingin := utils.GetFirstPingYin(name)
  883. fullIndexNamePingyin := namePrefixPingin + provincePingyin + namePingin
  884. indexItem, okIndex := indexMap[fullIndexName]
  885. if !okIndex {
  886. // 新增指标
  887. indexItem = new(models.YongyiExcelIndex)
  888. indexItem.IndexName = fullIndexName
  889. indexItem.ClassifyName = classifyName
  890. indexItem.ClassifySort = classifySort
  891. indexItem.IndexCode = fullIndexNamePingyin
  892. indexItem.Frequency = frequency
  893. indexItem.Sort = sort
  894. indexItem.Unit = unit
  895. indexItem.ExcelDataMap = make(map[string]string)
  896. sort++
  897. }
  898. //fmt.Printf("IndexCode: %s\n", indexItem.IndexCode)
  899. indexItem.ExcelDataMap[date] = text
  900. indexMap[fullIndexName] = indexItem
  901. continue
  902. }
  903. }
  904. }
  905. for _, v := range indexMap {
  906. indexList = append(indexList, v)
  907. }
  908. return
  909. }
  910. // HandleYongyiExcelWeekly29 月度-猪料销量
  911. func HandleYongyiExcelWeekly29(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  912. defer func() {
  913. if err != nil {
  914. //fmt.Printf("HandleYongyiExcelWeekly29 月度-猪料销量 ErrMsg: %s\n", err.Error())
  915. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly29 月度-猪料销量 ErrMsg: %s", err.Error()))
  916. }
  917. }()
  918. rows, e := f.GetRows(sheetName)
  919. if e != nil {
  920. err = fmt.Errorf("f GetRows err: %s", e.Error())
  921. return
  922. }
  923. // 获取指标分类
  924. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  925. // 遍历行读取
  926. indexList = make([]*models.YongyiExcelIndex, 0)
  927. nameMap := make(map[int]string)
  928. sort := 0
  929. fmt.Println("最大行")
  930. // 指标名称
  931. indexMap := make(map[string]*models.YongyiExcelIndex)
  932. for i, row := range rows {
  933. //fmt.Printf("当前第%d行 \n", i)
  934. if i == 0 {
  935. continue
  936. } else if i == 1 { //表示表头
  937. // 处理 index指标表
  938. for k, text := range row {
  939. if text != "" {
  940. text = strings.TrimSpace(text)
  941. nameMap[k] = text
  942. }
  943. }
  944. } else { //数据列
  945. date := ""
  946. for k, text := range row {
  947. //fmt.Printf("当前第%d列 \n", k)
  948. if k == 0 {
  949. text = strings.TrimSpace(text)
  950. var dateT time.Time
  951. //判断是否是数字,如果是数字,另外单独处理
  952. if dateFloat, e := strconv.ParseFloat(text, 64); e == nil {
  953. dateT, e = excelize.ExcelDateToTime(dateFloat, false)
  954. if e != nil {
  955. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  956. continue
  957. }
  958. } else {
  959. dateT, e = time.ParseInLocation("2006年1月", text, time.Local)
  960. if e != nil {
  961. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  962. continue
  963. }
  964. }
  965. // 查询当月的最后一天
  966. monthDate := dateT.Format(utils.FormatYearMonthDate)
  967. firstDayStr := monthDate + "-01"
  968. tmpT, _ := time.ParseInLocation(utils.FormatDate, firstDayStr, time.Local)
  969. date = tmpT.AddDate(0, 1, -1).Format(utils.FormatDate)
  970. fmt.Println(date)
  971. continue
  972. } else {
  973. // 判断出不是字符的,则过滤
  974. if text == "" {
  975. continue
  976. }
  977. if strings.Contains(text, "%") {
  978. text = strings.Replace(text, "%", "", 1)
  979. }
  980. _, e := strconv.ParseFloat(text, 64)
  981. if e != nil {
  982. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  983. continue
  984. }
  985. }
  986. name, ok2 := nameMap[k]
  987. if !ok2 {
  988. err = fmt.Errorf("找不到对应的列名,第%d行,第%d列", i, k)
  989. return
  990. }
  991. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, name)
  992. fullIndexName := fmt.Sprintf("%s/%s", namePrefix, name)
  993. namePingin := utils.GetFirstPingYin(name)
  994. fullIndexNamePingyin := namePrefixPingin + namePingin
  995. indexItem, okIndex := indexMap[fullIndexName]
  996. if !okIndex {
  997. // 新增指标
  998. indexItem = new(models.YongyiExcelIndex)
  999. indexItem.IndexName = fullIndexName
  1000. indexItem.ClassifyName = classifyName
  1001. indexItem.ClassifySort = classifySort
  1002. indexItem.IndexCode = fullIndexNamePingyin
  1003. indexItem.Frequency = frequency
  1004. indexItem.Sort = sort
  1005. indexItem.Unit = unit
  1006. indexItem.ExcelDataMap = make(map[string]string)
  1007. sort++
  1008. }
  1009. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  1010. indexItem.ExcelDataMap[date] = text
  1011. indexMap[fullIndexName] = indexItem
  1012. continue
  1013. }
  1014. }
  1015. }
  1016. for _, v := range indexMap {
  1017. indexList = append(indexList, v)
  1018. }
  1019. return
  1020. }
  1021. // HandleYongyiExcelWeekly30 月度-屠宰企业开工率
  1022. func HandleYongyiExcelWeekly30(f *excelize.File, sheetName string) (indexList []*models.YongyiExcelIndex, err error) {
  1023. defer func() {
  1024. if err != nil {
  1025. //fmt.Printf("HandleYongyiExcelWeekly30 月度-屠宰企业开工率 ErrMsg: %s\n", err.Error())
  1026. utils.FileLog.Info(fmt.Sprintf("HandleYongyiExcelWeekly30 月度-屠宰企业开工率 ErrMsg: %s", err.Error()))
  1027. }
  1028. }()
  1029. rows, e := f.GetRows(sheetName)
  1030. if e != nil {
  1031. err = fmt.Errorf("f GetRows err: %s", e.Error())
  1032. return
  1033. }
  1034. // 获取指标分类
  1035. classifyName, classifySort, frequency, unit, namePrefix, namePrefixPingin := GetBaseInfo(sheetName)
  1036. // 遍历行读取
  1037. indexList = make([]*models.YongyiExcelIndex, 0)
  1038. sort := 0
  1039. fmt.Println("最大行")
  1040. // 指标名称
  1041. indexMap := make(map[string]*models.YongyiExcelIndex)
  1042. for i, row := range rows {
  1043. //fmt.Printf("当前第%d行 \n", i)
  1044. if i > 0 { //数据列
  1045. date := ""
  1046. for k, text := range row {
  1047. //fmt.Printf("当前第%d列 \n", k)
  1048. if k == 0 {
  1049. text = strings.TrimSpace(text)
  1050. var dateT time.Time
  1051. dateT, e = time.ParseInLocation("2006年1月", text, time.Local)
  1052. if e != nil {
  1053. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 读取行,时间列失败 Err:%s", sheetName, i, k, e))
  1054. continue
  1055. }
  1056. // 查询当月的最后一天
  1057. monthDate := dateT.Format(utils.FormatYearMonthDate)
  1058. firstDayStr := monthDate + "-01"
  1059. tmpT, _ := time.ParseInLocation(utils.FormatDate, firstDayStr, time.Local)
  1060. date = tmpT.AddDate(0, 1, -1).Format(utils.FormatDate)
  1061. fmt.Println(date)
  1062. continue
  1063. } else {
  1064. // 判断出不是字符的,则过滤
  1065. if text == "" {
  1066. continue
  1067. }
  1068. if strings.Contains(text, "%") {
  1069. text = strings.Replace(text, "%", "", 1)
  1070. }
  1071. _, e := strconv.ParseFloat(text, 64)
  1072. if e != nil {
  1073. utils.FileLog.Info(fmt.Sprintf("sheet:%s 第%d行, 第%d列 strconv.ParseFloat Err:%s", sheetName, i, k, e))
  1074. continue
  1075. }
  1076. }
  1077. name := "屠宰企业开工率全国平均"
  1078. //fmt.Printf("当前第%d行第%d列, 当前省份%s \n", i, k, name)
  1079. fullIndexName := fmt.Sprintf("%s%s", namePrefix, name)
  1080. namePingin := utils.GetFirstPingYin(name)
  1081. fullIndexNamePingyin := namePrefixPingin + namePingin
  1082. indexItem, okIndex := indexMap[fullIndexName]
  1083. if !okIndex {
  1084. // 新增指标
  1085. indexItem = new(models.YongyiExcelIndex)
  1086. indexItem.IndexName = fullIndexName
  1087. indexItem.ClassifyName = classifyName
  1088. indexItem.ClassifySort = classifySort
  1089. indexItem.IndexCode = fullIndexNamePingyin
  1090. indexItem.Frequency = frequency
  1091. indexItem.Sort = sort
  1092. indexItem.Unit = unit
  1093. indexItem.ExcelDataMap = make(map[string]string)
  1094. sort++
  1095. }
  1096. //fmt.Printf("IndexCode: %s", indexItem.IndexCode)
  1097. indexItem.ExcelDataMap[date] = text
  1098. indexMap[fullIndexName] = indexItem
  1099. continue
  1100. }
  1101. }
  1102. }
  1103. for _, v := range indexMap {
  1104. indexList = append(indexList, v)
  1105. }
  1106. return
  1107. }