更改目录结构
This commit is contained in:
1 parent
be6b954dba
commit
68415a3061
20 files changed
+116
-15
No files matched your search
+51
-2
@@ -1,8 +1,11 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"changeme/cameraFunc"
|
||||
"changeme/util/response"
|
||||
"changeme/internal/logic/cameraFunc"
|
||||
"changeme/internal/logic/util/response"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
@@ -44,4 +47,50 @@ func DownLoadCameraJpg(r *ghttp.Request) {
|
||||
}
|
||||
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)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"changeme/masterFunc"
|
||||
"changeme/util/response"
|
||||
"changeme/internal/logic/masterFunc"
|
||||
"changeme/internal/logic/util/response"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"changeme/db"
|
||||
"changeme/model"
|
||||
"changeme/util/response"
|
||||
"changeme/internal/logic/db"
|
||||
"changeme/internal/logic/util/response"
|
||||
"changeme/internal/model"
|
||||
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user