fill_data.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. package controller
  2. import (
  3. "gas-cylinder-api/app/admin/model"
  4. "gas-cylinder-api/app/admin/service"
  5. "gas-cylinder-api/app/admin/service/dto"
  6. "gas-cylinder-api/common/actions"
  7. "github.com/gin-gonic/gin"
  8. "github.com/gin-gonic/gin/binding"
  9. "gogs.baozhida.cn/zoie/OAuth-core/api"
  10. _ "gogs.baozhida.cn/zoie/OAuth-core/pkg/response"
  11. )
  12. type FillDataController struct {
  13. api.Api
  14. }
  15. // GetPage 获取上报实时充装数据
  16. // @Summary 获取上报实时充装数据
  17. // @Description 获取上报实时充装数据
  18. // @Tags 上报实时充装数据
  19. // @Param stationId query string false "气站id"
  20. // @Param userId query string false "充装人员id"
  21. // @Param innerCode query string false "气瓶单位内编码"
  22. // @Param chipId query string false "高频编码"
  23. // @Param startFillTime query string false "充装开始时间"
  24. // @Param endFillTime query string false "充装结束时间"
  25. // @Param pageSize query int false "页条数"
  26. // @Param page query int false "页码"
  27. // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillData}} "{"code": 200, "data": [...]}"
  28. // @Router /api/goods [get]
  29. // @Security Bearer
  30. func (e FillDataController) GetPage(c *gin.Context) {
  31. s := service.FillData{}
  32. req := dto.FillDataGetPageReq{}
  33. err := e.MakeContext(c).
  34. MakeOrm().
  35. Bind(&req, binding.Query).
  36. MakeService(&s.Service).
  37. Errors
  38. if err != nil {
  39. e.Logger.Error(err)
  40. e.Error(500, err, err.Error())
  41. return
  42. }
  43. //数据权限检查
  44. p := actions.GetPermissionFromContext(c)
  45. list := make([]model.FillData, 0)
  46. var count int64
  47. err = s.GetPage(&req, &list, &count, p)
  48. if err != nil {
  49. e.Error(500, err, err.Error())
  50. return
  51. }
  52. e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
  53. }
  54. // Insert 添加上报实时充装数据
  55. // @Summary 添加上报实时充装数据
  56. // @Description 添加上报实时充装数据
  57. // @Tags 上报实时充装数据
  58. // @Accept application/json
  59. // @Product application/json
  60. // @Param data body dto.FillDataInsertReq true "data"
  61. // @Success 200 {string} string "{"code": 200, "message": "添加成功"}"
  62. // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
  63. // @Router /api/goods [post]
  64. // @Security Bearer
  65. func (e FillDataController) Insert(c *gin.Context) {
  66. s := service.FillData{}
  67. fillGunSvc := service.FillGun{}
  68. req := dto.FillDataInsertReq{}
  69. err := e.MakeContext(c).
  70. MakeOrm().
  71. Bind(&req, binding.JSON).
  72. MakeService(&s.Service).
  73. MakeService(&fillGunSvc.Service).
  74. Errors
  75. if err != nil {
  76. e.Logger.Error(err)
  77. e.Error(500, err, err.Error())
  78. return
  79. }
  80. // 设置创建人
  81. //p := actions.GetPermissionFromContext(c)
  82. //req.SetCreateBy(user.GetUserId(c))
  83. //req.SetDeptId(p.DeptId)
  84. // 获取充装枪信息
  85. var fillGun model.FillGun
  86. err = fillGunSvc.GetByCode(req.ScanGunCode, &fillGun)
  87. if err != nil {
  88. e.Error(500, err, err.Error())
  89. return
  90. }
  91. err = s.Insert(&req, fillGun)
  92. if err != nil {
  93. e.Error(500, err, err.Error())
  94. return
  95. }
  96. e.OK(req.GetId(), "创建成功")
  97. }
  98. // StationList 搜索-气站列表
  99. // @Summary 搜索-气站列表
  100. // @Description 搜索-气站列表
  101. // @Tags 上报实时充装数据
  102. // @Param deptName query string false "操作记录名称"
  103. // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
  104. // @Router /api/operation-log [get]
  105. // @Security Bearer
  106. func (e FillDataController) StationList(c *gin.Context) {
  107. s := service.FillData{}
  108. err := e.MakeContext(c).
  109. MakeOrm().
  110. MakeService(&s.Service).
  111. Errors
  112. if err != nil {
  113. e.Logger.Error(err)
  114. e.Error(500, err, err.Error())
  115. return
  116. }
  117. //数据权限检查
  118. p := actions.GetPermissionFromContext(c)
  119. list := make([]model.FillDataDistinctStation, 0)
  120. var count int64
  121. err = s.GetStationList(&list, &count, p)
  122. if err != nil {
  123. e.Error(500, err, err.Error())
  124. return
  125. }
  126. e.PageOK(list, int(count), 0, 0, "查询成功")
  127. }
  128. // UserList 搜索-送气员列表
  129. // @Summary 搜索-送气员列表
  130. // @Description 搜索-送气员列表
  131. // @Tags 上报实时充装数据
  132. // @Param deptName query string false "操作记录名称"
  133. // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
  134. // @Router /api/operation-log [get]
  135. // @Security Bearer
  136. func (e FillDataController) UserList(c *gin.Context) {
  137. s := service.FillData{}
  138. err := e.MakeContext(c).
  139. MakeOrm().
  140. MakeService(&s.Service).
  141. Errors
  142. if err != nil {
  143. e.Logger.Error(err)
  144. e.Error(500, err, err.Error())
  145. return
  146. }
  147. //数据权限检查
  148. p := actions.GetPermissionFromContext(c)
  149. list := make([]model.FillDataDistinctUser, 0)
  150. var count int64
  151. err = s.GetUserList(&list, &count, p)
  152. if err != nil {
  153. e.Error(500, err, err.Error())
  154. return
  155. }
  156. e.PageOK(list, int(count), 0, 0, "查询成功")
  157. }