BY ROBIN AT 20240428
This commit is contained in:
parent
6bf1f9e472
commit
e8649e1111
|
@ -48,7 +48,7 @@ func Run(batchId string) (successNum int, failNum int, err error) {
|
|||
|
||||
// 2.创建请求
|
||||
// oss不在上海的服务器,需要调用Advance接口
|
||||
req, err := createScanImageAdvanceRequest(ctrlBlock)
|
||||
reqs, err := createScanImageAdvanceRequest(ctrlBlock)
|
||||
if err != nil {
|
||||
logger.Info("Create Scan ImageRequest fail: %v", err)
|
||||
handleBatchError(ctrlBlock, err)
|
||||
|
@ -60,7 +60,10 @@ func Run(batchId string) (successNum int, failNum int, err error) {
|
|||
runtime := &teautils.RuntimeOptions{
|
||||
ConnectTimeout: tea.Int(30000),
|
||||
}
|
||||
_result, err := defaultImageAuditClient.ScanImageAdvance(req, runtime)
|
||||
|
||||
for _, req := range reqs {
|
||||
var _result *imageaudit.ScanImageResponse
|
||||
_result, err = defaultImageAuditClient.ScanImageAdvance(req, runtime)
|
||||
if err != nil {
|
||||
if _t, ok := err.(*tea.SDKError); ok {
|
||||
logger.Error("ScanImageAdvance fail, errinfo : %v", util.DerefString(_t.Data))
|
||||
|
@ -73,12 +76,13 @@ func Run(batchId string) (successNum int, failNum int, err error) {
|
|||
|
||||
// 4.处理应答
|
||||
err = handleScanImageResponse(ctrlBlock, _result)
|
||||
}
|
||||
|
||||
successNum = len(imageaudittasks)
|
||||
return
|
||||
}
|
||||
|
||||
func createScanImageAdvanceRequest(ctrlBlock *ImageAuditTaskBatchControlBlock) (request *imageaudit.ScanImageAdvanceRequest, err error) {
|
||||
func createScanImageAdvanceRequest(ctrlBlock *ImageAuditTaskBatchControlBlock) (requests []*imageaudit.ScanImageAdvanceRequest, err error) {
|
||||
httpClient := http.Client{}
|
||||
imageauditIds := ctrlBlock.ImageAuditIds
|
||||
reqTasks := make([]*imageaudit.ScanImageAdvanceRequestTask, 0)
|
||||
|
@ -90,7 +94,6 @@ func createScanImageAdvanceRequest(ctrlBlock *ImageAuditTaskBatchControlBlock) (
|
|||
logger.Error("httpClient Get fail : %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
reqTasks = append(reqTasks, &imageaudit.ScanImageAdvanceRequestTask{
|
||||
DataId: goproto.String(imageauditIds[i]),
|
||||
ImageURLObject: file.Body,
|
||||
|
@ -101,10 +104,24 @@ func createScanImageAdvanceRequest(ctrlBlock *ImageAuditTaskBatchControlBlock) (
|
|||
})
|
||||
}
|
||||
|
||||
request = &imageaudit.ScanImageAdvanceRequest{
|
||||
// 阿里云一次最多审10条,将待审图片按10条拆分
|
||||
requests = make([]*imageaudit.ScanImageAdvanceRequest, 0)
|
||||
i := 0
|
||||
for ; i < len(reqTasks)/10; i++ {
|
||||
request := &imageaudit.ScanImageAdvanceRequest{
|
||||
Scene: scenes,
|
||||
Task: reqTasks,
|
||||
Task: reqTasks[i*10 : (i+1)*10],
|
||||
}
|
||||
requests = append(requests, request)
|
||||
}
|
||||
if i*10 < len(reqTasks) {
|
||||
request := &imageaudit.ScanImageAdvanceRequest{
|
||||
Scene: scenes,
|
||||
Task: reqTasks[i*10:],
|
||||
}
|
||||
requests = append(requests, request)
|
||||
}
|
||||
|
||||
logger.Info("本次打包:%v", reqs)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue