getWorkingRoByCodeLogic.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 GetWorkingRoByCodeLogic struct {
  10. ctx context.Context
  11. svcCtx *svc.ServiceContext
  12. logx.Logger
  13. }
  14. func NewGetWorkingRoByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingRoByCodeLogic {
  15. return &GetWorkingRoByCodeLogic{
  16. ctx: ctx,
  17. svcCtx: svcCtx,
  18. Logger: logx.WithContext(ctx),
  19. }
  20. }
  21. func (l *GetWorkingRoByCodeLogic) GetWorkingRoByCode(in *pb.DcWorkingReq) (*pb.GetWorkingRoByCodeResp, error) {
  22. offset := (in.Page - 1) * in.PageSize
  23. res, err := l.svcCtx.WorkingRo.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.WorkingRo, len(res))
  28. for i, one := range res {
  29. list[i] = &pb.WorkingRo{
  30. Id: one.Id,
  31. ProjectId: one.ProjectId,
  32. DeviceCode: one.DeviceCode,
  33. WaterTemperature: one.WaterTemperature,
  34. FeedFlow_1St: one.FeedFlow1St,
  35. ConFlow_1St: one.ConFlow1St,
  36. ProductFlow_1St: one.ProductFlow1St,
  37. FeedPressure_1St: one.FeedPressure1St,
  38. ConPressure_1St: one.ConPressure1St,
  39. ProductPressure_1St: one.ProductPressure1St,
  40. Tmp_1St: one.Tmp1St,
  41. Flux_1St: one.Flux1St,
  42. Permeability_1St: one.Permeability1St,
  43. FeedFlow_2Nd: one.FeedFlow2Nd,
  44. ConFlow_2Nd: one.ConFlow2Nd,
  45. ProductFlow_2Nd: one.ProductFlow2Nd,
  46. FeedPressure_2Nd: one.FeedPressure2Nd,
  47. ConPressure_2Nd: one.ConPressure2Nd,
  48. ProductPressure_2Nd: one.ProductPressure2Nd,
  49. Tmp_2Nd: one.Tmp2Nd,
  50. Flux_2Nd: one.Flux2Nd,
  51. Permeability_2Nd: one.Permeability2Nd,
  52. FeedFlow_3Th: one.FeedFlow3Th,
  53. ConFlow_3Th: one.ConFlow3Th,
  54. ProductFlow_3Th: one.ProductFlow3Th,
  55. FeedPressure_3Th: one.FeedPressure3Th,
  56. ConPressure_3Th: one.ConPressure3Th,
  57. ProductPressure_3Th: one.ProductPressure3Th,
  58. Tmp_3Th: one.Tmp3Th,
  59. Flux_3Th: one.Flux3Th,
  60. Permeability_3Th: one.Permeability3Th,
  61. // 以下数据并未采集
  62. //FeedWqTurbidity: 0,
  63. //FeedWqPh: 0,
  64. //ProductWqPh: 0,
  65. //FeedWqAl: 0,
  66. //ProductWqAl: 0,
  67. //FeedWqFe: 0,
  68. //ProductWqFe: 0,
  69. //FeedWqMn: 0,
  70. //ProductWqMn: 0,
  71. //FeedWqSio2: 0,
  72. //ProductWqSio2: 0,
  73. //FeedWqCod: 0,
  74. //ProductWqCod: 0,
  75. //FeedWqP: 0,
  76. //ProductWqP: 0,
  77. Step: one.Step,
  78. CTime: one.CTime.Format("2006-01-02 15:04:05"),
  79. }
  80. }
  81. return &pb.GetWorkingRoByCodeResp{
  82. List: list,
  83. }, nil
  84. }