记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
72892b21
Commit
72892b21
authored
Nov 10, 2022
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
~api:店铺商品管理:批量导入数据;
parent
3fc7d2f6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
82 deletions
+115
-82
GoblinGoodsImportDto.java
...om/liquidnet/service/goblin/dto/GoblinGoodsImportDto.java
+16
-11
GoblinStoreMgtGoodsImportController.java
...ontroller/manage/GoblinStoreMgtGoodsImportController.java
+4
-3
GoblinStoreMgtGoodsImportService.java
...service/impl/manage/GoblinStoreMgtGoodsImportService.java
+95
-68
No files found.
liquidnet-bus-api/liquidnet-service-goblin-api/src/main/java/com/liquidnet/service/goblin/dto/GoblinGoodsImportDto.java
View file @
72892b21
...
@@ -8,26 +8,31 @@ import java.util.List;
...
@@ -8,26 +8,31 @@ import java.util.List;
@Data
@Data
public
class
GoblinGoodsImportDto
{
public
class
GoblinGoodsImportDto
{
@ExcelProperty
(
value
=
"商品编码"
)
@ExcelProperty
(
value
=
"商品编码"
,
index
=
0
)
private
String
spuCode
;
private
String
spuCode
;
@ExcelProperty
(
value
=
"商品名称"
)
@ExcelProperty
(
value
=
"商品名称"
,
index
=
1
)
private
String
spuName
;
private
String
spuName
;
@ExcelProperty
(
value
=
"商品图片"
)
@ExcelProperty
(
value
=
"商品图片"
,
index
=
2
)
private
String
spuImgs
;
private
String
spuImgs
;
private
List
<
String
>
spuImgList
;
private
List
<
String
>
spuImgList
;
//
@ExcelProperty
(
value
=
"商品规格"
)
@ExcelProperty
(
value
=
"商品规格"
,
index
=
3
)
private
String
skuSpec
;
private
String
skuSpec
;
private
List
<
GoblinGoodsSpecDto
>
skuSpecDtos
;
private
List
<
GoblinGoodsSpecDto
>
skuSpecDtos
;
//
@ExcelProperty
(
value
=
"规格编码"
)
@ExcelProperty
(
value
=
"规格编码"
,
index
=
4
)
private
String
skuCode
;
private
String
skuCode
;
@ExcelProperty
(
value
=
"价格"
)
@ExcelProperty
(
value
=
"价格"
,
index
=
5
)
private
BigDecimal
price
;
private
BigDecimal
price
;
@ExcelProperty
(
value
=
"库存"
)
@ExcelProperty
(
value
=
"库存"
,
index
=
6
)
private
Integer
stock
;
private
Integer
stock
;
@ExcelProperty
(
value
=
"规格图片"
)
@ExcelProperty
(
value
=
"规格图片"
,
index
=
7
)
private
String
skuImg
;
private
String
skuImg
;
@ExcelProperty
(
value
=
"规格条码"
)
@ExcelProperty
(
value
=
"规格条码"
,
index
=
8
)
private
String
skuBarCode
;
private
String
skuBarCode
;
// @ExcelProperty(value = "商品条码")
// @ExcelProperty(value = "商品条码")
// private String spuBarCode;
// private String spuBarCode;
private
String
failureReason
;
//
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/controller/manage/GoblinStoreMgtGoodsImportController.java
View file @
72892b21
...
@@ -48,10 +48,11 @@ public class GoblinStoreMgtGoodsImportController {
...
@@ -48,10 +48,11 @@ public class GoblinStoreMgtGoodsImportController {
if
(!
goblinRedisUtils
.
redisUtil
.
lock
(
GoblinRedisConst
.
BASIC_GOODS_SKU
.
concat
(
"lk"
).
concat
(
storeId
),
1
,
30
))
{
if
(!
goblinRedisUtils
.
redisUtil
.
lock
(
GoblinRedisConst
.
BASIC_GOODS_SKU
.
concat
(
"lk"
).
concat
(
storeId
),
1
,
30
))
{
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140000"
));
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"140000"
));
}
}
String
analysisResultMsg
;
try
{
try
{
switch
(
dataType
)
{
switch
(
dataType
)
{
case
1
:
case
1
:
goblinStoreMgtGoodsImportService
.
goodsInformationDataAnalysisProcessing
(
file
,
currentUid
,
storeId
);
analysisResultMsg
=
goblinStoreMgtGoodsImportService
.
goodsInformationDataAnalysisProcessing
(
file
,
currentUid
,
storeId
);
break
;
break
;
case
2
:
case
2
:
default
:
default
:
...
@@ -61,8 +62,8 @@ public class GoblinStoreMgtGoodsImportController {
...
@@ -61,8 +62,8 @@ public class GoblinStoreMgtGoodsImportController {
return
ResponseDto
.
failure
(
e
.
getMessage
());
return
ResponseDto
.
failure
(
e
.
getMessage
());
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},dataType={},fileName={}]"
,
currentUid
,
dataType
,
file
.
getOriginalFilename
(),
e
);
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},dataType={},fileName={}]"
,
currentUid
,
dataType
,
file
.
getOriginalFilename
(),
e
);
return
ResponseDto
.
failure
(
"数据
错
误,解析失败"
);
return
ResponseDto
.
failure
(
"数据
有
误,解析失败"
);
}
}
return
ResponseDto
.
success
();
return
ResponseDto
.
success
(
analysisResultMsg
);
}
}
}
}
liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/service/impl/manage/GoblinStoreMgtGoodsImportService.java
View file @
72892b21
...
@@ -158,12 +158,12 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -158,12 +158,12 @@ public class GoblinStoreMgtGoodsImportService {
/* 校验|------------------------------------------------------------------------------ */
/* 校验|------------------------------------------------------------------------------ */
}
}
public
void
goodsInformationDataAnalysisProcessing
(
MultipartFile
file
,
String
uid
,
String
storeId
)
throws
IOException
{
public
String
goodsInformationDataAnalysisProcessing
(
MultipartFile
file
,
String
uid
,
String
storeId
)
throws
IOException
{
List
<
String
>
skuBarCodeTmpList
=
CollectionUtil
.
arrayListString
();
AnalysisEventListener
<
GoblinGoodsImportDto
>
analysisEventListener
=
new
AnalysisEventListener
<
GoblinGoodsImportDto
>()
{
List
<
GoblinGoodsInfoVo
>
goodsInfoVos
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
()
;
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
;
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
()
;
List
<
GoblinGoodsInfoVo
>
goodsInfoVos
;
List
<
String
>
skuBarCodeTmpList
;
EasyExcel
.
read
(
file
.
getInputStream
(),
GoblinGoodsImportDto
.
class
,
new
AnalysisEventListener
<
GoblinGoodsImportDto
>()
{
LocalDateTime
now
;
@Override
@Override
public
void
onException
(
Exception
exception
,
AnalysisContext
context
)
throws
Exception
{
public
void
onException
(
Exception
exception
,
AnalysisContext
context
)
throws
Exception
{
...
@@ -181,7 +181,14 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -181,7 +181,14 @@ public class GoblinStoreMgtGoodsImportService {
if
(
approximateTotalRowNumber
>
501
)
{
if
(
approximateTotalRowNumber
>
501
)
{
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},storeId={},totalRowNumber={}]"
,
uid
,
storeId
,
approximateTotalRowNumber
);
log
.
warn
(
"店铺商品管理:批量导入数据:异常[UID={},storeId={},totalRowNumber={}]"
,
uid
,
storeId
,
approximateTotalRowNumber
);
throw
new
LiquidnetServiceException
(
"-1"
,
"超出总行数限制500"
);
throw
new
LiquidnetServiceException
(
"-1"
,
"超出总行数限制500"
);
}
else
if
(
approximateTotalRowNumber
<=
1
)
{
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
}
}
goodsSkuInfoVos
=
ObjectUtil
.
getGoblinGoodsSkuInfoVoArrayList
();
goodsInfoVos
=
ObjectUtil
.
goblinGoodsInfoVoArrayList
();
skuBarCodeTmpList
=
CollectionUtil
.
arrayListString
();
now
=
LocalDateTime
.
now
();
super
.
invokeHead
(
headMap
,
context
);
super
.
invokeHead
(
headMap
,
context
);
}
}
...
@@ -192,19 +199,27 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -192,19 +199,27 @@ public class GoblinStoreMgtGoodsImportService {
goodsInformationDataAnalysisProcessingValid
(
dto
,
skuBarCodeTmpList
,
rowIndex
+
1
);
goodsInformationDataAnalysisProcessingValid
(
dto
,
skuBarCodeTmpList
,
rowIndex
+
1
);
GoblinGoodsInfoVo
lastGoodsInfoVo
=
CollectionUtils
.
isEmpty
(
goodsInfoVos
)
?
null
:
goodsInfoVos
.
get
(
goodsInfoVos
.
size
()
-
1
);
GoblinGoodsInfoVo
lastGoodsInfoVo
=
CollectionUtils
.
isEmpty
(
goodsInfoVos
)
?
null
:
goodsInfoVos
.
get
(
goodsInfoVos
.
size
()
-
1
);
GoblinGoodsInfoVo
goodsInfoVo
=
goodsInformationDataAnalysisProcessingForSpu
(
dto
,
lastGoodsInfoVo
,
uid
,
storeId
,
LocalDateTime
.
now
()
,
goodsSkuInfoVos
);
GoblinGoodsInfoVo
goodsInfoVo
=
goodsInformationDataAnalysisProcessingForSpu
(
dto
,
lastGoodsInfoVo
,
uid
,
storeId
,
now
,
goodsSkuInfoVos
);
if
(
null
!=
goodsInfoVo
)
{
if
(
null
!=
goodsInfoVo
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"dt2:{}"
,
goodsInfoVo
);
log
.
debug
(
"dt2:{}"
,
goodsInfoVo
);
}
goodsInfoVos
.
add
(
goodsInfoVo
);
goodsInfoVos
.
add
(
goodsInfoVo
);
}
}
dto
.
setSkuSpecDtos
(
null
);
dto
.
setSpuImgList
(
null
);
}
}
@Override
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
// 解析完成...
public
void
doAfterAllAnalysed
(
AnalysisContext
analysisContext
)
{
// 解析完成...
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"dt3-1:{}"
,
JsonUtils
.
toJson
(
goodsInfoVos
));
log
.
debug
(
"dt3-1:{}"
,
JsonUtils
.
toJson
(
goodsInfoVos
));
log
.
debug
(
"dt3-2:{}"
,
JsonUtils
.
toJson
(
goodsSkuInfoVos
));
log
.
debug
(
"dt3-2:{}"
,
JsonUtils
.
toJson
(
goodsSkuInfoVos
));
}
if
(!
CollectionUtils
.
isEmpty
(
goodsInfoVos
))
{
List
<
String
>
existGoodsSkuNoList
=
goblinMongoUtils
.
existGoodsSkuNoBySkuNoList
(
storeId
,
skuBarCodeTmpList
);
List
<
String
>
existGoodsSkuNoList
=
goblinMongoUtils
.
existGoodsSkuNoBySkuNoList
(
storeId
,
skuBarCodeTmpList
);
if
(!
CollectionUtils
.
isEmpty
(
existGoodsSkuNoList
))
{
if
(!
CollectionUtils
.
isEmpty
(
existGoodsSkuNoList
))
{
if
(
existGoodsSkuNoList
.
size
()
>
3
)
{
if
(
existGoodsSkuNoList
.
size
()
>
3
)
{
...
@@ -271,13 +286,25 @@ public class GoblinStoreMgtGoodsImportService {
...
@@ -271,13 +286,25 @@ public class GoblinStoreMgtGoodsImportService {
if
(
initGoodsSkuObjs
.
size
()
>
0
)
{
if
(
initGoodsSkuObjs
.
size
()
>
0
)
{
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
queueUtils
.
sendMsgByRedis
(
MQConst
.
GoblinQueue
.
SQL_GOODS
.
getKey
(),
SqlMapping
.
gets
(
toMqSqls
,
initGoodsSkuObjs
,
initGoodsSkuSpecValueObjs
));
}
}
}
}
}
}).
sheet
(
0
).
doReadSync
();
};
List
<
GoblinGoodsImportDto
>
readDtoList
=
EasyExcel
.
read
(
file
.
getInputStream
(),
GoblinGoodsImportDto
.
class
,
analysisEventListener
).
sheet
(
0
).
doReadSync
();
if
(
CollectionUtils
.
isEmpty
(
readDtoList
))
{
throw
new
LiquidnetServiceException
(
"-1"
,
"导入文件不能为空"
);
}
long
failureRows
=
readDtoList
.
stream
().
filter
(
r
->
StringUtils
.
isNotEmpty
(
r
.
getFailureReason
())).
count
();
String
analysisResultMsg
=
String
.
format
(
"导入成功%s条数据,导入失败%s条数据"
,
readDtoList
.
size
()
-
failureRows
,
failureRows
);
log
.
info
(
"DT-IN:[storeId={},uid={},fileName={},readResult:{}]"
,
uid
,
storeId
,
file
.
getOriginalFilename
(),
analysisResultMsg
);
return
analysisResultMsg
;
}
}
private
GoblinGoodsInfoVo
goodsInformationDataAnalysisProcessingForSpu
(
GoblinGoodsImportDto
dt
,
GoblinGoodsInfoVo
lastGoodsInfoVo
,
String
uid
,
String
storeId
,
LocalDateTime
now
,
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
)
{
private
GoblinGoodsInfoVo
goodsInformationDataAnalysisProcessingForSpu
(
GoblinGoodsImportDto
dt
,
GoblinGoodsInfoVo
lastGoodsInfoVo
,
String
uid
,
String
storeId
,
LocalDateTime
now
,
List
<
GoblinGoodsSkuInfoVo
>
goodsSkuInfoVos
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"dt1:{}"
,
dt
.
toString
());
log
.
debug
(
"dt1:{}"
,
dt
.
toString
());
}
boolean
tobeNextSpuFlg
=
false
;
boolean
tobeNextSpuFlg
=
false
;
if
(
null
==
lastGoodsInfoVo
||
!
lastGoodsInfoVo
.
getName
().
equals
(
dt
.
getSpuName
()))
{
if
(
null
==
lastGoodsInfoVo
||
!
lastGoodsInfoVo
.
getName
().
equals
(
dt
.
getSpuName
()))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment