读取永辉excel
This commit is contained in:
@@ -39,12 +39,12 @@ type SheetParam struct {
|
||||
}
|
||||
|
||||
type DataSuccessLock struct {
|
||||
dataSuccessList []*DataSuccess
|
||||
dataSuccessList []DataSuccess
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
type DataFailedLock struct {
|
||||
dataFailedList []*DataFailed
|
||||
dataFailedList []DataFailed
|
||||
locker sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -152,13 +152,13 @@ const (
|
||||
fileExt = ".xlsx"
|
||||
)
|
||||
|
||||
func (d *DataSuccessLock) AppendData(dataSuccess *DataSuccess) {
|
||||
func (d *DataSuccessLock) AppendData(dataSuccess DataSuccess) {
|
||||
d.locker.Lock()
|
||||
defer d.locker.Unlock()
|
||||
d.dataSuccessList = append(d.dataSuccessList, dataSuccess)
|
||||
}
|
||||
|
||||
func (d *DataFailedLock) AppendData2(dataFailed *DataFailed) {
|
||||
func (d *DataFailedLock) AppendData2(dataFailed DataFailed) {
|
||||
d.locker.Lock()
|
||||
defer d.locker.Unlock()
|
||||
d.dataFailedList = append(d.dataFailedList, dataFailed)
|
||||
@@ -236,7 +236,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
for k, _ := range skuMap {
|
||||
//表示excel上有,微盟上没有
|
||||
if goodsInfoAndDetailMap[k] == nil {
|
||||
outPutData := &DataFailed{
|
||||
outPutData := DataFailed{
|
||||
GoodsID: k,
|
||||
GoodsName: skuMap[k].Name,
|
||||
Comment: "在微盟上未找到该商品",
|
||||
@@ -257,7 +257,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
//获取京西库商品
|
||||
skuList, _ := dao.GetSkus(db, nil, []int{int(utils.Str2Int64(goodsDetail.SkuMap.SingleSku.OuterSkuCode))}, nil, nil)
|
||||
if len(skuList) == 0 {
|
||||
outPutData := &DataFailed{
|
||||
outPutData := DataFailed{
|
||||
GoodsID: spuCode,
|
||||
GoodsName: skuMap[spuCode].Name,
|
||||
Comment: "在京西库中未找到该商品",
|
||||
@@ -277,7 +277,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
_, _, err = updateWeiMobGoods(costPrice, skuMap[spuCode].Price, isCompare, goodsDetail)
|
||||
if err != nil {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
outPutData := &DataFailed{
|
||||
outPutData := DataFailed{
|
||||
GoodsID: spuCode,
|
||||
GoodsName: skuMap[spuCode].Name,
|
||||
Comment: errExt.ErrMsg(),
|
||||
@@ -285,7 +285,7 @@ func LoadExcelBinByYongHui(ctx *jxcontext.Context, reader io.Reader, isAsync, is
|
||||
dataFailed.AppendData2(outPutData)
|
||||
}
|
||||
} else {
|
||||
outPutData := &DataSuccess{
|
||||
outPutData := DataSuccess{
|
||||
NameID: goodsDetail.SkuMap.SingleSku.OuterSkuCode,
|
||||
Name: goodsDetail.Title,
|
||||
Unit: skuList[0].Unit,
|
||||
@@ -665,7 +665,7 @@ func GetReplaceNewTitle(title, prefix string) (newTitle string) {
|
||||
}
|
||||
}
|
||||
|
||||
func WriteToExcel(task *tasksch.SeqTask, dataSuccess []*DataSuccess, dataFailed []*DataFailed) (err error) {
|
||||
func WriteToExcel(task *tasksch.SeqTask, dataSuccess []DataSuccess, dataFailed []DataFailed) (err error) {
|
||||
var sheetList1 []*excel.Obj2ExcelSheetConfig
|
||||
var sheetList2 []*excel.Obj2ExcelSheetConfig
|
||||
var downloadURL1, downloadURL2, fileName1, fileName2 string
|
||||
|
||||
Reference in New Issue
Block a user