Browse Source

增加LED屏最近在线时间

chengqian 4 months ago
parent
commit
a3f36b24cd

BIN
server/build/smart_intersection


+ 28 - 26
server/dao/devices/dev_screens.go

@@ -8,27 +8,28 @@ import (
 )
 
 type Screens struct {
-	ID            int            `gorm:"primarykey" json:"ID"`                    //主键ID
-	ScreensName   string         `gorm:"type:varchar(64)" json:"screensName"`     //设备名称
-	ScreensCode   string         `gorm:"type:varchar(64)" json:"screensCode"`     //设备编码
-	Sn            string         `gorm:"type:varchar(64)" json:"sn"`              //设备sn
-	Network       int            `gorm:"type:int" json:"network"`                 //组网方式 0代表网关 1代表4G模块
-	GatewayId     int            `gorm:"type:int" json:"gatewayId"`               //所属网关
-	ScreensBrand  string         `gorm:"type:varchar(60)" json:"screensBrand"`    //屏幕品牌
-	ScreensModel  string         `gorm:"type:varchar(60)" json:"screensModel"`    //屏幕型号
-	IPAddress     string         `gorm:"type:varchar(40)" json:"ipAddress"`       //IP地址
-	InstallTime   time.Time      `gorm:"type:date" json:"installTime"`            //安装时间
-	Shunt         int            `gorm:"type:int" json:"shunt"`                   //所属分路 1主路,2支路
-	ShuntDescribe string         `gorm:"type:varchar(60)" json:"shuntDescribe"`   //分路描述
-	ResolutionId  int            `gorm:"type:int" json:"resolutionId"`            //分辨率
-	ScreensSizeId int            `gorm:"type:int" json:"screensSizeId"`           //信息屏尺寸
-	IsDeleted     gorm.DeletedAt `gorm:"default:null" json:"isDeleted"`           //是否删除
-	Status        int            `gorm:"type:int;default:0" json:"status"`        //在线状态 0=离线,1=在线
-	PlayStatus    int            `gorm:"type:int;default:0" json:"playStatus"`    //播放状态
-	DisplayStatus int            `gorm:"type:int;default:0" json:"displayStatus"` //显示模板状态
-	SourceStatus  int            `gorm:"type:int;default:0" json:"sourceStatus"`  //素材状态
-	DayBright     int            `gorm:"type:int;default:100" json:"dayBright"`   //白天亮度
-	NightBright   int            `gorm:"type:int;default:30" json:"nightBright"`  //晚上亮度
+	ID             int            `gorm:"primarykey" json:"ID"`                    //主键ID
+	ScreensName    string         `gorm:"type:varchar(64)" json:"screensName"`     //设备名称
+	ScreensCode    string         `gorm:"type:varchar(64)" json:"screensCode"`     //设备编码
+	Sn             string         `gorm:"type:varchar(64)" json:"sn"`              //设备sn
+	Network        int            `gorm:"type:int" json:"network"`                 //组网方式 0代表网关 1代表4G模块
+	GatewayId      int            `gorm:"type:int" json:"gatewayId"`               //所属网关
+	ScreensBrand   string         `gorm:"type:varchar(60)" json:"screensBrand"`    //屏幕品牌
+	ScreensModel   string         `gorm:"type:varchar(60)" json:"screensModel"`    //屏幕型号
+	IPAddress      string         `gorm:"type:varchar(40)" json:"ipAddress"`       //IP地址
+	InstallTime    time.Time      `gorm:"type:date" json:"installTime"`            //安装时间
+	Shunt          int            `gorm:"type:int" json:"shunt"`                   //所属分路 1主路,2支路
+	ShuntDescribe  string         `gorm:"type:varchar(60)" json:"shuntDescribe"`   //分路描述
+	ResolutionId   int            `gorm:"type:int" json:"resolutionId"`            //分辨率
+	ScreensSizeId  int            `gorm:"type:int" json:"screensSizeId"`           //信息屏尺寸
+	IsDeleted      gorm.DeletedAt `gorm:"default:null" json:"isDeleted"`           //是否删除
+	Status         int            `gorm:"type:int;default:0" json:"status"`        //在线状态 0=离线,1=在线
+	PlayStatus     int            `gorm:"type:int;default:0" json:"playStatus"`    //播放状态
+	DisplayStatus  int            `gorm:"type:int;default:0" json:"displayStatus"` //显示模板状态
+	SourceStatus   int            `gorm:"type:int;default:0" json:"sourceStatus"`  //素材状态
+	DayBright      int            `gorm:"type:int;default:100" json:"dayBright"`   //白天亮度
+	NightBright    int            `gorm:"type:int;default:30" json:"nightBright"`  //晚上亮度
+	LastOnlineTime time.Time      `gorm:"type:datetime;" json:"lastOnlineTime"`    //最近在线时间
 
 	GateWay     GateWay     `gorm:"foreignkey:GatewayId"`
 	Resolution  Resolution  `gorm:"foreignkey:ResolutionId"`
@@ -112,12 +113,13 @@ func UpdateScreensStatusByGatewayId(id, status int) error {
 
 func UpdateScreensStatus(code string, sta request.DeviceStatus) error {
 	var screens Screens
-	return global.GVA_DB.Model(&screens).Select("status", "play_status", "display_status", "source_status").
+	return global.GVA_DB.Model(&screens).Select("status", "play_status", "display_status", "source_status", "last_online_time").
 		Where("screens_code = ?", code).Updates(map[string]interface{}{
-		"status":         sta.Status,
-		"play_status":    sta.PlayStatus,
-		"display_status": sta.DisplayStatus,
-		"source_status":  sta.SourceStatus,
+		"status":           sta.Status,
+		"play_status":      sta.PlayStatus,
+		"display_status":   sta.DisplayStatus,
+		"source_status":    sta.SourceStatus,
+		"last_online_time": time.Now(),
 	}).Error
 }
 

+ 1 - 0
web/package.json

@@ -20,6 +20,7 @@
         "axios": "^1.4.0",
         "core-js": "^3.31.1",
         "date-fns": "^3.6.0",
+        "dayjs": "^1.11.13",
         "echarts": "5.4.3",
         "element-plus": "^2.3.8",
         "highlight.js": "^11.8.0",

+ 7 - 1
web/src/view/devicesAdmin/screens/screens.vue

@@ -253,7 +253,7 @@
       <el-dialog v-model="viewScreensDialog" title="详情" style="padding: 35px">
         <el-form
             :model="screensInfo"
-            label-width="100px"
+            label-width="110px"
             style="padding: 20px"
         >
           <el-row>
@@ -362,6 +362,11 @@
                 {{screensInfo.installTime }}
               </el-form-item>
             </el-col>
+            <el-col :span="12">
+              <el-form-item label="最近在线时间:" :inline="false">
+                {{ dayjs(screensInfo.lastOnlineTime).format('YYYY-MM-DD HH:mm:ss') }}
+              </el-form-item>
+            </el-col>
           </el-row>
         </el-form>
       </el-dialog>
@@ -485,6 +490,7 @@ import {
 } from "@/api/screens";
 import { ref,reactive} from 'vue'
 import {ElMessage, ElMessageBox} from "element-plus";
+import dayjs from "dayjs";
 const page = ref(1)
 const total = ref(0)
 const pageSize = ref(10)