getWorkingUfByCodeLogic.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package logic
  2. import (
  3. "GtDataStore/app/cmd/organization/internal/svc"
  4. "GtDataStore/app/cmd/organization/pb"
  5. "GtDataStore/app/model"
  6. "context"
  7. "github.com/zeromicro/go-zero/core/logx"
  8. )
  9. type GetWorkingUfByCodeLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewGetWorkingUfByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingUfByCodeLogic {
  15. return &GetWorkingUfByCodeLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *GetWorkingUfByCodeLogic) GetWorkingUfByCode(in *pb.DcWorkingReq) (*pb.GetWorkingUfByCodeResp, error) {
  22. offset := (in.Page - 1) * in.PageSize
  23. res, err := l.svcCtx.WorkingUf.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
  24. if err != nil && err != model.ErrNotFound {
  25. return nil, err
  26. }
  27. list := make([]*pb.WorkingUf, len(res))
  28. for i, one := range res {
  29. list[i] = &pb.WorkingUf{
  30. Id: one.Id,
  31. ProjectId: one.ProjectId,
  32. DeviceCode: one.DeviceCode,
  33. WaterTemperature: one.WaterTemperature,
  34. FeedFlow: one.FeedFlow,
  35. ConFlow: one.ConFlow,
  36. ProductFlow: one.ProductFlow,
  37. FeedPressure: one.FeedPressure,
  38. ConPressure: one.ConPressure,
  39. ProductPressure: one.ProductPressure,
  40. Tmp: one.Tmp,
  41. Flux: one.Flux,
  42. FeedWqTurbidity: one.FeedWqTurbidity,
  43. FeedWqPh: one.FeedWqPh,
  44. ProductWqPh: one.ProductWqPh,
  45. FeedWqAl: one.FeedWqAl,
  46. ProductWqAl: one.ProductWqAl,
  47. FeedWqFe: one.FeedWqFe,
  48. ProductWqFe: one.ProductWqFe,
  49. FeedWqMn: one.FeedWqMn,
  50. ProductWqMn: one.ProductWqMn,
  51. FeedWqSio2: one.FeedWqSio2,
  52. ProductWqSio2: one.ProductWqSio2,
  53. FeedWqCod: one.FeedWqCod,
  54. ProductWqCod: one.ProductWqCod,
  55. FeedWqP: one.FeedWqP,
  56. ProductWqP: one.ProductWqP,
  57. Step: one.Step,
  58. CTime: one.CTime.Format("2006-01-02 15:04:05"),
  59. }
  60. }
  61. return &pb.GetWorkingUfByCodeResp{
  62. List: list,
  63. }, nil
  64. }