Browse Source

fit:
1. dtgateway 调试
2. 完成dcworking当前使用的接口

gaoyagang 1 năm trước cách đây
mục cha
commit
8da8e9528d
31 tập tin đã thay đổi với 1773 bổ sung728 xóa
  1. 35 30
      app/cmd/dtgateway/desc/dtgateway/dtgateway.api
  2. 20 4
      app/cmd/dtgateway/internal/logic/dtgateway/workingChestLogic.go
  3. 19 2
      app/cmd/dtgateway/internal/logic/dtgateway/workingPumpLogic.go
  4. 8 3
      app/cmd/dtgateway/internal/logic/dtgateway/workingRoLogic.go
  5. 8 3
      app/cmd/dtgateway/internal/logic/dtgateway/workingUfLogic.go
  6. 19 2
      app/cmd/dtgateway/internal/logic/dtgateway/workingValveLogic.go
  7. 29 3
      app/cmd/dtgateway/internal/middleware/datasignMiddleware.go
  8. 5 0
      app/cmd/dtgateway/internal/types/types.go
  9. 2 2
      app/cmd/organization/etc/organization.test.yaml
  10. 51 0
      app/cmd/organization/internal/logic/getWorkingChestByCodeLogic.go
  11. 55 0
      app/cmd/organization/internal/logic/getWorkingPumpByCodeLogic.go
  12. 91 0
      app/cmd/organization/internal/logic/getWorkingRoByCodeLogic.go
  13. 70 0
      app/cmd/organization/internal/logic/getWorkingUfByCodeLogic.go
  14. 51 0
      app/cmd/organization/internal/logic/getWorkingValveByCodeLogic.go
  15. 0 41
      app/cmd/organization/internal/logic/getworkingchestbycodelogic.go
  16. 0 41
      app/cmd/organization/internal/logic/getworkingpumpbycodelogic.go
  17. 0 41
      app/cmd/organization/internal/logic/getworkingrobycodelogic.go
  18. 0 40
      app/cmd/organization/internal/logic/getworkingufbycodelogic.go
  19. 0 41
      app/cmd/organization/internal/logic/getworkingvaluebycodelogic.go
  20. 7 7
      app/cmd/organization/internal/server/organizationServer.go
  21. 381 56
      app/cmd/organization/organization.proto
  22. 20 11
      app/cmd/organization/organization/organization.go
  23. 616 366
      app/cmd/organization/pb/organization.pb.go
  24. 33 33
      app/cmd/organization/pb/organization_grpc.pb.go
  25. 34 0
      app/model/dcWorkingChestModel.go
  26. 40 1
      app/model/dcWorkingMfModel.go
  27. 40 1
      app/model/dcWorkingNfModel.go
  28. 34 0
      app/model/dcWorkingPumpModel.go
  29. 34 0
      app/model/dcWorkingRoModel.go
  30. 35 0
      app/model/dcWorkingUfModel.go
  31. 36 0
      app/model/dcWorkingValveModel.go

+ 35 - 30
app/cmd/dtgateway/desc/dtgateway/dtgateway.api

@@ -1,58 +1,63 @@
 syntax = "v1"
 
 type CommonParams {
-    Ts        int64  `form:"ts"`
-    ProjectId int64  `form:"project_id"`
-    Sign      string `form:"sign"`
-    SignFlag  uint8  `form:"sign_flag,optional"`
-    AppName   string `header:"APP-NAME"`
+    Ts int64 `form:"ts"`
+    ProjectId int64 `form:"project_id"`
+    Sign string `form:"sign"`
+    SignFlag uint8 `form:"sign_flag,optional"`
+    AppName string `header:"APP-NAME"`
 }
 
 type CommonResponse {
-    Code uint32      `json:"code"`
-    Msg  string      `json:"msg"`
+    Code uint32 `json:"code"`
+    Msg string `json:"msg"`
     Data interface{} `json:"data,omitempty"`
 }
 
 type (
-    DcWorkingReq{
-        ProjectId           int64       `form:"project_id"`
-        DeviceCode          string      `form:"device_code"`
+    DcWorkingReq {
+        ProjectId int64 `form:"project_id"`
+        DeviceCode string `form:"device_code"`
+        Stime string `form:"stime"`
+        Etime string `form:"etime"`
+        Page int64 `form:"page"`
+        PageSize int64 `form:"page_size"`
+        Order string `form:"order"`
     }
 
     ItemHistoryData {
         CommonParams
-        ItemName    string    `json:"item_name"`
-        Val         float64   `json:"val"`
-        HTime       string    `json:"h_time"`
+        ItemName string `json:"item_name"`
+        Val float64 `json:"val"`
+        HTime string `json:"h_time"`
     }
 
-    MultiAddItemHistoryDataReq{
-        List    []*ItemHistoryData  `json:"list"`
+    MultiAddItemHistoryDataReq {
+        List []*ItemHistoryData `json:"list"`
     }
 
-    ItemHistoryDataListReq{
+    ItemHistoryDataListReq {
         CommonParams
-        ItemName    string    `form:"item_name"`
-        Size        int64     `form:"size"`         //结果间隔
-        Interval    string    `form:"interval"`     //时间单位 s,minute,h,day
-        Aggregator  string    `form:"aggregator"`   //聚合方式 min,max,avg,sum,realtime, new
-        STime       string    `form:"stime"`
-        ETime       string    `form:"etime"`
+        ItemName string `form:"item_name"`
+        Size int64 `form:"size"`                //结果间隔
+        Interval string `form:"interval"`       //时间单位 s,minute,h,day
+        Aggregator string `form:"aggregator"`   //聚合方式 min,max,avg,sum,realtime, new
+        STime string `form:"stime"`
+        ETime string `form:"etime"`
     }
 
-    ItemHistoryDataByTimeReq{
+    ItemHistoryDataByTimeReq {
         CommonParams
-        ItemName    string    `form:"item_name"`
-        STime       string    `form:"stime"`
-        ETime       string    `form:"etime"`
+        ItemName string `form:"item_name"`
+        STime string `form:"stime"`
+        ETime string `form:"etime"`
     }
 
-    ItemHistoryDataMaxMinByTimeReq{
+    ItemHistoryDataMaxMinByTimeReq {
         CommonParams
-        ItemName    string    `form:"item_name"`
-        STime       string    `form:"stime"`
-        ETime       string    `form:"etime"`
+        ItemName string `form:"item_name"`
+        STime string `form:"stime"`
+        ETime string `form:"etime"`
     }
 )
 

+ 20 - 4
app/cmd/dtgateway/internal/logic/dtgateway/workingChestLogic.go

@@ -1,10 +1,11 @@
 package dtgateway
 
 import (
-	"context"
-
 	"GtDataStore/app/cmd/dtgateway/internal/svc"
 	"GtDataStore/app/cmd/dtgateway/internal/types"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
 
 	"github.com/zeromicro/go-zero/core/logx"
 )
@@ -24,7 +25,22 @@ func NewWorkingChestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Work
 }
 
 func (l *WorkingChestLogic) WorkingChest(req *types.DcWorkingReq) (resp *types.CommonResponse, err error) {
-	// todo: add your logic here and delete this line
+	list, err := l.svcCtx.OrganizationRpc.GetWorkingChestByCode(l.ctx, &pb.DcWorkingReq{
+		ProjectId:  req.ProjectId,
+		DeviceCode: req.DeviceCode,
+		Stime:      req.Stime,
+		Etime:      req.Etime,
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		Order:      req.Order,
+	})
+	if err != nil {
+		return nil, err
+	}
 
-	return
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: list,
+	}, nil
 }

+ 19 - 2
app/cmd/dtgateway/internal/logic/dtgateway/workingPumpLogic.go

@@ -1,6 +1,8 @@
 package dtgateway
 
 import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
 	"context"
 
 	"GtDataStore/app/cmd/dtgateway/internal/svc"
@@ -24,7 +26,22 @@ func NewWorkingPumpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Worki
 }
 
 func (l *WorkingPumpLogic) WorkingPump(req *types.DcWorkingReq) (resp *types.CommonResponse, err error) {
-	// todo: add your logic here and delete this line
+	list, err := l.svcCtx.OrganizationRpc.GetWorkingPumpByCode(l.ctx, &pb.DcWorkingReq{
+		ProjectId:  req.ProjectId,
+		DeviceCode: req.DeviceCode,
+		Stime:      req.Stime,
+		Etime:      req.Etime,
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		Order:      req.Order,
+	})
+	if err != nil {
+		return nil, err
+	}
 
-	return
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: list,
+	}, nil
 }

+ 8 - 3
app/cmd/dtgateway/internal/logic/dtgateway/workingRoLogic.go

@@ -25,17 +25,22 @@ func NewWorkingRoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Working
 }
 
 func (l *WorkingRoLogic) WorkingRo(req *types.DcWorkingReq) (resp *types.CommonResponse, err error) {
-	rpcResp, err := l.svcCtx.OrganizationRpc.GetWorkingUfByCode(l.ctx, &pb.DcWorkingReq{
+	list, err := l.svcCtx.OrganizationRpc.GetWorkingRoByCode(l.ctx, &pb.DcWorkingReq{
 		ProjectId:  req.ProjectId,
 		DeviceCode: req.DeviceCode,
+		Stime:      req.Stime,
+		Etime:      req.Etime,
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		Order:      req.Order,
 	})
 	if err != nil {
-		return nil, xerr.NewErrMsg("获取数据失败")
+		return nil, err
 	}
 
 	return &types.CommonResponse{
 		Code: xerr.OK,
 		Msg:  xerr.MapErrMsg(xerr.OK),
-		Data: rpcResp,
+		Data: list,
 	}, nil
 }

+ 8 - 3
app/cmd/dtgateway/internal/logic/dtgateway/workingUfLogic.go

@@ -25,17 +25,22 @@ func NewWorkingUfLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Working
 }
 
 func (l *WorkingUfLogic) WorkingUf(req *types.DcWorkingReq) (resp *types.CommonResponse, err error) {
-	rpcResp, err := l.svcCtx.OrganizationRpc.GetWorkingUfByCode(l.ctx, &pb.DcWorkingReq{
+	list, err := l.svcCtx.OrganizationRpc.GetWorkingUfByCode(l.ctx, &pb.DcWorkingReq{
 		ProjectId:  req.ProjectId,
 		DeviceCode: req.DeviceCode,
+		Stime:      req.Stime,
+		Etime:      req.Etime,
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		Order:      req.Order,
 	})
 	if err != nil {
-		return nil, xerr.NewErrMsg("获取数据失败")
+		return nil, err
 	}
 
 	return &types.CommonResponse{
 		Code: xerr.OK,
 		Msg:  xerr.MapErrMsg(xerr.OK),
-		Data: rpcResp,
+		Data: list,
 	}, nil
 }

+ 19 - 2
app/cmd/dtgateway/internal/logic/dtgateway/workingValveLogic.go

@@ -1,6 +1,8 @@
 package dtgateway
 
 import (
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
 	"context"
 
 	"GtDataStore/app/cmd/dtgateway/internal/svc"
@@ -24,7 +26,22 @@ func NewWorkingValveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Work
 }
 
 func (l *WorkingValveLogic) WorkingValve(req *types.DcWorkingReq) (resp *types.CommonResponse, err error) {
-	// todo: add your logic here and delete this line
+	list, err := l.svcCtx.OrganizationRpc.GetWorkingValveByCode(l.ctx, &pb.DcWorkingReq{
+		ProjectId:  req.ProjectId,
+		DeviceCode: req.DeviceCode,
+		Stime:      req.Stime,
+		Etime:      req.Etime,
+		Page:       req.Page,
+		PageSize:   req.PageSize,
+		Order:      req.Order,
+	})
+	if err != nil {
+		return nil, err
+	}
 
-	return
+	return &types.CommonResponse{
+		Code: xerr.OK,
+		Msg:  xerr.MapErrMsg(xerr.OK),
+		Data: list,
+	}, nil
 }

+ 29 - 3
app/cmd/dtgateway/internal/middleware/datasignMiddleware.go

@@ -10,12 +10,15 @@ import (
 	"context"
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/validation"
 	"github.com/zeromicro/go-zero/rest/httpx"
 	"io/ioutil"
 	"k8s.io/apimachinery/pkg/util/json"
+	"math"
 	"net/http"
 	"net/url"
 	"sync"
+	"sync/atomic"
 	"time"
 )
 
@@ -30,6 +33,7 @@ const (
 var (
 	appSecrets     = make(map[string]secretExpire)
 	appSecretsLock sync.Mutex
+	validator      atomic.Value
 )
 
 type (
@@ -62,7 +66,8 @@ func NewDataSignMiddleware(conf config.Config) *DataSignMiddleware {
 func (m *DataSignMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {
 		cps := CommonParams{}
-		err := httpx.Parse(r, &cps)
+		err := m.parseCommonParams(r, &cps)
+
 		if err != nil {
 			httpx.WriteJson(w, http.StatusOK, map[string]interface{}{
 				"code": xerr.REUQEST_PARAM_ERROR,
@@ -123,7 +128,7 @@ func (m *DataSignMiddleware) calcSign(s1, s2, appSecret string, s3 int64, signFl
 		s2, _ = m.sortS2(s2)
 	}
 
-	//fmt.Printf("sign data: %s\n", fmt.Sprintf("%s%s%d%s", s1, s2, s3, appSecret))
+	//fmt.Printf("sign data: %s\n", fmt.Sprintf("%s_%s_%d_%s", s1, s2, s3, appSecret))
 	//fmt.Printf("md5: %s\n", md5.Md5([]byte(fmt.Sprintf("%s%s%d%s", s1, s2, s3, appSecret))))
 
 	return md5.Md5([]byte(fmt.Sprintf("%s%s%d%s", s1, s2, s3, appSecret)))
@@ -152,6 +157,27 @@ func (m *DataSignMiddleware) sortS2(s2 string) (string, error) {
 	}
 }
 
+func (m *DataSignMiddleware) parseCommonParams(r *http.Request, v any) error {
+	if err := httpx.ParsePath(r, v); err != nil {
+		return err
+	}
+
+	if err := httpx.ParseForm(r, v); err != nil {
+		return err
+	}
+
+	if err := httpx.ParseHeaders(r, v); err != nil {
+		return err
+	}
+
+	if valid, ok := v.(validation.Validator); ok {
+		return valid.Validate()
+	} else if val := validator.Load(); val != nil {
+		return val.(httpx.Validator).Validate(r, v)
+	}
+	return nil
+}
+
 func (m *DataSignMiddleware) parseBody(r *http.Request) (body string, err error) {
 	if r.Method == http.MethodGet {
 		return "", nil
@@ -197,5 +223,5 @@ func (m *DataSignMiddleware) getAppSecret(appName string) (string, error) {
 }
 
 func (m *DataSignMiddleware) checkTs(ts int64) bool {
-	return time.Now().Unix()-ts <= TIME_OUT
+	return math.Abs(float64(time.Now().Unix()-ts)) <= TIME_OUT
 }

+ 5 - 0
app/cmd/dtgateway/internal/types/types.go

@@ -18,6 +18,11 @@ type CommonResponse struct {
 type DcWorkingReq struct {
 	ProjectId  int64  `form:"project_id"`
 	DeviceCode string `form:"device_code"`
+	Stime      string `form:"stime"`
+	Etime      string `form:"etime"`
+	Page       int64  `form:"page"`
+	PageSize   int64  `form:"page_size"`
+	Order      string `form:"order"`
 }
 
 type ItemHistoryData struct {

+ 2 - 2
app/cmd/organization/etc/organization.test.yaml

@@ -13,8 +13,8 @@ Log:
 GtServerIp: 47.96.12.136:8788
 
 DtDataStoreDB:
-  #  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(192.168.60.201:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai
-  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(172.16.0.195:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai
+  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(192.168.60.201:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai
+#  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(172.16.0.195:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai
 
 Redis:
   Host: 47.96.12.136:6379

+ 51 - 0
app/cmd/organization/internal/logic/getWorkingChestByCodeLogic.go

@@ -0,0 +1,51 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWorkingChestByCodeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWorkingChestByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingChestByCodeLogic {
+	return &GetWorkingChestByCodeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWorkingChestByCodeLogic) GetWorkingChestByCode(in *pb.DcWorkingReq) (*pb.GetWorkingChestByCodeResp, error) {
+	offset := (in.Page - 1) * in.PageSize
+	res, err := l.svcCtx.WorkingChest.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
+	if err != nil && err != model.ErrNotFound {
+		return nil, err
+	}
+
+	list := make([]*pb.WorkingChest, len(res))
+	for i, one := range res {
+		list[i] = &pb.WorkingChest{
+			Id:                  one.Id,
+			ProjectId:           one.ProjectId,
+			DeviceCode:          one.DeviceCode,
+			Switch:              one.Switch,
+			Level:               one.Level,
+			AgitatorStatus:      one.AgitatorStatus,
+			AgitatorDuration:    one.AgitatorDuration,
+			AgitatorFaultStatus: one.AgitatorFaultStatus,
+			CTime:               one.CTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.GetWorkingChestByCodeResp{
+		List: list,
+	}, nil
+}

+ 55 - 0
app/cmd/organization/internal/logic/getWorkingPumpByCodeLogic.go

@@ -0,0 +1,55 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWorkingPumpByCodeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWorkingPumpByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingPumpByCodeLogic {
+	return &GetWorkingPumpByCodeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWorkingPumpByCodeLogic) GetWorkingPumpByCode(in *pb.DcWorkingReq) (*pb.GetWorkingPumpByCodeResp, error) {
+	offset := (in.Page - 1) * in.PageSize
+	res, err := l.svcCtx.WorkingPump.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
+	if err != nil && err != model.ErrNotFound {
+		return nil, err
+	}
+
+	list := make([]*pb.WorkingPump, len(res))
+	for i, one := range res {
+		list[i] = &pb.WorkingPump{
+			Id:           one.Id,
+			ProjectId:    one.ProjectId,
+			DeviceCode:   one.DeviceCode,
+			FeedPressure: one.FeedPressure,
+			OutPressure:  one.OutPressure,
+			Duration:     one.Duration,
+			Current:      one.Current,
+			Frequency:    one.Frequency,
+			Lift:         one.Lift,
+			Efficiency:   one.Efficiency,
+			RunStatus:    one.RunStatus,
+			FaultStatus:  one.FaultStatus,
+			CTime:        one.CTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.GetWorkingPumpByCodeResp{
+		List: list,
+	}, nil
+}

+ 91 - 0
app/cmd/organization/internal/logic/getWorkingRoByCodeLogic.go

@@ -0,0 +1,91 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWorkingRoByCodeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWorkingRoByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingRoByCodeLogic {
+	return &GetWorkingRoByCodeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWorkingRoByCodeLogic) GetWorkingRoByCode(in *pb.DcWorkingReq) (*pb.GetWorkingRoByCodeResp, error) {
+	offset := (in.Page - 1) * in.PageSize
+	res, err := l.svcCtx.WorkingRo.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
+	if err != nil && err != model.ErrNotFound {
+		return nil, err
+	}
+
+	list := make([]*pb.WorkingRo, len(res))
+	for i, one := range res {
+		list[i] = &pb.WorkingRo{
+			Id:                  one.Id,
+			ProjectId:           one.ProjectId,
+			DeviceCode:          one.DeviceCode,
+			WaterTemperature:    one.WaterTemperature,
+			FeedFlow_1St:        one.FeedFlow1St,
+			ConFlow_1St:         one.ConFlow1St,
+			ProductFlow_1St:     one.ProductFlow1St,
+			FeedPressure_1St:    one.FeedPressure1St,
+			ConPressure_1St:     one.ConPressure1St,
+			ProductPressure_1St: one.ProductPressure1St,
+			Tmp_1St:             one.Tmp1St,
+			Flux_1St:            one.Flux1St,
+			Permeability_1St:    one.Permeability1St,
+			FeedFlow_2Nd:        one.FeedFlow2Nd,
+			ConFlow_2Nd:         one.ConFlow2Nd,
+			ProductFlow_2Nd:     one.ProductFlow2Nd,
+			FeedPressure_2Nd:    one.FeedPressure2Nd,
+			ConPressure_2Nd:     one.ConPressure2Nd,
+			ProductPressure_2Nd: one.ProductPressure2Nd,
+			Tmp_2Nd:             one.Tmp2Nd,
+			Flux_2Nd:            one.Flux2Nd,
+			Permeability_2Nd:    one.Permeability2Nd,
+			FeedFlow_3Th:        one.FeedFlow3Th,
+			ConFlow_3Th:         one.ConFlow3Th,
+			ProductFlow_3Th:     one.ProductFlow3Th,
+			FeedPressure_3Th:    one.FeedPressure3Th,
+			ConPressure_3Th:     one.ConPressure3Th,
+			ProductPressure_3Th: one.ProductPressure3Th,
+			Tmp_3Th:             one.Tmp3Th,
+			Flux_3Th:            one.Flux3Th,
+			Permeability_3Th:    one.Permeability3Th,
+			// 以下数据并未采集
+			//FeedWqTurbidity:     0,
+			//FeedWqPh:            0,
+			//ProductWqPh:         0,
+			//FeedWqAl:            0,
+			//ProductWqAl:         0,
+			//FeedWqFe:            0,
+			//ProductWqFe:         0,
+			//FeedWqMn:            0,
+			//ProductWqMn:         0,
+			//FeedWqSio2:          0,
+			//ProductWqSio2:       0,
+			//FeedWqCod:           0,
+			//ProductWqCod:        0,
+			//FeedWqP:             0,
+			//ProductWqP:          0,
+			Step:  one.Step,
+			CTime: one.CTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.GetWorkingRoByCodeResp{
+		List: list,
+	}, nil
+}

+ 70 - 0
app/cmd/organization/internal/logic/getWorkingUfByCodeLogic.go

@@ -0,0 +1,70 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"context"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWorkingUfByCodeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWorkingUfByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingUfByCodeLogic {
+	return &GetWorkingUfByCodeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWorkingUfByCodeLogic) GetWorkingUfByCode(in *pb.DcWorkingReq) (*pb.GetWorkingUfByCodeResp, error) {
+	offset := (in.Page - 1) * in.PageSize
+	res, err := l.svcCtx.WorkingUf.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
+	if err != nil && err != model.ErrNotFound {
+		return nil, err
+	}
+
+	list := make([]*pb.WorkingUf, len(res))
+	for i, one := range res {
+		list[i] = &pb.WorkingUf{
+			Id:               one.Id,
+			ProjectId:        one.ProjectId,
+			DeviceCode:       one.DeviceCode,
+			WaterTemperature: one.WaterTemperature,
+			FeedFlow:         one.FeedFlow,
+			ConFlow:          one.ConFlow,
+			ProductFlow:      one.ProductFlow,
+			FeedPressure:     one.FeedPressure,
+			ConPressure:      one.ConPressure,
+			ProductPressure:  one.ProductPressure,
+			Tmp:              one.Tmp,
+			Flux:             one.Flux,
+			FeedWqTurbidity:  one.FeedWqTurbidity,
+			FeedWqPh:         one.FeedWqPh,
+			ProductWqPh:      one.ProductWqPh,
+			FeedWqAl:         one.FeedWqAl,
+			ProductWqAl:      one.ProductWqAl,
+			FeedWqFe:         one.FeedWqFe,
+			ProductWqFe:      one.ProductWqFe,
+			FeedWqMn:         one.FeedWqMn,
+			ProductWqMn:      one.ProductWqMn,
+			FeedWqSio2:       one.FeedWqSio2,
+			ProductWqSio2:    one.ProductWqSio2,
+			FeedWqCod:        one.FeedWqCod,
+			ProductWqCod:     one.ProductWqCod,
+			FeedWqP:          one.FeedWqP,
+			ProductWqP:       one.ProductWqP,
+			Step:             one.Step,
+			CTime:            one.CTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.GetWorkingUfByCodeResp{
+		List: list,
+	}, nil
+}

+ 51 - 0
app/cmd/organization/internal/logic/getWorkingValveByCodeLogic.go

@@ -0,0 +1,51 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWorkingValveByCodeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetWorkingValveByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingValveByCodeLogic {
+	return &GetWorkingValveByCodeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetWorkingValveByCodeLogic) GetWorkingValveByCode(in *pb.DcWorkingReq) (*pb.GetWorkingValveByCodeResp, error) {
+	offset := (in.Page - 1) * in.PageSize
+	res, err := l.svcCtx.WorkingValve.Search(l.ctx, in.ProjectId, in.DeviceCode, in.Stime, in.Etime, offset, in.PageSize, in.Order)
+	if err != nil && err != model.ErrNotFound {
+		return nil, err
+	}
+
+	list := make([]*pb.WorkingValve, len(res))
+	for i, one := range res {
+		list[i] = &pb.WorkingValve{
+			Id:          one.Id,
+			ProjectId:   one.ProjectId,
+			DeviceCode:  one.DeviceCode,
+			Adjust:      one.Adjust,
+			Opening:     one.Opening,
+			Closed:      one.Closed,
+			Opened:      one.Opened,
+			FaultStatus: one.FaultStatus,
+			CTime:       one.CTime.Format("2006-01-02 15:04:05"),
+		}
+	}
+
+	return &pb.GetWorkingValveByCodeResp{
+		List: list,
+	}, nil
+}

+ 0 - 41
app/cmd/organization/internal/logic/getworkingchestbycodelogic.go

@@ -1,41 +0,0 @@
-package logic
-
-import (
-	"GtDataStore/app/model"
-	"context"
-	"github.com/jinzhu/copier"
-
-	"GtDataStore/app/cmd/organization/internal/svc"
-	"GtDataStore/app/cmd/organization/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type GetWorkingChestByCodeLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewGetWorkingChestByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingChestByCodeLogic {
-	return &GetWorkingChestByCodeLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *GetWorkingChestByCodeLogic) GetWorkingChestByCode(in *pb.DcWorkingReq) (*pb.WorkingChest, error) {
-	//基础条件
-	workingChestInfo, err := l.svcCtx.WorkingChest.FindOneByCode(l.ctx, in.ProjectId, in.DeviceCode)
-	if err != nil && err != model.ErrNotFound {
-		logx.Errorf("not found workingUf data")
-		return nil, err
-	}
-
-	resp := &pb.WorkingChest{}
-	_ = copier.Copy(resp, workingChestInfo)
-	resp.CTime = workingChestInfo.CTime.Format("2006-01-02 15:04:05")
-
-	return resp, nil
-}

+ 0 - 41
app/cmd/organization/internal/logic/getworkingpumpbycodelogic.go

@@ -1,41 +0,0 @@
-package logic
-
-import (
-	"GtDataStore/app/model"
-	"context"
-	"github.com/jinzhu/copier"
-
-	"GtDataStore/app/cmd/organization/internal/svc"
-	"GtDataStore/app/cmd/organization/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type GetWorkingPumpByCodeLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewGetWorkingPumpByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingPumpByCodeLogic {
-	return &GetWorkingPumpByCodeLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *GetWorkingPumpByCodeLogic) GetWorkingPumpByCode(in *pb.DcWorkingReq) (*pb.WorkingPump, error) {
-	//基础条件
-	workingPumpInfo, err := l.svcCtx.WorkingPump.FindOneByCode(l.ctx, in.ProjectId, in.DeviceCode)
-	if err != nil && err != model.ErrNotFound {
-		logx.Errorf("not found workingUf data")
-		return nil, err
-	}
-
-	resp := &pb.WorkingPump{}
-	_ = copier.Copy(resp, workingPumpInfo)
-	resp.CTime = workingPumpInfo.CTime.Format("2006-01-02 15:04:05")
-
-	return resp, nil
-}

+ 0 - 41
app/cmd/organization/internal/logic/getworkingrobycodelogic.go

@@ -1,41 +0,0 @@
-package logic
-
-import (
-	"GtDataStore/app/model"
-	"context"
-	"github.com/jinzhu/copier"
-
-	"GtDataStore/app/cmd/organization/internal/svc"
-	"GtDataStore/app/cmd/organization/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type GetWorkingRoByCodeLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewGetWorkingRoByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingRoByCodeLogic {
-	return &GetWorkingRoByCodeLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *GetWorkingRoByCodeLogic) GetWorkingRoByCode(in *pb.DcWorkingReq) (*pb.WorkingRo, error) {
-	//基础条件
-	workingRoInfo, err := l.svcCtx.WorkingRo.FindOneByCode(l.ctx, in.ProjectId, in.DeviceCode)
-	if err != nil && err != model.ErrNotFound {
-		logx.Errorf("not found workingUf data")
-		return nil, err
-	}
-
-	resp := &pb.WorkingRo{}
-	_ = copier.Copy(resp, workingRoInfo)
-	resp.CTime = workingRoInfo.CTime.Format("2006-01-02 15:04:05")
-
-	return resp, nil
-}

+ 0 - 40
app/cmd/organization/internal/logic/getworkingufbycodelogic.go

@@ -1,40 +0,0 @@
-package logic
-
-import (
-	"GtDataStore/app/cmd/organization/internal/svc"
-	"GtDataStore/app/cmd/organization/pb"
-	"GtDataStore/app/model"
-	"context"
-	"github.com/jinzhu/copier"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type GetWorkingUfByCodeLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewGetWorkingUfByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingUfByCodeLogic {
-	return &GetWorkingUfByCodeLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *GetWorkingUfByCodeLogic) GetWorkingUfByCode(in *pb.DcWorkingReq) (*pb.WorkingUf, error) {
-	//基础条件
-	workingUfInfo, err := l.svcCtx.WorkingUf.FindOneByCode(l.ctx, in.ProjectId, in.DeviceCode)
-	if err != nil && err != model.ErrNotFound {
-		logx.Errorf("not found workingUf data")
-		return nil, err
-	}
-
-	resp := &pb.WorkingUf{}
-	_ = copier.Copy(resp, workingUfInfo)
-	resp.CTime = workingUfInfo.CTime.Format("2006-01-02 15:04:05")
-
-	return resp, nil
-}

+ 0 - 41
app/cmd/organization/internal/logic/getworkingvaluebycodelogic.go

@@ -1,41 +0,0 @@
-package logic
-
-import (
-	"GtDataStore/app/model"
-	"context"
-	"github.com/jinzhu/copier"
-
-	"GtDataStore/app/cmd/organization/internal/svc"
-	"GtDataStore/app/cmd/organization/pb"
-
-	"github.com/zeromicro/go-zero/core/logx"
-)
-
-type GetWorkingValueByCodeLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewGetWorkingValueByCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWorkingValueByCodeLogic {
-	return &GetWorkingValueByCodeLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-func (l *GetWorkingValueByCodeLogic) GetWorkingValueByCode(in *pb.DcWorkingReq) (*pb.WorkingValve, error) {
-	//基础条件
-	workingValveInfo, err := l.svcCtx.WorkingValve.FindOneByCode(l.ctx, in.ProjectId, in.DeviceCode)
-	if err != nil && err != model.ErrNotFound {
-		logx.Errorf("not found workingUf data")
-		return nil, err
-	}
-
-	resp := &pb.WorkingValve{}
-	_ = copier.Copy(resp, workingValveInfo)
-	resp.CTime = workingValveInfo.CTime.Format("2006-01-02 15:04:05")
-
-	return resp, nil
-}

+ 7 - 7
app/cmd/organization/internal/server/organizationServer.go

@@ -22,29 +22,29 @@ func NewOrganizationServer(svcCtx *svc.ServiceContext) *OrganizationServer {
 	}
 }
 
-func (s *OrganizationServer) GetWorkingUfByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.WorkingUf, error) {
+func (s *OrganizationServer) GetWorkingUfByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.GetWorkingUfByCodeResp, error) {
 	l := logic.NewGetWorkingUfByCodeLogic(ctx, s.svcCtx)
 	return l.GetWorkingUfByCode(in)
 }
 
-func (s *OrganizationServer) GetWorkingRoByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.WorkingRo, error) {
+func (s *OrganizationServer) GetWorkingRoByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.GetWorkingRoByCodeResp, error) {
 	l := logic.NewGetWorkingRoByCodeLogic(ctx, s.svcCtx)
 	return l.GetWorkingRoByCode(in)
 }
 
-func (s *OrganizationServer) GetWorkingChestByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.WorkingChest, error) {
+func (s *OrganizationServer) GetWorkingChestByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.GetWorkingChestByCodeResp, error) {
 	l := logic.NewGetWorkingChestByCodeLogic(ctx, s.svcCtx)
 	return l.GetWorkingChestByCode(in)
 }
 
-func (s *OrganizationServer) GetWorkingPumpByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.WorkingPump, error) {
+func (s *OrganizationServer) GetWorkingPumpByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.GetWorkingPumpByCodeResp, error) {
 	l := logic.NewGetWorkingPumpByCodeLogic(ctx, s.svcCtx)
 	return l.GetWorkingPumpByCode(in)
 }
 
-func (s *OrganizationServer) GetWorkingValueByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.WorkingValve, error) {
-	l := logic.NewGetWorkingValueByCodeLogic(ctx, s.svcCtx)
-	return l.GetWorkingValueByCode(in)
+func (s *OrganizationServer) GetWorkingValveByCode(ctx context.Context, in *pb.DcWorkingReq) (*pb.GetWorkingValveByCodeResp, error) {
+	l := logic.NewGetWorkingValveByCodeLogic(ctx, s.svcCtx)
+	return l.GetWorkingValveByCode(in)
 }
 
 func (s *OrganizationServer) MultiAddItemHistoryData(ctx context.Context, in *pb.MultiAddItemHistoryDataReq) (*pb.MultiAddItemHistoryDataResp, error) {

+ 381 - 56
app/cmd/organization/organization.proto

@@ -6,161 +6,449 @@ option go_package = "./pb";
 message DcWorkingReq{
   int64   project_id = 1;
   string  device_code = 2;
+  string  stime = 3; // c_time的搜索
+  string  etime = 4; // c_time的搜索
+  int64 page = 5;
+  int64 page_size = 6;
+  string order = 7; // 排序字段及方向 例: id desc
+}
+
+message WorkingMf{
+  // @gotags: json:"id"
+  int64         id = 1;
+  // @gotags: json:"project_id"
+  int64         project_id = 2;
+  // @gotags: json:"device_code"
+  string        device_code = 3;
+  // @gotags: json:"water_temperature"
+  double        water_temperature = 4;  // 水温 摄氏度
+  // @gotags: json:"feed_flow"
+  double        feed_flow = 5;          // 进水流量
+  // @gotags: json:"con_flow"
+  double        con_flow = 6;           // 浓水流量
+  // @gotags: json:"product_flow"
+  double        product_flow = 7;       // 产水流量
+  // @gotags: json:"feed_pressure"
+  double        feed_pressure = 8;      // 进水压力
+  // @gotags: json:"con_pressure"
+  double        con_pressure = 9;       // 浓水压力
+  // @gotags: json:"product_pressure"
+  double        product_pressure = 10;  // 产水压力
+  // @gotags: json:"tmp"
+  double        tmp = 11;               // 跨膜压差
+  // @gotags: json:"flux"
+  double        flux = 12;              // 膜通量
+  // @gotags: json:"feed_wq_turbidity"
+  double        feed_wq_turbidity = 13; // 进水浊度
+  // @gotags: json:"feed_wq_ph"
+  int64         feed_wq_ph = 14;        // 进水 PH 值
+  // @gotags: json:"product_wq_ph"
+  int64         product_wq_ph = 15;     // 产水 PH 值
+  // @gotags: json:"feed_wq_al"
+  double        feed_wq_al = 16;        // 进水水质:铝
+  // @gotags: json:"product_wq_al"
+  double        product_wq_al = 17;     // 产水水质:铝
+  // @gotags: json:"feed_wq_fe"
+  double        feed_wq_fe = 18;        // 进水水质:铁
+  // @gotags: json:"product_wq_fe"
+  double        product_wq_fe = 19;     // 产水水质:铁
+  // @gotags: json:"feed_wq_mn"
+  double        feed_wq_mn = 20;        // 进水水质:锰
+  // @gotags: json:"product_wq_mn"
+  double        product_wq_mn = 21;     // 产水水质:锰
+  // @gotags: json:"feed_wq_sio2"
+  double        feed_wq_sio2 = 22;      // 进水水质:二氧化硅
+  // @gotags: json:"product_wq_sio2"
+  double        product_wq_sio2 = 23;   // 产水水质:二氧化硅
+  // @gotags: json:"feed_wq_cod"
+  double        feed_wq_cod = 24;       // 进水水质:COD
+  // @gotags: json:"product_wq_cod"
+  double        product_wq_cod = 25;    // 产水水质:COD
+  // @gotags: json:"feed_wq_p"
+  double        feed_wq_p = 26;         // 进水水质:磷
+  // @gotags: json:"product_wq_p"
+  double        product_wq_p = 27;      // 产水水质:磷
+  // @gotags: json:"step"
+  int64         step = 28;              // 设备当前步序值
+  // @gotags: json:"c_time"
+  string        c_time = 29;
 }
 
 message WorkingUf{
+  // @gotags: json:"id"
   int64         id = 1;
+  // @gotags: json:"project_id"
   int64         project_id = 2;
+  // @gotags: json:"device_code"
   string        device_code = 3;
+  // @gotags: json:"water_temperature"
   double        water_temperature = 4;  // 水温 摄氏度
+  // @gotags: json:"feed_flow"
   double        feed_flow = 5;          // 进水流量
+  // @gotags: json:"con_flow"
   double        con_flow = 6;           // 浓水流量
+  // @gotags: json:"product_flow"
   double        product_flow = 7;       // 产水流量
+  // @gotags: json:"feed_pressure"
   double        feed_pressure = 8;      // 进水压力
+  // @gotags: json:"con_pressure"
   double        con_pressure = 9;       // 浓水压力
+  // @gotags: json:"product_pressure"
   double        product_pressure = 10;  // 产水压力
+  // @gotags: json:"tmp"
   double        tmp = 11;               // 跨膜压差
+  // @gotags: json:"flux"
   double        flux = 12;              // 膜通量
+  // @gotags: json:"feed_wq_turbidity"
   double        feed_wq_turbidity = 13; // 进水浊度
+  // @gotags: json:"feed_wq_ph"
   int64         feed_wq_ph = 14;        // 进水 PH 值
+  // @gotags: json:"product_wq_ph"
   int64         product_wq_ph = 15;     // 产水 PH 值
+  // @gotags: json:"feed_wq_al"
   double        feed_wq_al = 16;        // 进水水质:铝
+  // @gotags: json:"product_wq_al"
   double        product_wq_al = 17;     // 产水水质:铝
+  // @gotags: json:"feed_wq_fe"
   double        feed_wq_fe = 18;        // 进水水质:铁
+  // @gotags: json:"product_wq_fe"
   double        product_wq_fe = 19;     // 产水水质:铁
+  // @gotags: json:"feed_wq_mn"
   double        feed_wq_mn = 20;        // 进水水质:锰
+  // @gotags: json:"product_wq_mn"
   double        product_wq_mn = 21;     // 产水水质:锰
+  // @gotags: json:"feed_wq_sio2"
   double        feed_wq_sio2 = 22;      // 进水水质:二氧化硅
+  // @gotags: json:"product_wq_sio2"
   double        product_wq_sio2 = 23;   // 产水水质:二氧化硅
+  // @gotags: json:"feed_wq_cod"
   double        feed_wq_cod = 24;       // 进水水质:COD
+  // @gotags: json:"product_wq_cod"
   double        product_wq_cod = 25;    // 产水水质:COD
+  // @gotags: json:"feed_wq_p"
   double        feed_wq_p = 26;         // 进水水质:磷
+  // @gotags: json:"product_wq_p"
   double        product_wq_p = 27;      // 产水水质:磷
+  // @gotags: json:"step"
   int64         step = 28;              // 设备当前步序值
+  // @gotags: json:"c_time"
   string        c_time = 29;
 }
 
+message WorkingNf{
+  // gotags: json:"id"
+  int64         id = 1;
+  // gotags: json:"project_id"
+  int64         project_id = 2;
+  // gotags: json:"device_code"
+  string        device_code = 3;
+  // gotags: json:"water_temperature"
+  double       water_temperature = 4;    // 水温 摄氏度
+  // gotags: json:"feed_flow_1st"
+  double       feed_flow_1st = 5;        // 一段进水流量
+  // gotags: json:"con_flow_1st"
+  double       con_flow_1st = 6;         // 一段浓水流量
+  // gotags: json:"product_flow_1st"
+  double       product_flow_1st = 7;     // 一段产水流量
+  // gotags: json:"feed_pressure_1st"
+  double       feed_pressure_1st = 8;    // 一段进水压力
+  // gotags: json:"con_pressure_1st"
+  double       con_pressure_1st = 9;     // 一段浓水压力
+  // gotags: json:"product_pressure_1st"
+  double       product_pressure_1st = 10; // 一段产水压力
+  // gotags: json:"tmp_1st"
+  double       tmp_1st = 11;              // 一段跨膜压差
+  // gotags: json:"flux_1st"
+  double       flux_1st = 12;             // 一段膜通量
+  // gotags: json:"permeability_1st"
+  double       permeability_1st = 13;     // 一段渗透率
+  // gotags: json:"feed_flow_2nd"
+  double       feed_flow_2nd = 14;        // 二段进水流量
+  // gotags: json:"con_flow_2nd"
+  double       con_flow_2nd = 15;         // 二段浓水流量
+  // gotags: json:"product_flow_2nd"
+  double       product_flow_2nd = 16;     // 二段产水流量
+  // gotags: json:"feed_pressure_2nd"
+  double       feed_pressure_2nd = 17;    // 二段进水压力
+  // gotags: json:"con_pressure_2nd"
+  double       con_pressure_2nd = 18;     // 二段浓水压力
+  // gotags: json:"product_pressure_2nd"
+  double       product_pressure_2nd = 19; // 二段产水压力
+  // gotags: json:"tmp_2nd"
+  double       tmp_2nd = 20;              // 二段压差
+  // gotags: json:"flux_2nd"
+  double       flux_2nd = 21;             // 二段通量
+  // gotags: json:"permeability_2nd"
+  double       permeability_2nd = 22;     // 二段渗透率
+  // gotags: json:"feed_flow_3th"
+  double       feed_flow_3th = 23;        // 三段进水流量
+  // gotags: json:"con_flow_3th"
+  double       con_flow_3th = 24;         // 三段浓水流量
+  // gotags: json:"product_flow_3th"
+  double       product_flow_3th = 25;     // 三段产水流量
+  // gotags: json:"feed_pressure_3th"
+  double       feed_pressure_3th = 26;    // 三段进水压力
+  // gotags: json:"con_pressure_3th"
+  double       con_pressure_3th = 27;     // 三段浓水压力
+  // gotags: json:"product_pressure_3th"
+  double       product_pressure_3th = 28; // 三段产水压力
+  // gotags: json:"tmp_3th"
+  double       tmp_3th = 29;              // 三段压差
+  // gotags: json:"flux_3th"
+  double       flux_3th = 30;             // 三段通量
+  // gotags: json:"permeability_3th"
+  double       permeability_3th = 31;     // 三段渗透率
+  // gotags: json:"feed_wq_turbidity"
+  double       feed_wq_turbidity = 32;    // 进水浊度
+  // gotags: json:"feed_wq_ph"
+  int64        feed_wq_ph = 33;           // 进水 PH 值
+  // gotags: json:"product_wq_ph"
+  int64        product_wq_ph = 34;        // 产水 PH 值
+  // gotags: json:"feed_wq_al"
+  double       feed_wq_al = 35;           // 进水水质:铝
+  // gotags: json:"product_wq_al"
+  double       product_wq_al = 36;        // 产水水质:铝
+  // gotags: json:"feed_wq_fe"
+  double       feed_wq_fe = 37;           // 进水水质:铁
+  // gotags: json:"product_wq_fe"
+  double       product_wq_fe = 38;        // 产水水质:铁
+  // gotags: json:"feed_wq_mn"
+  double       feed_wq_mn = 39;           // 进水水质:锰
+  // gotags: json:"product_wq_mn"
+  double       product_wq_mn = 40;        // 产水水质:锰
+  // gotags: json:"feed_wq_sio2"
+  double       feed_wq_sio2 = 41;         // 进水水质:二氧化硅
+  // gotags: json:"product_wq_sio2"
+  double       product_wq_sio2 = 42;      // 产水水质:二氧化硅
+  // gotags: json:"feed_wq_cod"
+  double       feed_wq_cod = 43;          // 进水水质:COD
+  // gotags: json:"product_wq_cod"
+  double       product_wq_cod = 44;       // 产水水质:COD
+  // gotags: json:"feed_wq_p"
+  double       feed_wq_p = 45;            // 进水水质:磷
+  // gotags: json:"product_wq_p"
+  double       product_wq_p = 46;         // 产水水质:磷
+  // gotags: json:"step"
+  int64        step = 47;                 // 设备当前步序值
+  // gotags: json:"c_time"
+  string       c_time = 48;
+}
+
 message WorkingRo{
-    int64         id = 1;
-    int64         project_id = 2;
-    string        device_code = 3;
-    double       water_temperature = 4;    // 水温 摄氏度
-    double       feed_flow_1st = 5;        // 一段进水流量
-    double       con_flow_1st = 6;         // 一段浓水流量
-    double       product_flow_1st = 7;     // 一段产水流量
-    double       feed_pressure_1st = 8;    // 一段进水压力
-    double       con_pressure_1st = 9;     // 一段浓水压力
-    double       product_pressure_1st = 10; // 一段产水压力
-    double       tmp_1st = 11;              // 一段跨膜压差
-    double       flux_1st = 12;             // 一段膜通量
-    double       permeability_1st = 13;     // 一段渗透率
-    double       feed_flow_2nd = 14;        // 二段进水流量
-    double       con_flow_2nd = 15;         // 二段浓水流量
-    double       product_flow_2nd = 16;     // 二段产水流量
-    double       feed_pressure_2nd = 17;    // 二段进水压力
-    double       con_pressure_2nd = 18;     // 二段浓水压力
-    double       product_pressure_2nd = 19; // 二段产水压力
-    double       tmp_2nd = 20;              // 二段压差
-    double       flux_2nd = 21;             // 二段通量
-    double       permeability_2nd = 22;     // 二段渗透率
-    double       feed_flow_3th = 23;        // 三段进水流量
-    double       con_flow_3th = 24;         // 三段浓水流量
-    double       product_flow_3th = 25;     // 三段产水流量
-    double       feed_pressure_3th = 26;    // 三段进水压力
-    double       con_pressure_3th = 27;     // 三段浓水压力
-    double       product_pressure_3th = 28; // 三段产水压力
-    double       tmp_3th = 29;              // 三段压差
-    double       flux_3th = 30;             // 三段通量
-    double       permeability_3th = 31;     // 三段渗透率
-    double       feed_wq_turbidity = 32;    // 进水浊度
-    int64        feed_wq_ph = 33;           // 进水 PH 值
-    int64        product_wq_ph = 34;        // 产水 PH 值
-    double       feed_wq_al = 35;           // 进水水质:铝
-    double       product_wq_al = 36;        // 产水水质:铝
-    double       feed_wq_fe = 37;           // 进水水质:铁
-    double       product_wq_fe = 38;        // 产水水质:铁
-    double       feed_wq_mn = 39;           // 进水水质:锰
-    double       product_wq_mn = 40;        // 产水水质:锰
-    double       feed_wq_sio2 = 41;         // 进水水质:二氧化硅
-    double       product_wq_sio2 = 42;      // 产水水质:二氧化硅
-    double       feed_wq_cod = 43;          // 进水水质:COD
-    double       product_wq_cod = 44;       // 产水水质:COD
-    double       feed_wq_p = 45;            // 进水水质:磷
-    double       product_wq_p = 46;         // 产水水质:磷
-    int64        step = 47;                 // 设备当前步序值
-    string       c_time = 48;
+  // gotags: json:"id"
+  int64         id = 1;
+  // gotags: json:"project_id"
+  int64         project_id = 2;
+  // gotags: json:"device_code"
+  string        device_code = 3;
+  // gotags: json:"water_temperature"
+  double       water_temperature = 4;    // 水温 摄氏度
+  // gotags: json:"feed_flow_1st"
+  double       feed_flow_1st = 5;        // 一段进水流量
+  // gotags: json:"con_flow_1st"
+  double       con_flow_1st = 6;         // 一段浓水流量
+  // gotags: json:"product_flow_1st"
+  double       product_flow_1st = 7;     // 一段产水流量
+  // gotags: json:"feed_pressure_1st"
+  double       feed_pressure_1st = 8;    // 一段进水压力
+  // gotags: json:"con_pressure_1st"
+  double       con_pressure_1st = 9;     // 一段浓水压力
+  // gotags: json:"product_pressure_1st"
+  double       product_pressure_1st = 10; // 一段产水压力
+  // gotags: json:"tmp_1st"
+  double       tmp_1st = 11;              // 一段跨膜压差
+  // gotags: json:"flux_1st"
+  double       flux_1st = 12;             // 一段膜通量
+  // gotags: json:"permeability_1st"
+  double       permeability_1st = 13;     // 一段渗透率
+  // gotags: json:"feed_flow_2nd"
+  double       feed_flow_2nd = 14;        // 二段进水流量
+  // gotags: json:"con_flow_2nd"
+  double       con_flow_2nd = 15;         // 二段浓水流量
+  // gotags: json:"product_flow_2nd"
+  double       product_flow_2nd = 16;     // 二段产水流量
+  // gotags: json:"feed_pressure_2nd"
+  double       feed_pressure_2nd = 17;    // 二段进水压力
+  // gotags: json:"con_pressure_2nd"
+  double       con_pressure_2nd = 18;     // 二段浓水压力
+  // gotags: json:"product_pressure_2nd"
+  double       product_pressure_2nd = 19; // 二段产水压力
+  // gotags: json:"tmp_2nd"
+  double       tmp_2nd = 20;              // 二段压差
+  // gotags: json:"flux_2nd"
+  double       flux_2nd = 21;             // 二段通量
+  // gotags: json:"permeability_2nd"
+  double       permeability_2nd = 22;     // 二段渗透率
+  // gotags: json:"feed_flow_3th"
+  double       feed_flow_3th = 23;        // 三段进水流量
+  // gotags: json:"con_flow_3th"
+  double       con_flow_3th = 24;         // 三段浓水流量
+  // gotags: json:"product_flow_3th"
+  double       product_flow_3th = 25;     // 三段产水流量
+  // gotags: json:"feed_pressure_3th"
+  double       feed_pressure_3th = 26;    // 三段进水压力
+  // gotags: json:"con_pressure_3th"
+  double       con_pressure_3th = 27;     // 三段浓水压力
+  // gotags: json:"product_pressure_3th"
+  double       product_pressure_3th = 28; // 三段产水压力
+  // gotags: json:"tmp_3th"
+  double       tmp_3th = 29;              // 三段压差
+  // gotags: json:"flux_3th"
+  double       flux_3th = 30;             // 三段通量
+  // gotags: json:"permeability_3th"
+  double       permeability_3th = 31;     // 三段渗透率
+  // gotags: json:"feed_wq_turbidity"
+  double       feed_wq_turbidity = 32;    // 进水浊度
+  // gotags: json:"feed_wq_ph"
+  int64        feed_wq_ph = 33;           // 进水 PH 值
+  // gotags: json:"product_wq_ph"
+  int64        product_wq_ph = 34;        // 产水 PH 值
+  // gotags: json:"feed_wq_al"
+  double       feed_wq_al = 35;           // 进水水质:铝
+  // gotags: json:"product_wq_al"
+  double       product_wq_al = 36;        // 产水水质:铝
+  // gotags: json:"feed_wq_fe"
+  double       feed_wq_fe = 37;           // 进水水质:铁
+  // gotags: json:"product_wq_fe"
+  double       product_wq_fe = 38;        // 产水水质:铁
+  // gotags: json:"feed_wq_mn"
+  double       feed_wq_mn = 39;           // 进水水质:锰
+  // gotags: json:"product_wq_mn"
+  double       product_wq_mn = 40;        // 产水水质:锰
+  // gotags: json:"feed_wq_sio2"
+  double       feed_wq_sio2 = 41;         // 进水水质:二氧化硅
+  // gotags: json:"product_wq_sio2"
+  double       product_wq_sio2 = 42;      // 产水水质:二氧化硅
+  // gotags: json:"feed_wq_cod"
+  double       feed_wq_cod = 43;          // 进水水质:COD
+  // gotags: json:"product_wq_cod"
+  double       product_wq_cod = 44;       // 产水水质:COD
+  // gotags: json:"feed_wq_p"
+  double       feed_wq_p = 45;            // 进水水质:磷
+  // gotags: json:"product_wq_p"
+  double       product_wq_p = 46;         // 产水水质:磷
+  // gotags: json:"step"
+  int64        step = 47;                 // 设备当前步序值
+  // gotags: json:"c_time"
+  string       c_time = 48;
 }
 
 message WorkingChest {
+  // @gotags: json:"id"
   int64     id = 1;
+  // @gotags: json:"project_id"
   int64     project_id = 2;
+  // @gotags: json:"device_code"
   string    device_code = 3;
+  // @gotags: json:"switch"
   int64     switch = 4;                // 药箱液位开关 0: 关 1: 开
+  // @gotags: json:"level"
   double    level = 5;                 // 液位高度
+  // @gotags: json:"agitator_status"
   int64     agitator_status = 6;       // 搅拌器运行状态 0: 未运行 1:运行中
+  // @gotags: json:"agitator_duration"
   int64     agitator_duration = 7;     // 搅拌器运行时长
+  // @gotags: json:"agitator_fault_status"
   int64     agitator_fault_status = 8; // 搅拌器故障状态 0:正常 1:故障
+  // @gotags: json:"c_time"
   string    c_time = 9;
 }
 
 message WorkingPump {
+  // @gotags: json:"id"
   int64     id = 1;
+  // @gotags: json:"project_id"
   int64     project_id = 2;
+  // @gotags: json:"device_code"
   string    device_code = 3;
+  // @gotags: json:"feed_pressure"
   double    feed_pressure = 4; // 进水压力
+  // @gotags: json:"out_pressure"
   double    out_pressure = 5;  // 出水压力
+  // @gotags: json:"duration"
   int64     duration = 6;      // 运行时长 单位 s
+  // @gotags: json:"current"
   double    current = 7;       // 运行电流
+  // @gotags: json:"frequency"
   double    frequency = 8;     // 运行频率
+  // @gotags: json:"lift"
   double    lift = 9;          // 工作扬程
+  // @gotags: json:"efficiency"
   double    efficiency = 10;    // 运行效率
+  // @gotags: json:"run_status"
   int64     run_status = 11;    // 运行状态 0: 停机 1: 运行正常
+  // @gotags: json:"fault_status"
   int64     fault_status = 12;  // 故障状态 0: 正常 1: 故障
+  // @gotags: json:"c_time"
   string    c_time = 13;
 }
 
 message WorkingValve {
+  // @gotags: json:"id"
   int64     id = 1;
+  // @gotags: json:"project_id"
   int64     project_id = 2;
+  // @gotags: json:"device_code"
   string    device_code = 3;
+  // @gotags: json:"adjust"
   int64     adjust = 4;       // 是否为调节阀门 0: 否 1: 是
+  // @gotags: json:"opening"
   double    opening = 5;      // 当前阀门的开度
+  // @gotags: json:"closed"
   int64     closed = 6;       // 关到位 全关  0: 否 1: 是
+  // @gotags: json:"opened"
   int64     opened = 7;       // 开到位 开到 设置的开度 0: 否 1: 是
+  // @gotags: json:"fault_status"
   int64     fault_status = 8; // 是否故障 0: 否 1: 是
+  // @gotags: json:"c_time"
   string    c_time = 9;
 }
 
 message ItemHistoryData {
+  // @gotags: json:"project_id"
   int64     project_id = 1;
+  // @gotags: json:"item_name"
   string    item_name = 2;
-  // @gotags: valid:"val"
+  // @gotags: json:"val"
   double    val = 3;
+  // @gotags: json:"h_time"
   string    h_time = 4;
 }
 
 message MultiAddItemHistoryDataReq {
+  // @gotags: json:"project_id"
   int64     project_id = 1;
-  // @gotags: valid:"list"
+  // @gotags: json:"list"
   repeated ItemHistoryData list = 2;
 }
 
 message MultiAddItemHistoryDataResp {}
 
 message ItemHistoryDataListReq {
+  // @gotags: json:"project_id"
   int64     project_id = 1;
+  // @gotags: json:"item_name"
   string    item_name = 2;
+  // @gotags: json:"interval"
   string    interval = 3;     //时间单位 s,minute,h,day
+  // @gotags: json:"aggregator"
   string    aggregator = 4;   //聚合方式 min,max,avg,sum,realtime, new
+  // @gotags: json:"stime"
   string    stime = 5;
+  // @gotags: json:"etime"
   string    etime = 6;
+  // @gotags: json:"size"
   int64     size = 7;
 }
 
 message ItemHistoryDataByTimeReq {
+  // @gotags: json:"project_id"
   int64     project_id = 1;
+  // @gotags: json:"item_name"
   string    item_name = 2;
+  // @gotags: json:"stime"
   string    stime = 3;
+  // @gotags: json:"etime"
   string    etime = 4;
 }
 
@@ -172,23 +460,60 @@ message ItemHistoryDataMaxMinResp {
 }
 
 message ItemHistoryDataList {
+  // @gotags: json:"item_name"
   string    item_name = 1;
   // @gotags: json:"val"
   double    val = 2;
+  // @gotags: json:"h_time"
   string    h_time = 3;
 }
 
 message ItemHistoryDataListResp {
-  // @gotags: valid:"list"
+  // @gotags: json:"list"
   repeated ItemHistoryDataList list = 1;
 }
 
+message GetWorkingUfByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingUf list = 1;
+}
+
+message GetWorkingRoByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingRo list = 1;
+}
+
+message GetWorkingNfByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingNf list = 1;
+}
+
+message GetWorkingMfByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingMf list = 1;
+}
+
+message GetWorkingPumpByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingPump list = 1;
+}
+
+message GetWorkingValveByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingValve list = 1;
+}
+
+message GetWorkingChestByCodeResp{
+  // @gotags: json:"list"
+  repeated WorkingChest list = 1;
+}
+
 service Organization {
-  rpc GetWorkingUfByCode(DcWorkingReq) returns(WorkingUf);
-  rpc GetWorkingRoByCode(DcWorkingReq) returns(WorkingRo);
-  rpc GetWorkingChestByCode(DcWorkingReq) returns(WorkingChest);
-  rpc GetWorkingPumpByCode(DcWorkingReq) returns(WorkingPump);
-  rpc GetWorkingValueByCode(DcWorkingReq) returns(WorkingValve);
+  rpc GetWorkingUfByCode(DcWorkingReq) returns(GetWorkingUfByCodeResp);
+  rpc GetWorkingRoByCode(DcWorkingReq) returns(GetWorkingRoByCodeResp);
+  rpc GetWorkingChestByCode(DcWorkingReq) returns(GetWorkingChestByCodeResp);
+  rpc GetWorkingPumpByCode(DcWorkingReq) returns(GetWorkingPumpByCodeResp);
+  rpc GetWorkingValveByCode(DcWorkingReq) returns(GetWorkingValveByCodeResp);
   rpc MultiAddItemHistoryData(MultiAddItemHistoryDataReq) returns(MultiAddItemHistoryDataResp);
   rpc ItemHistoryDataList(ItemHistoryDataListReq) returns(ItemHistoryDataListResp);
   rpc ItemHistoryDataByTime(ItemHistoryDataByTimeReq) returns(ItemHistoryDataListResp);

+ 20 - 11
app/cmd/organization/organization/organization.go

@@ -14,6 +14,13 @@ import (
 
 type (
 	DcWorkingReq                = pb.DcWorkingReq
+	GetWorkingChestByCodeResp   = pb.GetWorkingChestByCodeResp
+	GetWorkingMfByCodeResp      = pb.GetWorkingMfByCodeResp
+	GetWorkingNfByCodeResp      = pb.GetWorkingNfByCodeResp
+	GetWorkingPumpByCodeResp    = pb.GetWorkingPumpByCodeResp
+	GetWorkingRoByCodeResp      = pb.GetWorkingRoByCodeResp
+	GetWorkingUfByCodeResp      = pb.GetWorkingUfByCodeResp
+	GetWorkingValveByCodeResp   = pb.GetWorkingValveByCodeResp
 	ItemHistoryData             = pb.ItemHistoryData
 	ItemHistoryDataByTimeReq    = pb.ItemHistoryDataByTimeReq
 	ItemHistoryDataList         = pb.ItemHistoryDataList
@@ -23,17 +30,19 @@ type (
 	MultiAddItemHistoryDataReq  = pb.MultiAddItemHistoryDataReq
 	MultiAddItemHistoryDataResp = pb.MultiAddItemHistoryDataResp
 	WorkingChest                = pb.WorkingChest
+	WorkingMf                   = pb.WorkingMf
+	WorkingNf                   = pb.WorkingNf
 	WorkingPump                 = pb.WorkingPump
 	WorkingRo                   = pb.WorkingRo
 	WorkingUf                   = pb.WorkingUf
 	WorkingValve                = pb.WorkingValve
 
 	Organization interface {
-		GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingUf, error)
-		GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingRo, error)
-		GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingChest, error)
-		GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error)
-		GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error)
+		GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingUfByCodeResp, error)
+		GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingRoByCodeResp, error)
+		GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingChestByCodeResp, error)
+		GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingPumpByCodeResp, error)
+		GetWorkingValveByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingValveByCodeResp, error)
 		MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
 		ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error)
 		ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error)
@@ -51,29 +60,29 @@ func NewOrganization(cli zrpc.Client) Organization {
 	}
 }
 
-func (m *defaultOrganization) GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingUf, error) {
+func (m *defaultOrganization) GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingUfByCodeResp, error) {
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.GetWorkingUfByCode(ctx, in, opts...)
 }
 
-func (m *defaultOrganization) GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingRo, error) {
+func (m *defaultOrganization) GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingRoByCodeResp, error) {
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.GetWorkingRoByCode(ctx, in, opts...)
 }
 
-func (m *defaultOrganization) GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingChest, error) {
+func (m *defaultOrganization) GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingChestByCodeResp, error) {
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.GetWorkingChestByCode(ctx, in, opts...)
 }
 
-func (m *defaultOrganization) GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error) {
+func (m *defaultOrganization) GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingPumpByCodeResp, error) {
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.GetWorkingPumpByCode(ctx, in, opts...)
 }
 
-func (m *defaultOrganization) GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error) {
+func (m *defaultOrganization) GetWorkingValveByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingValveByCodeResp, error) {
 	client := pb.NewOrganizationClient(m.cli.Conn())
-	return client.GetWorkingValueByCode(ctx, in, opts...)
+	return client.GetWorkingValveByCode(ctx, in, opts...)
 }
 
 func (m *defaultOrganization) MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error) {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 616 - 366
app/cmd/organization/pb/organization.pb.go


+ 33 - 33
app/cmd/organization/pb/organization_grpc.pb.go

@@ -22,11 +22,11 @@ const _ = grpc.SupportPackageIsVersion7
 //
 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
 type OrganizationClient interface {
-	GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingUf, error)
-	GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingRo, error)
-	GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingChest, error)
-	GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error)
-	GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error)
+	GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingUfByCodeResp, error)
+	GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingRoByCodeResp, error)
+	GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingChestByCodeResp, error)
+	GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingPumpByCodeResp, error)
+	GetWorkingValveByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingValveByCodeResp, error)
 	MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
 	ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error)
 	ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*ItemHistoryDataListResp, error)
@@ -41,8 +41,8 @@ func NewOrganizationClient(cc grpc.ClientConnInterface) OrganizationClient {
 	return &organizationClient{cc}
 }
 
-func (c *organizationClient) GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingUf, error) {
-	out := new(WorkingUf)
+func (c *organizationClient) GetWorkingUfByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingUfByCodeResp, error) {
+	out := new(GetWorkingUfByCodeResp)
 	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingUfByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
@@ -50,8 +50,8 @@ func (c *organizationClient) GetWorkingUfByCode(ctx context.Context, in *DcWorki
 	return out, nil
 }
 
-func (c *organizationClient) GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingRo, error) {
-	out := new(WorkingRo)
+func (c *organizationClient) GetWorkingRoByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingRoByCodeResp, error) {
+	out := new(GetWorkingRoByCodeResp)
 	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingRoByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
@@ -59,8 +59,8 @@ func (c *organizationClient) GetWorkingRoByCode(ctx context.Context, in *DcWorki
 	return out, nil
 }
 
-func (c *organizationClient) GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingChest, error) {
-	out := new(WorkingChest)
+func (c *organizationClient) GetWorkingChestByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingChestByCodeResp, error) {
+	out := new(GetWorkingChestByCodeResp)
 	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingChestByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
@@ -68,8 +68,8 @@ func (c *organizationClient) GetWorkingChestByCode(ctx context.Context, in *DcWo
 	return out, nil
 }
 
-func (c *organizationClient) GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error) {
-	out := new(WorkingPump)
+func (c *organizationClient) GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingPumpByCodeResp, error) {
+	out := new(GetWorkingPumpByCodeResp)
 	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingPumpByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
@@ -77,9 +77,9 @@ func (c *organizationClient) GetWorkingPumpByCode(ctx context.Context, in *DcWor
 	return out, nil
 }
 
-func (c *organizationClient) GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error) {
-	out := new(WorkingValve)
-	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingValueByCode", in, out, opts...)
+func (c *organizationClient) GetWorkingValveByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*GetWorkingValveByCodeResp, error) {
+	out := new(GetWorkingValveByCodeResp)
+	err := c.cc.Invoke(ctx, "/pb.Organization/GetWorkingValveByCode", in, out, opts...)
 	if err != nil {
 		return nil, err
 	}
@@ -126,11 +126,11 @@ func (c *organizationClient) ItemHistoryDataMaxMinByTime(ctx context.Context, in
 // All implementations must embed UnimplementedOrganizationServer
 // for forward compatibility
 type OrganizationServer interface {
-	GetWorkingUfByCode(context.Context, *DcWorkingReq) (*WorkingUf, error)
-	GetWorkingRoByCode(context.Context, *DcWorkingReq) (*WorkingRo, error)
-	GetWorkingChestByCode(context.Context, *DcWorkingReq) (*WorkingChest, error)
-	GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*WorkingPump, error)
-	GetWorkingValueByCode(context.Context, *DcWorkingReq) (*WorkingValve, error)
+	GetWorkingUfByCode(context.Context, *DcWorkingReq) (*GetWorkingUfByCodeResp, error)
+	GetWorkingRoByCode(context.Context, *DcWorkingReq) (*GetWorkingRoByCodeResp, error)
+	GetWorkingChestByCode(context.Context, *DcWorkingReq) (*GetWorkingChestByCodeResp, error)
+	GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*GetWorkingPumpByCodeResp, error)
+	GetWorkingValveByCode(context.Context, *DcWorkingReq) (*GetWorkingValveByCodeResp, error)
 	MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error)
 	ItemHistoryDataList(context.Context, *ItemHistoryDataListReq) (*ItemHistoryDataListResp, error)
 	ItemHistoryDataByTime(context.Context, *ItemHistoryDataByTimeReq) (*ItemHistoryDataListResp, error)
@@ -142,20 +142,20 @@ type OrganizationServer interface {
 type UnimplementedOrganizationServer struct {
 }
 
-func (UnimplementedOrganizationServer) GetWorkingUfByCode(context.Context, *DcWorkingReq) (*WorkingUf, error) {
+func (UnimplementedOrganizationServer) GetWorkingUfByCode(context.Context, *DcWorkingReq) (*GetWorkingUfByCodeResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingUfByCode not implemented")
 }
-func (UnimplementedOrganizationServer) GetWorkingRoByCode(context.Context, *DcWorkingReq) (*WorkingRo, error) {
+func (UnimplementedOrganizationServer) GetWorkingRoByCode(context.Context, *DcWorkingReq) (*GetWorkingRoByCodeResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingRoByCode not implemented")
 }
-func (UnimplementedOrganizationServer) GetWorkingChestByCode(context.Context, *DcWorkingReq) (*WorkingChest, error) {
+func (UnimplementedOrganizationServer) GetWorkingChestByCode(context.Context, *DcWorkingReq) (*GetWorkingChestByCodeResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingChestByCode not implemented")
 }
-func (UnimplementedOrganizationServer) GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*WorkingPump, error) {
+func (UnimplementedOrganizationServer) GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*GetWorkingPumpByCodeResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingPumpByCode not implemented")
 }
-func (UnimplementedOrganizationServer) GetWorkingValueByCode(context.Context, *DcWorkingReq) (*WorkingValve, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingValueByCode not implemented")
+func (UnimplementedOrganizationServer) GetWorkingValveByCode(context.Context, *DcWorkingReq) (*GetWorkingValveByCodeResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingValveByCode not implemented")
 }
 func (UnimplementedOrganizationServer) MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method MultiAddItemHistoryData not implemented")
@@ -254,20 +254,20 @@ func _Organization_GetWorkingPumpByCode_Handler(srv interface{}, ctx context.Con
 	return interceptor(ctx, in, info, handler)
 }
 
-func _Organization_GetWorkingValueByCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+func _Organization_GetWorkingValveByCode_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(DcWorkingReq)
 	if err := dec(in); err != nil {
 		return nil, err
 	}
 	if interceptor == nil {
-		return srv.(OrganizationServer).GetWorkingValueByCode(ctx, in)
+		return srv.(OrganizationServer).GetWorkingValveByCode(ctx, in)
 	}
 	info := &grpc.UnaryServerInfo{
 		Server:     srv,
-		FullMethod: "/pb.Organization/GetWorkingValueByCode",
+		FullMethod: "/pb.Organization/GetWorkingValveByCode",
 	}
 	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(OrganizationServer).GetWorkingValueByCode(ctx, req.(*DcWorkingReq))
+		return srv.(OrganizationServer).GetWorkingValveByCode(ctx, req.(*DcWorkingReq))
 	}
 	return interceptor(ctx, in, info, handler)
 }
@@ -368,8 +368,8 @@ var Organization_ServiceDesc = grpc.ServiceDesc{
 			Handler:    _Organization_GetWorkingPumpByCode_Handler,
 		},
 		{
-			MethodName: "GetWorkingValueByCode",
-			Handler:    _Organization_GetWorkingValueByCode_Handler,
+			MethodName: "GetWorkingValveByCode",
+			Handler:    _Organization_GetWorkingValveByCode_Handler,
 		},
 		{
 			MethodName: "MultiAddItemHistoryData",

+ 34 - 0
app/model/dcWorkingChestModel.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcWorkingChestModel = (*customDcWorkingChestModel)(nil)
@@ -15,6 +16,7 @@ type (
 	DcWorkingChestModel interface {
 		dcWorkingChestModel
 		FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingChest, error)
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingChest, error)
 	}
 
 	customDcWorkingChestModel struct {
@@ -42,3 +44,35 @@ func (m *defaultDcWorkingChestModel) FindOneByCode(ctx context.Context, projectI
 		return nil, err
 	}
 }
+
+func (m *defaultDcWorkingChestModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingChest, error) {
+	var resp []DcWorkingChest
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingChestRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}

+ 40 - 1
app/model/dcWorkingMfModel.go

@@ -1,6 +1,12 @@
 package model
 
-import "github.com/zeromicro/go-zero/core/stores/sqlx"
+import (
+	"context"
+	"fmt"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
+)
 
 var _ DcWorkingMfModel = (*customDcWorkingMfModel)(nil)
 
@@ -9,6 +15,7 @@ type (
 	// and implement the added methods in customDcWorkingMfModel.
 	DcWorkingMfModel interface {
 		dcWorkingMfModel
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingMf, error)
 	}
 
 	customDcWorkingMfModel struct {
@@ -22,3 +29,35 @@ func NewDcWorkingMfModel(conn sqlx.SqlConn) DcWorkingMfModel {
 		defaultDcWorkingMfModel: newDcWorkingMfModel(conn),
 	}
 }
+
+func (m *defaultDcWorkingMfModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingMf, error) {
+	var resp []DcWorkingMf
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingMfRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}

+ 40 - 1
app/model/dcWorkingNfModel.go

@@ -1,6 +1,12 @@
 package model
 
-import "github.com/zeromicro/go-zero/core/stores/sqlx"
+import (
+	"context"
+	"fmt"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
+)
 
 var _ DcWorkingNfModel = (*customDcWorkingNfModel)(nil)
 
@@ -9,6 +15,7 @@ type (
 	// and implement the added methods in customDcWorkingNfModel.
 	DcWorkingNfModel interface {
 		dcWorkingNfModel
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingNf, error)
 	}
 
 	customDcWorkingNfModel struct {
@@ -22,3 +29,35 @@ func NewDcWorkingNfModel(conn sqlx.SqlConn) DcWorkingNfModel {
 		defaultDcWorkingNfModel: newDcWorkingNfModel(conn),
 	}
 }
+
+func (m *defaultDcWorkingNfModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingNf, error) {
+	var resp []DcWorkingNf
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingNfRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}

+ 34 - 0
app/model/dcWorkingPumpModel.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcWorkingPumpModel = (*customDcWorkingPumpModel)(nil)
@@ -15,6 +16,7 @@ type (
 	DcWorkingPumpModel interface {
 		dcWorkingPumpModel
 		FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingPump, error)
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingPump, error)
 	}
 
 	customDcWorkingPumpModel struct {
@@ -29,6 +31,38 @@ func NewDcWorkingPumpModel(conn sqlx.SqlConn) DcWorkingPumpModel {
 	}
 }
 
+func (m *defaultDcWorkingPumpModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingPump, error) {
+	var resp []DcWorkingPump
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingPumpRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
 func (m *defaultDcWorkingPumpModel) FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingPump, error) {
 	var resp DcWorkingPump
 	query := fmt.Sprintf("select %s from %s where `project_id` = ? and `device_code` = ? order by c_time desc limit 1", dcWorkingPumpRows, m.table)

+ 34 - 0
app/model/dcWorkingRoModel.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcWorkingRoModel = (*customDcWorkingRoModel)(nil)
@@ -15,6 +16,7 @@ type (
 	DcWorkingRoModel interface {
 		dcWorkingRoModel
 		FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingRo, error)
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingRo, error)
 	}
 
 	customDcWorkingRoModel struct {
@@ -29,6 +31,38 @@ func NewDcWorkingRoModel(conn sqlx.SqlConn) DcWorkingRoModel {
 	}
 }
 
+func (m *defaultDcWorkingRoModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingRo, error) {
+	var resp []DcWorkingRo
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingRoRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
 func (m *defaultDcWorkingRoModel) FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingRo, error) {
 	var resp DcWorkingRo
 	query := fmt.Sprintf("select %s from %s where `project_id` = ? and `device_code` = ? order by c_time desc limit 1", dcWorkingRoRows, m.table)

+ 35 - 0
app/model/dcWorkingUfModel.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcWorkingUfModel = (*customDcWorkingUfModel)(nil)
@@ -15,6 +16,8 @@ type (
 	DcWorkingUfModel interface {
 		dcWorkingUfModel
 		FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingUf, error)
+
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingUf, error)
 	}
 
 	customDcWorkingUfModel struct {
@@ -29,6 +32,38 @@ func NewDcWorkingUfModel(conn sqlx.SqlConn) DcWorkingUfModel {
 	}
 }
 
+func (m *defaultDcWorkingUfModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingUf, error) {
+	var resp []DcWorkingUf
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingUfRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
 func (m *defaultDcWorkingUfModel) FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingUf, error) {
 	var resp DcWorkingUf
 	query := fmt.Sprintf("select %s from %s where `project_id` = ? and `device_code` = ? order by c_time desc limit 1", dcWorkingUfRows, m.table)

+ 36 - 0
app/model/dcWorkingValveModel.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcWorkingValveModel = (*customDcWorkingValveModel)(nil)
@@ -15,6 +16,8 @@ type (
 	DcWorkingValveModel interface {
 		dcWorkingValveModel
 		FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingValve, error)
+
+		Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingValve, error)
 	}
 
 	customDcWorkingValveModel struct {
@@ -28,6 +31,39 @@ func NewDcWorkingValveModel(conn sqlx.SqlConn) DcWorkingValveModel {
 		defaultDcWorkingValveModel: newDcWorkingValveModel(conn),
 	}
 }
+
+func (m *defaultDcWorkingValveModel) Search(ctx context.Context, projectId int64, deviceCode, st, et string, offset, limit int64, orderBy string) ([]DcWorkingValve, error) {
+	var resp []DcWorkingValve
+
+	condition := []string{"`project_id`=?", "`device_code`=?"}
+	vars := []interface{}{projectId, deviceCode}
+
+	if st != "" {
+		condition = append(condition, "`c_time`>=?")
+		vars = append(vars, st)
+	}
+
+	if et != "" {
+		condition = append(condition, "`c_time`<?")
+		vars = append(vars, et)
+	}
+
+	if orderBy == "" {
+		orderBy = "id desc"
+	}
+
+	query := fmt.Sprintf("select %s from %s where %s order by %s limit %d, %d", dcWorkingValveRows, m.table, strings.Join(condition, " and "), orderBy, offset, limit)
+	err := m.conn.QueryRowsCtx(ctx, &resp, query, vars...)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
 func (m *defaultDcWorkingValveModel) FindOneByCode(ctx context.Context, projectId int64, deviceCode string) (*DcWorkingValve, error) {
 	var resp DcWorkingValve
 	query := fmt.Sprintf("select %s from %s where `project_id` = ? and `device_code` = ? order by c_time desc limit 1", dcWorkingValveRows, m.table)

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác