面包店
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 7 mēnešiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package hdl
  2. import (
  3. "applet/app/admin/md"
  4. "applet/app/admin/svc"
  5. "applet/app/bigData/lib/validate"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "fmt"
  9. "github.com/gin-gonic/gin"
  10. "os"
  11. )
  12. func DataStatisticsList(c *gin.Context) {
  13. var req md.ExportRecordsListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. if req.Limit == 0 {
  22. req.Limit = 10
  23. }
  24. if req.Page == 0 {
  25. req.Page = 10
  26. }
  27. exportRecordsDb := db.ExportRecordsDb{}
  28. exportRecordsDb.Set()
  29. list, total, err := exportRecordsDb.ExportRecordsExportRecordsList(req)
  30. if err != nil {
  31. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  32. return
  33. }
  34. e.OutSuc(c, map[string]interface{}{
  35. "list": list,
  36. "total": total,
  37. "kind": []map[string]interface{}{
  38. {
  39. "name": "商品销售明细表",
  40. "value": 1,
  41. },
  42. {
  43. "name": "对账单",
  44. "value": 2,
  45. },
  46. },
  47. }, nil)
  48. return
  49. }
  50. func DataStatisticsDelete(c *gin.Context) {
  51. var req struct {
  52. Ids []int `json:"ids"`
  53. }
  54. err := c.ShouldBindJSON(&req)
  55. if err != nil {
  56. err = validate.HandleValidateErr(err)
  57. err1 := err.(e.E)
  58. e.OutErr(c, err1.Code, err1.Error())
  59. return
  60. }
  61. for _, id := range req.Ids {
  62. exportRecordsDb := db.ExportRecordsDb{}
  63. exportRecordsDb.Set()
  64. exportRecords, err1 := exportRecordsDb.GetExportRecordsExportRecords(id)
  65. if err1 != nil {
  66. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  67. return
  68. }
  69. if exportRecords == nil {
  70. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  71. return
  72. }
  73. err = os.RemoveAll("./data/export/" + exportRecords.DownloadPath) //移除文件
  74. if err != nil {
  75. fmt.Println("err>>>>>>>>>>>>>>", err.Error())
  76. }
  77. _, err2 := exportRecordsDb.ExportRecordsExportRecordsDelete(id)
  78. if err2 != nil {
  79. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  80. return
  81. }
  82. }
  83. e.OutSuc(c, "success", nil)
  84. return
  85. }
  86. func DataStatisticsExport(c *gin.Context) {
  87. var req md.DataStatisticsExportReq
  88. err := c.ShouldBindJSON(&req)
  89. if err != nil {
  90. err = validate.HandleValidateErr(err)
  91. err1 := err.(e.E)
  92. e.OutErr(c, err1.Code, err1.Error())
  93. return
  94. }
  95. if req.EnterpriseId != 0 {
  96. enterpriseDb := db.EnterpriseDb{}
  97. enterpriseDb.Set()
  98. enterprise, err1 := enterpriseDb.GetEnterprise(req.EnterpriseId)
  99. if err1 != nil {
  100. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  101. return
  102. }
  103. req.EnterpriseName = enterprise.Name
  104. }
  105. go svc.DataStatisticsExport(req)
  106. e.OutSuc(c, map[string]interface{}{
  107. "msg": "导出成功,请稍后刷新数据列表",
  108. }, nil)
  109. return
  110. }