From 4710055072d7bd17ddea1b17cb658dc3406680c1 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:46:02 +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 | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/business/jxstore/yonghui/yonghui.go b/business/jxstore/yonghui/yonghui.go index 3ce7101ec..1ed74ef9f 100644 --- a/business/jxstore/yonghui/yonghui.go +++ b/business/jxstore/yonghui/yonghui.go @@ -97,12 +97,11 @@ 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 - goodsIDListForPutAwayInterface []interface{} - err2 error + skuMap = make(map[string]float64) + errMsg string + costPrice float64 //成本价 + goodsList []*weimobapi.GoodsInfo + goodsIDListForPutAway []interface{} ) db := dao.GetDB() taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { @@ -191,17 +190,18 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, Is retVal = []int64{goodsDetail.GoodsID} } } - if err == nil { + if 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) - if err2 != nil { - errMsg += err2.Error() + goodsIDListForPutAwayInterface, err2 := taskParallel3.GetResult(0) + if err = err2; err != nil { + return "", err } + goodsIDListForPutAway = goodsIDListForPutAwayInterface case 3: // 批量下架微盟商品 // if errMsg == "" { @@ -213,12 +213,15 @@ 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, goodsIDListForPutAwayInterface) + taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway) tasksch.HandleTask(taskParallel4, task, true).Run() _, err = taskParallel4.GetResult(0) // } } - return result, errors.New(errMsg) + if errMsg != "" { + return result, errors.New(errMsg) + } + return result, err } taskSeq := tasksch.NewSeqTask("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, taskSeqFunc, 4) tasksch.HandleTask(taskSeq, nil, true).Run()