瀏覽代碼

批量入库单点位数据

songxiaohang 1 年之前
父節點
當前提交
fcbb694705

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

@@ -28,4 +28,8 @@ service datacenter {
 	@doc "查询working valve信息"
 	@handler WorkingValve
 	get /working-valve/info (DcWorkingReq) returns (WorkingValveResp)
+	
+	@doc "秒级单点数据批量入库"
+	@handler ItemHistoryData
+	post /item-history/multi-add (MultiAddItemHistoryDataReq) returns (MultiAddItemHistoryDataResq)
 }

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

@@ -144,3 +144,19 @@ type (
         Info    *DcWorkingPump    `json:"info"`
     }
 )
+
+type (
+    ItemHistoryData {
+        ProjectId   int64     `json:"project_id"`
+        ItemName    string    `json:"item_name"`
+        Val         float64   `json:"val"`
+        CTime       string    `json:"h_time"`
+    }
+
+    MultiAddItemHistoryDataReq{
+        List    []*ItemHistoryData  `json:"list"`
+    }
+
+    MultiAddItemHistoryDataResq{}
+)
+

+ 26 - 0
app/cmd/api/internal/handler/datacenter/itemHistoryDataHandler.go

@@ -0,0 +1,26 @@
+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 ItemHistoryDataHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.MultiAddItemHistoryDataReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := datacenter.NewItemHistoryDataLogic(r.Context(), svcCtx)
+		resp, err := l.ItemHistoryData(&req)
+		result.HttpResult(r, w, resp, err)
+
+	}
+}

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

@@ -38,6 +38,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/working-valve/info",
 				Handler: datacenter.WorkingValveHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/item-history/multi-add",
+				Handler: datacenter.ItemHistoryDataHandler(serverCtx),
+			},
 		},
 		rest.WithPrefix("/api/datacenter/v1"),
 	)

+ 43 - 0
app/cmd/api/internal/logic/datacenter/itemHistoryDataLogic.go

@@ -0,0 +1,43 @@
+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 ItemHistoryDataLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewItemHistoryDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ItemHistoryDataLogic {
+	return &ItemHistoryDataLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *ItemHistoryDataLogic) ItemHistoryData(req *types.MultiAddItemHistoryDataReq) (resp *types.MultiAddItemHistoryDataResq, err error) {
+	dataList := make([]*pb.ItemHistoryData, 0)
+	for _, line := range req.List {
+		tmp := &pb.ItemHistoryData{}
+		_ = copier.Copy(tmp, line)
+		dataList = append(dataList, tmp)
+	}
+	_, err = l.svcCtx.OrganizationRpc.MultiAddItemHistoryData(l.ctx, &pb.MultiAddItemHistoryDataReq{
+		List: dataList,
+	})
+	if err != nil {
+		return nil, err
+	}
+
+	return &types.MultiAddItemHistoryDataResq{}, nil
+}

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

@@ -148,3 +148,17 @@ type WorkingValveResp struct {
 type WorkingPumpResp struct {
 	Info *DcWorkingPump `json:"info"`
 }
+
+type ItemHistoryData struct {
+	ProjectId int64   `json:"project_id"`
+	ItemName  string  `json:"item_name"`
+	Val       float64 `json:"val"`
+	CTime     string  `json:"h_time"`
+}
+
+type MultiAddItemHistoryDataReq struct {
+	List []*ItemHistoryData `json:"list"`
+}
+
+type MultiAddItemHistoryDataResq struct {
+}

+ 49 - 0
app/cmd/organization/internal/logic/multiAddItemHistoryDataLogic.go

@@ -0,0 +1,49 @@
+package logic
+
+import (
+	"GtDataStore/app/cmd/organization/internal/svc"
+	"GtDataStore/app/cmd/organization/pb"
+	"GtDataStore/app/model"
+	"GtDataStore/common/xerr"
+	"context"
+	"github.com/pkg/errors"
+	"time"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type MultiAddItemHistoryDataLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewMultiAddItemHistoryDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MultiAddItemHistoryDataLogic {
+	return &MultiAddItemHistoryDataLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *MultiAddItemHistoryDataLogic) MultiAddItemHistoryData(in *pb.MultiAddItemHistoryDataReq) (*pb.MultiAddItemHistoryDataResp, error) {
+	ts := make([]model.DcItemHistoryData, len(in.List))
+
+	for i, data := range in.List {
+		layout := "2006-01-02 15:04:05"
+
+		t, _ := time.Parse(layout, data.CTime)
+		ts[i] = model.DcItemHistoryData{
+			ProjectId: data.ProjectId,
+			ItemName:  data.ItemName,
+			Val:       data.Val,
+			CTime:     t,
+		}
+	}
+	_, err := l.svcCtx.ItemHistoryData.MultiInsert(l.ctx, ts)
+	if err != nil {
+		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "item history data table multi Insert err:%v", err)
+	}
+
+	return &pb.MultiAddItemHistoryDataResp{}, nil
+}

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

@@ -46,3 +46,8 @@ func (s *OrganizationServer) GetWorkingValueByCode(ctx context.Context, in *pb.D
 	l := logic.NewGetWorkingValueByCodeLogic(ctx, s.svcCtx)
 	return l.GetWorkingValueByCode(in)
 }
+
+func (s *OrganizationServer) MultiAddItemHistoryData(ctx context.Context, in *pb.MultiAddItemHistoryDataReq) (*pb.MultiAddItemHistoryDataResp, error) {
+	l := logic.NewMultiAddItemHistoryDataLogic(ctx, s.svcCtx)
+	return l.MultiAddItemHistoryData(in)
+}

+ 11 - 9
app/cmd/organization/internal/svc/vars.go

@@ -6,15 +6,16 @@ import (
 )
 
 type modelList struct {
-	DeviceBind    model.DcDeviceBindModel
-	ProjectConfig model.DcProjectConfigModel
-	WorkingUf     model.DcWorkingUfModel
-	WorkingMf     model.DcWorkingMfModel
-	WorkingNf     model.DcWorkingNfModel
-	WorkingRo     model.DcWorkingRoModel
-	WorkingPump   model.DcWorkingPumpModel
-	WorkingValve  model.DcWorkingValveModel
-	WorkingChest  model.DcWorkingChestModel
+	DeviceBind      model.DcDeviceBindModel
+	ProjectConfig   model.DcProjectConfigModel
+	WorkingUf       model.DcWorkingUfModel
+	WorkingMf       model.DcWorkingMfModel
+	WorkingNf       model.DcWorkingNfModel
+	WorkingRo       model.DcWorkingRoModel
+	WorkingPump     model.DcWorkingPumpModel
+	WorkingValve    model.DcWorkingValveModel
+	WorkingChest    model.DcWorkingChestModel
+	ItemHistoryData model.DcItemHistoryDataModel
 }
 
 func initModel(svc *ServiceContext) {
@@ -28,4 +29,5 @@ func initModel(svc *ServiceContext) {
 	svc.WorkingPump = model.NewDcWorkingPumpModel(mysql)
 	svc.WorkingChest = model.NewDcWorkingChestModel(mysql)
 	svc.WorkingValve = model.NewDcWorkingValveModel(mysql)
+	svc.ItemHistoryData = model.NewDcItemHistoryDataModel(mysql)
 }

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

@@ -131,10 +131,25 @@ message WorkingValve {
   string    c_time = 9;
 }
 
+message ItemHistoryData {
+  int64     id = 1;
+  int64     project_id = 2;
+  string    item_name = 3;
+  double    val = 4;
+  string    c_time = 5;
+}
+
+message MultiAddItemHistoryDataReq {
+  repeated ItemHistoryData list = 1;
+}
+
+message MultiAddItemHistoryDataResp {}
+
 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 MultiAddItemHistoryData(MultiAddItemHistoryDataReq) returns(MultiAddItemHistoryDataResp);
 }

+ 15 - 6
app/cmd/organization/organization/organization.go

@@ -13,12 +13,15 @@ import (
 )
 
 type (
-	DcWorkingReq = pb.DcWorkingReq
-	WorkingChest = pb.WorkingChest
-	WorkingPump  = pb.WorkingPump
-	WorkingRo    = pb.WorkingRo
-	WorkingUf    = pb.WorkingUf
-	WorkingValve = pb.WorkingValve
+	DcWorkingReq                = pb.DcWorkingReq
+	ItemHistoryData             = pb.ItemHistoryData
+	MultiAddItemHistoryDataReq  = pb.MultiAddItemHistoryDataReq
+	MultiAddItemHistoryDataResp = pb.MultiAddItemHistoryDataResp
+	WorkingChest                = pb.WorkingChest
+	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)
@@ -26,6 +29,7 @@ type (
 		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)
+		MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
 	}
 
 	defaultOrganization struct {
@@ -63,3 +67,8 @@ func (m *defaultOrganization) GetWorkingValueByCode(ctx context.Context, in *DcW
 	client := pb.NewOrganizationClient(m.cli.Conn())
 	return client.GetWorkingValueByCode(ctx, in, opts...)
 }
+
+func (m *defaultOrganization) MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error) {
+	client := pb.NewOrganizationClient(m.cli.Conn())
+	return client.MultiAddItemHistoryData(ctx, in, opts...)
+}

+ 270 - 43
app/cmd/organization/pb/organization.pb.go

@@ -1134,6 +1134,170 @@ func (x *WorkingValve) GetCTime() string {
 	return ""
 }
 
+type ItemHistoryData struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Id        int64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
+	ProjectId int64   `protobuf:"varint,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"`
+	ItemName  string  `protobuf:"bytes,3,opt,name=item_name,json=itemName,proto3" json:"item_name,omitempty"`
+	Val       float64 `protobuf:"fixed64,4,opt,name=val,proto3" json:"val,omitempty"`
+	CTime     string  `protobuf:"bytes,5,opt,name=c_time,json=cTime,proto3" json:"c_time,omitempty"`
+}
+
+func (x *ItemHistoryData) Reset() {
+	*x = ItemHistoryData{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_organization_proto_msgTypes[6]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ItemHistoryData) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ItemHistoryData) ProtoMessage() {}
+
+func (x *ItemHistoryData) ProtoReflect() protoreflect.Message {
+	mi := &file_organization_proto_msgTypes[6]
+	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 ItemHistoryData.ProtoReflect.Descriptor instead.
+func (*ItemHistoryData) Descriptor() ([]byte, []int) {
+	return file_organization_proto_rawDescGZIP(), []int{6}
+}
+
+func (x *ItemHistoryData) GetId() int64 {
+	if x != nil {
+		return x.Id
+	}
+	return 0
+}
+
+func (x *ItemHistoryData) GetProjectId() int64 {
+	if x != nil {
+		return x.ProjectId
+	}
+	return 0
+}
+
+func (x *ItemHistoryData) GetItemName() string {
+	if x != nil {
+		return x.ItemName
+	}
+	return ""
+}
+
+func (x *ItemHistoryData) GetVal() float64 {
+	if x != nil {
+		return x.Val
+	}
+	return 0
+}
+
+func (x *ItemHistoryData) GetCTime() string {
+	if x != nil {
+		return x.CTime
+	}
+	return ""
+}
+
+type MultiAddItemHistoryDataReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	List []*ItemHistoryData `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
+}
+
+func (x *MultiAddItemHistoryDataReq) Reset() {
+	*x = MultiAddItemHistoryDataReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_organization_proto_msgTypes[7]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *MultiAddItemHistoryDataReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MultiAddItemHistoryDataReq) ProtoMessage() {}
+
+func (x *MultiAddItemHistoryDataReq) ProtoReflect() protoreflect.Message {
+	mi := &file_organization_proto_msgTypes[7]
+	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 MultiAddItemHistoryDataReq.ProtoReflect.Descriptor instead.
+func (*MultiAddItemHistoryDataReq) Descriptor() ([]byte, []int) {
+	return file_organization_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *MultiAddItemHistoryDataReq) GetList() []*ItemHistoryData {
+	if x != nil {
+		return x.List
+	}
+	return nil
+}
+
+type MultiAddItemHistoryDataResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+}
+
+func (x *MultiAddItemHistoryDataResp) Reset() {
+	*x = MultiAddItemHistoryDataResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_organization_proto_msgTypes[8]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *MultiAddItemHistoryDataResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*MultiAddItemHistoryDataResp) ProtoMessage() {}
+
+func (x *MultiAddItemHistoryDataResp) ProtoReflect() protoreflect.Message {
+	mi := &file_organization_proto_msgTypes[8]
+	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 MultiAddItemHistoryDataResp.ProtoReflect.Descriptor instead.
+func (*MultiAddItemHistoryDataResp) Descriptor() ([]byte, []int) {
+	return file_organization_proto_rawDescGZIP(), []int{8}
+}
+
 var File_organization_proto protoreflect.FileDescriptor
 
 var file_organization_proto_rawDesc = []byte{
@@ -1369,27 +1533,48 @@ var file_organization_proto_rawDesc = []byte{
 	0x0c, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20,
 	0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73,
 	0x12, 0x15, 0x0a, 0x06, 0x63, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x32, 0xb1, 0x02, 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,
+	0x52, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x86, 0x01, 0x0a, 0x0f, 0x49, 0x74, 0x65, 0x6d,
+	0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x70,
+	0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 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, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69,
+	0x74, 0x65, 0x6d, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x76, 0x61, 0x6c, 0x18, 0x04,
+	0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x76, 0x61, 0x6c, 0x12, 0x15, 0x0a, 0x06, 0x63, 0x5f, 0x74,
+	0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65,
+	0x22, 0x45, 0x0a, 0x1a, 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, 0x27,
+	0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70,
+	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, 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, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e,
-	0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	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,
+	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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -1404,31 +1589,37 @@ func file_organization_proto_rawDescGZIP() []byte {
 	return file_organization_proto_rawDescData
 }
 
-var file_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
+var file_organization_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
 var file_organization_proto_goTypes = []interface{}{
-	(*DcWorkingReq)(nil), // 0: pb.DcWorkingReq
-	(*WorkingUf)(nil),    // 1: pb.WorkingUf
-	(*WorkingRo)(nil),    // 2: pb.WorkingRo
-	(*WorkingChest)(nil), // 3: pb.WorkingChest
-	(*WorkingPump)(nil),  // 4: pb.WorkingPump
-	(*WorkingValve)(nil), // 5: pb.WorkingValve
+	(*DcWorkingReq)(nil),                // 0: pb.DcWorkingReq
+	(*WorkingUf)(nil),                   // 1: pb.WorkingUf
+	(*WorkingRo)(nil),                   // 2: pb.WorkingRo
+	(*WorkingChest)(nil),                // 3: pb.WorkingChest
+	(*WorkingPump)(nil),                 // 4: pb.WorkingPump
+	(*WorkingValve)(nil),                // 5: pb.WorkingValve
+	(*ItemHistoryData)(nil),             // 6: pb.ItemHistoryData
+	(*MultiAddItemHistoryDataReq)(nil),  // 7: pb.MultiAddItemHistoryDataReq
+	(*MultiAddItemHistoryDataResp)(nil), // 8: pb.MultiAddItemHistoryDataResp
 }
 var file_organization_proto_depIdxs = []int32{
-	0, // 0: pb.Organization.GetWorkingUfByCode:input_type -> pb.DcWorkingReq
-	0, // 1: pb.Organization.GetWorkingRoByCode:input_type -> pb.DcWorkingReq
-	0, // 2: pb.Organization.GetWorkingChestByCode:input_type -> pb.DcWorkingReq
-	0, // 3: pb.Organization.GetWorkingPumpByCode:input_type -> pb.DcWorkingReq
-	0, // 4: pb.Organization.GetWorkingValueByCode:input_type -> pb.DcWorkingReq
-	1, // 5: pb.Organization.GetWorkingUfByCode:output_type -> pb.WorkingUf
-	2, // 6: pb.Organization.GetWorkingRoByCode:output_type -> pb.WorkingRo
-	3, // 7: pb.Organization.GetWorkingChestByCode:output_type -> pb.WorkingChest
-	4, // 8: pb.Organization.GetWorkingPumpByCode:output_type -> pb.WorkingPump
-	5, // 9: pb.Organization.GetWorkingValueByCode:output_type -> pb.WorkingValve
-	5, // [5:10] is the sub-list for method output_type
-	0, // [0:5] is the sub-list for method input_type
-	0, // [0:0] is the sub-list for extension type_name
-	0, // [0:0] is the sub-list for extension extendee
-	0, // [0:0] 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
+	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
 }
 
 func init() { file_organization_proto_init() }
@@ -1509,6 +1700,42 @@ func file_organization_proto_init() {
 				return nil
 			}
 		}
+		file_organization_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ItemHistoryData); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_organization_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*MultiAddItemHistoryDataReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_organization_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*MultiAddItemHistoryDataResp); 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{
@@ -1516,7 +1743,7 @@ func file_organization_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_organization_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   6,
+			NumMessages:   9,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 42 - 5
app/cmd/organization/pb/organization_grpc.pb.go

@@ -19,11 +19,12 @@ import (
 const _ = grpc.SupportPackageIsVersion7
 
 const (
-	Organization_GetWorkingUfByCode_FullMethodName    = "/pb.Organization/GetWorkingUfByCode"
-	Organization_GetWorkingRoByCode_FullMethodName    = "/pb.Organization/GetWorkingRoByCode"
-	Organization_GetWorkingChestByCode_FullMethodName = "/pb.Organization/GetWorkingChestByCode"
-	Organization_GetWorkingPumpByCode_FullMethodName  = "/pb.Organization/GetWorkingPumpByCode"
-	Organization_GetWorkingValueByCode_FullMethodName = "/pb.Organization/GetWorkingValueByCode"
+	Organization_GetWorkingUfByCode_FullMethodName      = "/pb.Organization/GetWorkingUfByCode"
+	Organization_GetWorkingRoByCode_FullMethodName      = "/pb.Organization/GetWorkingRoByCode"
+	Organization_GetWorkingChestByCode_FullMethodName   = "/pb.Organization/GetWorkingChestByCode"
+	Organization_GetWorkingPumpByCode_FullMethodName    = "/pb.Organization/GetWorkingPumpByCode"
+	Organization_GetWorkingValueByCode_FullMethodName   = "/pb.Organization/GetWorkingValueByCode"
+	Organization_MultiAddItemHistoryData_FullMethodName = "/pb.Organization/MultiAddItemHistoryData"
 )
 
 // OrganizationClient is the client API for Organization service.
@@ -35,6 +36,7 @@ type OrganizationClient interface {
 	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)
+	MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error)
 }
 
 type organizationClient struct {
@@ -90,6 +92,15 @@ func (c *organizationClient) GetWorkingValueByCode(ctx context.Context, in *DcWo
 	return out, nil
 }
 
+func (c *organizationClient) MultiAddItemHistoryData(ctx context.Context, in *MultiAddItemHistoryDataReq, opts ...grpc.CallOption) (*MultiAddItemHistoryDataResp, error) {
+	out := new(MultiAddItemHistoryDataResp)
+	err := c.cc.Invoke(ctx, Organization_MultiAddItemHistoryData_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
@@ -99,6 +110,7 @@ type OrganizationServer interface {
 	GetWorkingChestByCode(context.Context, *DcWorkingReq) (*WorkingChest, error)
 	GetWorkingPumpByCode(context.Context, *DcWorkingReq) (*WorkingPump, error)
 	GetWorkingValueByCode(context.Context, *DcWorkingReq) (*WorkingValve, error)
+	MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error)
 	mustEmbedUnimplementedOrganizationServer()
 }
 
@@ -121,6 +133,9 @@ func (UnimplementedOrganizationServer) GetWorkingPumpByCode(context.Context, *Dc
 func (UnimplementedOrganizationServer) GetWorkingValueByCode(context.Context, *DcWorkingReq) (*WorkingValve, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetWorkingValueByCode not implemented")
 }
+func (UnimplementedOrganizationServer) MultiAddItemHistoryData(context.Context, *MultiAddItemHistoryDataReq) (*MultiAddItemHistoryDataResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method MultiAddItemHistoryData not implemented")
+}
 func (UnimplementedOrganizationServer) mustEmbedUnimplementedOrganizationServer() {}
 
 // UnsafeOrganizationServer may be embedded to opt out of forward compatibility for this service.
@@ -224,6 +239,24 @@ func _Organization_GetWorkingValueByCode_Handler(srv interface{}, ctx context.Co
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Organization_MultiAddItemHistoryData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(MultiAddItemHistoryDataReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(OrganizationServer).MultiAddItemHistoryData(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: Organization_MultiAddItemHistoryData_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(OrganizationServer).MultiAddItemHistoryData(ctx, req.(*MultiAddItemHistoryDataReq))
+	}
+	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)
@@ -251,6 +284,10 @@ var Organization_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GetWorkingValueByCode",
 			Handler:    _Organization_GetWorkingValueByCode_Handler,
 		},
+		{
+			MethodName: "MultiAddItemHistoryData",
+			Handler:    _Organization_MultiAddItemHistoryData_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "organization.proto",

+ 36 - 1
app/model/GtDataStore.sql

@@ -384,4 +384,39 @@ CREATE TABLE `dc_project_config` (
                                      `m_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
                                      PRIMARY KEY (`id`),
                                      UNIQUE KEY `project_id` (`project_id`)
-) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+CREATE TABLE `dc_item_history_data` (
+        `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+        `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 '值',
+        `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`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='单点位秒级历史数据' /*T![ttl] TTL=`c_time` + INTERVAL 6 MONTH */ /*T![ttl] TTL_ENABLE='ON' */ /*T![ttl] TTL_JOB_INTERVAL='1h' */;
+
+CREATE TABLE `dc_item_config` (
+      `id` int(10) NOT NULL AUTO_INCREMENT,
+      `project_id` int(10) NOT NULL,
+      `device_code` varchar(55) NOT NULL COMMENT '位号',
+      `item_name` varchar(100) NOT NULL COMMENT '点位名',
+      `item_alias` varchar(55) NOT NULL COMMENT '别名',
+      `min_val` decimal(10,4) NOT NULL DEFAULT '0' COMMENT '量程最小值',
+      `max_val` decimal(10,4) NOT NULL DEFAULT '0' COMMENT '量程最大值',
+      `item_one_value` tinyint(1) NOT NULL DEFAULT '1' COMMENT '约定值1',
+      `item_one_value_color` varchar(50) NOT NULL COMMENT '约定值 1 颜色',
+      `item_zero_value` tinyint(1) NOT NULL COMMENT '约定值 0',
+      `item_zero_value_color` varchar(55) NOT NULL COMMENT '约定值 0 颜色',
+      `is_flicker` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否闪烁 0 不闪烁 1 闪烁',
+      `bit_value` varchar(55) NOT NULL COMMENT '石景山取bit位规则',
+      `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+      PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
+      KEY `idx_project_item` (`project_id`,`item_name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='点位量程及颜色配置';
+
+
+
+
+
+

+ 24 - 0
app/model/dcitemconfigmodel.go

@@ -0,0 +1,24 @@
+package model
+
+import "github.com/zeromicro/go-zero/core/stores/sqlx"
+
+var _ DcItemConfigModel = (*customDcItemConfigModel)(nil)
+
+type (
+	// DcItemConfigModel is an interface to be customized, add more methods here,
+	// and implement the added methods in customDcItemConfigModel.
+	DcItemConfigModel interface {
+		dcItemConfigModel
+	}
+
+	customDcItemConfigModel struct {
+		*defaultDcItemConfigModel
+	}
+)
+
+// NewDcItemConfigModel returns a model for the database table.
+func NewDcItemConfigModel(conn sqlx.SqlConn) DcItemConfigModel {
+	return &customDcItemConfigModel{
+		defaultDcItemConfigModel: newDcItemConfigModel(conn),
+	}
+}

+ 97 - 0
app/model/dcitemconfigmodel_gen.go

@@ -0,0 +1,97 @@
+// Code generated by goctl. DO NOT EDIT.
+
+package model
+
+import (
+	"context"
+	"database/sql"
+	"fmt"
+	"strings"
+	"time"
+
+	"github.com/zeromicro/go-zero/core/stores/builder"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/stringx"
+)
+
+var (
+	dcItemConfigFieldNames          = builder.RawFieldNames(&DcItemConfig{})
+	dcItemConfigRows                = strings.Join(dcItemConfigFieldNames, ",")
+	dcItemConfigRowsExpectAutoSet   = strings.Join(stringx.Remove(dcItemConfigFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
+	dcItemConfigRowsWithPlaceHolder = strings.Join(stringx.Remove(dcItemConfigFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
+)
+
+type (
+	dcItemConfigModel interface {
+		Insert(ctx context.Context, data *DcItemConfig) (sql.Result, error)
+		FindOne(ctx context.Context, id int64) (*DcItemConfig, error)
+		Update(ctx context.Context, data *DcItemConfig) error
+		Delete(ctx context.Context, id int64) error
+	}
+
+	defaultDcItemConfigModel struct {
+		conn  sqlx.SqlConn
+		table string
+	}
+
+	DcItemConfig struct {
+		Id                 int64     `db:"id"`
+		ProjectId          int64     `db:"project_id"`
+		DeviceCode         string    `db:"device_code"`           // 位号
+		ItemName           string    `db:"item_name"`             // 点位名
+		ItemAlias          string    `db:"item_alias"`            // 别名
+		MinVal             float64   `db:"min_val"`               // 量程最小值
+		MaxVal             float64   `db:"max_val"`               // 量程最大值
+		ItemOneValue       int64     `db:"item_one_value"`        // 约定值1
+		ItemOneValueColor  string    `db:"item_one_value_color"`  // 约定值 1 颜色
+		ItemZeroValue      int64     `db:"item_zero_value"`       // 约定值 0
+		ItemZeroValueColor string    `db:"item_zero_value_color"` // 约定值 0 颜色
+		IsFlicker          int64     `db:"is_flicker"`            // 是否闪烁 0 不闪烁 1 闪烁
+		BitValue           string    `db:"bit_value"`             // 石景山取bit位规则
+		CreateTime         time.Time `db:"create_time"`
+	}
+)
+
+func newDcItemConfigModel(conn sqlx.SqlConn) *defaultDcItemConfigModel {
+	return &defaultDcItemConfigModel{
+		conn:  conn,
+		table: "`dc_item_config`",
+	}
+}
+
+func (m *defaultDcItemConfigModel) Delete(ctx context.Context, id int64) error {
+	query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
+	_, err := m.conn.ExecCtx(ctx, query, id)
+	return err
+}
+
+func (m *defaultDcItemConfigModel) FindOne(ctx context.Context, id int64) (*DcItemConfig, error) {
+	query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", dcItemConfigRows, m.table)
+	var resp DcItemConfig
+	err := m.conn.QueryRowCtx(ctx, &resp, query, id)
+	switch err {
+	case nil:
+		return &resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
+func (m *defaultDcItemConfigModel) Insert(ctx context.Context, data *DcItemConfig) (sql.Result, error) {
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, dcItemConfigRowsExpectAutoSet)
+	ret, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.ItemName, data.ItemAlias, data.MinVal, data.MaxVal, data.ItemOneValue, data.ItemOneValueColor, data.ItemZeroValue, data.ItemZeroValueColor, data.IsFlicker, data.BitValue)
+	return ret, err
+}
+
+func (m *defaultDcItemConfigModel) Update(ctx context.Context, data *DcItemConfig) error {
+	query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, dcItemConfigRowsWithPlaceHolder)
+	_, err := m.conn.ExecCtx(ctx, query, data.ProjectId, data.DeviceCode, data.ItemName, data.ItemAlias, data.MinVal, data.MaxVal, data.ItemOneValue, data.ItemOneValueColor, data.ItemZeroValue, data.ItemZeroValueColor, data.IsFlicker, data.BitValue, data.Id)
+	return err
+}
+
+func (m *defaultDcItemConfigModel) tableName() string {
+	return m.table
+}

+ 46 - 0
app/model/dcitemhistorydatamodel.go

@@ -0,0 +1,46 @@
+package model
+
+import (
+	"context"
+	"fmt"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+)
+
+var _ DcItemHistoryDataModel = (*customDcItemHistoryDataModel)(nil)
+
+type (
+	// DcItemHistoryDataModel is an interface to be customized, add more methods here,
+	// and implement the added methods in customDcItemHistoryDataModel.
+	DcItemHistoryDataModel interface {
+		dcItemHistoryDataModel
+		MultiInsert(ctx context.Context, datas []DcItemHistoryData) (int64, error)
+	}
+
+	customDcItemHistoryDataModel struct {
+		*defaultDcItemHistoryDataModel
+	}
+)
+
+// NewDcItemHistoryDataModel returns a model for the database table.
+func NewDcItemHistoryDataModel(conn sqlx.SqlConn) DcItemHistoryDataModel {
+	return &customDcItemHistoryDataModel{
+		defaultDcItemHistoryDataModel: newDcItemHistoryDataModel(conn),
+	}
+}
+
+func (m *defaultDcItemHistoryDataModel) MultiInsert(ctx context.Context, datas []DcItemHistoryData) (int64, error) {
+	query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?)", m.table, dcItemHistoryDataRowsExpectAutoSet)
+
+	if bulk, err := sqlx.NewBulkInserter(m.conn, query); err == nil {
+		for _, data := range datas {
+			if err = bulk.Insert(data.ProjectId, data.ItemName, data.Val, data.CTime); err != nil {
+				return 0, err
+			}
+		}
+
+		bulk.Flush()
+		return int64(len(datas)), nil
+	} else {
+		return 0, err
+	}
+}

+ 88 - 0
app/model/dcitemhistorydatamodel_gen.go

@@ -0,0 +1,88 @@
+// Code generated by goctl. DO NOT EDIT.
+
+package model
+
+import (
+	"context"
+	"database/sql"
+	"fmt"
+	"strings"
+	"time"
+
+	"github.com/zeromicro/go-zero/core/stores/builder"
+	"github.com/zeromicro/go-zero/core/stores/sqlc"
+	"github.com/zeromicro/go-zero/core/stores/sqlx"
+	"github.com/zeromicro/go-zero/core/stringx"
+)
+
+var (
+	dcItemHistoryDataFieldNames          = builder.RawFieldNames(&DcItemHistoryData{})
+	dcItemHistoryDataRows                = strings.Join(dcItemHistoryDataFieldNames, ",")
+	dcItemHistoryDataRowsExpectAutoSet   = strings.Join(stringx.Remove(dcItemHistoryDataFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
+	dcItemHistoryDataRowsWithPlaceHolder = strings.Join(stringx.Remove(dcItemHistoryDataFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
+)
+
+type (
+	dcItemHistoryDataModel interface {
+		Insert(ctx context.Context, data *DcItemHistoryData) (sql.Result, error)
+		FindOne(ctx context.Context, id int64) (*DcItemHistoryData, error)
+		Update(ctx context.Context, data *DcItemHistoryData) error
+		Delete(ctx context.Context, id int64) error
+	}
+
+	defaultDcItemHistoryDataModel struct {
+		conn  sqlx.SqlConn
+		table string
+	}
+
+	DcItemHistoryData struct {
+		Id        int64     `db:"id"`
+		ProjectId int64     `db:"project_id"` // 项目ID
+		ItemName  string    `db:"item_name"`  // 点位名
+		Val       float64   `db:"val"`        // 值
+		CTime     time.Time `db:"c_time"`     // 创建时间
+	}
+)
+
+func newDcItemHistoryDataModel(conn sqlx.SqlConn) *defaultDcItemHistoryDataModel {
+	return &defaultDcItemHistoryDataModel{
+		conn:  conn,
+		table: "`dc_item_history_data`",
+	}
+}
+
+func (m *defaultDcItemHistoryDataModel) Delete(ctx context.Context, id int64) error {
+	query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
+	_, err := m.conn.ExecCtx(ctx, query, id)
+	return err
+}
+
+func (m *defaultDcItemHistoryDataModel) FindOne(ctx context.Context, id int64) (*DcItemHistoryData, error) {
+	query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", dcItemHistoryDataRows, m.table)
+	var resp DcItemHistoryData
+	err := m.conn.QueryRowCtx(ctx, &resp, query, id)
+	switch err {
+	case nil:
+		return &resp, nil
+	case sqlc.ErrNotFound:
+		return nil, ErrNotFound
+	default:
+		return nil, err
+	}
+}
+
+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)
+	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)
+	return err
+}
+
+func (m *defaultDcItemHistoryDataModel) tableName() string {
+	return m.table
+}