|
@@ -1,14 +1,18 @@
|
|
|
package handler
|
|
|
|
|
|
import (
|
|
|
+ "city_chips/internal/model"
|
|
|
"city_chips/internal/service"
|
|
|
"city_chips/pkg/helper/resp"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "math/rand"
|
|
|
+ "strconv"
|
|
|
+ "time"
|
|
|
+
|
|
|
"github.com/gin-gonic/gin"
|
|
|
"github.com/spf13/viper"
|
|
|
"github.com/tidwall/gjson"
|
|
|
- "strconv"
|
|
|
)
|
|
|
|
|
|
type HikvisionHandler struct {
|
|
@@ -25,6 +29,247 @@ func NewHikvisionHandler(handler *Handler, hikvisionService service.HikvisionSer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// GetMonitor 获取视频监控
|
|
|
+func (h *HikvisionHandler) GetMonitor(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ LicensePlateRecognition := make(map[string]any)
|
|
|
+ Blacklist := make(map[string]any)
|
|
|
+ var monitor []model.Monitor
|
|
|
+ for i := 0; i < 7; i++ {
|
|
|
+ name := fmt.Sprintf("周%v", i+1)
|
|
|
+ LicensePlateRecognition[name] = rand.Intn(100)
|
|
|
+ Blacklist[name] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ name := fmt.Sprintf("监控设备%v", i+1)
|
|
|
+ m2 := model.Monitor{
|
|
|
+ Id: i + 1,
|
|
|
+ Name: name,
|
|
|
+ }
|
|
|
+ monitor = append(monitor, m2)
|
|
|
+ }
|
|
|
+
|
|
|
+ m["MonitorCount"] = rand.Intn(1000) //摄像头总数
|
|
|
+ m["DeviceOnline"] = rand.Intn(1000) //设备在线
|
|
|
+ m["DeviceOffline"] = rand.Intn(1000) //设备离线
|
|
|
+ m["StorageCapacity"] = rand.Intn(1000) //存储容量
|
|
|
+ m["StoreSurplus"] = rand.Intn(1000) //存储剩余
|
|
|
+ m["IntrusionDetection"] = rand.Intn(1000) //入侵检测
|
|
|
+ m["AbnormalBehavior"] = rand.Intn(1000) //异常行为
|
|
|
+ m["LostAlarms"] = rand.Intn(1000) //丢失告警
|
|
|
+ m["LicensePlateRecognition"] = LicensePlateRecognition //车牌识别
|
|
|
+ m["Blacklist"] = Blacklist //黑名单
|
|
|
+ m["CPU"] = rand.Intn(100) //Cpu
|
|
|
+ m["RAM"] = rand.Intn(100) //RAM
|
|
|
+ m["MonitorList"] = monitor //监控列表
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
+// GetInvade 获取入侵检测
|
|
|
+func (h *HikvisionHandler) GetInvade(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ AlarmTrend24Hour := make(map[string]any)
|
|
|
+ var realTime []model.RealTimeInspection
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+ realTime = append(realTime, inspection)
|
|
|
+ }
|
|
|
+
|
|
|
+ m["DeviceAlerts"] = rand.Intn(100) //设备预警
|
|
|
+ m["LowRiskWarning"] = rand.Intn(100) //低危预警
|
|
|
+ m["MediumRiskWarning"] = rand.Intn(100) //中危预警
|
|
|
+ m["HighRiskWarning"] = rand.Intn(1000) //高危预警
|
|
|
+ m["HighRiskWarning"] = rand.Intn(1000) //高危预警
|
|
|
+ m["OverHazardWarning"] = rand.Intn(1000) //超危预警
|
|
|
+ m["EventRisk"] = rand.Intn(100) //事件风险
|
|
|
+ m["AlarmRisk"] = rand.Intn(100) //告警风险
|
|
|
+ m["trend"] = rand.Intn(100) //圆环中间百分比
|
|
|
+ m["realTime"] = realTime //实时巡检
|
|
|
+ m["AlarmTrend24Hour"] = AlarmTrend24Hour //24小时告警趋势
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
+// GetElectronicInspections 电子巡查
|
|
|
+func (h *HikvisionHandler) GetElectronicInspections(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ Inspect := make(map[string]any)
|
|
|
+ var device []model.Device
|
|
|
+ var realTime []model.RealTimeInspection
|
|
|
+
|
|
|
+ for i := 0; i < 24; i++ {
|
|
|
+ name := fmt.Sprintf("%v时", i+1)
|
|
|
+ Inspect[name] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ name := fmt.Sprintf("设备%v", i+1)
|
|
|
+ m2 := model.Device{
|
|
|
+ Id: i + 1,
|
|
|
+ Name: name,
|
|
|
+ State: rand.Intn(2),
|
|
|
+ Date: time.Now().Format("2006-01-02 15:04:05"),
|
|
|
+ }
|
|
|
+ device = append(device, m2)
|
|
|
+ }
|
|
|
+ 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,
|
|
|
+ }
|
|
|
+ realTime = append(realTime, inspection)
|
|
|
+ }
|
|
|
+ m["TodayTotal"] = rand.Intn(100) //今日总数
|
|
|
+ m["InspectionPoints"] = rand.Intn(100) //巡检点数
|
|
|
+ m["InspectionPlan"] = rand.Intn(100) //巡检计划
|
|
|
+ m["InspectTheLine"] = rand.Intn(1000) //巡检线路
|
|
|
+ m["Inspect"] = Inspect //巡检统计
|
|
|
+ m["realTime"] = realTime //实时巡检
|
|
|
+ m["DeviceList"] = device //设备列表
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
+// 访客系统
|
|
|
+func (h *HikvisionHandler) GetVisitor(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ PersonnelAllocation := make(map[string]any)
|
|
|
+ var visitor []model.Visitor
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ name := 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"),
|
|
|
+ }
|
|
|
+ PersonnelAllocation[address] = rand.Intn(100)
|
|
|
+ visitor = append(visitor, m2)
|
|
|
+ }
|
|
|
+
|
|
|
+ m["Area"] = rand.Intn(100) //总建筑面积
|
|
|
+ m["Test"] = rand.Intn(100) //测试
|
|
|
+ m["DeviceList"] = visitor //访客列表
|
|
|
+ m["PersonnelAllocation"] = PersonnelAllocation //外地人员分配
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
+// 客流统计
|
|
|
+func (h *HikvisionHandler) GetPassenger(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ Type1 := make(map[string]any)
|
|
|
+ Type2 := make(map[string]any)
|
|
|
+ Type3 := make(map[string]any)
|
|
|
+ Type4 := make(map[string]any)
|
|
|
+ rankings := make(map[string]any)
|
|
|
+ customers := make(map[string]any)
|
|
|
+ var event []model.RealTimeInspection
|
|
|
+ for i := 0; i < 7; i++ {
|
|
|
+ sprintf := fmt.Sprintf("2025-5-%v", i+1)
|
|
|
+ ranking := fmt.Sprintf("类型-%v", i+1)
|
|
|
+ rankings[ranking] = rand.Intn(100)
|
|
|
+ Type1[sprintf] = rand.Intn(100)
|
|
|
+ Type2[sprintf] = rand.Intn(100)
|
|
|
+ Type3[sprintf] = rand.Intn(100)
|
|
|
+ Type4[sprintf] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 3; i++ {
|
|
|
+ sprintf := fmt.Sprintf("客群-%v", i+1)
|
|
|
+ customers[sprintf] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ sprintf := fmt.Sprintf("安全事件-%v", i+1)
|
|
|
+ location := fmt.Sprintf("位置-%v", i+1)
|
|
|
+ inspection := model.RealTimeInspection{
|
|
|
+ Id: i + 1,
|
|
|
+ Name: sprintf,
|
|
|
+ Location: location,
|
|
|
+ Event: time.Now().Format("2006-01-02 15:04:05"),
|
|
|
+ }
|
|
|
+ event = append(event, inspection)
|
|
|
+ }
|
|
|
+ m["SecurityLevel"] = rand.Intn(500) //安全等级
|
|
|
+ m["NetworkEquipment"] = rand.Intn(100) //网络设备
|
|
|
+ m["Normal"] = rand.Intn(100) //正常
|
|
|
+ m["Fault"] = rand.Intn(100) //故障
|
|
|
+ m["Offline"] = rand.Intn(100) //离线
|
|
|
+ m["Type1"] = Type1 //客流监控type1
|
|
|
+ m["Type2"] = Type2 //客流监控type2
|
|
|
+ m["Type3"] = Type3 //客流监控type3
|
|
|
+ m["Type4"] = Type4 //客流监控type4
|
|
|
+ m["Rankings"] = rankings //指标区排行榜
|
|
|
+ m["Customers"] = customers //客群分析统计
|
|
|
+ m["Customers"] = customers //客群分析统计
|
|
|
+ m["Event"] = event //安全事件列表
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
+// 门禁系统
|
|
|
+func (h *HikvisionHandler) GetAccess(ctx *gin.Context) {
|
|
|
+ m := make(map[string]any)
|
|
|
+ invasio1 := make(map[string]any)
|
|
|
+ invasio2 := make(map[string]any)
|
|
|
+ DailyTotal := make(map[string]any)
|
|
|
+ Cumulative := make(map[string]any)
|
|
|
+ var devices []model.RealTimeInspection
|
|
|
+ var alarmList []model.AlarmList
|
|
|
+ for i := 0; i < 7; i++ {
|
|
|
+ sprintf := fmt.Sprintf("2025-5-%v", i+1)
|
|
|
+ invasio1[sprintf] = rand.Intn(100)
|
|
|
+ invasio2[sprintf] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 24; i++ {
|
|
|
+ sprintf := fmt.Sprintf("%v时", i+1)
|
|
|
+ DailyTotal[sprintf] = rand.Intn(100)
|
|
|
+ Cumulative[sprintf] = rand.Intn(100)
|
|
|
+ }
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+ sprintf := fmt.Sprintf("设备-%v", i+1)
|
|
|
+ location := fmt.Sprintf("位置-%v", i+1)
|
|
|
+ inspection := model.RealTimeInspection{
|
|
|
+ Id: i + 1,
|
|
|
+ Name: sprintf,
|
|
|
+ Location: location,
|
|
|
+ Event: time.Now().Format("2006-01-02 15:04:05"),
|
|
|
+ }
|
|
|
+ alarm := model.AlarmList{
|
|
|
+ Id: i + 1,
|
|
|
+ AlarmContent: fmt.Sprintf("设备-%v", i+1),
|
|
|
+ Location: location,
|
|
|
+ State: rand.Intn(2),
|
|
|
+ Date: time.Now().Format("2006-01-02 15:04:05"),
|
|
|
+ }
|
|
|
+
|
|
|
+ devices = append(devices, inspection)
|
|
|
+ alarmList = append(alarmList, alarm)
|
|
|
+ }
|
|
|
+
|
|
|
+ m["DeviceCount"] = rand.Intn(500) //设备总数
|
|
|
+ m["Online"] = rand.Intn(100) //在线
|
|
|
+ m["Abnormal"] = rand.Intn(100) //异常
|
|
|
+ m["Fault"] = rand.Intn(100) //故障
|
|
|
+ m["Offline"] = rand.Intn(100) //离线
|
|
|
+ m["Invasio1"] = invasio1 //入侵事件1
|
|
|
+ m["Invasio2"] = invasio2 //入侵事件2
|
|
|
+ m["DailyTotal"] = DailyTotal //每日统计
|
|
|
+ m["Cumulative"] = Cumulative //累计统计
|
|
|
+ m["AlarmList"] = alarmList //实时告警与通知
|
|
|
+ resp.HandleSuccess(ctx, m)
|
|
|
+}
|
|
|
+
|
|
|
// GetHikvisionMonitoring 获取视频监控流{
|
|
|
// "cameraIndexCode": "748d84750e3a4a5bbad3cd4af9ed5101",
|
|
|
// "streamType": 0,
|