فهرست منبع

点位查询接口

songxiaohang 1 سال پیش
والد
کامیت
50371422ba

+ 8 - 0
app/cmd/api/desc/datacenter.api

@@ -32,4 +32,12 @@ service datacenter {
 	@doc "秒级单点数据批量入库"
 	@handler ItemHistoryData
 	post /item-history/multi-add (MultiAddItemHistoryDataReq) returns (MultiAddItemHistoryDataResq)
+	
+	@doc "点位历史数据查询"
+	@handler ItemHistoryDataList
+	post /item-history/list (ItemHistoryDataListResq) returns (MultiAddItemHistoryDataReq)
+	
+	@doc "按时间点位历史数据查询"
+	@handler ItemHistoryDataInfo
+	post /item-history/info (ItemHistoryDataByTimeResq) returns (MultiAddItemHistoryDataReq)
 }

+ 19 - 0
app/cmd/api/desc/datacenter/datacenter.api

@@ -160,3 +160,22 @@ type (
     MultiAddItemHistoryDataResq{}
 )
 
+type (
+    ItemHistoryDataListResq{
+        ProjectId   int64     `json:"project_id"`
+        ItemName    string    `json:"item_name"`
+        Size        int64     `json:"size"`         //结果间隔
+        Interval    string    `json:"interval"`     //时间单位 s,minute,h,day
+        Aggregator  string    `json:"aggregator"`   //聚合方式 min,max,avg,sum,realtime, new
+        STime       string    `json:"stime"`
+        ETime       string    `json:"etime"`
+    }
+
+    ItemHistoryDataByTimeResq{
+        ProjectId   int64     `json:"project_id"`
+        ItemName    string    `json:"item_name"`
+        STime       string    `json:"stime"`
+        ETime       string    `json:"etime"`
+    }
+)
+

+ 28 - 0
app/cmd/api/internal/handler/datacenter/itemHistoryDataInfoHandler.go

@@ -0,0 +1,28 @@
+package datacenter
+
+import (
+	"net/http"
+
+	"GtDataStore/app/cmd/api/internal/logic/datacenter"
+	"GtDataStore/app/cmd/api/internal/svc"
+	"GtDataStore/app/cmd/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ItemHistoryDataInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ItemHistoryDataByTimeResq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := datacenter.NewItemHistoryDataInfoLogic(r.Context(), svcCtx)
+		resp, err := l.ItemHistoryDataInfo(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 25 - 0
app/cmd/api/internal/handler/datacenter/itemHistoryDataListHandler.go

@@ -0,0 +1,25 @@
+package datacenter
+
+import (
+	"GtDataStore/common/result"
+	"net/http"
+
+	"GtDataStore/app/cmd/api/internal/logic/datacenter"
+	"GtDataStore/app/cmd/api/internal/svc"
+	"GtDataStore/app/cmd/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func ItemHistoryDataListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.ItemHistoryDataListResq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := datacenter.NewItemHistoryDataListLogic(r.Context(), svcCtx)
+		resp, err := l.ItemHistoryDataList(&req)
+		result.HttpResult(r, w, resp, err)
+	}
+}

+ 10 - 0
app/cmd/api/internal/handler/routes.go

@@ -43,6 +43,16 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/item-history/multi-add",
 				Handler: datacenter.ItemHistoryDataHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/item-history/list",
+				Handler: datacenter.ItemHistoryDataListHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/item-history/info",
+				Handler: datacenter.ItemHistoryDataInfoHandler(serverCtx),
+			},
 		},
 		rest.WithPrefix("/api/datacenter/v1"),
 	)

+ 46 - 0
app/cmd/api/internal/logic/datacenter/itemHistoryDataInfoLogic.go

@@ -0,0 +1,46 @@
+package datacenter
+
+import (
+	"GtDataStore/app/cmd/organization/pb"
+	"context"
+	"github.com/jinzhu/copier"
+
+	"GtDataStore/app/cmd/api/internal/svc"
+	"GtDataStore/app/cmd/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ItemHistoryDataInfoLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewItemHistoryDataInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataInfoLogic {
+	return &ItemHistoryDataInfoLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ItemHistoryDataInfoLogic) ItemHistoryDataInfo(req *types.ItemHistoryDataByTimeResq) (resp *types.MultiAddItemHistoryDataReq, err error) {
+	respList := make([]*types.ItemHistoryData, 0)
+	dataList, err := l.svcCtx.OrganizationRpc.ItemHistoryDataByTime(l.ctx, &pb.ItemHistoryDataByTimeReq{
+		ProjectId: req.ProjectId,
+		ItemName:  req.ItemName,
+		Stime:     req.STime,
+		Etime:     req.ETime,
+	})
+	if err != nil {
+		return nil, err
+	}
+	for _, line := range dataList.List {
+		tmp := &types.ItemHistoryData{}
+		_ = copier.Copy(tmp, line)
+		respList = append(respList, tmp)
+	}
+
+	return &types.MultiAddItemHistoryDataReq{List: respList}, nil
+}

+ 47 - 0
app/cmd/api/internal/logic/datacenter/itemHistoryDataListLogic.go

@@ -0,0 +1,47 @@
+package datacenter
+
+import (
+	"GtDataStore/app/cmd/api/internal/svc"
+	"GtDataStore/app/cmd/api/internal/types"
+	"GtDataStore/app/cmd/organization/pb"
+	"context"
+	"github.com/jinzhu/copier"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ItemHistoryDataListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewItemHistoryDataListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataListLogic {
+	return &ItemHistoryDataListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ItemHistoryDataListLogic) ItemHistoryDataList(req *types.ItemHistoryDataListResq) (resp *types.MultiAddItemHistoryDataReq, err error) {
+	respList := make([]*types.ItemHistoryData, 0)
+	dataList, err := l.svcCtx.OrganizationRpc.ItemHistoryDataList(l.ctx, &pb.ItemHistoryDataListReq{
+		ProjectId:  req.ProjectId,
+		ItemName:   req.ItemName,
+		Interval:   req.Interval,
+		Aggregator: req.Aggregator,
+		Stime:      req.STime,
+		Etime:      req.ETime,
+	})
+	if err != nil {
+		return nil, err
+	}
+	for _, line := range dataList.List {
+		tmp := &types.ItemHistoryData{}
+		_ = copier.Copy(tmp, line)
+		respList = append(respList, tmp)
+	}
+
+	return &types.MultiAddItemHistoryDataReq{List: respList}, nil
+}

+ 17 - 0
app/cmd/api/internal/types/types.go

@@ -162,3 +162,20 @@ type MultiAddItemHistoryDataReq struct {
 
 type MultiAddItemHistoryDataResq struct {
 }
+
+type ItemHistoryDataListResq struct {
+	ProjectId  int64  `json:"project_id"`
+	ItemName   string `json:"item_name"`
+	Size       int64  `json:"size"`       //结果间隔
+	Interval   string `json:"interval"`   //时间单位 s,minute,h,day
+	Aggregator string `json:"aggregator"` //聚合方式 min,max,avg,sum,realtime, new
+	STime      string `json:"stime"`
+	ETime      string `json:"etime"`
+}
+
+type ItemHistoryDataByTimeResq struct {
+	ProjectId int64  `json:"project_id"`
+	ItemName  string `json:"item_name"`
+	STime     string `json:"stime"`
+	ETime     string `json:"etime"`
+}

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

@@ -13,7 +13,8 @@ Log:
 GtServerIp: 47.96.12.136:8788
 
 DtDataStoreDB:
-  DataSource: ws_data:c712f89fc4f8edaf30e41b828f4e3d26@tcp(172.16.0.194: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.194:4000)/ws_data?charset=utf8mb4&parseTime=True&loc=&loc=Asia%2FShanghai
 
 Redis:
   Host: 47.96.12.136:6379

+ 43 - 0
app/cmd/organization/internal/logic/itemHistoryDataByTimeLogic.go

@@ -0,0 +1,43 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/common/xerr"
+	"context"
+	"github.com/jinzhu/copier"
+	"github.com/pkg/errors"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ItemHistoryDataByTimeLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewItemHistoryDataByTimeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataByTimeLogic {
+	return &ItemHistoryDataByTimeLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ItemHistoryDataByTimeLogic) ItemHistoryDataByTime(in *pb.ItemHistoryDataByTimeReq) (*pb.MultiAddItemHistoryDataReq, error) {
+	modeList, err := l.svcCtx.ItemHistoryData.QueryHistoryDataByTime(l.ctx, in)
+	if err != nil {
+		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "model QueryHistoryDataByTime get data err:%v", err)
+	}
+
+	dataList := make([]*pb.ItemHistoryData, 0)
+	for _, line := range modeList {
+		tmp := &pb.ItemHistoryData{}
+		_ = copier.Copy(tmp, line)
+		tmp.CTime = line.CTime.Format("2006-01-02 15:04:05")
+		dataList = append(dataList, tmp)
+	}
+
+	return &pb.MultiAddItemHistoryDataReq{List: dataList}, nil
+}

+ 32 - 0
app/cmd/organization/internal/logic/itemHistoryDataListLogic.go

@@ -0,0 +1,32 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"context"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type ItemHistoryDataListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewItemHistoryDataListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataListLogic {
+	return &ItemHistoryDataListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *ItemHistoryDataListLogic) ItemHistoryDataList(in *pb.ItemHistoryDataListReq) (*pb.MultiAddItemHistoryDataReq, error) {
+	//_, err := l.svcCtx.ItemHistoryData.QueryHistoryData(l.ctx, in)
+	//if err != nil {
+	//	return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "item history data table multi Insert err:%v", err)
+	//}
+
+	return &pb.MultiAddItemHistoryDataReq{}, nil
+}

+ 2 - 1
app/cmd/organization/internal/logic/multiAddItemHistoryDataLogic.go

@@ -37,7 +37,8 @@ func (l *MultiAddItemHistoryDataLogic) MultiAddItemHistoryData(in *pb.MultiAddIt
 			ProjectId: data.ProjectId,
 			ItemName:  data.ItemName,
 			Val:       data.Val,
-			CTime:     t,
+			CTime:     time.Now(),
+			HTime:     t,
 		}
 	}
 	_, err := l.svcCtx.ItemHistoryData.MultiInsert(l.ctx, ts)

+ 10 - 0
app/cmd/organization/internal/server/organizationServer.go

@@ -51,3 +51,13 @@ func (s *OrganizationServer) MultiAddItemHistoryData(ctx context.Context, in *pb
 	l := logic.NewMultiAddItemHistoryDataLogic(ctx, s.svcCtx)
 	return l.MultiAddItemHistoryData(in)
 }
+
+func (s *OrganizationServer) ItemHistoryDataList(ctx context.Context, in *pb.ItemHistoryDataListReq) (*pb.MultiAddItemHistoryDataReq, error) {
+	l := logic.NewItemHistoryDataListLogic(ctx, s.svcCtx)
+	return l.ItemHistoryDataList(in)
+}
+
+func (s *OrganizationServer) ItemHistoryDataByTime(ctx context.Context, in *pb.ItemHistoryDataByTimeReq) (*pb.MultiAddItemHistoryDataReq, error) {
+	l := logic.NewItemHistoryDataByTimeLogic(ctx, s.svcCtx)
+	return l.ItemHistoryDataByTime(in)
+}

+ 19 - 0
app/cmd/organization/organization.proto

@@ -145,6 +145,23 @@ message MultiAddItemHistoryDataReq {
 
 message MultiAddItemHistoryDataResp {}
 
+message ItemHistoryDataListReq {
+  int64     project_id = 1;
+  string    item_name = 2;
+  string    interval = 3;     //时间单位 s,minute,h,day
+  string    aggregator = 4;   //聚合方式 min,max,avg,sum,realtime, new
+  string    stime = 5;
+  string    etime = 6;
+  int64     size = 7;
+}
+
+message ItemHistoryDataByTimeReq {
+  int64     project_id = 1;
+  string    item_name = 2;
+  string    stime = 3;
+  string    etime = 4;
+}
+
 service Organization {
   rpc GetWorkingUfByCode(DcWorkingReq) returns(WorkingUf);
   rpc GetWorkingRoByCode(DcWorkingReq) returns(WorkingRo);
@@ -152,4 +169,6 @@ service Organization {
   rpc GetWorkingPumpByCode(DcWorkingReq) returns(WorkingPump);
   rpc GetWorkingValueByCode(DcWorkingReq) returns(WorkingValve);
   rpc MultiAddItemHistoryData(MultiAddItemHistoryDataReq) returns(MultiAddItemHistoryDataResp);
+  rpc ItemHistoryDataList(ItemHistoryDataListReq) returns(MultiAddItemHistoryDataReq);
+  rpc ItemHistoryDataByTime(ItemHistoryDataByTimeReq) returns(MultiAddItemHistoryDataReq);
 }

+ 14 - 0
app/cmd/organization/organization/organization.go

@@ -15,6 +15,8 @@ import (
 type (
 	DcWorkingReq                = pb.DcWorkingReq
 	ItemHistoryData             = pb.ItemHistoryData
+	ItemHistoryDataByTimeReq    = pb.ItemHistoryDataByTimeReq
+	ItemHistoryDataListReq      = pb.ItemHistoryDataListReq
 	MultiAddItemHistoryDataReq  = pb.MultiAddItemHistoryDataReq
 	MultiAddItemHistoryDataResp = pb.MultiAddItemHistoryDataResp
 	WorkingChest                = pb.WorkingChest
@@ -30,6 +32,8 @@ type (
 		GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error)
 		GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error)
 		MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
+		ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error)
+		ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error)
 	}
 
 	defaultOrganization struct {
@@ -72,3 +76,13 @@ func (m *defaultOrganization) MultiAddItemHistoryData(ctx context.Context, in *M
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.MultiAddItemHistoryData(ctx, in, opts...)
 }
+
+func (m *defaultOrganization) ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.ItemHistoryDataList(ctx, in, opts...)
+}
+
+func (m *defaultOrganization) ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.ItemHistoryDataByTime(ctx, in, opts...)
+}

+ 272 - 44
app/cmd/organization/pb/organization.pb.go

@@ -1298,6 +1298,172 @@ func (*MultiAddItemHistoryDataResp) Descriptor() ([]byte, []int) {
 	return file_organization_proto_rawDescGZIP(), []int{8}
 }
 
+type ItemHistoryDataListReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ProjectId  int64  `protobuf:"varint,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
+	ItemName   string `protobuf:"bytes,2,opt,name=item_name,json=itemName,proto3" json:"item_name,omitempty"`
+	Interval   string `protobuf:"bytes,3,opt,name=interval,proto3" json:"interval,omitempty"`     //时间单位 s,minute,h,day
+	Aggregator string `protobuf:"bytes,4,opt,name=aggregator,proto3" json:"aggregator,omitempty"` //聚合方式 min,max,avg,sum,realtime, new
+	Stime      string `protobuf:"bytes,5,opt,name=stime,proto3" json:"stime,omitempty"`
+	Etime      string `protobuf:"bytes,6,opt,name=etime,proto3" json:"etime,omitempty"`
+	Size       int64  `protobuf:"varint,7,opt,name=size,proto3" json:"size,omitempty"`
+}
+
+func (x *ItemHistoryDataListReq) Reset() {
+	*x = ItemHistoryDataListReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_organization_proto_msgTypes[9]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ItemHistoryDataListReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ItemHistoryDataListReq) ProtoMessage() {}
+
+func (x *ItemHistoryDataListReq) ProtoReflect() protoreflect.Message {
+	mi := &file_organization_proto_msgTypes[9]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ItemHistoryDataListReq.ProtoReflect.Descriptor instead.
+func (*ItemHistoryDataListReq) Descriptor() ([]byte, []int) {
+	return file_organization_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *ItemHistoryDataListReq) GetProjectId() int64 {
+	if x != nil {
+		return x.ProjectId
+	}
+	return 0
+}
+
+func (x *ItemHistoryDataListReq) GetItemName() string {
+	if x != nil {
+		return x.ItemName
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataListReq) GetInterval() string {
+	if x != nil {
+		return x.Interval
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataListReq) GetAggregator() string {
+	if x != nil {
+		return x.Aggregator
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataListReq) GetStime() string {
+	if x != nil {
+		return x.Stime
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataListReq) GetEtime() string {
+	if x != nil {
+		return x.Etime
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataListReq) GetSize() int64 {
+	if x != nil {
+		return x.Size
+	}
+	return 0
+}
+
+type ItemHistoryDataByTimeReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ProjectId int64  `protobuf:"varint,1,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
+	ItemName  string `protobuf:"bytes,2,opt,name=item_name,json=itemName,proto3" json:"item_name,omitempty"`
+	Stime     string `protobuf:"bytes,3,opt,name=stime,proto3" json:"stime,omitempty"`
+	Etime     string `protobuf:"bytes,4,opt,name=etime,proto3" json:"etime,omitempty"`
+}
+
+func (x *ItemHistoryDataByTimeReq) Reset() {
+	*x = ItemHistoryDataByTimeReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_organization_proto_msgTypes[10]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ItemHistoryDataByTimeReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ItemHistoryDataByTimeReq) ProtoMessage() {}
+
+func (x *ItemHistoryDataByTimeReq) ProtoReflect() protoreflect.Message {
+	mi := &file_organization_proto_msgTypes[10]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use ItemHistoryDataByTimeReq.ProtoReflect.Descriptor instead.
+func (*ItemHistoryDataByTimeReq) Descriptor() ([]byte, []int) {
+	return file_organization_proto_rawDescGZIP(), []int{10}
+}
+
+func (x *ItemHistoryDataByTimeReq) GetProjectId() int64 {
+	if x != nil {
+		return x.ProjectId
+	}
+	return 0
+}
+
+func (x *ItemHistoryDataByTimeReq) GetItemName() string {
+	if x != nil {
+		return x.ItemName
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataByTimeReq) GetStime() string {
+	if x != nil {
+		return x.Stime
+	}
+	return ""
+}
+
+func (x *ItemHistoryDataByTimeReq) GetEtime() string {
+	if x != nil {
+		return x.Etime
+	}
+	return ""
+}
+
 var File_organization_proto protoreflect.FileDescriptor
 
 var file_organization_proto_rawDesc = []byte{
@@ -1548,33 +1714,65 @@ var file_organization_proto_rawDesc = []byte{
 	0x62, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74,
 	0x61, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x1d, 0x0a, 0x1b, 0x4d, 0x75, 0x6c, 0x74, 0x69,
 	0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61,
-	0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x32, 0x8d, 0x03, 0x0a, 0x0c, 0x4f, 0x72, 0x67, 0x61, 0x6e,
-	0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x35, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x57, 0x6f,
-	0x72, 0x6b, 0x69, 0x6e, 0x67, 0x55, 0x66, 0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e,
-	0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a,
-	0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x55, 0x66, 0x12, 0x35,
-	0x0a, 0x12, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x6f, 0x42, 0x79,
-	0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b,
-	0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b,
-	0x69, 0x6e, 0x67, 0x52, 0x6f, 0x12, 0x3b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b,
-	0x69, 0x6e, 0x67, 0x43, 0x68, 0x65, 0x73, 0x74, 0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10,
-	0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71,
-	0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x65,
-	0x73, 0x74, 0x12, 0x39, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67,
-	0x50, 0x75, 0x6d, 0x70, 0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e,
-	0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70,
-	0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x6d, 0x70, 0x12, 0x3b, 0x0a,
-	0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65,
+	0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x22, 0xd0, 0x01, 0x0a, 0x16, 0x49, 0x74, 0x65, 0x6d, 0x48,
+	0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
+	0x71, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x64,
+	0x12, 0x1b, 0x0a, 0x09, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x74, 0x65, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a,
+	0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x67, 0x67,
+	0x72, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61,
+	0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x69,
+	0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x12,
+	0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
+	0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x82, 0x01, 0x0a, 0x18, 0x49, 0x74,
+	0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x42, 0x79, 0x54,
+	0x69, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63,
+	0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x6a,
+	0x65, 0x63, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x74, 0x65, 0x6d, 0x5f, 0x6e, 0x61,
+	0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x74, 0x65, 0x6d, 0x4e, 0x61,
+	0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x73, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d,
+	0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x32, 0xb7,
+	0x04, 0x0a, 0x0c, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12,
+	0x35, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x55, 0x66, 0x42,
+	0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72,
+	0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x0d, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72,
+	0x6b, 0x69, 0x6e, 0x67, 0x55, 0x66, 0x12, 0x35, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72,
+	0x6b, 0x69, 0x6e, 0x67, 0x52, 0x6f, 0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e, 0x70,
+	0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x0d,
+	0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x6f, 0x12, 0x3b, 0x0a,
+	0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x65, 0x73, 0x74,
 	0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f,
 	0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f,
-	0x72, 0x6b, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x76, 0x65, 0x12, 0x5a, 0x0a, 0x17, 0x4d, 0x75,
+	0x72, 0x6b, 0x69, 0x6e, 0x67, 0x43, 0x68, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x14, 0x47, 0x65,
+	0x74, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x50, 0x75, 0x6d, 0x70, 0x42, 0x79, 0x43, 0x6f,
+	0x64, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e,
+	0x67, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e,
+	0x67, 0x50, 0x75, 0x6d, 0x70, 0x12, 0x3b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x57, 0x6f, 0x72, 0x6b,
+	0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10,
+	0x2e, 0x70, 0x62, 0x2e, 0x44, 0x63, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71,
+	0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c,
+	0x76, 0x65, 0x12, 0x5a, 0x0a, 0x17, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x41, 0x64, 0x64, 0x49, 0x74,
+	0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x2e,
+	0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48,
+	0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e,
+	0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48,
+	0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x12, 0x51,
+	0x0a, 0x13, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74,
+	0x61, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x48,
+	0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65,
+	0x71, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x41, 0x64, 0x64, 0x49,
+	0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65,
+	0x71, 0x12, 0x55, 0x0a, 0x15, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79,
+	0x44, 0x61, 0x74, 0x61, 0x42, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e,
+	0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x42,
+	0x79, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x75,
 	0x6c, 0x74, 0x69, 0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72,
-	0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69,
-	0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61,
-	0x74, 0x61, 0x52, 0x65, 0x71, 0x1a, 0x1f, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69,
-	0x41, 0x64, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61,
-	0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x79, 0x44, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
+	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1589,7 +1787,7 @@ func file_organization_proto_rawDescGZIP() []byte {
 	return file_organization_proto_rawDescData
 }
 
-var file_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
 var file_organization_proto_goTypes = []interface{}{
 	(*DcWorkingReq)(nil),                // 0: pb.DcWorkingReq
 	(*WorkingUf)(nil),                   // 1: pb.WorkingUf
@@ -1600,26 +1798,32 @@ var file_organization_proto_goTypes = []interface{}{
 	(*ItemHistoryData)(nil),             // 6: pb.ItemHistoryData
 	(*MultiAddItemHistoryDataReq)(nil),  // 7: pb.MultiAddItemHistoryDataReq
 	(*MultiAddItemHistoryDataResp)(nil), // 8: pb.MultiAddItemHistoryDataResp
+	(*ItemHistoryDataListReq)(nil),      // 9: pb.ItemHistoryDataListReq
+	(*ItemHistoryDataByTimeReq)(nil),    // 10: pb.ItemHistoryDataByTimeReq
 }
 var file_organization_proto_depIdxs = []int32{
-	6, // 0: pb.MultiAddItemHistoryDataReq.list:type_name -> pb.ItemHistoryData
-	0, // 1: pb.Organization.GetWorkingUfByCode:input_type -> pb.DcWorkingReq
-	0, // 2: pb.Organization.GetWorkingRoByCode:input_type -> pb.DcWorkingReq
-	0, // 3: pb.Organization.GetWorkingChestByCode:input_type -> pb.DcWorkingReq
-	0, // 4: pb.Organization.GetWorkingPumpByCode:input_type -> pb.DcWorkingReq
-	0, // 5: pb.Organization.GetWorkingValueByCode:input_type -> pb.DcWorkingReq
-	7, // 6: pb.Organization.MultiAddItemHistoryData:input_type -> pb.MultiAddItemHistoryDataReq
-	1, // 7: pb.Organization.GetWorkingUfByCode:output_type -> pb.WorkingUf
-	2, // 8: pb.Organization.GetWorkingRoByCode:output_type -> pb.WorkingRo
-	3, // 9: pb.Organization.GetWorkingChestByCode:output_type -> pb.WorkingChest
-	4, // 10: pb.Organization.GetWorkingPumpByCode:output_type -> pb.WorkingPump
-	5, // 11: pb.Organization.GetWorkingValueByCode:output_type -> pb.WorkingValve
-	8, // 12: pb.Organization.MultiAddItemHistoryData:output_type -> pb.MultiAddItemHistoryDataResp
-	7, // [7:13] is the sub-list for method output_type
-	1, // [1:7] is the sub-list for method input_type
-	1, // [1:1] is the sub-list for extension type_name
-	1, // [1:1] is the sub-list for extension extendee
-	0, // [0:1] is the sub-list for field type_name
+	6,  // 0: pb.MultiAddItemHistoryDataReq.list:type_name -> pb.ItemHistoryData
+	0,  // 1: pb.Organization.GetWorkingUfByCode:input_type -> pb.DcWorkingReq
+	0,  // 2: pb.Organization.GetWorkingRoByCode:input_type -> pb.DcWorkingReq
+	0,  // 3: pb.Organization.GetWorkingChestByCode:input_type -> pb.DcWorkingReq
+	0,  // 4: pb.Organization.GetWorkingPumpByCode:input_type -> pb.DcWorkingReq
+	0,  // 5: pb.Organization.GetWorkingValueByCode:input_type -> pb.DcWorkingReq
+	7,  // 6: pb.Organization.MultiAddItemHistoryData:input_type -> pb.MultiAddItemHistoryDataReq
+	9,  // 7: pb.Organization.ItemHistoryDataList:input_type -> pb.ItemHistoryDataListReq
+	10, // 8: pb.Organization.ItemHistoryDataByTime:input_type -> pb.ItemHistoryDataByTimeReq
+	1,  // 9: pb.Organization.GetWorkingUfByCode:output_type -> pb.WorkingUf
+	2,  // 10: pb.Organization.GetWorkingRoByCode:output_type -> pb.WorkingRo
+	3,  // 11: pb.Organization.GetWorkingChestByCode:output_type -> pb.WorkingChest
+	4,  // 12: pb.Organization.GetWorkingPumpByCode:output_type -> pb.WorkingPump
+	5,  // 13: pb.Organization.GetWorkingValueByCode:output_type -> pb.WorkingValve
+	8,  // 14: pb.Organization.MultiAddItemHistoryData:output_type -> pb.MultiAddItemHistoryDataResp
+	7,  // 15: pb.Organization.ItemHistoryDataList:output_type -> pb.MultiAddItemHistoryDataReq
+	7,  // 16: pb.Organization.ItemHistoryDataByTime:output_type -> pb.MultiAddItemHistoryDataReq
+	9,  // [9:17] is the sub-list for method output_type
+	1,  // [1:9] is the sub-list for method input_type
+	1,  // [1:1] is the sub-list for extension type_name
+	1,  // [1:1] is the sub-list for extension extendee
+	0,  // [0:1] is the sub-list for field type_name
 }
 
 func init() { file_organization_proto_init() }
@@ -1736,6 +1940,30 @@ func file_organization_proto_init() {
 				return nil
 			}
 		}
+		file_organization_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ItemHistoryDataListReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_organization_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ItemHistoryDataByTimeReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -1743,7 +1971,7 @@ func file_organization_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_organization_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   9,
+			NumMessages:   11,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 74 - 0
app/cmd/organization/pb/organization_grpc.pb.go

@@ -25,6 +25,8 @@ const (
 	Organization_GetWorkingPumpByCode_FullMethodName    = "/pb.Organization/GetWorkingPumpByCode"
 	Organization_GetWorkingValueByCode_FullMethodName   = "/pb.Organization/GetWorkingValueByCode"
 	Organization_MultiAddItemHistoryData_FullMethodName = "/pb.Organization/MultiAddItemHistoryData"
+	Organization_ItemHistoryDataList_FullMethodName     = "/pb.Organization/ItemHistoryDataList"
+	Organization_ItemHistoryDataByTime_FullMethodName   = "/pb.Organization/ItemHistoryDataByTime"
 )
 
 // OrganizationClient is the client API for Organization service.
@@ -37,6 +39,8 @@ type OrganizationClient interface {
 	GetWorkingPumpByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingPump, error)
 	GetWorkingValueByCode(ctx context.Context, in *DcWorkingReq, opts ...grpc.CallOption) (*WorkingValve, error)
 	MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
+	ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error)
+	ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error)
 }
 
 type organizationClient struct {
@@ -101,6 +105,24 @@ func (c *organizationClient) MultiAddItemHistoryData(ctx context.Context, in *Mu
 	return out, nil
 }
 
+func (c *organizationClient) ItemHistoryDataList(ctx context.Context, in *ItemHistoryDataListReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error) {
+	out := new(MultiAddItemHistoryDataReq)
+	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataList_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *organizationClient) ItemHistoryDataByTime(ctx context.Context, in *ItemHistoryDataByTimeReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataReq, error) {
+	out := new(MultiAddItemHistoryDataReq)
+	err := c.cc.Invoke(ctx, Organization_ItemHistoryDataByTime_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // OrganizationServer is the server API for Organization service.
 // All implementations must embed UnimplementedOrganizationServer
 // for forward compatibility
@@ -111,6 +133,8 @@ type OrganizationServer interface {
 	GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*WorkingPump, error)
 	GetWorkingValueByCode(context.Context, *DcWorkingReq) (*WorkingValve, error)
 	MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error)
+	ItemHistoryDataList(context.Context, *ItemHistoryDataListReq) (*MultiAddItemHistoryDataReq, error)
+	ItemHistoryDataByTime(context.Context, *ItemHistoryDataByTimeReq) (*MultiAddItemHistoryDataReq, error)
 	mustEmbedUnimplementedOrganizationServer()
 }
 
@@ -136,6 +160,12 @@ func (UnimplementedOrganizationServer) GetWorkingValueByCode(context.Context, *D
 func (UnimplementedOrganizationServer) MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method MultiAddItemHistoryData not implemented")
 }
+func (UnimplementedOrganizationServer) ItemHistoryDataList(context.Context, *ItemHistoryDataListReq) (*MultiAddItemHistoryDataReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ItemHistoryDataList not implemented")
+}
+func (UnimplementedOrganizationServer) ItemHistoryDataByTime(context.Context, *ItemHistoryDataByTimeReq) (*MultiAddItemHistoryDataReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ItemHistoryDataByTime not implemented")
+}
 func (UnimplementedOrganizationServer) mustEmbedUnimplementedOrganizationServer() {}
 
 // UnsafeOrganizationServer may be embedded to opt out of forward compatibility for this service.
@@ -257,6 +287,42 @@ func _Organization_MultiAddItemHistoryData_Handler(srv interface{}, ctx context.
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Organization_ItemHistoryDataList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ItemHistoryDataListReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).ItemHistoryDataList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: Organization_ItemHistoryDataList_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).ItemHistoryDataList(ctx, req.(*ItemHistoryDataListReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Organization_ItemHistoryDataByTime_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ItemHistoryDataByTimeReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).ItemHistoryDataByTime(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: Organization_ItemHistoryDataByTime_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).ItemHistoryDataByTime(ctx, req.(*ItemHistoryDataByTimeReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Organization_ServiceDesc is the grpc.ServiceDesc for Organization service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -288,6 +354,14 @@ var Organization_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "MultiAddItemHistoryData",
 			Handler:    _Organization_MultiAddItemHistoryData_Handler,
 		},
+		{
+			MethodName: "ItemHistoryDataList",
+			Handler:    _Organization_ItemHistoryDataList_Handler,
+		},
+		{
+			MethodName: "ItemHistoryDataByTime",
+			Handler:    _Organization_ItemHistoryDataByTime_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "organization.proto",

+ 1 - 0
app/model/GtDataStore.sql

@@ -391,6 +391,7 @@ CREATE TABLE `dc_item_history_data` (
         `project_id` int(10) NOT NULL COMMENT '项目ID',
         `item_name` varchar(100) NOT NULL DEFAULT '' COMMENT '点位名',
         `val` decimal(10,4) NOT NULL DEFAULT '0' COMMENT '值',
+        `h_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '采集数据时间',
         `c_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
         PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
         KEY `index_project_item` (`project_id`,`item_name`,`c_time`)

+ 170 - 0
app/model/dcitemhistorydatamodel.go

@@ -1,9 +1,12 @@
 package model
 
 import (
+	"GtDataStore/app/cmd/organization/pb"
 	"context"
 	"fmt"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
 	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"strings"
 )
 
 var _ DcItemHistoryDataModel = (*customDcItemHistoryDataModel)(nil)
@@ -14,6 +17,7 @@ type (
 	DcItemHistoryDataModel interface {
 		dcItemHistoryDataModel
 		MultiInsert(ctx context.Context, datas []DcItemHistoryData) (int64, error)
+		QueryHistoryDataByTime(ctx context.Context, in *pb.ItemHistoryDataByTimeReq) ([]DcItemHistoryData, error)
 	}
 
 	customDcItemHistoryDataModel struct {
@@ -44,3 +48,169 @@ func (m *defaultDcItemHistoryDataModel) MultiInsert(ctx context.Context, datas [
 		return 0, err
 	}
 }
+
+func (m *defaultDcItemHistoryDataModel) QueryHistoryDataByTime(ctx context.Context, in *pb.ItemHistoryDataByTimeReq) ([]DcItemHistoryData, error) {
+	resp := make([]DcItemHistoryData, 0)
+	var err error
+	query := fmt.Sprintf("SELECT * FROM %s WHERE project_id = ? AND item_name in (?) AND c_time BETWEEN ? AND ? ORDER BY id desc", m.table)
+	if strings.Index(in.ItemName, ",") > 0 {
+		err = m.conn.QueryRowsCtx(ctx, &resp, query, in.ProjectId, strings.Split(in.ItemName, ","), in.Stime, in.Etime)
+	} else {
+		err = m.conn.QueryRowsCtx(ctx, &resp, query, in.ProjectId, in.ItemName, in.Stime, in.Etime)
+	}
+
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
+/*
+func (m *defaultDcItemHistoryDataModel) QueryHistoryData(ctx context.Context, in *pb.ItemHistoryDataListReq) ([]DcItemHistoryData, error) {
+	resp := make([]DcItemHistoryData, 0)
+	var err error
+	var query string
+	if in.Aggregator == "realtime" {
+		query = fmt.Sprintf("SELECT project_id,item_name,val,DATE_FORMAT(c_time, '%%Y-%%m-%%d %%H:00:00') as c_time FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY DATE_FORMAT(c_time, '%%Y-%%m-%%d %%H:00:00') ORDER BY TIME_TO_SEC(c_time) ASC) AS row_num FROM %s WHERE project_id = ? AND item_name = ? AND c_time >= ? AND c_time < ? AND val <> 0) subquery WHERE row_num = 1;", m.table)
+	} else if in.Aggregator == "new" {
+		groupSql := ""
+		timeSql := ""
+		if in.Interval == "minute" {
+			query = fmt.Sprintf(`
+					SELECT val, DATE_ADD(DATE_FORMAT(min_c_time, '%%Y-%%m-%%d %%H:%%i'), INTERVAL (FLOOR(TIME_TO_SEC(min_c_time)/600)*%d) MINUTE) as c_time
+					FROM (
+						SELECT MAX(val) AS val,
+							MIN(c_time) AS min_c_time
+						FROM %s
+						WHERE project_id = ? AND item_name = ?
+							AND c_time >= ? AND c_time < ?
+						GROUP BY DATE_FORMAT(c_time, '%%Y-%%m-%%d %%H:%%i'), FLOOR(TIME_TO_SEC(c_time) / 600)
+					) AS subquery
+					ORDER BY min_c_time ASC;`, in.Size, m.table)
+		} else if in.Interval == "h" {
+			timeSql = fmt.Sprintf("DATE_ADD(concat(DATE_FORMAT(ts,'%%Y-%%m-%%d '),LPAD(FLOOR(DATE_FORMAT(ts, '%%H')/%d)*%d,2,0),':00:00'), INTERVAL %d hour)", in.Size, in.Size, in.Size)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m-%%d' ),FLOOR(DATE_FORMAT(ts, '%%H' )/%d)", in.Size)
+
+		} else {
+			// day
+			timeSql = fmt.Sprintf("DATE_ADD(concat(DATE_FORMAT(ts,'%%Y-%%m-'),LPAD(FLOOR(DATE_FORMAT(ts, '%%d')/%d)*%d,2,0),' 00:00:00'), INTERVAL %d day)", in.Size, in.Size, in.Size)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m' ),FLOOR(DATE_FORMAT(ts, '%%d' )/%d)", in.Size)
+		}
+		tableName := "ws_scada." + TableName(itemId)
+		table := fmt.Sprintf(`(select *
+								from %s
+								where item_name = "%s" and project_id = %s
+									and ts >= "%s" and ts < "%s"
+								order by ts desc
+								limit 99999999) A `, tableName, itemId, projectId, sTime, eTime)
+		rows, err = DB.New().Table(table).
+			Select(fmt.Sprintf("cast(item_value as DECIMAL(11,4)) as val, %s as htime", timeSql)).
+			Group(groupSql).
+			Order("htime asc").
+			Rows()
+	}
+	err = m.conn.QueryRowCtx(ctx, &resp, query, in.ProjectId, in.ItemName, in.Stime, in.Etime)
+	switch err {
+	case nil:
+		return resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+
+	var rows *sql.Rows
+
+	if aggregator == "realtime" {
+		rows, err = DB.New().Table("ws_scada."+TableName(itemId)).
+			Select("item_value as val,CASE   WHEN MINUTE(ts) >= 30  THEN DATE_FORMAT(DATE_ADD(ts, INTERVAL 1 HOUR), '%Y-%m-%d %H:00:00') ELSE DATE_FORMAT(ts, '%Y-%m-%d %H:00:00') END AS htime").
+			Where("item_name = ? ", itemId).
+			Where("ts >= ? and ts < ?", sTime, eTime).
+			Where("project_id = ?", projectId).
+			Group("htime").
+			Rows()
+	} else if aggregator == "new" {
+		groupSql := ""
+		timeSql := ""
+		if interval == "minute" {
+			timeSql = fmt.Sprintf("DATE_ADD(concat(DATE_FORMAT(ts,'%%Y-%%m-%%d %%H:'),LPAD(FLOOR(DATE_FORMAT(ts, '%%i')/%d)*%d,2,0),':00'), INTERVAL %d minute)", sizeInt, sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m-%%d %%H' ),FLOOR(DATE_FORMAT(ts, '%%i' )/%d)", sizeInt)
+		} else if interval == "h" {
+			timeSql = fmt.Sprintf("DATE_ADD(concat(DATE_FORMAT(ts,'%%Y-%%m-%%d '),LPAD(FLOOR(DATE_FORMAT(ts, '%%H')/%d)*%d,2,0),':00:00'), INTERVAL %d hour)", sizeInt, sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m-%%d' ),FLOOR(DATE_FORMAT(ts, '%%H' )/%d)", sizeInt)
+		} else {
+			// day
+			timeSql = fmt.Sprintf("DATE_ADD(concat(DATE_FORMAT(ts,'%%Y-%%m-'),LPAD(FLOOR(DATE_FORMAT(ts, '%%d')/%d)*%d,2,0),' 00:00:00'), INTERVAL %d day)", sizeInt, sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m' ),FLOOR(DATE_FORMAT(ts, '%%d' )/%d)", sizeInt)
+		}
+		tableName := "ws_scada." + TableName(itemId)
+		table := fmt.Sprintf(`(select *
+								from %s
+								where item_name = "%s" and project_id = %s
+									and ts >= "%s" and ts < "%s"
+								order by ts desc
+								limit 99999999) A `, tableName, itemId, projectId, sTime, eTime)
+		rows, err = DB.New().Table(table).
+			Select(fmt.Sprintf("cast(item_value as DECIMAL(11,4)) as val, %s as htime", timeSql)).
+			Group(groupSql).
+			Order("htime asc").
+			Rows()
+	} else {
+		groupSql := ""
+		timeSql := ""
+		if interval == "minute" {
+			timeSql = fmt.Sprintf("concat(DATE_FORMAT(ts,'%%Y-%%m-%%d %%H:'),LPAD(FLOOR(DATE_FORMAT(ts, '%%i')/%d)*%d,2,0),':00')", sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m-%%d %%H' ),FLOOR(DATE_FORMAT(ts, '%%i' )/%d)", sizeInt)
+		} else if interval == "h" {
+			timeSql = fmt.Sprintf("concat(DATE_FORMAT(ts, '%%Y-%%m-%%d ' ),LPAD(FLOOR(DATE_FORMAT(ts, '%%H' )/%d)*%d,2,0),':00:00')", sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m-%%d' ),FLOOR(DATE_FORMAT(ts, '%%H' )/%d)", sizeInt)
+		} else {
+			//day
+			timeSql = fmt.Sprintf("concat(DATE_FORMAT(ts, '%%Y-%%m-' ),LPAD(FLOOR(DATE_FORMAT(ts, '%%d' )/%d)*%d,2,0),' 00:00:00')", sizeInt, sizeInt)
+			groupSql = fmt.Sprintf("DATE_FORMAT(ts, '%%Y-%%m' ),FLOOR(DATE_FORMAT(ts, '%%d' )/%d)", sizeInt)
+		}
+
+		rows, err = DB.New().Table("ws_scada."+TableName(itemId)).
+			Select(fmt.Sprintf("%s(cast(item_value as DECIMAL(11,4))) as val, %s as htime", aggregator, timeSql)).
+			Where("item_name = ? ", itemId).
+			Where("ts >= ? and ts < ?", sTime, eTime).
+			Where("project_id = ?", projectId).
+			Group(groupSql).
+			Rows()
+	}
+	defer rows.Close()
+	if err != nil {
+		log.Error(err)
+		return nil, err
+	}
+
+	// 查询点位信息 导出表格需要
+	configMap, err := GetDrdcByItemNameAndDeviceId(itemId, fmt.Sprintf("%d", deviceId))
+	if err != nil {
+		log.Error(err)
+		return nil, err
+	}
+
+	for rows.Next() {
+		di := postgres.JinkeHistoryData{}
+		var val sql.NullString
+		err := rows.Scan(&val, &di.Htime)
+		di.Val = NullStringConverse(val)
+		if err != nil { // 获得的都是字符串
+			log.Error("Some amazing wrong happens in the process of queryAll.", err)
+			return nil, err
+		}
+		di.Name = configMap.ItemAlias
+		//判断小数点
+		if configMap.IsBool == false {
+			di.Val = processPrecise(di.Val, configMap.ItemPrecise)
+		}
+		resp = append(resp, di)
+	}
+	return resp, nil
+}
+*/

+ 4 - 3
app/model/dcitemhistorydatamodel_gen.go

@@ -40,6 +40,7 @@ type (
 		ProjectId int64     `db:"project_id"` // 项目ID
 		ItemName  string    `db:"item_name"`  // 点位名
 		Val       float64   `db:"val"`        // 值
+		HTime     time.Time `db:"h_time"`     // 采集数据时间
 		CTime     time.Time `db:"c_time"`     // 创建时间
 	}
 )
@@ -72,14 +73,14 @@ func (m *defaultDcItemHistoryDataModel) FindOne(ctx context.Context, id int64) (
 }
 
 func (m *defaultDcItemHistoryDataModel) Insert(ctx context.Context, data *DcItemHistoryData) (sql.Result, error) {
-	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, dcItemHistoryDataRowsExpectAutoSet)
-	ret, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.ItemName, data.Val, data.CTime)
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, dcItemHistoryDataRowsExpectAutoSet)
+	ret, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.ItemName, data.Val, data.HTime, data.CTime)
 	return ret, err
 }
 
 func (m *defaultDcItemHistoryDataModel) Update(ctx context.Context, data *DcItemHistoryData) error {
 	query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, dcItemHistoryDataRowsWithPlaceHolder)
-	_, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.ItemName, data.Val, data.CTime, data.Id)
+	_, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.ItemName, data.Val, data.HTime, data.CTime, data.Id)
 	return err
 }