ERP.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package controllers
  2. import (
  3. "ColdVerify_server/lib"
  4. "ColdVerify_server/models/Account"
  5. "ColdVerify_server/models/Distributor"
  6. "ColdVerify_server/models/Task"
  7. )
  8. // 获取管理员 关联ERP
  9. func (c *AccountController) Account_List_All_For_ERP() {
  10. PowerList := Account.Read_Power_List_ALL_1()
  11. PowerMap := Account.UserPowerListToPowerMap(PowerList)
  12. T_name := c.GetString("T_name")
  13. var r_jsons lib.R_JSONS
  14. r_jsons.List = Account.Read_Admin_List_ALL_Power("", T_name, PowerMap)
  15. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
  16. c.ServeJSON()
  17. return
  18. }
  19. // 获取公司列表
  20. func (c *UserController) User_List_All_For_ERP() {
  21. T_name := c.GetString("T_name")
  22. CreateDate := c.GetString("CreateDate")
  23. if len(CreateDate) > 0 && !lib.IsDateStr(CreateDate) {
  24. c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
  25. c.ServeJSON()
  26. return
  27. }
  28. distributorList := Distributor.Read_Distributor_List_ALL("")
  29. distributorMap := Distributor.DistributorListToMap(distributorList)
  30. List, _ := Account.List_All_For_ERP(T_name, CreateDate, distributorMap)
  31. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: List}
  32. c.ServeJSON()
  33. return
  34. }
  35. func (c *TaskController) Task_List_All_For_ERP() {
  36. start_time := c.GetString("T_reporting_pass_start_time")
  37. end_time := c.GetString("T_reporting_pass_end_time")
  38. if _, is := lib.TimeStrToTime(start_time); !is {
  39. c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间格式错误!"}
  40. c.ServeJSON()
  41. return
  42. }
  43. if _, is := lib.TimeStrToTime(end_time); !is {
  44. c.Data["json"] = lib.JSONS{Code: 202, Msg: "结束时间格式错误!"}
  45. c.ServeJSON()
  46. return
  47. }
  48. List, _ := Task.Read_Task_List_For_ERP(start_time, end_time)
  49. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: List}
  50. c.ServeJSON()
  51. return
  52. }
  53. func (c *TaskController) Task_List2_All_For_ERP() {
  54. T_type := c.GetString("T_type")
  55. if T_type != "collection" && T_type != "reporting" {
  56. c.Data["json"] = lib.JSONS{Code: 202, Msg: "类型错误!"}
  57. c.ServeJSON()
  58. return
  59. }
  60. start_time := c.GetString("T_start_time")
  61. end_time := c.GetString("T_end_time")
  62. if _, is := lib.TimeStrToTime(start_time); !is {
  63. c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间格式错误!"}
  64. c.ServeJSON()
  65. return
  66. }
  67. if _, is := lib.TimeStrToTime(end_time); !is {
  68. c.Data["json"] = lib.JSONS{Code: 202, Msg: "结束时间格式错误!"}
  69. c.ServeJSON()
  70. return
  71. }
  72. var List []Task.Task_
  73. if T_type == "collection" {
  74. List, _ = Task.Read_Task_List_For_ERP_By_Type(T_type, start_time, end_time)
  75. }
  76. if T_type == "reporting" {
  77. List, _ = Task.Read_Task_List_For_ERP_By_Type(T_type, start_time, end_time)
  78. }
  79. c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: List}
  80. c.ServeJSON()
  81. return
  82. }