inventoryController.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. line[value] = v[key]
  52. }
  53. list[k] = line
  54. }
  55. return row, list
  56. }
  57. func InventoryCompareFormat(data []map[string]string) ([]interface{}, [][]interface{}) {
  58. row := []interface{}{
  59. "货主","任务号","生产时间","商品名称","商品编码","商品条码","属性仓","质量状态","宝时库存","参考库存","差值",
  60. }
  61. column := map[string]int{
  62. "owner_name" : 0,
  63. "mission_code" : 1,
  64. "created_at" : 2,
  65. "commodity_name" : 3,
  66. "commodity_sku" : 4,
  67. "commodity_barcode_code" : 5,
  68. "custom_location" : 6,
  69. "quality" : 7,
  70. "amount_in_sys" : 8,
  71. "amount_in_compare" : 9,
  72. "differ" : 10,
  73. }
  74. list := make([][]interface{},len(data))
  75. for k,v := range data{
  76. line := make([]interface{},len(row))
  77. for key,value := range column {
  78. if key == "created_at" {
  79. line[value] = utilities.DateFormat(v[key],"2006-01-02T15:04:05Z")
  80. continue
  81. }
  82. line[value] = v[key]
  83. }
  84. list[k] = line
  85. }
  86. return row, list
  87. }