Przeglądaj źródła

照明系统,能源系统

huangyan 2 miesięcy temu
rodzic
commit
108b103491

BIN
cmd/server/city_chips


+ 3 - 0
cmd/server/wire/wire.go

@@ -31,6 +31,7 @@ var RepositorySet = wire.NewSet(
 	repository.NewInformationRepository,
 	repository.NewIlluminatingRepository,
 	repository.NewEnergyRepository,
+	repository.NewIntelligentBuildingControlRepository,
 )
 
 var ServiceSet = wire.NewSet(
@@ -46,6 +47,7 @@ var ServiceSet = wire.NewSet(
 	service.NewInformationService,
 	service.NewIlluminatingService,
 	service.NewEnergyService,
+	service.NewIntelligentBuildingControlService,
 )
 
 var HandlerSet = wire.NewSet(
@@ -61,6 +63,7 @@ var HandlerSet = wire.NewSet(
 	handler.NewInformationHandler,
 	handler.NewIlluminatingHandler,
 	handler.NewEnergyHandler,
+	handler.NewIntelligentBuildingControlHandler,
 )
 
 func NewWire(*viper.Viper, *log.Logger) (*gin.Engine, func(), error) {

+ 7 - 4
cmd/server/wire/wire_gen.go

@@ -55,7 +55,10 @@ func NewWire(viperViper *viper.Viper, logger *log.Logger) (*gin.Engine, func(),
 	energyRepository := repository.NewEnergyRepository(repositoryRepository)
 	energyService := service.NewEnergyService(serviceService, energyRepository)
 	energyHandler := handler.NewEnergyHandler(handlerHandler, energyService, viperViper)
-	engine := server.NewServerHTTP(logger, accessControlHandler, hikvisionHandler, conferenceHandler, homeHandler, elevatorHandler, broadcastHandler, propertyHandler, informationHandler, illuminatingHandler, energyHandler)
+	intelligentBuildingControlRepository := repository.NewIntelligentBuildingControlRepository(repositoryRepository)
+	intelligentBuildingControlService := service.NewIntelligentBuildingControlService(serviceService, intelligentBuildingControlRepository)
+	intelligentBuildingControlHandler := handler.NewIntelligentBuildingControlHandler(handlerHandler, intelligentBuildingControlService, viperViper)
+	engine := server.NewServerHTTP(logger, accessControlHandler, hikvisionHandler, conferenceHandler, homeHandler, elevatorHandler, broadcastHandler, propertyHandler, informationHandler, illuminatingHandler, energyHandler, intelligentBuildingControlHandler)
 	return engine, func() {
 	}, nil
 }
@@ -64,8 +67,8 @@ func NewWire(viperViper *viper.Viper, logger *log.Logger) (*gin.Engine, func(),
 
 var ServerSet = wire.NewSet(server.NewServerHTTP)
 
-var RepositorySet = wire.NewSet(repository.NewDb, repository.NewRedis, repository.NewRepository, repository.NewUserRepository, repository.NewAccessControlRepository, repository.NewHikvisionRepository, repository.NewConferenceRepository, repository.NewHomeRepository, repository.NewElevatorRepository, repository.NewBroadcastRepository, repository.NewPropertyRepository, repository.NewInformationRepository, repository.NewIlluminatingRepository, repository.NewEnergyRepository)
+var RepositorySet = wire.NewSet(repository.NewDb, repository.NewRedis, repository.NewRepository, repository.NewUserRepository, repository.NewAccessControlRepository, repository.NewHikvisionRepository, repository.NewConferenceRepository, repository.NewHomeRepository, repository.NewElevatorRepository, repository.NewBroadcastRepository, repository.NewPropertyRepository, repository.NewInformationRepository, repository.NewIlluminatingRepository, repository.NewEnergyRepository, repository.NewIntelligentBuildingControlRepository)
 
-var ServiceSet = wire.NewSet(service.NewService, service.NewUserService, service.NewAccessControlService, service.NewHikvisionService, service.NewConferenceService, service.NewHomeService, service.NewElevatorService, service.NewBroadcastService, service.NewPropertyService, service.NewInformationService, service.NewIlluminatingService, service.NewEnergyService)
+var ServiceSet = wire.NewSet(service.NewService, service.NewUserService, service.NewAccessControlService, service.NewHikvisionService, service.NewConferenceService, service.NewHomeService, service.NewElevatorService, service.NewBroadcastService, service.NewPropertyService, service.NewInformationService, service.NewIlluminatingService, service.NewEnergyService, service.NewIntelligentBuildingControlService)
 
-var HandlerSet = wire.NewSet(handler.NewHandler, handler.NewUserHandler, handler.NewAccessControlHandler, handler.NewHikvisionHandler, handler.NewConferenceHandler, handler.NewHomeHandler, handler.NewElevatorHandler, handler.NewBroadcastHandler, handler.NewPropertyHandler, handler.NewInformationHandler, handler.NewIlluminatingHandler, handler.NewEnergyHandler)
+var HandlerSet = wire.NewSet(handler.NewHandler, handler.NewUserHandler, handler.NewAccessControlHandler, handler.NewHikvisionHandler, handler.NewConferenceHandler, handler.NewHomeHandler, handler.NewElevatorHandler, handler.NewBroadcastHandler, handler.NewPropertyHandler, handler.NewInformationHandler, handler.NewIlluminatingHandler, handler.NewEnergyHandler, handler.NewIntelligentBuildingControlHandler)

+ 31 - 20
internal/handler/hikvision.go

@@ -69,19 +69,18 @@ func (h *HikvisionHandler) GetMonitor(ctx *gin.Context) {
 func (h *HikvisionHandler) GetInvade(ctx *gin.Context) {
 	m := make(map[string]any)
 	AlarmTrend24Hour := make(map[string]any)
-	var realTime []model.RealTimeInspection
+	var realTime []model.Device
 	for i := 0; i < 24; i++ {
 		name := fmt.Sprintf("%v时", i+1)
 		AlarmTrend24Hour[name] = rand.Intn(100)
 	}
 	for i := 0; i < 10; i++ {
-		name := fmt.Sprintf("巡检事件%v", i+1)
-		Location := fmt.Sprintf("位置%v", i+1)
-		inspection := model.RealTimeInspection{
-			Id:       i + 1,
-			Name:     name,
-			Location: Location,
-			Event:    name,
+		name := fmt.Sprintf("设备%v", i+1)
+		inspection := model.Device{
+			Id:    i + 1,
+			Name:  name,
+			State: rand.Intn(2),
+			Date:  time.Now().Format("2006-01-02 15:04:05"),
 		}
 		realTime = append(realTime, inspection)
 	}
@@ -145,25 +144,35 @@ func (h *HikvisionHandler) GetElectronicInspections(ctx *gin.Context) {
 // 访客系统
 func (h *HikvisionHandler) GetVisitor(ctx *gin.Context) {
 	m := make(map[string]any)
-	PersonnelAllocation := make(map[string]any)
+	PrevailingTrends := make(map[string]any)
 	var visitor []model.Visitor
-	for i := 0; i < 10; i++ {
+	for i := 0; i < 24; i++ {
 		name := fmt.Sprintf("人员%v", i+1)
-		address := fmt.Sprintf("地址%v", i+1)
+		address := fmt.Sprintf("%v", i+1)
 		m2 := model.Visitor{
-			Id:    i + 1,
-			Name:  name,
-			State: rand.Intn(2),
-			Date:  time.Now().Format("2006-01-02 15:04:05"),
+			Id:       i + 1,
+			Name:     name,
+			State:    rand.Intn(2),
+			Phone:    strconv.Itoa(rand.Intn(1000000000)),
+			Location: address,
+			Date:     time.Now().Format("2006-01-02 15:04:05"),
 		}
-		PersonnelAllocation[address] = rand.Intn(100)
+		PrevailingTrends[address] = rand.Intn(100)
 		visitor = append(visitor, m2)
 	}
 
-	m["Area"] = rand.Intn(100)                     //总建筑面积
-	m["Test"] = rand.Intn(100)                     //测试
-	m["DeviceList"] = visitor                      //访客列表
-	m["PersonnelAllocation"] = PersonnelAllocation //外地人员分配
+	m["VisitorCount"] = rand.Intn(1000)       //访客总量
+	m["SignInCount"] = rand.Intn(1000)        //签到数量
+	m["TransitCount"] = rand.Intn(1000)       //通行数量
+	m["Exit"] = rand.Intn(1000)               //离场数量
+	m["Client"] = rand.Intn(100)              //客户
+	m["Vendor"] = rand.Intn(100)              //供应商
+	m["Interviewees"] = rand.Intn(100)        //面试者
+	m["GovernmentPersonnel"] = rand.Intn(100) //政府人员
+	m["Other"] = rand.Intn(100)               //其他
+	m["PrevailingTrends"] = PrevailingTrends  //通行趋势
+	m["VisitorRegistration"] = visitor        //访客登记
+	m["VisitorsSwipeCards"] = visitor         //访客刷卡记录
 	resp.HandleSuccess(ctx, m)
 }
 
@@ -262,11 +271,13 @@ func (h *HikvisionHandler) GetAccess(ctx *gin.Context) {
 	m["Abnormal"] = rand.Intn(100)    //异常
 	m["Fault"] = rand.Intn(100)       //故障
 	m["Offline"] = rand.Intn(100)     //离线
+	m["Attendance"] = rand.Intn(100)  //出勤率
 	m["Invasio1"] = invasio1          //入侵事件1
 	m["Invasio2"] = invasio2          //入侵事件2
 	m["DailyTotal"] = DailyTotal      //每日统计
 	m["Cumulative"] = Cumulative      //累计统计
 	m["AlarmList"] = alarmList        //实时告警与通知
+	m["devices"] = devices            //设备列表
 	resp.HandleSuccess(ctx, m)
 }
 

+ 58 - 0
internal/handler/intelligentbuildingcontrol.go

@@ -0,0 +1,58 @@
+package handler
+
+import (
+	"city_chips/internal/model"
+	"city_chips/internal/service"
+	"city_chips/pkg/helper/resp"
+	"fmt"
+	"github.com/spf13/viper"
+	"math/rand"
+	"time"
+
+	"github.com/gin-gonic/gin"
+)
+
+type IntelligentBuildingControlHandler struct {
+	*Handler
+	intelligentBuildingControlService service.IntelligentBuildingControlService
+	conf                              *viper.Viper
+}
+
+func NewIntelligentBuildingControlHandler(
+	handler *Handler,
+	intelligentBuildingControlService service.IntelligentBuildingControlService,
+	conf *viper.Viper,
+) *IntelligentBuildingControlHandler {
+	return &IntelligentBuildingControlHandler{
+		Handler:                           handler,
+		intelligentBuildingControlService: intelligentBuildingControlService,
+		conf:                              conf,
+	}
+}
+
+func (h *IntelligentBuildingControlHandler) GetIntelligentBuildingControl(ctx *gin.Context) {
+	m := make(map[string]any)
+	var device []model.AlarmList
+	for i := 0; i < 10; i++ {
+		name := fmt.Sprintf("设备%v", i+1)
+		location := fmt.Sprintf("位置%v", i+1)
+		alarm := fmt.Sprintf("报警时间%v", i+1)
+		inspection := model.AlarmList{
+			Id:           i + 1,
+			Name:         name,
+			State:        rand.Intn(2),
+			Date:         time.Now().Format("2006-01-02 15:04:05"),
+			Location:     location,
+			AlarmContent: alarm,
+		}
+		device = append(device, inspection)
+	}
+
+	m["DeviceCount"] = rand.Intn(100) //设备总数
+	m["StopState"] = rand.Intn(100)   //停止状态
+	m["RunState"] = rand.Intn(100)    //运行状态
+	m["FaultState"] = rand.Intn(1000) //故障状态
+	m["DeviceList"] = device          //设备列表
+
+	resp.HandleSuccess(ctx, m)
+}

+ 7 - 4
internal/model/hikvision.go

@@ -22,13 +22,16 @@ type Device struct {
 	Date  string `json:"Date"`  //事件-列3
 }
 type Visitor struct {
-	Id    int    `json:"Id"`
-	Name  string `json:"Name"`  //名称
-	State int    `json:"State"` //状态
-	Date  string `json:"Date"`  //事件-列3
+	Id       int    `json:"Id"`
+	Name     string `json:"Name"`     //名称
+	State    int    `json:"State"`    //状态
+	Phone    string `json:"Phone"`    //电话
+	Location string `json:"Location"` //位置
+	Date     string `json:"Date"`     //时间
 }
 type AlarmList struct {
 	Id           int    `json:"Id"`
+	Name         string `json:"Name"`         //名称
 	AlarmContent string `json:"AlarmContent"` //告警内容
 	Location     string `json:"Location"`     //位置
 	State        int    `json:"State"`        //状态

+ 11 - 0
internal/model/intelligentbuildingcontrol.go

@@ -0,0 +1,11 @@
+package model
+
+import "gorm.io/gorm"
+
+type IntelligentBuildingControl struct {
+	gorm.Model
+}
+
+func (m *IntelligentBuildingControl) TableName() string {
+	return "intelligent_building_control"
+}

+ 28 - 0
internal/repository/intelligentbuildingcontrol.go

@@ -0,0 +1,28 @@
+package repository
+
+import (
+	"city_chips/internal/model"
+	"context"
+)
+
+type IntelligentBuildingControlRepository interface {
+	GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error)
+}
+
+func NewIntelligentBuildingControlRepository(
+	repository *Repository,
+) IntelligentBuildingControlRepository {
+	return &intelligentBuildingControlRepository{
+		Repository: repository,
+	}
+}
+
+type intelligentBuildingControlRepository struct {
+	*Repository
+}
+
+func (r *intelligentBuildingControlRepository) GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error) {
+	var intelligentBuildingControl model.IntelligentBuildingControl
+
+	return &intelligentBuildingControl, nil
+}

+ 6 - 0
internal/server/http.go

@@ -20,6 +20,7 @@ func NewServerHTTP(
 	information *handler.InformationHandler,
 	illuminating *handler.IlluminatingHandler,
 	energy *handler.EnergyHandler,
+	intell *handler.IntelligentBuildingControlHandler,
 ) *gin.Engine {
 	gin.SetMode(gin.ReleaseMode)
 	r := gin.Default()
@@ -89,5 +90,10 @@ func NewServerHTTP(
 	{
 		ener.GET("/count", energy.GetEnergy)
 	}
+	//楼宇智控
+	inte := r.Group("/intell")
+	{
+		inte.GET("/count", intell.GetIntelligentBuildingControl)
+	}
 	return r
 }

+ 30 - 0
internal/service/intelligentbuildingcontrol.go

@@ -0,0 +1,30 @@
+package service
+
+import (
+	"city_chips/internal/model"
+	"city_chips/internal/repository"
+	"context"
+)
+
+type IntelligentBuildingControlService interface {
+	GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error)
+}
+
+func NewIntelligentBuildingControlService(
+	service *Service,
+	intelligentBuildingControlRepository repository.IntelligentBuildingControlRepository,
+) IntelligentBuildingControlService {
+	return &intelligentBuildingControlService{
+		Service:                              service,
+		intelligentBuildingControlRepository: intelligentBuildingControlRepository,
+	}
+}
+
+type intelligentBuildingControlService struct {
+	*Service
+	intelligentBuildingControlRepository repository.IntelligentBuildingControlRepository
+}
+
+func (s *intelligentBuildingControlService) GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error) {
+	return s.intelligentBuildingControlRepository.GetIntelligentBuildingControl(ctx, id)
+}