inventoryController.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. package controller
  2. import (
  3. "bswas/utilities"
  4. )
  5. func InventoryFormat(data []map[string]string, requestType bool) ([]interface{}, [][]interface{}) {
  6. row := []interface{}{
  7. "货主","库位","产品编码","产品条码","商品名称","属性仓 ","质量状态","失效日期","批号",
  8. }
  9. if requestType == true {
  10. row = append(row,"移出数量","移入数量")
  11. }
  12. row = append(row,"在库数量","占用数量")
  13. list := make([][]interface{},len(data))
  14. for k,v := range data{
  15. line := make([]interface{},len(row))
  16. for index,column := range row {
  17. line[index] = v[column.(string)]
  18. }
  19. list[k] = line
  20. }
  21. return row, list
  22. }
  23. func InventoryAccountMissionFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  24. row := []interface{}{
  25. "库位","产品名","商品条码","商品编码","生产日期","失效日期","批号","盘点人","ERP属性仓","质量状态","库存数量",
  26. "可用数量","盘点数量","复盘数量","复盘差异","分配数量","状态",
  27. }
  28. column := map[string]int{
  29. "location" : 0,
  30. "commodity_name" : 1,
  31. "commodity_barcode" : 2,
  32. "commodity_sku" : 3,
  33. "produced_at" : 4,
  34. "valid_at" : 5,
  35. "batch_number" : 6,
  36. "stock_person" : 7,
  37. "erp_type_position" : 8,
  38. "quality" : 9,
  39. "stored_amount" : 10,
  40. "valid_amount" : 11,
  41. "verified_amount" : 12,
  42. "re_checked_amount" : 13,
  43. "difference_amount" : 14,
  44. "occupied_amount" : 15,
  45. "mark" : 16,
  46. }
  47. list := make([][]interface{},len(data))
  48. for k,v := range data{
  49. line := make([]interface{},len(row))
  50. for key,value := range column {
  51. if key == "produced_at"{
  52. line[value] = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z")
  53. continue
  54. }
  55. if key == "valid_at"{
  56. line[value] = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z")
  57. continue
  58. }
  59. line[value] = v[key]
  60. }
  61. list[k] = line
  62. }
  63. return row, list
  64. }
  65. func InventoryCompareFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  66. row := []interface{}{
  67. "货主","任务号","生产时间","商品名称","商品编码","商品条码","属性仓","质量状态","宝时库存","参考库存","差值",
  68. }
  69. column := map[string]int{
  70. "owner_name" : 0,
  71. "mission_code" : 1,
  72. "created_at" : 2,
  73. "commodity_name" : 3,
  74. "commodity_sku" : 4,
  75. "commodity_barcode_code" : 5,
  76. "custom_location" : 6,
  77. "quality" : 7,
  78. "amount_in_sys" : 8,
  79. "amount_in_compare" : 9,
  80. "differ" : 10,
  81. }
  82. list := make([][]interface{},len(data))
  83. for k,v := range data{
  84. line := make([]interface{},len(row))
  85. for key,value := range column {
  86. if key == "created_at" {
  87. line[value] = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z")
  88. continue
  89. }
  90. line[value] = v[key]
  91. }
  92. list[k] = line
  93. }
  94. return row, list
  95. }