读取永辉excel
This commit is contained in:
@@ -114,7 +114,7 @@ var (
|
||||
OrgSkuIdCol: 5,
|
||||
OrgSkuPriceCol: 8,
|
||||
OrgSkuNameCol: 6,
|
||||
SkuRow: 1,
|
||||
SkuRow: 2,
|
||||
}, "水果": &SheetParam{
|
||||
SkuIDCol: 0,
|
||||
SkuPriceCol: 14,
|
||||
@@ -133,12 +133,12 @@ var (
|
||||
SkuRow: 1,
|
||||
}, "净配": &SheetParam{
|
||||
SkuIDCol: 0,
|
||||
SkuPriceCol: 13,
|
||||
SkuPriceCol: 12,
|
||||
SkuNameCol: 1,
|
||||
OrgSkuIdCol: 4,
|
||||
OrgSkuPriceCol: 7,
|
||||
OrgSkuNameCol: 5,
|
||||
SkuRow: 2,
|
||||
SkuRow: 1,
|
||||
}, "水产": &SheetParam{
|
||||
SkuIDCol: 1,
|
||||
SkuPriceCol: 15,
|
||||
@@ -239,44 +239,43 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
costPrice float64 //成本价
|
||||
goodsList []*weimobapi.GoodsInfo
|
||||
goodsIDListForPutAway []interface{}
|
||||
isCompare bool
|
||||
// isCompare bool
|
||||
)
|
||||
db := dao.GetDB()
|
||||
//读取excel文件
|
||||
xlsx, err := excelize.OpenReader(reader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
for k := range sheetMap {
|
||||
sheetParam := sheetMap[k]
|
||||
rows, _ := xlsx.GetRows(k)
|
||||
for rowNum, row := range rows {
|
||||
if rowNum < sheetParam.SkuRow {
|
||||
continue
|
||||
}
|
||||
GetCellIntoMap(sheetParam, skuMap, row, k, rowNum)
|
||||
if len(skuMap) < 1 {
|
||||
errMsg += fmt.Sprintf("读取Excel数据失败,Excel格式排版可能发生了变化!sheetName: [%v]\n", k)
|
||||
}
|
||||
}
|
||||
if errMsg != "" {
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
}
|
||||
//修改分组名
|
||||
// 分类名格式为:可定XX日
|
||||
// XX为上传永辉 提供的 价格表时间 +2天
|
||||
// isCompare, err = UpdateClassifyAndGetLastClassify()
|
||||
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||
switch step {
|
||||
case 0:
|
||||
//读取excel文件
|
||||
xlsx, err := excelize.OpenReader(reader)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
for k := range sheetMap {
|
||||
sheetParam := sheetMap[k]
|
||||
rows, _ := xlsx.GetRows(k)
|
||||
for rowNum, row := range rows {
|
||||
if rowNum < sheetParam.SkuRow {
|
||||
continue
|
||||
}
|
||||
GetCellIntoMap(sheetParam, skuMap, row, k, rowNum)
|
||||
if len(skuMap) < 1 {
|
||||
errMsg += fmt.Sprintf("读取Excel数据失败,Excel格式排版可能发生了变化!sheetName: [%v]\n", k)
|
||||
}
|
||||
}
|
||||
if errMsg != "" {
|
||||
return "", errors.New(errMsg)
|
||||
}
|
||||
}
|
||||
//修改分组名
|
||||
// 分类名格式为:可定XX日
|
||||
// XX为上传永辉 提供的 价格表时间 +2天
|
||||
isCompare, err = UpdateClassifyAndGetLastClassify()
|
||||
case 1:
|
||||
//获取微盟所有商品
|
||||
param := &weimobapi.QueryGoodsListParam{
|
||||
PageNum: 1,
|
||||
PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||
}
|
||||
goodsList, err = GetWeiMobGoodsList(param)
|
||||
// param := &weimobapi.QueryGoodsListParam{
|
||||
// PageNum: 1,
|
||||
// PageSize: jdapi.MaxSkuIDsCount4QueryListBySkuIds,
|
||||
// }
|
||||
// goodsList, err = GetWeiMobGoodsList(param)
|
||||
if err != nil {
|
||||
baseapi.SugarLogger.Errorf("GetWeiMobGoodsList error:%v", err)
|
||||
}
|
||||
@@ -306,7 +305,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
// errMsg += fmt.Sprintf("在微盟上未找到该商品xxx", xxx)
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
case 1:
|
||||
//找出微盟上有,excel上没有的,有就更新,没有就下架
|
||||
taskFunc3 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
goods := batchItemList[0].(*weimobapi.GoodsInfo)
|
||||
@@ -353,7 +352,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
return "", err
|
||||
}
|
||||
goodsIDListForPutAway = goodsIDListForPutAwayInterface
|
||||
case 3:
|
||||
case 2:
|
||||
// 批量下架微盟商品
|
||||
taskFunc4 := func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
int64Slice := []int64{}
|
||||
@@ -368,7 +367,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
taskParallel4 := tasksch.NewParallelTask("下架微盟商品", tasksch.NewParallelConfig().SetParallelCount(parallelCount).SetBatchSize(UpdateGoodsShelfStatusCount), ctx, taskFunc4, goodsIDListForPutAway)
|
||||
tasksch.HandleTask(taskParallel4, task, true).Run()
|
||||
_, err = taskParallel4.GetResult(0)
|
||||
case 4:
|
||||
case 3:
|
||||
WriteToExcel(task, dataSuccess.dataSuccessList, dataFailed.dataFailedList)
|
||||
}
|
||||
// if errMsg != "" {
|
||||
@@ -376,7 +375,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
// }
|
||||
return result, err
|
||||
}
|
||||
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 5)
|
||||
taskSeq := tasksch.NewSeqTask2("读取永辉Excel文件修改微盟商品价格可售状态-序列任务", ctx, isContinueWhenError, taskSeqFunc, 4)
|
||||
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = taskSeq.GetResult(0)
|
||||
|
||||
Reference in New Issue
Block a user