读取永辉excel

This commit is contained in:
苏尹岚
2019-11-18 17:26:20 +08:00
parent bfb3aa5b0e
commit ac8222c6e1

View File

@@ -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) { func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, IsContinueWhenError bool) (hint string, err error) {
var ( var (
skuMap = make(map[string]float64) skuMap = make(map[string]float64)
errMsg string errMsg string
costPrice float64 //成本价 costPrice float64 //成本价
goodsList []*weimobapi.GoodsInfo goodsList []*weimobapi.GoodsInfo
goodsIDListForPutAway []interface{} goodsIDListForPutAwayInterface []interface{}
err2 error
) )
db := dao.GetDB() db := dao.GetDB()
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { 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 { if err == nil {
return retVal, errors.New(errMsg + errTmp) return retVal, errors.New(errTmp)
} }
return retVal, err return retVal, err
} }
taskParallel3 := tasksch.NewParallelTask("根据获取的微盟所有商品并更新", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(IsContinueWhenError), ctx, taskFunc3, goodsList) taskParallel3 := tasksch.NewParallelTask("根据获取的微盟所有商品并更新", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetIsContinueWhenError(IsContinueWhenError), ctx, taskFunc3, goodsList)
tasksch.HandleTask(taskParallel3, task, true).Run() tasksch.HandleTask(taskParallel3, task, true).Run()
goodsIDListForPutAwayInterface, err2 := taskParallel3.GetResult(0) goodsIDListForPutAwayInterface, err2 = taskParallel3.GetResult(0)
if err = err2; err != nil { if err = err2; err != nil {
return "", err return "", err
} }
// 批量下架微盟商品
goodsIDListForPutAway = goodsIDListForPutAwayInterface
case 3: case 3:
// 批量下架微盟商品
// if errMsg == "" { // if errMsg == "" {
taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) { taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
int64Slice := []int64{} int64Slice := []int64{}
@@ -213,11 +213,14 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, Is
PutAwayWeiMobSku(int64Slice) PutAwayWeiMobSku(int64Slice)
return retVal, err 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() tasksch.HandleTask(taskParallel4, task, true).Run()
_, err = taskParallel4.GetResult(0) _, err = taskParallel4.GetResult(0)
// } // }
} }
if err == nil {
return result, errors.New(errMsg + err2.Error())
}
return result, err return result, err
} }
taskSeq := tasksch.NewSeqTask("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, taskSeqFunc, 4) taskSeq := tasksch.NewSeqTask("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, taskSeqFunc, 4)