From ac8222c6e1598f9f5377073b1ddb16efafaaac23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 18 Nov 2019 17:26:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B0=B8=E8=BE=89excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxstore/yonghui/yonghui.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 6975d4a9c..060d311ec 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -97,11 +97,12 @@ func LoadExcelByYongHui(ctx *jxcontext.Context, files []*multipart.FileHeader, i func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, IsContinueWhenError bool) (hint string, err error) { var ( - skuMap = make(map[string]float64) - errMsg string - costPrice float64 //成本价 - goodsList []*weimobapi.GoodsInfo - goodsIDListForPutAway []interface{} + skuMap = make(map[string]float64) + errMsg string + costPrice float64 //成本价 + goodsList []*weimobapi.GoodsInfo + goodsIDListForPutAwayInterface []interface{} + err2 error ) db := dao.GetDB() taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { @@ -191,19 +192,18 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, Is } } if err == nil { - return retVal, errors.New(errMsg + errTmp) + return retVal, errors.New(errTmp) } return retVal, err } taskParallel3 := tasksch.NewParallelTask("根据获取的微盟所有商品并更新", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(IsContinueWhenError), ctx, taskFunc3, goodsList) tasksch.HandleTask(taskParallel3, task, true).Run() - goodsIDListForPutAwayInterface, err2 := taskParallel3.GetResult(0) + goodsIDListForPutAwayInterface, err2 = taskParallel3.GetResult(0) if err = err2; err != nil { return "", err } - // 批量下架微盟商品 - goodsIDListForPutAway = goodsIDListForPutAwayInterface case 3: + // 批量下架微盟商品 // if errMsg == "" { taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { int64Slice := []int64{} @@ -213,11 +213,14 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, Is PutAwayWeiMobSku(int64Slice) return retVal, err } - taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) + taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAwayInterface) tasksch.HandleTask(taskParallel4, task, true).Run() _, err = taskParallel4.GetResult(0) // } } + if err == nil { + return result, errors.New(errMsg + err2.Error()) + } return result, err } taskSeq := tasksch.NewSeqTask("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, taskSeqFunc, 4)