huangyan 1 месяц назад
Родитель
Сommit
c018ffd789

+ 2 - 3
config/local.yml

@@ -52,12 +52,10 @@ hikvision:
     doorStates: "/artemis/api/acs/v1/door/states" #查询门禁设备状态接口
     eventLogs: "/artemis/api/scpms/v2/eventLogs/searches" #入侵报警事件日志查询
 
-
-
 #会议系统
 conference:
   pageSize: 9999
-  mobile: "14000000000"
+  mobile: "18026297604"
   password: "admin@123456"
   baseurl: "http://183.129.224.253:9998/api"
   getPublicKey: "/getPublicKey"
@@ -68,6 +66,7 @@ conference:
   meetingRoom: "/meetingRoom" #会议室详情
   location: "/location" #地点详情
   meetingRoomStatus: "/meetingRoomStatus/home" #会议室状态
+  meeting:  "/meeting" #会议记录
 #广播系统
 broadcast:
   pageSize: 9999

+ 31 - 0
internal/handler/conference.go

@@ -229,3 +229,34 @@ func (h *ConferenceHandler) GetRoomsByLocation(ctx *gin.Context) {
 	}
 	resp.HandleError(ctx, 1203, "获取会议室列表失败", string(request))
 }
+func (h *ConferenceHandler) GetRoomsMeeting(ctx *gin.Context) {
+	getRoomsmeeting := h.conf.GetString("conference.baseurl") + h.conf.GetString("conference.meeting")
+	date := ctx.Query("date")
+	types := ctx.Query("type")
+	status := ctx.Query("status")
+	search := ctx.Query("search")
+	page := ctx.Query("page")
+	pageSize := ctx.Query("pageSize")
+	record := ctx.Query("record")
+	is_external := ctx.Query("is_external")
+	m := make(map[string]string)
+	m["date"] = date
+	m["types"] = types
+	m["status"] = status
+	m["search"] = search
+	m["page"] = page
+	m["pageSize"] = pageSize
+	m["record"] = record
+	m["is_external"] = is_external
+	request, err := h.conferenceService.SendRequest(http.DefaultClient, "GET", getRoomsmeeting, m)
+	if err != nil {
+		resp.HandleError(ctx, 1203, "获取会议室列表失败", err.Error())
+		return
+	}
+	if gjson.Get(string(request), "code").Int() == 0 {
+		s := gjson.Get(string(request), "data").Value()
+		resp.HandleSuccess(ctx, s)
+		return
+	}
+	resp.HandleError(ctx, 1203, "获取会议记录失败", string(request))
+}

+ 57 - 47
internal/handler/hikvision.go

@@ -8,12 +8,12 @@ import (
 	"encoding/json"
 	"fmt"
 	"math/rand"
+	"net/http"
 	"strconv"
 	"time"
 
 	"github.com/gin-gonic/gin"
 	"github.com/spf13/viper"
-	"github.com/tidwall/gjson"
 )
 
 type HikvisionHandler struct {
@@ -36,6 +36,7 @@ func (h *HikvisionHandler) GetMonitor(ctx *gin.Context) {
 	LicensePlateRecognition := make(map[string]any)
 	Blacklist := make(map[string]any)
 	var monitor []model.Monitor
+	var monitornms []model.MonitorNms
 	for i := 0; i < 7; i++ {
 		name := fmt.Sprintf("周%v", i+1)
 		LicensePlateRecognition[name] = rand.Intn(100)
@@ -43,25 +44,29 @@ func (h *HikvisionHandler) GetMonitor(ctx *gin.Context) {
 	}
 	for i := 0; i < 20; i++ {
 		m2 := model.Monitor{
-			Id:   i + 1,
-			Name: model.GetRandomItem(model.MonitorDeviceNames),
+			Id:       i + 1,
+			State:    rand.Intn(2),
+			Location: model.GetRandomItem(model.MJlocations),
+			Name:     model.GetRandomItem(model.MonitorDeviceNames),
+		}
+		nms := model.MonitorNms{
+			Id:            i + 1,
+			Name:          model.GetRandomItem(model.MonitorDeviceNames),
+			InspectResult: rand.Intn(6),
 		}
 		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                             //监控列表
+		monitornms = append(monitornms, nms)
+	}
+	m["MonitorCount"] = rand.Intn(1000)       //摄像头总数
+	m["DeviceOnline"] = rand.Intn(1000)       //设备在线
+	m["DeviceOffline"] = rand.Intn(1000)      //设备离线
+	m["StorageCapacity"] = rand.Intn(1000)    //存储容量
+	m["MonitorList"] = monitor                //监控列表
+	m["MonitorNms"] = monitornms              //监控检测
+	m["ImageIsNormal"] = rand.Intn(1000)      //图像正常
+	m["ImageAbnormalities"] = rand.Intn(1000) //图像异常
+	m["DiagnosisFailed"] = rand.Intn(1000)    //诊断失败
+	m["NotDetected"] = rand.Intn(1000)        //未检测
 	resp.HandleSuccess(ctx, m)
 }
 
@@ -289,32 +294,37 @@ func (h *HikvisionHandler) GetHikvisionMonitoring(ctx *gin.Context) {
 		resp.HandleError(ctx, 1203, "设备编码不能为空", nil)
 		return
 	}
-	fmt.Println("cameraIndexCode", h.conf.GetString("hikvision.api.previewURLs"))
-	hikvision, err := h.hikvisionService.Hikvision(h.conf.GetString("hikvision.api.previewURLs"), m, 15)
-	//返回结果{
-	//    "code": "0",
-	//    "msg": "success",
-	//    "data": {
-	//        "url": "rtsp://10.2.145.66:655/EUrl/CLJ52BW"
-	//    }
+	ctx.HTML(http.StatusOK, "index.html", gin.H{
+		"title":   "测试",
+		"message": "ws://127.0.0.1/" + cameraIndexCode,
+	})
+	//fmt.Println("cameraIndexCode", h.conf.GetString("hikvision.api.previewURLs"))
+	//hikvision, err := h.hikvisionService.Hikvision(h.conf.GetString("hikvision.api.previewURLs"), m, 15)
+	////返回结果{
+	////    "code": "0",
+	////    "msg": "success",
+	////    "data": {
+	////        "url": "rtsp://10.2.145.66:655/EUrl/CLJ52BW"
+	////    }
+	////}
+	//if err != nil {
+	//	h.logger.Error("获取获取监控点资源失败")
+	//	resp.HandleError(ctx, 1201, "获取获取监控点资源失败", err)
+	//	return
 	//}
-	if err != nil {
-		h.logger.Error("获取获取监控点资源失败")
-		resp.HandleError(ctx, 1201, "获取获取监控点资源失败", err)
-		return
-	}
-	if hikvision.Code != "0" {
-		atoi, _ := strconv.Atoi(hikvision.Code)
-		resp.HandleError(ctx, atoi, hikvision.Msg, nil)
-		return
-	}
-	marshalString, err := json.Marshal(hikvision)
-	if err != nil {
-		resp.HandleError(ctx, 1202, "json序列化失败", nil)
-		return
-	}
-	url := gjson.Get(string(marshalString), "data.url")
-	resp.HandleSuccess(ctx, url)
+	//if hikvision.Code != "0" {
+	//	atoi, _ := strconv.Atoi(hikvision.Code)
+	//	resp.HandleError(ctx, atoi, hikvision.Msg, nil)
+	//	return
+	//}
+	//marshalString, err := json.Marshal(hikvision)
+	//if err != nil {
+	//	resp.HandleError(ctx, 1202, "json序列化失败", nil)
+	//	return
+	//}
+	//url := gjson.Get(string(marshalString), "data.url")
+	//
+	//resp.HandleSuccess(ctx, url)
 }
 
 // 视频监控云台控制{
@@ -584,24 +594,24 @@ func (h *HikvisionHandler) RealTimeInspection(ctx *gin.Context) {
 	hikvision, err := h.hikvisionService.Hikvision(h.conf.GetString("hikvision.api.eventLogs"), m, 15)
 	if err != nil {
 		h.logger.Error("入侵报警事件日志查询失败")
-		resp.HandleError(ctx, 1203, "入侵报警事件日志查询失败", nil)
+		resp.HandleError(ctx, 1203, "入侵报警事件日志查询失败", err)
 		return
 	}
 	if hikvision.Code != "0" {
 		h.logger.Error("入侵报警事件日志查询失败")
-		resp.HandleError(ctx, 1203, "入侵报警事件日志查询失败", nil)
+		resp.HandleError(ctx, 1203, "入侵报警事件日志查询失败", hikvision.Code)
 		return
 	}
 	marshal, err := json.Marshal(hikvision)
 	if err != nil {
 		h.logger.Error("json序列化失败")
-		resp.HandleError(ctx, 1203, "json序列化失败", nil)
+		resp.HandleError(ctx, 1203, "json序列化失败", err)
 		return
 	}
 	err = json.Unmarshal(marshal, &eventLogs)
 	if err != nil {
 		h.logger.Error("json反序列化失败")
-		resp.HandleError(ctx, 1203, "json反序列化失败", nil)
+		resp.HandleError(ctx, 1203, "json反序列化失败", err)
 		return
 	}
 	for i, _ := range eventLogs.Data.List {

+ 9 - 10
internal/handler/information.go

@@ -31,13 +31,12 @@ func NewInformationHandler(
 // GetInformation 获取信息发布数据
 func (h *InformationHandler) GetInformation(ctx *gin.Context) {
 	m := make(map[string]any)
-	readings := make(map[string]any)
 	var Large []model.LargeController
 	var information []model.InformationCount
 	for i := 0; i < 20; i++ {
 		records := model.LargeController{
 			Id:         i + 1,
-			DeviceName: model.LargeScreenNames[i],
+			DeviceName: model.GetRandomItem(model.LargeScreenNames),
 			UseState:   rand.Intn(2),
 		}
 		Large = append(Large, records)
@@ -51,13 +50,13 @@ func (h *InformationHandler) GetInformation(ctx *gin.Context) {
 		}
 		information = append(information, count)
 	}
-	readings["online"] = rand.Intn(100)  //在线率
-	readings["unline"] = rand.Intn(1000) //离线率
-	m["LargeScreen"] = rand.Intn(1000)   //大屏总
-	m["Normal"] = rand.Intn(1000)        //大屏正常
-	m["Fault"] = rand.Intn(1000)         //大屏故障数
-	m["Idle"] = rand.Intn(1000)          //大屏空闲数
-	m["Large"] = Large                   //大屏控制
-	m["Information"] = information       //进入信息占比
+	m["LargeScreen"] = rand.Intn(1000) //大屏总数
+	m["Normal"] = rand.Intn(1000)      //大屏正常数
+	m["Fault"] = rand.Intn(1000)       //大屏故障
+	m["Idle"] = rand.Intn(1000)        //大屏空闲
+	m["Large"] = Large                 //大屏控制
+	m["Information"] = information     //进入信息占比
+	m["online"] = rand.Intn(100)       //在线率
+	m["unline"] = rand.Intn(100)       //离线率
 	resp.HandleSuccess(ctx, m)
 }

+ 9 - 2
internal/model/hikvision.go

@@ -6,8 +6,15 @@ type Hikvision struct {
 	gorm.Model
 }
 type Monitor struct {
-	Id   int    `json:"Id"`
-	Name string `json:"Name"`
+	Id       int    `json:"Id"`
+	Name     string `json:"Name"`
+	Location string `json:"Location"` //位置
+	State    int    `json:"State"`    //状态
+}
+type MonitorNms struct {
+	Id            int    `json:"Id"`
+	Name          string `json:"Name"`
+	InspectResult int    `json:"InspectResult"` //状态(0-视频异常,1-视频正常,2-登录失败,3-取流异常,4-解码失败,5-码流延时,6-诊断失败)
 }
 type RealTimeInspection struct {
 	Id       int    `json:"Id"`

+ 3 - 0
internal/server/http.go

@@ -23,6 +23,7 @@ func NewServerHTTP(
 ) *gin.Engine {
 	gin.SetMode(gin.ReleaseMode)
 	r := gin.Default()
+	r.LoadHTMLGlob("templates/*")
 	//r.Use(
 	//	middleware.CORSMiddleware(),
 	//)
@@ -46,6 +47,7 @@ func NewServerHTTP(
 		Hikvision.GET("/access", hikvision.GetAccess)
 		Hikvision.GET("/getDoorSearch", hikvision.GetDoorSearch)
 		Hikvision.GET("/doControl", hikvision.DoControl)
+		Hikvision.GET("/eventLogs", hikvision.RealTimeInspection)
 	}
 	//会议系统
 	Conference := r.Group("/Conference")
@@ -56,6 +58,7 @@ func NewServerHTTP(
 		Conference.POST("/getRoomsByLocation", conference.GetRoomsByLocation)
 		Conference.GET("/meetingRoomById", conference.MeetingRoomById)
 		Conference.GET("/location", conference.Location)
+		Conference.GET("/meeting", conference.GetRoomsMeeting)
 	}
 	//首页数据
 	h := r.Group("/Home")

+ 5 - 2
internal/service/conference.go

@@ -57,8 +57,11 @@ func (s *conferenceService) SendRequest(client HTTPClient, method, url string, b
 	if err != nil {
 		return nil, err
 	}
-	// 设置请求头
-	req.Header.Set("Content-Type", "application/json")
+	if method == "POST" {
+		req.Header.Set("Content-Type", "application/json")
+	} else if method == "GET" {
+		req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
+	}
 	if token != "" {
 		req.Header.Set("Authorization", token)
 	}

+ 3 - 3
web/index.html → templates/index.html

@@ -2,9 +2,9 @@
 <html lang="en">
 <head>
     <meta charset="UTF-8">
-    <title>Title</title>
+    <title>{{.title}}</title>
 </head>
 <body>
-<h1>Hello World</h1>
+<h1>{{.message}}</h1>
 </body>
-</html>
+</html>