From d5769136a6e78b1a825fa390fb2c8b710b1e064b Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期五, 29 三月 2024 09:57:00 +0800
Subject: [PATCH] 调整日志打印
---
controller/captureCtl.go | 2
models/device.go | 2
repository/captureRepo.go | 26 +++++-------
service/report.go | 7 ++-
vo/forward.go | 24 +++++-------
service/nvcs.go | 2
6 files changed, 29 insertions(+), 34 deletions(-)
diff --git a/controller/captureCtl.go b/controller/captureCtl.go
index fc4cd79..6dd58f8 100644
--- a/controller/captureCtl.go
+++ b/controller/captureCtl.go
@@ -38,7 +38,7 @@
face := req.FaceListObject.FaceObject[0]
- logger.Debug("鎺ユ敹鍒颁汉鑴告暟鎹�, faceId:%s, LeftTopX:%d", face.FaceID, face.LeftTopX)
+ logger.Debug("鎺ユ敹鍒颁汉鑴告暟鎹�, ip:%s dev:%s faceId:%s, LeftTopX:%d", c.RemoteIP(), face.DeviceID, face.FaceID, face.LeftTopX)
a.Repository.FaceForward(req.FaceListObject.FaceObject)
diff --git a/models/device.go b/models/device.go
index 5a6b417..6c5ab51 100644
--- a/models/device.go
+++ b/models/device.go
@@ -33,7 +33,7 @@
func (d *Device) Upsert() error {
var existingDevice Device
- if err := db.Where("id = ?", d.Id).First(&existingDevice).Error; err != nil {
+ if err := db.Table(d.TableName()).Where("id = ?", d.Id).First(&existingDevice).Error; err != nil {
if err == gorm.ErrRecordNotFound {
// 璁板綍涓嶅瓨鍦紝鍒涘缓鏂拌褰�
db.Create(&d)
diff --git a/repository/captureRepo.go b/repository/captureRepo.go
index 027172f..76a963d 100644
--- a/repository/captureRepo.go
+++ b/repository/captureRepo.go
@@ -70,7 +70,7 @@
var device models.Device
if err := device.FindById(deviceId); err != nil {
- logger.Debug("Can't find device in database, device:%s, %s", deviceId, err.Error())
+ logger.Warn("Can't find device in database, device:%s, %s", deviceId, err.Error())
return pd
}
@@ -83,20 +83,16 @@
pd.PicMaxImages = append(pd.PicMaxImages, imageBytes)
tr := vo.TaskResultInfo{
- Id: uuid.NewV4().String(),
- CameraId: deviceId,
- OrgName: "",
- CameraAddr: device.Addr + device.Pos,
- CameraName: device.Name,
- PicMaxUrl: []string{""},
- PicDate: time.Now().Format("2006-01-02 15:04:05"),
- LikeDate: time.Now().Format("2006-01-02 15:04:05"),
- TaskId: "",
- AnalyServerId: deviceId,
- AnalyServerName: "",
- AnalyServerIp: "",
- DataSource: "camera",
- TargetInfo: []vo.TargetInfo{{TargetId: faceId}},
+ Id: uuid.NewV4().String(),
+ CameraId: deviceId,
+ CameraAddr: device.Addr + device.Pos,
+ CameraName: device.Name,
+ PicMaxUrl: []string{""},
+ PicDate: time.Now().Format("2006-01-02 15:04:05"),
+ LikeDate: time.Now().Format("2006-01-02 15:04:05"),
+ AnalyServerId: deviceId,
+ DataSource: "camera",
+ TargetInfo: []vo.TargetInfo{{TargetId: faceId}},
}
pd.SourceData = vo.ESInfo{
diff --git a/service/nvcs.go b/service/nvcs.go
index 7a4605b..fb255cd 100644
--- a/service/nvcs.go
+++ b/service/nvcs.go
@@ -54,7 +54,7 @@
}
defer conn.Close()
- logger.Debug("UDP server listening on port %s...", port)
+ logger.Info("UDP server listening on port %s...", port)
// 鏃犻檺寰幆绛夊緟鎺ユ敹鏁版嵁
for {
diff --git a/service/report.go b/service/report.go
index 4409839..f352d55 100644
--- a/service/report.go
+++ b/service/report.go
@@ -69,7 +69,12 @@
return err
}
+ logger.Info("Report device info. %+v", dev)
+
_, err = HttpPost(config.ForwardConf.ReportServer, nil, data)
+ if err != nil {
+ return err
+ }
}
return nil
@@ -91,8 +96,6 @@
for {
select {
case <-ticker.C:
- logger.Debug("report device info.")
-
err := reportDeviceInfo()
if err != nil {
logger.Warn(err.Error())
diff --git a/vo/forward.go b/vo/forward.go
index 8318aba..c4592ac 100644
--- a/vo/forward.go
+++ b/vo/forward.go
@@ -5,20 +5,16 @@
}
type TaskResultInfo struct {
- Id string `json:"id"`
- CameraId string `json:"cameraId"`
- OrgName string `json:"orgName"` //鏈烘瀯鍚嶇О
- CameraAddr string `json:"cameraAddr"` //灏忓尯鍚嶇О
- CameraName string `json:"cameraName"` //鍏蜂綋浣嶇疆
- PicDate string `json:"picDate"`
- LikeDate string `json:"likeDate"`
- PicMaxUrl []string `json:"picMaxUrl"`
- TaskId string `json:"taskId"`
- AnalyServerId string `json:"analyServerId"`
- AnalyServerName string `json:"analyServerName"`
- AnalyServerIp string `json:"analyServerIp"`
- TargetInfo []TargetInfo `json:"targetInfo"`
- DataSource string `json:"dataSource"` // 鏁版嵁鏉ユ簮:鎽勫儚鏈�, 鏁版嵁鏍�
+ Id string `json:"id"`
+ CameraId string `json:"cameraId"`
+ CameraAddr string `json:"cameraAddr"` //灏忓尯鍚嶇О
+ CameraName string `json:"cameraName"` //鍏蜂綋浣嶇疆
+ PicDate string `json:"picDate"`
+ LikeDate string `json:"likeDate"`
+ PicMaxUrl []string `json:"picMaxUrl"`
+ AnalyServerId string `json:"analyServerId"`
+ TargetInfo []TargetInfo `json:"targetInfo"`
+ DataSource string `json:"dataSource"` // 鏁版嵁鏉ユ簮:鎽勫儚鏈�, 鏁版嵁鏍�
}
// es瑙嗛鍒嗘瀽鐨勬暟鎹粨鏋�
--
Gitblit v1.8.0