소스 검색

日志保存时间修改,控制卡登录修改

chengqian 5 달 전
부모
커밋
77f74c22b1
5개의 변경된 파일20개의 추가작업 그리고 9개의 파일을 삭제
  1. BIN
      server/build/smart_intersection
  2. 1 1
      server/config.yaml
  3. 15 7
      server/service/tcp/deviceMgr.go
  4. 1 1
      server/utils/logger/lclog.go
  5. 3 0
      server/utils/mqtt/mqtt_handle.go

BIN
server/build/smart_intersection


+ 1 - 1
server/config.yaml

@@ -134,7 +134,7 @@ mysql:
     singular: false
     log-zap: false
 mqtt:
-    server: "tcp://106.52.134.22:1883"
+    server: "tcp://118.253.180.18:1883"
     id: "smart_intersection_admin"
     user: "admin"
     password: "admin"

+ 15 - 7
server/service/tcp/deviceMgr.go

@@ -62,6 +62,18 @@ func (s *Device) Process() {
 				logger.Logger.Errorf("Process[case '61'] SN not found \n")
 				break
 			}
+
+			err = Dev.UpdateScreensStatus(screens.ScreensCode, request.DeviceStatus{
+				Status:        1,
+				PlayStatus:    1,
+				DisplayStatus: 1,
+				SourceStatus:  1,
+			})
+			if err != nil {
+				logger.Logger.Error("[Handle] UpdateScreensStatus err", zap.Error(err))
+				continue
+			}
+
 			s.info = screens
 			devices[s.info.Sn] = *s
 			s.conn.Write(buffer.Bytes())
@@ -98,17 +110,13 @@ func (s *Device) Handle() {
 		case <-t2.C:
 			state := request.DeviceStatus{
 				Status:        1,
-				PlayStatus:    1,
-				DisplayStatus: 1,
-				SourceStatus:  1,
+				PlayStatus:    s.info.PlayStatus,
+				DisplayStatus: s.info.DisplayStatus,
+				SourceStatus:  s.info.SourceStatus,
 			}
 			if time.Now().Add(-2*time.Minute).After(s.lastTime) || s.lastTime.IsZero() {
 				//离线
 				state.Status = 0
-				state.PlayStatus = 0
-				state.DisplayStatus = 0
-				state.SourceStatus = 0
-
 				err := Dev.UpdateScreensStatus(s.info.ScreensCode, state)
 				if err != nil {
 					logger.Logger.Error("[Handle] UpdateScreensStatus err", zap.Error(err))

+ 1 - 1
server/utils/logger/lclog.go

@@ -28,7 +28,7 @@ func InitLog() {
 	fileName := path.Join(logFilePath, logFileName)
 	writer, _ := rotatelogs.New(
 		fileName+".%Y%m%d.log",
-		rotatelogs.WithMaxAge(15*24*time.Hour),    // 文件最大保存时间
+		rotatelogs.WithMaxAge(5*24*time.Hour),     // 文件最大保存时间
 		rotatelogs.WithRotationTime(24*time.Hour), // 日志切割时间间隔
 	)
 	// 实例化

+ 3 - 0
server/utils/mqtt/mqtt_handle.go

@@ -2,6 +2,7 @@ package mqtt
 
 import (
 	"errors"
+	"fmt"
 	jsoniter "github.com/json-iterator/go"
 	"go.uber.org/zap"
 	"runtime"
@@ -102,6 +103,8 @@ func (o *MqttHandler) Handler() interface{} {
 			if err != nil {
 				logger.Logger.Error("UpdateScreensStatus err", zap.Error(err))
 			}
+		default:
+			fmt.Println("我是主题:::", topic)
 		}
 	}
 }