- SyncStoresCategory中改为并行任务

This commit is contained in:
gazebo
2019-09-09 17:29:25 +08:00
parent 13c9bb76d4
commit cf6bd1d5ea

View File

@@ -345,11 +345,13 @@ func (v *VendorSync) SyncStoresCategory(ctx *jxcontext.Context, db *dao.DaoDB, v
dao.SetStoreCategorySyncStatus(db, loopMapInfo.VendorID, storeIDs, nil, model.SyncFlagModifiedMask)
}
if len(loopMapInfo.StoreMapList) > 1 {
loopStoreTask := tasksch.NewSeqTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]), ctx,
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
_, err = v.proxySyncStoreCategory(ctx, task, loopMapInfo.StoreMapList[step], nil, nil, false, isContinueWhenError)
loopStoreTask := tasksch.NewParallelTask(fmt.Sprintf("处理平台%s", model.VendorChineseNames[loopMapInfo.VendorID]),
tasksch.NewParallelConfig().SetParallelCount(5).SetIsContinueWhenError(isContinueWhenError), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
storeMap := batchItemList[0].(*model.StoreMap)
_, err = v.proxySyncStoreCategory(ctx, task, storeMap, nil, nil, false, isContinueWhenError)
return nil, err
}, len(loopMapInfo.StoreMapList))
}, loopMapInfo.StoreMapList)
t.AddChild(loopStoreTask).Run()
_, err = loopStoreTask.GetResult(0)
} else {