This commit is contained in:
dongchangxi committed 2025-01-15 17:42:02 +08:00
commit 00983e5ff2
16 files changed
+61 -10

No files matched your search

+51 -2
View File
@@ -1,8 +1,11 @@
package api package api
import ( import (
"changeme/cameraFunc" "changeme/internal/logic/cameraFunc"
"changeme/util/response" "changeme/internal/logic/util/response"
"fmt"
"strings"
"sync"
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
) )
@@ -45,3 +48,49 @@ func DownLoadCameraJpg(r *ghttp.Request) {
response.SusJson(true, r, "下载成功") response.SusJson(true, r, "下载成功")
} }
} }
func DownLoadAllCameraJpg(r *ghttp.Request) {
fileType := r.Get("file_type").String()
ids := r.Get("ids").String()
if ids == "" {
response.FailJson(true, r, "参数错误")
return
}
arrIds := strings.Split(ids, ",")
arrDeviceId := []string{
"11", "12", "14", "22", "23", "32", "34", "42", "43", "52", "54", "62",
"63", "71", "72", "74", "82", "83", "92", "94", "102", "103", "112",
"114", "122", "123",
}
arrFail := make([]string, 0)
var wg sync.WaitGroup
var mu sync.Mutex
// 控制并发数,限制最大并发goroutine数量
sem := make(chan struct{}, 26) // 限制并发数为10
for _, id := range arrIds {
for _, deviceId := range arrDeviceId {
wg.Add(1)
go func(id, deviceId string) {
defer wg.Done()
// 控制并发数
sem <- struct{}{}
defer func() { <-sem }()
err := cameraFunc.DownLoadCameraJpgByFtp(id, deviceId, fileType)
if err != nil {
mu.Lock()
arrFail = append(arrFail, fmt.Sprintf("%s_%s-error-%s", id, deviceId, err.Error()))
mu.Unlock()
}
}(id, deviceId)
}
}
// 等待所有goroutine完成
wg.Wait()
// 所有下载成功
response.SusJson(true, r, "下载成功",arrFail)
}
+2 -2
View File
@@ -1,8 +1,8 @@
package api package api
import ( import (
"changeme/masterFunc" "changeme/internal/logic/masterFunc"
"changeme/util/response" "changeme/internal/logic/util/response"
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
) )
+3 -3
View File
@@ -1,9 +1,9 @@
package api package api
import ( import (
"changeme/db" "changeme/internal/logic/db"
"changeme/model" "changeme/internal/logic/util/response"
"changeme/util/response" "changeme/internal/model"
"github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/ghttp"
) )
File renamed without changes.
+1 -1
View File
@@ -1,7 +1,7 @@
package db package db
import ( import (
"changeme/model" "changeme/internal/model"
"database/sql" "database/sql"
"errors" "errors"
"fmt" "fmt"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4 -2
View File
@@ -2,7 +2,7 @@ package main
import ( import (
"changeme/api" "changeme/api"
"changeme/initFunc" "changeme/internal/logic/initFunc"
"context" "context"
"embed" "embed"
"strings" "strings"
@@ -57,8 +57,9 @@ func main() {
AppMenu := menu.NewMenu() AppMenu := menu.NewMenu()
SubMenu := AppMenu.AddSubmenu("工具") SubMenu := AppMenu.AddSubmenu("工具")
SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) { SubMenu.AddText("刷新", keys.CmdOrCtrl("F5"), func(_ *menu.CallbackData) {
// runtime.Reload(app.ctx)
runtime.WindowReloadApp(app.ctx) runtime.WindowReloadApp(app.ctx)
}) })
// Create application with options // Create application with options
@@ -119,6 +120,7 @@ func HttpServer(){
s.BindHandler("/update_take_photo",api.UpdateDbData) s.BindHandler("/update_take_photo",api.UpdateDbData)
s.BindHandler("/delete_take_photo",api.DeleteDbData) s.BindHandler("/delete_take_photo",api.DeleteDbData)
s.BindHandler("/download_camera_jpg",api.DownLoadCameraJpg) s.BindHandler("/download_camera_jpg",api.DownLoadCameraJpg)
s.BindHandler("/download_all_camera_jpg",api.DownLoadAllCameraJpg)
s.BindHandler("/download_master_jpg",api.DownLoadMasterJpg) s.BindHandler("/download_master_jpg",api.DownLoadMasterJpg)
s.SetPort(8383) s.SetPort(8383)